Introduction an ADD_FUNCTION macro to simply the set up of the static function mappings

This commit is contained in:
Robert Osfield
2010-05-19 13:40:46 +00:00
parent b979b585f2
commit 2996dc8244

View File

@@ -19,6 +19,7 @@
#include "GLStaticLibrary.h"
#include <osg/GL>
#include <osg/Notify>
#include <map>
#include <string>
@@ -34,150 +35,153 @@ typedef std::map<std::string, GLProc> GLProcAddressMap;
static bool sProcAddressInitialized = false;
static GLProcAddressMap sProcAddressMap;
#define ADD_FUNCTION(FunctionName) sProcAddressMap[#FunctionName] = reinterpret_cast<GLProc>(&FunctionName);
void initGLES2ProcAddress()
{
sProcAddressMap["glActiveTexture"] = reinterpret_cast<GLProc>(&glActiveTexture);
sProcAddressMap["glAttachShader"] = reinterpret_cast<GLProc>(&glAttachShader);
sProcAddressMap["glBindAttribLocation"] = reinterpret_cast<GLProc>(&glBindAttribLocation);
sProcAddressMap["glBindBuffer"] = reinterpret_cast<GLProc>(&glBindBuffer);
sProcAddressMap["glBindFramebuffer"] = reinterpret_cast<GLProc>(&glBindFramebuffer);
sProcAddressMap["glBindRenderbuffer"] = reinterpret_cast<GLProc>(&glBindRenderbuffer);
sProcAddressMap["glBindTexture"] = reinterpret_cast<GLProc>(&glBindTexture);
sProcAddressMap["glBlendColor"] = reinterpret_cast<GLProc>(&glBlendColor);
sProcAddressMap["glBlendEquation"] = reinterpret_cast<GLProc>(&glBlendEquation);
sProcAddressMap["glBlendEquationSeparate"] = reinterpret_cast<GLProc>(&glBlendEquationSeparate);
sProcAddressMap["glBlendFunc"] = reinterpret_cast<GLProc>(&glBlendFunc);
sProcAddressMap["glBlendFuncSeparate"] = reinterpret_cast<GLProc>(&glBlendFuncSeparate);
sProcAddressMap["glBufferData"] = reinterpret_cast<GLProc>(&glBufferData);
sProcAddressMap["glBufferSubData"] = reinterpret_cast<GLProc>(&glBufferSubData);
sProcAddressMap["glCheckFramebufferStatus"] = reinterpret_cast<GLProc>(&glCheckFramebufferStatus);
sProcAddressMap["glClear"] = reinterpret_cast<GLProc>(&glClear);
sProcAddressMap["glClearColor"] = reinterpret_cast<GLProc>(&glClearColor);
sProcAddressMap["glClearDepthf"] = reinterpret_cast<GLProc>(&glClearDepthf);
sProcAddressMap["glClearStencil"] = reinterpret_cast<GLProc>(&glClearStencil);
sProcAddressMap["glColorMask"] = reinterpret_cast<GLProc>(&glColorMask);
sProcAddressMap["glCompileShader"] = reinterpret_cast<GLProc>(&glCompileShader);
sProcAddressMap["glCompressedTexImage2D"] = reinterpret_cast<GLProc>(&glCompressedTexImage2D);
sProcAddressMap["glCompressedTexSubImage2D"] = reinterpret_cast<GLProc>(&glCompressedTexSubImage2D);
sProcAddressMap["glCopyTexImage2D"] = reinterpret_cast<GLProc>(&glCopyTexImage2D);
sProcAddressMap["glCopyTexSubImage2D"] = reinterpret_cast<GLProc>(&glCopyTexSubImage2D);
sProcAddressMap["glCreateProgram"] = reinterpret_cast<GLProc>(&glCreateProgram);
sProcAddressMap["glCreateShader"] = reinterpret_cast<GLProc>(&glCreateShader);
sProcAddressMap["glCullFace"] = reinterpret_cast<GLProc>(&glCullFace);
sProcAddressMap["glDeleteBuffers"] = reinterpret_cast<GLProc>(&glDeleteBuffers);
sProcAddressMap["glDeleteFramebuffers"] = reinterpret_cast<GLProc>(&glDeleteFramebuffers);
sProcAddressMap["glDeleteProgram"] = reinterpret_cast<GLProc>(&glDeleteProgram);
sProcAddressMap["glDeleteRenderbuffers"] = reinterpret_cast<GLProc>(&glDeleteRenderbuffers);
sProcAddressMap["glDeleteShader"] = reinterpret_cast<GLProc>(&glDeleteShader);
sProcAddressMap["glDeleteTextures"] = reinterpret_cast<GLProc>(&glDeleteTextures);
sProcAddressMap["glDepthFunc"] = reinterpret_cast<GLProc>(&glDepthFunc);
sProcAddressMap["glDepthMask"] = reinterpret_cast<GLProc>(&glDepthMask);
sProcAddressMap["glDepthRangef"] = reinterpret_cast<GLProc>(&glDepthRangef);
sProcAddressMap["glDetachShader"] = reinterpret_cast<GLProc>(&glDetachShader);
sProcAddressMap["glDisable"] = reinterpret_cast<GLProc>(&glDisable);
sProcAddressMap["glDisableVertexAttribArray"] = reinterpret_cast<GLProc>(&glDisableVertexAttribArray);
sProcAddressMap["glDrawArrays"] = reinterpret_cast<GLProc>(&glDrawArrays);
sProcAddressMap["glDrawElements"] = reinterpret_cast<GLProc>(&glDrawElements);
sProcAddressMap["glEnable"] = reinterpret_cast<GLProc>(&glEnable);
sProcAddressMap["glEnableVertexAttribArray"] = reinterpret_cast<GLProc>(&glEnableVertexAttribArray);
sProcAddressMap["glFinish"] = reinterpret_cast<GLProc>(&glFinish);
sProcAddressMap["glFlush"] = reinterpret_cast<GLProc>(&glFlush);
sProcAddressMap["glFramebufferRenderbuffer"] = reinterpret_cast<GLProc>(&glFramebufferRenderbuffer);
sProcAddressMap["glFramebufferTexture2D"] = reinterpret_cast<GLProc>(&glFramebufferTexture2D);
sProcAddressMap["glFrontFace"] = reinterpret_cast<GLProc>(&glFrontFace);
sProcAddressMap["glGenBuffers"] = reinterpret_cast<GLProc>(&glGenBuffers);
sProcAddressMap["glGenerateMipmap"] = reinterpret_cast<GLProc>(&glGenerateMipmap);
sProcAddressMap["glGenFramebuffers"] = reinterpret_cast<GLProc>(&glGenFramebuffers);
sProcAddressMap["glGenRenderbuffers"] = reinterpret_cast<GLProc>(&glGenRenderbuffers);
sProcAddressMap["glGenTextures"] = reinterpret_cast<GLProc>(&glGenTextures);
sProcAddressMap["glGetActiveAttrib"] = reinterpret_cast<GLProc>(&glGetActiveAttrib);
sProcAddressMap["glGetActiveUniform"] = reinterpret_cast<GLProc>(&glGetActiveUniform);
sProcAddressMap["glGetAttachedShaders"] = reinterpret_cast<GLProc>(&glGetAttachedShaders);
sProcAddressMap["glGetAttribLocation"] = reinterpret_cast<GLProc>(&glGetAttribLocation);
sProcAddressMap["glGetBooleanv"] = reinterpret_cast<GLProc>(&glGetBooleanv);
sProcAddressMap["glGetBufferParameteriv"] = reinterpret_cast<GLProc>(&glGetBufferParameteriv);
sProcAddressMap["glGetError"] = reinterpret_cast<GLProc>(&glGetError);
sProcAddressMap["glGetFloatv"] = reinterpret_cast<GLProc>(&glGetFloatv);
sProcAddressMap["glGetFramebufferAttachmentParameteriv"] = reinterpret_cast<GLProc>(&glGetFramebufferAttachmentParameteriv);
sProcAddressMap["glGetIntegerv"] = reinterpret_cast<GLProc>(&glGetIntegerv);
sProcAddressMap["glGetProgramiv"] = reinterpret_cast<GLProc>(&glGetProgramiv);
sProcAddressMap["glGetProgramInfoLog"] = reinterpret_cast<GLProc>(&glGetProgramInfoLog);
sProcAddressMap["glGetRenderbufferParameteriv"] = reinterpret_cast<GLProc>(&glGetRenderbufferParameteriv);
sProcAddressMap["glGetShaderiv"] = reinterpret_cast<GLProc>(&glGetShaderiv);
sProcAddressMap["glGetShaderInfoLog"] = reinterpret_cast<GLProc>(&glGetShaderInfoLog);
sProcAddressMap["glGetShaderPrecisionFormat"] = reinterpret_cast<GLProc>(&glGetShaderPrecisionFormat);
sProcAddressMap["glGetShaderSource"] = reinterpret_cast<GLProc>(&glGetShaderSource);
sProcAddressMap["glGetString"] = reinterpret_cast<GLProc>(&glGetString);
sProcAddressMap["glGetTexParameterfv"] = reinterpret_cast<GLProc>(&glGetTexParameterfv);
sProcAddressMap["glGetTexParameteriv"] = reinterpret_cast<GLProc>(&glGetTexParameteriv);
sProcAddressMap["glGetUniformfv"] = reinterpret_cast<GLProc>(&glGetUniformfv);
sProcAddressMap["glGetUniformiv"] = reinterpret_cast<GLProc>(&glGetUniformiv);
sProcAddressMap["glGetUniformLocation"] = reinterpret_cast<GLProc>(&glGetUniformLocation);
sProcAddressMap["glGetVertexAttribfv"] = reinterpret_cast<GLProc>(&glGetVertexAttribfv);
sProcAddressMap["glGetVertexAttribiv"] = reinterpret_cast<GLProc>(&glGetVertexAttribiv);
sProcAddressMap["glGetVertexAttribPointerv"] = reinterpret_cast<GLProc>(&glGetVertexAttribPointerv);
sProcAddressMap["glHint"] = reinterpret_cast<GLProc>(&glHint);
sProcAddressMap["glIsBuffer"] = reinterpret_cast<GLProc>(&glIsBuffer);
sProcAddressMap["glIsEnabled"] = reinterpret_cast<GLProc>(&glIsEnabled);
sProcAddressMap["glIsFramebuffer"] = reinterpret_cast<GLProc>(&glIsFramebuffer);
sProcAddressMap["glIsProgram"] = reinterpret_cast<GLProc>(&glIsProgram);
sProcAddressMap["glIsRenderbuffer"] = reinterpret_cast<GLProc>(&glIsRenderbuffer);
sProcAddressMap["glIsShader"] = reinterpret_cast<GLProc>(&glIsShader);
sProcAddressMap["glIsTexture"] = reinterpret_cast<GLProc>(&glIsTexture);
sProcAddressMap["glLineWidth"] = reinterpret_cast<GLProc>(&glLineWidth);
sProcAddressMap["glLinkProgram"] = reinterpret_cast<GLProc>(&glLinkProgram);
sProcAddressMap["glPixelStorei"] = reinterpret_cast<GLProc>(&glPixelStorei);
sProcAddressMap["glPolygonOffset"] = reinterpret_cast<GLProc>(&glPolygonOffset);
sProcAddressMap["glReadPixels"] = reinterpret_cast<GLProc>(&glReadPixels);
sProcAddressMap["glReleaseShaderCompiler"] = reinterpret_cast<GLProc>(&glReleaseShaderCompiler);
sProcAddressMap["glRenderbufferStorage"] = reinterpret_cast<GLProc>(&glRenderbufferStorage);
sProcAddressMap["glSampleCoverage"] = reinterpret_cast<GLProc>(&glSampleCoverage);
sProcAddressMap["glScissor"] = reinterpret_cast<GLProc>(&glScissor);
sProcAddressMap["glShaderBinary"] = reinterpret_cast<GLProc>(&glShaderBinary);
sProcAddressMap["glShaderSource"] = reinterpret_cast<GLProc>(&glShaderSource);
sProcAddressMap["glStencilFunc"] = reinterpret_cast<GLProc>(&glStencilFunc);
sProcAddressMap["glStencilFuncSeparate"] = reinterpret_cast<GLProc>(&glStencilFuncSeparate);
sProcAddressMap["glStencilMask"] = reinterpret_cast<GLProc>(&glStencilMask);
sProcAddressMap["glStencilMaskSeparate"] = reinterpret_cast<GLProc>(&glStencilMaskSeparate);
sProcAddressMap["glStencilOp"] = reinterpret_cast<GLProc>(&glStencilOp);
sProcAddressMap["glStencilOpSeparate"] = reinterpret_cast<GLProc>(&glStencilOpSeparate);
sProcAddressMap["glTexImage2D"] = reinterpret_cast<GLProc>(&glTexImage2D);
sProcAddressMap["glTexParameterf"] = reinterpret_cast<GLProc>(&glTexParameterf);
sProcAddressMap["glTexParameterfv"] = reinterpret_cast<GLProc>(&glTexParameterfv);
sProcAddressMap["glTexParameteri"] = reinterpret_cast<GLProc>(&glTexParameteri);
sProcAddressMap["glTexParameteriv"] = reinterpret_cast<GLProc>(&glTexParameteriv);
sProcAddressMap["glTexSubImage2D"] = reinterpret_cast<GLProc>(&glTexSubImage2D);
sProcAddressMap["glUniform1f"] = reinterpret_cast<GLProc>(&glUniform1f);
sProcAddressMap["glUniform1fv"] = reinterpret_cast<GLProc>(&glUniform1fv);
sProcAddressMap["glUniform1i"] = reinterpret_cast<GLProc>(&glUniform1i);
sProcAddressMap["glUniform1iv"] = reinterpret_cast<GLProc>(&glUniform1iv);
sProcAddressMap["glUniform2f"] = reinterpret_cast<GLProc>(&glUniform2f);
sProcAddressMap["glUniform2fv"] = reinterpret_cast<GLProc>(&glUniform2fv);
sProcAddressMap["glUniform2i"] = reinterpret_cast<GLProc>(&glUniform2i);
sProcAddressMap["glUniform2iv"] = reinterpret_cast<GLProc>(&glUniform2iv);
sProcAddressMap["glUniform3f"] = reinterpret_cast<GLProc>(&glUniform3f);
sProcAddressMap["glUniform3fv"] = reinterpret_cast<GLProc>(&glUniform3fv);
sProcAddressMap["glUniform3i"] = reinterpret_cast<GLProc>(&glUniform3i);
sProcAddressMap["glUniform3iv"] = reinterpret_cast<GLProc>(&glUniform3iv);
sProcAddressMap["glUniform4f"] = reinterpret_cast<GLProc>(&glUniform4f);
sProcAddressMap["glUniform4fv"] = reinterpret_cast<GLProc>(&glUniform4fv);
sProcAddressMap["glUniform4i"] = reinterpret_cast<GLProc>(&glUniform4i);
sProcAddressMap["glUniform4iv"] = reinterpret_cast<GLProc>(&glUniform4iv);
sProcAddressMap["glUniformMatrix2fv"] = reinterpret_cast<GLProc>(&glUniformMatrix2fv);
sProcAddressMap["glUniformMatrix3fv"] = reinterpret_cast<GLProc>(&glUniformMatrix3fv);
sProcAddressMap["glUniformMatrix4fv"] = reinterpret_cast<GLProc>(&glUniformMatrix4fv);
sProcAddressMap["glUseProgram"] = reinterpret_cast<GLProc>(&glUseProgram);
sProcAddressMap["glValidateProgram"] = reinterpret_cast<GLProc>(&glValidateProgram);
sProcAddressMap["glVertexAttrib1f"] = reinterpret_cast<GLProc>(&glVertexAttrib1f);
sProcAddressMap["glVertexAttrib1fv"] = reinterpret_cast<GLProc>(&glVertexAttrib1fv);
sProcAddressMap["glVertexAttrib2f"] = reinterpret_cast<GLProc>(&glVertexAttrib2f);
sProcAddressMap["glVertexAttrib2fv"] = reinterpret_cast<GLProc>(&glVertexAttrib2fv);
sProcAddressMap["glVertexAttrib3f"] = reinterpret_cast<GLProc>(&glVertexAttrib3f);
sProcAddressMap["glVertexAttrib3fv"] = reinterpret_cast<GLProc>(&glVertexAttrib3fv);
sProcAddressMap["glVertexAttrib4f"] = reinterpret_cast<GLProc>(&glVertexAttrib4f);
sProcAddressMap["glVertexAttrib4fv"] = reinterpret_cast<GLProc>(&glVertexAttrib4fv);
sProcAddressMap["glVertexAttribPointer"] = reinterpret_cast<GLProc>(&glVertexAttribPointer);
sProcAddressMap["glViewport"] = reinterpret_cast<GLProc>(&glViewport);
ADD_FUNCTION(glActiveTexture)
ADD_FUNCTION(glAttachShader)
ADD_FUNCTION(glBindAttribLocation)
ADD_FUNCTION(glBindBuffer)
ADD_FUNCTION(glBindFramebuffer)
ADD_FUNCTION(glBindRenderbuffer)
ADD_FUNCTION(glBindTexture)
ADD_FUNCTION(glBlendColor)
ADD_FUNCTION(glBlendEquation)
ADD_FUNCTION(glBlendEquationSeparate)
ADD_FUNCTION(glBlendFunc)
ADD_FUNCTION(glBlendFuncSeparate)
ADD_FUNCTION(glBufferData)
ADD_FUNCTION(glBufferSubData)
ADD_FUNCTION(glCheckFramebufferStatus)
ADD_FUNCTION(glClear)
ADD_FUNCTION(glClearColor)
ADD_FUNCTION(glClearDepthf)
ADD_FUNCTION(glClearStencil)
ADD_FUNCTION(glColorMask)
ADD_FUNCTION(glCompileShader)
ADD_FUNCTION(glCompressedTexImage2D)
ADD_FUNCTION(glCompressedTexSubImage2D)
ADD_FUNCTION(glCopyTexImage2D)
ADD_FUNCTION(glCopyTexSubImage2D)
ADD_FUNCTION(glCreateProgram)
ADD_FUNCTION(glCreateShader)
ADD_FUNCTION(glCullFace)
ADD_FUNCTION(glDeleteBuffers)
ADD_FUNCTION(glDeleteFramebuffers)
ADD_FUNCTION(glDeleteProgram)
ADD_FUNCTION(glDeleteRenderbuffers)
ADD_FUNCTION(glDeleteShader)
ADD_FUNCTION(glDeleteTextures)
ADD_FUNCTION(glDepthFunc)
ADD_FUNCTION(glDepthMask)
ADD_FUNCTION(glDepthRangef)
ADD_FUNCTION(glDetachShader)
ADD_FUNCTION(glDisable)
ADD_FUNCTION(glDisableVertexAttribArray)
ADD_FUNCTION(glDrawArrays)
ADD_FUNCTION(glDrawElements)
ADD_FUNCTION(glEnable)
ADD_FUNCTION(glEnableVertexAttribArray)
ADD_FUNCTION(glFinish)
ADD_FUNCTION(glFlush)
ADD_FUNCTION(glFramebufferRenderbuffer)
ADD_FUNCTION(glFramebufferTexture2D)
ADD_FUNCTION(glFrontFace)
ADD_FUNCTION(glGenBuffers)
ADD_FUNCTION(glGenerateMipmap)
ADD_FUNCTION(glGenFramebuffers)
ADD_FUNCTION(glGenRenderbuffers)
ADD_FUNCTION(glGenTextures)
ADD_FUNCTION(glGetActiveAttrib)
ADD_FUNCTION(glGetActiveUniform)
ADD_FUNCTION(glGetAttachedShaders)
ADD_FUNCTION(glGetAttribLocation)
ADD_FUNCTION(glGetBooleanv)
ADD_FUNCTION(glGetBufferParameteriv)
ADD_FUNCTION(glGetError)
ADD_FUNCTION(glGetFloatv)
ADD_FUNCTION(glGetFramebufferAttachmentParameteriv)
ADD_FUNCTION(glGetIntegerv)
ADD_FUNCTION(glGetProgramiv)
ADD_FUNCTION(glGetProgramInfoLog)
ADD_FUNCTION(glGetRenderbufferParameteriv)
ADD_FUNCTION(glGetShaderiv)
ADD_FUNCTION(glGetShaderInfoLog)
ADD_FUNCTION(glGetShaderPrecisionFormat)
ADD_FUNCTION(glGetShaderSource)
ADD_FUNCTION(glGetString)
ADD_FUNCTION(glGetTexParameterfv)
ADD_FUNCTION(glGetTexParameteriv)
ADD_FUNCTION(glGetUniformfv)
ADD_FUNCTION(glGetUniformiv)
ADD_FUNCTION(glGetUniformLocation)
ADD_FUNCTION(glGetVertexAttribfv)
ADD_FUNCTION(glGetVertexAttribiv)
ADD_FUNCTION(glGetVertexAttribPointerv)
ADD_FUNCTION(glHint)
ADD_FUNCTION(glIsBuffer)
ADD_FUNCTION(glIsEnabled)
ADD_FUNCTION(glIsFramebuffer)
ADD_FUNCTION(glIsProgram)
ADD_FUNCTION(glIsRenderbuffer)
ADD_FUNCTION(glIsShader)
ADD_FUNCTION(glIsTexture)
ADD_FUNCTION(glLineWidth)
ADD_FUNCTION(glLinkProgram)
ADD_FUNCTION(glPixelStorei)
ADD_FUNCTION(glPolygonOffset)
ADD_FUNCTION(glReadPixels)
ADD_FUNCTION(glReleaseShaderCompiler)
ADD_FUNCTION(glRenderbufferStorage)
ADD_FUNCTION(glSampleCoverage)
ADD_FUNCTION(glScissor)
ADD_FUNCTION(glShaderBinary)
ADD_FUNCTION(glShaderSource)
ADD_FUNCTION(glStencilFunc)
ADD_FUNCTION(glStencilFuncSeparate)
ADD_FUNCTION(glStencilMask)
ADD_FUNCTION(glStencilMaskSeparate)
ADD_FUNCTION(glStencilOp)
ADD_FUNCTION(glStencilOpSeparate)
ADD_FUNCTION(glTexImage2D)
ADD_FUNCTION(glTexParameterf)
ADD_FUNCTION(glTexParameterfv)
ADD_FUNCTION(glTexParameteri)
ADD_FUNCTION(glTexParameteriv)
ADD_FUNCTION(glTexSubImage2D)
ADD_FUNCTION(glUniform1f)
ADD_FUNCTION(glUniform1fv)
ADD_FUNCTION(glUniform1i)
ADD_FUNCTION(glUniform1iv)
ADD_FUNCTION(glUniform2f)
ADD_FUNCTION(glUniform2fv)
ADD_FUNCTION(glUniform2i)
ADD_FUNCTION(glUniform2iv)
ADD_FUNCTION(glUniform3f)
ADD_FUNCTION(glUniform3fv)
ADD_FUNCTION(glUniform3i)
ADD_FUNCTION(glUniform3iv)
ADD_FUNCTION(glUniform4f)
ADD_FUNCTION(glUniform4fv)
ADD_FUNCTION(glUniform4i)
ADD_FUNCTION(glUniform4iv)
ADD_FUNCTION(glUniformMatrix2fv)
ADD_FUNCTION(glUniformMatrix3fv)
ADD_FUNCTION(glUniformMatrix4fv)
ADD_FUNCTION(glUseProgram)
ADD_FUNCTION(glValidateProgram)
ADD_FUNCTION(glVertexAttrib1f)
ADD_FUNCTION(glVertexAttrib1fv)
ADD_FUNCTION(glVertexAttrib2f)
ADD_FUNCTION(glVertexAttrib2fv)
ADD_FUNCTION(glVertexAttrib3f)
ADD_FUNCTION(glVertexAttrib3fv)
ADD_FUNCTION(glVertexAttrib4f)
ADD_FUNCTION(glVertexAttrib4fv)
ADD_FUNCTION(glVertexAttribPointer)
ADD_FUNCTION(glViewport)
}
void initProcAddress()