Skip to content

Commit b08f95a

Browse files
authored
GL version defines for main templates / PG (#8573)
* WebGL and iOS GLES version from OF_WEBGL_VERSION / OF_GLES_VERSION defines * Desktop GL version from OF_GL_VERSION_MAJOR / MINOR in templates; keep iOS GLES define to template main.mm * Only set GL version when both OF_GL_VERSION_MAJOR and OF_GL_VERSION_MINOR are defined * Update ofxiOSConstants.h * Add OF_GLES_VERSION definition in main.mm Define OF_GLES_VERSION for iOS renderer compatibility. * Add GLES version definition for tvOS Define OF_GLES_VERSION if not already defined.
1 parent 08462a6 commit b08f95a

15 files changed

Lines changed: 65 additions & 3 deletions

File tree

‎addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
#include "ofEvents.h"
1111
#include "ofGLProgrammableRenderer.h"
1212

13+
#ifndef OF_WEBGL_VERSION
14+
#define OF_WEBGL_VERSION 2
15+
#endif
16+
1317
using namespace std;
1418

1519
ofxAppEmscriptenWindow * ofxAppEmscriptenWindow::instance = NULL;
@@ -38,7 +42,7 @@ void ofxAppEmscriptenWindow::setup(const ofGLESWindowSettings & settings){
3842
attrs.depth = 1;
3943
attrs.stencil = 1;
4044
attrs.antialias = 1;
41-
attrs.majorVersion = 2;
45+
attrs.majorVersion = OF_WEBGL_VERSION;
4246
attrs.minorVersion = 0;
4347
attrs.alpha = 0;
4448

‎addons/ofxiOS/src/ofxiOSConstants.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ enum ofxiOSRendererType {
6868
OFXIOS_RENDERER_METAL = 4
6969
};
7070

71+
// OF_GLES_VERSION=1|2|3 in the project defines to override or in projectGenerator from 0.99.0
72+
#ifndef OF_GLES_VERSION
73+
#define OF_GLES_VERSION OFXIOS_RENDERER_ES2
74+
#endif
75+
7176
enum ofxiOSWindowControllerType{
7277
CORE_ANIMATION = 1,
7378
GL_KIT = 2,

‎libs/openFrameworksCompiled/project/emscripten/config.emscripten.default.mk‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,12 @@ ifneq ($(strip $(wildcard bin/data/*)),)
124124
PLATFORM_LDFLAGS += --preload-file bin/data@data
125125
endif
126126
PLATFORM_LDFLAGS += --use-port=emdawnwebgpu
127+
# PROJECT_DEFINES += OF_WEBGL_VERSION=1 in config.make for a WebGL 1 only build (default WebGL 2)
128+
ifneq ($(filter OF_WEBGL_VERSION=1,$(PROJECT_DEFINES)),)
129+
PLATFORM_LDFLAGS += -s MAX_WEBGL_VERSION=1 -s FULL_ES2
130+
else
127131
PLATFORM_LDFLAGS += -s MAX_WEBGL_VERSION=2 -s WEBGL2_BACKWARDS_COMPATIBILITY_EMULATION=1 -s FULL_ES3
132+
endif
128133
PLATFORM_LDFLAGS += -s AUTO_NATIVE_LIBRARIES=1
129134
PLATFORM_LDFLAGS += -s AUTO_JS_LIBRARIES=1
130135

‎scripts/templates/ios/src/main.mm‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#include "ofApp.h"
22

3+
#ifndef OF_GLES_VERSION
4+
#define OF_GLES_VERSION OFXIOS_RENDERER_ES2
5+
#endif
6+
37
int main() {
48

59
// here are the most commonly used iOS window settings.
@@ -11,7 +15,7 @@ int main() {
1115
settings.numOfAntiAliasingSamples = 0; // number of samples used for anti-aliasing.
1216
settings.enableHardwareOrientation = false; // enables native view orientation.
1317
settings.enableHardwareOrientationAnimation = false; // enables native orientation changes to be animated.
14-
settings.glesVersion = OFXIOS_RENDERER_ES2; // type of renderer to use, ES1, ES2, ES3
18+
settings.glesVersion = OF_GLES_VERSION; // type of renderer to use, ES1, ES2, ES3 - default ES2, set via OF_GLES_VERSION define
1519
settings.windowControllerType = ofxiOSWindowControllerType::GL_KIT; // Window Controller Type
1620
settings.colorType = ofxiOSRendererColorFormat::RGBA8888; // color format used default RGBA8888
1721
settings.depthType = ofxiOSRendererDepthFormat::DEPTH_NONE; // depth format (16/24) if depth enabled

‎scripts/templates/linux/src/main.cpp‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ int main( ){
99
settings.setSize(1024, 768);
1010
settings.windowMode = OF_WINDOW; //can also be OF_FULLSCREEN
1111

12+
#if defined(OF_GL_VERSION_MAJOR) && defined(OF_GL_VERSION_MINOR)
13+
settings.setGLVersion(OF_GL_VERSION_MAJOR, OF_GL_VERSION_MINOR); // set via projectGenerator OpenGL version
14+
#endif
15+
1216
auto window = ofCreateWindow(settings);
1317

1418
ofRunApp(window, std::make_shared<ofApp>());

‎scripts/templates/linux64/src/main.cpp‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ int main( ){
99
settings.setSize(1024, 768);
1010
settings.windowMode = OF_WINDOW; //can also be OF_FULLSCREEN
1111

12+
#if defined(OF_GL_VERSION_MAJOR) && defined(OF_GL_VERSION_MINOR)
13+
settings.setGLVersion(OF_GL_VERSION_MAJOR, OF_GL_VERSION_MINOR); // set via projectGenerator OpenGL version
14+
#endif
15+
1216
auto window = ofCreateWindow(settings);
1317

1418
ofRunApp(window, std::make_shared<ofApp>());

‎scripts/templates/linuxarmv6l/src/main.cpp‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ int main( ){
99
settings.setSize(1024, 768);
1010
settings.windowMode = OF_WINDOW; //can also be OF_FULLSCREEN
1111

12+
#if defined(OF_GL_VERSION_MAJOR) && defined(OF_GL_VERSION_MINOR)
13+
settings.setGLVersion(OF_GL_VERSION_MAJOR, OF_GL_VERSION_MINOR); // set via projectGenerator OpenGL version
14+
#endif
15+
1216
auto window = ofCreateWindow(settings);
1317

1418
ofRunApp(window, std::make_shared<ofApp>());

‎scripts/templates/linuxarmv7l/src/main.cpp‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ int main( ){
99
settings.setSize(1024, 768);
1010
settings.windowMode = OF_WINDOW; //can also be OF_FULLSCREEN
1111

12+
#if defined(OF_GL_VERSION_MAJOR) && defined(OF_GL_VERSION_MINOR)
13+
settings.setGLVersion(OF_GL_VERSION_MAJOR, OF_GL_VERSION_MINOR); // set via projectGenerator OpenGL version
14+
#endif
15+
1216
auto window = ofCreateWindow(settings);
1317

1418
ofRunApp(window, std::make_shared<ofApp>());

‎scripts/templates/msys2/src/main.cpp‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ int main( ){
99
settings.setSize(1024, 768);
1010
settings.windowMode = OF_WINDOW; //can also be OF_FULLSCREEN
1111

12+
#if defined(OF_GL_VERSION_MAJOR) && defined(OF_GL_VERSION_MINOR)
13+
settings.setGLVersion(OF_GL_VERSION_MAJOR, OF_GL_VERSION_MINOR); // set via projectGenerator OpenGL version
14+
#endif
15+
1216
auto window = ofCreateWindow(settings);
1317

1418
ofRunApp(window, std::make_shared<ofApp>());

‎scripts/templates/osx/src/main.cpp‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ int main( ){
99
settings.setSize(1024, 768);
1010
settings.windowMode = OF_WINDOW; //can also be OF_FULLSCREEN
1111

12+
#if defined(OF_GL_VERSION_MAJOR) && defined(OF_GL_VERSION_MINOR)
13+
settings.setGLVersion(OF_GL_VERSION_MAJOR, OF_GL_VERSION_MINOR); // set via projectGenerator OpenGL version
14+
#endif
15+
1216
auto window = ofCreateWindow(settings);
1317

1418
ofRunApp(window, std::make_shared<ofApp>());

0 commit comments

Comments
 (0)