From eea3d559a7a45318aa43c135294d6eee334ea528 Mon Sep 17 00:00:00 2001 From: Thomas Hogarth Date: Wed, 15 Mar 2017 01:35:58 +0000 Subject: [PATCH 1/6] Added conditionals for GLES3, added correct gl headers for GLES3 on iOS and Android to GL.in --- .gitignore | 6 +++ CMakeLists.txt | 10 ++++- include/osg/Camera | 2 +- include/osg/Image | 5 ++- include/osg/PolygonMode | 2 +- include/osg/TexGen | 2 +- src/osg/Depth.cpp | 2 +- src/osg/GL.in | 4 +- src/osg/Image.cpp | 2 +- src/osg/PolygonMode.cpp | 2 +- src/osg/Texture.cpp | 2 +- src/osg/Texture1D.cpp | 10 ++--- src/osg/TextureRectangle.cpp | 2 +- src/osg/glu/libutil/mipmap.cpp | 56 ++++++++++++------------ src/osgDB/ObjectWrapper.cpp | 2 +- src/osgGA/StateSetManipulator.cpp | 4 +- src/osgParticle/ParticleSystem.cpp | 8 ++-- src/osgPlugins/logo/ReaderWriterLOGO.cpp | 2 +- src/osgShadow/ShadowMap.cpp | 2 +- src/osgShadow/StandardShadowMap.cpp | 4 +- src/osgSim/LightPointDrawable.cpp | 2 +- src/osgSim/LightPointSpriteDrawable.cpp | 2 +- src/osgUtil/RenderStage.cpp | 10 ++--- src/osgUtil/SceneView.cpp | 2 +- 24 files changed, 80 insertions(+), 65 deletions(-) diff --git a/.gitignore b/.gitignore index 84a2fea78..d0ef9cd12 100644 --- a/.gitignore +++ b/.gitignore @@ -78,3 +78,9 @@ PlatformSpecifics/Windows/*.rc # Visual Studio - Browsing Database File *.sdf *.opensdf + +#osx xcode +DerivedData/ +*.DS_Store +*.build +*.xcodeproj diff --git a/CMakeLists.txt b/CMakeLists.txt index 338d3d43f..232f0ba6c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -568,11 +568,17 @@ 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() +ELSEIF(OSG_GLES3_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") + 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") ENDIF() ELSE() IF (APPLE) diff --git a/include/osg/Camera b/include/osg/Camera index 376029201..a48b9d0eb 100644 --- a/include/osg/Camera +++ b/include/osg/Camera @@ -26,7 +26,7 @@ #include -#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) +#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) #define GL_FRONT_LEFT 0x0400 #define GL_FRONT_RIGHT 0x0401 #define GL_BACK_LEFT 0x0402 diff --git a/include/osg/Image b/include/osg/Image index b1e467caa..3a90175ea 100644 --- a/include/osg/Image +++ b/include/osg/Image @@ -61,10 +61,13 @@ #define GL_GREEN 0x1904 #define GL_BLUE 0x1905 #define GL_DEPTH_COMPONENT 0x1902 +#endif + +#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE) #define GL_STENCIL_INDEX 0x1901 #endif -#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) || defined(OSG_GL3_AVAILABLE) +#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE) || defined(OSG_GL3_AVAILABLE) #define GL_BITMAP 0x1A00 #define GL_COLOR_INDEX 0x1900 #define GL_INTENSITY12 0x804C diff --git a/include/osg/PolygonMode b/include/osg/PolygonMode index daa326788..230d6716e 100644 --- a/include/osg/PolygonMode +++ b/include/osg/PolygonMode @@ -17,7 +17,7 @@ #include #include -#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) +#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE) #define GL_POINT 0x1B00 #define GL_LINE 0x1B01 #define GL_FILL 0x1B02 diff --git a/include/osg/TexGen b/include/osg/TexGen index cb7200687..ed153d6f6 100644 --- a/include/osg/TexGen +++ b/include/osg/TexGen @@ -17,7 +17,7 @@ #include #include -#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) || defined(OSG_GL3_AVAILABLE) +#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE) || defined(OSG_GL3_AVAILABLE) #define GL_OBJECT_LINEAR 0x2401 #define GL_EYE_LINEAR 0x2400 #define GL_SPHERE_MAP 0x2402 diff --git a/src/osg/Depth.cpp b/src/osg/Depth.cpp index 32b09cdad..bf1877287 100644 --- a/src/osg/Depth.cpp +++ b/src/osg/Depth.cpp @@ -30,7 +30,7 @@ void Depth::apply(State&) const { glDepthFunc((GLenum)_func); glDepthMask((GLboolean)_depthWriteMask); -#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) +#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE) glDepthRangef(_zNear,_zFar); #else glDepthRange(_zNear,_zFar); diff --git a/src/osg/GL.in b/src/osg/GL.in index 2cacb8142..89c6bace4 100644 --- a/src/osg/GL.in +++ b/src/osg/GL.in @@ -172,13 +172,13 @@ #define GL_NONE 0x0 #endif -#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) +#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE) //GLES defines (OES) #define GL_RGB8_OES 0x8051 #define GL_RGBA8_OES 0x8058 #endif -#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) || defined(OSG_GL3_AVAILABLE) +#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE) || defined(OSG_GL3_AVAILABLE) #define GL_POLYGON 0x0009 #define GL_QUADS 0x0007 #define GL_QUAD_STRIP 0x0008 diff --git a/src/osg/Image.cpp b/src/osg/Image.cpp index b126048ee..1149acdc4 100644 --- a/src/osg/Image.cpp +++ b/src/osg/Image.cpp @@ -1061,7 +1061,7 @@ void Image::readPixels(int x,int y,int width,int height, void Image::readImageFromCurrentTexture(unsigned int contextID, bool copyMipMapsIfAvailable, GLenum type, unsigned int face) { -#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) +#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) // OSG_NOTICE<<"Image::readImageFromCurrentTexture()"<data()) return; @@ -378,7 +378,7 @@ void Texture1D::applyTexImage1D(GLenum target, Image* image, State& state, GLsiz void Texture1D::copyTexImage1D(State& state, int x, int y, int width) { -#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) +#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) const unsigned int contextID = state.getContextID(); // get the texture object for the current contextID. @@ -435,7 +435,7 @@ void Texture1D::copyTexImage1D(State& state, int x, int y, int width) void Texture1D::copyTexSubImage1D(State& state, int xoffset, int x, int y, int width) { -#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) +#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) const unsigned int contextID = state.getContextID(); // get the texture object for the current contextID. @@ -467,7 +467,7 @@ void Texture1D::copyTexSubImage1D(State& state, int xoffset, int x, int y, int w void Texture1D::allocateMipmap(State& state) const { -#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) +#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) const unsigned int contextID = state.getContextID(); // get the texture object for the current contextID. diff --git a/src/osg/TextureRectangle.cpp b/src/osg/TextureRectangle.cpp index e6e741e1c..87dbf6f9c 100644 --- a/src/osg/TextureRectangle.cpp +++ b/src/osg/TextureRectangle.cpp @@ -321,7 +321,7 @@ void TextureRectangle::applyTexImage_load(GLenum target, Image* image, State& st { glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE,GL_TRUE); - #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_PRIORITY,0.0f); #endif diff --git a/src/osg/glu/libutil/mipmap.cpp b/src/osg/glu/libutil/mipmap.cpp index af66c39e6..96c958bd6 100644 --- a/src/osg/glu/libutil/mipmap.cpp +++ b/src/osg/glu/libutil/mipmap.cpp @@ -267,7 +267,7 @@ void PixelStorageModes::retrieveStoreModes() { glGetIntegerv(GL_UNPACK_ALIGNMENT, &unpack_alignment); -#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) +#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) glGetIntegerv(GL_UNPACK_ROW_LENGTH, &unpack_row_length); glGetIntegerv(GL_UNPACK_SKIP_ROWS, &unpack_skip_rows); glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &unpack_skip_pixels); @@ -276,7 +276,7 @@ void PixelStorageModes::retrieveStoreModes() #endif glGetIntegerv(GL_PACK_ALIGNMENT, &pack_alignment); -#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) +#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) glGetIntegerv(GL_PACK_ROW_LENGTH, &pack_row_length); glGetIntegerv(GL_PACK_SKIP_ROWS, &pack_skip_rows); glGetIntegerv(GL_PACK_SKIP_PIXELS, &pack_skip_pixels); @@ -288,7 +288,7 @@ void PixelStorageModes::retrieveStoreModes() void PixelStorageModes::retrieveStoreModes3D() { glGetIntegerv(GL_UNPACK_ALIGNMENT, &unpack_alignment); -#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) +#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) glGetIntegerv(GL_UNPACK_ROW_LENGTH, &unpack_row_length); glGetIntegerv(GL_UNPACK_SKIP_ROWS, &unpack_skip_rows); glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &unpack_skip_pixels); @@ -299,7 +299,7 @@ void PixelStorageModes::retrieveStoreModes3D() #endif glGetIntegerv(GL_PACK_ALIGNMENT, &pack_alignment); -#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) +#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) glGetIntegerv(GL_PACK_ROW_LENGTH, &pack_row_length); glGetIntegerv(GL_PACK_SKIP_ROWS, &pack_skip_rows); glGetIntegerv(GL_PACK_SKIP_PIXELS, &pack_skip_pixels); @@ -3437,7 +3437,7 @@ static void closestFit(GLenum target, GLint width, GLint height, GLint internalFormat, GLenum format, GLenum type, GLint *newWidth, GLint *newHeight) { -#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) +#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) /* Use proxy textures if OpenGL version is >= 1.1 */ if ( (strtod((const char *)glGetString(GL_VERSION),NULL) >= 1.1) ) { @@ -3592,7 +3592,7 @@ int gluBuild1DMipmapLevelsCore(GLenum target, GLint internalFormat, GLint userLevel, GLint baseLevel,GLint maxLevel, const void *data) { -#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) +#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) GLint newwidth; GLint level, levels; GLushort *newImage; @@ -3786,7 +3786,7 @@ static int bitmapBuild2DMipmaps(GLenum target, GLint internalFormat, cmpts = elements_per_group(format,type); glPixelStorei(GL_UNPACK_ALIGNMENT, 2); -#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_SKIP_ROWS, 0); glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); @@ -3808,7 +3808,7 @@ static int bitmapBuild2DMipmaps(GLenum target, GLint internalFormat, otherImage = (GLushort *) malloc(memreq); if (otherImage == NULL) { glPixelStorei(GL_UNPACK_ALIGNMENT, psm.unpack_alignment); -#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_SKIP_ROWS, psm.unpack_skip_rows); glPixelStorei(GL_UNPACK_SKIP_PIXELS,psm.unpack_skip_pixels); glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length); @@ -3836,7 +3836,7 @@ static int bitmapBuild2DMipmaps(GLenum target, GLint internalFormat, } glPixelStorei(GL_UNPACK_ALIGNMENT, psm.unpack_alignment); -#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_SKIP_ROWS, psm.unpack_skip_rows); glPixelStorei(GL_UNPACK_SKIP_PIXELS, psm.unpack_skip_pixels); glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length); @@ -3913,7 +3913,7 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat, usersImage = (const GLubyte *) data + psm.unpack_skip_rows * rowsize + psm.unpack_skip_pixels * group_size; -#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_SKIP_ROWS, 0); glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); @@ -3925,20 +3925,20 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat, if (width == newwidth && height == newheight) { /* Use usersImage for level userLevel */ if (baseLevel <= level && level <= maxLevel) { -#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, psm.unpack_row_length); #endif glTexImage2D(target, level, internalFormat, width, height, 0, format, type, usersImage); } -#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, 0); #endif if(levels == 0) { /* we're done. clean up and return */ glPixelStorei(GL_UNPACK_ALIGNMENT, psm.unpack_alignment); -#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_SKIP_ROWS, psm.unpack_skip_rows); glPixelStorei(GL_UNPACK_SKIP_PIXELS, psm.unpack_skip_pixels); glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length); @@ -4001,7 +4001,7 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat, } if (dstImage == NULL) { glPixelStorei(GL_UNPACK_ALIGNMENT, psm.unpack_alignment); -#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_SKIP_ROWS, psm.unpack_skip_rows); glPixelStorei(GL_UNPACK_SKIP_PIXELS, psm.unpack_skip_pixels); glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length); @@ -4168,7 +4168,7 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat, } if (dstImage == NULL) { glPixelStorei(GL_UNPACK_ALIGNMENT, psm.unpack_alignment); -#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_SKIP_ROWS, psm.unpack_skip_rows); glPixelStorei(GL_UNPACK_SKIP_PIXELS, psm.unpack_skip_pixels); glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length); @@ -4227,7 +4227,7 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat, if (dstImage == NULL) { glPixelStorei(GL_UNPACK_ALIGNMENT, psm.unpack_alignment); -#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_SKIP_ROWS, psm.unpack_skip_rows); glPixelStorei(GL_UNPACK_SKIP_PIXELS, psm.unpack_skip_pixels); glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length); @@ -4415,7 +4415,7 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat, } if (dstImage == NULL) { glPixelStorei(GL_UNPACK_ALIGNMENT, psm.unpack_alignment); -#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_SKIP_ROWS, psm.unpack_skip_rows); glPixelStorei(GL_UNPACK_SKIP_PIXELS, psm.unpack_skip_pixels); glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length); @@ -4429,7 +4429,7 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat, level = userLevel; } -#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_SWAP_BYTES, GL_FALSE); #endif @@ -4579,7 +4579,7 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat, if (newMipmapImage == NULL) { /* out of memory so return */ glPixelStorei(GL_UNPACK_ALIGNMENT, psm.unpack_alignment); -#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_SKIP_ROWS, psm.unpack_skip_rows); glPixelStorei(GL_UNPACK_SKIP_PIXELS, psm.unpack_skip_pixels); glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length); @@ -4615,7 +4615,7 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat, } /* for level */ glPixelStorei(GL_UNPACK_ALIGNMENT, psm.unpack_alignment); -#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_SKIP_ROWS, psm.unpack_skip_rows); glPixelStorei(GL_UNPACK_SKIP_PIXELS, psm.unpack_skip_pixels); glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length); @@ -7428,7 +7428,7 @@ static void closestFit3D(GLTexImage3DProc gluTexImage3D, GLint internalFormat, GLenum format, GLenum type, GLint *newWidth, GLint *newHeight, GLint *newDepth) { -#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) +#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) GLint widthPowerOf2= nearestPower(width); GLint heightPowerOf2= nearestPower(height); GLint depthPowerOf2= nearestPower(depth); @@ -7837,7 +7837,7 @@ static int gluBuild3DMipmapLevelsCore(GLTexImage3DProc gluTexImage3D, } if(levels == 0) { /* we're done. clean up and return */ glPixelStorei(GL_UNPACK_ALIGNMENT, psm.unpack_alignment); -#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_SKIP_ROWS, psm.unpack_skip_rows); glPixelStorei(GL_UNPACK_SKIP_PIXELS, psm.unpack_skip_pixels); glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length); @@ -7903,7 +7903,7 @@ static int gluBuild3DMipmapLevelsCore(GLTexImage3DProc gluTexImage3D, } if (dstImage == NULL) { glPixelStorei(GL_UNPACK_ALIGNMENT, psm.unpack_alignment); -#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_SKIP_ROWS, psm.unpack_skip_rows); glPixelStorei(GL_UNPACK_SKIP_PIXELS, psm.unpack_skip_pixels); glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length); @@ -8124,7 +8124,7 @@ static int gluBuild3DMipmapLevelsCore(GLTexImage3DProc gluTexImage3D, } if (dstImage == NULL) { glPixelStorei(GL_UNPACK_ALIGNMENT, psm.unpack_alignment); -#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_SKIP_ROWS, psm.unpack_skip_rows); glPixelStorei(GL_UNPACK_SKIP_PIXELS, psm.unpack_skip_pixels); glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length); @@ -8185,7 +8185,7 @@ static int gluBuild3DMipmapLevelsCore(GLTexImage3DProc gluTexImage3D, if (dstImage == NULL) { glPixelStorei(GL_UNPACK_ALIGNMENT, psm.unpack_alignment); -#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_SKIP_ROWS, psm.unpack_skip_rows); glPixelStorei(GL_UNPACK_SKIP_PIXELS, psm.unpack_skip_pixels); glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length); @@ -8263,7 +8263,7 @@ static int gluBuild3DMipmapLevelsCore(GLTexImage3DProc gluTexImage3D, } if (dstImage == NULL) { glPixelStorei(GL_UNPACK_ALIGNMENT, psm.unpack_alignment); -#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_SKIP_ROWS, psm.unpack_skip_rows); glPixelStorei(GL_UNPACK_SKIP_PIXELS, psm.unpack_skip_pixels); glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length); @@ -8279,7 +8279,7 @@ static int gluBuild3DMipmapLevelsCore(GLTexImage3DProc gluTexImage3D, level = userLevel; } -#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_SWAP_BYTES, GL_FALSE); #endif @@ -8466,7 +8466,7 @@ static int gluBuild3DMipmapLevelsCore(GLTexImage3DProc gluTexImage3D, } /* for level */ glPixelStorei(GL_UNPACK_ALIGNMENT, psm.unpack_alignment); - #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_SKIP_ROWS, psm.unpack_skip_rows); glPixelStorei(GL_UNPACK_SKIP_PIXELS, psm.unpack_skip_pixels); glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length); diff --git a/src/osgDB/ObjectWrapper.cpp b/src/osgDB/ObjectWrapper.cpp index bab389342..ef0d8eab0 100644 --- a/src/osgDB/ObjectWrapper.cpp +++ b/src/osgDB/ObjectWrapper.cpp @@ -53,7 +53,7 @@ #define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 #endif -#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) +#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE) #define GL_POLYGON_SMOOTH_HINT 0x0C53 #define GL_LINE_SMOOTH_HINT 0x0C52 #define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B diff --git a/src/osgGA/StateSetManipulator.cpp b/src/osgGA/StateSetManipulator.cpp index cd75cb06a..2f5b61e05 100644 --- a/src/osgGA/StateSetManipulator.cpp +++ b/src/osgGA/StateSetManipulator.cpp @@ -96,7 +96,7 @@ bool StateSetManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& aa) (_stateset->getTextureMode(0,GL_TEXTURE_RECTANGLE)&mode)!=0 || (_stateset->getTextureMode(0,GL_TEXTURE_CUBE_MAP)&mode)!=0; - #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) _texture |= ((_stateset->getTextureMode(0,GL_TEXTURE_1D)&mode)!=0); #endif } @@ -181,7 +181,7 @@ void StateSetManipulator::setTextureEnabled(bool newtexture) if ( _texture ) mode = osg::StateAttribute::INHERIT|osg::StateAttribute::ON; for( unsigned int ii=0; ii<_maxNumOfTextureUnits; ii++ ) { - #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) _stateset->setTextureMode( ii, GL_TEXTURE_1D, mode ); #endif _stateset->setTextureMode( ii, GL_TEXTURE_2D, mode ); diff --git a/src/osgParticle/ParticleSystem.cpp b/src/osgParticle/ParticleSystem.cpp index 7d95b3516..c20bef1d5 100644 --- a/src/osgParticle/ParticleSystem.cpp +++ b/src/osgParticle/ParticleSystem.cpp @@ -460,7 +460,7 @@ void osgParticle::ParticleSystem::drawImplementation(osg::RenderInfo& renderInfo } // set up depth mask for first rendering pass -#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) +#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) glPushAttrib(GL_DEPTH_BUFFER_BIT); #endif @@ -469,7 +469,7 @@ void osgParticle::ParticleSystem::drawImplementation(osg::RenderInfo& renderInfo ad.dispatchArrays(state); ad.dispatchPrimitives(); -#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) +#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) // restore depth mask settings glPopAttrib(); #endif @@ -478,14 +478,14 @@ void osgParticle::ParticleSystem::drawImplementation(osg::RenderInfo& renderInfo if (_doublepass) { // set up color mask for second rendering pass -#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) +#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) glPushAttrib(GL_COLOR_BUFFER_BIT); #endif glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); ad.dispatchPrimitives(); -#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) +#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) // restore color mask settings glPopAttrib(); #endif diff --git a/src/osgPlugins/logo/ReaderWriterLOGO.cpp b/src/osgPlugins/logo/ReaderWriterLOGO.cpp index 7f3655456..0af8a20a7 100644 --- a/src/osgPlugins/logo/ReaderWriterLOGO.cpp +++ b/src/osgPlugins/logo/ReaderWriterLOGO.cpp @@ -98,7 +98,7 @@ class Logos: public osg::Drawable virtual void drawImplementation(osg::RenderInfo& renderInfo) const { - #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) if( renderInfo.getContextID() != _contextID ) return; diff --git a/src/osgShadow/ShadowMap.cpp b/src/osgShadow/ShadowMap.cpp index 724ff9fe6..3391523b7 100644 --- a/src/osgShadow/ShadowMap.cpp +++ b/src/osgShadow/ShadowMap.cpp @@ -341,7 +341,7 @@ void ShadowMap::init() _stateset->setTextureAttribute(_baseTextureUnit,fakeTex,osg::StateAttribute::ON); _stateset->setTextureMode(_baseTextureUnit,GL_TEXTURE_2D,osg::StateAttribute::ON); _stateset->setTextureMode(_baseTextureUnit,GL_TEXTURE_3D,osg::StateAttribute::OFF); - #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) _stateset->setTextureMode(_baseTextureUnit,GL_TEXTURE_1D,osg::StateAttribute::OFF); #endif } diff --git a/src/osgShadow/StandardShadowMap.cpp b/src/osgShadow/StandardShadowMap.cpp index ae87c55ea..564aff078 100644 --- a/src/osgShadow/StandardShadowMap.cpp +++ b/src/osgShadow/StandardShadowMap.cpp @@ -560,7 +560,7 @@ void StandardShadowMap::ViewData::init( ThisClass *st, osgUtil::CullVisitor *cv _stateset->setTextureAttribute(st->_baseTextureUnit,fakeTex,osg::StateAttribute::ON); _stateset->setTextureMode(st->_baseTextureUnit,GL_TEXTURE_2D,osg::StateAttribute::ON); _stateset->setTextureMode(st->_baseTextureUnit,GL_TEXTURE_3D,osg::StateAttribute::OFF); - #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) _stateset->setTextureMode(st->_baseTextureUnit,GL_TEXTURE_1D,osg::StateAttribute::OFF); #endif } @@ -664,7 +664,7 @@ void StandardShadowMap::ViewData::init( ThisClass *st, osgUtil::CullVisitor *cv for( unsigned stage = 1; stage < 4; stage ++ ) { - #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) stateset->setTextureMode( stage, GL_TEXTURE_1D, osg::StateAttribute::OVERRIDE | osg::StateAttribute::OFF ); #endif stateset->setTextureMode( stage, GL_TEXTURE_2D, osg::StateAttribute::OVERRIDE | osg::StateAttribute::OFF ); diff --git a/src/osgSim/LightPointDrawable.cpp b/src/osgSim/LightPointDrawable.cpp index 4f5b4f115..1a6b9f7bc 100644 --- a/src/osgSim/LightPointDrawable.cpp +++ b/src/osgSim/LightPointDrawable.cpp @@ -85,7 +85,7 @@ void LightPointDrawable::reset() void LightPointDrawable::drawImplementation(osg::RenderInfo& renderInfo) const { -#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) +#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) osg::State& state = *renderInfo.getState(); state.applyMode(GL_POINT_SMOOTH,true); diff --git a/src/osgSim/LightPointSpriteDrawable.cpp b/src/osgSim/LightPointSpriteDrawable.cpp index 607f97e20..530725613 100644 --- a/src/osgSim/LightPointSpriteDrawable.cpp +++ b/src/osgSim/LightPointSpriteDrawable.cpp @@ -30,7 +30,7 @@ LightPointSpriteDrawable::LightPointSpriteDrawable(const LightPointSpriteDrawabl void LightPointSpriteDrawable::drawImplementation(osg::RenderInfo& renderInfo) const { -#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) +#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) osg::State& state = *renderInfo.getState(); if (!state.getModeValidity(GL_POINT_SPRITE_ARB)) diff --git a/src/osgUtil/RenderStage.cpp b/src/osgUtil/RenderStage.cpp index a08bf3a67..2b707e57d 100644 --- a/src/osgUtil/RenderStage.cpp +++ b/src/osgUtil/RenderStage.cpp @@ -519,7 +519,7 @@ void RenderStage::runCameraSetUp(osg::RenderInfo& renderInfo) { setDrawBuffer( GL_NONE, true ); setReadBuffer( GL_NONE, true ); - #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) glDrawBuffer( GL_NONE ); glReadBuffer( GL_NONE ); #endif @@ -911,7 +911,7 @@ void RenderStage::drawInner(osg::RenderInfo& renderInfo,RenderLeaf*& previous, b if (!using_multiple_render_targets) { - #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) if( getDrawBufferApplyMask() ) glDrawBuffer(_drawBuffer); @@ -997,7 +997,7 @@ void RenderStage::drawInner(osg::RenderInfo& renderInfo,RenderLeaf*& previous, b blitMask, GL_NEAREST); } -#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) +#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) if (needToBlitColorBuffers) { for (FrameBufferObject::AttachmentMap::const_iterator @@ -1349,7 +1349,7 @@ void RenderStage::drawImplementation(osg::RenderInfo& renderInfo,RenderLeaf*& pr if (_clearMask & GL_DEPTH_BUFFER_BIT) { - #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) glClearDepth( _clearDepth); #else glClearDepthf( _clearDepth); @@ -1366,7 +1366,7 @@ void RenderStage::drawImplementation(osg::RenderInfo& renderInfo,RenderLeaf*& pr state.haveAppliedAttribute( osg::StateAttribute::STENCIL ); } - #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) if (_clearMask & GL_ACCUM_BUFFER_BIT) { glClearAccum( _clearAccum[0], _clearAccum[1], _clearAccum[2], _clearAccum[3]); diff --git a/src/osgUtil/SceneView.cpp b/src/osgUtil/SceneView.cpp index 89296b3c1..b4fd18a89 100644 --- a/src/osgUtil/SceneView.cpp +++ b/src/osgUtil/SceneView.cpp @@ -1232,7 +1232,7 @@ void SceneView::draw() case(osg::DisplaySettings::HORIZONTAL_INTERLACE): case(osg::DisplaySettings::CHECKERBOARD): { - #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) if( 0 == ( _camera->getInheritanceMask() & DRAW_BUFFER) ) { _renderStageLeft->setDrawBuffer(_camera->getDrawBuffer()); From 1deaac75083c9b715fb553f5dff3b2ac0cf58298 Mon Sep 17 00:00:00 2001 From: Thomas Hogarth Date: Fri, 17 Mar 2017 18:01:44 +0000 Subject: [PATCH 2/6] More gles3 tweaks --- examples/osgviewerIPhone/CMakeLists.txt | 2 +- examples/osgviewerIPhone/osgPlugins.h | 2 +- src/osgText/Text.cpp | 12 ++++++------ src/osgViewer/GraphicsWindowIOS.mm | 5 +++-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/examples/osgviewerIPhone/CMakeLists.txt b/examples/osgviewerIPhone/CMakeLists.txt index 4697fe047..067bd8977 100644 --- a/examples/osgviewerIPhone/CMakeLists.txt +++ b/examples/osgviewerIPhone/CMakeLists.txt @@ -6,7 +6,7 @@ SET(TARGET_SRC osgIPhoneViewer-Info.plist ) -SET(TARGET_ADDED_LIBRARIES osgdb_osg osgdb_imageio osgdb_avfoundation) +SET(TARGET_ADDED_LIBRARIES osgdb_osg osgdb_imageio) # osgdb_avfoundation doesn't seem to get added on iOS? #backup setting SET(TMP_OSG_BUILD_APPLICATION_BUNDLES {$OSG_BUILD_APPLICATION_BUNDLES}) diff --git a/examples/osgviewerIPhone/osgPlugins.h b/examples/osgviewerIPhone/osgPlugins.h index 6ed790eb1..160f6a23a 100644 --- a/examples/osgviewerIPhone/osgPlugins.h +++ b/examples/osgviewerIPhone/osgPlugins.h @@ -14,6 +14,6 @@ USE_GRAPICSWINDOW_IMPLEMENTATION(IOS) USE_OSGPLUGIN(osg) USE_OSGPLUGIN(imageio) -USE_OSGPLUGIN(avfoundation) +//USE_OSGPLUGIN(avfoundation) //USE_OSGPLUGIN(freetype) diff --git a/src/osgText/Text.cpp b/src/osgText/Text.cpp index 2c614f0e2..d51f0e1c9 100644 --- a/src/osgText/Text.cpp +++ b/src/osgText/Text.cpp @@ -1150,7 +1150,7 @@ void Text::drawImplementation(osg::State& state, const osg::Vec4& colorMultiplie osg::State::ApplyModeProxy applyMode(state, GL_LIGHTING, false); osg::State::ApplyTextureModeProxy applyTextureMode(state, 0, GL_TEXTURE_2D, false); - #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) switch(_backdropImplementation) { case NO_DEPTH_BUFFER: @@ -1182,7 +1182,7 @@ void Text::drawImplementation(osg::State& state, const osg::Vec4& colorMultiplie (*itr)->draw(state, usingVertexBufferObjects); } - #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) + #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) switch(_backdropImplementation) { case NO_DEPTH_BUFFER: @@ -1492,7 +1492,7 @@ void Text::drawTextWithBackdrop(osg::State& state, const osg::Vec4& colorMultipl void Text::renderWithPolygonOffset(osg::State& state, const osg::Vec4& colorMultiplier) const { -#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) +#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) bool usingVertexBufferObjects = state.useVertexBufferObject(_supportsVertexBufferObjects && _useVertexBufferObjects); VertexArrayState* vas = state.getCurrentVertexArrayState(); @@ -1557,7 +1557,7 @@ void Text::renderWithPolygonOffset(osg::State& state, const osg::Vec4& colorMult void Text::renderWithNoDepthBuffer(osg::State& state, const osg::Vec4& colorMultiplier) const { -#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) +#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)&& !defined(OSG_GLES3_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) bool usingVertexBufferObjects = state.useVertexBufferObject(_supportsVertexBufferObjects && _useVertexBufferObjects); @@ -1609,7 +1609,7 @@ void Text::renderWithNoDepthBuffer(osg::State& state, const osg::Vec4& colorMult // This idea comes from Paul Martz's OpenGL FAQ: 13.050 void Text::renderWithDepthRange(osg::State& state, const osg::Vec4& colorMultiplier) const { -#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) +#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) bool usingVertexBufferObjects = state.useVertexBufferObject(_supportsVertexBufferObjects && _useVertexBufferObjects); @@ -1665,7 +1665,7 @@ void Text::renderWithDepthRange(osg::State& state, const osg::Vec4& colorMultipl void Text::renderWithStencilBuffer(osg::State& state, const osg::Vec4& colorMultiplier) const { -#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) +#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) bool usingVertexBufferObjects = state.useVertexBufferObject(_supportsVertexBufferObjects && _useVertexBufferObjects); diff --git a/src/osgViewer/GraphicsWindowIOS.mm b/src/osgViewer/GraphicsWindowIOS.mm index a91f1155b..904aa99a8 100644 --- a/src/osgViewer/GraphicsWindowIOS.mm +++ b/src/osgViewer/GraphicsWindowIOS.mm @@ -9,8 +9,9 @@ #if OSG_GLES1_FEATURES #import #else - #import - #if defined(OSG_GLES3_FEATURES) + #if defined(OSG_GLES2_FEATURES) + #import + #elif defined(OSG_GLES3_FEATURES) #import #endif From c7af72daaed3d293bc0065e3af53bc17bc12c600 Mon Sep 17 00:00:00 2001 From: Thomas Hogarth Date: Sat, 18 Mar 2017 06:53:32 +0000 Subject: [PATCH 3/6] 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 --- CMakeLists.txt | 17 +- examples/osgviewerIPhone/CMakeLists.txt | 8 +- .../iphoneViewerAppDelegate.mm | 156 ++++++++++++------ examples/osgviewerIPhone/shaders.h | 113 +++++++++++++ src/osg/GLExtensions.cpp | 26 +-- src/osg/State.cpp | 4 +- src/osgPlugins/avfoundation/CMakeLists.txt | 4 +- src/osgText/Glyph.cpp | 12 +- src/osgViewer/GraphicsWindowIOS.mm | 57 ++++--- 9 files changed, 298 insertions(+), 99 deletions(-) create mode 100644 examples/osgviewerIPhone/shaders.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 232f0ba6c..3813ba715 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -239,8 +239,8 @@ IF(APPLE) IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR) #you need to manually set the default sdk version here - SET (IPHONE_SDKVER "6.0" CACHE STRING "IOS SDK-Version") - SET (IPHONE_VERSION_MIN "4.2" CACHE STRING "IOS minimum os version, use 7.0 or greater to get 64bit support") + SET (IPHONE_SDKVER "10.2" CACHE STRING "IOS SDK-Version") + SET (IPHONE_VERSION_MIN "7.0" CACHE STRING "IOS minimum os version, use 7.0 or greater to get 64bit support") #the below is taken from ogre, it states the gcc stuff needs to happen before PROJECT() is called. I've no clue if we even need it # Force gcc <= 4.2 on iPhone @@ -499,6 +499,8 @@ 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_GLES3_AVAILABLE "Set to OFF to disable use of OpenGL ES 3.x functions library." ON ) +ELSEIF ((OPENGL_PROFILE STREQUAL "GLES2+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() @@ -510,7 +512,7 @@ ENDIF() OPTION(OSG_GL_LIBRARY_STATIC "Set to ON to statically link with OpenGL/GLES library." OFF) # Map the OSG_GL*_AVAILABLE settings to OSG_GL_* settings -IF (OSG_GLES2_AVAILABLE OR OSG_GL3_AVAILABLE) +IF (OSG_GLES2_AVAILABLE OR OSG_GLES3_AVAILABLE OR OSG_GL3_AVAILABLE) OPTION(OSG_GL_DISPLAYLISTS_AVAILABLE "Set to OFF to disable use of OpenGL display lists." OFF) OPTION(OSG_GL_MATRICES_AVAILABLE "Set to OFF to disable use of OpenGL built-in matrices." OFF) OPTION(OSG_GL_VERTEX_FUNCS_AVAILABLE "Set to OFF to disable use of OpenGL vertex functions such as glVertex/glColor etc." OFF) @@ -530,7 +532,7 @@ ELSE() OPTION(OSG_GL_FIXED_FUNCTION_AVAILABLE "Set to OFF to disable use of OpenGL fixed function pipeline." ON) ENDIF() -IF (OSG_GLES1_AVAILABLE OR OSG_GLES2_AVAILABLE) +IF (OSG_GLES1_AVAILABLE OR OSG_GLES2_AVAILABLE OR OSG_GLES3_AVAILABLE) OPTION(OSG_CPP_EXCEPTIONS_AVAILABLE "Set to OFF to disable compile of OSG components that use C++ exceptions." OFF) ELSE() OPTION(OSG_CPP_EXCEPTIONS_AVAILABLE "Set to OFF to disable compile of OSG components that use C++ exceptions." ON) @@ -641,6 +643,13 @@ IF(ANDROID) FIND_LIBRARY(OPENGL_gl_LIBRARY GLESv2 PATHS ${ANDROID_SYSROOT}/usr/lib) + ELSEIF(OSG_GLES3_AVAILABLE) + FIND_PATH(OPENGL_INCLUDE_DIR GLES3/gl3.h + PATHS + ${ANDROID_SYSROOT}/usr/include) + FIND_LIBRARY(OPENGL_gl_LIBRARY GLESv3 + PATHS + ${ANDROID_SYSROOT}/usr/lib) ENDIF() ENDIF() diff --git a/examples/osgviewerIPhone/CMakeLists.txt b/examples/osgviewerIPhone/CMakeLists.txt index 067bd8977..f5b0bf0a6 100644 --- a/examples/osgviewerIPhone/CMakeLists.txt +++ b/examples/osgviewerIPhone/CMakeLists.txt @@ -3,16 +3,20 @@ SET(TARGET_SRC iphoneViewerAppDelegate.mm main.m osgPlugins.h + shaders.h osgIPhoneViewer-Info.plist ) -SET(TARGET_ADDED_LIBRARIES osgdb_osg osgdb_imageio) # osgdb_avfoundation doesn't seem to get added on iOS? +SET(TARGET_ADDED_LIBRARIES osgdb_osg osgdb_imageio osgdb_avfoundation) #backup setting SET(TMP_OSG_BUILD_APPLICATION_BUNDLES {$OSG_BUILD_APPLICATION_BUNDLES}) SET(OSG_BUILD_APPLICATION_BUNDLES TRUE) +SET(MACOSX_DEPLOYMENT_TARGET, ${IPHONE_VERSION_MIN}) SETUP_EXAMPLE(osgViewerIPhone) -SET_TARGET_PROPERTIES(example_osgViewerIPhone PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer") +SET_TARGET_PROPERTIES(example_osgViewerIPhone PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer" + XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET ${IPHONE_VERSION_MIN} + XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2") #restore setting SET(OSG_BUILD_APPLICATION_BUNDLES {$TMP_OSG_BUILD_APPLICATION_BUNDLES}) diff --git a/examples/osgviewerIPhone/iphoneViewerAppDelegate.mm b/examples/osgviewerIPhone/iphoneViewerAppDelegate.mm index 439fe60ee..fa5b9562a 100644 --- a/examples/osgviewerIPhone/iphoneViewerAppDelegate.mm +++ b/examples/osgviewerIPhone/iphoneViewerAppDelegate.mm @@ -1,17 +1,25 @@ // Created by Thomas Hogarth 2009 -// cleaned up by Stephan Huber 2013 +// Cleaned up by Stephan Huber 2013 +// Added gles3 support 2017 TH // -// this example will create a fullscreen window showing a grey box. You can interact with it via +// this example will create a fullscreen window showing a box. You can interact with it via // multi-touch gestures. #import "iphoneViewerAppDelegate.h" #include #include +#include //include the iphone specific windowing stuff #include +#include "shaders.h" + +// global programs +osg::ref_ptr _vertColorProgram; +osg::ref_ptr _textProgram; + @interface MyViewController : UIViewController @@ -33,10 +41,19 @@ @synthesize _window; +// +// Shape drawables sometimes use gl_quads so use this function to convert +// +void optimizeNode(osg::Node* node) { + osgUtil::Optimizer optimizer; + optimizer.optimize(node, osgUtil::Optimizer::TRISTRIP_GEOMETRY); +} +// +// create a camera to set up the projection and model view matrices, and the subgraph to draw in the HUD +// osg::Camera* createHUD(unsigned int w, unsigned int h) { - // create a camera to set up the projection and model view matrices, and the subgraph to draw in the HUD osg::Camera* camera = new osg::Camera; // set the projection matrix @@ -55,28 +72,25 @@ osg::Camera* createHUD(unsigned int w, unsigned int h) // we don't want the camera to grab event focus from the viewers main camera(s). camera->setAllowEventFocus(false); - - // add to this camera a subgraph to render { - osg::Geode* geode = new osg::Geode(); - std::string timesFont("fonts/arial.ttf"); - - // turn lighting off for the text and disable depth test to ensure it's always ontop. - osg::StateSet* stateset = geode->getOrCreateStateSet(); - stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF); - osg::Vec3 position(50.0f,h-50,0.0f); { - osgText::Text* text = new osgText::Text; - geode->addDrawable( text ); - - text->setFont(timesFont); + osgText::Text* text = new osgText::Text(); + text->setUseVertexBufferObjects(true); + text->setFont(0);//"fonts/arial.ttf"); text->setPosition(position); text->setText("A simple multi-touch-example\n1 touch = rotate, \n2 touches = drag + scale, \n3 touches = home"); + +#if defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE) + text->getOrCreateStateSet()->setAttributeAndModes(_textProgram, osg::StateAttribute::ON); + text->getOrCreateStateSet()->addUniform(new osg::Uniform("glyphTexture",0)); + text->getOrCreateStateSet()->addUniform(new osg::Uniform("color", osg::Vec4(1.0f,1.0f,1.0f,1.0f))); +#endif + geode->addDrawable( text ); } camera->addChild(geode); @@ -106,24 +120,36 @@ private: osg::Geode* geode = new osg::Geode(); osg::ShapeDrawable* drawable = new osg::ShapeDrawable(new osg::Box(osg::Vec3(0,0,0), 100)); + drawable->setUseVertexBufferObjects(true); + drawable->setDataVariance(osg::Object::DYNAMIC); +#if defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE) + drawable->getOrCreateStateSet()->setAttributeAndModes(_vertColorProgram, osg::StateAttribute::ON); + drawable->getOrCreateStateSet()->addUniform(new osg::Uniform("color", osg::Vec4(0.5, 0.5, 0.5,1))); + optimizeNode(drawable); +#else drawable->setColor(osg::Vec4(0.5, 0.5, 0.5,1)); +#endif + geode->addDrawable(drawable); ss << "Touch " << i; osgText::Text* text = new osgText::Text; - geode->addDrawable( text ); - drawable->setDataVariance(osg::Object::DYNAMIC); - _drawables.push_back(drawable); - - - text->setFont("fonts/arial.ttf"); + text->setUseVertexBufferObjects(true); + text->setFont(0); //"fonts/arial.ttf"); text->setPosition(osg::Vec3(110,0,0)); - text->setText(ss.str()); - _texts.push_back(text); text->setDataVariance(osg::Object::DYNAMIC); + text->setText(ss.str()); +#if defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE) + text->getOrCreateStateSet()->setAttributeAndModes(_textProgram, osg::StateAttribute::ON); + text->getOrCreateStateSet()->addUniform(new osg::Uniform("glyphTexture",0)); + text->getOrCreateStateSet()->addUniform(new osg::Uniform("color", osg::Vec4(1.0f,1.0f,1.0f,1.0f))); +#endif + geode->addDrawable( text ); + _drawables.push_back(drawable); + _texts.push_back(text); osg::MatrixTransform* mat = new osg::MatrixTransform(); mat->addChild(geode); @@ -133,8 +159,6 @@ private: parent_group->addChild(mat); } - - parent_group->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF); } virtual bool handle (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa, osg::Object *, osg::NodeVisitor *) @@ -175,32 +199,41 @@ private: ss << "Touch " << tp.id; _texts[j]->setText(ss.str()); + osg::Vec4 color; + switch (tp.phase) { case osgGA::GUIEventAdapter::TOUCH_BEGAN: - _drawables[j]->setColor(osg::Vec4(0,1,0,1)); - std::cout << "touch began: " << ss.str() << std::endl; + color = osg::Vec4(0,1,0,1); + + OSG_INFO << "touch began: " << ss.str() << std::endl; break; case osgGA::GUIEventAdapter::TOUCH_MOVED: - //std::cout << "touch moved: " << ss.str() << std::endl; - _drawables[j]->setColor(osg::Vec4(1,1,1,1)); + //OSG_INFO << "touch moved: " << ss.str() << std::endl; + color = osg::Vec4(1,1,1,1); break; case osgGA::GUIEventAdapter::TOUCH_ENDED: - _drawables[j]->setColor(osg::Vec4(1,0,0,1)); - std::cout << "touch ended: " << ss.str() << std::endl; + color = osg::Vec4(1,0,0,1); + OSG_INFO << "touch ended: " << ss.str() << std::endl; ++num_touch_ended; break; case osgGA::GUIEventAdapter::TOUCH_STATIONERY: - _drawables[j]->setColor(osg::Vec4(0.8,0.8,0.8,1)); + color = osg::Vec4(0.5,0.5,0.5,1); break; default: break; } +#if defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE) + _drawables[j]->getOrCreateStateSet()->addUniform(new osg::Uniform("color", color)); +#else + _drawables[j]->setColor(color); +#endif + } // hide unused geometry @@ -279,11 +312,11 @@ private: osg::ref_ptr windata = new osgViewer::GraphicsWindowIOS::WindowData(parent_view); // Setup the traits parameters - traits->x = 50; - traits->y = 50; - traits->width = w-100; - traits->height = h-100; - traits->depth = 16; //keep memory down, default is currently 24 + traits->x = 0; + traits->y = 0; + traits->width = w; + traits->height = h; + traits->depth = 16; //can be 16 or 24 traits->windowDecoration = false; traits->doubleBuffer = true; traits->sharedContext = 0; @@ -301,43 +334,64 @@ private: { _viewer->getCamera()->setGraphicsContext(graphicsContext); _viewer->getCamera()->setViewport(new osg::Viewport(0, 0, traits->width, traits->height)); + _viewer->getCamera()->setProjectionMatrixAsPerspective(60.0, (double)traits->width/(double)traits->height, 0.1, 1000.0); } } - + + // create our default programs +#if defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE) + _textProgram = new osg::Program(); + _textProgram->addShader( new osg::Shader(osg::Shader::VERTEX, TextShaderVert)); + _textProgram->addShader( new osg::Shader(osg::Shader::FRAGMENT, TextShaderFrag)); + + _vertColorProgram = new osg::Program(); + _vertColorProgram->addShader( new osg::Shader(osg::Shader::VERTEX, ColorShaderVert)); + _vertColorProgram->addShader( new osg::Shader(osg::Shader::FRAGMENT, ColorShaderFrag)); +#endif //create root - _root = new osg::MatrixTransform(); + _root = new osg::MatrixTransform(); + _root->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF | osg::StateAttribute::OVERRIDE); //load and attach scene model - osg::ref_ptr model = (osgDB::readNodeFile("hog.osg")); - if (model) { - _root->addChild(model); - } - else { + osg::ref_ptr model = osgDB::readNodeFile("hog.osg"); + if (!model) { osg::Geode* geode = new osg::Geode(); - osg::ShapeDrawable* drawable = new osg::ShapeDrawable(new osg::Box(osg::Vec3(1,1,1), 1)); + osg::ShapeDrawable* drawable = new osg::ShapeDrawable(new osg::Box(osg::Vec3(0,0,0), 1)); geode->addDrawable(drawable); - _root->addChild(geode); + model = geode; } + // attach shader program if needed +#if defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE) + model->getOrCreateStateSet()->setAttributeAndModes(_vertColorProgram, osg::StateAttribute::ON); + model->getOrCreateStateSet()->addUniform(new osg::Uniform("color", osg::Vec4(0.1f,0.4f,0.8f,1.0f))); + optimizeNode(model); +#endif + + _root->addChild(model); + + // create text hud osg::Camera* hud_camera = createHUD(w,h); _root->addChild(hud_camera); - + + // attach root to viewer and add event handlers _viewer->setSceneData(_root.get()); _viewer->setCameraManipulator(new osgGA::MultiTouchTrackballManipulator()); - _viewer->addEventHandler(new TestMultiTouchEventHandler(hud_camera)); - - // sun single-threaded + // run single-threaded _viewer->setThreadingModel(osgViewer::Viewer::SingleThreaded); + osg::setNotifyLevel(osg::INFO); + _viewer->realize(); // render a frame so the window-manager shows some content and not only an empty + black window _viewer->frame(); + osg::setNotifyLevel(osg::WARN); // create a display link, which will update our scene on every screen-refresh _displayLink = [application.keyWindow.screen displayLinkWithTarget:self selector:@selector(updateScene)]; diff --git a/examples/osgviewerIPhone/shaders.h b/examples/osgviewerIPhone/shaders.h new file mode 100644 index 000000000..cd3e83024 --- /dev/null +++ b/examples/osgviewerIPhone/shaders.h @@ -0,0 +1,113 @@ +#pragma once + +#include + +// +// vertex color shader +// +#if OSG_GLES3_FEATURES + +const char* ColorShaderVert = +"#version 300 es\n" +"in vec4 osg_Vertex;\n" +"uniform mat4 osg_ModelViewProjectionMatrix;\n" +"void main()\n" +"{\n" +" gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;\n" +"}\n"; + +const char* ColorShaderFrag = +"#version 300 es\n" +"uniform lowp vec4 color;\n" +"out lowp vec4 fragColor;\n" +"void main()\n" +"{\n" +" fragColor = color;\n" +"}\n"; + +#elif OSG_GLES2_FEATURES + +const char* ColorShaderVert = +"#version 100\n" +"attribute vec4 osg_Vertex;\n" +"uniform mat4 osg_ModelViewProjectionMatrix;\n" +"void main()\n" +"{\n" +" gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;\n" +"}\n"; + +const char* ColorShaderFrag = +"#version 100\n" +"uniform lowp vec4 color;\n" +"void main()\n" +"{\n" +" gl_FragColor = color;\n" +"}\n"; + +#elif + +const char* ColorShaderVert = NULL; +const char* ColorShaderFrag = NULL; + +#endif + + +// +// text shader +// +#if OSG_GLES3_FEATURES + +const char* TextShaderVert = +"#version 300 es\n" +"in vec4 osg_Vertex;\n" +"in vec4 osg_MultiTexCoord0;\n" +"uniform mat4 osg_ModelViewProjectionMatrix;\n" +"out vec4 texCoord;\n" +"void main()\n" +"{\n" +" gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;\n" +" texCoord = osg_MultiTexCoord0;\n" +"}\n"; + +const char* TextShaderFrag = +"#version 300 es\n" +"in lowp vec4 texCoord;\n" +"uniform sampler2D glyphTexture;\n" +"uniform lowp vec4 color;\n" +"out lowp vec4 fragColor;\n" +"void main()\n" +"{\n" +" //lowp vec4 gc = texture(glyphTexture, texCoord.xy);\n" +" fragColor = color * texture(glyphTexture, texCoord.xy).a;\n" +"}\n"; + +#elif OSG_GLES2_FEATURES + +const char* TextShaderVert = +"#version 100\n" +"attribute vec4 osg_Vertex;\n" +"attribute vec4 osg_MultiTexCoord0;\n" +"uniform mat4 osg_ModelViewProjectionMatrix;\n" +"varying vec4 texCoord;\n" +"void main()\n" +"{\n" +" gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;\n" +" texCoord = osg_MultiTexCoord0;\n" +"}\n"; + +const char* TextShaderFrag = +"#version 100\n" +"varying lowp vec4 texCoord;\n" +"uniform sampler2D glyphTexture;\n" +"uniform lowp vec4 color;\n" +"void main()\n" +"{\n" +" gl_FragColor = color * texture2D(glyphTexture, texCoord.xy).a;\n" +"}\n"; + +#elif + +const char* TextShaderVert = NULL; +const char* TextShaderFrag = NULL; + +#endif diff --git a/src/osg/GLExtensions.cpp b/src/osg/GLExtensions.cpp index 4b8306867..588208a6a 100644 --- a/src/osg/GLExtensions.cpp +++ b/src/osg/GLExtensions.cpp @@ -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 diff --git a/src/osg/State.cpp b/src/osg/State.cpp index 43eed6cb6..727e77b52 100644 --- a/src/osg/State.cpp +++ b/src/osg/State.cpp @@ -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 diff --git a/src/osgPlugins/avfoundation/CMakeLists.txt b/src/osgPlugins/avfoundation/CMakeLists.txt index 07b276b30..04340f216 100644 --- a/src/osgPlugins/avfoundation/CMakeLists.txt +++ b/src/osgPlugins/avfoundation/CMakeLists.txt @@ -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() diff --git a/src/osgText/Glyph.cpp b/src/osgText/Glyph.cpp index 068ce1fb0..27a621781 100644 --- a/src/osgText/Glyph.cpp +++ b/src/osgText/Glyph.cpp @@ -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 diff --git a/src/osgViewer/GraphicsWindowIOS.mm b/src/osgViewer/GraphicsWindowIOS.mm index 904aa99a8..c57cd45d0 100644 --- a/src/osgViewer/GraphicsWindowIOS.mm +++ b/src/osgViewer/GraphicsWindowIOS.mm @@ -9,9 +9,13 @@ #if OSG_GLES1_FEATURES #import #else - #if defined(OSG_GLES2_FEATURES) + + #define MUTLI_GLES (OSG_GLES2_FEATURES && OSG_GLES3_FEATURES) + + #if OSG_GLES2_FEATURES || MUTLI_GLES #import - #elif defined(OSG_GLES3_FEATURES) + #endif + #if OSG_GLES3_FEATURES || MUTLI_GLES #import #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 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 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; } From 2841d78653f8d25dff133b123a94bb7a16e7849b Mon Sep 17 00:00:00 2001 From: Thomas Hogarth Date: Sat, 18 Mar 2017 07:32:17 +0000 Subject: [PATCH 4/6] updated ios build instructions in readme --- README.md | 88 ++++++++++++++++++++++++++----------------------------- 1 file changed, 41 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index 7e1526d14..38758e8f2 100644 --- a/README.md +++ b/README.md @@ -159,54 +159,48 @@ still images, and a QTKit plugin will need to be developed to handle animations. -### Section 3. Release notes on iOS build, by Thomas Hoghart +### Section 3. Release notes on iOS build, by Thomas Hogarth -* Run CMake with either OSG_BUILD_PLATFORM_IPHONE or OSG_BUILD_PLATFORM_IPHONE_SIMULATOR set: - $ mkdir build-iOS ; cd build-iOS - $ ccmake -DOSG_BUILD_PLATFORM_IPHONE_SIMULATOR=YES -G Xcode .. -* Check that CMAKE_OSX_ARCHITECTURE is i386 for the simulator or armv6;armv7 for the device -* Disable DYNAMIC_OPENSCENEGRAPH, DYNAMIC_OPENTHREADS - 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 *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) -* Ensure that CMake_OSX_SYSROOT points to your iOS SDK. -* Generate the Xcode project -* Open the Xcode project - $ open OpenSceneGraph.xcodeproj -* Under Sources -> osgDB, select FileUtils.cpp and open the 'Get Info' panel, change File Type - to source.cpp.objcpp +With CMake, XCode and the iOS sdk installed you can generate an iOS XCode +project using the following command line -Here's an example for the command-line: - $ cmake -G Xcode \ - -D OSG_BUILD_PLATFORM_IPHONE:BOOL=ON \ - -D CMAKE_CXX_FLAGS:STRING="-ftree-vectorize -fvisibility-inlines-hidden -mno-thumb -arch armv6 -pipe -no-cpp-precomp -miphoneos-version-min=3.1 -mno-thumb" \ - -D BUILD_OSG_APPLICATIONS:BOOL=OFF \ - -D OSG_BUILD_FRAMEWORKS:BOOL=OFF \ - -D OSG_WINDOWING_SYSTEM:STRING=IOS \ - -D OSG_BUILD_PLATFORM_IPHONE:BOOL=ON \ - -D CMAKE_OSX_ARCHITECTURES:STRING="armv6;armv7" \ - -D CMAKE_OSX_SYSROOT:STRING=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk \ - -D OSG_GL1_AVAILABLE:BOOL=OFF \ - -D OSG_GL2_AVAILABLE:BOOL=OFF \ - -D OSG_GLES1_AVAILABLE:BOOL=ON \ - -D OSG_GL_DISPLAYLISTS_AVAILABLE:BOOL=OFF \ - -D OSG_GL_FIXED_FUNCTION_AVAILABLE:BOOL=ON \ - -D OSG_GL_LIBRARY_STATIC:BOOL=OFF \ - -D OSG_GL_MATRICES_AVAILABLE:BOOL=ON \ - -D OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE:BOOL=ON \ - -D OSG_GL_VERTEX_FUNCS_AVAILABLE:BOOL=OFF \ - -D DYNAMIC_OPENSCENEGRAPH:BOOL=OFF \ - -D DYNAMIC_OPENTHREADS:BOOL=OFF . +export THIRDPARTY_PATH=/path/to/my/3rdParty +cmake ./ -G Xcode -DOSG_BUILD_PLATFORM_IPHONE:BOOL=ON \ +-DIPHONE_SDKVER="10.2" \ +-DIPHONE_VERSION_MIN="8.0" \ +-DOPENGL_PROFILE:STRING=GLES2 \ +-DBUILD_OSG_APPLICATIONS:BOOL=OFF \ +-DBUILD_OSG_EXAMPLES:BOOL=ON \ +-DOSG_WINDOWING_SYSTEM:STRING=IOS \ +-DOSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX="imageio" \ +-DDYNAMIC_OPENSCENEGRAPH:BOOL=OFF \ +-DDYNAMIC_OPENTHREADS:BOOL=OFF \ +-DCURL_INCLUDE_DIR:PATH="$THIRDPARTY_PATH/curl-ios-device/include" \ +-DCURL_LIBRARY:PATH="$THIRDPARTY_PATH/curl-ios-device/lib/libcurl.a" \ +-DFREETYPE_INCLUDE_DIR_freetype2:PATH="$THIRDPARTY_PATH/freetype-ios-universal/include/freetype" \ +-DFREETYPE_INCLUDE_DIR_ft2build:PATH="$THIRDPARTY_PATH/freetype-ios-universal/include" \ +-DFREETYPE_LIBRARY:PATH="$THIRDPARTY_PATH/freetype-ios-universal/lib/libFreeType_iphone_universal.a" \ +-DTIFF_INCLUDE_DIR:PATH="$THIRDPARTY_PATH/tiff-ios-device/include" \ +-DTIFF_LIBRARY:PATH="$THIRDPARTY_PATH/tiff-ios-device/lib/libtiff.a" \ +-DGDAL_INCLUDE_DIR:PATH="$THIRDPARTY_PATH/gdal-ios-device/include" \ +-DGDAL_LIBRARY:PATH="$THIRDPARTY_PATH/gdal-ios-device/lib/libgdal.a" + + +Be sure to set the THIRDPARTY_PATH to the path containing your thirdparty +dependancies. Set IPHONE_SDKVER to the version of the iOS sdk you have +installed, in this instance 10.2. IPHONE_VERSION_MIN controls the base sdk +used by xcode, and lastly set OPENGL_PROFILE to the version of GLES you want +to use. + +Once this completes an XCode project will have been generated in the osg root +folder. Open the generated Xcode project, select the example_osgViewerIPhone +target. In 'General' tab set a development team. In the 'Build Settings' tab +search for 'Other Linker Flags', then for each target type (debug, release etc) +that you want to use open the list of arguments and delete the 'OpenGL' line +and the '-framework' line above it. This is because cmake has tried to add the +desktop OpenGL library which we don't want. + +Once this is done you should be able to build and deploy the example_osgViewerIPhone +target on your device. -Known issues: -* When Linking final app against ive plugin, you need to add -lz to - the 'Other linker flags' list. -* Apps and exes don't get created -* You can only select Simulator, or Device projects. In the XCode - project you will see both types but the sdk they link will - be the same. From 896d9a4ee56b4aa97174e1a55584cf4c73e86327 Mon Sep 17 00:00:00 2001 From: Thomas Hogarth Date: Sat, 18 Mar 2017 07:46:14 +0000 Subject: [PATCH 5/6] small compile fix for ios viewer example gles1 --- examples/osgviewerIPhone/shaders.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/osgviewerIPhone/shaders.h b/examples/osgviewerIPhone/shaders.h index cd3e83024..bedb3e729 100644 --- a/examples/osgviewerIPhone/shaders.h +++ b/examples/osgviewerIPhone/shaders.h @@ -44,7 +44,7 @@ const char* ColorShaderFrag = " gl_FragColor = color;\n" "}\n"; -#elif +#else const char* ColorShaderVert = NULL; const char* ColorShaderFrag = NULL; @@ -105,7 +105,7 @@ const char* TextShaderFrag = " gl_FragColor = color * texture2D(glyphTexture, texCoord.xy).a;\n" "}\n"; -#elif +#else const char* TextShaderVert = NULL; const char* TextShaderFrag = NULL; From 4578b32364206d1f889d23c86256af23da9e0c74 Mon Sep 17 00:00:00 2001 From: Thomas Hogarth Date: Sat, 18 Mar 2017 17:35:00 +0000 Subject: [PATCH 6/6] Shaders now using vertex colors --- .../iphoneViewerAppDelegate.mm | 26 +++++------------ examples/osgviewerIPhone/shaders.h | 29 +++++++++++++------ 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/examples/osgviewerIPhone/iphoneViewerAppDelegate.mm b/examples/osgviewerIPhone/iphoneViewerAppDelegate.mm index fa5b9562a..88a0267c6 100644 --- a/examples/osgviewerIPhone/iphoneViewerAppDelegate.mm +++ b/examples/osgviewerIPhone/iphoneViewerAppDelegate.mm @@ -84,11 +84,10 @@ osg::Camera* createHUD(unsigned int w, unsigned int h) text->setFont(0);//"fonts/arial.ttf"); text->setPosition(position); text->setText("A simple multi-touch-example\n1 touch = rotate, \n2 touches = drag + scale, \n3 touches = home"); - + text->setColor(osg::Vec4(0.9,0.1,0.1,1.0)); #if defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE) text->getOrCreateStateSet()->setAttributeAndModes(_textProgram, osg::StateAttribute::ON); text->getOrCreateStateSet()->addUniform(new osg::Uniform("glyphTexture",0)); - text->getOrCreateStateSet()->addUniform(new osg::Uniform("color", osg::Vec4(1.0f,1.0f,1.0f,1.0f))); #endif geode->addDrawable( text ); } @@ -124,11 +123,9 @@ private: drawable->setDataVariance(osg::Object::DYNAMIC); #if defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE) drawable->getOrCreateStateSet()->setAttributeAndModes(_vertColorProgram, osg::StateAttribute::ON); - drawable->getOrCreateStateSet()->addUniform(new osg::Uniform("color", osg::Vec4(0.5, 0.5, 0.5,1))); optimizeNode(drawable); -#else - drawable->setColor(osg::Vec4(0.5, 0.5, 0.5,1)); #endif + drawable->setColor(osg::Vec4(0.5, 0.5, 0.5,1)); geode->addDrawable(drawable); @@ -143,7 +140,6 @@ private: #if defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE) text->getOrCreateStateSet()->setAttributeAndModes(_textProgram, osg::StateAttribute::ON); text->getOrCreateStateSet()->addUniform(new osg::Uniform("glyphTexture",0)); - text->getOrCreateStateSet()->addUniform(new osg::Uniform("color", osg::Vec4(1.0f,1.0f,1.0f,1.0f))); #endif geode->addDrawable( text ); @@ -199,40 +195,32 @@ private: ss << "Touch " << tp.id; _texts[j]->setText(ss.str()); - osg::Vec4 color; - switch (tp.phase) { case osgGA::GUIEventAdapter::TOUCH_BEGAN: - color = osg::Vec4(0,1,0,1); - + _drawables[j]->setColor(osg::Vec4(0,1,0,1)); OSG_INFO << "touch began: " << ss.str() << std::endl; break; case osgGA::GUIEventAdapter::TOUCH_MOVED: //OSG_INFO << "touch moved: " << ss.str() << std::endl; - color = osg::Vec4(1,1,1,1); + _drawables[j]->setColor(osg::Vec4(1,1,1,1)); break; case osgGA::GUIEventAdapter::TOUCH_ENDED: - color = osg::Vec4(1,0,0,1); + _drawables[j]->setColor(osg::Vec4(1,0,0,1)); OSG_INFO << "touch ended: " << ss.str() << std::endl; ++num_touch_ended; break; case osgGA::GUIEventAdapter::TOUCH_STATIONERY: - color = osg::Vec4(0.5,0.5,0.5,1); + _drawables[j]->setColor(osg::Vec4(0.5,0.5,0.5,1)); break; default: break; } -#if defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE) - _drawables[j]->getOrCreateStateSet()->addUniform(new osg::Uniform("color", color)); -#else - _drawables[j]->setColor(color); -#endif } @@ -358,6 +346,7 @@ private: if (!model) { osg::Geode* geode = new osg::Geode(); osg::ShapeDrawable* drawable = new osg::ShapeDrawable(new osg::Box(osg::Vec3(0,0,0), 1)); + drawable->setColor(osg::Vec4(0.1,0.1,0.9,1.0)); geode->addDrawable(drawable); model = geode; } @@ -365,7 +354,6 @@ private: // attach shader program if needed #if defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE) model->getOrCreateStateSet()->setAttributeAndModes(_vertColorProgram, osg::StateAttribute::ON); - model->getOrCreateStateSet()->addUniform(new osg::Uniform("color", osg::Vec4(0.1f,0.4f,0.8f,1.0f))); optimizeNode(model); #endif diff --git a/examples/osgviewerIPhone/shaders.h b/examples/osgviewerIPhone/shaders.h index bedb3e729..fda287d42 100644 --- a/examples/osgviewerIPhone/shaders.h +++ b/examples/osgviewerIPhone/shaders.h @@ -10,19 +10,22 @@ const char* ColorShaderVert = "#version 300 es\n" "in vec4 osg_Vertex;\n" +"in vec4 osg_Color;\n" +"out vec4 vertColor;\n" "uniform mat4 osg_ModelViewProjectionMatrix;\n" "void main()\n" "{\n" " gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;\n" +" vertColor = osg_Color;\n" "}\n"; const char* ColorShaderFrag = "#version 300 es\n" -"uniform lowp vec4 color;\n" +"in lowp vec4 vertColor;\n" "out lowp vec4 fragColor;\n" "void main()\n" "{\n" -" fragColor = color;\n" +" fragColor = vertColor;\n" "}\n"; #elif OSG_GLES2_FEATURES @@ -30,18 +33,21 @@ const char* ColorShaderFrag = const char* ColorShaderVert = "#version 100\n" "attribute vec4 osg_Vertex;\n" +"attribute vec4 osg_Color;\n" "uniform mat4 osg_ModelViewProjectionMatrix;\n" +"varying vec4 vertColor;\n" "void main()\n" "{\n" " gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;\n" +" vertColor = osg_Color;\n" "}\n"; const char* ColorShaderFrag = "#version 100\n" -"uniform lowp vec4 color;\n" +"varying lowp vec4 vertColor;\n" "void main()\n" "{\n" -" gl_FragColor = color;\n" +" gl_FragColor = vertColor;\n" "}\n"; #else @@ -60,25 +66,27 @@ const char* ColorShaderFrag = NULL; const char* TextShaderVert = "#version 300 es\n" "in vec4 osg_Vertex;\n" +"in vec4 osg_Color;\n" "in vec4 osg_MultiTexCoord0;\n" "uniform mat4 osg_ModelViewProjectionMatrix;\n" +"out vec4 vertColor;\n" "out vec4 texCoord;\n" "void main()\n" "{\n" " gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;\n" +" vertColor = osg_Color;\n" " texCoord = osg_MultiTexCoord0;\n" "}\n"; const char* TextShaderFrag = "#version 300 es\n" +"in lowp vec4 vertColor;\n" "in lowp vec4 texCoord;\n" "uniform sampler2D glyphTexture;\n" -"uniform lowp vec4 color;\n" "out lowp vec4 fragColor;\n" "void main()\n" "{\n" -" //lowp vec4 gc = texture(glyphTexture, texCoord.xy);\n" -" fragColor = color * texture(glyphTexture, texCoord.xy).a;\n" +" fragColor = vertColor * texture(glyphTexture, texCoord.xy).a;\n" "}\n"; #elif OSG_GLES2_FEATURES @@ -86,23 +94,26 @@ const char* TextShaderFrag = const char* TextShaderVert = "#version 100\n" "attribute vec4 osg_Vertex;\n" +"attribute vec4 osg_Color;\n" "attribute vec4 osg_MultiTexCoord0;\n" "uniform mat4 osg_ModelViewProjectionMatrix;\n" +"varying vec4 vertColor;\n" "varying vec4 texCoord;\n" "void main()\n" "{\n" " gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;\n" +" vertColor = osg_Color;\n" " texCoord = osg_MultiTexCoord0;\n" "}\n"; const char* TextShaderFrag = "#version 100\n" +"varying lowp vec4 vertColor;\n" "varying lowp vec4 texCoord;\n" "uniform sampler2D glyphTexture;\n" -"uniform lowp vec4 color;\n" "void main()\n" "{\n" -" gl_FragColor = color * texture2D(glyphTexture, texCoord.xy).a;\n" +" gl_FragColor = vertColor * texture2D(glyphTexture, texCoord.xy).a;\n" "}\n"; #else