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:
@@ -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
|
||||
|
||||
|
||||
@@ -47,6 +47,9 @@
|
||||
#include <sstream> // for istream
|
||||
#include <iostream> // for ios::
|
||||
|
||||
#ifndef GL_BGRA_EXT
|
||||
# define GL_BGRA_EXT GL_BGRA
|
||||
#endif
|
||||
|
||||
/**************************************************************
|
||||
***** Begin Callback functions for istream block reading *****
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
#import <OpenGLES/ES1/glext.h>
|
||||
#else
|
||||
#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)
|
||||
#define glGenFramebuffersOES glGenFramebuffers
|
||||
#define glGenRenderbuffersOES glGenRenderbuffers
|
||||
@@ -513,7 +517,24 @@ typedef std::map<void*, unsigned int> 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user