From Konstantin Matveyev, "I've added GLES3 profile, which also enables GLES2 features (OSG_GLES3_AVAILABLE=true => OSG_GLES2_AVAILABLE=true).
If OSG_OPENGL_PROFILE="GLES3" => GraphicsWindowIOS will create gles3 context. If failed, GraphicsWindowIOS will create gles2 context. Multisampling also working. " git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14831 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
parent
a711fdba36
commit
166c49eedd
@ -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
|
# 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"))
|
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 )
|
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"))
|
IF ((OPENGL_PROFILE STREQUAL "GLES2"))
|
||||||
OPTION(OSG_GLES2_AVAILABLE "Set to OFF to disable use of OpenGL ES 2.x functions library." ON )
|
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()
|
ELSE()
|
||||||
OPTION(OSG_GLES2_AVAILABLE "Set to OFF to disable use of OpenGL ES 2.x functions library." OFF )
|
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()
|
ENDIF()
|
||||||
|
|
||||||
|
|
||||||
@ -498,9 +502,11 @@ ELSEIF(OSG_GLES2_AVAILABLE)
|
|||||||
IF (APPLE AND NOT ANDROID)
|
IF (APPLE AND NOT ANDROID)
|
||||||
SET(OPENGL_HEADER1 "#include \"TargetConditionals.h\"" CACHE STRING "#include<> line for OpenGL Header")
|
SET(OPENGL_HEADER1 "#include \"TargetConditionals.h\"" CACHE STRING "#include<> line for OpenGL Header")
|
||||||
SET(OPENGL_HEADER2 "#include <OpenGLES/ES2/gl.h>" CACHE STRING "#include<> line for additional OpenGL Headers if required")
|
SET(OPENGL_HEADER2 "#include <OpenGLES/ES2/gl.h>" CACHE STRING "#include<> line for additional OpenGL Headers if required")
|
||||||
|
# TODO: GLES3
|
||||||
ELSE()
|
ELSE()
|
||||||
SET(OPENGL_HEADER1 "#include <GLES2/gl2.h>" CACHE STRING "#include<> line for OpenGL Header")
|
SET(OPENGL_HEADER1 "#include <GLES2/gl2.h>" CACHE STRING "#include<> line for OpenGL Header")
|
||||||
SET(OPENGL_HEADER2 "" CACHE STRING "#include<> line for additional OpenGL Headers if required")
|
SET(OPENGL_HEADER2 "" CACHE STRING "#include<> line for additional OpenGL Headers if required")
|
||||||
|
# TODO: GLES3
|
||||||
ENDIF()
|
ENDIF()
|
||||||
ELSE()
|
ELSE()
|
||||||
IF (APPLE)
|
IF (APPLE)
|
||||||
@ -542,6 +548,12 @@ ELSE()
|
|||||||
SET(OSG_GLES2_FEATURES "false")
|
SET(OSG_GLES2_FEATURES "false")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
IF (OSG_GLES3_AVAILABLE)
|
||||||
|
SET(OSG_GLES3_FEATURES "true")
|
||||||
|
ELSE()
|
||||||
|
SET(OSG_GLES3_FEATURES "false")
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
IF(ANDROID)
|
IF(ANDROID)
|
||||||
IF(OSG_GLES1_AVAILABLE)
|
IF(OSG_GLES1_AVAILABLE)
|
||||||
FIND_PATH(OPENGL_INCLUDE_DIR GLES/gl.h
|
FIND_PATH(OPENGL_INCLUDE_DIR GLES/gl.h
|
||||||
|
@ -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.
|
This will give us the static build we need for iPhone.
|
||||||
* Disable OSG_GL1_AVAILABLE, OSG_GL2_AVAILABLE, OSG_GL3_AVAILABLE,
|
* Disable OSG_GL1_AVAILABLE, OSG_GL2_AVAILABLE, OSG_GL3_AVAILABLE,
|
||||||
OSG_GL_DISPLAYLISTS_AVAILABLE, OSG_GL_VERTEX_FUNCS_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
|
* Ensure OSG_WINDOWING_SYSTEM is set to IOS
|
||||||
* Change FREETYPE include and library paths to an iPhone version
|
* Change FREETYPE include and library paths to an iPhone version
|
||||||
(OpenFrameworks has one bundled with its distribution)
|
(OpenFrameworks has one bundled with its distribution)
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#cmakedefine OSG_GL3_AVAILABLE
|
#cmakedefine OSG_GL3_AVAILABLE
|
||||||
#cmakedefine OSG_GLES1_AVAILABLE
|
#cmakedefine OSG_GLES1_AVAILABLE
|
||||||
#cmakedefine OSG_GLES2_AVAILABLE
|
#cmakedefine OSG_GLES2_AVAILABLE
|
||||||
|
#cmakedefine OSG_GLES3_AVAILABLE
|
||||||
#cmakedefine OSG_GL_LIBRARY_STATIC
|
#cmakedefine OSG_GL_LIBRARY_STATIC
|
||||||
#cmakedefine OSG_GL_DISPLAYLISTS_AVAILABLE
|
#cmakedefine OSG_GL_DISPLAYLISTS_AVAILABLE
|
||||||
#cmakedefine OSG_GL_MATRICES_AVAILABLE
|
#cmakedefine OSG_GL_MATRICES_AVAILABLE
|
||||||
@ -34,6 +35,7 @@
|
|||||||
#define OSG_GL3_FEATURES @OSG_GL3_FEATURES@
|
#define OSG_GL3_FEATURES @OSG_GL3_FEATURES@
|
||||||
#define OSG_GLES1_FEATURES @OSG_GLES1_FEATURES@
|
#define OSG_GLES1_FEATURES @OSG_GLES1_FEATURES@
|
||||||
#define OSG_GLES2_FEATURES @OSG_GLES2_FEATURES@
|
#define OSG_GLES2_FEATURES @OSG_GLES2_FEATURES@
|
||||||
|
#define OSG_GLES3_FEATURES @OSG_GLES3_FEATURES@
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
|
|
||||||
|
@ -47,6 +47,9 @@
|
|||||||
#include <sstream> // for istream
|
#include <sstream> // for istream
|
||||||
#include <iostream> // for ios::
|
#include <iostream> // for ios::
|
||||||
|
|
||||||
|
#ifndef GL_BGRA_EXT
|
||||||
|
# define GL_BGRA_EXT GL_BGRA
|
||||||
|
#endif
|
||||||
|
|
||||||
/**************************************************************
|
/**************************************************************
|
||||||
***** Begin Callback functions for istream block reading *****
|
***** Begin Callback functions for istream block reading *****
|
||||||
|
@ -10,6 +10,10 @@
|
|||||||
#import <OpenGLES/ES1/glext.h>
|
#import <OpenGLES/ES1/glext.h>
|
||||||
#else
|
#else
|
||||||
#import <OpenGLES/ES2/glext.h>
|
#import <OpenGLES/ES2/glext.h>
|
||||||
|
#if defined(OSG_GLES3_FEATURES)
|
||||||
|
#import <OpenGLES/ES3/glext.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
// in GLES2, the OES suffix if dropped from function names (from rti)
|
// in GLES2, the OES suffix if dropped from function names (from rti)
|
||||||
#define glGenFramebuffersOES glGenFramebuffers
|
#define glGenFramebuffersOES glGenFramebuffers
|
||||||
#define glGenRenderbuffersOES glGenRenderbuffers
|
#define glGenRenderbuffersOES glGenRenderbuffers
|
||||||
@ -513,7 +517,24 @@ typedef std::map<void*, unsigned int> TouchPointsIdMapping;
|
|||||||
glResolveMultisampleFramebufferAPPLE();
|
glResolveMultisampleFramebufferAPPLE();
|
||||||
|
|
||||||
GLenum attachments[] = {GL_DEPTH_ATTACHMENT_OES, GL_COLOR_ATTACHMENT0_OES};
|
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);
|
glDiscardFramebufferEXT(GL_READ_FRAMEBUFFER_APPLE, 2, attachments);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
glDiscardFramebufferEXT(GL_READ_FRAMEBUFFER_APPLE, 2, attachments);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -860,6 +881,11 @@ bool GraphicsWindowIOS::realizeImplementation()
|
|||||||
#if OSG_GLES1_FEATURES
|
#if OSG_GLES1_FEATURES
|
||||||
_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
|
_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
|
||||||
#elif OSG_GLES2_FEATURES
|
#elif OSG_GLES2_FEATURES
|
||||||
|
#if OSG_GLES3_FEATURES
|
||||||
|
_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!_context)
|
||||||
_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
|
_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -868,8 +894,12 @@ bool GraphicsWindowIOS::realizeImplementation()
|
|||||||
#if OSG_GLES1_FEATURES
|
#if OSG_GLES1_FEATURES
|
||||||
OSG_FATAL << "GraphicsWindowIOS::realizeImplementation: ERROR: Failed to create a valid OpenGLES1 context" << std::endl;
|
OSG_FATAL << "GraphicsWindowIOS::realizeImplementation: ERROR: Failed to create a valid OpenGLES1 context" << std::endl;
|
||||||
#elif OSG_GLES2_FEATURES
|
#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;
|
OSG_FATAL << "GraphicsWindowIOS::realizeImplementation: ERROR: Failed to create a valid OpenGLES2 context" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user