From 66da1328f81d505e71186572e487f563408150f4 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 4 Dec 2014 16:22:31 +0000 Subject: [PATCH] Ported GL2Extentions across to using the new GL extensions approach - cutting code count by 3000 lines! git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14566 16af8721-9629-0410-8352-f15c8da7e697 --- .../osgshaderterrain/osgshaderterrain.cpp | 5 +- include/osg/GL2Extensions | 706 +--- include/osg/State | 7 + src/osg/FrameBufferObject.cpp | 4 +- src/osg/GL2Extensions.cpp | 3046 ++--------------- src/osg/PatchParameter.cpp | 6 +- src/osg/Program.cpp | 14 +- src/osg/Shader.cpp | 2 +- src/osg/State.cpp | 7 + 9 files changed, 422 insertions(+), 3375 deletions(-) diff --git a/examples/osgshaderterrain/osgshaderterrain.cpp b/examples/osgshaderterrain/osgshaderterrain.cpp index 0d33b4828..c167ee432 100644 --- a/examples/osgshaderterrain/osgshaderterrain.cpp +++ b/examples/osgshaderterrain/osgshaderterrain.cpp @@ -269,11 +269,12 @@ public: { OpenThreads::ScopedLock lock(_mutex); + unsigned int contextID = gc->getState()->getContextID(); - osg::GL2Extensions* gl2ext = osg::GL2Extensions::Get(contextID,true); + osg::GL2Extensions* gl2ext = gc->getState()->get(); if( gl2ext ) { - if( !gl2ext->isGlslSupported() ) + if( !gl2ext->isGlslSupported ) { _supported = false; _errorMessage = "ERROR: GLSL not supported by OpenGL driver."; diff --git a/include/osg/GL2Extensions b/include/osg/GL2Extensions index 5ed890fb6..38793aa1a 100644 --- a/include/osg/GL2Extensions +++ b/include/osg/GL2Extensions @@ -491,52 +491,6 @@ class OSG_EXPORT GL2Extensions : public osg::Referenced { public: GL2Extensions(unsigned int contextID); - GL2Extensions(const GL2Extensions& rhs); - - void lowestCommonDenominator(const GL2Extensions& rhs); - - void setupGL2Extensions(unsigned int contextID); - - /** Does the GL driver support OpenGL Shading Language? */ - bool isGlslSupported() const; - - float getGlVersion() const { return _glVersion; } - float getLanguageVersion() const { return _glslLanguageVersion; } - - void setShaderObjectsSupported(bool flag) { _isShaderObjectsSupported = flag; } - bool isShaderObjectsSupported() const { return _isShaderObjectsSupported; } - - void setVertexShaderSupported(bool flag) { _isVertexShaderSupported = flag; } - bool isVertexShaderSupported() const { return _isVertexShaderSupported; } - - void setFragmentShaderSupported(bool flag) { _isFragmentShaderSupported = flag; } - bool isFragmentShaderSupported() const { return _isFragmentShaderSupported; } - - void setLanguage100Supported(bool flag) { _isLanguage100Supported = flag; } - bool isLanguage100Supported() const { return _isLanguage100Supported; } - - void setGeometryShader4Supported(bool flag) { _isGeometryShader4Supported = flag; } - bool isGeometryShader4Supported() const { return _isGeometryShader4Supported; } - - void setTessellationShadersSupported(bool flag) { _areTessellationShadersSupported = flag; } - bool areTessellationShadersSupported() const { return _areTessellationShadersSupported; } - - void setGpuShader4Supported(bool flag) { _isGpuShader4Supported = flag; } - bool isGpuShader4Supported() const { return _isGpuShader4Supported; } - - void setUniformBufferObjectSupported(bool flag) { _isUniformBufferObjectSupported = flag; } - bool isUniformBufferObjectSupported() const {return _isUniformBufferObjectSupported; } - - void setGetProgramBinarySupported(bool flag) { _isGetProgramBinarySupported = flag; } - bool isGetProgramBinarySupported() const {return _isGetProgramBinarySupported; } - - void setGpuShaderFp64Supported(bool flag) { _isGpuShaderFp64Supported = flag; } - bool isGpuShaderFp64Supported() const {return _isGpuShaderFp64Supported; } - - void setShaderAtomicCounterSupported(bool flag) { _isShaderAtomicCountersSupported = flag; } - bool isShaderAtomicCounterSupported() const {return _isShaderAtomicCountersSupported; } - - bool isDrawBuffersSupported() const { return _glDrawBuffers!=0; } /** Function to call to get the extension of a specified context. * If the Exentsion object for that context has not yet been created then @@ -551,102 +505,6 @@ class OSG_EXPORT GL2Extensions : public osg::Referenced * but need to ensure that they all use the same low common denominator extensions.*/ static void Set(unsigned int contextID, GL2Extensions* extensions); - - void glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) const; - void glDrawBuffers(GLsizei n, const GLenum *bufs) const; - void glStencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) const; - void glStencilFuncSeparate(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask) const; - void glStencilMaskSeparate(GLenum face, GLuint mask) const; - void glAttachShader(GLuint program, GLuint shader) const; - void glBindAttribLocation(GLuint program, GLuint index, const GLchar *name) const; - void glCompileShader(GLuint shader) const; - GLuint glCreateProgram(void) const; - GLuint glCreateShader(GLenum type) const; - void glDeleteProgram(GLuint program) const; - void glDeleteShader(GLuint shader) const; - void glDetachShader(GLuint program, GLuint shader) const; - void glDisableVertexAttribArray(GLuint index) const; - void glEnableVertexAttribArray(GLuint index) const; - void glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) const; - void glGetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) const; - void glGetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj) const; - GLint glGetAttribLocation(GLuint program, const GLchar *name) const; - void glGetProgramiv(GLuint program, GLenum pname, GLint *params) const; - void glGetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog) const; - void glGetShaderiv(GLuint shader, GLenum pname, GLint *params) const; - void glGetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog) const; - void glGetShaderSource(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source) const; - GLint glGetUniformLocation(GLuint program, const GLchar *name) const; - void glGetUniformfv(GLuint program, GLint location, GLfloat *params) const; - void glGetUniformiv(GLuint program, GLint location, GLint *params) const; - void glGetVertexAttribdv(GLuint index, GLenum pname, GLdouble *params) const; - void glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat *params) const; - void glGetVertexAttribiv(GLuint index, GLenum pname, GLint *params) const; - void glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid* *pointer) const; - GLboolean glIsProgram(GLuint program) const; - GLboolean glIsShader(GLuint shader) const; - void glLinkProgram(GLuint program) const; - void glShaderSource(GLuint shader, GLsizei count, const GLchar* *string, const GLint *length) const; - void glUseProgram(GLuint program) const; - void glUniform1f(GLint location, GLfloat v0) const; - void glUniform2f(GLint location, GLfloat v0, GLfloat v1) const; - void glUniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) const; - void glUniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) const; - void glUniform1i(GLint location, GLint v0) const; - void glUniform2i(GLint location, GLint v0, GLint v1) const; - void glUniform3i(GLint location, GLint v0, GLint v1, GLint v2) const; - void glUniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) const; - void glUniform1fv(GLint location, GLsizei count, const GLfloat *value) const; - void glUniform2fv(GLint location, GLsizei count, const GLfloat *value) const; - void glUniform3fv(GLint location, GLsizei count, const GLfloat *value) const; - void glUniform4fv(GLint location, GLsizei count, const GLfloat *value) const; - void glUniform1iv(GLint location, GLsizei count, const GLint *value) const; - void glUniform2iv(GLint location, GLsizei count, const GLint *value) const; - void glUniform3iv(GLint location, GLsizei count, const GLint *value) const; - void glUniform4iv(GLint location, GLsizei count, const GLint *value) const; - void glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) const; - void glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) const; - void glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) const; - void glValidateProgram(GLuint program) const; - void glVertexAttrib1d(GLuint index, GLdouble x) const; - void glVertexAttrib1dv(GLuint index, const GLdouble *v) const; - void glVertexAttrib1f(GLuint index, GLfloat x) const; - void glVertexAttrib1fv(GLuint index, const GLfloat *v) const; - void glVertexAttrib1s(GLuint index, GLshort x) const; - void glVertexAttrib1sv(GLuint index, const GLshort *v) const; - void glVertexAttrib2d(GLuint index, GLdouble x, GLdouble y) const; - void glVertexAttrib2dv(GLuint index, const GLdouble *v) const; - void glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y) const; - void glVertexAttrib2fv(GLuint index, const GLfloat *v) const; - void glVertexAttrib2s(GLuint index, GLshort x, GLshort y) const; - void glVertexAttrib2sv(GLuint index, const GLshort *v) const; - void glVertexAttrib3d(GLuint index, GLdouble x, GLdouble y, GLdouble z) const; - void glVertexAttrib3dv(GLuint index, const GLdouble *v) const; - void glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) const; - void glVertexAttrib3fv(GLuint index, const GLfloat *v) const; - void glVertexAttrib3s(GLuint index, GLshort x, GLshort y, GLshort z) const; - void glVertexAttrib3sv(GLuint index, const GLshort *v) const; - void glVertexAttrib4Nbv(GLuint index, const GLbyte *v) const; - void glVertexAttrib4Niv(GLuint index, const GLint *v) const; - void glVertexAttrib4Nsv(GLuint index, const GLshort *v) const; - void glVertexAttrib4Nub(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w) const; - void glVertexAttrib4Nubv(GLuint index, const GLubyte *v) const; - void glVertexAttrib4Nuiv(GLuint index, const GLuint *v) const; - void glVertexAttrib4Nusv(GLuint index, const GLushort *v) const; - void glVertexAttrib4bv(GLuint index, const GLbyte *v) const; - void glVertexAttrib4d(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w) const; - void glVertexAttrib4dv(GLuint index, const GLdouble *v) const; - void glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) const; - void glVertexAttrib4fv(GLuint index, const GLfloat *v) const; - void glVertexAttrib4iv(GLuint index, const GLint *v) const; - void glVertexAttrib4s(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w) const; - void glVertexAttrib4sv(GLuint index, const GLshort *v) const; - void glVertexAttrib4ubv(GLuint index, const GLubyte *v) const; - void glVertexAttrib4uiv(GLuint index, const GLuint *v) const; - void glVertexAttrib4usv(GLuint index, const GLushort *v) const; - void glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer) const; - void glVertexAttribDivisor(GLuint index, GLuint divisor) const; - // C++-friendly convenience wrapper methods GLuint getCurrentProgram() const; bool getProgramInfoLog( GLuint program, std::string& result ) const; @@ -654,411 +512,173 @@ class OSG_EXPORT GL2Extensions : public osg::Referenced bool getAttribLocation( const char* attribName, GLuint& slot ) const; bool getFragDataLocation( const char* fragDataName, GLuint& slot) const; - // GL 2.1 - void glUniformMatrix2x3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) const; - void glUniformMatrix3x2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) const; - void glUniformMatrix2x4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) const; - void glUniformMatrix4x2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) const; - void glUniformMatrix3x4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) const; - void glUniformMatrix4x3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) const; - // EXT_geometry_shader4 - void glProgramParameteri( GLuint program, GLenum pname, GLint value ) const; - void glFramebufferTexture( GLenum target, GLenum attachment, GLuint texture, GLint level ) const; - void glFramebufferTextureLayer( GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer ) const; - void glFramebufferTextureFace( GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face ) const; + float glVersion; + float glslLanguageVersion; - // ARB_tessellation_shader - void glPatchParameteri(GLenum pname, GLint value) const; - void glPatchParameterfv(GLenum pname, const GLfloat *values) const; + bool isGlslSupported; + bool isShaderObjectsSupported; + bool isVertexShaderSupported; + bool isFragmentShaderSupported; + bool isLanguage100Supported; + bool isGeometryShader4Supported; + bool areTessellationShadersSupported; + bool isGpuShader4Supported; + bool isUniformBufferObjectSupported; + bool isGetProgramBinarySupported; + bool isGpuShaderFp64Supported; + bool isShaderAtomicCountersSupported; - // EXT_gpu_shader4 - void glGetUniformuiv( GLuint program, GLint location, GLuint *params ) const; - void glBindFragDataLocation( GLuint program, GLuint color, const GLchar *name ) const; - GLint glGetFragDataLocation( GLuint program, const GLchar *name ) const; - void glUniform1ui( GLint location, GLuint v0 ) const; - void glUniform2ui( GLint location, GLuint v0, GLuint v1 ) const; - void glUniform3ui( GLint location, GLuint v0, GLuint v1, GLuint v2 ) const; - void glUniform4ui( GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3 ) const; - void glUniform1uiv( GLint location, GLsizei count, const GLuint *value ) const; - void glUniform2uiv( GLint location, GLsizei count, const GLuint *value ) const; - void glUniform3uiv( GLint location, GLsizei count, const GLuint *value ) const; - void glUniform4uiv( GLint location, GLsizei count, const GLuint *value ) const; + void (GL_APIENTRY * glBlendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha); + void (GL_APIENTRY * glDrawBuffers)(GLsizei n, const GLenum *bufs); + void (GL_APIENTRY * glStencilOpSeparate)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); + void (GL_APIENTRY * glStencilFuncSeparate)(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); + void (GL_APIENTRY * glStencilMaskSeparate)(GLenum face, GLuint mask); + void (GL_APIENTRY * glAttachShader)(GLuint program, GLuint shader); + void (GL_APIENTRY * glBindAttribLocation)(GLuint program, GLuint index, const GLchar *name); + void (GL_APIENTRY * glCompileShader)(GLuint shader); + GLuint (GL_APIENTRY * glCreateProgram)(void); + GLuint (GL_APIENTRY * glCreateShader)(GLenum type); + void (GL_APIENTRY * glDeleteProgram)(GLuint program); + void (GL_APIENTRY * glDeleteObjectARB)(GLuint program); + void (GL_APIENTRY * glDeleteShader)(GLuint shader); + void (GL_APIENTRY * glDetachShader)(GLuint program, GLuint shader); + void (GL_APIENTRY * glDisableVertexAttribArray)(GLuint index); + void (GL_APIENTRY * glEnableVertexAttribArray)(GLuint index); + void (GL_APIENTRY * glGetActiveAttrib)(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); + void (GL_APIENTRY * glGetActiveUniform)(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); + void (GL_APIENTRY * glGetAttachedShaders)(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); + GLint (GL_APIENTRY * glGetAttribLocation)(GLuint program, const GLchar *name); + void (GL_APIENTRY * glGetProgramiv)(GLuint program, GLenum pname, GLint *params); + void (GL_APIENTRY * glGetObjectParameterivARB)(GLuint program, GLenum pname, GLint *params); + void (GL_APIENTRY * glGetProgramInfoLog)(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); + void (GL_APIENTRY * glGetInfoLogARB)(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); + void (GL_APIENTRY * glGetShaderiv)(GLuint shader, GLenum pname, GLint *params); + void (GL_APIENTRY * glGetShaderInfoLog)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); + void (GL_APIENTRY * glGetShaderSource)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); + GLint (GL_APIENTRY * glGetUniformLocation)(GLuint program, const GLchar *name); + void (GL_APIENTRY * glGetUniformfv)(GLuint program, GLint location, GLfloat *params); + void (GL_APIENTRY * glGetUniformiv)(GLuint program, GLint location, GLint *params); + void (GL_APIENTRY * glGetVertexAttribdv)(GLuint index, GLenum pname, GLdouble *params); + void (GL_APIENTRY * glGetVertexAttribfv)(GLuint index, GLenum pname, GLfloat *params); + void (GL_APIENTRY * glGetVertexAttribiv)(GLuint index, GLenum pname, GLint *params); + void (GL_APIENTRY * glGetVertexAttribPointerv)(GLuint index, GLenum pname, GLvoid* *pointer); + GLboolean (GL_APIENTRY * glIsProgram)(GLuint program); + GLboolean (GL_APIENTRY * glIsShader)(GLuint shader); + void (GL_APIENTRY * glLinkProgram)(GLuint program); + void (GL_APIENTRY * glShaderSource)(GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); + void (GL_APIENTRY * glUseProgram)(GLuint program); + void (GL_APIENTRY * glUniform1f)(GLint location, GLfloat v0); + void (GL_APIENTRY * glUniform2f)(GLint location, GLfloat v0, GLfloat v1); + void (GL_APIENTRY * glUniform3f)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2); + void (GL_APIENTRY * glUniform4f)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); + void (GL_APIENTRY * glUniform1i)(GLint location, GLint v0); + void (GL_APIENTRY * glUniform2i)(GLint location, GLint v0, GLint v1); + void (GL_APIENTRY * glUniform3i)(GLint location, GLint v0, GLint v1, GLint v2); + void (GL_APIENTRY * glUniform4i)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3); + void (GL_APIENTRY * glUniform1fv)(GLint location, GLsizei count, const GLfloat *value); + void (GL_APIENTRY * glUniform2fv)(GLint location, GLsizei count, const GLfloat *value); + void (GL_APIENTRY * glUniform3fv)(GLint location, GLsizei count, const GLfloat *value); + void (GL_APIENTRY * glUniform4fv)(GLint location, GLsizei count, const GLfloat *value); + void (GL_APIENTRY * glUniform1iv)(GLint location, GLsizei count, const GLint *value); + void (GL_APIENTRY * glUniform2iv)(GLint location, GLsizei count, const GLint *value); + void (GL_APIENTRY * glUniform3iv)(GLint location, GLsizei count, const GLint *value); + void (GL_APIENTRY * glUniform4iv)(GLint location, GLsizei count, const GLint *value); + void (GL_APIENTRY * glUniformMatrix2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + void (GL_APIENTRY * glUniformMatrix3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + void (GL_APIENTRY * glUniformMatrix4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + void (GL_APIENTRY * glValidateProgram)(GLuint program); + void (GL_APIENTRY * glVertexAttrib1d)(GLuint index, GLdouble x); + void (GL_APIENTRY * glVertexAttrib1dv)(GLuint index, const GLdouble *v); + void (GL_APIENTRY * glVertexAttrib1f)(GLuint index, GLfloat x); + void (GL_APIENTRY * glVertexAttrib1fv)(GLuint index, const GLfloat *v); + void (GL_APIENTRY * glVertexAttrib1s)(GLuint index, GLshort x); + void (GL_APIENTRY * glVertexAttrib1sv)(GLuint index, const GLshort *v); + void (GL_APIENTRY * glVertexAttrib2d)(GLuint index, GLdouble x, GLdouble y); + void (GL_APIENTRY * glVertexAttrib2dv)(GLuint index, const GLdouble *v); + void (GL_APIENTRY * glVertexAttrib2f)(GLuint index, GLfloat x, GLfloat y); + void (GL_APIENTRY * glVertexAttrib2fv)(GLuint index, const GLfloat *v); + void (GL_APIENTRY * glVertexAttrib2s)(GLuint index, GLshort x, GLshort y); + void (GL_APIENTRY * glVertexAttrib2sv)(GLuint index, const GLshort *v); + void (GL_APIENTRY * glVertexAttrib3d)(GLuint index, GLdouble x, GLdouble y, GLdouble z); + void (GL_APIENTRY * glVertexAttrib3dv)(GLuint index, const GLdouble *v); + void (GL_APIENTRY * glVertexAttrib3f)(GLuint index, GLfloat x, GLfloat y, GLfloat z); + void (GL_APIENTRY * glVertexAttrib3fv)(GLuint index, const GLfloat *v); + void (GL_APIENTRY * glVertexAttrib3s)(GLuint index, GLshort x, GLshort y, GLshort z); + void (GL_APIENTRY * glVertexAttrib3sv)(GLuint index, const GLshort *v); + void (GL_APIENTRY * glVertexAttrib4Nbv)(GLuint index, const GLbyte *v); + void (GL_APIENTRY * glVertexAttrib4Niv)(GLuint index, const GLint *v); + void (GL_APIENTRY * glVertexAttrib4Nsv)(GLuint index, const GLshort *v); + void (GL_APIENTRY * glVertexAttrib4Nub)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); + void (GL_APIENTRY * glVertexAttrib4Nubv)(GLuint index, const GLubyte *v); + void (GL_APIENTRY * glVertexAttrib4Nuiv)(GLuint index, const GLuint *v); + void (GL_APIENTRY * glVertexAttrib4Nusv)(GLuint index, const GLushort *v); + void (GL_APIENTRY * glVertexAttrib4bv)(GLuint index, const GLbyte *v); + void (GL_APIENTRY * glVertexAttrib4d)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + void (GL_APIENTRY * glVertexAttrib4dv)(GLuint index, const GLdouble *v); + void (GL_APIENTRY * glVertexAttrib4f)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + void (GL_APIENTRY * glVertexAttrib4fv)(GLuint index, const GLfloat *v); + void (GL_APIENTRY * glVertexAttrib4iv)(GLuint index, const GLint *v); + void (GL_APIENTRY * glVertexAttrib4s)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); + void (GL_APIENTRY * glVertexAttrib4sv)(GLuint index, const GLshort *v); + void (GL_APIENTRY * glVertexAttrib4ubv)(GLuint index, const GLubyte *v); + void (GL_APIENTRY * glVertexAttrib4uiv)(GLuint index, const GLuint *v); + void (GL_APIENTRY * glVertexAttrib4usv)(GLuint index, const GLushort *v); + void (GL_APIENTRY * glVertexAttribPointer)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); + void (GL_APIENTRY * glVertexAttribDivisor)(GLuint index, GLuint divisor); + void (GL_APIENTRY * glUniformMatrix2x3fv)( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ); + void (GL_APIENTRY * glUniformMatrix3x2fv)( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ); + void (GL_APIENTRY * glUniformMatrix2x4fv)( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ); + void (GL_APIENTRY * glUniformMatrix4x2fv)( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ); + void (GL_APIENTRY * glUniformMatrix3x4fv)( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ); + void (GL_APIENTRY * glUniformMatrix4x3fv)( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ); + void (GL_APIENTRY * glProgramParameteri)( GLuint program, GLenum pname, GLint value ); + void (GL_APIENTRY * glFramebufferTexture)( GLenum target, GLenum attachment, GLuint texture, GLint level ); + void (GL_APIENTRY * glFramebufferTextureLayer)( GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer ); + void (GL_APIENTRY * glFramebufferTextureFace)( GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face ); + void (GL_APIENTRY * glPatchParameteri)( GLenum pname, GLint value ); + void (GL_APIENTRY * glPatchParameterfv)( GLenum pname, const GLfloat* values ); + void (GL_APIENTRY * glGetUniformuiv)( GLuint program, GLint location, GLuint* params ); + void (GL_APIENTRY * glBindFragDataLocation)( GLuint program, GLuint color, const GLchar* name ); + GLint (GL_APIENTRY * glGetFragDataLocation)( GLuint program, const GLchar* name ); + void (GL_APIENTRY * glUniform1ui)( GLint location, GLuint v0 ); + void (GL_APIENTRY * glUniform2ui)( GLint location, GLuint v0, GLuint v1 ); + void (GL_APIENTRY * glUniform3ui)( GLint location, GLuint v0, GLuint v1, GLuint v2 ); + void (GL_APIENTRY * glUniform4ui)( GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3 ); + void (GL_APIENTRY * glUniform1uiv)( GLint location, GLsizei count, const GLuint *value ); + void (GL_APIENTRY * glUniform2uiv)( GLint location, GLsizei count, const GLuint *value ); + void (GL_APIENTRY * glUniform3uiv)( GLint location, GLsizei count, const GLuint *value ); + void (GL_APIENTRY * glUniform4uiv)( GLint location, GLsizei count, const GLuint *value ); + GLuint (GL_APIENTRY * glGetHandleARB) (GLenum pname); + void (GL_APIENTRY * glGetUniformIndices)(GLuint program, GLsizei uniformCount, const GLchar* *uniformNames, GLuint *uniformIndices); + void (GL_APIENTRY * glGetActiveUniformsiv)(GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); + void (GL_APIENTRY * glGetActiveUniformName)(GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); + GLuint (GL_APIENTRY * glGetUniformBlockIndex)(GLuint program, const GLchar *uniformBlockName); + void (GL_APIENTRY * glGetActiveUniformBlockiv)(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); + void (GL_APIENTRY * glGetActiveUniformBlockName)(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); + void (GL_APIENTRY * glUniformBlockBinding)(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); + void (GL_APIENTRY * glGetProgramBinary)(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); + void (GL_APIENTRY * glProgramBinary)(GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); + void (GL_APIENTRY * glUniform1d)(GLint location, GLdouble v0); + void (GL_APIENTRY * glUniform2d)(GLint location, GLdouble v0, GLdouble v1); + void (GL_APIENTRY * glUniform3d)(GLint location, GLdouble v0, GLdouble v1, GLdouble v2); + void (GL_APIENTRY * glUniform4d)(GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); + void (GL_APIENTRY * glUniform1dv)(GLint location, GLsizei count, const GLdouble *value); + void (GL_APIENTRY * glUniform2dv)(GLint location, GLsizei count, const GLdouble *value); + void (GL_APIENTRY * glUniform3dv)(GLint location, GLsizei count, const GLdouble *value); + void (GL_APIENTRY * glUniform4dv)(GLint location, GLsizei count, const GLdouble *value); + void (GL_APIENTRY * glUniformMatrix2dv)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + void (GL_APIENTRY * glUniformMatrix3dv)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + void (GL_APIENTRY * glUniformMatrix4dv)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); + void (GL_APIENTRY * glUniformMatrix2x3dv)( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value ); + void (GL_APIENTRY * glUniformMatrix3x2dv)( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value ); + void (GL_APIENTRY * glUniformMatrix2x4dv)( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value ); + void (GL_APIENTRY * glUniformMatrix4x2dv)( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value ); + void (GL_APIENTRY * glUniformMatrix3x4dv)( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value ); + void (GL_APIENTRY * glUniformMatrix4x3dv)( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value ); + void (GL_APIENTRY * glGetActiveAtomicCounterBufferiv)( GLuint program, GLuint bufferIndex, GLenum pname, GLint* params ); + void (GL_APIENTRY * glDispatchCompute)( GLuint numGroupsX, GLuint numGroupsY, GLuint numGroupsZ ); - // ARB_uniform_buffer_object - void glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* *uniformNames, GLuint *uniformIndices) const; - void glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params) const; - void glGetActiveUniformName(GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName) const; - GLuint glGetUniformBlockIndex(GLuint program, const GLchar *uniformBlockName) const; - void glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params) const; - void glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName) const; - void glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) const; - - // ARB_get_program_binary - void glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary) const; - void glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length) const; - - // ARB_gpu_shader_fp64 - void glUniform1d( GLint location, GLdouble v0 ) const; - void glUniform2d( GLint location, GLdouble v0, GLdouble v1 ) const; - void glUniform3d( GLint location, GLdouble v0, GLdouble v1, GLdouble v2 ) const; - void glUniform4d( GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3 ) const; - void glUniform1dv( GLint location, GLsizei count, const GLdouble *value ) const; - void glUniform2dv( GLint location, GLsizei count, const GLdouble *value ) const; - void glUniform3dv( GLint location, GLsizei count, const GLdouble *value ) const; - void glUniform4dv( GLint location, GLsizei count, const GLdouble *value ) const; - void glUniformMatrix2dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value) const; - void glUniformMatrix3dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value) const; - void glUniformMatrix4dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value) const; - void glUniformMatrix2x3dv( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value ) const; - void glUniformMatrix3x2dv( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value ) const; - void glUniformMatrix2x4dv( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value ) const; - void glUniformMatrix4x2dv( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value ) const; - void glUniformMatrix3x4dv( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value ) const; - void glUniformMatrix4x3dv( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value ) const; - - // ARB_shader_atomic_counters - void glGetActiveAtomicCounterBufferiv( GLuint program, GLuint bufferIndex, GLenum pname, GLint* params ) const; - - // ARB_compute_shader - void glDispatchCompute( GLuint numGroupsX, GLuint numGroupsY, GLuint numGroupsZ ) const; - - protected: - ~GL2Extensions() {} - - float _glVersion; - float _glslLanguageVersion; - - bool _isShaderObjectsSupported; - bool _isVertexShaderSupported; - bool _isFragmentShaderSupported; - bool _isLanguage100Supported; - bool _isGeometryShader4Supported; - bool _areTessellationShadersSupported; - bool _isGpuShader4Supported; - bool _isUniformBufferObjectSupported; - bool _isGetProgramBinarySupported; - bool _isGpuShaderFp64Supported; - bool _isShaderAtomicCountersSupported; - - typedef void (GL_APIENTRY * BlendEquationSeparateProc)(GLenum modeRGB, GLenum modeAlpha); - typedef void (GL_APIENTRY * DrawBuffersProc)(GLsizei n, const GLenum *bufs); - typedef void (GL_APIENTRY * StencilOpSeparateProc)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); - typedef void (GL_APIENTRY * StencilFuncSeparateProc)(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); - typedef void (GL_APIENTRY * StencilMaskSeparateProc)(GLenum face, GLuint mask); - typedef void (GL_APIENTRY * AttachShaderProc)(GLuint program, GLuint shader); - typedef void (GL_APIENTRY * BindAttribLocationProc)(GLuint program, GLuint index, const GLchar *name); - typedef void (GL_APIENTRY * CompileShaderProc)(GLuint shader); - typedef GLuint (GL_APIENTRY * CreateProgramProc)(void); - typedef GLuint (GL_APIENTRY * CreateShaderProc)(GLenum type); - typedef void (GL_APIENTRY * DeleteProgramProc)(GLuint program); - typedef void (GL_APIENTRY * DeleteObjectARBProc)(GLuint program); - typedef void (GL_APIENTRY * DeleteShaderProc)(GLuint shader); - typedef void (GL_APIENTRY * DetachShaderProc)(GLuint program, GLuint shader); - typedef void (GL_APIENTRY * DisableVertexAttribArrayProc)(GLuint index); - typedef void (GL_APIENTRY * EnableVertexAttribArrayProc)(GLuint index); - typedef void (GL_APIENTRY * GetActiveAttribProc)(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); - typedef void (GL_APIENTRY * GetActiveUniformProc)(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); - typedef void (GL_APIENTRY * GetAttachedShadersProc)(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); - typedef GLint (GL_APIENTRY * GetAttribLocationProc)(GLuint program, const GLchar *name); - typedef void (GL_APIENTRY * GetProgramivProc)(GLuint program, GLenum pname, GLint *params); - typedef void (GL_APIENTRY * GetObjectParameterivARBProc)(GLuint program, GLenum pname, GLint *params); - typedef void (GL_APIENTRY * GetProgramInfoLogProc)(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); - typedef void (GL_APIENTRY * GetInfoLogARBProc)(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); - typedef void (GL_APIENTRY * GetShaderivProc)(GLuint shader, GLenum pname, GLint *params); - typedef void (GL_APIENTRY * GetShaderInfoLogProc)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); - typedef void (GL_APIENTRY * GetShaderSourceProc)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); - typedef GLint (GL_APIENTRY * GetUniformLocationProc)(GLuint program, const GLchar *name); - typedef void (GL_APIENTRY * GetUniformfvProc)(GLuint program, GLint location, GLfloat *params); - typedef void (GL_APIENTRY * GetUniformivProc)(GLuint program, GLint location, GLint *params); - typedef void (GL_APIENTRY * GetVertexAttribdvProc)(GLuint index, GLenum pname, GLdouble *params); - typedef void (GL_APIENTRY * GetVertexAttribfvProc)(GLuint index, GLenum pname, GLfloat *params); - typedef void (GL_APIENTRY * GetVertexAttribivProc)(GLuint index, GLenum pname, GLint *params); - typedef void (GL_APIENTRY * GetVertexAttribPointervProc)(GLuint index, GLenum pname, GLvoid* *pointer); - typedef GLboolean (GL_APIENTRY * IsProgramProc)(GLuint program); - typedef GLboolean (GL_APIENTRY * IsShaderProc)(GLuint shader); - typedef void (GL_APIENTRY * LinkProgramProc)(GLuint program); - typedef void (GL_APIENTRY * ShaderSourceProc)(GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); - typedef void (GL_APIENTRY * UseProgramProc)(GLuint program); - typedef void (GL_APIENTRY * Uniform1fProc)(GLint location, GLfloat v0); - typedef void (GL_APIENTRY * Uniform2fProc)(GLint location, GLfloat v0, GLfloat v1); - typedef void (GL_APIENTRY * Uniform3fProc)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2); - typedef void (GL_APIENTRY * Uniform4fProc)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); - typedef void (GL_APIENTRY * Uniform1iProc)(GLint location, GLint v0); - typedef void (GL_APIENTRY * Uniform2iProc)(GLint location, GLint v0, GLint v1); - typedef void (GL_APIENTRY * Uniform3iProc)(GLint location, GLint v0, GLint v1, GLint v2); - typedef void (GL_APIENTRY * Uniform4iProc)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3); - typedef void (GL_APIENTRY * Uniform1fvProc)(GLint location, GLsizei count, const GLfloat *value); - typedef void (GL_APIENTRY * Uniform2fvProc)(GLint location, GLsizei count, const GLfloat *value); - typedef void (GL_APIENTRY * Uniform3fvProc)(GLint location, GLsizei count, const GLfloat *value); - typedef void (GL_APIENTRY * Uniform4fvProc)(GLint location, GLsizei count, const GLfloat *value); - typedef void (GL_APIENTRY * Uniform1ivProc)(GLint location, GLsizei count, const GLint *value); - typedef void (GL_APIENTRY * Uniform2ivProc)(GLint location, GLsizei count, const GLint *value); - typedef void (GL_APIENTRY * Uniform3ivProc)(GLint location, GLsizei count, const GLint *value); - typedef void (GL_APIENTRY * Uniform4ivProc)(GLint location, GLsizei count, const GLint *value); - typedef void (GL_APIENTRY * UniformMatrix2fvProc)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); - typedef void (GL_APIENTRY * UniformMatrix3fvProc)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); - typedef void (GL_APIENTRY * UniformMatrix4fvProc)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); - typedef void (GL_APIENTRY * ValidateProgramProc)(GLuint program); - typedef void (GL_APIENTRY * VertexAttrib1dProc)(GLuint index, GLdouble x); - typedef void (GL_APIENTRY * VertexAttrib1dvProc)(GLuint index, const GLdouble *v); - typedef void (GL_APIENTRY * VertexAttrib1fProc)(GLuint index, GLfloat x); - typedef void (GL_APIENTRY * VertexAttrib1fvProc)(GLuint index, const GLfloat *v); - typedef void (GL_APIENTRY * VertexAttrib1sProc)(GLuint index, GLshort x); - typedef void (GL_APIENTRY * VertexAttrib1svProc)(GLuint index, const GLshort *v); - typedef void (GL_APIENTRY * VertexAttrib2dProc)(GLuint index, GLdouble x, GLdouble y); - typedef void (GL_APIENTRY * VertexAttrib2dvProc)(GLuint index, const GLdouble *v); - typedef void (GL_APIENTRY * VertexAttrib2fProc)(GLuint index, GLfloat x, GLfloat y); - typedef void (GL_APIENTRY * VertexAttrib2fvProc)(GLuint index, const GLfloat *v); - typedef void (GL_APIENTRY * VertexAttrib2sProc)(GLuint index, GLshort x, GLshort y); - typedef void (GL_APIENTRY * VertexAttrib2svProc)(GLuint index, const GLshort *v); - typedef void (GL_APIENTRY * VertexAttrib3dProc)(GLuint index, GLdouble x, GLdouble y, GLdouble z); - typedef void (GL_APIENTRY * VertexAttrib3dvProc)(GLuint index, const GLdouble *v); - typedef void (GL_APIENTRY * VertexAttrib3fProc)(GLuint index, GLfloat x, GLfloat y, GLfloat z); - typedef void (GL_APIENTRY * VertexAttrib3fvProc)(GLuint index, const GLfloat *v); - typedef void (GL_APIENTRY * VertexAttrib3sProc)(GLuint index, GLshort x, GLshort y, GLshort z); - typedef void (GL_APIENTRY * VertexAttrib3svProc)(GLuint index, const GLshort *v); - typedef void (GL_APIENTRY * VertexAttrib4NbvProc)(GLuint index, const GLbyte *v); - typedef void (GL_APIENTRY * VertexAttrib4NivProc)(GLuint index, const GLint *v); - typedef void (GL_APIENTRY * VertexAttrib4NsvProc)(GLuint index, const GLshort *v); - typedef void (GL_APIENTRY * VertexAttrib4NubProc)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); - typedef void (GL_APIENTRY * VertexAttrib4NubvProc)(GLuint index, const GLubyte *v); - typedef void (GL_APIENTRY * VertexAttrib4NuivProc)(GLuint index, const GLuint *v); - typedef void (GL_APIENTRY * VertexAttrib4NusvProc)(GLuint index, const GLushort *v); - typedef void (GL_APIENTRY * VertexAttrib4bvProc)(GLuint index, const GLbyte *v); - typedef void (GL_APIENTRY * VertexAttrib4dProc)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); - typedef void (GL_APIENTRY * VertexAttrib4dvProc)(GLuint index, const GLdouble *v); - typedef void (GL_APIENTRY * VertexAttrib4fProc)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); - typedef void (GL_APIENTRY * VertexAttrib4fvProc)(GLuint index, const GLfloat *v); - typedef void (GL_APIENTRY * VertexAttrib4ivProc)(GLuint index, const GLint *v); - typedef void (GL_APIENTRY * VertexAttrib4sProc)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); - typedef void (GL_APIENTRY * VertexAttrib4svProc)(GLuint index, const GLshort *v); - typedef void (GL_APIENTRY * VertexAttrib4ubvProc)(GLuint index, const GLubyte *v); - typedef void (GL_APIENTRY * VertexAttrib4uivProc)(GLuint index, const GLuint *v); - typedef void (GL_APIENTRY * VertexAttrib4usvProc)(GLuint index, const GLushort *v); - typedef void (GL_APIENTRY * VertexAttribPointerProc)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); - typedef void (GL_APIENTRY * VertexAttribDivisorProc)(GLuint index, GLuint divisor); - typedef void (GL_APIENTRY * UniformMatrix2x3fvProc)( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ); - typedef void (GL_APIENTRY * UniformMatrix3x2fvProc)( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ); - typedef void (GL_APIENTRY * UniformMatrix2x4fvProc)( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ); - typedef void (GL_APIENTRY * UniformMatrix4x2fvProc)( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ); - typedef void (GL_APIENTRY * UniformMatrix3x4fvProc)( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ); - typedef void (GL_APIENTRY * UniformMatrix4x3fvProc)( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ); - typedef void (GL_APIENTRY * ProgramParameteriProc)( GLuint program, GLenum pname, GLint value ); - typedef void (GL_APIENTRY * FramebufferTextureProc)( GLenum target, GLenum attachment, GLuint texture, GLint level ); - typedef void (GL_APIENTRY * FramebufferTextureLayerProc)( GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer ); - typedef void (GL_APIENTRY * FramebufferTextureFaceProc)( GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face ); - typedef void (GL_APIENTRY * PatchParameteriProc)( GLenum pname, GLint value ); - typedef void (GL_APIENTRY * PatchParameterfvProc)( GLenum pname, const GLfloat* values ); - typedef void (GL_APIENTRY * GetUniformuivProc)( GLuint program, GLint location, GLuint* params ); - typedef void (GL_APIENTRY * BindFragDataLocationProc)( GLuint program, GLuint color, const GLchar* name ); - typedef GLint (GL_APIENTRY * GetFragDataLocationProc)( GLuint program, const GLchar* name ); - typedef void (GL_APIENTRY * Uniform1uiProc)( GLint location, GLuint v0 ); - typedef void (GL_APIENTRY * Uniform2uiProc)( GLint location, GLuint v0, GLuint v1 ); - typedef void (GL_APIENTRY * Uniform3uiProc)( GLint location, GLuint v0, GLuint v1, GLuint v2 ); - typedef void (GL_APIENTRY * Uniform4uiProc)( GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3 ); - typedef void (GL_APIENTRY * Uniform1uivProc)( GLint location, GLsizei count, const GLuint *value ); - typedef void (GL_APIENTRY * Uniform2uivProc)( GLint location, GLsizei count, const GLuint *value ); - typedef void (GL_APIENTRY * Uniform3uivProc)( GLint location, GLsizei count, const GLuint *value ); - typedef void (GL_APIENTRY * Uniform4uivProc)( GLint location, GLsizei count, const GLuint *value ); - typedef GLuint (GL_APIENTRY * GetHandleProc) (GLenum pname); - typedef void (GL_APIENTRY * GetUniformIndicesProc)(GLuint program, GLsizei uniformCount, const GLchar* *uniformNames, GLuint *uniformIndices); - typedef void (GL_APIENTRY * GetActiveUniformsivProc)(GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); - typedef void (GL_APIENTRY * GetActiveUniformNameProc)(GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); - typedef GLuint (GL_APIENTRY * GetUniformBlockIndexProc)(GLuint program, const GLchar *uniformBlockName); - typedef void (GL_APIENTRY * GetActiveUniformBlockivProc)(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); - typedef void (GL_APIENTRY * GetActiveUniformBlockNameProc)(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); - typedef void (GL_APIENTRY * UniformBlockBindingProc)(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); - typedef void (GL_APIENTRY * GetProgramBinaryProc)(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); - typedef void (GL_APIENTRY * ProgramBinaryProc)(GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); - typedef void (GL_APIENTRY * Uniform1dProc)(GLint location, GLdouble v0); - typedef void (GL_APIENTRY * Uniform2dProc)(GLint location, GLdouble v0, GLdouble v1); - typedef void (GL_APIENTRY * Uniform3dProc)(GLint location, GLdouble v0, GLdouble v1, GLdouble v2); - typedef void (GL_APIENTRY * Uniform4dProc)(GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); - typedef void (GL_APIENTRY * Uniform1dvProc)(GLint location, GLsizei count, const GLdouble *value); - typedef void (GL_APIENTRY * Uniform2dvProc)(GLint location, GLsizei count, const GLdouble *value); - typedef void (GL_APIENTRY * Uniform3dvProc)(GLint location, GLsizei count, const GLdouble *value); - typedef void (GL_APIENTRY * Uniform4dvProc)(GLint location, GLsizei count, const GLdouble *value); - typedef void (GL_APIENTRY * UniformMatrix2dvProc)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); - typedef void (GL_APIENTRY * UniformMatrix3dvProc)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); - typedef void (GL_APIENTRY * UniformMatrix4dvProc)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); - typedef void (GL_APIENTRY * UniformMatrix2x3dvProc)( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value ); - typedef void (GL_APIENTRY * UniformMatrix3x2dvProc)( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value ); - typedef void (GL_APIENTRY * UniformMatrix2x4dvProc)( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value ); - typedef void (GL_APIENTRY * UniformMatrix4x2dvProc)( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value ); - typedef void (GL_APIENTRY * UniformMatrix3x4dvProc)( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value ); - typedef void (GL_APIENTRY * UniformMatrix4x3dvProc)( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value ); - typedef void (GL_APIENTRY * GetActiveAtomicCounterBufferivProc)( GLuint program, GLuint bufferIndex, GLenum pname, GLint* params ); - typedef void (GL_APIENTRY * DispatchComputeProc)( GLuint numGroupsX, GLuint numGroupsY, GLuint numGroupsZ ); - - BlendEquationSeparateProc _glBlendEquationSeparate; - DrawBuffersProc _glDrawBuffers; - StencilOpSeparateProc _glStencilOpSeparate; - StencilFuncSeparateProc _glStencilFuncSeparate; - StencilMaskSeparateProc _glStencilMaskSeparate; - AttachShaderProc _glAttachShader; - BindAttribLocationProc _glBindAttribLocation; - CompileShaderProc _glCompileShader; - CreateProgramProc _glCreateProgram; - CreateShaderProc _glCreateShader; - DeleteProgramProc _glDeleteProgram; - DeleteShaderProc _glDeleteShader; - DetachShaderProc _glDetachShader; - DisableVertexAttribArrayProc _glDisableVertexAttribArray; - EnableVertexAttribArrayProc _glEnableVertexAttribArray; - GetActiveAttribProc _glGetActiveAttrib; - GetActiveUniformProc _glGetActiveUniform; - GetAttachedShadersProc _glGetAttachedShaders; - GetAttribLocationProc _glGetAttribLocation; - GetProgramivProc _glGetProgramiv; - GetProgramInfoLogProc _glGetProgramInfoLog; - GetShaderivProc _glGetShaderiv; - GetShaderInfoLogProc _glGetShaderInfoLog; - GetShaderSourceProc _glGetShaderSource; - GetUniformLocationProc _glGetUniformLocation; - GetUniformfvProc _glGetUniformfv; - GetUniformivProc _glGetUniformiv; - GetVertexAttribdvProc _glGetVertexAttribdv; - GetVertexAttribfvProc _glGetVertexAttribfv; - GetVertexAttribivProc _glGetVertexAttribiv; - GetVertexAttribPointervProc _glGetVertexAttribPointerv; - IsProgramProc _glIsProgram; - IsShaderProc _glIsShader; - LinkProgramProc _glLinkProgram; - ShaderSourceProc _glShaderSource; - UseProgramProc _glUseProgram; - Uniform1fProc _glUniform1f; - Uniform2fProc _glUniform2f; - Uniform3fProc _glUniform3f; - Uniform4fProc _glUniform4f; - Uniform1iProc _glUniform1i; - Uniform2iProc _glUniform2i; - Uniform3iProc _glUniform3i; - Uniform4iProc _glUniform4i; - Uniform1fvProc _glUniform1fv; - Uniform2fvProc _glUniform2fv; - Uniform3fvProc _glUniform3fv; - Uniform4fvProc _glUniform4fv; - Uniform1ivProc _glUniform1iv; - Uniform2ivProc _glUniform2iv; - Uniform3ivProc _glUniform3iv; - Uniform4ivProc _glUniform4iv; - UniformMatrix2fvProc _glUniformMatrix2fv; - UniformMatrix3fvProc _glUniformMatrix3fv; - UniformMatrix4fvProc _glUniformMatrix4fv; - ValidateProgramProc _glValidateProgram; - VertexAttrib1dProc _glVertexAttrib1d; - VertexAttrib1dvProc _glVertexAttrib1dv; - VertexAttrib1fProc _glVertexAttrib1f; - VertexAttrib1fvProc _glVertexAttrib1fv; - VertexAttrib1sProc _glVertexAttrib1s; - VertexAttrib1svProc _glVertexAttrib1sv; - VertexAttrib2dProc _glVertexAttrib2d; - VertexAttrib2dvProc _glVertexAttrib2dv; - VertexAttrib2fProc _glVertexAttrib2f; - VertexAttrib2fvProc _glVertexAttrib2fv; - VertexAttrib2sProc _glVertexAttrib2s; - VertexAttrib2svProc _glVertexAttrib2sv; - VertexAttrib3dProc _glVertexAttrib3d; - VertexAttrib3dvProc _glVertexAttrib3dv; - VertexAttrib3fProc _glVertexAttrib3f; - VertexAttrib3fvProc _glVertexAttrib3fv; - VertexAttrib3sProc _glVertexAttrib3s; - VertexAttrib3svProc _glVertexAttrib3sv; - VertexAttrib4NbvProc _glVertexAttrib4Nbv; - VertexAttrib4NivProc _glVertexAttrib4Niv; - VertexAttrib4NsvProc _glVertexAttrib4Nsv; - VertexAttrib4NubProc _glVertexAttrib4Nub; - VertexAttrib4NubvProc _glVertexAttrib4Nubv; - VertexAttrib4NuivProc _glVertexAttrib4Nuiv; - VertexAttrib4NusvProc _glVertexAttrib4Nusv; - VertexAttrib4bvProc _glVertexAttrib4bv; - VertexAttrib4dProc _glVertexAttrib4d; - VertexAttrib4dvProc _glVertexAttrib4dv; - VertexAttrib4fProc _glVertexAttrib4f; - VertexAttrib4fvProc _glVertexAttrib4fv; - VertexAttrib4ivProc _glVertexAttrib4iv; - VertexAttrib4sProc _glVertexAttrib4s; - VertexAttrib4svProc _glVertexAttrib4sv; - VertexAttrib4ubvProc _glVertexAttrib4ubv; - VertexAttrib4uivProc _glVertexAttrib4uiv; - VertexAttrib4usvProc _glVertexAttrib4usv; - VertexAttribPointerProc _glVertexAttribPointer; - VertexAttribDivisorProc _glVertexAttribDivisor; - - GetInfoLogARBProc _glGetInfoLogARB; - GetObjectParameterivARBProc _glGetObjectParameterivARB; - DeleteObjectARBProc _glDeleteObjectARB; - GetHandleProc _glGetHandleARB; - - // GL 2.1 - UniformMatrix2x3fvProc _glUniformMatrix2x3fv; - UniformMatrix3x2fvProc _glUniformMatrix3x2fv; - UniformMatrix2x4fvProc _glUniformMatrix2x4fv; - UniformMatrix4x2fvProc _glUniformMatrix4x2fv; - UniformMatrix3x4fvProc _glUniformMatrix3x4fv; - UniformMatrix4x3fvProc _glUniformMatrix4x3fv; - - // EXT_geometry_shader4 - ProgramParameteriProc _glProgramParameteri; - FramebufferTextureProc _glFramebufferTexture; - FramebufferTextureLayerProc _glFramebufferTextureLayer; - FramebufferTextureFaceProc _glFramebufferTextureFace; - - // ARB_tesselation_shader - PatchParameteriProc _glPatchParameteri; - PatchParameterfvProc _glPatchParameterfv; - - // EXT_gpu_shader4 - GetUniformuivProc _glGetUniformuiv; - BindFragDataLocationProc _glBindFragDataLocation; - GetFragDataLocationProc _glGetFragDataLocation; - Uniform1uiProc _glUniform1ui; - Uniform2uiProc _glUniform2ui; - Uniform3uiProc _glUniform3ui; - Uniform4uiProc _glUniform4ui; - Uniform1uivProc _glUniform1uiv; - Uniform2uivProc _glUniform2uiv; - Uniform3uivProc _glUniform3uiv; - Uniform4uivProc _glUniform4uiv; - - // ARB_uniform_buffer_object - GetUniformIndicesProc _glGetUniformIndices; - GetActiveUniformsivProc _glGetActiveUniformsiv; - GetActiveUniformNameProc _glGetActiveUniformName; - GetUniformBlockIndexProc _glGetUniformBlockIndex; - GetActiveUniformBlockivProc _glGetActiveUniformBlockiv; - GetActiveUniformBlockNameProc _glGetActiveUniformBlockName; - UniformBlockBindingProc _glUniformBlockBinding; - - // ARB_get_program_binary - GetProgramBinaryProc _glGetProgramBinary; - ProgramBinaryProc _glProgramBinary; - - // ARB_gpu_shader_fp64 - Uniform1dProc _glUniform1d; - Uniform2dProc _glUniform2d; - Uniform3dProc _glUniform3d; - Uniform4dProc _glUniform4d; - Uniform1dvProc _glUniform1dv; - Uniform2dvProc _glUniform2dv; - Uniform3dvProc _glUniform3dv; - Uniform4dvProc _glUniform4dv; - UniformMatrix2dvProc _glUniformMatrix2dv; - UniformMatrix3dvProc _glUniformMatrix3dv; - UniformMatrix4dvProc _glUniformMatrix4dv; - UniformMatrix2x3dvProc _glUniformMatrix2x3dv; - UniformMatrix3x2dvProc _glUniformMatrix3x2dv; - UniformMatrix2x4dvProc _glUniformMatrix2x4dv; - UniformMatrix4x2dvProc _glUniformMatrix4x2dv; - UniformMatrix3x4dvProc _glUniformMatrix3x4dv; - UniformMatrix4x3dvProc _glUniformMatrix4x3dv; - - // ARB_shader_atomic_counters - GetActiveAtomicCounterBufferivProc _glGetActiveAtomicCounterBufferiv; - - // ARB_compute_shader - DispatchComputeProc _glDispatchCompute; }; } diff --git a/include/osg/State b/include/osg/State index 85cc23ea4..3eb77b31e 100644 --- a/include/osg/State +++ b/include/osg/State @@ -15,6 +15,7 @@ #define OSG_STATE 1 #include +#include #include #include #include @@ -1940,6 +1941,8 @@ class OSG_EXPORT State : public Referenced DrawArraysInstancedProc _glDrawArraysInstanced; DrawElementsInstancedProc _glDrawElementsInstanced; + osg::ref_ptr _gl2Extentsions; + unsigned int _dynamicObjectCount; osg::ref_ptr _completeDynamicObjectRenderingCallback; @@ -2773,6 +2776,10 @@ inline bool State::setActiveTextureUnit( unsigned int unit ) return true; } +// forward declare speciailization of State::get() method +template<> inline GL2Extensions* State::get() { return _gl2Extentsions.get(); } +template<> inline const GL2Extensions* State::getExisting() const { return _gl2Extentsions.get(); } + } #endif diff --git a/src/osg/FrameBufferObject.cpp b/src/osg/FrameBufferObject.cpp index 062ee6428..cad4b0b2a 100644 --- a/src/osg/FrameBufferObject.cpp +++ b/src/osg/FrameBufferObject.cpp @@ -918,8 +918,8 @@ void FrameBufferObject::apply(State &state, BindTarget target) const { if (_drawBuffers.size() > 0) { - GL2Extensions *gl2e = GL2Extensions::Get(state.getContextID(), true ); - if (gl2e && gl2e->isDrawBuffersSupported()) + GL2Extensions *gl2e = state.get(); + if (gl2e && gl2e->glDrawBuffers) { gl2e->glDrawBuffers(_drawBuffers.size(), &(_drawBuffers[0])); } diff --git a/src/osg/GL2Extensions.cpp b/src/osg/GL2Extensions.cpp index c3ee2fd71..abbe9b5b2 100644 --- a/src/osg/GL2Extensions.cpp +++ b/src/osg/GL2Extensions.cpp @@ -29,802 +29,7 @@ using namespace osg; /////////////////////////////////////////////////////////////////////////// -// Extension function pointers for OpenGL v2.x - -GL2Extensions::GL2Extensions(unsigned int contextID) -{ - setupGL2Extensions(contextID); -} - - -GL2Extensions::GL2Extensions(const GL2Extensions& rhs) : osg::Referenced() -{ - _glVersion = rhs._glVersion; - _glslLanguageVersion = rhs._glslLanguageVersion; - - _isShaderObjectsSupported = rhs._isShaderObjectsSupported; - _isVertexShaderSupported = rhs._isVertexShaderSupported; - _isFragmentShaderSupported = rhs._isFragmentShaderSupported; - _isLanguage100Supported = rhs._isLanguage100Supported; - _isGeometryShader4Supported = rhs._isGeometryShader4Supported; - _areTessellationShadersSupported = rhs._areTessellationShadersSupported; - _isGpuShader4Supported = rhs._isGpuShader4Supported; - _isUniformBufferObjectSupported = rhs._isUniformBufferObjectSupported; - _isGetProgramBinarySupported = rhs._isGetProgramBinarySupported; - _isGpuShaderFp64Supported = rhs._isGpuShaderFp64Supported; - _isShaderAtomicCountersSupported = rhs._isShaderAtomicCountersSupported; - - _glBlendEquationSeparate = rhs._glBlendEquationSeparate; - _glDrawBuffers = rhs._glDrawBuffers; - _glStencilOpSeparate = rhs._glStencilOpSeparate; - _glStencilFuncSeparate = rhs._glStencilFuncSeparate; - _glStencilMaskSeparate = rhs._glStencilMaskSeparate; - _glAttachShader = rhs._glAttachShader; - _glBindAttribLocation = rhs._glBindAttribLocation; - _glCompileShader = rhs._glCompileShader; - _glCreateProgram = rhs._glCreateProgram; - _glCreateShader = rhs._glCreateShader; - _glDeleteProgram = rhs._glDeleteProgram; - _glDeleteShader = rhs._glDeleteShader; - _glDetachShader = rhs._glDetachShader; - _glDisableVertexAttribArray = rhs._glDisableVertexAttribArray; - _glEnableVertexAttribArray = rhs._glEnableVertexAttribArray; - _glGetActiveAttrib = rhs._glGetActiveAttrib; - _glGetActiveUniform = rhs._glGetActiveUniform; - _glGetAttachedShaders = rhs._glGetAttachedShaders; - _glGetAttribLocation = rhs._glGetAttribLocation; - _glGetProgramiv = rhs._glGetProgramiv; - _glGetProgramInfoLog = rhs._glGetProgramInfoLog; - _glGetShaderiv = rhs._glGetShaderiv; - _glGetShaderInfoLog = rhs._glGetShaderInfoLog; - _glGetShaderSource = rhs._glGetShaderSource; - _glGetUniformLocation = rhs._glGetUniformLocation; - _glGetUniformfv = rhs._glGetUniformfv; - _glGetUniformiv = rhs._glGetUniformiv; - _glGetVertexAttribdv = rhs._glGetVertexAttribdv; - _glGetVertexAttribfv = rhs._glGetVertexAttribfv; - _glGetVertexAttribiv = rhs._glGetVertexAttribiv; - _glGetVertexAttribPointerv = rhs._glGetVertexAttribPointerv; - _glIsProgram = rhs._glIsProgram; - _glIsShader = rhs._glIsShader; - _glLinkProgram = rhs._glLinkProgram; - _glShaderSource = rhs._glShaderSource; - _glUseProgram = rhs._glUseProgram; - _glUniform1f = rhs._glUniform1f; - _glUniform2f = rhs._glUniform2f; - _glUniform3f = rhs._glUniform3f; - _glUniform4f = rhs._glUniform4f; - _glUniform1i = rhs._glUniform1i; - _glUniform2i = rhs._glUniform2i; - _glUniform3i = rhs._glUniform3i; - _glUniform4i = rhs._glUniform4i; - _glUniform1fv = rhs._glUniform1fv; - _glUniform2fv = rhs._glUniform2fv; - _glUniform3fv = rhs._glUniform3fv; - _glUniform4fv = rhs._glUniform4fv; - _glUniform1iv = rhs._glUniform1iv; - _glUniform2iv = rhs._glUniform2iv; - _glUniform3iv = rhs._glUniform3iv; - _glUniform4iv = rhs._glUniform4iv; - _glUniformMatrix2fv = rhs._glUniformMatrix2fv; - _glUniformMatrix3fv = rhs._glUniformMatrix3fv; - _glUniformMatrix4fv = rhs._glUniformMatrix4fv; - _glValidateProgram = rhs._glValidateProgram; - _glVertexAttrib1d = rhs._glVertexAttrib1d; - _glVertexAttrib1dv = rhs._glVertexAttrib1dv; - _glVertexAttrib1f = rhs._glVertexAttrib1f; - _glVertexAttrib1fv = rhs._glVertexAttrib1fv; - _glVertexAttrib1s = rhs._glVertexAttrib1s; - _glVertexAttrib1sv = rhs._glVertexAttrib1sv; - _glVertexAttrib2d = rhs._glVertexAttrib2d; - _glVertexAttrib2dv = rhs._glVertexAttrib2dv; - _glVertexAttrib2f = rhs._glVertexAttrib2f; - _glVertexAttrib2fv = rhs._glVertexAttrib2fv; - _glVertexAttrib2s = rhs._glVertexAttrib2s; - _glVertexAttrib2sv = rhs._glVertexAttrib2sv; - _glVertexAttrib3d = rhs._glVertexAttrib3d; - _glVertexAttrib3dv = rhs._glVertexAttrib3dv; - _glVertexAttrib3f = rhs._glVertexAttrib3f; - _glVertexAttrib3fv = rhs._glVertexAttrib3fv; - _glVertexAttrib3s = rhs._glVertexAttrib3s; - _glVertexAttrib3sv = rhs._glVertexAttrib3sv; - _glVertexAttrib4Nbv = rhs._glVertexAttrib4Nbv; - _glVertexAttrib4Niv = rhs._glVertexAttrib4Niv; - _glVertexAttrib4Nsv = rhs._glVertexAttrib4Nsv; - _glVertexAttrib4Nub = rhs._glVertexAttrib4Nub; - _glVertexAttrib4Nubv = rhs._glVertexAttrib4Nubv; - _glVertexAttrib4Nuiv = rhs._glVertexAttrib4Nuiv; - _glVertexAttrib4Nusv = rhs._glVertexAttrib4Nusv; - _glVertexAttrib4bv = rhs._glVertexAttrib4bv; - _glVertexAttrib4d = rhs._glVertexAttrib4d; - _glVertexAttrib4dv = rhs._glVertexAttrib4dv; - _glVertexAttrib4f = rhs._glVertexAttrib4f; - _glVertexAttrib4fv = rhs._glVertexAttrib4fv; - _glVertexAttrib4iv = rhs._glVertexAttrib4iv; - _glVertexAttrib4s = rhs._glVertexAttrib4s; - _glVertexAttrib4sv = rhs._glVertexAttrib4sv; - _glVertexAttrib4ubv = rhs._glVertexAttrib4ubv; - _glVertexAttrib4uiv = rhs._glVertexAttrib4uiv; - _glVertexAttrib4usv = rhs._glVertexAttrib4usv; - _glVertexAttribPointer = rhs._glVertexAttribPointer; - _glVertexAttribDivisor = rhs._glVertexAttribDivisor; - - _glGetInfoLogARB = rhs._glGetInfoLogARB; - _glGetObjectParameterivARB = rhs._glGetObjectParameterivARB; - _glDeleteObjectARB = rhs._glDeleteObjectARB; - _glGetHandleARB = rhs._glGetHandleARB; - - // GL 2.1 - _glUniformMatrix2x3fv = rhs._glUniformMatrix2x3fv; - _glUniformMatrix3x2fv = rhs._glUniformMatrix3x2fv; - _glUniformMatrix2x4fv = rhs._glUniformMatrix2x4fv; - _glUniformMatrix4x2fv = rhs._glUniformMatrix4x2fv; - _glUniformMatrix3x4fv = rhs._glUniformMatrix3x4fv; - _glUniformMatrix4x3fv = rhs._glUniformMatrix4x3fv; - - // EXT_geometry_shader4 - _glProgramParameteri = rhs._glProgramParameteri; - _glFramebufferTexture = rhs._glFramebufferTexture; - _glFramebufferTextureLayer = rhs._glFramebufferTextureLayer; - _glFramebufferTextureFace = rhs._glFramebufferTextureFace; - - // EXT_gpu_shader4 - _glGetUniformuiv = rhs._glGetUniformuiv; - _glBindFragDataLocation = rhs._glBindFragDataLocation; - _glGetFragDataLocation = rhs._glGetFragDataLocation; - _glUniform1ui = rhs._glUniform1ui; - _glUniform2ui = rhs._glUniform2ui; - _glUniform3ui = rhs._glUniform3ui; - _glUniform4ui = rhs._glUniform4ui; - _glUniform1uiv = rhs._glUniform1uiv; - _glUniform2uiv = rhs._glUniform2uiv; - _glUniform3uiv = rhs._glUniform3uiv; - _glUniform4uiv = rhs._glUniform4uiv; - - // ARB_uniform_buffer_object - _glGetUniformIndices = rhs._glGetUniformIndices; - _glGetActiveUniformsiv = rhs._glGetActiveUniformsiv; - _glGetActiveUniformName = rhs._glGetActiveUniformName; - _glGetUniformBlockIndex = rhs._glGetUniformBlockIndex; - _glGetActiveUniformBlockiv = rhs._glGetActiveUniformBlockiv; - _glGetActiveUniformBlockName = rhs._glGetActiveUniformBlockName; - _glUniformBlockBinding = rhs._glUniformBlockBinding; - - // ARB_get_program_binary - _glGetProgramBinary = rhs._glGetProgramBinary; - _glProgramBinary = rhs._glProgramBinary; - - // ARB_gpu_shader_fp64 - _glUniform1d = rhs._glUniform1d; - _glUniform2d = rhs._glUniform2d; - _glUniform3d = rhs._glUniform3d; - _glUniform4d = rhs._glUniform4d; - _glUniform1dv = rhs._glUniform1dv; - _glUniform2dv = rhs._glUniform2dv; - _glUniform3dv = rhs._glUniform3dv; - _glUniform4dv = rhs._glUniform4dv; - _glUniformMatrix2dv = rhs._glUniformMatrix2dv; - _glUniformMatrix3dv = rhs._glUniformMatrix3dv; - _glUniformMatrix4dv = rhs._glUniformMatrix4dv; - _glUniformMatrix2x3dv = rhs._glUniformMatrix2x3dv; - _glUniformMatrix3x2dv = rhs._glUniformMatrix3x2dv; - _glUniformMatrix2x4dv = rhs._glUniformMatrix2x4dv; - _glUniformMatrix4x2dv = rhs._glUniformMatrix4x2dv; - _glUniformMatrix3x4dv = rhs._glUniformMatrix3x4dv; - _glUniformMatrix4x3dv = rhs._glUniformMatrix4x3dv; - - // ARB_shader_atomic_counters - _glGetActiveAtomicCounterBufferiv = rhs._glGetActiveAtomicCounterBufferiv; - - // ARB_compute_shader - _glDispatchCompute = rhs._glDispatchCompute; -} - - -void GL2Extensions::lowestCommonDenominator(const GL2Extensions& rhs) -{ - if (rhs._glVersion < _glVersion) _glVersion = rhs._glVersion; - if (rhs._glslLanguageVersion < _glslLanguageVersion) - _glslLanguageVersion = rhs._glslLanguageVersion; - - if (!rhs._isShaderObjectsSupported) _isShaderObjectsSupported = false; - if (!rhs._isVertexShaderSupported) _isVertexShaderSupported = false; - if (!rhs._isFragmentShaderSupported) _isFragmentShaderSupported = false; - if (!rhs._isLanguage100Supported) _isLanguage100Supported = false; - if (!rhs._isGeometryShader4Supported) _isGeometryShader4Supported = false; - if (!rhs._areTessellationShadersSupported) _areTessellationShadersSupported = false; - if (!rhs._isGpuShader4Supported) _isGpuShader4Supported = false; - if (!rhs._isUniformBufferObjectSupported) _isUniformBufferObjectSupported = false; - if (!rhs._isGetProgramBinarySupported) _isGetProgramBinarySupported = false; - if (!rhs._isGpuShaderFp64Supported) _isGpuShaderFp64Supported = false; - if (!rhs._isShaderAtomicCountersSupported) _isShaderAtomicCountersSupported = false; - - if (!rhs._glBlendEquationSeparate) _glBlendEquationSeparate = 0; - if (!rhs._glDrawBuffers) _glDrawBuffers = 0; - if (!rhs._glStencilOpSeparate) _glStencilOpSeparate = 0; - if (!rhs._glStencilFuncSeparate) _glStencilFuncSeparate = 0; - if (!rhs._glStencilMaskSeparate) _glStencilMaskSeparate = 0; - if (!rhs._glAttachShader) _glAttachShader = 0; - if (!rhs._glBindAttribLocation) _glBindAttribLocation = 0; - if (!rhs._glCompileShader) _glCompileShader = 0; - if (!rhs._glCreateProgram) _glCreateProgram = 0; - if (!rhs._glCreateShader) _glCreateShader = 0; - if (!rhs._glDeleteProgram) _glDeleteProgram = 0; - if (!rhs._glDeleteShader) _glDeleteShader = 0; - if (!rhs._glDetachShader) _glDetachShader = 0; - if (!rhs._glDisableVertexAttribArray) _glDisableVertexAttribArray = 0; - if (!rhs._glEnableVertexAttribArray) _glEnableVertexAttribArray = 0; - if (!rhs._glGetActiveAttrib) _glGetActiveAttrib = 0; - if (!rhs._glGetActiveUniform) _glGetActiveUniform = 0; - if (!rhs._glGetAttachedShaders) _glGetAttachedShaders = 0; - if (!rhs._glGetAttribLocation) _glGetAttribLocation = 0; - if (!rhs._glGetProgramiv) _glGetProgramiv = 0; - if (!rhs._glGetProgramInfoLog) _glGetProgramInfoLog = 0; - if (!rhs._glGetShaderiv) _glGetShaderiv = 0; - if (!rhs._glGetShaderInfoLog) _glGetShaderInfoLog = 0; - if (!rhs._glGetShaderSource) _glGetShaderSource = 0; - if (!rhs._glGetUniformLocation) _glGetUniformLocation = 0; - if (!rhs._glGetUniformfv) _glGetUniformfv = 0; - if (!rhs._glGetUniformiv) _glGetUniformiv = 0; - if (!rhs._glGetVertexAttribdv) _glGetVertexAttribdv = 0; - if (!rhs._glGetVertexAttribfv) _glGetVertexAttribfv = 0; - if (!rhs._glGetVertexAttribiv) _glGetVertexAttribiv = 0; - if (!rhs._glGetVertexAttribPointerv) _glGetVertexAttribPointerv = 0; - if (!rhs._glIsProgram) _glIsProgram = 0; - if (!rhs._glIsShader) _glIsShader = 0; - if (!rhs._glLinkProgram) _glLinkProgram = 0; - if (!rhs._glShaderSource) _glShaderSource = 0; - if (!rhs._glUseProgram) _glUseProgram = 0; - if (!rhs._glUniform1f) _glUniform1f = 0; - if (!rhs._glUniform2f) _glUniform2f = 0; - if (!rhs._glUniform3f) _glUniform3f = 0; - if (!rhs._glUniform4f) _glUniform4f = 0; - if (!rhs._glUniform1i) _glUniform1i = 0; - if (!rhs._glUniform2i) _glUniform2i = 0; - if (!rhs._glUniform3i) _glUniform3i = 0; - if (!rhs._glUniform4i) _glUniform4i = 0; - if (!rhs._glUniform1fv) _glUniform1fv = 0; - if (!rhs._glUniform2fv) _glUniform2fv = 0; - if (!rhs._glUniform3fv) _glUniform3fv = 0; - if (!rhs._glUniform4fv) _glUniform4fv = 0; - if (!rhs._glUniform1iv) _glUniform1iv = 0; - if (!rhs._glUniform2iv) _glUniform2iv = 0; - if (!rhs._glUniform3iv) _glUniform3iv = 0; - if (!rhs._glUniform4iv) _glUniform4iv = 0; - if (!rhs._glUniformMatrix2fv) _glUniformMatrix2fv = 0; - if (!rhs._glUniformMatrix3fv) _glUniformMatrix3fv = 0; - if (!rhs._glUniformMatrix4fv) _glUniformMatrix4fv = 0; - if (!rhs._glValidateProgram) _glValidateProgram = 0; - if (!rhs._glVertexAttrib1d) _glVertexAttrib1d = 0; - if (!rhs._glVertexAttrib1dv) _glVertexAttrib1dv = 0; - if (!rhs._glVertexAttrib1f) _glVertexAttrib1f = 0; - if (!rhs._glVertexAttrib1fv) _glVertexAttrib1fv = 0; - if (!rhs._glVertexAttrib1s) _glVertexAttrib1s = 0; - if (!rhs._glVertexAttrib1sv) _glVertexAttrib1sv = 0; - if (!rhs._glVertexAttrib2d) _glVertexAttrib2d = 0; - if (!rhs._glVertexAttrib2dv) _glVertexAttrib2dv = 0; - if (!rhs._glVertexAttrib2f) _glVertexAttrib2f = 0; - if (!rhs._glVertexAttrib2fv) _glVertexAttrib2fv = 0; - if (!rhs._glVertexAttrib2s) _glVertexAttrib2s = 0; - if (!rhs._glVertexAttrib2sv) _glVertexAttrib2sv = 0; - if (!rhs._glVertexAttrib3d) _glVertexAttrib3d = 0; - if (!rhs._glVertexAttrib3dv) _glVertexAttrib3dv = 0; - if (!rhs._glVertexAttrib3f) _glVertexAttrib3f = 0; - if (!rhs._glVertexAttrib3fv) _glVertexAttrib3fv = 0; - if (!rhs._glVertexAttrib3s) _glVertexAttrib3s = 0; - if (!rhs._glVertexAttrib3sv) _glVertexAttrib3sv = 0; - if (!rhs._glVertexAttrib4Nbv) _glVertexAttrib4Nbv = 0; - if (!rhs._glVertexAttrib4Niv) _glVertexAttrib4Niv = 0; - if (!rhs._glVertexAttrib4Nsv) _glVertexAttrib4Nsv = 0; - if (!rhs._glVertexAttrib4Nub) _glVertexAttrib4Nub = 0; - if (!rhs._glVertexAttrib4Nubv) _glVertexAttrib4Nubv = 0; - if (!rhs._glVertexAttrib4Nuiv) _glVertexAttrib4Nuiv = 0; - if (!rhs._glVertexAttrib4Nusv) _glVertexAttrib4Nusv = 0; - if (!rhs._glVertexAttrib4bv) _glVertexAttrib4bv = 0; - if (!rhs._glVertexAttrib4d) _glVertexAttrib4d = 0; - if (!rhs._glVertexAttrib4dv) _glVertexAttrib4dv = 0; - if (!rhs._glVertexAttrib4f) _glVertexAttrib4f = 0; - if (!rhs._glVertexAttrib4fv) _glVertexAttrib4fv = 0; - if (!rhs._glVertexAttrib4iv) _glVertexAttrib4iv = 0; - if (!rhs._glVertexAttrib4s) _glVertexAttrib4s = 0; - if (!rhs._glVertexAttrib4sv) _glVertexAttrib4sv = 0; - if (!rhs._glVertexAttrib4ubv) _glVertexAttrib4ubv = 0; - if (!rhs._glVertexAttrib4uiv) _glVertexAttrib4uiv = 0; - if (!rhs._glVertexAttrib4usv) _glVertexAttrib4usv = 0; - if (!rhs._glVertexAttribPointer) _glVertexAttribPointer = 0; - if (!rhs._glVertexAttribDivisor) _glVertexAttribDivisor = 0; - - if (!rhs._glGetInfoLogARB) _glGetInfoLogARB = 0; - if (!rhs._glGetObjectParameterivARB) _glGetObjectParameterivARB = 0; - if (!rhs._glDeleteObjectARB) _glDeleteObjectARB = 0; - if (!rhs._glGetHandleARB) _glGetHandleARB = 0; - - // GL 2.1 - if (!rhs._glUniformMatrix2x3fv) _glUniformMatrix2x3fv = 0; - if (!rhs._glUniformMatrix3x2fv) _glUniformMatrix3x2fv = 0; - if (!rhs._glUniformMatrix2x4fv) _glUniformMatrix2x4fv = 0; - if (!rhs._glUniformMatrix4x2fv) _glUniformMatrix4x2fv = 0; - if (!rhs._glUniformMatrix3x4fv) _glUniformMatrix3x4fv = 0; - if (!rhs._glUniformMatrix4x3fv) _glUniformMatrix4x3fv = 0; - - // EXT_geometry_shader4 - if (!rhs._glProgramParameteri) _glProgramParameteri = 0; - if (!rhs._glFramebufferTexture) _glFramebufferTexture = 0; - if (!rhs._glFramebufferTextureLayer) _glFramebufferTextureLayer = 0; - if (!rhs._glFramebufferTextureFace) _glFramebufferTextureFace = 0; - - // ARB_tessellation_shader - if (!rhs._glPatchParameteri) _glPatchParameteri = 0; - if (!rhs._glPatchParameterfv) _glPatchParameterfv = 0; - - // EXT_gpu_shader4 - if (!rhs._glGetUniformuiv) _glGetUniformuiv = 0; - if (!rhs._glBindFragDataLocation) _glBindFragDataLocation = 0; - if (!rhs._glGetFragDataLocation) _glGetFragDataLocation = 0; - if (!rhs._glUniform1ui) _glUniform1ui = 0; - if (!rhs._glUniform2ui) _glUniform2ui = 0; - if (!rhs._glUniform3ui) _glUniform3ui = 0; - if (!rhs._glUniform4ui) _glUniform4ui = 0; - if (!rhs._glUniform1uiv) _glUniform1uiv = 0; - if (!rhs._glUniform2uiv) _glUniform2uiv = 0; - if (!rhs._glUniform3uiv) _glUniform3uiv = 0; - if (!rhs._glUniform4uiv) _glUniform4uiv = 0; - - // ARB_uniform_buffer_object - if (!rhs._glGetUniformIndices) _glGetUniformIndices = 0; - if (!rhs._glGetActiveUniformsiv) _glGetActiveUniformsiv = 0; - if (!rhs._glGetActiveUniformName) _glGetActiveUniformName = 0; - if (!rhs._glGetUniformBlockIndex) _glGetUniformBlockIndex = 0; - if (!rhs._glGetActiveUniformBlockiv) _glGetActiveUniformBlockiv = 0; - if (!rhs._glGetActiveUniformBlockName) _glGetActiveUniformBlockName = 0; - if (!rhs._glUniformBlockBinding) _glUniformBlockBinding = 0; - - // ARB_get_program_binary - if (!rhs._glGetProgramBinary) _glGetProgramBinary = 0; - if (!rhs._glProgramBinary) _glProgramBinary = 0; - - // ARB_gpu_shader_fp64 - if(!rhs._glUniform1d) _glUniform1d = 0; - if(!rhs._glUniform2d) _glUniform2d = 0; - if(!rhs._glUniform3d) _glUniform3d = 0; - if(!rhs._glUniform4d) _glUniform4d = 0; - if(!rhs._glUniform1dv) _glUniform1dv = 0; - if(!rhs._glUniform2dv) _glUniform2dv = 0; - if(!rhs._glUniform3dv) _glUniform3dv = 0; - if(!rhs._glUniform4dv) _glUniform4dv = 0; - if(!rhs._glUniformMatrix2dv) _glUniformMatrix2dv = 0; - if(!rhs._glUniformMatrix3dv) _glUniformMatrix3dv = 0; - if(!rhs._glUniformMatrix4dv) _glUniformMatrix4dv = 0; - if(!rhs._glUniformMatrix2x3dv) _glUniformMatrix2x3dv = 0; - if(!rhs._glUniformMatrix3x2dv) _glUniformMatrix3x2dv = 0; - if(!rhs._glUniformMatrix2x4dv) _glUniformMatrix2x4dv = 0; - if(!rhs._glUniformMatrix4x2dv) _glUniformMatrix4x2dv = 0; - if(!rhs._glUniformMatrix3x4dv) _glUniformMatrix3x4dv = 0; - if(!rhs._glUniformMatrix4x3dv) _glUniformMatrix4x3dv = 0; - - // ARB_shader_atomic_counters - if(!rhs._glGetActiveAtomicCounterBufferiv) _glGetActiveAtomicCounterBufferiv = 0; - - // ARB_compute_shder - if(!rhs._glDispatchCompute) _glDispatchCompute = 0; -} - - -void GL2Extensions::setupGL2Extensions(unsigned int contextID) -{ - const char* version = (const char*) glGetString( GL_VERSION ); - if (!version) - { - OSG_NOTIFY(osg::FATAL)<<"Error: OpenGL version test failed, requires valid graphics context."<= 2.0f ) || - ( _isShaderObjectsSupported && - _isVertexShaderSupported && - _isFragmentShaderSupported && - _isLanguage100Supported ); -} - - -/////////////////////////////////////////////////////////////////////////// -// Static array of per-context osg::GL2Extensions instances +// Static array of percontext osg::GL2Extensions instances typedef osg::buffered_object< osg::ref_ptr > BufferedExtensions; static BufferedExtensions s_extensions; @@ -842,2052 +47,259 @@ void GL2Extensions::Set(unsigned int contextID, GL2Extensions* extensions) s_extensions[contextID] = extensions; } - /////////////////////////////////////////////////////////////////////////// +// Extension function pointers for OpenGL v2.x + +GL2Extensions::GL2Extensions(unsigned int contextID) +{ + const char* version = (const char*) glGetString( GL_VERSION ); + if (!version) + { + OSG_NOTIFY(osg::FATAL)<<"Error: OpenGL version test failed, requires valid graphics context."<= 2.0f ) || + ( isShaderObjectsSupported && + isVertexShaderSupported && + isFragmentShaderSupported && + isLanguage100Supported ); + + if( isGlslSupported ) + { + // If glGetString raises an error, assume initial release "1.00" + while(glGetError() != GL_NO_ERROR) {} // reset error flag + + const char* langVerStr = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION); + if( (glGetError() == GL_NO_ERROR) && langVerStr ) + { + glslLanguageVersion = (findAsciiToFloat(langVerStr)); + } + else + glslLanguageVersion = 1.0f; + } + + OSG_INFO + << "glVersion=" << glVersion << ", " + << "isGlslSupported=" << (isGlslSupported ? "YES" : "NO") << ", " + << "glslLanguageVersion=" << glslLanguageVersion + << std::endl; + + + setGLExtensionFuncPtr(glBlendEquationSeparate, "glBlendEquationSeparate"); + setGLExtensionFuncPtr(glDrawBuffers, "glDrawBuffers", "glDrawBuffersARB"); + setGLExtensionFuncPtr(glStencilOpSeparate, "glStencilOpSeparate"); + setGLExtensionFuncPtr(glStencilFuncSeparate, "glStencilFuncSeparate"); + setGLExtensionFuncPtr(glStencilMaskSeparate, "glStencilMaskSeparate"); + setGLExtensionFuncPtr(glAttachShader, "glAttachShader", "glAttachObjectARB"); + setGLExtensionFuncPtr(glBindAttribLocation, "glBindAttribLocation", "glBindAttribLocationARB"); + setGLExtensionFuncPtr(glCompileShader, "glCompileShader", "glCompileShaderARB"); + setGLExtensionFuncPtr(glCreateProgram, "glCreateProgram", "glCreateProgramObjectARB"); + setGLExtensionFuncPtr(glCreateShader, "glCreateShader", "glCreateShaderObjectARB"); + setGLExtensionFuncPtr(glDeleteProgram, "glDeleteProgram"); + setGLExtensionFuncPtr(glDeleteShader, "glDeleteShader"); + setGLExtensionFuncPtr(glDetachShader, "glDetachShader", "glDetachObjectARB"); + setGLExtensionFuncPtr(glDisableVertexAttribArray, "glDisableVertexAttribArray"); + setGLExtensionFuncPtr(glEnableVertexAttribArray, "glEnableVertexAttribArray"); + setGLExtensionFuncPtr(glGetActiveAttrib, "glGetActiveAttrib", "glGetActiveAttribARB"); + setGLExtensionFuncPtr(glGetActiveUniform, "glGetActiveUniform", "glGetActiveUniformARB"); + setGLExtensionFuncPtr(glGetAttachedShaders, "glGetAttachedShaders", "glGetAttachedObjectsARB"); + setGLExtensionFuncPtr(glGetAttribLocation, "glGetAttribLocation", "glGetAttribLocationARB"); + setGLExtensionFuncPtr(glGetProgramiv, "glGetProgramiv"); + setGLExtensionFuncPtr(glGetProgramInfoLog, "glGetProgramInfoLog"); + setGLExtensionFuncPtr(glGetShaderiv, "glGetShaderiv"); + setGLExtensionFuncPtr(glGetShaderInfoLog, "glGetShaderInfoLog"); + setGLExtensionFuncPtr(glGetShaderSource, "glGetShaderSource", "glGetShaderSourceARB"); + setGLExtensionFuncPtr(glGetUniformLocation, "glGetUniformLocation", "glGetUniformLocationARB"); + setGLExtensionFuncPtr(glGetUniformfv, "glGetUniformfv", "glGetUniformfvARB"); + setGLExtensionFuncPtr(glGetUniformiv, "glGetUniformiv", "glGetUniformivARB"); + setGLExtensionFuncPtr(glGetVertexAttribdv, "glGetVertexAttribdv"); + setGLExtensionFuncPtr(glGetVertexAttribfv, "glGetVertexAttribfv"); + setGLExtensionFuncPtr(glGetVertexAttribiv, "glGetVertexAttribiv"); + setGLExtensionFuncPtr(glGetVertexAttribPointerv, "glGetVertexAttribPointerv"); + setGLExtensionFuncPtr(glIsProgram, "glIsProgram"); + setGLExtensionFuncPtr(glIsShader, "glIsShader"); + setGLExtensionFuncPtr(glLinkProgram, "glLinkProgram", "glLinkProgramARB"); + setGLExtensionFuncPtr(glShaderSource, "glShaderSource", "glShaderSourceARB"); + setGLExtensionFuncPtr(glUseProgram, "glUseProgram", "glUseProgramObjectARB"); + setGLExtensionFuncPtr(glUniform1f, "glUniform1f", "glUniform1fARB"); + setGLExtensionFuncPtr(glUniform2f, "glUniform2f", "glUniform2fARB"); + setGLExtensionFuncPtr(glUniform3f, "glUniform3f", "glUniform3fARB"); + setGLExtensionFuncPtr(glUniform4f, "glUniform4f", "glUniform4fARB"); + setGLExtensionFuncPtr(glUniform1i, "glUniform1i", "glUniform1iARB"); + setGLExtensionFuncPtr(glUniform2i, "glUniform2i", "glUniform2iARB"); + setGLExtensionFuncPtr(glUniform3i, "glUniform3i", "glUniform3iARB"); + setGLExtensionFuncPtr(glUniform4i, "glUniform4i", "glUniform4iARB"); + setGLExtensionFuncPtr(glUniform1fv, "glUniform1fv", "glUniform1fvARB"); + setGLExtensionFuncPtr(glUniform2fv, "glUniform2fv", "glUniform2fvARB"); + setGLExtensionFuncPtr(glUniform3fv, "glUniform3fv", "glUniform3fvARB"); + setGLExtensionFuncPtr(glUniform4fv, "glUniform4fv", "glUniform4fvARB"); + setGLExtensionFuncPtr(glUniform1iv, "glUniform1iv", "glUniform1ivARB"); + setGLExtensionFuncPtr(glUniform2iv, "glUniform2iv", "glUniform2ivARB"); + setGLExtensionFuncPtr(glUniform3iv, "glUniform3iv", "glUniform3ivARB"); + setGLExtensionFuncPtr(glUniform4iv, "glUniform4iv", "glUniform4ivARB"); + setGLExtensionFuncPtr(glUniformMatrix2fv, "glUniformMatrix2fv", "glUniformMatrix2fvARB"); + setGLExtensionFuncPtr(glUniformMatrix3fv, "glUniformMatrix3fv", "glUniformMatrix3fvARB"); + setGLExtensionFuncPtr(glUniformMatrix4fv, "glUniformMatrix4fv", "glUniformMatrix4fvARB"); + setGLExtensionFuncPtr(glValidateProgram, "glValidateProgram", "glValidateProgramARB"); + setGLExtensionFuncPtr(glVertexAttrib1d, "glVertexAttrib1d"); + setGLExtensionFuncPtr(glVertexAttrib1dv, "glVertexAttrib1dv"); + setGLExtensionFuncPtr(glVertexAttrib1f, "glVertexAttrib1f"); + setGLExtensionFuncPtr(glVertexAttrib1fv, "glVertexAttrib1fv"); + setGLExtensionFuncPtr(glVertexAttrib1s, "glVertexAttrib1s"); + setGLExtensionFuncPtr(glVertexAttrib1sv, "glVertexAttrib1sv"); + setGLExtensionFuncPtr(glVertexAttrib2d, "glVertexAttrib2d"); + setGLExtensionFuncPtr(glVertexAttrib2dv, "glVertexAttrib2dv"); + setGLExtensionFuncPtr(glVertexAttrib2f, "glVertexAttrib2f"); + setGLExtensionFuncPtr(glVertexAttrib2fv, "glVertexAttrib2fv"); + setGLExtensionFuncPtr(glVertexAttrib2s, "glVertexAttrib2s"); + setGLExtensionFuncPtr(glVertexAttrib2sv, "glVertexAttrib2sv"); + setGLExtensionFuncPtr(glVertexAttrib3d, "glVertexAttrib3d"); + setGLExtensionFuncPtr(glVertexAttrib3dv, "glVertexAttrib3dv"); + setGLExtensionFuncPtr(glVertexAttrib3f, "glVertexAttrib3f"); + setGLExtensionFuncPtr(glVertexAttrib3fv, "glVertexAttrib3fv"); + setGLExtensionFuncPtr(glVertexAttrib3s, "glVertexAttrib3s"); + setGLExtensionFuncPtr(glVertexAttrib3sv, "glVertexAttrib3sv"); + setGLExtensionFuncPtr(glVertexAttrib4Nbv, "glVertexAttrib4Nbv"); + setGLExtensionFuncPtr(glVertexAttrib4Niv, "glVertexAttrib4Niv"); + setGLExtensionFuncPtr(glVertexAttrib4Nsv, "glVertexAttrib4Nsv"); + setGLExtensionFuncPtr(glVertexAttrib4Nub, "glVertexAttrib4Nub"); + setGLExtensionFuncPtr(glVertexAttrib4Nubv, "glVertexAttrib4Nubv"); + setGLExtensionFuncPtr(glVertexAttrib4Nuiv, "glVertexAttrib4Nuiv"); + setGLExtensionFuncPtr(glVertexAttrib4Nusv, "glVertexAttrib4Nusv"); + setGLExtensionFuncPtr(glVertexAttrib4bv, "glVertexAttrib4bv"); + setGLExtensionFuncPtr(glVertexAttrib4d, "glVertexAttrib4d"); + setGLExtensionFuncPtr(glVertexAttrib4dv, "glVertexAttrib4dv"); + setGLExtensionFuncPtr(glVertexAttrib4f, "glVertexAttrib4f"); + setGLExtensionFuncPtr(glVertexAttrib4fv, "glVertexAttrib4fv"); + setGLExtensionFuncPtr(glVertexAttrib4iv, "glVertexAttrib4iv"); + setGLExtensionFuncPtr(glVertexAttrib4s, "glVertexAttrib4s"); + setGLExtensionFuncPtr(glVertexAttrib4sv, "glVertexAttrib4sv"); + setGLExtensionFuncPtr(glVertexAttrib4ubv, "glVertexAttrib4ubv"); + setGLExtensionFuncPtr(glVertexAttrib4uiv, "glVertexAttrib4uiv"); + setGLExtensionFuncPtr(glVertexAttrib4usv, "glVertexAttrib4usv"); + setGLExtensionFuncPtr(glVertexAttribPointer, "glVertexAttribPointer"); + setGLExtensionFuncPtr(glVertexAttribDivisor, "glVertexAttribDivisor"); + + // v1.5-only ARB entry points, in case they're needed for fallback + setGLExtensionFuncPtr(glGetInfoLogARB, "glGetInfoLogARB"); + setGLExtensionFuncPtr(glGetObjectParameterivARB, "glGetObjectParameterivARB"); + setGLExtensionFuncPtr(glDeleteObjectARB, "glDeleteObjectARB"); + setGLExtensionFuncPtr(glGetHandleARB, "glGetHandleARB"); + + // GL 2.1 + setGLExtensionFuncPtr(glUniformMatrix2x3fv, "glUniformMatrix2x3fv" ); + setGLExtensionFuncPtr(glUniformMatrix3x2fv, "glUniformMatrix3x2fv" ); + setGLExtensionFuncPtr(glUniformMatrix2x4fv, "glUniformMatrix2x4fv" ); + setGLExtensionFuncPtr(glUniformMatrix4x2fv, "glUniformMatrix4x2fv" ); + setGLExtensionFuncPtr(glUniformMatrix3x4fv, "glUniformMatrix3x4fv" ); + setGLExtensionFuncPtr(glUniformMatrix4x3fv, "glUniformMatrix4x3fv" ); + + // EXT_geometry_shader4 + setGLExtensionFuncPtr(glProgramParameteri, "glProgramParameteri", "glProgramParameteriEXT" ); + setGLExtensionFuncPtr(glFramebufferTexture, "glFramebufferTexture", "glFramebufferTextureEXT" ); + setGLExtensionFuncPtr(glFramebufferTextureLayer, "glFramebufferTextureLayer", "glFramebufferTextureLayerEXT" ); + setGLExtensionFuncPtr(glFramebufferTextureFace, "glFramebufferTextureFace", "glFramebufferTextureFaceEXT" ); + + // ARB_tesselation_shader + setGLExtensionFuncPtr(glPatchParameteri, "glPatchParameteri" ); + setGLExtensionFuncPtr(glPatchParameterfv, "glPatchParameterfv"); + + // EXT_gpu_shader4 + setGLExtensionFuncPtr(glGetUniformuiv, "glGetUniformuiv", "glGetUniformuivEXT" ); + setGLExtensionFuncPtr(glBindFragDataLocation, "glBindFragDataLocation", "glBindFragDataLocationEXT" ); + setGLExtensionFuncPtr(glGetFragDataLocation, "glGetFragDataLocation", "glGetFragDataLocationEXT" ); + setGLExtensionFuncPtr(glUniform1ui, "glUniform1ui", "glUniform1uiEXT" ); + setGLExtensionFuncPtr(glUniform2ui, "glUniform2ui", "glUniform2uiEXT" ); + setGLExtensionFuncPtr(glUniform3ui, "glUniform3ui", "glUniform3uiEXT" ); + setGLExtensionFuncPtr(glUniform4ui, "glUniform4ui", "glUniform4uiEXT" ); + setGLExtensionFuncPtr(glUniform1uiv, "glUniform1uiv", "glUniform1uivEXT" ); + setGLExtensionFuncPtr(glUniform2uiv, "glUniform2uiv", "glUniform2uivEXT" ); + setGLExtensionFuncPtr(glUniform3uiv, "glUniform3uiv", "glUniform3uivEXT" ); + setGLExtensionFuncPtr(glUniform4uiv, "glUniform4uiv", "glUniform4uivEXT" ); + // ARB_uniform_buffer_object + setGLExtensionFuncPtr(glGetUniformIndices, "glGetUniformIndices"); + setGLExtensionFuncPtr(glGetActiveUniformsiv, "glGetActiveUniformsiv"); + setGLExtensionFuncPtr(glGetActiveUniformName, "glGetActiveUniformName"); + setGLExtensionFuncPtr(glGetUniformBlockIndex, "glGetUniformBlockIndex"); + setGLExtensionFuncPtr(glGetActiveUniformBlockiv, "glGetActiveUniformBlockiv"); + setGLExtensionFuncPtr(glGetActiveUniformBlockName, "glGetActiveUniformBlockName"); + setGLExtensionFuncPtr(glUniformBlockBinding, "glUniformBlockBinding"); + + // ARB_get_program_binary + setGLExtensionFuncPtr(glGetProgramBinary, "glGetProgramBinary"); + setGLExtensionFuncPtr(glProgramBinary, "glProgramBinary"); + + // ARB_gpu_shader_fp64 + setGLExtensionFuncPtr(glUniform1d, "glUniform1d" ); + setGLExtensionFuncPtr(glUniform2d, "glUniform2d" ); + setGLExtensionFuncPtr(glUniform3d, "glUniform3d" ); + setGLExtensionFuncPtr(glUniform4d, "glUniform4d" ); + setGLExtensionFuncPtr(glUniform1dv, "glUniform1dv" ); + setGLExtensionFuncPtr(glUniform2dv, "glUniform2dv" ); + setGLExtensionFuncPtr(glUniform3dv, "glUniform3dv" ); + setGLExtensionFuncPtr(glUniform4dv, "glUniform4dv" ); + setGLExtensionFuncPtr(glUniformMatrix2dv, "glUniformMatrix2dv" ); + setGLExtensionFuncPtr(glUniformMatrix3dv, "glUniformMatrix3dv" ); + setGLExtensionFuncPtr(glUniformMatrix4dv, "glUniformMatrix4dv" ); + setGLExtensionFuncPtr(glUniformMatrix2x3dv, "glUniformMatrix2x3dv" ); + setGLExtensionFuncPtr(glUniformMatrix3x2dv, "glUniformMatrix3x2dv" ); + setGLExtensionFuncPtr(glUniformMatrix2x4dv, "glUniformMatrix2x4dv" ); + setGLExtensionFuncPtr(glUniformMatrix4x2dv, "glUniformMatrix4x2dv" ); + setGLExtensionFuncPtr(glUniformMatrix3x4dv, "glUniformMatrix3x4dv" ); + setGLExtensionFuncPtr(glUniformMatrix4x3dv, "glUniformMatrix4x3dv" ); + + // ARB_shader_atomic_counters + setGLExtensionFuncPtr(glGetActiveAtomicCounterBufferiv, "glGetActiveAtomicCounterBufferiv" ); + + // ARB_compute_shader + setGLExtensionFuncPtr(glDispatchCompute, "glDispatchCompute" ); -static void NotSupported( const char* funcName ) -{ - OSG_WARN - <<"Error: "<= 2.0f ) + if( glVersion >= 2.0f ) { // GLSL as GL v2.0 core functionality GLint result = 0; glGetIntegerv( GL_CURRENT_PROGRAM, &result ); return static_cast(result); } - else if (_glGetHandleARB) + else if (glGetHandleARB) { // fallback for GLSL as GL v1.5 ARB extension #ifndef GL_PROGRAM_OBJECT_ARB #define GL_PROGRAM_OBJECT_ARB 0x8B40 #endif - return _glGetHandleARB( GL_PROGRAM_OBJECT_ARB ); + return glGetHandleARB( GL_PROGRAM_OBJECT_ARB ); } else { - NotSupported( "getCurrentProgram" ); + OSG_WARN<<"Warning GL2Extensions::getCurrentProgram not supported"<(fragDataName) ); diff --git a/src/osg/PatchParameter.cpp b/src/osg/PatchParameter.cpp index 8955960e0..25d62ac78 100644 --- a/src/osg/PatchParameter.cpp +++ b/src/osg/PatchParameter.cpp @@ -31,10 +31,10 @@ PatchParameter::~PatchParameter() void PatchParameter::apply(State& state) const { - GL2Extensions* extensions = GL2Extensions::Get( state.getContextID(), true ); - if (extensions->areTessellationShadersSupported() ) + GL2Extensions* extensions = state.get(); + if (extensions->areTessellationShadersSupported ) { - + extensions->glPatchParameteri( GL_PATCH_VERTICES, _vertices ); extensions->glPatchParameterfv( GL_PATCH_DEFAULT_INNER_LEVEL, _patchDefaultInnerLevel.ptr() ); extensions->glPatchParameterfv( GL_PATCH_DEFAULT_OUTER_LEVEL, _patchDefaultOuterLevel.ptr() ); diff --git a/src/osg/Program.cpp b/src/osg/Program.cpp index 79e410ee1..b241ff2e5 100644 --- a/src/osg/Program.cpp +++ b/src/osg/Program.cpp @@ -67,7 +67,7 @@ void Program::flushDeletedGlPrograms(unsigned int contextID,double /*currentTime OpenThreads::ScopedLock lock(s_mutex_deletedGlProgramCache); const GL2Extensions* extensions = GL2Extensions::Get(contextID,true); - if( ! extensions->isGlslSupported() ) return; + if( ! extensions->isGlslSupported ) return; const osg::Timer& timer = *osg::Timer::instance(); osg::Timer_t start_tick = timer.tick(); @@ -441,8 +441,8 @@ void Program::removeBindUniformBlock(const std::string& name) void Program::apply( osg::State& state ) const { const unsigned int contextID = state.getContextID(); - const GL2Extensions* extensions = GL2Extensions::Get(contextID,true); - if( ! extensions->isGlslSupported() ) return; + const GL2Extensions* extensions = state.get(); + if( ! extensions->isGlslSupported ) return; if( isFixedFunction() ) { @@ -532,9 +532,9 @@ Program::PerContextProgram::PerContextProgram(const Program* program, unsigned i _ownsProgramHandle(false) { _program = program; - _extensions = GL2Extensions::Get( _contextID, true ); if (_glProgramHandle == 0) { + _extensions = GL2Extensions::Get( _contextID, true ); _glProgramHandle = _extensions->glCreateProgram(); _ownsProgramHandle = true; } @@ -581,7 +581,7 @@ void Program::PerContextProgram::linkProgram(osg::State& state) if (!_loadedBinary) { - if (_extensions->isGeometryShader4Supported()) + if (_extensions->isGeometryShader4Supported) { _extensions->glProgramParameteri( _glProgramHandle, GL_GEOMETRY_VERTICES_OUT_EXT, _program->_geometryVerticesOut ); _extensions->glProgramParameteri( _glProgramHandle, GL_GEOMETRY_INPUT_TYPE_EXT, _program->_geometryInputType ); @@ -678,7 +678,7 @@ void Program::PerContextProgram::linkProgram(osg::State& state) } } - if (_extensions->isUniformBufferObjectSupported()) + if (_extensions->isUniformBufferObjectSupported) { GLuint activeUniformBlocks = 0; GLsizei maxBlockNameLen = 0; @@ -779,7 +779,7 @@ void Program::PerContextProgram::linkProgram(osg::State& state) // print atomic counter - if (_extensions->isShaderAtomicCounterSupported() && !atomicCounterMap.empty()) + if (_extensions->isShaderAtomicCountersSupported && !atomicCounterMap.empty()) { std::vector bufferIndex( atomicCounterMap.size(), 0 ); std::vector uniformIndex; diff --git a/src/osg/Shader.cpp b/src/osg/Shader.cpp index c06b48d39..62d58cc2b 100644 --- a/src/osg/Shader.cpp +++ b/src/osg/Shader.cpp @@ -178,7 +178,7 @@ void Shader::flushDeletedGlShaders(unsigned int contextID,double /*currentTime*/ if (availableTime<=0.0) return; const GL2Extensions* extensions = GL2Extensions::Get(contextID,true); - if( ! extensions->isGlslSupported() ) return; + if( ! extensions->isGlslSupported ) return; const osg::Timer& timer = *osg::Timer::instance(); osg::Timer_t start_tick = timer.tick(); diff --git a/src/osg/State.cpp b/src/osg/State.cpp index 5150361d0..31078d67c 100644 --- a/src/osg/State.cpp +++ b/src/osg/State.cpp @@ -131,6 +131,10 @@ State::State(): State::~State() { + // delete the GL2Extensions object associated with this osg::State. + GL2Extensions::Set(_contextID, 0); + _gl2Extentsions = 0; + //_texCoordArrayList.clear(); //_vertexAttribArrayList.clear(); @@ -918,6 +922,9 @@ void State::initializeExtensionProcs() { if (_extensionProcsInitialized) return; + _gl2Extentsions = new GL2Extensions(_contextID); + GL2Extensions::Set(_contextID, _gl2Extentsions.get()); + setGLExtensionFuncPtr(_glClientActiveTexture,"glClientActiveTexture","glClientActiveTextureARB"); setGLExtensionFuncPtr(_glActiveTexture, "glActiveTexture","glActiveTextureARB"); setGLExtensionFuncPtr(_glFogCoordPointer, "glFogCoordPointer","glFogCoordPointerEXT");