From 327b67a30563a76804a1fa316ae6acfc702d5293 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 23 Oct 2009 13:19:57 +0000 Subject: [PATCH] Added CMake support for specifying what OpenGL target and features that the OpenSceneGraph build should use. Added use of the new Cmake generated #define's for optionally compiling parts of the OpenSceneGraph's OpenGL support for the various OpenGL targets --- CMakeLists.txt | 25 ++++++++------------- include/osg/Drawable | 2 ++ src/osg/AlphaFunc.cpp | 4 ++++ src/osg/ClipPlane.cpp | 4 ++++ src/osg/ColorMatrix.cpp | 4 ++++ src/osg/DrawPixels.cpp | 4 ++++ src/osg/Drawable.cpp | 43 +++++++++++++++++++++++++++++++++---- src/osg/Fog.cpp | 4 ++++ src/osg/FragmentProgram.cpp | 5 +++++ src/osg/GLObjects.cpp | 31 ++++++++++++++++++++------ src/osg/Light.cpp | 10 +++++++-- src/osg/LightModel.cpp | 6 ++++++ src/osg/LineStipple.cpp | 4 ++++ src/osg/LogicOp.cpp | 5 +++++ src/osg/Material.cpp | 6 +++++- src/osg/Point.cpp | 4 ++++ src/osg/PointSprite.cpp | 4 ++++ src/osg/PolygonMode.cpp | 4 ++++ src/osg/PolygonStipple.cpp | 4 ++++ src/osg/ShadeModel.cpp | 5 +++++ src/osg/TexEnv.cpp | 4 ++++ src/osg/TexEnvCombine.cpp | 4 ++++ src/osg/TexEnvFilter.cpp | 4 ++++ src/osg/TexGen.cpp | 6 ++++-- src/osg/TexMat.cpp | 5 ++++- src/osg/VertexProgram.cpp | 5 +++++ 26 files changed, 174 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c349ffbaf..7130c569c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -281,28 +281,21 @@ MARK_AS_ADVANCED(OSG_DISABLE_MSVC_WARNINGS) OPTION(OSG_USE_REF_PTR_IMPLICIT_OUTPUT_CONVERSION "Set to ON to use the ref_ptr<> T* operator() output conversion. " ON) OPTION(OSG_GLU_AVAILABLE "Set to OFF to disable use of OpenGL GLU library." ${OPENGL_GLU_FOUND}) -# MARK_AS_ADVANCED(OSG_GLU_AVAILABLE) - - OPTION(OSG_GL1_AVAILABLE "Set to OFF to disable use of OpenGL 1.x functions library." ON) -# MARK_AS_ADVANCED(OSG_GL1_AVAILABLE) - OPTION(OSG_GL2_AVAILABLE "Set to OFF to disable use of OpenGL 2.x functions library." ON) -# MARK_AS_ADVANCED(OSG_GL2_AVAILABLE) - OPTION(OSG_GL3_AVAILABLE "Set to OFF to disable use of OpenGL 3.x functions library." OFF) -# MARK_AS_ADVANCED(OSG_GL3_AVAILABLE) - OPTION(OSG_GLES1_AVAILABLE "Set to OFF to disable use of OpenGL ES 1.x functions library." OFF) -# MARK_AS_ADVANCED(OSG_GLES1_AVAILABLE) - OPTION(OSG_GLES2_AVAILABLE "Set to OFF to disable use of OpenGL ES 2.x functions library." OFF) -# MARK_AS_ADVANCED(OSG_GLES2_AVAILABLE) -SET(OSG_GL_DISPLAYLISTS_AVAILABLE ${OSG_GL1_AVAILABLE}) -SET(OSG_GL_MATRICES_AVAILABLE ${OSG_GL1_AVAILABLE}) -SET(OSG_GL_VERTEX_FUNCS_AVAILABLE ${OSG_GL1_AVAILABLE}) -SET(OSG_GL_FIXED_FUNCTION_AVAILABLE ${OSG_GL1_AVAILABLE}) +# SET(OSG_GL_DISPLAYLISTS_AVAILABLE ${OSG_GL1_AVAILABLE}) +# SET(OSG_GL_MATRICES_AVAILABLE ${OSG_GL1_AVAILABLE}) +# SET(OSG_GL_VERTEX_FUNCS_AVAILABLE ${OSG_GL1_AVAILABLE}) +# SET(OSG_GL_FIXED_FUNCTION_AVAILABLE ${OSG_GL1_AVAILABLE}) + +OPTION(OSG_GL_DISPLAYLISTS_AVAILABLE "Set to OFF to disable use of OpenGL display lists." ${OSG_GL1_AVAILABLE}) +OPTION(OSG_GL_MATRICES_AVAILABLE "Set to OFF to disable use of OpenGL built-in matrices." ${OSG_GL1_AVAILABLE}) +OPTION(OSG_GL_VERTEX_FUNCS_AVAILABLE "Set to OFF to disable use of OpenGL vertex functions such as glVertex/glColor etc." ${OSG_GL1_AVAILABLE}) +OPTION(OSG_GL_FIXED_FUNCTION_AVAILABLE "Set to OFF to disable use of OpenGL fixed function pipeline." ${OSG_GL1_AVAILABLE}) ################################################################################ # Set Config file diff --git a/include/osg/Drawable b/include/osg/Drawable index 478624b8d..257639e2d 100644 --- a/include/osg/Drawable +++ b/include/osg/Drawable @@ -857,6 +857,7 @@ class OSG_EXPORT Drawable : public Object inline void Drawable::draw(RenderInfo& renderInfo) const { +#ifdef OSG_GL_DISPLAYLISTS_AVAILABLE if (_useDisplayList && !(_supportsVertexBufferObjects && _useVertexBufferObjects && renderInfo.getState()->isVertexBufferObjectSupported())) { // get the contextID (user defined ID of 0 upwards) for the @@ -897,6 +898,7 @@ inline void Drawable::draw(RenderInfo& renderInfo) const return; } +#endif // draw object as nature intended.. if (_drawCallback.valid()) diff --git a/src/osg/AlphaFunc.cpp b/src/osg/AlphaFunc.cpp index b263b5e34..9d16dd67e 100644 --- a/src/osg/AlphaFunc.cpp +++ b/src/osg/AlphaFunc.cpp @@ -29,6 +29,10 @@ AlphaFunc::~AlphaFunc() void AlphaFunc::apply(State&) const { +#ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE glAlphaFunc((GLenum)_comparisonFunc,_referenceValue); +#else + osg::notify(osg::NOTICE)<<"Warning: AlphaFunc::apply(State&) - not supported."<getDataType(), _image->data() ); } +#else + osg::notify(osg::NOTICE)<<"Warning: DrawPixels::drawImplementation(RenderInfo&) - not supported."< lock(s_mutex_deletedDisplayListCache); DisplayListMap& dll = s_deletedDisplayListCache[contextID]; @@ -76,6 +77,10 @@ GLuint Drawable::generateDisplayList(unsigned int contextID, unsigned int sizeHi return glGenLists( 1 ); } } +#else + osg::notify(osg::NOTICE)<<"Warning: Drawable::generateDisplayList(..) - not supported."< lock(s_mutex_deletedDisplayListCache); @@ -98,10 +104,14 @@ void Drawable::deleteDisplayList(unsigned int contextID,GLuint globj, unsigned i // insert the globj into the cache for the appropriate context. s_deletedDisplayListCache[contextID].insert(DisplayListMap::value_type(sizeHint,globj)); } +#else + osg::notify(osg::NOTICE)<<"Warning: Drawable::deleteDisplayList(..) - not supported."< lock(s_mutex_deletedDisplayListCache); DisplayListMap& dll = s_deletedDisplayListCache[contextID]; @@ -114,6 +124,9 @@ void Drawable::flushAllDeletedDisplayLists(unsigned int contextID) } dll.clear(); +#else + osg::notify(osg::NOTICE)<<"Warning: Drawable::deleteDisplayList(..) - not supported."< #include + #include #include +#include using namespace osg; @@ -48,6 +50,7 @@ LightModel::~LightModel() void LightModel::apply(State&) const { +#ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE glLightModelfv(GL_LIGHT_MODEL_AMBIENT,_ambient.ptr()); static bool s_separateSpecularSupported = strncmp((const char*)glGetString(GL_VERSION),"1.2",3)>=0; @@ -65,5 +68,8 @@ void LightModel::apply(State&) const glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,_localViewer); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,_twoSided); +#else + osg::notify(osg::NOTICE)<<"Warning: LightModel::apply(State&) - not supported."< +#include using namespace osg; @@ -30,6 +31,10 @@ LogicOp::~LogicOp() void LogicOp::apply(State&) const { +#ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE glLogicOp(static_cast(_opcode)); +#else + osg::notify(osg::NOTICE)<<"Warning: LogicOp::apply(State&) - not supported."< #include +#include using namespace osg; @@ -351,6 +352,7 @@ void Material::setAlpha(Face face,float alpha) void Material::apply(State&) const { +#ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE if (_colorMode==OFF) { glDisable(GL_COLOR_MATERIAL); @@ -432,5 +434,7 @@ void Material::apply(State&) const glMaterialf( GL_FRONT, GL_SHININESS, _shininessFront ); glMaterialf( GL_BACK, GL_SHININESS, _shininessBack ); } - +#else + osg::notify(osg::NOTICE)<<"Warning: Material::apply(State&) - not supported."<glPointParameterf(GL_POINT_FADE_THRESHOLD_SIZE, _fadeThresholdSize); extensions->glPointParameterf(GL_POINT_SIZE_MIN, _minSize); extensions->glPointParameterf(GL_POINT_SIZE_MAX, _maxSize); +#else + osg::notify(osg::NOTICE)<<"Warning: Point::apply(State&) - not supported."<isPointSpriteCoordOriginSupported()) extensions->glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN,_coordOriginMode); +#else + osg::notify(osg::NOTICE)<<"Warning: PointSprite::apply(State&) - not supported."< #include +#include using namespace osg; @@ -27,5 +28,9 @@ ShadeModel::~ShadeModel() void ShadeModel::apply(State&) const { +#ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE glShadeModel((GLenum)_mode); +#else + osg::notify(osg::NOTICE)<<"Warning: ShadeModel::apply(State&) - not supported."<=1.4 || isGLExtensionSupported(state.getContextID(),"GL_EXT_texture_lod_bias"); @@ -36,4 +37,7 @@ void TexEnvFilter::apply(State& state) const { glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, _lodBias); } +#else + osg::notify(osg::NOTICE)<<"Warning: TexEnvFilter::apply(State&) - not supported."<