[osg-users] How to set OSG's OpenGL context version to 4.1?
Hayward Park
freeson.wang at yahoo.com
Sat May 9 04:14:18 PDT 2015
I am having trouble compiling GLSL shaders that are #version 140 or higher. Ideally, I'd like to compile GLSL shaders that are #version 410. I believe to do this, OSG should create an OpenGL context that is 4.1, but everything I've been trying has been creating a (very old!) 2.1 context. Please help!
- I am using OpenSceneGraph 3.3.3.
- I'm working on a Macbook Air with Mac OS X 10.10.3. From both Apple's website, downloading the OpenGL Extensions Viewer, and writing a test program in raw OpenGL, I am absolutely sure that my machine supports OpenGL 4.1.
- I straight up tried compiling and running the osgsimplegl3 example. While it compiles, it doesn't compile it's own shaders, which are tagged with #version 330. This is corroborated with the fact that when I print the OpenGL version while the program is running (after failing to compile the shaders), it prints as OpenGL 2.1.
- I have tried setting CMake flags. I am a little new to CMake, but I've tried adding this in my top level CMakeLists.txt.
Code:
SET(OSG_GL3_AVAILABLE ON)
SET(OSG_GL1_AVAILABLE OFF)
SET(OSG_GL2_AVAILABLE OFF)
SET(OSG_GLES1_AVAILABLE OFF)
SET(OSG_GLES2_AVAILABLE OFF)
SET(OSG_GL_DISPLAYLISTS_AVAILABLE OFF)
SET(OSG_GL_FIXED_FUNCTION_AVAILABLE OFF)
SET(OSG_GL_MATRICES_AVAILABLE OFF)
SET(OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE OFF)
SET(OSG_GL_VERTEX_FUNCS_AVAILABLE OFF)
I have also tried the cmake command as such.
Code:
cmake -G"Eclipse CDT4 - Unix Makefiles" -D CMAKE_BUILD_TYPE=Debug \
-D OSG_GL3_AVAILABLE:BOOL=1 \
-D OSG_GL1_AVAILABLE:BOOL=0 \
-D OSG_GL2_AVAILABLE:BOOL=0 \
-D OSG_GLES1_AVAILABLE:BOOL=0 \
-D OSG_GLES2_AVAILABLE:BOOL=0 \
-D OSG_GL_DISPLAYLISTS_AVAILABLE:BOOL=0 \
-D OSG_GL_FIXED_FUNCTION_AVAILABLE:BOOL=0 \
-D OSG_GL_MATRICES_AVAILABLE:BOOL=0 \
-D OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE:BOOL=0 \
-D OSG_GL_VERTEX_FUNCS_AVAILABLE:BOOL=0 \
.. "$@"
- I have dug into the source to discover the --gl-version flag in osg/src/DisplaySettings.cpp on line 754. I have tried running my program (which is examples/osgsimplegl3) with the --gl-version 4.1. While the string reported back to me is indeed 4.1, the actual version that is used is 2.1 and my shaders are still not compiled.
I'm now at my wit's end. Upon final investigation it seems that the OpenGLContext is created in osg/src/osgViewer/GraphicsWindowCocoa.mm on line 1219, but it doesn't seem like it's taking into account the glContextVersion in the GraphicsContext::Traits object. I can see nowhere in the code where glContextVersion is being used other than osg/src/osgViewer/GraphicsWindowWin32.cpp.
How can I create an OpenGL 4.1 context with OpenSceneGraph on Mac?
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=63681#63681
More information about the osg-users
mailing list