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:
Thomas Hogarth 2017-03-18 06:53:32 +00:00
parent 3a6e28da9c
commit 7ba2e728cd
9 changed files with 298 additions and 99 deletions

View File

@ -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()

View File

@ -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})

View File

@ -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 <osgGA/MultiTouchTrackballManipulator>
#include <osg/ShapeDrawable>
#include <osgUtil/Optimizer>
//include the iphone specific windowing stuff
#include <osgViewer/api/IOS/GraphicsWindowIOS>
#include "shaders.h"
// global programs
osg::ref_ptr<osg::Program> _vertColorProgram;
osg::ref_ptr<osg::Program> _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<osg::Referenced> 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<osg::Node> model = (osgDB::readNodeFile("hog.osg"));
if (model) {
_root->addChild(model);
}
else {
osg::ref_ptr<osg::Node> 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)];

View File

@ -0,0 +1,113 @@
#pragma once
#include <osg/GL>
//
// 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

View File

@ -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

View File

@ -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

View File

@ -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()

View File

@ -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

View File

@ -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;
}