diff --git a/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp b/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp index be3f9d663cf..d67de5826c2 100644 --- a/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp +++ b/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp @@ -10,6 +10,10 @@ #include "ofEvents.h" #include "ofGLProgrammableRenderer.h" +#ifndef OF_WEBGL_VERSION +#define OF_WEBGL_VERSION 2 +#endif + using namespace std; ofxAppEmscriptenWindow * ofxAppEmscriptenWindow::instance = NULL; @@ -38,7 +42,7 @@ void ofxAppEmscriptenWindow::setup(const ofGLESWindowSettings & settings){ attrs.depth = 1; attrs.stencil = 1; attrs.antialias = 1; - attrs.majorVersion = 2; + attrs.majorVersion = OF_WEBGL_VERSION; attrs.minorVersion = 0; attrs.alpha = 0; diff --git a/addons/ofxiOS/src/ofxiOSConstants.h b/addons/ofxiOS/src/ofxiOSConstants.h index 516c04519be..7f81073f79b 100644 --- a/addons/ofxiOS/src/ofxiOSConstants.h +++ b/addons/ofxiOS/src/ofxiOSConstants.h @@ -68,6 +68,11 @@ enum ofxiOSRendererType { OFXIOS_RENDERER_METAL = 4 }; +// OF_GLES_VERSION=1|2|3 in the project defines to override or in projectGenerator from 0.99.0 +#ifndef OF_GLES_VERSION +#define OF_GLES_VERSION OFXIOS_RENDERER_ES2 +#endif + enum ofxiOSWindowControllerType{ CORE_ANIMATION = 1, GL_KIT = 2, diff --git a/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk b/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk index 1c633c942da..9cda101fb32 100644 --- a/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk +++ b/libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk @@ -124,7 +124,12 @@ ifneq ($(strip $(wildcard bin/data/*)),) PLATFORM_LDFLAGS += --preload-file bin/data@data endif PLATFORM_LDFLAGS += --use-port=emdawnwebgpu +# PROJECT_DEFINES += OF_WEBGL_VERSION=1 in config.make for a WebGL 1 only build (default WebGL 2) +ifneq ($(filter OF_WEBGL_VERSION=1,$(PROJECT_DEFINES)),) +PLATFORM_LDFLAGS += -s MAX_WEBGL_VERSION=1 -s FULL_ES2 +else PLATFORM_LDFLAGS += -s MAX_WEBGL_VERSION=2 -s WEBGL2_BACKWARDS_COMPATIBILITY_EMULATION=1 -s FULL_ES3 +endif PLATFORM_LDFLAGS += -s AUTO_NATIVE_LIBRARIES=1 PLATFORM_LDFLAGS += -s AUTO_JS_LIBRARIES=1 diff --git a/scripts/templates/ios/src/main.mm b/scripts/templates/ios/src/main.mm index 4aa96717b78..b4d84d3eb4b 100644 --- a/scripts/templates/ios/src/main.mm +++ b/scripts/templates/ios/src/main.mm @@ -1,5 +1,9 @@ #include "ofApp.h" +#ifndef OF_GLES_VERSION +#define OF_GLES_VERSION OFXIOS_RENDERER_ES2 +#endif + int main() { // here are the most commonly used iOS window settings. @@ -11,7 +15,7 @@ int main() { settings.numOfAntiAliasingSamples = 0; // number of samples used for anti-aliasing. settings.enableHardwareOrientation = false; // enables native view orientation. settings.enableHardwareOrientationAnimation = false; // enables native orientation changes to be animated. - settings.glesVersion = OFXIOS_RENDERER_ES2; // type of renderer to use, ES1, ES2, ES3 + settings.glesVersion = OF_GLES_VERSION; // type of renderer to use, ES1, ES2, ES3 - default ES2, set via OF_GLES_VERSION define settings.windowControllerType = ofxiOSWindowControllerType::GL_KIT; // Window Controller Type settings.colorType = ofxiOSRendererColorFormat::RGBA8888; // color format used default RGBA8888 settings.depthType = ofxiOSRendererDepthFormat::DEPTH_NONE; // depth format (16/24) if depth enabled diff --git a/scripts/templates/linux/src/main.cpp b/scripts/templates/linux/src/main.cpp index 4e6518d49dc..9b9203fcad7 100644 --- a/scripts/templates/linux/src/main.cpp +++ b/scripts/templates/linux/src/main.cpp @@ -9,6 +9,10 @@ int main( ){ settings.setSize(1024, 768); settings.windowMode = OF_WINDOW; //can also be OF_FULLSCREEN +#if defined(OF_GL_VERSION_MAJOR) && defined(OF_GL_VERSION_MINOR) + settings.setGLVersion(OF_GL_VERSION_MAJOR, OF_GL_VERSION_MINOR); // set via projectGenerator OpenGL version +#endif + auto window = ofCreateWindow(settings); ofRunApp(window, std::make_shared()); diff --git a/scripts/templates/linux64/src/main.cpp b/scripts/templates/linux64/src/main.cpp index 4e6518d49dc..9b9203fcad7 100644 --- a/scripts/templates/linux64/src/main.cpp +++ b/scripts/templates/linux64/src/main.cpp @@ -9,6 +9,10 @@ int main( ){ settings.setSize(1024, 768); settings.windowMode = OF_WINDOW; //can also be OF_FULLSCREEN +#if defined(OF_GL_VERSION_MAJOR) && defined(OF_GL_VERSION_MINOR) + settings.setGLVersion(OF_GL_VERSION_MAJOR, OF_GL_VERSION_MINOR); // set via projectGenerator OpenGL version +#endif + auto window = ofCreateWindow(settings); ofRunApp(window, std::make_shared()); diff --git a/scripts/templates/linuxarmv6l/src/main.cpp b/scripts/templates/linuxarmv6l/src/main.cpp index 4e6518d49dc..9b9203fcad7 100644 --- a/scripts/templates/linuxarmv6l/src/main.cpp +++ b/scripts/templates/linuxarmv6l/src/main.cpp @@ -9,6 +9,10 @@ int main( ){ settings.setSize(1024, 768); settings.windowMode = OF_WINDOW; //can also be OF_FULLSCREEN +#if defined(OF_GL_VERSION_MAJOR) && defined(OF_GL_VERSION_MINOR) + settings.setGLVersion(OF_GL_VERSION_MAJOR, OF_GL_VERSION_MINOR); // set via projectGenerator OpenGL version +#endif + auto window = ofCreateWindow(settings); ofRunApp(window, std::make_shared()); diff --git a/scripts/templates/linuxarmv7l/src/main.cpp b/scripts/templates/linuxarmv7l/src/main.cpp index 4e6518d49dc..9b9203fcad7 100644 --- a/scripts/templates/linuxarmv7l/src/main.cpp +++ b/scripts/templates/linuxarmv7l/src/main.cpp @@ -9,6 +9,10 @@ int main( ){ settings.setSize(1024, 768); settings.windowMode = OF_WINDOW; //can also be OF_FULLSCREEN +#if defined(OF_GL_VERSION_MAJOR) && defined(OF_GL_VERSION_MINOR) + settings.setGLVersion(OF_GL_VERSION_MAJOR, OF_GL_VERSION_MINOR); // set via projectGenerator OpenGL version +#endif + auto window = ofCreateWindow(settings); ofRunApp(window, std::make_shared()); diff --git a/scripts/templates/msys2/src/main.cpp b/scripts/templates/msys2/src/main.cpp index 4e6518d49dc..9b9203fcad7 100644 --- a/scripts/templates/msys2/src/main.cpp +++ b/scripts/templates/msys2/src/main.cpp @@ -9,6 +9,10 @@ int main( ){ settings.setSize(1024, 768); settings.windowMode = OF_WINDOW; //can also be OF_FULLSCREEN +#if defined(OF_GL_VERSION_MAJOR) && defined(OF_GL_VERSION_MINOR) + settings.setGLVersion(OF_GL_VERSION_MAJOR, OF_GL_VERSION_MINOR); // set via projectGenerator OpenGL version +#endif + auto window = ofCreateWindow(settings); ofRunApp(window, std::make_shared()); diff --git a/scripts/templates/osx/src/main.cpp b/scripts/templates/osx/src/main.cpp index 4e6518d49dc..9b9203fcad7 100644 --- a/scripts/templates/osx/src/main.cpp +++ b/scripts/templates/osx/src/main.cpp @@ -9,6 +9,10 @@ int main( ){ settings.setSize(1024, 768); settings.windowMode = OF_WINDOW; //can also be OF_FULLSCREEN +#if defined(OF_GL_VERSION_MAJOR) && defined(OF_GL_VERSION_MINOR) + settings.setGLVersion(OF_GL_VERSION_MAJOR, OF_GL_VERSION_MINOR); // set via projectGenerator OpenGL version +#endif + auto window = ofCreateWindow(settings); ofRunApp(window, std::make_shared()); diff --git a/scripts/templates/tvOS/src/main.mm b/scripts/templates/tvOS/src/main.mm index 7a44a4c64df..56c8bd89054 100644 --- a/scripts/templates/tvOS/src/main.mm +++ b/scripts/templates/tvOS/src/main.mm @@ -1,5 +1,9 @@ #include "ofApp.h" +#ifndef OF_GLES_VERSION +#define OF_GLES_VERSION OFXIOS_RENDERER_ES2 +#endif + int main() { // here are the most commonly used iOS window settings. @@ -11,7 +15,7 @@ int main() { settings.numOfAntiAliasingSamples = 0; // number of samples used for anti-aliasing. settings.enableHardwareOrientation = false; // enables native view orientation. settings.enableHardwareOrientationAnimation = false; // enables native orientation changes to be animated. - settings.glesVersion = OFXIOS_RENDERER_ES2; // type of renderer to use, ES1, ES2, ES3 + settings.glesVersion = OF_GLES_VERSION; // type of renderer to use, ES1, ES2, ES3 - default ES2, set via OF_GLES_VERSION define settings.windowControllerType = ofxiOSWindowControllerType::GL_KIT; // Window Controller Type settings.colorType = ofxiOSRendererColorFormat::RGBA8888; // color format used default RGBA8888 settings.depthType = ofxiOSRendererDepthFormat::DEPTH_NONE; // depth format (16/24) if depth enabled diff --git a/scripts/templates/vs/src/main.cpp b/scripts/templates/vs/src/main.cpp index 4e6518d49dc..9b9203fcad7 100644 --- a/scripts/templates/vs/src/main.cpp +++ b/scripts/templates/vs/src/main.cpp @@ -9,6 +9,10 @@ int main( ){ settings.setSize(1024, 768); settings.windowMode = OF_WINDOW; //can also be OF_FULLSCREEN +#if defined(OF_GL_VERSION_MAJOR) && defined(OF_GL_VERSION_MINOR) + settings.setGLVersion(OF_GL_VERSION_MAJOR, OF_GL_VERSION_MINOR); // set via projectGenerator OpenGL version +#endif + auto window = ofCreateWindow(settings); ofRunApp(window, std::make_shared()); diff --git a/scripts/templates/vs2019/src/main.cpp b/scripts/templates/vs2019/src/main.cpp index 4e6518d49dc..9b9203fcad7 100644 --- a/scripts/templates/vs2019/src/main.cpp +++ b/scripts/templates/vs2019/src/main.cpp @@ -9,6 +9,10 @@ int main( ){ settings.setSize(1024, 768); settings.windowMode = OF_WINDOW; //can also be OF_FULLSCREEN +#if defined(OF_GL_VERSION_MAJOR) && defined(OF_GL_VERSION_MINOR) + settings.setGLVersion(OF_GL_VERSION_MAJOR, OF_GL_VERSION_MINOR); // set via projectGenerator OpenGL version +#endif + auto window = ofCreateWindow(settings); ofRunApp(window, std::make_shared()); diff --git a/scripts/templates/vs2026/src/main.cpp b/scripts/templates/vs2026/src/main.cpp index 4e6518d49dc..9b9203fcad7 100644 --- a/scripts/templates/vs2026/src/main.cpp +++ b/scripts/templates/vs2026/src/main.cpp @@ -9,6 +9,10 @@ int main( ){ settings.setSize(1024, 768); settings.windowMode = OF_WINDOW; //can also be OF_FULLSCREEN +#if defined(OF_GL_VERSION_MAJOR) && defined(OF_GL_VERSION_MINOR) + settings.setGLVersion(OF_GL_VERSION_MAJOR, OF_GL_VERSION_MINOR); // set via projectGenerator OpenGL version +#endif + auto window = ofCreateWindow(settings); ofRunApp(window, std::make_shared()); diff --git a/scripts/templates/vscode/src/main.cpp b/scripts/templates/vscode/src/main.cpp index 4e6518d49dc..9b9203fcad7 100644 --- a/scripts/templates/vscode/src/main.cpp +++ b/scripts/templates/vscode/src/main.cpp @@ -9,6 +9,10 @@ int main( ){ settings.setSize(1024, 768); settings.windowMode = OF_WINDOW; //can also be OF_FULLSCREEN +#if defined(OF_GL_VERSION_MAJOR) && defined(OF_GL_VERSION_MINOR) + settings.setGLVersion(OF_GL_VERSION_MAJOR, OF_GL_VERSION_MINOR); // set via projectGenerator OpenGL version +#endif + auto window = ofCreateWindow(settings); ofRunApp(window, std::make_shared());