diff --git a/CMakeLists.txt b/CMakeLists.txt index badecd43d..bc5181b07 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -402,7 +402,7 @@ OPTION(OSG_USE_REF_PTR_IMPLICIT_OUTPUT_CONVERSION "Set to ON to use the ref_ptr< # Map the OPENGL_PROFILE to OSG_GL*_AVAILABLE settings -SET(OPENGL_PROFILE "GL2" CACHE STRING "OpenGL Profile to use, choose from GL2, GL3, GLES1, GLES2") +SET(OPENGL_PROFILE "GL2" CACHE STRING "OpenGL Profile to use, choose from GL2, GL3, GLES1, GLES2, GLES3") IF ((OPENGL_PROFILE STREQUAL "GL1") OR (OPENGL_PROFILE STREQUAL "GL2")) OPTION(OSG_GL1_AVAILABLE "Set to OFF to disable use of OpenGL 1.x functions library." ON ) @@ -430,8 +430,12 @@ ENDIF() IF ((OPENGL_PROFILE STREQUAL "GLES2")) OPTION(OSG_GLES2_AVAILABLE "Set to OFF to disable use of OpenGL ES 2.x functions library." ON ) +ELSEIF ((OPENGL_PROFILE STREQUAL "GLES3")) + OPTION(OSG_GLES2_AVAILABLE "Set to OFF to disable use of OpenGL ES 2.x functions library." ON ) + OPTION(OSG_GLES3_AVAILABLE "Set to OFF to disable use of OpenGL ES 3.x functions library." ON ) ELSE() OPTION(OSG_GLES2_AVAILABLE "Set to OFF to disable use of OpenGL ES 2.x functions library." OFF ) + OPTION(OSG_GLES3_AVAILABLE "Set to OFF to disable use of OpenGL ES 3.x functions library." OFF ) ENDIF() @@ -498,9 +502,11 @@ ELSEIF(OSG_GLES2_AVAILABLE) IF (APPLE AND NOT ANDROID) SET(OPENGL_HEADER1 "#include \"TargetConditionals.h\"" CACHE STRING "#include<> line for OpenGL Header") SET(OPENGL_HEADER2 "#include " CACHE STRING "#include<> line for additional OpenGL Headers if required") + # TODO: GLES3 ELSE() SET(OPENGL_HEADER1 "#include " CACHE STRING "#include<> line for OpenGL Header") SET(OPENGL_HEADER2 "" CACHE STRING "#include<> line for additional OpenGL Headers if required") + # TODO: GLES3 ENDIF() ELSE() IF (APPLE) @@ -542,6 +548,12 @@ ELSE() SET(OSG_GLES2_FEATURES "false") ENDIF() +IF (OSG_GLES3_AVAILABLE) + SET(OSG_GLES3_FEATURES "true") +ELSE() + SET(OSG_GLES3_FEATURES "false") +ENDIF() + IF(ANDROID) IF(OSG_GLES1_AVAILABLE) FIND_PATH(OPENGL_INCLUDE_DIR GLES/gl.h diff --git a/README.txt b/README.txt index 171115ba8..94b6db17f 100644 --- a/README.txt +++ b/README.txt @@ -166,7 +166,7 @@ Section 3. Release notes on iOS build, by Thomas Hoghart This will give us the static build we need for iPhone. * Disable OSG_GL1_AVAILABLE, OSG_GL2_AVAILABLE, OSG_GL3_AVAILABLE, OSG_GL_DISPLAYLISTS_AVAILABLE, OSG_GL_VERTEX_FUNCS_AVAILABLE -* Enable OSG_GLES1_AVAILABLE *OR* OSG_GLES2_AVAILABLE +* Enable OSG_GLES1_AVAILABLE *OR* OSG_GLES2_AVAILABLE *OR* OSG_GLES3_AVAILABLE (GLES3 will enable GLES2 features) * Ensure OSG_WINDOWING_SYSTEM is set to IOS * Change FREETYPE include and library paths to an iPhone version (OpenFrameworks has one bundled with its distribution) diff --git a/src/osg/GL.in b/src/osg/GL.in index be53e8acc..1215b6fd4 100644 --- a/src/osg/GL.in +++ b/src/osg/GL.in @@ -22,6 +22,7 @@ #cmakedefine OSG_GL3_AVAILABLE #cmakedefine OSG_GLES1_AVAILABLE #cmakedefine OSG_GLES2_AVAILABLE +#cmakedefine OSG_GLES3_AVAILABLE #cmakedefine OSG_GL_LIBRARY_STATIC #cmakedefine OSG_GL_DISPLAYLISTS_AVAILABLE #cmakedefine OSG_GL_MATRICES_AVAILABLE @@ -34,6 +35,7 @@ #define OSG_GL3_FEATURES @OSG_GL3_FEATURES@ #define OSG_GLES1_FEATURES @OSG_GLES1_FEATURES@ #define OSG_GLES2_FEATURES @OSG_GLES2_FEATURES@ +#define OSG_GLES3_FEATURES @OSG_GLES3_FEATURES@ #ifndef WIN32 diff --git a/src/osgPlugins/imageio/ReaderWriterImageIO.cpp b/src/osgPlugins/imageio/ReaderWriterImageIO.cpp index aea340d4f..1ded6047b 100644 --- a/src/osgPlugins/imageio/ReaderWriterImageIO.cpp +++ b/src/osgPlugins/imageio/ReaderWriterImageIO.cpp @@ -47,6 +47,9 @@ #include // for istream #include // for ios:: +#ifndef GL_BGRA_EXT +# define GL_BGRA_EXT GL_BGRA +#endif /************************************************************** ***** Begin Callback functions for istream block reading ***** diff --git a/src/osgViewer/GraphicsWindowIOS.mm b/src/osgViewer/GraphicsWindowIOS.mm index e129ed7b9..5bca620b5 100644 --- a/src/osgViewer/GraphicsWindowIOS.mm +++ b/src/osgViewer/GraphicsWindowIOS.mm @@ -10,6 +10,10 @@ #import #else #import + #if defined(OSG_GLES3_FEATURES) + #import + #endif + // in GLES2, the OES suffix if dropped from function names (from rti) #define glGenFramebuffersOES glGenFramebuffers #define glGenRenderbuffersOES glGenRenderbuffers @@ -513,7 +517,24 @@ typedef std::map TouchPointsIdMapping; glResolveMultisampleFramebufferAPPLE(); GLenum attachments[] = {GL_DEPTH_ATTACHMENT_OES, GL_COLOR_ATTACHMENT0_OES}; + #ifdef OSG_GLES3_FEATURES + switch ([_context API]) + { + case kEAGLRenderingAPIOpenGLES3: + glBlitFramebuffer(0, 0, _backingWidth, _backingHeight, + 0, 0, _backingWidth, _backingHeight, + GL_COLOR_BUFFER_BIT, GL_LINEAR); + glInvalidateFramebuffer(GL_READ_FRAMEBUFFER_APPLE, 2, attachments); + break; + + default: + glResolveMultisampleFramebufferAPPLE(); + glDiscardFramebufferEXT(GL_READ_FRAMEBUFFER_APPLE, 2, attachments); + break; + } + #else glDiscardFramebufferEXT(GL_READ_FRAMEBUFFER_APPLE, 2, attachments); + #endif } #endif @@ -860,7 +881,12 @@ bool GraphicsWindowIOS::realizeImplementation() #if OSG_GLES1_FEATURES _context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; #elif OSG_GLES2_FEATURES - _context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; + #if OSG_GLES3_FEATURES + _context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3]; + #endif + + if (!_context) + _context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; #endif if (!_context || ![EAGLContext setCurrentContext:_context]) { @@ -868,7 +894,11 @@ bool GraphicsWindowIOS::realizeImplementation() #if OSG_GLES1_FEATURES OSG_FATAL << "GraphicsWindowIOS::realizeImplementation: ERROR: Failed to create a valid OpenGLES1 context" << std::endl; #elif OSG_GLES2_FEATURES + #if OSG_GLES3_FEATURES + OSG_FATAL << "GraphicsWindowIOS::realizeImplementation: ERROR: Failed to create a valid OpenGLES3 or OpenGLES2 context" << std::endl; + #else OSG_FATAL << "GraphicsWindowIOS::realizeImplementation: ERROR: Failed to create a valid OpenGLES2 context" << std::endl; + #endif #endif return false; }