GLES3 now working on iOS, tried to maintain support for have bother gles2 and gles3, allowed avfoundation to be added on iOS, improved iOS example cmake generation
This commit is contained in:
@@ -451,7 +451,7 @@ GLExtensions::GLExtensions(unsigned int in_contextID):
|
||||
glVersion = validContext ? findAsciiToFloat( versionString ) : 0.0f;
|
||||
glslLanguageVersion = 0.0f;
|
||||
|
||||
bool shadersBuiltIn = OSG_GLES2_FEATURES || OSG_GL3_FEATURES;
|
||||
bool shadersBuiltIn = OSG_GLES2_FEATURES || OSG_GLES3_FEATURES || OSG_GL3_FEATURES;
|
||||
|
||||
isShaderObjectsSupported = validContext && (shadersBuiltIn || osg::isGLExtensionSupported(contextID,"GL_ARB_shader_objects"));
|
||||
isVertexShaderSupported = validContext && (shadersBuiltIn || osg::isGLExtensionSupported(contextID,"GL_ARB_vertex_shader"));
|
||||
@@ -472,7 +472,7 @@ GLExtensions::GLExtensions(unsigned int in_contextID):
|
||||
isGLExtensionSupported(contextID,"GL_NV_texture_rectangle"));
|
||||
|
||||
isCubeMapSupported = validContext &&
|
||||
(OSG_GLES2_FEATURES || OSG_GL3_FEATURES ||
|
||||
(OSG_GLES2_FEATURES || OSG_GLES3_FEATURES || OSG_GL3_FEATURES ||
|
||||
isGLExtensionSupported(contextID,"GL_ARB_texture_cube_map") ||
|
||||
isGLExtensionSupported(contextID,"GL_EXT_texture_cube_map") ||
|
||||
(glVersion >= 1.3f));
|
||||
@@ -718,17 +718,17 @@ GLExtensions::GLExtensions(unsigned int in_contextID):
|
||||
setGLExtensionFuncPtr(glBindBufferBase, "glBindBufferBase", "glBindBufferBaseEXT", "glBindBufferBaseNV" , validContext);
|
||||
setGLExtensionFuncPtr(glTexBuffer, "glTexBuffer","glTexBufferARB" , validContext);
|
||||
|
||||
isVBOSupported = validContext && (OSG_GLES2_FEATURES || OSG_GL3_FEATURES || osg::isGLExtensionSupported(contextID,"GL_ARB_vertex_buffer_object"));
|
||||
isPBOSupported = validContext && (OSG_GLES2_FEATURES || OSG_GL3_FEATURES || osg::isGLExtensionSupported(contextID,"GL_ARB_pixel_buffer_object"));
|
||||
isVBOSupported = validContext && (OSG_GLES2_FEATURES || OSG_GLES3_FEATURES || OSG_GL3_FEATURES || osg::isGLExtensionSupported(contextID,"GL_ARB_vertex_buffer_object"));
|
||||
isPBOSupported = validContext && (OSG_GLES2_FEATURES || OSG_GLES3_FEATURES || OSG_GL3_FEATURES || osg::isGLExtensionSupported(contextID,"GL_ARB_pixel_buffer_object"));
|
||||
isTBOSupported = validContext && osg::isGLExtensionSupported(contextID,"GL_ARB_texture_buffer_object");
|
||||
isVAOSupported = validContext && (OSG_GL3_FEATURES || osg::isGLExtensionSupported(contextID, "GL_ARB_vertex_array_object", "GL_OES_vertex_array_object"));
|
||||
isVAOSupported = validContext && (OSG_GLES3_FEATURES || OSG_GL3_FEATURES || osg::isGLExtensionSupported(contextID, "GL_ARB_vertex_array_object", "GL_OES_vertex_array_object"));
|
||||
isTransformFeedbackSupported = validContext && osg::isGLExtensionSupported(contextID, "GL_ARB_transform_feedback2");
|
||||
isBufferObjectSupported = isVBOSupported && isPBOSupported;
|
||||
|
||||
|
||||
// BlendFunc extensions
|
||||
isBlendFuncSeparateSupported = validContext &&
|
||||
(OSG_GLES2_FEATURES || OSG_GL3_FEATURES ||
|
||||
(OSG_GLES2_FEATURES || OSG_GLES3_FEATURES || OSG_GL3_FEATURES ||
|
||||
osg::isGLExtensionSupported(contextID, "GL_EXT_blend_func_separate") ||
|
||||
(glVersion >= 1.4f));
|
||||
|
||||
@@ -820,7 +820,7 @@ GLExtensions::GLExtensions(unsigned int in_contextID):
|
||||
bool radeonHardwareDetected = (rendererString.find("Radeon")!=std::string::npos || rendererString.find("RADEON")!=std::string::npos);
|
||||
bool fireGLHardwareDetected = (rendererString.find("FireGL")!=std::string::npos || rendererString.find("FIREGL")!=std::string::npos);
|
||||
|
||||
bool builtInSupport = OSG_GLES2_FEATURES || OSG_GL3_FEATURES;
|
||||
bool builtInSupport = OSG_GLES2_FEATURES || OSG_GLES3_FEATURES || OSG_GL3_FEATURES;
|
||||
|
||||
isMultiTexturingSupported = validContext &&
|
||||
(builtInSupport || OSG_GLES1_FEATURES ||
|
||||
@@ -852,7 +852,7 @@ GLExtensions::GLExtensions(unsigned int in_contextID):
|
||||
isTextureBorderClampSupported = validContext &&
|
||||
(OSG_GL3_FEATURES ||
|
||||
((OSG_GL1_FEATURES || OSG_GL2_FEATURES) && isGLExtensionOrVersionSupported(contextID,"GL_ARB_texture_border_clamp", 1.3f)) ||
|
||||
(OSG_GLES2_FEATURES && isGLExtensionSupported(contextID,"GL_EXT_texture_border_clamp")));
|
||||
((OSG_GLES2_FEATURES || OSG_GLES3_FEATURES) && isGLExtensionSupported(contextID,"GL_EXT_texture_border_clamp")));
|
||||
|
||||
isGenerateMipMapSupported = validContext && (builtInSupport || isGLExtensionOrVersionSupported(contextID,"GL_SGIS_generate_mipmap", 1.4f));
|
||||
preferGenerateMipmapSGISForPowerOfTwo = (radeonHardwareDetected||fireGLHardwareDetected) ? false : true;
|
||||
@@ -939,13 +939,13 @@ GLExtensions::GLExtensions(unsigned int in_contextID):
|
||||
|
||||
// Blending
|
||||
isBlendColorSupported = validContext &&
|
||||
(OSG_GLES2_FEATURES || OSG_GL3_FEATURES ||
|
||||
(OSG_GLES2_FEATURES || OSG_GLES3_FEATURES || OSG_GL3_FEATURES ||
|
||||
isGLExtensionSupported(contextID,"GL_EXT_blend_color") ||
|
||||
(glVersion >= 1.2f));
|
||||
|
||||
setGLExtensionFuncPtr(glBlendColor, "glBlendColor", "glBlendColorEXT", validContext);
|
||||
|
||||
bool bultInSupport = OSG_GLES2_FEATURES || OSG_GL3_FEATURES;
|
||||
bool bultInSupport = OSG_GLES2_FEATURES || OSG_GLES3_FEATURES || OSG_GL3_FEATURES;
|
||||
isBlendEquationSupported = validContext &&
|
||||
(bultInSupport ||
|
||||
isGLExtensionSupported(contextID, "GL_EXT_blend_equation") ||
|
||||
@@ -1012,7 +1012,7 @@ GLExtensions::GLExtensions(unsigned int in_contextID):
|
||||
isGLExtensionSupported(contextID,"GL_SGIS_point_parameters"));
|
||||
|
||||
|
||||
isPointSpriteSupported = validContext && (OSG_GL3_FEATURES || isGLExtensionSupported(contextID, "GL_ARB_point_sprite") || isGLExtensionSupported(contextID, "GL_OES_point_sprite") || isGLExtensionSupported(contextID, "GL_NV_point_sprite"));
|
||||
isPointSpriteSupported = validContext && (OSG_GLES2_FEATURES || OSG_GLES3_FEATURES || OSG_GL3_FEATURES || isGLExtensionSupported(contextID, "GL_ARB_point_sprite") || isGLExtensionSupported(contextID, "GL_OES_point_sprite") || isGLExtensionSupported(contextID, "GL_NV_point_sprite"));
|
||||
isPointSpriteCoordOriginSupported = validContext && (OSG_GL3_FEATURES || (glVersion >= 2.0f));
|
||||
|
||||
|
||||
@@ -1027,7 +1027,7 @@ GLExtensions::GLExtensions(unsigned int in_contextID):
|
||||
|
||||
|
||||
// Multisample
|
||||
isMultisampleSupported = validContext && (OSG_GLES2_FEATURES || OSG_GL3_FEATURES || isGLExtensionSupported(contextID,"GL_ARB_multisample"));
|
||||
isMultisampleSupported = validContext && (OSG_GLES2_FEATURES || OSG_GLES2_FEATURES || OSG_GL3_FEATURES || isGLExtensionSupported(contextID,"GL_ARB_multisample"));
|
||||
isMultisampleFilterHintSupported = validContext && isGLExtensionSupported(contextID, "GL_NV_multisample_filter_hint");
|
||||
|
||||
setGLExtensionFuncPtr(glSampleCoverage, "glSampleCoverage", "glSampleCoverageARB", validContext);
|
||||
@@ -1159,7 +1159,7 @@ GLExtensions::GLExtensions(unsigned int in_contextID):
|
||||
|
||||
if (validContext)
|
||||
{
|
||||
if (osg::getGLVersionNumber() >= 2.0 || osg::isGLExtensionSupported(contextID, "GL_ARB_vertex_shader") || OSG_GLES2_FEATURES || OSG_GL3_FEATURES)
|
||||
if (osg::getGLVersionNumber() >= 2.0 || osg::isGLExtensionSupported(contextID, "GL_ARB_vertex_shader") || OSG_GLES2_FEATURES || OSG_GLES3_FEATURES || OSG_GL3_FEATURES)
|
||||
{
|
||||
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS,&glMaxTextureUnits);
|
||||
#ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE
|
||||
|
||||
@@ -175,7 +175,7 @@ void State::initializeExtensionProcs()
|
||||
|
||||
_isSecondaryColorSupported = osg::isGLExtensionSupported(_contextID,"GL_EXT_secondary_color");
|
||||
_isFogCoordSupported = osg::isGLExtensionSupported(_contextID,"GL_EXT_fog_coord");
|
||||
_isVertexBufferObjectSupported = OSG_GLES2_FEATURES || OSG_GL3_FEATURES || osg::isGLExtensionSupported(_contextID,"GL_ARB_vertex_buffer_object");
|
||||
_isVertexBufferObjectSupported = OSG_GLES2_FEATURES || OSG_GLES3_FEATURES || OSG_GL3_FEATURES || osg::isGLExtensionSupported(_contextID,"GL_ARB_vertex_buffer_object");
|
||||
_isVertexArrayObjectSupported = _glExtensions->isVAOSupported;
|
||||
|
||||
const DisplaySettings* ds = getDisplaySettings() ? getDisplaySettings() : osg::DisplaySettings::instance().get();
|
||||
@@ -211,7 +211,7 @@ void State::initializeExtensionProcs()
|
||||
setGLExtensionFuncPtr(_glDrawArraysInstanced, "glDrawArraysInstanced","glDrawArraysInstancedARB","glDrawArraysInstancedEXT");
|
||||
setGLExtensionFuncPtr(_glDrawElementsInstanced, "glDrawElementsInstanced","glDrawElementsInstancedARB","glDrawElementsInstancedEXT");
|
||||
|
||||
if (osg::getGLVersionNumber() >= 2.0 || osg::isGLExtensionSupported(_contextID, "GL_ARB_vertex_shader") || OSG_GLES2_FEATURES || OSG_GL3_FEATURES)
|
||||
if (osg::getGLVersionNumber() >= 2.0 || osg::isGLExtensionSupported(_contextID, "GL_ARB_vertex_shader") || OSG_GLES2_FEATURES || OSG_GLES3_FEATURES || OSG_GL3_FEATURES)
|
||||
{
|
||||
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS,&_glMaxTextureUnits);
|
||||
#ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# AVFoundation plugin only works with OSX/Cocoa (not X11 or Carbon)
|
||||
IF(NOT OSG_WINDOWING_SYSTEM STREQUAL "Cocoa")
|
||||
MESSAGE(WARNING "Disabling AVFoundation plugin because it requires OSG_WINDOWING_SYSTEM to be Cocoa")
|
||||
IF(NOT OSG_WINDOWING_SYSTEM STREQUAL "Cocoa" AND NOT OSG_WINDOWING_SYSTEM STREQUAL "IOS")
|
||||
MESSAGE(WARNING "Disabling AVFoundation plugin because it requires OSG_WINDOWING_SYSTEM to be Cocoa or IOS")
|
||||
RETURN()
|
||||
ENDIF()
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ void GlyphTexture::apply(osg::State& state) const
|
||||
|
||||
bool newTextureObject = (textureObject == 0);
|
||||
|
||||
#if defined(OSG_GLES2_AVAILABLE)
|
||||
#if defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE)
|
||||
bool requiresGenerateMipmapCall = false;
|
||||
|
||||
// need to look to see generate mip map call is required.
|
||||
@@ -203,7 +203,7 @@ void GlyphTexture::apply(osg::State& state) const
|
||||
case LINEAR_MIPMAP_LINEAR:
|
||||
if (generateMipMapSupported)
|
||||
{
|
||||
#if !defined(OSG_GLES2_AVAILABLE)
|
||||
#if !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE)
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_TRUE);
|
||||
#endif
|
||||
}
|
||||
@@ -223,7 +223,7 @@ void GlyphTexture::apply(osg::State& state) const
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
|
||||
|
||||
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
|
||||
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE)
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH,getTextureWidth());
|
||||
#endif
|
||||
|
||||
@@ -299,7 +299,7 @@ void GlyphTexture::apply(osg::State& state) const
|
||||
|
||||
bool subloadAllGlyphsTogether = s_subloadAllGlyphsTogether;
|
||||
|
||||
#if defined(OSG_GLES2_AVAILABLE)
|
||||
#if defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE)
|
||||
if (requiresGenerateMipmapCall) subloadAllGlyphsTogether = true;
|
||||
#endif
|
||||
|
||||
@@ -374,7 +374,7 @@ void GlyphTexture::apply(osg::State& state) const
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
|
||||
|
||||
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
|
||||
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE)
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH,getTextureWidth());
|
||||
#endif
|
||||
|
||||
@@ -384,7 +384,7 @@ void GlyphTexture::apply(osg::State& state) const
|
||||
getTextureHeight(),
|
||||
OSGTEXT_GLYPH_FORMAT, GL_UNSIGNED_BYTE, local_data);
|
||||
|
||||
#if defined(OSG_GLES2_AVAILABLE)
|
||||
#if defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE)
|
||||
if (requiresGenerateMipmapCall) glGenerateMipmap(GL_TEXTURE_2D);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -9,9 +9,13 @@
|
||||
#if OSG_GLES1_FEATURES
|
||||
#import <OpenGLES/ES1/glext.h>
|
||||
#else
|
||||
#if defined(OSG_GLES2_FEATURES)
|
||||
|
||||
#define MUTLI_GLES (OSG_GLES2_FEATURES && OSG_GLES3_FEATURES)
|
||||
|
||||
#if OSG_GLES2_FEATURES || MUTLI_GLES
|
||||
#import <OpenGLES/ES2/glext.h>
|
||||
#elif defined(OSG_GLES3_FEATURES)
|
||||
#endif
|
||||
#if OSG_GLES3_FEATURES || MUTLI_GLES
|
||||
#import <OpenGLES/ES3/glext.h>
|
||||
#endif
|
||||
|
||||
@@ -39,6 +43,18 @@
|
||||
#define GL_STENCIL_ATTACHMENT_OES GL_STENCIL_ATTACHMENT
|
||||
|
||||
#define GL_RGB5_A1_OES GL_RGB5_A1
|
||||
|
||||
#if OSG_GLES3_FEATURES && !MUTLI_GLES
|
||||
#define glRenderbufferStorageMultisampleAPPLE glRenderbufferStorageMultisample
|
||||
#define glDiscardFramebufferEXT glInvalidateFramebuffer
|
||||
//#define glResolveMultisampleFramebufferAPPLE glResolveMultisampleFramebuffer
|
||||
|
||||
#define GL_DEPTH24_STENCIL8_OES GL_DEPTH24_STENCIL8
|
||||
#define GL_DEPTH_COMPONENT24_OES GL_DEPTH_COMPONENT24
|
||||
#define GL_READ_FRAMEBUFFER_APPLE GL_READ_FRAMEBUFFER
|
||||
#define GL_DRAW_FRAMEBUFFER_APPLE GL_DRAW_FRAMEBUFFER
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#include "IOSUtils.h"
|
||||
@@ -514,11 +530,13 @@ typedef std::map<void*, unsigned int> TouchPointsIdMapping;
|
||||
|
||||
glBindFramebufferOES(GL_READ_FRAMEBUFFER_APPLE, _msaaFramebuffer);
|
||||
glBindFramebufferOES(GL_DRAW_FRAMEBUFFER_APPLE, _viewFramebuffer);
|
||||
|
||||
glResolveMultisampleFramebufferAPPLE();
|
||||
|
||||
|
||||
GLenum attachments[] = {GL_DEPTH_ATTACHMENT_OES, GL_COLOR_ATTACHMENT0_OES};
|
||||
#ifdef OSG_GLES3_FEATURES
|
||||
|
||||
#if !OSG_GLES3_FEATURES
|
||||
glResolveMultisampleFramebufferAPPLE();
|
||||
glDiscardFramebufferEXT(GL_READ_FRAMEBUFFER_APPLE, 2, attachments);
|
||||
#else
|
||||
switch ([_context API])
|
||||
{
|
||||
case kEAGLRenderingAPIOpenGLES3:
|
||||
@@ -529,17 +547,16 @@ typedef std::map<void*, unsigned int> TouchPointsIdMapping;
|
||||
break;
|
||||
|
||||
default:
|
||||
#if !OSG_GLES3_FEATURES
|
||||
glResolveMultisampleFramebufferAPPLE();
|
||||
#endif
|
||||
glDiscardFramebufferEXT(GL_READ_FRAMEBUFFER_APPLE, 2, attachments);
|
||||
break;
|
||||
}
|
||||
#else
|
||||
glDiscardFramebufferEXT(GL_READ_FRAMEBUFFER_APPLE, 2, attachments);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//swap buffers (sort of i think?)
|
||||
glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer);
|
||||
|
||||
@@ -882,12 +899,16 @@ bool GraphicsWindowIOS::realizeImplementation()
|
||||
#if OSG_GLES1_FEATURES
|
||||
_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
|
||||
#elif OSG_GLES2_FEATURES
|
||||
#if OSG_GLES3_FEATURES
|
||||
_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
|
||||
#endif
|
||||
|
||||
if (!_context)
|
||||
#if MULTI_GLES
|
||||
_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
|
||||
if(!_context) _context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
|
||||
#else
|
||||
_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
|
||||
#endif
|
||||
|
||||
#elif OSG_GLES3_FEATURES
|
||||
_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
|
||||
#endif
|
||||
|
||||
if (!_context || ![EAGLContext setCurrentContext:_context]) {
|
||||
@@ -895,11 +916,9 @@ 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
|
||||
OSG_FATAL << "GraphicsWindowIOS::realizeImplementation: ERROR: Failed to create a valid OpenGLES2" << std::endl;
|
||||
#elif OSG_GLES3_FEATURES
|
||||
OSG_FATAL << "GraphicsWindowIOS::realizeImplementation: ERROR: Failed to create a valid OpenGLES3 context" << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user