// GML - OpenGL Multithreading Library
// for Spring http://springrts.com
// Author: Mattias "zerver" Radeskog
// (C) Ware Zerver Tech. http://zerver.net
// Ware Zerver Tech. licenses this library
// to be used, distributed and modified 
// freely for any purpose, as long as 
// this notice remains unchanged

#undef glDisable
#undef glEnable
#undef glBindTexture
#undef glTexParameteri
#undef glActiveTextureARB
#undef glColor4f
#undef glVertex3f
#undef glTexEnvi
#undef glTexCoord2f
#undef glProgramEnvParameter4fARB
#undef glEnd
#undef glBegin
#undef glMatrixMode
#undef glVertex2f
#undef glPopMatrix
#undef glPushMatrix
#undef glLoadIdentity
#undef glTranslatef
#undef glBlendFunc
#undef glCallList
#undef glColor3f
#undef glTexImage2D
#undef glColor4fv
#undef glBindProgramARB
#undef glScalef
#undef glViewport
#undef glDeleteTextures
#undef glMultiTexCoord2fARB
#undef glAlphaFunc
#undef glDepthMask
#undef glLineWidth
#undef glBindFramebufferEXT
#undef glRotatef
#undef glDeleteLists
#undef glDisableClientState
#undef glEnableClientState
#undef glRectf
#undef glLightfv
#undef gluBuild2DMipmaps
#undef glClear
#undef glEndList
#undef glNewList
#undef glClearColor
#undef glPolygonMode
#undef glActiveTexture
#undef glFogf
#undef glMultMatrixf
#undef glOrtho
#undef glPopAttrib
#undef glMaterialfv
#undef glPolygonOffset
#undef glPushAttrib
#undef glCullFace
#undef glColorMask
#undef glVertex3fv
#undef glTexGenfv
#undef glVertex2d
#undef glVertexPointer
#undef glDrawArrays
#undef glFogfv
#undef glFramebufferTexture2DEXT
#undef glTexCoordPointer
#undef glTexSubImage2D
#undef glClipPlane
#undef glColor4d
#undef glLightModeli
#undef glTexGeni
#undef glTexParameterf
#undef glCopyTexSubImage2D
#undef glDeleteFramebuffersEXT
#undef glLoadMatrixf
#undef glShadeModel
#undef glUseProgram
#undef glClientActiveTextureARB
#undef glDeleteRenderbuffersEXT
#undef glFlush
#undef glNormal3f
#undef glUseProgramObjectARB
#undef glCompressedTexImage2DARB
#undef glDeleteObjectARB
#undef glFogi
#undef glMultMatrixd
#undef glPixelStorei
#undef glPointParameterf
#undef glTexCoord3f
#undef glUniform1i
#undef glBindRenderbufferEXT
#undef glColor3fv
#undef glDepthFunc
#undef glHint
#undef glLogicOp
#undef glStencilOp
#undef glTexEnvfv
#undef glUniformMatrix4fv
#undef gluOrtho2D
#undef glAttachObjectARB
#undef glBindBufferARB
#undef glColor3ubv
#undef glDetachObjectARB
#undef glFramebufferRenderbufferEXT
#undef glLineStipple
#undef glLoadMatrixd
#undef glSetFenceNV
#undef glStencilFunc
#undef glTexImage3D
#undef glUniform1f
#undef glClearStencil
#undef glColorPointer
#undef glDeleteShader
#undef glDrawElements
#undef glGenerateMipmapEXT
#undef glMaterialf
#undef glNormalPointer
#undef glProgramEnvParameter4fvARB
#undef glRenderbufferStorageEXT
#undef glStencilMask
#undef glUniform3f
#undef gluPerspective
#undef glActiveStencilFaceEXT
#undef glAttachShader
#undef glBlitFramebufferEXT
#undef glBufferDataARB
#undef glClearDepth
#undef glColor3ub
#undef glCompressedTexImage1DARB
#undef glCompressedTexImage3DARB
#undef glDrawBuffer
#undef glFrontFace
#undef glFrustum
#undef glLinkProgramARB
#undef glMultiTexCoord1f
#undef glMultiTexCoord2f
#undef glMultiTexCoord3f
#undef glMultiTexCoord4f
#undef glPointParameterfv
#undef glPointSize
#undef glProgramStringARB
#undef glSecondaryColor3f
#undef glTexCoord1f
#undef glTexCoord4f
#undef glTexEnvf
#undef glTexGenf
#undef glTexImage1D
#undef glUniform1iARB
#undef glUniform2f
#undef glUniform2fARB
#undef glUniform2i
#undef glUniform3fARB
#undef glUniform3i
#undef glUniform4f
#undef glUniform4i
#undef glUniformMatrix2fv
#undef glUniformMatrix3fv
#undef glVertex4f
#undef gluDeleteQuadric
#undef gluQuadricDrawStyle
#undef gluSphere
#undef glClearAccum
#undef glColor4ub
#undef glColor4ubv
#undef glCompileShader
#undef glCompileShaderARB
#undef glCopyTexImage2D
#undef glDeleteBuffersARB
#undef glDeleteFencesNV
#undef glDeleteProgram
#undef glDeleteProgramsARB
#undef glDetachShader
#undef glDisableVertexAttribArrayARB
#undef glDrawBuffersARB
#undef glEdgeFlag
#undef glEnableVertexAttribArrayARB
#undef glFinish
#undef glFinishFenceNV
#undef glFogCoordf
#undef glLightf
#undef glLinkProgram
#undef glNormal3fv
#undef glRasterPos2i
#undef glReadBuffer
#undef glScissor
#undef glShaderSource
#undef glShaderSourceARB
#undef glTexCoord2fv
#undef glTexParameterfv
#undef glTranslated
#undef glUniform1fv
#undef glUniform4fARB
#undef glUniformMatrix4fvARB
#undef glVertexAttribPointerARB
#undef gluLookAt
#undef glLightModelfv
#undef glDeleteQueries
#undef glBlendEquation
#undef glStencilMaskSeparate
#undef glStencilFuncSeparate
#undef glStencilOpSeparate
#undef glBeginQuery
#undef glEndQuery
#undef glGetQueryObjectuiv
#undef glBlendEquationSeparate
#undef glBlendFuncSeparate
#undef gluCylinder
#undef glGenBuffers
#undef glDeleteBuffers
#undef glBindBuffer
#undef glBufferData
#undef glMapBuffer
#undef glUnmapBuffer
#undef glCompressedTexImage2D
#undef glIsShader
#undef glVertex3i
#undef glGetIntegerv
#undef glCheckFramebufferStatusEXT
#undef glGetFloatv
#undef glGetString
#undef glGetUniformLocationARB
#undef glReadPixels
#undef glGetError
#undef glGetObjectParameterivARB
#undef glGetUniformLocation
#undef glGetDoublev
#undef glGetProgramiv
#undef glGetActiveUniform
#undef glGetAttribLocationARB
#undef glGetInfoLogARB
#undef glGetProgramInfoLog
#undef glGetProgramivARB
#undef glGetShaderInfoLog
#undef glGetShaderiv
#undef glIsRenderbufferEXT
#undef glMapBufferARB
#undef gluProject
#undef gluScaleImage
#undef glIndexPointer
#undef glEdgeFlagPointer
#undef glTrackMatrixNV
#undef glTestFenceNV
#undef glCreateProgram
#undef glCreateProgramObjectARB
#undef glCreateShader
#undef glCreateShaderObjectARB
#undef gluNewQuadric
#undef glGenTextures
#undef glGenBuffersARB
#undef glGenFencesNV
#undef glGenProgramsARB
#undef glGenRenderbuffersEXT
#undef glGenFramebuffersEXT
#undef glGenQueries
#undef glGenLists
#undef glProgramParameteriEXT
#undef glBlendColor
#undef glMap1f
#undef glMap2f
#undef glMapGrid1f
#undef glMapGrid2f
#undef glEvalMesh1
#undef glEvalMesh2
#undef glEvalCoord1f
#undef glEvalCoord2f
#undef glEvalPoint1
#undef glEvalPoint2
#undef glRenderMode
#undef glSelectBuffer
#undef glInitNames
#undef glLoadName
#undef glPushName
#undef glPopName
#undef glGetTexLevelParameteriv
#undef glGetFramebufferAttachmentParameterivEXT
#undef glGetRenderbufferParameterivEXT
#undef glGetTexImage
#undef glIsTexture
#undef glFramebufferTexture1DEXT
#undef glFramebufferTexture3DEXT
#undef glClientActiveTexture
#undef glMultiTexCoord2i
#undef glGetQueryiv
#undef glGetBooleanv
#undef glValidateProgram
#undef glUniform2iv
#undef glUniform3iv
#undef glUniform4iv
#undef glUniform2fv
#undef glUniform3fv
#undef glUniform4fv
#undef glMapBufferRange
#undef glPrimitiveRestartIndexNV
#undef glDrawRangeElements

// #####################################################################

#define GML_NULL_CHECK(name) (GLEW_GET_FUN(__glew##name) ? &gml##name : GLEW_GET_FUN(__glew##name))

#define glDisable gmlDisable
#define glEnable gmlEnable
#define glBindTexture gmlBindTexture
#define glTexParameteri gmlTexParameteri
#define glActiveTextureARB gmlActiveTextureARB
#define glColor4f gmlColor4f
#define glVertex3f gmlVertex3f
#define glTexEnvi gmlTexEnvi
#define glTexCoord2f gmlTexCoord2f
#define glProgramEnvParameter4fARB gmlProgramEnvParameter4fARB
#define glEnd gmlEnd
#define glBegin gmlBegin
#define glMatrixMode gmlMatrixMode
#define glVertex2f gmlVertex2f
#define glPopMatrix gmlPopMatrix
#define glPushMatrix gmlPushMatrix
#define glLoadIdentity gmlLoadIdentity
#define glTranslatef gmlTranslatef
#define glBlendFunc gmlBlendFunc
#define glCallList gmlCallList
#define glColor3f gmlColor3f
#define glTexImage2D gmlTexImage2D
#define glColor4fv gmlColor4fv
#define glBindProgramARB GML_NULL_CHECK(BindProgramARB)
#define glScalef gmlScalef
#define glViewport gmlViewport
#define glDeleteTextures gmlDeleteTextures
#define glMultiTexCoord2fARB gmlMultiTexCoord2fARB
#define glAlphaFunc gmlAlphaFunc
#define glDepthMask gmlDepthMask
#define glLineWidth gmlLineWidth
#define glBindFramebufferEXT gmlBindFramebufferEXT
#define glRotatef gmlRotatef
#define glDeleteLists gmlDeleteLists
#define glDisableClientState gmlDisableClientState
#define glEnableClientState gmlEnableClientState
#define glRectf gmlRectf
#define glLightfv gmlLightfv
#define gluBuild2DMipmaps gmluBuild2DMipmaps
#define glClear gmlClear
#define glEndList gmlEndList
#define glNewList gmlNewList
#define glClearColor gmlClearColor
#define glPolygonMode gmlPolygonMode
#define glActiveTexture gmlActiveTexture
#define glFogf gmlFogf
#define glMultMatrixf gmlMultMatrixf
#define glOrtho gmlOrtho
#define glPopAttrib gmlPopAttrib
#define glMaterialfv gmlMaterialfv
#define glPolygonOffset gmlPolygonOffset
#define glPushAttrib gmlPushAttrib
#define glCullFace gmlCullFace
#define glColorMask gmlColorMask
#define glVertex3fv gmlVertex3fv
#define glTexGenfv gmlTexGenfv
#define glVertex2d gmlVertex2d
#define glVertexPointer gmlVertexPointer
#define glDrawArrays gmlDrawArrays
#define glFogfv gmlFogfv
#define glFramebufferTexture2DEXT gmlFramebufferTexture2DEXT
#define glTexCoordPointer gmlTexCoordPointer
#define glTexSubImage2D gmlTexSubImage2D
#define glClipPlane gmlClipPlane
#define glColor4d gmlColor4d
#define glLightModeli gmlLightModeli
#define glTexGeni gmlTexGeni
#define glTexParameterf gmlTexParameterf
#define glCopyTexSubImage2D gmlCopyTexSubImage2D
#define glDeleteFramebuffersEXT gmlDeleteFramebuffersEXT
#define glLoadMatrixf gmlLoadMatrixf
#define glShadeModel gmlShadeModel
#define glUseProgram GML_NULL_CHECK(UseProgram)
#define glClientActiveTextureARB gmlClientActiveTextureARB
#define glDeleteRenderbuffersEXT gmlDeleteRenderbuffersEXT
#define glFlush gmlFlush
#define glNormal3f gmlNormal3f
#define glUseProgramObjectARB gmlUseProgramObjectARB
#define glCompressedTexImage2DARB gmlCompressedTexImage2DARB
#define glDeleteObjectARB gmlDeleteObjectARB
#define glFogi gmlFogi
#define glMultMatrixd gmlMultMatrixd
#define glPixelStorei gmlPixelStorei
#define glPointParameterf gmlPointParameterf
#define glTexCoord3f gmlTexCoord3f
#define glUniform1i gmlUniform1i
#define glBindRenderbufferEXT gmlBindRenderbufferEXT
#define glColor3fv gmlColor3fv
#define glDepthFunc gmlDepthFunc
#define glHint gmlHint
#define glLogicOp gmlLogicOp
#define glStencilOp gmlStencilOp
#define glTexEnvfv gmlTexEnvfv
#define glUniformMatrix4fv gmlUniformMatrix4fv
#define gluOrtho2D gmluOrtho2D
#define glAttachObjectARB gmlAttachObjectARB
#define glBindBufferARB gmlBindBufferARB
#define glColor3ubv gmlColor3ubv
#define glDetachObjectARB gmlDetachObjectARB
#define glFramebufferRenderbufferEXT gmlFramebufferRenderbufferEXT
#define glLineStipple gmlLineStipple
#define glLoadMatrixd gmlLoadMatrixd
#define glSetFenceNV gmlSetFenceNV
#define glStencilFunc gmlStencilFunc
#define glTexImage3D gmlTexImage3D
#define glUniform1f gmlUniform1f
#define glClearStencil gmlClearStencil
#define glColorPointer gmlColorPointer
#define glDeleteShader GML_NULL_CHECK(DeleteShader)
#define glDrawElements gmlDrawElements
#define glGenerateMipmapEXT GML_NULL_CHECK(GenerateMipmapEXT)
#define glMaterialf gmlMaterialf
#define glNormalPointer gmlNormalPointer
#define glProgramEnvParameter4fvARB gmlProgramEnvParameter4fvARB
#define glRenderbufferStorageEXT gmlRenderbufferStorageEXT
#define glStencilMask gmlStencilMask
#define glUniform3f gmlUniform3f
#define gluPerspective gmluPerspective
#define glActiveStencilFaceEXT gmlActiveStencilFaceEXT
#define glAttachShader gmlAttachShader
#define glBlitFramebufferEXT gmlBlitFramebufferEXT
#define glBufferDataARB gmlBufferDataARB
#define glClearDepth gmlClearDepth
#define glColor3ub gmlColor3ub
#define glCompressedTexImage1DARB gmlCompressedTexImage1DARB
#define glCompressedTexImage3DARB gmlCompressedTexImage3DARB
#define glDrawBuffer gmlDrawBuffer
#define glFrontFace gmlFrontFace
#define glFrustum gmlFrustum
#define glLinkProgramARB gmlLinkProgramARB
#define glMultiTexCoord1f gmlMultiTexCoord1f
#define glMultiTexCoord2f gmlMultiTexCoord2f
#define glMultiTexCoord3f gmlMultiTexCoord3f
#define glMultiTexCoord4f gmlMultiTexCoord4f
#define glPointParameterfv gmlPointParameterfv
#define glPointSize gmlPointSize
#define glProgramStringARB gmlProgramStringARB
#define glSecondaryColor3f gmlSecondaryColor3f
#define glTexCoord1f gmlTexCoord1f
#define glTexCoord4f gmlTexCoord4f
#define glTexEnvf gmlTexEnvf
#define glTexGenf gmlTexGenf
#define glTexImage1D gmlTexImage1D
#define glUniform1iARB gmlUniform1iARB
#define glUniform2f gmlUniform2f
#define glUniform2fARB gmlUniform2fARB
#define glUniform2i gmlUniform2i
#define glUniform3fARB gmlUniform3fARB
#define glUniform3i gmlUniform3i
#define glUniform4f gmlUniform4f
#define glUniform4i gmlUniform4i
#define glUniformMatrix2fv gmlUniformMatrix2fv
#define glUniformMatrix3fv gmlUniformMatrix3fv
#define glVertex4f gmlVertex4f
#define gluDeleteQuadric gmluDeleteQuadric
#define gluQuadricDrawStyle gmluQuadricDrawStyle
#define gluSphere gmluSphere
#define glClearAccum gmlClearAccum
#define glColor4ub gmlColor4ub
#define glColor4ubv gmlColor4ubv
#define glCompileShader gmlCompileShader
#define glCompileShaderARB gmlCompileShaderARB
#define glCopyTexImage2D gmlCopyTexImage2D
#define glDeleteBuffersARB gmlDeleteBuffersARB
#define glDeleteFencesNV gmlDeleteFencesNV
#define glDeleteProgram GML_NULL_CHECK(DeleteProgram)
#define glDeleteProgramsARB GML_NULL_CHECK(DeleteProgramsARB)
#define glDetachShader gmlDetachShader
#define glDisableVertexAttribArrayARB gmlDisableVertexAttribArrayARB
#define glDrawBuffersARB gmlDrawBuffersARB
#define glEdgeFlag gmlEdgeFlag
#define glEnableVertexAttribArrayARB gmlEnableVertexAttribArrayARB
#define glFinish gmlFinish
#define glFinishFenceNV gmlFinishFenceNV
#define glFogCoordf gmlFogCoordf
#define glLightf gmlLightf
#define glLinkProgram GML_NULL_CHECK(LinkProgram)
#define glNormal3fv gmlNormal3fv
#define glRasterPos2i gmlRasterPos2i
#define glReadBuffer gmlReadBuffer
#define glScissor gmlScissor
#define glShaderSource GML_NULL_CHECK(ShaderSource)
#define glShaderSourceARB gmlShaderSourceARB
#define glTexCoord2fv gmlTexCoord2fv
#define glTexParameterfv gmlTexParameterfv
#define glTranslated gmlTranslated
#define glUniform1fv gmlUniform1fv
#define glUniform4fARB gmlUniform4fARB
#define glUniformMatrix4fvARB gmlUniformMatrix4fvARB
#define glVertexAttribPointerARB gmlVertexAttribPointerARB
#define gluLookAt gmluLookAt
#define glLightModelfv gmlLightModelfv
#define glDeleteQueries gmlDeleteQueries
#define glBlendEquation GML_NULL_CHECK(BlendEquation)
#define glStencilMaskSeparate gmlStencilMaskSeparate
#define glStencilFuncSeparate gmlStencilFuncSeparate
#define glStencilOpSeparate gmlStencilOpSeparate
#define glBeginQuery gmlBeginQuery
#define glEndQuery gmlEndQuery
#define glGetQueryObjectuiv gmlGetQueryObjectuiv
#define glBlendEquationSeparate gmlBlendEquationSeparate
#define glBlendFuncSeparate gmlBlendFuncSeparate
#define gluCylinder gmluCylinder
#define glGenBuffers gmlGenBuffers
#define glDeleteBuffers gmlDeleteBuffers
#define glBindBuffer gmlBindBuffer
#define glBufferData gmlBufferData
#define glMapBuffer gmlMapBuffer
#define glUnmapBuffer gmlUnmapBuffer
#define glCompressedTexImage2D gmlCompressedTexImage2D
#define glIsShader gmlIsShader
#define glVertex3i gmlVertex3i
#define glGetIntegerv gmlGetIntegerv
#define glCheckFramebufferStatusEXT gmlCheckFramebufferStatusEXT
#define glGetFloatv gmlGetFloatv
#define glGetString gmlGetString
#define glGetUniformLocationARB gmlGetUniformLocationARB
#define glReadPixels gmlReadPixels
#define glGetError gmlGetError
#define glGetObjectParameterivARB gmlGetObjectParameterivARB
#define glGetUniformLocation gmlGetUniformLocation
#define glGetDoublev gmlGetDoublev
#define glGetProgramiv gmlGetProgramiv
#define glGetActiveUniform gmlGetActiveUniform
#define glGetAttribLocationARB gmlGetAttribLocationARB
#define glGetInfoLogARB gmlGetInfoLogARB
#define glGetProgramInfoLog gmlGetProgramInfoLog
#define glGetProgramivARB gmlGetProgramivARB
#define glGetShaderInfoLog gmlGetShaderInfoLog
#define glGetShaderiv gmlGetShaderiv
#define glIsRenderbufferEXT gmlIsRenderbufferEXT
#define glMapBufferARB gmlMapBufferARB
#define gluProject gmluProject
#define gluScaleImage gmluScaleImage
#define glIndexPointer gmlIndexPointer
#define glEdgeFlagPointer gmlEdgeFlagPointer
#define glTrackMatrixNV gmlTrackMatrixNV
#define glTestFenceNV gmlTestFenceNV
#define glCreateProgram GML_NULL_CHECK(CreateProgram)
#define glCreateProgramObjectARB gmlCreateProgramObjectARB
#define glCreateShader GML_NULL_CHECK(CreateShader)
#define glCreateShaderObjectARB gmlCreateShaderObjectARB
#define gluNewQuadric gmluNewQuadric
#define glGenTextures gmlGenTextures
#define glGenBuffersARB gmlGenBuffersARB
#define glGenFencesNV gmlGenFencesNV
#define glGenProgramsARB GML_NULL_CHECK(GenProgramsARB)
#define glGenRenderbuffersEXT gmlGenRenderbuffersEXT
#define glGenFramebuffersEXT gmlGenFramebuffersEXT
#define glGenQueries gmlGenQueries
#define glGenLists gmlGenLists
#define glProgramParameteriEXT GML_NULL_CHECK(ProgramParameteriEXT)
#define glBlendColor gmlBlendColor
#define glMap1f gmlMap1f
#define glMap2f gmlMap2f
#define glMapGrid1f gmlMapGrid1f
#define glMapGrid2f gmlMapGrid2f
#define glEvalMesh1 gmlEvalMesh1
#define glEvalMesh2 gmlEvalMesh2
#define glEvalCoord1f gmlEvalCoord1f
#define glEvalCoord2f gmlEvalCoord2f
#define glEvalPoint1 gmlEvalPoint1
#define glEvalPoint2 gmlEvalPoint2
#define glRenderMode gmlRenderMode
#define glSelectBuffer gmlSelectBuffer
#define glInitNames gmlInitNames
#define glLoadName gmlLoadName
#define glPushName gmlPushName
#define glPopName gmlPopName
#define glGetTexLevelParameteriv gmlGetTexLevelParameteriv
#define glGetFramebufferAttachmentParameterivEXT gmlGetFramebufferAttachmentParameterivEXT
#define glGetRenderbufferParameterivEXT gmlGetRenderbufferParameterivEXT
#define glGetTexImage gmlGetTexImage
#define glIsTexture gmlIsTexture
#define glFramebufferTexture1DEXT gmlFramebufferTexture1DEXT
#define glFramebufferTexture3DEXT gmlFramebufferTexture3DEXT
#define glClientActiveTexture gmlClientActiveTexture
#define glMultiTexCoord2i gmlMultiTexCoord2i
#define glGetQueryiv gmlGetQueryiv
#define glGetBooleanv gmlGetBooleanv
#define glValidateProgram gmlValidateProgram
#define glUniform2iv gmlUniform2iv
#define glUniform3iv gmlUniform3iv
#define glUniform4iv gmlUniform4iv
#define glUniform2fv gmlUniform2fv
#define glUniform3fv gmlUniform3fv
#define glUniform4fv gmlUniform4fv
#define glMapBufferRange gmlMapBufferRange
#define glPrimitiveRestartIndexNV gmlPrimitiveRestartIndexNV
#define glDrawRangeElements gmlDrawRangeElements
