Skip to content

Commit 04d2e08

Browse files
danoli3Marcel Ruegenberg
andauthored
OpenGLES 3.1 (#8533)
* Android: sync NDK / API / build-tools with apothecary Match apothecary's Android CI (build-android.yml, android_configure.sh) so the core, the template and the prebuilt libs use the same toolchain: - NDK r29 29.0.14206865 (template + core gradle ndkVersion, cmake.sh, of.yml env); previously 28.2 in gradle, "27" / newest folder in cmake.sh and the runner's latest NDK in CI - min API 25 (template was 24, core gradle and cmake.sh were 34, so the core wouldn't load below Android 14) - build-tools 37.0.0 (was 35.0.0) - cmake.sh: use the pinned $NDK under the SDK (or ANDROID_NDK_ROOT / ANDROID_NDK_HOME) instead of silently taking the newest ndk folder, which also picked up half-installed NDKs; ANDROID_PLATFORM follows ANDROID_API; honour ANDROID_HOME / ANDROID_SDK_ROOT on macOS - android.toolchain.cmake: NDKs ship only darwin-x86_64 (universal) / linux-x86_64, so fall back to the x86_64 prebuilt when the arm64 host folder doesn't exist (failed on Apple silicon before) * Enable new functionality of GL ES 2/3/3.1 via ifdefs * Android Studio 1.3/1.4 compatibility, and a fix. * Get an OpenGL ES 3.1 context if possible. * Fixes. * Misc fixes * Minor fixes when using GLES1. * More consistent API. * Update EGL window class to use new GLES settings class. TODO: iOS * Fixed problem with broken textures. * Smaller fixes * . * Remove old android changes * ofImageType * ofGLRenderer * ofGLUtils fix * Update ofAppEGLWindow.cpp * OpenGLES 3 changes for ofFbo and ofGLProgrammableRenderer * Refactor GLES version variables in ofGLESWindowSettings * OpenGLES 3.0 and Emscripten * ofBufferObject OpenGLES 3 fixes * ofVbo and ofFbo OpenGLES 3 fixes * ofWindowSettings fix for scope * OpenGLES 3 fixes for ofGLProgrammableRenderer and BaseTypes * OpenGLES 3 * OpenGLES fixes * OpenGLES shader defaults fixed * ofMaterial fixes * Android Window * ofAppAndroidWindow Fix * ofAppAndroidWindow * Android Window * ofGLUtils Android Fix * OpenGLES 3.0 # Conflicts: # libs/openFrameworks/gl/ofGLProgrammableRenderer.cpp * ofWindowSettings with hidpi c++ default cpy ctor * OpenGLES defines with targetable undefs in ofConstants * ofMesh Mode to Triangles on init * ofShader Fix * OpenGL fixes * Update Emscripten to 6.0.6 * Fix client-side mesh indices on OpenGL ES 2 * Restore line topology for ofMesh axis * Guard desktop buffer invalidation on OpenGL ES * Android View null fix * Add Android GLES lifecycle hardware stress test * Make GL smoke tests safe on ES1, ES2, ES3 and desktop OpenGL The shared test always called drawInstanced, which is not in ES1/ES2 or GL 2.1, and the programmable GLES path never instanced even on ES3 (gated on 3.1, and ofVboMesh ignored primCount). Skip instancing unless the live context is GL 3.1+ / ES 3.0+, match VBO index type to ofIndexType on GLES, report WebGL2 as GLES 3, and give the Android lifecycle test ES2 shaders / an ES1 no-shader path. * Fix PR compile failures across all CI platforms - ofGraphics/ofGLRenderer: revert background-gradient relocation that used ofVboMesh without its header and dropped the renderer's drawBackgroundGradient definition (broke every build + link) - ofGraphics: revert illegal static_cast to ofBaseGLRenderer in ofEnable/DisablePointSprites, virtual dispatch already covers it - ofAppEGLWindow: rename glesVersion member to glesVersionMajor to match ofAppEGLWindow.cpp usage - ofAppAndroidWindow: drop dead overwrite of glesVersion from legacy field so settings getters take effect, init glesVersionMinor - ofxEmscriptenURLFileLoader: restore lowercase __EMSCRIPTEN_major__/ __EMSCRIPTEN_minor__ macros (uppercase form is never defined) - ofTexture: restore GL_TEXTURE_CUBE_MAP mipmap case on desktop, align bindAsImage cpp guard with header - ofConstants: make GLES3 includes live (unconditional on Linux ARM and Emscripten, API-gated on Android) so TARGET_OPENGLES_3 auto-detection actually works * Fix GLES regressions found testing ES 1.1 / 2.0 / 3.0 on iOS - ofFbo::readToPixels: GLES has no glGetTexImage (ES 1/2/3), so the ES 3 branch returned empty pixels; read the bound FBO with glReadPixels on all GLES again, selecting the attachment with glReadBuffer on ES 3 contexts. - ofGLProgrammableRenderer::draw(ofMesh) on ES: line modes use the lines shader, which needs the line bundle; raw client arrays made GL_LINE_STRIP / GL_LINE_LOOP (circle and polyline outlines) collapse to nothing. Build the bundle like desktop (ofSetLineWidth works on ES again). - ofFbo::allocate(w, h, format): keep colour-only on ES; the combined depth+stencil renderbuffer was FRAMEBUFFER_INCOMPLETE_ATTACHMENT. - TARGET_OPENGLES_3 only means the ES 3 headers exist, which is true on iOS even for ES 1 / ES 2 contexts. Add ofIsGLES3Context() (headers + live context >= 3) and use it for sized RGBA8 / RGB8 internal formats (ES 2 rejects them with GL_INVALID_OPERATION); ofFbo::checkGLSupport accepts GL_OES_framebuffer_object for ES 1.1 contexts. * ofFbo: only accept GL_OES_framebuffer_object for ES 1.1 on iOS On Android an ES 1 context has no GLES2 entry points, so glGenFramebuffers resolved to a null function pointer and ofFbo::allocate crashed (SIGSEGV, pc 0) on ES 1.1 contexts. iOS shares one GL library across ES versions, so the OES path stays enabled there; Android ES 1.1 now reports FBOs as unsupported instead of crashing. * Fix GL_INVALID_ENUM on ES 1 / ES 2 contexts Found with a glGetError trace after every setup/draw step on the Android emulator (ES 1.1) and iOS Simulator (ES 1.1 / 2.0): - ofGLRenderer: loadViewMatrix / enableLighting / setLightPosition / setLightSpotDirection queried glGetIntegerv(GL_MATRIX_MODE), which some ES 1.1 drivers reject, then restored glMatrixMode() from the uninitialised result (two errors per setupScreen, every frame). Restore the matrix mode oF already tracks in matrixStack instead. - ofTexture::loadData: on ES 1.1 (fixed function) the Android emulator rejects glTexSubImage2D with GL_LUMINANCE / GL_LUMINANCE_ALPHA / GL_ALPHA and leaves the texture empty, so ofDrawBitmapString drew nothing. Full-size updates re-specify the level with glTexImage2D. - ofFbo::checkGLSupport: GL_MAX_COLOR_ATTACHMENTS / GL_MAX_DRAW_BUFFERS / GL_MAX_SAMPLES are ES 3 queries; on ES 1 / ES 2 contexts built with ES 3 headers (iOS) use 1 / 1 / 0 instead of querying. Now zero GL errors on macOS GL 2.1 / 3.2, iOS ES 1.1 / 2.0 / 3.0 and Android ES 1.1 / 2.0 / 3.0 / 3.1. * Android ES 1.1: OES framebuffer entry points, disabled on the emulator On Android an ES 1.1 context provides FBOs through GL_OES_framebuffer_object in libGLESv1_CM (glGenFramebuffersOES, ...); the core names resolve to libGLESv2 and are null in an ES 1 context. Add ofGLFramebuffer.h with ofGLGenFramebuffers / ofGLBindFramebuffer / ... wrappers that call the OES entry points on Android fixed-function contexts and the core names everywhere else (enum values are identical), and use them in ofFbo, ofGLRenderer and ofTexture (generateMipmap). The Android emulator's ES 1 driver (goldfish GLESv1_enc) advertises the extension but can't be used: glDeleteFramebuffersOES crashes (GLClientState::removeFramebuffers locks renderbuffer state that is only set up for ES 2+) and rebinding framebuffer 0 doesn't return drawing to the window. ofIsAndroidEmulatorGLES1() detects it from GL_RENDERER; ofGLRenderer::setup() logs a startup warning that FBOs won't work on the emulator with ES 1.1 but will on devices, and ofFbo reports them as unsupported there. --------- Co-authored-by: Marcel Ruegenberg <ruegenbe@in.tum.de>
1 parent b08f95a commit 04d2e08

41 files changed

Lines changed: 2220 additions & 1620 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎addons/ofxAndroid/Java/cc/openframeworks/OFAndroidLifeCycleHelper.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,14 +273,14 @@ public static void onResume(){
273273
OFAndroid.onStart();
274274
}
275275
}
276-
else if( glView.getRenderer() == null){
276+
else if(glView == null || glView.getRenderer() == null){
277277
Log.w(TAG,"onResume glView is null or not setup");
278278
OFAndroid.setupGL(OFAndroid.eglVersion, true);
279279
if(OFAndroidLifeCycle.coreLibraryLoaded && OFAndroidLifeCycle.appLibraryLoaded) {
280280
OFAndroid.onStart();
281281
}
282282
}
283-
else if( glView != null && glView.getDisplay() == null) {
283+
else if(glView.getDisplay() == null) {
284284
Log.w(TAG,"onResume glView has a null display");
285285
OFAndroid.setupGL(OFAndroid.eglVersion, true);
286286
if(OFAndroidLifeCycle.coreLibraryLoaded && OFAndroidLifeCycle.appLibraryLoaded) {

‎addons/ofxAndroid/src/ofAppAndroidWindow.cpp‎

Lines changed: 54 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,27 @@ ofAppAndroidWindow::ofAppAndroidWindow() {
122122
window = this;
123123
msaaSamples = 1;
124124
glesVersion = 2;
125-
125+
glesVersionMinor = 0;
126+
#ifdef TARGET_PROGRAMMABLE_GL
127+
#ifdef GL_ES_VERSION_3_0
128+
glesVersion = 3;
129+
#ifdef GL_ES_VERSION_3_1
130+
glesVersionMinor = 1;
131+
#endif
132+
#else
133+
glesVersion = 2;
134+
#endif
135+
#else
136+
glesVersion = 1;
137+
#endif
126138
ofGetMainLoop()->setCurrentWindow(this);
127139
}
128140

129141
ofAppAndroidWindow::ofAppAndroidWindow(ofAppBaseWindow & other) {
130142
window = this;
131143
msaaSamples = 1;
132144
glesVersion = 2;
145+
glesVersionMinor = 0;
133146
setMultiWindowMode(other.getWindowMode());
134147
ofGetMainLoop()->setCurrentWindow(this);
135148
}
@@ -164,47 +177,44 @@ ofAppAndroidWindow::~ofAppAndroidWindow() {
164177
// TODO Auto-generated destructor stub
165178
}
166179

180+
167181
bool ofAppAndroidWindow::isSurfaceDestroyed() {
168182
return surfaceDestroyed;
169183
}
170184

171185
void ofAppAndroidWindow::setup(const ofGLESWindowSettings & settings)
172186
{
187+
glesVersion = settings.getGLESVersionMajor();
188+
glesVersionMinor = settings.getGLESVersionMinor();
173189
setup( (const ofxAndroidWindowSettings &)settings );
174190
}
175191

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

194+
glesVersion = settings.getGLESVersionMajor();
195+
glesVersionMinor = settings.getGLESVersionMinor();
178196
if(window == nullptr) {
179197
ofLogError("ofAppAndroidWindow") << "Setup and Window is nullptr ! Fixing";
180198
setCurrentWindow();
181199
}
182-
glesVersion = settings.glesVersion;
183200
ofLogError("ofAppAndroidWindow") << "Setup OpenGLES:" << glesVersion;
184201
if(glesVersion<2){
185202
currentRenderer = std::make_shared<ofGLRenderer>(this);
186203
}else{
187204
currentRenderer = std::make_shared<ofGLProgrammableRenderer>(this);
188205
}
189-
190206
jclass javaClass = ofGetJNIEnv()->FindClass("cc/openframeworks/OFAndroid");
191-
192207
if(javaClass==nullptr){
193208
ofLogError("ofAppAndroidWindow") << "setupOpenGL(): couldn't find OFAndroid java class";
194209
return;
195210
}
196-
197211
makeCurrent();
198-
199212
jmethodID method = ofGetJNIEnv()->GetStaticMethodID(javaClass,"setupGL","(IZ)V");
200213
if(!method){
201214
ofLogError("ofAppAndroidWindow") << "setupOpenGL(): couldn't find OFAndroid setupGL method";
202215
return;
203216
}
204-
205217
ofGetJNIEnv()->CallStaticVoidMethod(javaClass,method,glesVersion,settings.preserveContextOnPause);
206-
207-
208218
}
209219

210220
void ofAppAndroidWindow::update(){
@@ -330,6 +340,10 @@ int ofAppAndroidWindow::getGlesVersion()
330340
return glesVersion;
331341
}
332342

343+
int ofAppAndroidWindow::getGlesVersionMinor()
344+
{
345+
return glesVersionMinor;
346+
}
333347

334348
extern "C"{
335349

@@ -443,57 +457,46 @@ Java_cc_openframeworks_OFAndroid_onSurfaceDestroyed( JNIEnv* env, jclass thiz
443457
}
444458
}
445459

460+
446461
JNIEXPORT void JNICALL
447-
Java_cc_openframeworks_OFAndroid_onSurfaceCreated( JNIEnv* env, jclass thiz ){
448-
if(appSetup){
449-
ofLogVerbose("ofAppAndroidWindow") << "onSurfaceCreated";
450-
if(!surfaceDestroyed){
451-
ofNotifyEvent(ofxAndroidEvents().unloadGL);
452-
}
453-
ofNotifyEvent(ofxAndroidEvents().reloadGL);
454-
window->renderer()->pushStyle();
455-
window->renderer()->setupGraphicDefaults();
456-
window->renderer()->popStyle();
457-
window->setThreadedEvents(false);
458-
int glesVersion = window->getGlesVersion();
459-
bSetupScreen = true;
460-
if( glesVersion < 2 )
461-
{
462-
ofLogVerbose("ofAppAndroidWindow") << "onSurfaceCreated OpenGLES 1";
463-
dynamic_cast<ofGLRenderer*>(window->renderer().get())->setup();
464-
}
465-
else
466-
{
467-
ofLogVerbose("ofAppAndroidWindow") << "onSurfaceCreated OpenGLES 2.0";
468-
dynamic_cast<ofGLProgrammableRenderer*>(window->renderer().get())->setup(glesVersion,0);
469-
}
462+
Java_cc_openframeworks_OFAndroid_onSurfaceCreated( JNIEnv* env, jclass thiz ){
463+
ofLogVerbose("ofAppAndroidWindow") << "onSurfaceCreated";
470464

471-
}else{
472-
if(window != nullptr) {
473-
int glesVersion = window->getGlesVersion();
474-
bSetupScreen = true;
475-
if (glesVersion < 2) {
476-
ofLogVerbose("ofAppAndroidWindow") << "onSurfaceCreated OpenGLES 1";
477-
dynamic_cast<ofGLRenderer *>(window->renderer().get())->setup();
478-
} else {
479-
ofLogVerbose("ofAppAndroidWindow") << "onSurfaceCreated OpenGLES 2.0";
480-
dynamic_cast<ofGLProgrammableRenderer *>(window->renderer().get())->setup(
481-
glesVersion, 0);
482-
}
483-
}
484-
}
465+
if(!surfaceDestroyed && appSetup){
466+
ofNotifyEvent(ofxAndroidEvents().unloadGL);
467+
}
468+
ofNotifyEvent(ofxAndroidEvents().reloadGL);
469+
470+
if(appSetup){
471+
window->renderer()->pushStyle();
472+
window->renderer()->setupGraphicDefaults();
473+
window->renderer()->popStyle();
474+
window->setThreadedEvents(false);
475+
}
476+
477+
bSetupScreen = true;
478+
int glesVersion = window->getGlesVersion();
479+
int glesVersionMinor = window->getGlesVersionMinor();
480+
481+
if(glesVersion < 2){
482+
ofLogVerbose("ofAppAndroidWindow") << "onSurfaceCreated OpenGLES 1";
483+
dynamic_cast<ofGLRenderer*>(window->renderer().get())->setup();
484+
}else{
485+
ofLogVerbose("ofAppAndroidWindow") << "onSurfaceCreated OpenGLES 2.0+";
486+
dynamic_cast<ofGLProgrammableRenderer*>(window->renderer().get())->setup(glesVersion, glesVersionMinor);
487+
}
485488

486-
surfaceDestroyed = false;
489+
surfaceDestroyed = false;
487490
}
488491

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

492-
if(window != nullptr && window->renderer() != nullptr) {
493-
return true;
494-
} else {
495+
if(window != nullptr && window->renderer() != nullptr) {
496+
return true;
497+
} else {
495498
return false;
496-
}
499+
}
497500
}
498501

499502
JNIEXPORT void JNICALL
@@ -554,25 +557,19 @@ Java_cc_openframeworks_OFAndroid_setAssetManager(JNIEnv *env, jclass thiz,
554557
jobject jAssetManager) {
555558

556559
env->NewGlobalRef(jAssetManager);
557-
558560
AAssetManager *aaAssetManager = AAssetManager_fromJava(env, jAssetManager);
559561
if (aaAssetManager == nullptr) {
560562
ofLogError("ofAppAndroidWindow") << "Could not obtain the AAssetManager";
561563
return;
562564
}
563-
564565
assetManager = aaAssetManager;
565566

566567
if(window == nullptr || (window != nullptr && window->renderer() == nullptr)) {
567568
ofLogVerbose("ofAppAndroidWindow") << "setAssetManager window is null";
568569
return;
569570
}
570-
571571
window->setAssetManager(assetManager);
572572

573-
574-
575-
576573
}
577574

578575
/* Call to render the next GL frame */

‎addons/ofxAndroid/src/ofAppAndroidWindow.h‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,20 @@ class ofAppAndroidWindow: public ofAppBaseGLESWindow {
110110

111111

112112
int getGlesVersion();
113+
int getGlesVersionMinor();
113114

114115
AAssetManager& getAssetManager();
115116
void setAssetManager(AAssetManager* assetManager);
116117

118+
int glesVersion;
119+
int glesVersionMinor;
120+
117121

118122

119123
private:
120124
ofCoreEvents coreEvents;
121125
std::shared_ptr<ofBaseRenderer> currentRenderer;
122-
int glesVersion;
126+
123127
int msaaSamples;
124128
AAssetManager* assetManager = nullptr;
125129

‎addons/ofxAndroid/src/ofxAndroidVideoGrabber.cpp‎

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -132,35 +132,34 @@ ofxAndroidVideoGrabber::Data::~Data(){
132132
}
133133

134134
void ofxAndroidVideoGrabber::Data::loadTexture(){
135-
ofTextureData td;
136-
GLuint texId[1];
137-
glGenTextures(1, texId);
138-
139-
glEnable(GL_TEXTURE_EXTERNAL_OES);
140-
glBindTexture(GL_TEXTURE_EXTERNAL_OES, texId[0]);
141-
142-
glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
143-
glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
144-
glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
145-
glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
146-
if (!ofIsGLProgrammableRenderer()) {
147-
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
148-
}
135+
ofTextureData td;
136+
GLuint texId[1];
137+
glGenTextures(1, texId);
138+
139+
glEnable(GL_TEXTURE_EXTERNAL_OES);
140+
glBindTexture(GL_TEXTURE_EXTERNAL_OES, texId[0]);
149141

150-
glDisable(GL_TEXTURE_EXTERNAL_OES);
142+
glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
143+
glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
144+
glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
145+
glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
151146

152-
// Set the externally created texture reference
153-
texture.setUseExternalTextureID(texId[0]);
154-
texture.texData.width = width;
155-
texture.texData.height = height;
156-
texture.texData.tex_w = width;
157-
texture.texData.tex_h = height;
158-
texture.texData.tex_t = 1; // Hack!
159-
texture.texData.tex_u = 1;
160-
texture.texData.textureTarget = GL_TEXTURE_EXTERNAL_OES;
161-
texture.texData.glInternalFormat = GL_RGBA;
147+
#ifndef TARGET_PROGRAMMABLE_GL
148+
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
149+
#endif
162150

151+
glDisable(GL_TEXTURE_EXTERNAL_OES);
163152

153+
// Set the externally created texture reference
154+
texture.setUseExternalTextureID(texId[0]);
155+
texture.texData.width = width;
156+
texture.texData.height = height;
157+
texture.texData.tex_w = width;
158+
texture.texData.tex_h = height;
159+
texture.texData.tex_t = 1; // Hack!
160+
texture.texData.tex_u = 1;
161+
texture.texData.textureTarget = GL_TEXTURE_EXTERNAL_OES;
162+
texture.texData.glInternalFormat = GL_RGBA;
164163
}
165164

166165

@@ -262,7 +261,7 @@ void ofxAndroidVideoGrabber::close(){
262261
} else {
263262
ofLogError("ofxAndroidVideoGrabber") << "close(): couldn't get OFAndroidVideoGrabber close grabber method";
264263
}
265-
264+
266265
data->bGrabberInited = false;
267266
}
268267

‎addons/ofxAndroid/src/ofxAndroidVideoPlayer.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ void ofxAndroidVideoPlayer::reloadTexture(){
2626
glTexParameterf(texture.texData.textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
2727
glTexParameterf(texture.texData.textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
2828
glTexParameterf(texture.texData.textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
29+
#ifndef TARGET_PROGRAMMABLE_GL
2930
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
31+
#endif
3032

3133
glDisable(texture.texData.textureTarget);
3234

‎addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,18 @@ void ofxAppEmscriptenWindow::setup(const ofGLESWindowSettings & settings){
4747
attrs.alpha = 0;
4848

4949
context = emscripten_webgl_create_context("#canvas", &attrs);
50+
int glesMajor = 3; // WebGL 2 == GLES 3
51+
if (!context) {
52+
attrs.majorVersion = 1;
53+
context = emscripten_webgl_create_context("#canvas", &attrs);
54+
glesMajor = 2; // WebGL 1 == GLES 2
55+
}
5056
assert(context);
5157

5258
makeCurrent();
5359

5460
_renderer = std::make_shared<ofGLProgrammableRenderer>(this);
55-
((ofGLProgrammableRenderer*)_renderer.get())->setup(2,0);
61+
((ofGLProgrammableRenderer*)_renderer.get())->setup(glesMajor, 0);
5662

5763
emscripten_set_keydown_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW,this,useCapture,&keydown_cb);
5864
emscripten_set_keyup_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW,this,useCapture,&keyup_cb);
@@ -363,7 +369,7 @@ EM_BOOL ofxAppEmscriptenWindow::mousedown_cb(int eventType, const EmscriptenMous
363369
return true;
364370
}
365371
EM_BOOL ofxAppEmscriptenWindow::rescale(int* x, int* y) {
366-
372+
return false;
367373
}
368374

369375
//------------------------------------------------------------

‎addons/ofxEmscripten/src/ofxEmscriptenURLFileLoader.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ ofHttpResponse ofxEmscriptenURLFileLoader::get(const string & url){
2424

2525
int ofxEmscriptenURLFileLoader::getAsync(const string & url, const string & name){
2626
ofHttpRequest * req = new ofHttpRequest(url,name,false);
27-
#if __EMSCRIPTEN_major__>1 || (__EMSCRIPTEN_major__==1 && __EMSCRIPTEN_minor__>22)
27+
#if __EMSCRIPTEN_major__ > 1 || (__EMSCRIPTEN_major__ == 1 && __EMSCRIPTEN_minor__ > 22)
2828
emscripten_async_wget2_data(url.c_str(), "GET", "", req, true, &onload_cb, &onerror_cb, NULL);
2929
#endif
3030
return req->getId();
@@ -37,7 +37,7 @@ ofHttpResponse ofxEmscriptenURLFileLoader::saveTo(const string & url, const of::
3737

3838
int ofxEmscriptenURLFileLoader::saveAsync(const string & url, const of::filesystem::path & path){
3939
ofHttpRequest * req = new ofHttpRequest(url,url,true);
40-
#if __EMSCRIPTEN_major__>1 || (__EMSCRIPTEN_major__==1 && __EMSCRIPTEN_minor__>22)
40+
#if __EMSCRIPTEN_major__ > 1 || (__EMSCRIPTEN_major__ == 1 && __EMSCRIPTEN_minor__ > 22)
4141
emscripten_async_wget2(url.c_str(), path.c_str(), "GET", "", req, &onload_file_cb, &onerror_file_cb, NULL);
4242
#endif
4343
return 0;

‎apps/myApps/.gitignore‎

Whitespace-only changes.

0 commit comments

Comments
 (0)