diff --git a/include/osg/GLExtensions b/include/osg/GLExtensions index 750ce91e3..350a4a87e 100644 --- a/include/osg/GLExtensions +++ b/include/osg/GLExtensions @@ -78,6 +78,13 @@ inline void* getGLExtensionFuncPtr(const char *funcName,const char *fallbackFunc return getGLExtensionFuncPtr(fallbackFuncName); } +template +T convertPointerType(R src) +{ + T dest; + memcpy(&dest, &src, sizeof(src)); + return dest; +} template bool setGLExtensionFuncPtr(T& t, const char* str1) diff --git a/include/osg/VertexProgram b/include/osg/VertexProgram index 7f44d7cd2..1b1e9e685 100644 --- a/include/osg/VertexProgram +++ b/include/osg/VertexProgram @@ -267,11 +267,17 @@ class OSG_EXPORT VertexProgram : public StateAttribute bool _isVertexProgramSupported; - void* _glBindProgram; - void* _glGenPrograms; - void *_glDeletePrograms; - void* _glProgramString; - void* _glProgramLocalParameter4fv; + typedef void (APIENTRY * BindProgramProc) (GLenum target, GLuint id); + typedef void (APIENTRY * GenProgramsProc) (GLsizei n, GLuint *programs); + typedef void (APIENTRY * DeleteProgramsProc) (GLsizei n, GLuint *programs); + typedef void (APIENTRY * ProgramStringProc) (GLenum target, GLenum format, GLsizei len, const void *string); + typedef void (APIENTRY * ProgramLocalParameter4fvProc) (GLenum target, GLuint index, const GLfloat *params); + + BindProgramProc _glBindProgram; + GenProgramsProc _glGenPrograms; + DeleteProgramsProc _glDeletePrograms; + ProgramStringProc _glProgramString; + ProgramLocalParameter4fvProc _glProgramLocalParameter4fv; }; diff --git a/include/osgAnimation/Timeline b/include/osgAnimation/Timeline index 31079cf38..b34209ba9 100644 --- a/include/osgAnimation/Timeline +++ b/include/osgAnimation/Timeline @@ -152,7 +152,7 @@ namespace osgAnimation enum State { Play, - Stop, + Stop }; State _state; @@ -168,7 +168,7 @@ namespace osgAnimation enum State { Play, - Stop, + Stop }; diff --git a/include/osgWidget/PdfReader b/include/osgWidget/PdfReader index bfd7eb5c6..cbeb329bf 100644 --- a/include/osgWidget/PdfReader +++ b/include/osgWidget/PdfReader @@ -29,7 +29,7 @@ struct GeometryHints { RESIZE_HEIGHT_TO_MAINTAINCE_ASPECT_RATIO, RESIZE_WIDTH_TO_MAINTAINCE_ASPECT_RATIO, - IGNORE_DOCUMENT_ASPECT_RATIO, + IGNORE_DOCUMENT_ASPECT_RATIO }; GeometryHints(): diff --git a/src/osg/GLExtensions.cpp b/src/osg/GLExtensions.cpp index 15af23a16..304b164ab 100644 --- a/src/osg/GLExtensions.cpp +++ b/src/osg/GLExtensions.cpp @@ -307,6 +307,7 @@ bool osg::isGLUExtensionSupported(unsigned int contextID, const char *extension) #include #endif + void* osg::getGLExtensionFuncPtr(const char *funcName) { #if defined(WIN32) @@ -358,10 +359,10 @@ void* osg::getGLExtensionFuncPtr(const char *funcName) typedef void (*__GLXextFuncPtr)(void); typedef __GLXextFuncPtr (*GetProcAddressARBProc)(const char*); - static GetProcAddressARBProc s_glXGetProcAddressARB = (GetProcAddressARBProc)dlsym(0, "glXGetProcAddressARB"); + static GetProcAddressARBProc s_glXGetProcAddressARB = convertPointerType(dlsym(0, "glXGetProcAddressARB")); if (s_glXGetProcAddressARB) { - return (void*) (s_glXGetProcAddressARB)(funcName); + return convertPointerType((s_glXGetProcAddressARB)(funcName)); } else { diff --git a/src/osg/State.cpp b/src/osg/State.cpp index 6a74a30d0..6aa5848dc 100644 --- a/src/osg/State.cpp +++ b/src/osg/State.cpp @@ -745,14 +745,14 @@ void State::initializeExtensionProcs() { if (_extensionProcsInitialized) return; - _glClientActiveTexture = (ActiveTextureProc) osg::getGLExtensionFuncPtr("glClientActiveTexture","glClientActiveTextureARB"); - _glActiveTexture = (ActiveTextureProc) osg::getGLExtensionFuncPtr("glActiveTexture","glActiveTextureARB"); - _glFogCoordPointer = (FogCoordPointerProc) osg::getGLExtensionFuncPtr("glFogCoordPointer","glFogCoordPointerEXT"); - _glSecondaryColorPointer = (SecondaryColorPointerProc) osg::getGLExtensionFuncPtr("glSecondaryColorPointer","glSecondaryColorPointerEXT"); - _glVertexAttribPointer = (VertexAttribPointerProc) osg::getGLExtensionFuncPtr("glVertexAttribPointer","glVertexAttribPointerARB"); - _glEnableVertexAttribArray = (EnableVertexAttribProc) osg::getGLExtensionFuncPtr("glEnableVertexAttribArray","glEnableVertexAttribArrayARB"); - _glDisableVertexAttribArray = (DisableVertexAttribProc) osg::getGLExtensionFuncPtr("glDisableVertexAttribArray","glDisableVertexAttribArrayARB"); - _glBindBuffer = (BindBufferProc) osg::getGLExtensionFuncPtr("glBindBuffer","glBindBufferARB"); + setGLExtensionFuncPtr(_glClientActiveTexture,"glClientActiveTexture","glClientActiveTextureARB"); + setGLExtensionFuncPtr(_glActiveTexture, "glActiveTexture","glActiveTextureARB"); + setGLExtensionFuncPtr(_glFogCoordPointer, "glFogCoordPointer","glFogCoordPointerEXT"); + setGLExtensionFuncPtr(_glSecondaryColorPointer, "glSecondaryColorPointer","glSecondaryColorPointerEXT"); + setGLExtensionFuncPtr(_glVertexAttribPointer, "glVertexAttribPointer","glVertexAttribPointerARB"); + setGLExtensionFuncPtr(_glEnableVertexAttribArray, "glEnableVertexAttribArray","glEnableVertexAttribArrayARB"); + setGLExtensionFuncPtr(_glDisableVertexAttribArray, "glDisableVertexAttribArray","glDisableVertexAttribArrayARB"); + setGLExtensionFuncPtr(_glBindBuffer, "glBindBuffer","glBindBufferARB"); if ( osg::getGLVersionNumber() >= 2.0 || osg::isGLExtensionSupported(_contextID,"GL_ARB_vertex_shader") ) { diff --git a/src/osg/VertexProgram.cpp b/src/osg/VertexProgram.cpp index 8abc4a8e3..5098a8328 100644 --- a/src/osg/VertexProgram.cpp +++ b/src/osg/VertexProgram.cpp @@ -257,19 +257,18 @@ void VertexProgram::Extensions::setupGLExtensions(unsigned int contextID) { _isVertexProgramSupported = isGLExtensionSupported(contextID,"GL_ARB_vertex_program"); - _glBindProgram = osg::getGLExtensionFuncPtr("glBindProgramARB"); - _glGenPrograms = osg::getGLExtensionFuncPtr("glGenProgramsARB"); - _glDeletePrograms = osg::getGLExtensionFuncPtr("glDeleteProgramsARB"); - _glProgramString = osg::getGLExtensionFuncPtr("glProgramStringARB"); - _glProgramLocalParameter4fv = osg::getGLExtensionFuncPtr("glProgramLocalParameter4fvARB"); + setGLExtensionFuncPtr(_glBindProgram,"glBindProgramARB"); + setGLExtensionFuncPtr(_glGenPrograms, "glGenProgramsARB"); + setGLExtensionFuncPtr(_glDeletePrograms, "glDeleteProgramsARB"); + setGLExtensionFuncPtr(_glProgramString, "glProgramStringARB"); + setGLExtensionFuncPtr(_glProgramLocalParameter4fv, "glProgramLocalParameter4fvARB"); } void VertexProgram::Extensions::glBindProgram(GLenum target, GLuint id) const { if (_glBindProgram) { - typedef void (APIENTRY * BindProgramProc) (GLenum target, GLuint id); - ((BindProgramProc)_glBindProgram)(target,id); + _glBindProgram(target,id); } else { @@ -281,8 +280,7 @@ void VertexProgram::Extensions::glGenPrograms(GLsizei n, GLuint *programs) const { if (_glGenPrograms) { - typedef void (APIENTRY * GenProgramsProc) (GLsizei n, GLuint *programs); - ((GenProgramsProc)_glGenPrograms)(n,programs); + _glGenPrograms(n,programs); } else { @@ -294,8 +292,7 @@ void VertexProgram::Extensions::glDeletePrograms(GLsizei n, GLuint *programs) co { if (_glDeletePrograms) { - typedef void (APIENTRY * DeleteProgramsProc) (GLsizei n, GLuint *programs); - ((DeleteProgramsProc)_glDeletePrograms)(n,programs); + _glDeletePrograms(n,programs); } else { @@ -307,8 +304,7 @@ void VertexProgram::Extensions::glProgramString(GLenum target, GLenum format, GL { if (_glProgramString) { - typedef void (APIENTRY * ProgramStringProc) (GLenum target, GLenum format, GLsizei len, const void *string); - ((ProgramStringProc)_glProgramString)(target,format, len, string); + _glProgramString(target,format, len, string); } else { @@ -320,8 +316,7 @@ void VertexProgram::Extensions::glProgramLocalParameter4fv(GLenum target, GLuint { if (_glProgramLocalParameter4fv) { - typedef void (APIENTRY * ProgramLocalParameter4fvProc) (GLenum target, GLuint index, const GLfloat *params); - ((ProgramLocalParameter4fvProc)_glProgramLocalParameter4fv)(target, index, params); + _glProgramLocalParameter4fv(target, index, params); } else { diff --git a/src/osgPlugins/hdr/hdrloader.cpp b/src/osgPlugins/hdr/hdrloader.cpp index 7f2d72a02..7c61eac4d 100644 --- a/src/osgPlugins/hdr/hdrloader.cpp +++ b/src/osgPlugins/hdr/hdrloader.cpp @@ -57,6 +57,7 @@ bool HDRLoader::isHDRFile(const char *_fileName) char str[10]; fread(str, 10, 1, file); + fclose(file); if (memcmp(str, "#?RADIANCE", 10) && memcmp(str, "#?RGBE", 6)) diff --git a/src/osgWidget/Input.cpp b/src/osgWidget/Input.cpp index d5c6bd857..11cdc75cd 100644 --- a/src/osgWidget/Input.cpp +++ b/src/osgWidget/Input.cpp @@ -42,12 +42,15 @@ void Input::_calculateSize(const XYCoord& size) { // An Input cannot currently set it's own size RELIABLY until the osgText implementation // is dratiscally improved. I'm getting wildly crazy results. :( // point_type height = size.y() > _cursor->getHeight() ? size.y() : _cursor->getHeight(); + +#if 0 point_type width = size.x() + _cursor->getWidth(); point_type height = _cursor->getHeight(); - // if(width > getWidth()) setWidth(osg::round(width)); + if(width > getWidth()) setWidth(osg::round(width)); - // if(height > getHeight()) setHeight(osg::round(height)); + if(height > getHeight()) setHeight(osg::round(height)); +#endif } void Input::_calculateCursorOffsets() { @@ -99,10 +102,7 @@ void Input::positioned() { ln = ln == 0.0f ? 1.0f : ln; - point_type th = - (_text->getCharacterHeight() * ln) + - (_text->getLineSpacing() * (ln - 1.0f)) - ; + // point_type th = (_text->getCharacterHeight() * ln) + (_text->getLineSpacing() * (ln - 1.0f)); point_type x = getX() + _xoff; point_type y = getY() + _yoff;