Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9d98a43
Enable new functionality of GL ES 2/3/3.1 via ifdefs
Sep 6, 2015
0ca6b92
Android Studio 1.3/1.4 compatibility, and a fix.
Sep 6, 2015
5387cab
Get an OpenGL ES 3.1 context if possible.
Sep 8, 2015
5722bed
Fixes.
Sep 8, 2015
f0eb239
Misc fixes
Sep 12, 2015
681c528
Minor fixes when using GLES1.
Sep 17, 2015
0298e3f
More consistent API.
Sep 17, 2015
959fde7
Update EGL window class to use new GLES settings class.
Sep 17, 2015
358c266
Fixed problem with broken textures.
Sep 18, 2015
90fd1ae
Smaller fixes
Sep 30, 2015
e3ca877
.
Sep 30, 2015
45e936b
Remove old android changes
danoli3 Apr 6, 2026
0050001
ofImageType
danoli3 Apr 7, 2026
1f1c5f2
ofGLRenderer
danoli3 Apr 7, 2026
45e3974
Update ofAppEGLWindow.cpp
danoli3 Apr 7, 2026
9641d7c
ofGLUtils fix
danoli3 Apr 7, 2026
310f840
Merge commit '45e3974d59dbea6d29b757d7f6bd4d00f8ca840b' into OpenGLES3
danoli3 Apr 7, 2026
8c80fc8
OpenGLES 3 changes for ofFbo and ofGLProgrammableRenderer
danoli3 Apr 7, 2026
03bbcee
Refactor GLES version variables in ofGLESWindowSettings
danoli3 Apr 7, 2026
e38707b
OpenGLES 3.0 and Emscripten
danoli3 Apr 7, 2026
0150608
ofBufferObject OpenGLES 3 fixes
danoli3 Apr 8, 2026
4c14964
ofVbo and ofFbo OpenGLES 3 fixes
danoli3 Apr 8, 2026
be38559
ofWindowSettings fix for scope
danoli3 Apr 8, 2026
0e76c6c
OpenGLES 3 fixes for ofGLProgrammableRenderer and BaseTypes
danoli3 Apr 8, 2026
af4c34e
OpenGLES 3
danoli3 Apr 8, 2026
2d65880
OpenGLES fixes
danoli3 Apr 8, 2026
ef91f76
OpenGLES shader defaults fixed
danoli3 Apr 8, 2026
bd1d234
ofMaterial fixes
danoli3 Apr 8, 2026
2f5c374
Android Window
danoli3 Apr 8, 2026
5130bd0
ofAppAndroidWindow Fix
danoli3 Apr 8, 2026
9dca43f
ofAppAndroidWindow
danoli3 Apr 8, 2026
3a6b3cd
Android Window
danoli3 Apr 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 53 additions & 56 deletions addons/ofxAndroid/src/ofAppAndroidWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,19 @@ ofAppAndroidWindow::ofAppAndroidWindow() {
window = this;
msaaSamples = 1;
glesVersion = 2;

#ifdef TARGET_PROGRAMMABLE_GL
#ifdef GL_ES_VERSION_3_0
glesVersion = 3;
#ifdef GL_ES_VERSION_3_1
glesVersionMinor = 1;
#endif
#else
glesVersion = 2;
#endif
#else
glesVersion = 1;
#endif
window = this;
ofGetMainLoop()->setCurrentWindow(this);
}

Expand Down Expand Up @@ -164,17 +176,22 @@ ofAppAndroidWindow::~ofAppAndroidWindow() {
// TODO Auto-generated destructor stub
}


bool ofAppAndroidWindow::isSurfaceDestroyed() {
return surfaceDestroyed;
}

void ofAppAndroidWindow::setup(const ofGLESWindowSettings & settings)
{
glesVersion = settings.getGLESVersionMajor();
glesVersionMinor = settings.getGLESVersionMinor();
setup( (const ofxAndroidWindowSettings &)settings );
}

void ofAppAndroidWindow::setup(const ofxAndroidWindowSettings & settings){

glesVersion = settings.getGLESVersionMajor();
glesVersionMinor = settings.getGLESVersionMinor();
if(window == nullptr) {
ofLogError("ofAppAndroidWindow") << "Setup and Window is nullptr ! Fixing";
setCurrentWindow();
Expand All @@ -186,25 +203,18 @@ void ofAppAndroidWindow::setup(const ofxAndroidWindowSettings & settings){
}else{
currentRenderer = std::make_shared<ofGLProgrammableRenderer>(this);
}

jclass javaClass = ofGetJNIEnv()->FindClass("cc/openframeworks/OFAndroid");

if(javaClass==nullptr){
ofLogError("ofAppAndroidWindow") << "setupOpenGL(): couldn't find OFAndroid java class";
return;
}

makeCurrent();

jmethodID method = ofGetJNIEnv()->GetStaticMethodID(javaClass,"setupGL","(IZ)V");
if(!method){
ofLogError("ofAppAndroidWindow") << "setupOpenGL(): couldn't find OFAndroid setupGL method";
return;
}

ofGetJNIEnv()->CallStaticVoidMethod(javaClass,method,glesVersion,settings.preserveContextOnPause);


}

void ofAppAndroidWindow::update(){
Expand Down Expand Up @@ -330,6 +340,10 @@ int ofAppAndroidWindow::getGlesVersion()
return glesVersion;
}

int ofAppAndroidWindow::getGlesVersionMinor()
{
return glesVersionMinor;
}

extern "C"{

Expand Down Expand Up @@ -443,57 +457,46 @@ Java_cc_openframeworks_OFAndroid_onSurfaceDestroyed( JNIEnv* env, jclass thiz
}
}


JNIEXPORT void JNICALL
Java_cc_openframeworks_OFAndroid_onSurfaceCreated( JNIEnv* env, jclass thiz ){
if(appSetup){
ofLogVerbose("ofAppAndroidWindow") << "onSurfaceCreated";
if(!surfaceDestroyed){
ofNotifyEvent(ofxAndroidEvents().unloadGL);
}
ofNotifyEvent(ofxAndroidEvents().reloadGL);
window->renderer()->pushStyle();
window->renderer()->setupGraphicDefaults();
window->renderer()->popStyle();
window->setThreadedEvents(false);
int glesVersion = window->getGlesVersion();
bSetupScreen = true;
if( glesVersion < 2 )
{
ofLogVerbose("ofAppAndroidWindow") << "onSurfaceCreated OpenGLES 1";
dynamic_cast<ofGLRenderer*>(window->renderer().get())->setup();
}
else
{
ofLogVerbose("ofAppAndroidWindow") << "onSurfaceCreated OpenGLES 2.0";
dynamic_cast<ofGLProgrammableRenderer*>(window->renderer().get())->setup(glesVersion,0);
}
Java_cc_openframeworks_OFAndroid_onSurfaceCreated( JNIEnv* env, jclass thiz ){
ofLogVerbose("ofAppAndroidWindow") << "onSurfaceCreated";

}else{
if(window != nullptr) {
int glesVersion = window->getGlesVersion();
bSetupScreen = true;
if (glesVersion < 2) {
ofLogVerbose("ofAppAndroidWindow") << "onSurfaceCreated OpenGLES 1";
dynamic_cast<ofGLRenderer *>(window->renderer().get())->setup();
} else {
ofLogVerbose("ofAppAndroidWindow") << "onSurfaceCreated OpenGLES 2.0";
dynamic_cast<ofGLProgrammableRenderer *>(window->renderer().get())->setup(
glesVersion, 0);
}
}
}
if(!surfaceDestroyed && appSetup){
ofNotifyEvent(ofxAndroidEvents().unloadGL);
}
ofNotifyEvent(ofxAndroidEvents().reloadGL);

if(appSetup){
window->renderer()->pushStyle();
window->renderer()->setupGraphicDefaults();
window->renderer()->popStyle();
window->setThreadedEvents(false);
}

bSetupScreen = true;
int glesVersion = window->getGlesVersion();
int glesVersionMinor = window->getGlesVersionMinor();

if(glesVersion < 2){
ofLogVerbose("ofAppAndroidWindow") << "onSurfaceCreated OpenGLES 1";
dynamic_cast<ofGLRenderer*>(window->renderer().get())->setup();
}else{
ofLogVerbose("ofAppAndroidWindow") << "onSurfaceCreated OpenGLES 2.0+";
dynamic_cast<ofGLProgrammableRenderer*>(window->renderer().get())->setup(glesVersion, glesVersionMinor);
}

surfaceDestroyed = false;
surfaceDestroyed = false;
}

JNIEXPORT jboolean JNICALL
Java_cc_openframeworks_OFAndroid_isWindowReady( JNIEnv* env, jclass thiz) {

if(window != nullptr && window->renderer() != nullptr) {
return true;
} else {
if(window != nullptr && window->renderer() != nullptr) {
return true;
} else {
return false;
}
}
}

JNIEXPORT void JNICALL
Expand Down Expand Up @@ -554,25 +557,19 @@ Java_cc_openframeworks_OFAndroid_setAssetManager(JNIEnv *env, jclass thiz,
jobject jAssetManager) {

env->NewGlobalRef(jAssetManager);

AAssetManager *aaAssetManager = AAssetManager_fromJava(env, jAssetManager);
if (aaAssetManager == nullptr) {
ofLogError("ofAppAndroidWindow") << "Could not obtain the AAssetManager";
return;
}

assetManager = aaAssetManager;

if(window == nullptr || (window != nullptr && window->renderer() == nullptr)) {
ofLogVerbose("ofAppAndroidWindow") << "setAssetManager window is null";
return;
}

window->setAssetManager(assetManager);




}

/* Call to render the next GL frame */
Expand Down
6 changes: 5 additions & 1 deletion addons/ofxAndroid/src/ofAppAndroidWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,20 @@ class ofAppAndroidWindow: public ofAppBaseGLESWindow {


int getGlesVersion();
int getGlesVersionMinor();

AAssetManager& getAssetManager();
void setAssetManager(AAssetManager* assetManager);

int glesVersion;
int glesVersionMinor;



private:
ofCoreEvents coreEvents;
std::shared_ptr<ofBaseRenderer> currentRenderer;
int glesVersion;

int msaaSamples;
AAssetManager* assetManager = nullptr;

Expand Down
51 changes: 25 additions & 26 deletions addons/ofxAndroid/src/ofxAndroidVideoGrabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,35 +132,34 @@ ofxAndroidVideoGrabber::Data::~Data(){
}

void ofxAndroidVideoGrabber::Data::loadTexture(){
ofTextureData td;
GLuint texId[1];
glGenTextures(1, texId);

glEnable(GL_TEXTURE_EXTERNAL_OES);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, texId[0]);

glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
if (!ofIsGLProgrammableRenderer()) {
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
ofTextureData td;
GLuint texId[1];
glGenTextures(1, texId);

glEnable(GL_TEXTURE_EXTERNAL_OES);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, texId[0]);

glDisable(GL_TEXTURE_EXTERNAL_OES);
glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

// Set the externally created texture reference
texture.setUseExternalTextureID(texId[0]);
texture.texData.width = width;
texture.texData.height = height;
texture.texData.tex_w = width;
texture.texData.tex_h = height;
texture.texData.tex_t = 1; // Hack!
texture.texData.tex_u = 1;
texture.texData.textureTarget = GL_TEXTURE_EXTERNAL_OES;
texture.texData.glInternalFormat = GL_RGBA;
#ifndef TARGET_PROGRAMMABLE_GL
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
#endif

glDisable(GL_TEXTURE_EXTERNAL_OES);

// Set the externally created texture reference
texture.setUseExternalTextureID(texId[0]);
texture.texData.width = width;
texture.texData.height = height;
texture.texData.tex_w = width;
texture.texData.tex_h = height;
texture.texData.tex_t = 1; // Hack!
texture.texData.tex_u = 1;
texture.texData.textureTarget = GL_TEXTURE_EXTERNAL_OES;
texture.texData.glInternalFormat = GL_RGBA;
}


Expand Down Expand Up @@ -262,7 +261,7 @@ void ofxAndroidVideoGrabber::close(){
} else {
ofLogError("ofxAndroidVideoGrabber") << "close(): couldn't get OFAndroidVideoGrabber close grabber method";
}

data->bGrabberInited = false;
}

Expand Down
2 changes: 2 additions & 0 deletions addons/ofxAndroid/src/ofxAndroidVideoPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ void ofxAndroidVideoPlayer::reloadTexture(){
glTexParameterf(texture.texData.textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(texture.texData.textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(texture.texData.textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
#ifndef TARGET_PROGRAMMABLE_GL
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
#endif

glDisable(texture.texData.textureTarget);

Expand Down
Loading
Loading