]> git.tdb.fi Git - libs/gl.git/commitdiff
Complete rewrite of extension handling
authorMikko Rasa <tdb@tdb.fi>
Mon, 27 Aug 2012 20:22:10 +0000 (23:22 +0300)
committerMikko Rasa <tdb@tdb.fi>
Mon, 27 Aug 2012 20:59:16 +0000 (23:59 +0300)
Prefer the promoted versions of extensions.  This improves compatibility
with OpenGL 3.0 and OpenGL ES 2.0.

Extension availability is now checked through global identifiers rather
than strings.  This eliminates the possibility of typos.

61 files changed:
gl.spec.fixes [new file with mode: 0644]
scripts/extgen.py
source/arb_fragment_shader.cpp [new file with mode: 0644]
source/arb_fragment_shader.h [new file with mode: 0644]
source/arb_multitexture.cpp [new file with mode: 0644]
source/arb_multitexture.h [new file with mode: 0644]
source/arb_pixel_buffer_object.cpp [new file with mode: 0644]
source/arb_pixel_buffer_object.h [new file with mode: 0644]
source/arb_shader_objects.cpp
source/arb_shader_objects.h
source/arb_texture_cube_map.cpp [new file with mode: 0644]
source/arb_texture_cube_map.h [new file with mode: 0644]
source/arb_uniform_buffer_object.cpp
source/arb_uniform_buffer_object.h
source/arb_vertex_buffer_object.cpp
source/arb_vertex_buffer_object.h
source/arb_vertex_program.cpp [deleted file]
source/arb_vertex_program.h [deleted file]
source/arb_vertex_shader.cpp
source/arb_vertex_shader.h
source/batch.cpp
source/blend.cpp
source/buffer.cpp
source/buffer.h
source/ext_blend_minmax.cpp [new file with mode: 0644]
source/ext_blend_minmax.h [new file with mode: 0644]
source/ext_blend_subtract.cpp [new file with mode: 0644]
source/ext_blend_subtract.h [new file with mode: 0644]
source/ext_draw_range_elements.cpp [new file with mode: 0644]
source/ext_draw_range_elements.h [new file with mode: 0644]
source/ext_framebuffer_blit.cpp
source/ext_framebuffer_blit.h
source/ext_framebuffer_multisample.cpp
source/ext_framebuffer_multisample.h
source/ext_framebuffer_object.cpp
source/ext_framebuffer_object.h
source/ext_texture3d.cpp [new file with mode: 0644]
source/ext_texture3d.h [new file with mode: 0644]
source/extension.cpp
source/extension.h
source/framebuffer.cpp
source/framebuffer.h
source/mesh.cpp
source/nv_primitive_restart.cpp
source/nv_primitive_restart.h
source/program.cpp
source/programdata.cpp
source/renderbuffer.cpp
source/sgis_generate_mipmap.cpp [new file with mode: 0644]
source/sgis_generate_mipmap.h [new file with mode: 0644]
source/shader.cpp
source/texture.cpp
source/texture3d.cpp
source/texturecube.cpp
source/texunit.cpp
source/uniform.cpp
source/version_1_2.cpp [deleted file]
source/version_1_2.h [deleted file]
source/version_1_3.cpp [deleted file]
source/version_1_3.h [deleted file]
source/vertexarray.cpp

diff --git a/gl.spec.fixes b/gl.spec.fixes
new file mode 100644 (file)
index 0000000..4a3cba1
--- /dev/null
@@ -0,0 +1,50 @@
+# The gl.spec file does not contain enough information to generate extension
+# headers correctly, and is a bit broken at some places.  This file attempts to
+# rectify these problems.
+
+
+# ARB_shader_objects function names got changed when promoted to core
+
+DeleteObjectARB(...)
+       alias DeleteShader
+       alias DeleteProgram
+
+GetHandleARB(...)
+       delete
+
+GetInfoLogARB(...)
+       alias GetShaderInfoLog
+       alias GetProgramInfoLog
+
+GetObjectParameterfvARB(...)
+       delete
+
+GetObjectParameterivARB(...)
+       alias GetShaderiv
+       alias GetProgramiv
+
+
+# These are listed for the VERSION_3_0 category
+
+BindBufferRange(...)
+       category ARB_uniform_buffer_object
+
+BindBufferBase(...)
+       category ARB_uniform_buffer_object
+
+
+# The EXT versions allow user-generated names; core versions don't.  Since we
+# use GL-generated names, it's safe to alias them.
+
+BindFramebufferEXT(...)
+       alias BindFramebuffer
+
+BindRenderbufferEXT(...)
+       alias BindRenderbuffer
+
+
+# Ignore this, as it comes from ARB_vertex_program and I'm not sure if it works
+# with ARB_shader_objects.
+
+IsProgramARB(...)
+       delete
index f349d5251473a8f147d3af9edf082a636e89a6fd..d6727123d97cb842a5836ea1b7d2f4a901396962 100755 (executable)
 
 import sys
 
-ext = sys.argv[1]
+if len(sys.argv)<2:
+       print """Usage:
+  extgen.py <extension> [<version>] [<secondary> ...]"
+
+Reads gl.spec and generates files to use <extension>.  Any promoted functions
+are exposed with their promoted names.  If <secondary> extensions are given,
+any promoted functions from those are pulled in as well.  <version> can be
+given to override the version where <extension> was promoted to core."""
+       sys.exit(0)
 
-funcs = []
+ext = sys.argv[1]
+exttype = ext.split('_')[0]
+secondary = sys.argv[2:]
+ver = None
+if secondary and secondary[0][0].isdigit():
+       ver = secondary.pop(0)
+bp_ext = None
+
+class Function:
+       def __init__(self, name):
+               self.name = name
+               self.version = None
+               self.category = None
+               self.vectorequiv = None
+               self.aliases = []
+               self.extfunc = None
+
+funcs = {}
 cur_func = None
-for line in file("gl.spec"):
-       if line[0]=='#' or line.find(':')>=0:
-               continue
-       elif line[0]=='\t' and cur_func:
-               parts = line.split()
-               if parts[0]=="category" and parts[1]==ext:
-                       funcs.append(cur_func)
-       else:
-               paren = line.find('(')
-               if paren>0:
-                       cur_func = line[:paren]
+
+def parse_file(fn):
+       for line in open(fn):
+               if line[0]=='#' or line.find(':')>=0:
+                       continue
+               elif line[0]=='\t':
+                       if cur_func:
+                               parts = line.split()
+                               if parts[0]=="category":
+                                       cur_func.category = parts[1]
+                               elif parts[0]=="vectorequiv":
+                                       cur_func.vectorequiv = parts[1]
+                               elif parts[0]=="alias":
+                                       cur_func.aliases.append(parts[1])
+                               elif parts[0]=="version":
+                                       cur_func.version = parts[1]
+                               elif parts[0]=="delete":
+                                       del funcs[cur_func.name]
+                                       cur_func = None
+               else:
+                       paren = line.find('(')
+                       if paren>0:
+                               name = line[:paren]
+                               if name in funcs:
+                                       cur_func = funcs[name]
+                               else:
+                                       cur_func = Function(name)
+                                       funcs[name] = cur_func
+
+parse_file("gl.spec")
+parse_file("gl.spec.fixes")
+
+for f in funcs.itervalues():
+       if f.category==ext or f.category in secondary:
+               if not f.aliases and f.vectorequiv:
+                       for g in funcs.itervalues():
+                               if g!=f and g.vectorequiv==f.vectorequiv and f.name.startswith(g.name):
+                                       f.aliases.append(g.name)
+                                       break
+
+               for a in f.aliases:
+                       if a in funcs:
+                               funcs[a].extfunc = f
+
+def is_relevant(f):
+       if f.category==ext and not f.aliases:
+               return True
+       if f.extfunc:
+               e = f.extfunc
+               if e.category==ext or e.category in secondary:
+                       return True
+       return False
+
+funcs = [f for f in funcs.itervalues() if is_relevant(f)]
+funcs.sort(key=(lambda f: f.name))
+
+for f in funcs:
+       if f.extfunc:
+               if not ver:
+                       ver = f.version
+               if not f.category.startswith("VERSION_"):
+                       bp_ext = f.category
+       if not f.extfunc and not f.name.endswith(exttype):
+               bp_ext = f.category
+
+if ver:
+       ver = map(int, ver.split('.'))
 
 out = file(ext.lower()+".h", "w")
 out.write("#ifndef MSP_GL_%s_\n"%ext.upper())
 out.write("#define MSP_GL_%s_\n"%ext.upper())
 
 out.write("""
+#include "extension.h"
 #include "gl.h"
 #include <GL/glext.h>
 
 namespace Msp {
 namespace GL {
-
 """)
 
+if funcs:
+       out.write("\n")
 for f in funcs:
-       out.write("extern PFNGL%sPROC gl%s;\n"%(f.upper(), f))
+       out.write("extern PFNGL%sPROC gl%s;\n"%(f.name.upper(), f.name))
 
-out.write("\nvoid init_%s();\n"%ext.lower())
+out.write("\nextern Extension %s;\n"%ext)
 
 out.write("""
 } // namespace GL
@@ -44,23 +127,42 @@ out.write("""
 """)
 
 out = file(ext.lower()+".cpp", "w")
-out.write("#include \"extension.h\"\n")
 out.write("#include \"%s.h\"\n"%ext.lower())
 
 out.write("""
 namespace Msp {
 namespace GL {
-
 """)
 
+if funcs:
+       out.write("\n")
 for f in funcs:
-       out.write("PFNGL%sPROC gl%s = 0;\n"%(f.upper(), f))
-
-out.write("\nvoid init_%s()\n{\n"%ext.lower())
-for f in funcs:
-       out.write("\tgl%s = reinterpret_cast<PFNGL%sPROC>(get_proc_address(\"gl%s\"));\n"%(f, f.upper(), f))
+       out.write("PFNGL%sPROC gl%s = 0;\n"%(f.name.upper(), f.name))
+
+out.write("\nExtension::SupportLevel init_%s()\n{\n"%ext.lower())
+if ver:
+       out.write("\tif(is_version_at_least(%d, %d)"%tuple(ver))
+       if bp_ext:
+               out.write(" || is_supported(\"GL_%s\")"%bp_ext)
+       out.write(")\n\t{\n")
+       for f in funcs:
+               out.write("\t\tgl%s = reinterpret_cast<PFNGL%sPROC>(get_proc_address(\"gl%s\"));\n"%(f.name, f.name.upper(), f.name))
+       out.write("\t\treturn Extension::CORE;\n")
+       out.write("\t}\n")
+if ext!=bp_ext:
+       out.write("\tif(is_supported(\"GL_%s\"))\n\t{\n"%(ext))
+       for f in funcs:
+               n = f.name
+               if f.extfunc:
+                       n = f.extfunc.name
+               out.write("\t\tgl%s = reinterpret_cast<PFNGL%sPROC>(get_proc_address(\"gl%s\"));\n"%(f.name, f.name.upper(), n))
+       out.write("\t\treturn Extension::EXTENSION;\n")
+       out.write("\t}\n")
+out.write("\treturn Extension::UNSUPPORTED;\n")
 out.write("}\n")
 
+out.write("\nExtension %s(\"GL_%s\", init_%s);\n"%(ext, ext, ext.lower()))
+
 out.write("""
 } // namespace GL
 } // namespace Msp
diff --git a/source/arb_fragment_shader.cpp b/source/arb_fragment_shader.cpp
new file mode 100644 (file)
index 0000000..18524dc
--- /dev/null
@@ -0,0 +1,22 @@
+#include "arb_fragment_shader.h"
+
+namespace Msp {
+namespace GL {
+
+Extension::SupportLevel init_arb_fragment_shader()
+{
+       if(is_version_at_least(2, 0))
+       {
+               return Extension::CORE;
+       }
+       if(is_supported("GL_ARB_fragment_shader"))
+       {
+               return Extension::EXTENSION;
+       }
+       return Extension::UNSUPPORTED;
+}
+
+Extension ARB_fragment_shader("GL_ARB_fragment_shader", init_arb_fragment_shader);
+
+} // namespace GL
+} // namespace Msp
diff --git a/source/arb_fragment_shader.h b/source/arb_fragment_shader.h
new file mode 100644 (file)
index 0000000..984f155
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef MSP_GL_ARB_FRAGMENT_SHADER_
+#define MSP_GL_ARB_FRAGMENT_SHADER_
+
+#include "extension.h"
+#include "gl.h"
+#include <GL/glext.h>
+
+namespace Msp {
+namespace GL {
+
+extern Extension ARB_fragment_shader;
+
+} // namespace GL
+} // namespace Msp
+
+#endif
diff --git a/source/arb_multitexture.cpp b/source/arb_multitexture.cpp
new file mode 100644 (file)
index 0000000..391b045
--- /dev/null
@@ -0,0 +1,125 @@
+#include "arb_multitexture.h"
+
+namespace Msp {
+namespace GL {
+
+PFNGLACTIVETEXTUREPROC glActiveTexture = 0;
+PFNGLCLIENTACTIVETEXTUREPROC glClientActiveTexture = 0;
+PFNGLMULTITEXCOORD1DPROC glMultiTexCoord1d = 0;
+PFNGLMULTITEXCOORD1DVPROC glMultiTexCoord1dv = 0;
+PFNGLMULTITEXCOORD1FPROC glMultiTexCoord1f = 0;
+PFNGLMULTITEXCOORD1FVPROC glMultiTexCoord1fv = 0;
+PFNGLMULTITEXCOORD1IPROC glMultiTexCoord1i = 0;
+PFNGLMULTITEXCOORD1IVPROC glMultiTexCoord1iv = 0;
+PFNGLMULTITEXCOORD1SPROC glMultiTexCoord1s = 0;
+PFNGLMULTITEXCOORD1SVPROC glMultiTexCoord1sv = 0;
+PFNGLMULTITEXCOORD2DPROC glMultiTexCoord2d = 0;
+PFNGLMULTITEXCOORD2DVPROC glMultiTexCoord2dv = 0;
+PFNGLMULTITEXCOORD2FPROC glMultiTexCoord2f = 0;
+PFNGLMULTITEXCOORD2FVPROC glMultiTexCoord2fv = 0;
+PFNGLMULTITEXCOORD2IPROC glMultiTexCoord2i = 0;
+PFNGLMULTITEXCOORD2IVPROC glMultiTexCoord2iv = 0;
+PFNGLMULTITEXCOORD2SPROC glMultiTexCoord2s = 0;
+PFNGLMULTITEXCOORD2SVPROC glMultiTexCoord2sv = 0;
+PFNGLMULTITEXCOORD3DPROC glMultiTexCoord3d = 0;
+PFNGLMULTITEXCOORD3DVPROC glMultiTexCoord3dv = 0;
+PFNGLMULTITEXCOORD3FPROC glMultiTexCoord3f = 0;
+PFNGLMULTITEXCOORD3FVPROC glMultiTexCoord3fv = 0;
+PFNGLMULTITEXCOORD3IPROC glMultiTexCoord3i = 0;
+PFNGLMULTITEXCOORD3IVPROC glMultiTexCoord3iv = 0;
+PFNGLMULTITEXCOORD3SPROC glMultiTexCoord3s = 0;
+PFNGLMULTITEXCOORD3SVPROC glMultiTexCoord3sv = 0;
+PFNGLMULTITEXCOORD4DPROC glMultiTexCoord4d = 0;
+PFNGLMULTITEXCOORD4DVPROC glMultiTexCoord4dv = 0;
+PFNGLMULTITEXCOORD4FPROC glMultiTexCoord4f = 0;
+PFNGLMULTITEXCOORD4FVPROC glMultiTexCoord4fv = 0;
+PFNGLMULTITEXCOORD4IPROC glMultiTexCoord4i = 0;
+PFNGLMULTITEXCOORD4IVPROC glMultiTexCoord4iv = 0;
+PFNGLMULTITEXCOORD4SPROC glMultiTexCoord4s = 0;
+PFNGLMULTITEXCOORD4SVPROC glMultiTexCoord4sv = 0;
+
+Extension::SupportLevel init_arb_multitexture()
+{
+       if(is_version_at_least(1, 3))
+       {
+               glActiveTexture = reinterpret_cast<PFNGLACTIVETEXTUREPROC>(get_proc_address("glActiveTexture"));
+               glClientActiveTexture = reinterpret_cast<PFNGLCLIENTACTIVETEXTUREPROC>(get_proc_address("glClientActiveTexture"));
+               glMultiTexCoord1d = reinterpret_cast<PFNGLMULTITEXCOORD1DPROC>(get_proc_address("glMultiTexCoord1d"));
+               glMultiTexCoord1dv = reinterpret_cast<PFNGLMULTITEXCOORD1DVPROC>(get_proc_address("glMultiTexCoord1dv"));
+               glMultiTexCoord1f = reinterpret_cast<PFNGLMULTITEXCOORD1FPROC>(get_proc_address("glMultiTexCoord1f"));
+               glMultiTexCoord1fv = reinterpret_cast<PFNGLMULTITEXCOORD1FVPROC>(get_proc_address("glMultiTexCoord1fv"));
+               glMultiTexCoord1i = reinterpret_cast<PFNGLMULTITEXCOORD1IPROC>(get_proc_address("glMultiTexCoord1i"));
+               glMultiTexCoord1iv = reinterpret_cast<PFNGLMULTITEXCOORD1IVPROC>(get_proc_address("glMultiTexCoord1iv"));
+               glMultiTexCoord1s = reinterpret_cast<PFNGLMULTITEXCOORD1SPROC>(get_proc_address("glMultiTexCoord1s"));
+               glMultiTexCoord1sv = reinterpret_cast<PFNGLMULTITEXCOORD1SVPROC>(get_proc_address("glMultiTexCoord1sv"));
+               glMultiTexCoord2d = reinterpret_cast<PFNGLMULTITEXCOORD2DPROC>(get_proc_address("glMultiTexCoord2d"));
+               glMultiTexCoord2dv = reinterpret_cast<PFNGLMULTITEXCOORD2DVPROC>(get_proc_address("glMultiTexCoord2dv"));
+               glMultiTexCoord2f = reinterpret_cast<PFNGLMULTITEXCOORD2FPROC>(get_proc_address("glMultiTexCoord2f"));
+               glMultiTexCoord2fv = reinterpret_cast<PFNGLMULTITEXCOORD2FVPROC>(get_proc_address("glMultiTexCoord2fv"));
+               glMultiTexCoord2i = reinterpret_cast<PFNGLMULTITEXCOORD2IPROC>(get_proc_address("glMultiTexCoord2i"));
+               glMultiTexCoord2iv = reinterpret_cast<PFNGLMULTITEXCOORD2IVPROC>(get_proc_address("glMultiTexCoord2iv"));
+               glMultiTexCoord2s = reinterpret_cast<PFNGLMULTITEXCOORD2SPROC>(get_proc_address("glMultiTexCoord2s"));
+               glMultiTexCoord2sv = reinterpret_cast<PFNGLMULTITEXCOORD2SVPROC>(get_proc_address("glMultiTexCoord2sv"));
+               glMultiTexCoord3d = reinterpret_cast<PFNGLMULTITEXCOORD3DPROC>(get_proc_address("glMultiTexCoord3d"));
+               glMultiTexCoord3dv = reinterpret_cast<PFNGLMULTITEXCOORD3DVPROC>(get_proc_address("glMultiTexCoord3dv"));
+               glMultiTexCoord3f = reinterpret_cast<PFNGLMULTITEXCOORD3FPROC>(get_proc_address("glMultiTexCoord3f"));
+               glMultiTexCoord3fv = reinterpret_cast<PFNGLMULTITEXCOORD3FVPROC>(get_proc_address("glMultiTexCoord3fv"));
+               glMultiTexCoord3i = reinterpret_cast<PFNGLMULTITEXCOORD3IPROC>(get_proc_address("glMultiTexCoord3i"));
+               glMultiTexCoord3iv = reinterpret_cast<PFNGLMULTITEXCOORD3IVPROC>(get_proc_address("glMultiTexCoord3iv"));
+               glMultiTexCoord3s = reinterpret_cast<PFNGLMULTITEXCOORD3SPROC>(get_proc_address("glMultiTexCoord3s"));
+               glMultiTexCoord3sv = reinterpret_cast<PFNGLMULTITEXCOORD3SVPROC>(get_proc_address("glMultiTexCoord3sv"));
+               glMultiTexCoord4d = reinterpret_cast<PFNGLMULTITEXCOORD4DPROC>(get_proc_address("glMultiTexCoord4d"));
+               glMultiTexCoord4dv = reinterpret_cast<PFNGLMULTITEXCOORD4DVPROC>(get_proc_address("glMultiTexCoord4dv"));
+               glMultiTexCoord4f = reinterpret_cast<PFNGLMULTITEXCOORD4FPROC>(get_proc_address("glMultiTexCoord4f"));
+               glMultiTexCoord4fv = reinterpret_cast<PFNGLMULTITEXCOORD4FVPROC>(get_proc_address("glMultiTexCoord4fv"));
+               glMultiTexCoord4i = reinterpret_cast<PFNGLMULTITEXCOORD4IPROC>(get_proc_address("glMultiTexCoord4i"));
+               glMultiTexCoord4iv = reinterpret_cast<PFNGLMULTITEXCOORD4IVPROC>(get_proc_address("glMultiTexCoord4iv"));
+               glMultiTexCoord4s = reinterpret_cast<PFNGLMULTITEXCOORD4SPROC>(get_proc_address("glMultiTexCoord4s"));
+               glMultiTexCoord4sv = reinterpret_cast<PFNGLMULTITEXCOORD4SVPROC>(get_proc_address("glMultiTexCoord4sv"));
+               return Extension::CORE;
+       }
+       if(is_supported("GL_ARB_multitexture"))
+       {
+               glActiveTexture = reinterpret_cast<PFNGLACTIVETEXTUREPROC>(get_proc_address("glActiveTextureARB"));
+               glClientActiveTexture = reinterpret_cast<PFNGLCLIENTACTIVETEXTUREPROC>(get_proc_address("glClientActiveTextureARB"));
+               glMultiTexCoord1d = reinterpret_cast<PFNGLMULTITEXCOORD1DPROC>(get_proc_address("glMultiTexCoord1dARB"));
+               glMultiTexCoord1dv = reinterpret_cast<PFNGLMULTITEXCOORD1DVPROC>(get_proc_address("glMultiTexCoord1dvARB"));
+               glMultiTexCoord1f = reinterpret_cast<PFNGLMULTITEXCOORD1FPROC>(get_proc_address("glMultiTexCoord1fARB"));
+               glMultiTexCoord1fv = reinterpret_cast<PFNGLMULTITEXCOORD1FVPROC>(get_proc_address("glMultiTexCoord1fvARB"));
+               glMultiTexCoord1i = reinterpret_cast<PFNGLMULTITEXCOORD1IPROC>(get_proc_address("glMultiTexCoord1iARB"));
+               glMultiTexCoord1iv = reinterpret_cast<PFNGLMULTITEXCOORD1IVPROC>(get_proc_address("glMultiTexCoord1ivARB"));
+               glMultiTexCoord1s = reinterpret_cast<PFNGLMULTITEXCOORD1SPROC>(get_proc_address("glMultiTexCoord1sARB"));
+               glMultiTexCoord1sv = reinterpret_cast<PFNGLMULTITEXCOORD1SVPROC>(get_proc_address("glMultiTexCoord1svARB"));
+               glMultiTexCoord2d = reinterpret_cast<PFNGLMULTITEXCOORD2DPROC>(get_proc_address("glMultiTexCoord2dARB"));
+               glMultiTexCoord2dv = reinterpret_cast<PFNGLMULTITEXCOORD2DVPROC>(get_proc_address("glMultiTexCoord2dvARB"));
+               glMultiTexCoord2f = reinterpret_cast<PFNGLMULTITEXCOORD2FPROC>(get_proc_address("glMultiTexCoord2fARB"));
+               glMultiTexCoord2fv = reinterpret_cast<PFNGLMULTITEXCOORD2FVPROC>(get_proc_address("glMultiTexCoord2fvARB"));
+               glMultiTexCoord2i = reinterpret_cast<PFNGLMULTITEXCOORD2IPROC>(get_proc_address("glMultiTexCoord2iARB"));
+               glMultiTexCoord2iv = reinterpret_cast<PFNGLMULTITEXCOORD2IVPROC>(get_proc_address("glMultiTexCoord2ivARB"));
+               glMultiTexCoord2s = reinterpret_cast<PFNGLMULTITEXCOORD2SPROC>(get_proc_address("glMultiTexCoord2sARB"));
+               glMultiTexCoord2sv = reinterpret_cast<PFNGLMULTITEXCOORD2SVPROC>(get_proc_address("glMultiTexCoord2svARB"));
+               glMultiTexCoord3d = reinterpret_cast<PFNGLMULTITEXCOORD3DPROC>(get_proc_address("glMultiTexCoord3dARB"));
+               glMultiTexCoord3dv = reinterpret_cast<PFNGLMULTITEXCOORD3DVPROC>(get_proc_address("glMultiTexCoord3dvARB"));
+               glMultiTexCoord3f = reinterpret_cast<PFNGLMULTITEXCOORD3FPROC>(get_proc_address("glMultiTexCoord3fARB"));
+               glMultiTexCoord3fv = reinterpret_cast<PFNGLMULTITEXCOORD3FVPROC>(get_proc_address("glMultiTexCoord3fvARB"));
+               glMultiTexCoord3i = reinterpret_cast<PFNGLMULTITEXCOORD3IPROC>(get_proc_address("glMultiTexCoord3iARB"));
+               glMultiTexCoord3iv = reinterpret_cast<PFNGLMULTITEXCOORD3IVPROC>(get_proc_address("glMultiTexCoord3ivARB"));
+               glMultiTexCoord3s = reinterpret_cast<PFNGLMULTITEXCOORD3SPROC>(get_proc_address("glMultiTexCoord3sARB"));
+               glMultiTexCoord3sv = reinterpret_cast<PFNGLMULTITEXCOORD3SVPROC>(get_proc_address("glMultiTexCoord3svARB"));
+               glMultiTexCoord4d = reinterpret_cast<PFNGLMULTITEXCOORD4DPROC>(get_proc_address("glMultiTexCoord4dARB"));
+               glMultiTexCoord4dv = reinterpret_cast<PFNGLMULTITEXCOORD4DVPROC>(get_proc_address("glMultiTexCoord4dvARB"));
+               glMultiTexCoord4f = reinterpret_cast<PFNGLMULTITEXCOORD4FPROC>(get_proc_address("glMultiTexCoord4fARB"));
+               glMultiTexCoord4fv = reinterpret_cast<PFNGLMULTITEXCOORD4FVPROC>(get_proc_address("glMultiTexCoord4fvARB"));
+               glMultiTexCoord4i = reinterpret_cast<PFNGLMULTITEXCOORD4IPROC>(get_proc_address("glMultiTexCoord4iARB"));
+               glMultiTexCoord4iv = reinterpret_cast<PFNGLMULTITEXCOORD4IVPROC>(get_proc_address("glMultiTexCoord4ivARB"));
+               glMultiTexCoord4s = reinterpret_cast<PFNGLMULTITEXCOORD4SPROC>(get_proc_address("glMultiTexCoord4sARB"));
+               glMultiTexCoord4sv = reinterpret_cast<PFNGLMULTITEXCOORD4SVPROC>(get_proc_address("glMultiTexCoord4svARB"));
+               return Extension::EXTENSION;
+       }
+       return Extension::UNSUPPORTED;
+}
+
+Extension ARB_multitexture("GL_ARB_multitexture", init_arb_multitexture);
+
+} // namespace GL
+} // namespace Msp
diff --git a/source/arb_multitexture.h b/source/arb_multitexture.h
new file mode 100644 (file)
index 0000000..4c41f09
--- /dev/null
@@ -0,0 +1,51 @@
+#ifndef MSP_GL_ARB_MULTITEXTURE_
+#define MSP_GL_ARB_MULTITEXTURE_
+
+#include "extension.h"
+#include "gl.h"
+#include <GL/glext.h>
+
+namespace Msp {
+namespace GL {
+
+extern PFNGLACTIVETEXTUREPROC glActiveTexture;
+extern PFNGLCLIENTACTIVETEXTUREPROC glClientActiveTexture;
+extern PFNGLMULTITEXCOORD1DPROC glMultiTexCoord1d;
+extern PFNGLMULTITEXCOORD1DVPROC glMultiTexCoord1dv;
+extern PFNGLMULTITEXCOORD1FPROC glMultiTexCoord1f;
+extern PFNGLMULTITEXCOORD1FVPROC glMultiTexCoord1fv;
+extern PFNGLMULTITEXCOORD1IPROC glMultiTexCoord1i;
+extern PFNGLMULTITEXCOORD1IVPROC glMultiTexCoord1iv;
+extern PFNGLMULTITEXCOORD1SPROC glMultiTexCoord1s;
+extern PFNGLMULTITEXCOORD1SVPROC glMultiTexCoord1sv;
+extern PFNGLMULTITEXCOORD2DPROC glMultiTexCoord2d;
+extern PFNGLMULTITEXCOORD2DVPROC glMultiTexCoord2dv;
+extern PFNGLMULTITEXCOORD2FPROC glMultiTexCoord2f;
+extern PFNGLMULTITEXCOORD2FVPROC glMultiTexCoord2fv;
+extern PFNGLMULTITEXCOORD2IPROC glMultiTexCoord2i;
+extern PFNGLMULTITEXCOORD2IVPROC glMultiTexCoord2iv;
+extern PFNGLMULTITEXCOORD2SPROC glMultiTexCoord2s;
+extern PFNGLMULTITEXCOORD2SVPROC glMultiTexCoord2sv;
+extern PFNGLMULTITEXCOORD3DPROC glMultiTexCoord3d;
+extern PFNGLMULTITEXCOORD3DVPROC glMultiTexCoord3dv;
+extern PFNGLMULTITEXCOORD3FPROC glMultiTexCoord3f;
+extern PFNGLMULTITEXCOORD3FVPROC glMultiTexCoord3fv;
+extern PFNGLMULTITEXCOORD3IPROC glMultiTexCoord3i;
+extern PFNGLMULTITEXCOORD3IVPROC glMultiTexCoord3iv;
+extern PFNGLMULTITEXCOORD3SPROC glMultiTexCoord3s;
+extern PFNGLMULTITEXCOORD3SVPROC glMultiTexCoord3sv;
+extern PFNGLMULTITEXCOORD4DPROC glMultiTexCoord4d;
+extern PFNGLMULTITEXCOORD4DVPROC glMultiTexCoord4dv;
+extern PFNGLMULTITEXCOORD4FPROC glMultiTexCoord4f;
+extern PFNGLMULTITEXCOORD4FVPROC glMultiTexCoord4fv;
+extern PFNGLMULTITEXCOORD4IPROC glMultiTexCoord4i;
+extern PFNGLMULTITEXCOORD4IVPROC glMultiTexCoord4iv;
+extern PFNGLMULTITEXCOORD4SPROC glMultiTexCoord4s;
+extern PFNGLMULTITEXCOORD4SVPROC glMultiTexCoord4sv;
+
+extern Extension ARB_multitexture;
+
+} // namespace GL
+} // namespace Msp
+
+#endif
diff --git a/source/arb_pixel_buffer_object.cpp b/source/arb_pixel_buffer_object.cpp
new file mode 100644 (file)
index 0000000..0243f8b
--- /dev/null
@@ -0,0 +1,22 @@
+#include "arb_pixel_buffer_object.h"
+
+namespace Msp {
+namespace GL {
+
+Extension::SupportLevel init_arb_pixel_buffer_object()
+{
+       if(is_version_at_least(2, 1))
+       {
+               return Extension::CORE;
+       }
+       if(is_supported("GL_ARB_pixel_buffer_object"))
+       {
+               return Extension::EXTENSION;
+       }
+       return Extension::UNSUPPORTED;
+}
+
+Extension ARB_pixel_buffer_object("GL_ARB_pixel_buffer_object", init_arb_pixel_buffer_object);
+
+} // namespace GL
+} // namespace Msp
diff --git a/source/arb_pixel_buffer_object.h b/source/arb_pixel_buffer_object.h
new file mode 100644 (file)
index 0000000..e781982
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef MSP_GL_ARB_PIXEL_BUFFER_OBJECT_
+#define MSP_GL_ARB_PIXEL_BUFFER_OBJECT_
+
+#include "extension.h"
+#include "gl.h"
+#include <GL/glext.h>
+
+namespace Msp {
+namespace GL {
+
+extern Extension ARB_pixel_buffer_object;
+
+} // namespace GL
+} // namespace Msp
+
+#endif
index 18ea54829897a59994de32fbf3883d4f3b3a70da..3cb31bc5cd36f4779ccc91d67071dae77480b687 100644 (file)
-#include "extension.h"
 #include "arb_shader_objects.h"
 
 namespace Msp {
 namespace GL {
 
-PFNGLDELETEOBJECTARBPROC glDeleteObjectARB = 0;
-PFNGLGETHANDLEARBPROC glGetHandleARB = 0;
-PFNGLDETACHOBJECTARBPROC glDetachObjectARB = 0;
-PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB = 0;
-PFNGLSHADERSOURCEARBPROC glShaderSourceARB = 0;
-PFNGLCOMPILESHADERARBPROC glCompileShaderARB = 0;
-PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB = 0;
-PFNGLATTACHOBJECTARBPROC glAttachObjectARB = 0;
-PFNGLLINKPROGRAMARBPROC glLinkProgramARB = 0;
-PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB = 0;
-PFNGLVALIDATEPROGRAMARBPROC glValidateProgramARB = 0;
-PFNGLUNIFORM1FARBPROC glUniform1fARB = 0;
-PFNGLUNIFORM2FARBPROC glUniform2fARB = 0;
-PFNGLUNIFORM3FARBPROC glUniform3fARB = 0;
-PFNGLUNIFORM4FARBPROC glUniform4fARB = 0;
-PFNGLUNIFORM1IARBPROC glUniform1iARB = 0;
-PFNGLUNIFORM2IARBPROC glUniform2iARB = 0;
-PFNGLUNIFORM3IARBPROC glUniform3iARB = 0;
-PFNGLUNIFORM4IARBPROC glUniform4iARB = 0;
-PFNGLUNIFORM1FVARBPROC glUniform1fvARB = 0;
-PFNGLUNIFORM2FVARBPROC glUniform2fvARB = 0;
-PFNGLUNIFORM3FVARBPROC glUniform3fvARB = 0;
-PFNGLUNIFORM4FVARBPROC glUniform4fvARB = 0;
-PFNGLUNIFORM1IVARBPROC glUniform1ivARB = 0;
-PFNGLUNIFORM2IVARBPROC glUniform2ivARB = 0;
-PFNGLUNIFORM3IVARBPROC glUniform3ivARB = 0;
-PFNGLUNIFORM4IVARBPROC glUniform4ivARB = 0;
-PFNGLUNIFORMMATRIX2FVARBPROC glUniformMatrix2fvARB = 0;
-PFNGLUNIFORMMATRIX3FVARBPROC glUniformMatrix3fvARB = 0;
-PFNGLUNIFORMMATRIX4FVARBPROC glUniformMatrix4fvARB = 0;
-PFNGLGETOBJECTPARAMETERFVARBPROC glGetObjectParameterfvARB = 0;
-PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB = 0;
-PFNGLGETINFOLOGARBPROC glGetInfoLogARB = 0;
-PFNGLGETATTACHEDOBJECTSARBPROC glGetAttachedObjectsARB = 0;
-PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB = 0;
-PFNGLGETACTIVEUNIFORMARBPROC glGetActiveUniformARB = 0;
-PFNGLGETUNIFORMFVARBPROC glGetUniformfvARB = 0;
-PFNGLGETUNIFORMIVARBPROC glGetUniformivARB = 0;
-PFNGLGETSHADERSOURCEARBPROC glGetShaderSourceARB = 0;
+PFNGLATTACHSHADERPROC glAttachShader = 0;
+PFNGLCOMPILESHADERPROC glCompileShader = 0;
+PFNGLCREATEPROGRAMPROC glCreateProgram = 0;
+PFNGLCREATESHADERPROC glCreateShader = 0;
+PFNGLDELETEPROGRAMPROC glDeleteProgram = 0;
+PFNGLDELETESHADERPROC glDeleteShader = 0;
+PFNGLDETACHSHADERPROC glDetachShader = 0;
+PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform = 0;
+PFNGLGETATTACHEDSHADERSPROC glGetAttachedShaders = 0;
+PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog = 0;
+PFNGLGETPROGRAMIVPROC glGetProgramiv = 0;
+PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog = 0;
+PFNGLGETSHADERSOURCEPROC glGetShaderSource = 0;
+PFNGLGETSHADERIVPROC glGetShaderiv = 0;
+PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation = 0;
+PFNGLGETUNIFORMFVPROC glGetUniformfv = 0;
+PFNGLGETUNIFORMIVPROC glGetUniformiv = 0;
+PFNGLLINKPROGRAMPROC glLinkProgram = 0;
+PFNGLSHADERSOURCEPROC glShaderSource = 0;
+PFNGLUNIFORM1FPROC glUniform1f = 0;
+PFNGLUNIFORM1FVPROC glUniform1fv = 0;
+PFNGLUNIFORM1IPROC glUniform1i = 0;
+PFNGLUNIFORM1IVPROC glUniform1iv = 0;
+PFNGLUNIFORM2FPROC glUniform2f = 0;
+PFNGLUNIFORM2FVPROC glUniform2fv = 0;
+PFNGLUNIFORM2IPROC glUniform2i = 0;
+PFNGLUNIFORM2IVPROC glUniform2iv = 0;
+PFNGLUNIFORM3FPROC glUniform3f = 0;
+PFNGLUNIFORM3FVPROC glUniform3fv = 0;
+PFNGLUNIFORM3IPROC glUniform3i = 0;
+PFNGLUNIFORM3IVPROC glUniform3iv = 0;
+PFNGLUNIFORM4FPROC glUniform4f = 0;
+PFNGLUNIFORM4FVPROC glUniform4fv = 0;
+PFNGLUNIFORM4IPROC glUniform4i = 0;
+PFNGLUNIFORM4IVPROC glUniform4iv = 0;
+PFNGLUNIFORMMATRIX2FVPROC glUniformMatrix2fv = 0;
+PFNGLUNIFORMMATRIX3FVPROC glUniformMatrix3fv = 0;
+PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv = 0;
+PFNGLUSEPROGRAMPROC glUseProgram = 0;
+PFNGLVALIDATEPROGRAMPROC glValidateProgram = 0;
 
-void init_arb_shader_objects()
+Extension::SupportLevel init_arb_shader_objects()
 {
-       glDeleteObjectARB = reinterpret_cast<PFNGLDELETEOBJECTARBPROC>(get_proc_address("glDeleteObjectARB"));
-       glGetHandleARB = reinterpret_cast<PFNGLGETHANDLEARBPROC>(get_proc_address("glGetHandleARB"));
-       glDetachObjectARB = reinterpret_cast<PFNGLDETACHOBJECTARBPROC>(get_proc_address("glDetachObjectARB"));
-       glCreateShaderObjectARB = reinterpret_cast<PFNGLCREATESHADEROBJECTARBPROC>(get_proc_address("glCreateShaderObjectARB"));
-       glShaderSourceARB = reinterpret_cast<PFNGLSHADERSOURCEARBPROC>(get_proc_address("glShaderSourceARB"));
-       glCompileShaderARB = reinterpret_cast<PFNGLCOMPILESHADERARBPROC>(get_proc_address("glCompileShaderARB"));
-       glCreateProgramObjectARB = reinterpret_cast<PFNGLCREATEPROGRAMOBJECTARBPROC>(get_proc_address("glCreateProgramObjectARB"));
-       glAttachObjectARB = reinterpret_cast<PFNGLATTACHOBJECTARBPROC>(get_proc_address("glAttachObjectARB"));
-       glLinkProgramARB = reinterpret_cast<PFNGLLINKPROGRAMARBPROC>(get_proc_address("glLinkProgramARB"));
-       glUseProgramObjectARB = reinterpret_cast<PFNGLUSEPROGRAMOBJECTARBPROC>(get_proc_address("glUseProgramObjectARB"));
-       glValidateProgramARB = reinterpret_cast<PFNGLVALIDATEPROGRAMARBPROC>(get_proc_address("glValidateProgramARB"));
-       glUniform1fARB = reinterpret_cast<PFNGLUNIFORM1FARBPROC>(get_proc_address("glUniform1fARB"));
-       glUniform2fARB = reinterpret_cast<PFNGLUNIFORM2FARBPROC>(get_proc_address("glUniform2fARB"));
-       glUniform3fARB = reinterpret_cast<PFNGLUNIFORM3FARBPROC>(get_proc_address("glUniform3fARB"));
-       glUniform4fARB = reinterpret_cast<PFNGLUNIFORM4FARBPROC>(get_proc_address("glUniform4fARB"));
-       glUniform1iARB = reinterpret_cast<PFNGLUNIFORM1IARBPROC>(get_proc_address("glUniform1iARB"));
-       glUniform2iARB = reinterpret_cast<PFNGLUNIFORM2IARBPROC>(get_proc_address("glUniform2iARB"));
-       glUniform3iARB = reinterpret_cast<PFNGLUNIFORM3IARBPROC>(get_proc_address("glUniform3iARB"));
-       glUniform4iARB = reinterpret_cast<PFNGLUNIFORM4IARBPROC>(get_proc_address("glUniform4iARB"));
-       glUniform1fvARB = reinterpret_cast<PFNGLUNIFORM1FVARBPROC>(get_proc_address("glUniform1fvARB"));
-       glUniform2fvARB = reinterpret_cast<PFNGLUNIFORM2FVARBPROC>(get_proc_address("glUniform2fvARB"));
-       glUniform3fvARB = reinterpret_cast<PFNGLUNIFORM3FVARBPROC>(get_proc_address("glUniform3fvARB"));
-       glUniform4fvARB = reinterpret_cast<PFNGLUNIFORM4FVARBPROC>(get_proc_address("glUniform4fvARB"));
-       glUniform1ivARB = reinterpret_cast<PFNGLUNIFORM1IVARBPROC>(get_proc_address("glUniform1ivARB"));
-       glUniform2ivARB = reinterpret_cast<PFNGLUNIFORM2IVARBPROC>(get_proc_address("glUniform2ivARB"));
-       glUniform3ivARB = reinterpret_cast<PFNGLUNIFORM3IVARBPROC>(get_proc_address("glUniform3ivARB"));
-       glUniform4ivARB = reinterpret_cast<PFNGLUNIFORM4IVARBPROC>(get_proc_address("glUniform4ivARB"));
-       glUniformMatrix2fvARB = reinterpret_cast<PFNGLUNIFORMMATRIX2FVARBPROC>(get_proc_address("glUniformMatrix2fvARB"));
-       glUniformMatrix3fvARB = reinterpret_cast<PFNGLUNIFORMMATRIX3FVARBPROC>(get_proc_address("glUniformMatrix3fvARB"));
-       glUniformMatrix4fvARB = reinterpret_cast<PFNGLUNIFORMMATRIX4FVARBPROC>(get_proc_address("glUniformMatrix4fvARB"));
-       glGetObjectParameterfvARB = reinterpret_cast<PFNGLGETOBJECTPARAMETERFVARBPROC>(get_proc_address("glGetObjectParameterfvARB"));
-       glGetObjectParameterivARB = reinterpret_cast<PFNGLGETOBJECTPARAMETERIVARBPROC>(get_proc_address("glGetObjectParameterivARB"));
-       glGetInfoLogARB = reinterpret_cast<PFNGLGETINFOLOGARBPROC>(get_proc_address("glGetInfoLogARB"));
-       glGetAttachedObjectsARB = reinterpret_cast<PFNGLGETATTACHEDOBJECTSARBPROC>(get_proc_address("glGetAttachedObjectsARB"));
-       glGetUniformLocationARB = reinterpret_cast<PFNGLGETUNIFORMLOCATIONARBPROC>(get_proc_address("glGetUniformLocationARB"));
-       glGetActiveUniformARB = reinterpret_cast<PFNGLGETACTIVEUNIFORMARBPROC>(get_proc_address("glGetActiveUniformARB"));
-       glGetUniformfvARB = reinterpret_cast<PFNGLGETUNIFORMFVARBPROC>(get_proc_address("glGetUniformfvARB"));
-       glGetUniformivARB = reinterpret_cast<PFNGLGETUNIFORMIVARBPROC>(get_proc_address("glGetUniformivARB"));
-       glGetShaderSourceARB = reinterpret_cast<PFNGLGETSHADERSOURCEARBPROC>(get_proc_address("glGetShaderSourceARB"));
+       if(is_version_at_least(2, 0))
+       {
+               glAttachShader = reinterpret_cast<PFNGLATTACHSHADERPROC>(get_proc_address("glAttachShader"));
+               glCompileShader = reinterpret_cast<PFNGLCOMPILESHADERPROC>(get_proc_address("glCompileShader"));
+               glCreateProgram = reinterpret_cast<PFNGLCREATEPROGRAMPROC>(get_proc_address("glCreateProgram"));
+               glCreateShader = reinterpret_cast<PFNGLCREATESHADERPROC>(get_proc_address("glCreateShader"));
+               glDeleteProgram = reinterpret_cast<PFNGLDELETEPROGRAMPROC>(get_proc_address("glDeleteProgram"));
+               glDeleteShader = reinterpret_cast<PFNGLDELETESHADERPROC>(get_proc_address("glDeleteShader"));
+               glDetachShader = reinterpret_cast<PFNGLDETACHSHADERPROC>(get_proc_address("glDetachShader"));
+               glGetActiveUniform = reinterpret_cast<PFNGLGETACTIVEUNIFORMPROC>(get_proc_address("glGetActiveUniform"));
+               glGetAttachedShaders = reinterpret_cast<PFNGLGETATTACHEDSHADERSPROC>(get_proc_address("glGetAttachedShaders"));
+               glGetProgramInfoLog = reinterpret_cast<PFNGLGETPROGRAMINFOLOGPROC>(get_proc_address("glGetProgramInfoLog"));
+               glGetProgramiv = reinterpret_cast<PFNGLGETPROGRAMIVPROC>(get_proc_address("glGetProgramiv"));
+               glGetShaderInfoLog = reinterpret_cast<PFNGLGETSHADERINFOLOGPROC>(get_proc_address("glGetShaderInfoLog"));
+               glGetShaderSource = reinterpret_cast<PFNGLGETSHADERSOURCEPROC>(get_proc_address("glGetShaderSource"));
+               glGetShaderiv = reinterpret_cast<PFNGLGETSHADERIVPROC>(get_proc_address("glGetShaderiv"));
+               glGetUniformLocation = reinterpret_cast<PFNGLGETUNIFORMLOCATIONPROC>(get_proc_address("glGetUniformLocation"));
+               glGetUniformfv = reinterpret_cast<PFNGLGETUNIFORMFVPROC>(get_proc_address("glGetUniformfv"));
+               glGetUniformiv = reinterpret_cast<PFNGLGETUNIFORMIVPROC>(get_proc_address("glGetUniformiv"));
+               glLinkProgram = reinterpret_cast<PFNGLLINKPROGRAMPROC>(get_proc_address("glLinkProgram"));
+               glShaderSource = reinterpret_cast<PFNGLSHADERSOURCEPROC>(get_proc_address("glShaderSource"));
+               glUniform1f = reinterpret_cast<PFNGLUNIFORM1FPROC>(get_proc_address("glUniform1f"));
+               glUniform1fv = reinterpret_cast<PFNGLUNIFORM1FVPROC>(get_proc_address("glUniform1fv"));
+               glUniform1i = reinterpret_cast<PFNGLUNIFORM1IPROC>(get_proc_address("glUniform1i"));
+               glUniform1iv = reinterpret_cast<PFNGLUNIFORM1IVPROC>(get_proc_address("glUniform1iv"));
+               glUniform2f = reinterpret_cast<PFNGLUNIFORM2FPROC>(get_proc_address("glUniform2f"));
+               glUniform2fv = reinterpret_cast<PFNGLUNIFORM2FVPROC>(get_proc_address("glUniform2fv"));
+               glUniform2i = reinterpret_cast<PFNGLUNIFORM2IPROC>(get_proc_address("glUniform2i"));
+               glUniform2iv = reinterpret_cast<PFNGLUNIFORM2IVPROC>(get_proc_address("glUniform2iv"));
+               glUniform3f = reinterpret_cast<PFNGLUNIFORM3FPROC>(get_proc_address("glUniform3f"));
+               glUniform3fv = reinterpret_cast<PFNGLUNIFORM3FVPROC>(get_proc_address("glUniform3fv"));
+               glUniform3i = reinterpret_cast<PFNGLUNIFORM3IPROC>(get_proc_address("glUniform3i"));
+               glUniform3iv = reinterpret_cast<PFNGLUNIFORM3IVPROC>(get_proc_address("glUniform3iv"));
+               glUniform4f = reinterpret_cast<PFNGLUNIFORM4FPROC>(get_proc_address("glUniform4f"));
+               glUniform4fv = reinterpret_cast<PFNGLUNIFORM4FVPROC>(get_proc_address("glUniform4fv"));
+               glUniform4i = reinterpret_cast<PFNGLUNIFORM4IPROC>(get_proc_address("glUniform4i"));
+               glUniform4iv = reinterpret_cast<PFNGLUNIFORM4IVPROC>(get_proc_address("glUniform4iv"));
+               glUniformMatrix2fv = reinterpret_cast<PFNGLUNIFORMMATRIX2FVPROC>(get_proc_address("glUniformMatrix2fv"));
+               glUniformMatrix3fv = reinterpret_cast<PFNGLUNIFORMMATRIX3FVPROC>(get_proc_address("glUniformMatrix3fv"));
+               glUniformMatrix4fv = reinterpret_cast<PFNGLUNIFORMMATRIX4FVPROC>(get_proc_address("glUniformMatrix4fv"));
+               glUseProgram = reinterpret_cast<PFNGLUSEPROGRAMPROC>(get_proc_address("glUseProgram"));
+               glValidateProgram = reinterpret_cast<PFNGLVALIDATEPROGRAMPROC>(get_proc_address("glValidateProgram"));
+               return Extension::CORE;
+       }
+       if(is_supported("GL_ARB_shader_objects"))
+       {
+               glAttachShader = reinterpret_cast<PFNGLATTACHSHADERPROC>(get_proc_address("glAttachObjectARB"));
+               glCompileShader = reinterpret_cast<PFNGLCOMPILESHADERPROC>(get_proc_address("glCompileShaderARB"));
+               glCreateProgram = reinterpret_cast<PFNGLCREATEPROGRAMPROC>(get_proc_address("glCreateProgramObjectARB"));
+               glCreateShader = reinterpret_cast<PFNGLCREATESHADERPROC>(get_proc_address("glCreateShaderObjectARB"));
+               glDeleteProgram = reinterpret_cast<PFNGLDELETEPROGRAMPROC>(get_proc_address("glDeleteObjectARB"));
+               glDeleteShader = reinterpret_cast<PFNGLDELETESHADERPROC>(get_proc_address("glDeleteObjectARB"));
+               glDetachShader = reinterpret_cast<PFNGLDETACHSHADERPROC>(get_proc_address("glDetachObjectARB"));
+               glGetActiveUniform = reinterpret_cast<PFNGLGETACTIVEUNIFORMPROC>(get_proc_address("glGetActiveUniformARB"));
+               glGetAttachedShaders = reinterpret_cast<PFNGLGETATTACHEDSHADERSPROC>(get_proc_address("glGetAttachedObjectsARB"));
+               glGetProgramInfoLog = reinterpret_cast<PFNGLGETPROGRAMINFOLOGPROC>(get_proc_address("glGetInfoLogARB"));
+               glGetProgramiv = reinterpret_cast<PFNGLGETPROGRAMIVPROC>(get_proc_address("glGetObjectParameterivARB"));
+               glGetShaderInfoLog = reinterpret_cast<PFNGLGETSHADERINFOLOGPROC>(get_proc_address("glGetInfoLogARB"));
+               glGetShaderSource = reinterpret_cast<PFNGLGETSHADERSOURCEPROC>(get_proc_address("glGetShaderSourceARB"));
+               glGetShaderiv = reinterpret_cast<PFNGLGETSHADERIVPROC>(get_proc_address("glGetObjectParameterivARB"));
+               glGetUniformLocation = reinterpret_cast<PFNGLGETUNIFORMLOCATIONPROC>(get_proc_address("glGetUniformLocationARB"));
+               glGetUniformfv = reinterpret_cast<PFNGLGETUNIFORMFVPROC>(get_proc_address("glGetUniformfvARB"));
+               glGetUniformiv = reinterpret_cast<PFNGLGETUNIFORMIVPROC>(get_proc_address("glGetUniformivARB"));
+               glLinkProgram = reinterpret_cast<PFNGLLINKPROGRAMPROC>(get_proc_address("glLinkProgramARB"));
+               glShaderSource = reinterpret_cast<PFNGLSHADERSOURCEPROC>(get_proc_address("glShaderSourceARB"));
+               glUniform1f = reinterpret_cast<PFNGLUNIFORM1FPROC>(get_proc_address("glUniform1fARB"));
+               glUniform1fv = reinterpret_cast<PFNGLUNIFORM1FVPROC>(get_proc_address("glUniform1fvARB"));
+               glUniform1i = reinterpret_cast<PFNGLUNIFORM1IPROC>(get_proc_address("glUniform1iARB"));
+               glUniform1iv = reinterpret_cast<PFNGLUNIFORM1IVPROC>(get_proc_address("glUniform1ivARB"));
+               glUniform2f = reinterpret_cast<PFNGLUNIFORM2FPROC>(get_proc_address("glUniform2fARB"));
+               glUniform2fv = reinterpret_cast<PFNGLUNIFORM2FVPROC>(get_proc_address("glUniform2fvARB"));
+               glUniform2i = reinterpret_cast<PFNGLUNIFORM2IPROC>(get_proc_address("glUniform2iARB"));
+               glUniform2iv = reinterpret_cast<PFNGLUNIFORM2IVPROC>(get_proc_address("glUniform2ivARB"));
+               glUniform3f = reinterpret_cast<PFNGLUNIFORM3FPROC>(get_proc_address("glUniform3fARB"));
+               glUniform3fv = reinterpret_cast<PFNGLUNIFORM3FVPROC>(get_proc_address("glUniform3fvARB"));
+               glUniform3i = reinterpret_cast<PFNGLUNIFORM3IPROC>(get_proc_address("glUniform3iARB"));
+               glUniform3iv = reinterpret_cast<PFNGLUNIFORM3IVPROC>(get_proc_address("glUniform3ivARB"));
+               glUniform4f = reinterpret_cast<PFNGLUNIFORM4FPROC>(get_proc_address("glUniform4fARB"));
+               glUniform4fv = reinterpret_cast<PFNGLUNIFORM4FVPROC>(get_proc_address("glUniform4fvARB"));
+               glUniform4i = reinterpret_cast<PFNGLUNIFORM4IPROC>(get_proc_address("glUniform4iARB"));
+               glUniform4iv = reinterpret_cast<PFNGLUNIFORM4IVPROC>(get_proc_address("glUniform4ivARB"));
+               glUniformMatrix2fv = reinterpret_cast<PFNGLUNIFORMMATRIX2FVPROC>(get_proc_address("glUniformMatrix2fvARB"));
+               glUniformMatrix3fv = reinterpret_cast<PFNGLUNIFORMMATRIX3FVPROC>(get_proc_address("glUniformMatrix3fvARB"));
+               glUniformMatrix4fv = reinterpret_cast<PFNGLUNIFORMMATRIX4FVPROC>(get_proc_address("glUniformMatrix4fvARB"));
+               glUseProgram = reinterpret_cast<PFNGLUSEPROGRAMPROC>(get_proc_address("glUseProgramObjectARB"));
+               glValidateProgram = reinterpret_cast<PFNGLVALIDATEPROGRAMPROC>(get_proc_address("glValidateProgramARB"));
+               return Extension::EXTENSION;
+       }
+       return Extension::UNSUPPORTED;
 }
 
+Extension ARB_shader_objects("GL_ARB_shader_objects", init_arb_shader_objects);
+
 } // namespace GL
 } // namespace Msp
index e256d06837f0b0fa444d5db92f566c46c347e8a0..6b35cee18bb0dca16f9d7dd944fbe1a8aed752a4 100644 (file)
@@ -1,53 +1,55 @@
 #ifndef MSP_GL_ARB_SHADER_OBJECTS_
 #define MSP_GL_ARB_SHADER_OBJECTS_
 
+#include "extension.h"
 #include "gl.h"
 #include <GL/glext.h>
 
 namespace Msp {
 namespace GL {
 
-extern PFNGLDELETEOBJECTARBPROC glDeleteObjectARB;
-extern PFNGLGETHANDLEARBPROC glGetHandleARB;
-extern PFNGLDETACHOBJECTARBPROC glDetachObjectARB;
-extern PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB;
-extern PFNGLSHADERSOURCEARBPROC glShaderSourceARB;
-extern PFNGLCOMPILESHADERARBPROC glCompileShaderARB;
-extern PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB;
-extern PFNGLATTACHOBJECTARBPROC glAttachObjectARB;
-extern PFNGLLINKPROGRAMARBPROC glLinkProgramARB;
-extern PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB;
-extern PFNGLVALIDATEPROGRAMARBPROC glValidateProgramARB;
-extern PFNGLUNIFORM1FARBPROC glUniform1fARB;
-extern PFNGLUNIFORM2FARBPROC glUniform2fARB;
-extern PFNGLUNIFORM3FARBPROC glUniform3fARB;
-extern PFNGLUNIFORM4FARBPROC glUniform4fARB;
-extern PFNGLUNIFORM1IARBPROC glUniform1iARB;
-extern PFNGLUNIFORM2IARBPROC glUniform2iARB;
-extern PFNGLUNIFORM3IARBPROC glUniform3iARB;
-extern PFNGLUNIFORM4IARBPROC glUniform4iARB;
-extern PFNGLUNIFORM1FVARBPROC glUniform1fvARB;
-extern PFNGLUNIFORM2FVARBPROC glUniform2fvARB;
-extern PFNGLUNIFORM3FVARBPROC glUniform3fvARB;
-extern PFNGLUNIFORM4FVARBPROC glUniform4fvARB;
-extern PFNGLUNIFORM1IVARBPROC glUniform1ivARB;
-extern PFNGLUNIFORM2IVARBPROC glUniform2ivARB;
-extern PFNGLUNIFORM3IVARBPROC glUniform3ivARB;
-extern PFNGLUNIFORM4IVARBPROC glUniform4ivARB;
-extern PFNGLUNIFORMMATRIX2FVARBPROC glUniformMatrix2fvARB;
-extern PFNGLUNIFORMMATRIX3FVARBPROC glUniformMatrix3fvARB;
-extern PFNGLUNIFORMMATRIX4FVARBPROC glUniformMatrix4fvARB;
-extern PFNGLGETOBJECTPARAMETERFVARBPROC glGetObjectParameterfvARB;
-extern PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB;
-extern PFNGLGETINFOLOGARBPROC glGetInfoLogARB;
-extern PFNGLGETATTACHEDOBJECTSARBPROC glGetAttachedObjectsARB;
-extern PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB;
-extern PFNGLGETACTIVEUNIFORMARBPROC glGetActiveUniformARB;
-extern PFNGLGETUNIFORMFVARBPROC glGetUniformfvARB;
-extern PFNGLGETUNIFORMIVARBPROC glGetUniformivARB;
-extern PFNGLGETSHADERSOURCEARBPROC glGetShaderSourceARB;
+extern PFNGLATTACHSHADERPROC glAttachShader;
+extern PFNGLCOMPILESHADERPROC glCompileShader;
+extern PFNGLCREATEPROGRAMPROC glCreateProgram;
+extern PFNGLCREATESHADERPROC glCreateShader;
+extern PFNGLDELETEPROGRAMPROC glDeleteProgram;
+extern PFNGLDELETESHADERPROC glDeleteShader;
+extern PFNGLDETACHSHADERPROC glDetachShader;
+extern PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform;
+extern PFNGLGETATTACHEDSHADERSPROC glGetAttachedShaders;
+extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
+extern PFNGLGETPROGRAMIVPROC glGetProgramiv;
+extern PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog;
+extern PFNGLGETSHADERSOURCEPROC glGetShaderSource;
+extern PFNGLGETSHADERIVPROC glGetShaderiv;
+extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
+extern PFNGLGETUNIFORMFVPROC glGetUniformfv;
+extern PFNGLGETUNIFORMIVPROC glGetUniformiv;
+extern PFNGLLINKPROGRAMPROC glLinkProgram;
+extern PFNGLSHADERSOURCEPROC glShaderSource;
+extern PFNGLUNIFORM1FPROC glUniform1f;
+extern PFNGLUNIFORM1FVPROC glUniform1fv;
+extern PFNGLUNIFORM1IPROC glUniform1i;
+extern PFNGLUNIFORM1IVPROC glUniform1iv;
+extern PFNGLUNIFORM2FPROC glUniform2f;
+extern PFNGLUNIFORM2FVPROC glUniform2fv;
+extern PFNGLUNIFORM2IPROC glUniform2i;
+extern PFNGLUNIFORM2IVPROC glUniform2iv;
+extern PFNGLUNIFORM3FPROC glUniform3f;
+extern PFNGLUNIFORM3FVPROC glUniform3fv;
+extern PFNGLUNIFORM3IPROC glUniform3i;
+extern PFNGLUNIFORM3IVPROC glUniform3iv;
+extern PFNGLUNIFORM4FPROC glUniform4f;
+extern PFNGLUNIFORM4FVPROC glUniform4fv;
+extern PFNGLUNIFORM4IPROC glUniform4i;
+extern PFNGLUNIFORM4IVPROC glUniform4iv;
+extern PFNGLUNIFORMMATRIX2FVPROC glUniformMatrix2fv;
+extern PFNGLUNIFORMMATRIX3FVPROC glUniformMatrix3fv;
+extern PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv;
+extern PFNGLUSEPROGRAMPROC glUseProgram;
+extern PFNGLVALIDATEPROGRAMPROC glValidateProgram;
 
-void init_arb_shader_objects();
+extern Extension ARB_shader_objects;
 
 } // namespace GL
 } // namespace Msp
diff --git a/source/arb_texture_cube_map.cpp b/source/arb_texture_cube_map.cpp
new file mode 100644 (file)
index 0000000..b74993a
--- /dev/null
@@ -0,0 +1,22 @@
+#include "arb_texture_cube_map.h"
+
+namespace Msp {
+namespace GL {
+
+Extension::SupportLevel init_arb_texture_cube_map()
+{
+       if(is_version_at_least(1, 3))
+       {
+               return Extension::CORE;
+       }
+       if(is_supported("GL_ARB_texture_cube_map"))
+       {
+               return Extension::EXTENSION;
+       }
+       return Extension::UNSUPPORTED;
+}
+
+Extension ARB_texture_cube_map("GL_ARB_texture_cube_map", init_arb_texture_cube_map);
+
+} // namespace GL
+} // namespace Msp
diff --git a/source/arb_texture_cube_map.h b/source/arb_texture_cube_map.h
new file mode 100644 (file)
index 0000000..3cde6e7
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef MSP_GL_ARB_TEXTURE_CUBE_MAP_
+#define MSP_GL_ARB_TEXTURE_CUBE_MAP_
+
+#include "extension.h"
+#include "gl.h"
+#include <GL/glext.h>
+
+namespace Msp {
+namespace GL {
+
+extern Extension ARB_texture_cube_map;
+
+} // namespace GL
+} // namespace Msp
+
+#endif
index b788e03686cf3615968e391e8dd77ff3e2c16af0..9b224ffb607343fe01d5d7afb5d6aefe6ea90e24 100644 (file)
@@ -1,31 +1,37 @@
-#include "extension.h"
 #include "arb_uniform_buffer_object.h"
 
 namespace Msp {
 namespace GL {
 
-PFNGLGETUNIFORMINDICESPROC glGetUniformIndices = 0;
-PFNGLGETACTIVEUNIFORMSIVPROC glGetActiveUniformsiv = 0;
+PFNGLBINDBUFFERBASEPROC glBindBufferBase = 0;
+PFNGLBINDBUFFERRANGEPROC glBindBufferRange = 0;
+PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glGetActiveUniformBlockName = 0;
+PFNGLGETACTIVEUNIFORMBLOCKIVPROC glGetActiveUniformBlockiv = 0;
 PFNGLGETACTIVEUNIFORMNAMEPROC glGetActiveUniformName = 0;
+PFNGLGETACTIVEUNIFORMSIVPROC glGetActiveUniformsiv = 0;
 PFNGLGETUNIFORMBLOCKINDEXPROC glGetUniformBlockIndex = 0;
-PFNGLGETACTIVEUNIFORMBLOCKIVPROC glGetActiveUniformBlockiv = 0;
-PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glGetActiveUniformBlockName = 0;
+PFNGLGETUNIFORMINDICESPROC glGetUniformIndices = 0;
 PFNGLUNIFORMBLOCKBINDINGPROC glUniformBlockBinding = 0;
-PFNGLBINDBUFFERBASEPROC glBindBufferBase = 0;
-PFNGLBINDBUFFERRANGEPROC glBindBufferRange = 0;
 
-void init_arb_uniform_buffer_object()
+Extension::SupportLevel init_arb_uniform_buffer_object()
 {
-       glGetUniformIndices = reinterpret_cast<PFNGLGETUNIFORMINDICESPROC>(get_proc_address("glGetUniformIndices"));
-       glGetActiveUniformsiv = reinterpret_cast<PFNGLGETACTIVEUNIFORMSIVPROC>(get_proc_address("glGetActiveUniformsiv"));
-       glGetActiveUniformName = reinterpret_cast<PFNGLGETACTIVEUNIFORMNAMEPROC>(get_proc_address("glGetActiveUniformName"));
-       glGetUniformBlockIndex = reinterpret_cast<PFNGLGETUNIFORMBLOCKINDEXPROC>(get_proc_address("glGetUniformBlockIndex"));
-       glGetActiveUniformBlockiv = reinterpret_cast<PFNGLGETACTIVEUNIFORMBLOCKIVPROC>(get_proc_address("glGetActiveUniformBlockiv"));
-       glGetActiveUniformBlockName = reinterpret_cast<PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC>(get_proc_address("glGetActiveUniformBlockName"));
-       glUniformBlockBinding = reinterpret_cast<PFNGLUNIFORMBLOCKBINDINGPROC>(get_proc_address("glUniformBlockBinding"));
-       glBindBufferBase = reinterpret_cast<PFNGLBINDBUFFERBASEPROC>(get_proc_address("glBindBufferBase"));
-       glBindBufferRange = reinterpret_cast<PFNGLBINDBUFFERRANGEPROC>(get_proc_address("glBindBufferRange"));
+       if(is_version_at_least(3, 0) || is_supported("GL_ARB_uniform_buffer_object"))
+       {
+               glBindBufferBase = reinterpret_cast<PFNGLBINDBUFFERBASEPROC>(get_proc_address("glBindBufferBase"));
+               glBindBufferRange = reinterpret_cast<PFNGLBINDBUFFERRANGEPROC>(get_proc_address("glBindBufferRange"));
+               glGetActiveUniformBlockName = reinterpret_cast<PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC>(get_proc_address("glGetActiveUniformBlockName"));
+               glGetActiveUniformBlockiv = reinterpret_cast<PFNGLGETACTIVEUNIFORMBLOCKIVPROC>(get_proc_address("glGetActiveUniformBlockiv"));
+               glGetActiveUniformName = reinterpret_cast<PFNGLGETACTIVEUNIFORMNAMEPROC>(get_proc_address("glGetActiveUniformName"));
+               glGetActiveUniformsiv = reinterpret_cast<PFNGLGETACTIVEUNIFORMSIVPROC>(get_proc_address("glGetActiveUniformsiv"));
+               glGetUniformBlockIndex = reinterpret_cast<PFNGLGETUNIFORMBLOCKINDEXPROC>(get_proc_address("glGetUniformBlockIndex"));
+               glGetUniformIndices = reinterpret_cast<PFNGLGETUNIFORMINDICESPROC>(get_proc_address("glGetUniformIndices"));
+               glUniformBlockBinding = reinterpret_cast<PFNGLUNIFORMBLOCKBINDINGPROC>(get_proc_address("glUniformBlockBinding"));
+               return Extension::CORE;
+       }
+       return Extension::UNSUPPORTED;
 }
 
+Extension ARB_uniform_buffer_object("GL_ARB_uniform_buffer_object", init_arb_uniform_buffer_object);
+
 } // namespace GL
 } // namespace Msp
index 1b8ced53b508837dd45f8707a91e2ac6d11c65a5..5a259252514bb5d96b43a32179d2ceb21c0fe410 100644 (file)
@@ -1,23 +1,24 @@
 #ifndef MSP_GL_ARB_UNIFORM_BUFFER_OBJECT_
 #define MSP_GL_ARB_UNIFORM_BUFFER_OBJECT_
 
+#include "extension.h"
 #include "gl.h"
 #include <GL/glext.h>
 
 namespace Msp {
 namespace GL {
 
-extern PFNGLGETUNIFORMINDICESPROC glGetUniformIndices;
-extern PFNGLGETACTIVEUNIFORMSIVPROC glGetActiveUniformsiv;
+extern PFNGLBINDBUFFERBASEPROC glBindBufferBase;
+extern PFNGLBINDBUFFERRANGEPROC glBindBufferRange;
+extern PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glGetActiveUniformBlockName;
+extern PFNGLGETACTIVEUNIFORMBLOCKIVPROC glGetActiveUniformBlockiv;
 extern PFNGLGETACTIVEUNIFORMNAMEPROC glGetActiveUniformName;
+extern PFNGLGETACTIVEUNIFORMSIVPROC glGetActiveUniformsiv;
 extern PFNGLGETUNIFORMBLOCKINDEXPROC glGetUniformBlockIndex;
-extern PFNGLGETACTIVEUNIFORMBLOCKIVPROC glGetActiveUniformBlockiv;
-extern PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glGetActiveUniformBlockName;
+extern PFNGLGETUNIFORMINDICESPROC glGetUniformIndices;
 extern PFNGLUNIFORMBLOCKBINDINGPROC glUniformBlockBinding;
-extern PFNGLBINDBUFFERBASEPROC glBindBufferBase;
-extern PFNGLBINDBUFFERRANGEPROC glBindBufferRange;
 
-void init_arb_uniform_buffer_object();
+extern Extension ARB_uniform_buffer_object;
 
 } // namespace GL
 } // namespace Msp
index 66ef40e5d952d9845147091ec4da51a6e1ce3fff..cf623c476221a66ec8cd21e75fd971b9c6a837f4 100644 (file)
@@ -1,35 +1,56 @@
-#include "extension.h"
 #include "arb_vertex_buffer_object.h"
 
 namespace Msp {
 namespace GL {
 
-PFNGLBINDBUFFERARBPROC glBindBufferARB = 0;
-PFNGLDELETEBUFFERSARBPROC glDeleteBuffersARB = 0;
-PFNGLGENBUFFERSARBPROC glGenBuffersARB = 0;
-PFNGLISBUFFERARBPROC glIsBufferARB = 0;
-PFNGLBUFFERDATAARBPROC glBufferDataARB = 0;
-PFNGLBUFFERSUBDATAARBPROC glBufferSubDataARB = 0;
-PFNGLGETBUFFERSUBDATAARBPROC glGetBufferSubDataARB = 0;
-PFNGLMAPBUFFERARBPROC glMapBufferARB = 0;
-PFNGLUNMAPBUFFERARBPROC glUnmapBufferARB = 0;
-PFNGLGETBUFFERPARAMETERIVARBPROC glGetBufferParameterivARB = 0;
-PFNGLGETBUFFERPOINTERVARBPROC glGetBufferPointervARB = 0;
+PFNGLBINDBUFFERPROC glBindBuffer = 0;
+PFNGLBUFFERDATAPROC glBufferData = 0;
+PFNGLBUFFERSUBDATAPROC glBufferSubData = 0;
+PFNGLDELETEBUFFERSPROC glDeleteBuffers = 0;
+PFNGLGENBUFFERSPROC glGenBuffers = 0;
+PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv = 0;
+PFNGLGETBUFFERPOINTERVPROC glGetBufferPointerv = 0;
+PFNGLGETBUFFERSUBDATAPROC glGetBufferSubData = 0;
+PFNGLISBUFFERPROC glIsBuffer = 0;
+PFNGLMAPBUFFERPROC glMapBuffer = 0;
+PFNGLUNMAPBUFFERPROC glUnmapBuffer = 0;
 
-void init_arb_vertex_buffer_object()
+Extension::SupportLevel init_arb_vertex_buffer_object()
 {
-       glBindBufferARB = reinterpret_cast<PFNGLBINDBUFFERARBPROC>(get_proc_address("glBindBufferARB"));
-       glDeleteBuffersARB = reinterpret_cast<PFNGLDELETEBUFFERSARBPROC>(get_proc_address("glDeleteBuffersARB"));
-       glGenBuffersARB = reinterpret_cast<PFNGLGENBUFFERSARBPROC>(get_proc_address("glGenBuffersARB"));
-       glIsBufferARB = reinterpret_cast<PFNGLISBUFFERARBPROC>(get_proc_address("glIsBufferARB"));
-       glBufferDataARB = reinterpret_cast<PFNGLBUFFERDATAARBPROC>(get_proc_address("glBufferDataARB"));
-       glBufferSubDataARB = reinterpret_cast<PFNGLBUFFERSUBDATAARBPROC>(get_proc_address("glBufferSubDataARB"));
-       glGetBufferSubDataARB = reinterpret_cast<PFNGLGETBUFFERSUBDATAARBPROC>(get_proc_address("glGetBufferSubDataARB"));
-       glMapBufferARB = reinterpret_cast<PFNGLMAPBUFFERARBPROC>(get_proc_address("glMapBufferARB"));
-       glUnmapBufferARB = reinterpret_cast<PFNGLUNMAPBUFFERARBPROC>(get_proc_address("glUnmapBufferARB"));
-       glGetBufferParameterivARB = reinterpret_cast<PFNGLGETBUFFERPARAMETERIVARBPROC>(get_proc_address("glGetBufferParameterivARB"));
-       glGetBufferPointervARB = reinterpret_cast<PFNGLGETBUFFERPOINTERVARBPROC>(get_proc_address("glGetBufferPointervARB"));
+       if(is_version_at_least(1, 5))
+       {
+               glBindBuffer = reinterpret_cast<PFNGLBINDBUFFERPROC>(get_proc_address("glBindBuffer"));
+               glBufferData = reinterpret_cast<PFNGLBUFFERDATAPROC>(get_proc_address("glBufferData"));
+               glBufferSubData = reinterpret_cast<PFNGLBUFFERSUBDATAPROC>(get_proc_address("glBufferSubData"));
+               glDeleteBuffers = reinterpret_cast<PFNGLDELETEBUFFERSPROC>(get_proc_address("glDeleteBuffers"));
+               glGenBuffers = reinterpret_cast<PFNGLGENBUFFERSPROC>(get_proc_address("glGenBuffers"));
+               glGetBufferParameteriv = reinterpret_cast<PFNGLGETBUFFERPARAMETERIVPROC>(get_proc_address("glGetBufferParameteriv"));
+               glGetBufferPointerv = reinterpret_cast<PFNGLGETBUFFERPOINTERVPROC>(get_proc_address("glGetBufferPointerv"));
+               glGetBufferSubData = reinterpret_cast<PFNGLGETBUFFERSUBDATAPROC>(get_proc_address("glGetBufferSubData"));
+               glIsBuffer = reinterpret_cast<PFNGLISBUFFERPROC>(get_proc_address("glIsBuffer"));
+               glMapBuffer = reinterpret_cast<PFNGLMAPBUFFERPROC>(get_proc_address("glMapBuffer"));
+               glUnmapBuffer = reinterpret_cast<PFNGLUNMAPBUFFERPROC>(get_proc_address("glUnmapBuffer"));
+               return Extension::CORE;
+       }
+       if(is_supported("GL_ARB_vertex_buffer_object"))
+       {
+               glBindBuffer = reinterpret_cast<PFNGLBINDBUFFERPROC>(get_proc_address("glBindBufferARB"));
+               glBufferData = reinterpret_cast<PFNGLBUFFERDATAPROC>(get_proc_address("glBufferDataARB"));
+               glBufferSubData = reinterpret_cast<PFNGLBUFFERSUBDATAPROC>(get_proc_address("glBufferSubDataARB"));
+               glDeleteBuffers = reinterpret_cast<PFNGLDELETEBUFFERSPROC>(get_proc_address("glDeleteBuffersARB"));
+               glGenBuffers = reinterpret_cast<PFNGLGENBUFFERSPROC>(get_proc_address("glGenBuffersARB"));
+               glGetBufferParameteriv = reinterpret_cast<PFNGLGETBUFFERPARAMETERIVPROC>(get_proc_address("glGetBufferParameterivARB"));
+               glGetBufferPointerv = reinterpret_cast<PFNGLGETBUFFERPOINTERVPROC>(get_proc_address("glGetBufferPointervARB"));
+               glGetBufferSubData = reinterpret_cast<PFNGLGETBUFFERSUBDATAPROC>(get_proc_address("glGetBufferSubDataARB"));
+               glIsBuffer = reinterpret_cast<PFNGLISBUFFERPROC>(get_proc_address("glIsBufferARB"));
+               glMapBuffer = reinterpret_cast<PFNGLMAPBUFFERPROC>(get_proc_address("glMapBufferARB"));
+               glUnmapBuffer = reinterpret_cast<PFNGLUNMAPBUFFERPROC>(get_proc_address("glUnmapBufferARB"));
+               return Extension::EXTENSION;
+       }
+       return Extension::UNSUPPORTED;
 }
 
+Extension ARB_vertex_buffer_object("GL_ARB_vertex_buffer_object", init_arb_vertex_buffer_object);
+
 } // namespace GL
 } // namespace Msp
index 8d3be978b457544f69c6c9dd73b956db20fa8427..1154446d54550b3af8074bccf9be4043c7f7e2b8 100644 (file)
@@ -1,25 +1,26 @@
 #ifndef MSP_GL_ARB_VERTEX_BUFFER_OBJECT_
 #define MSP_GL_ARB_VERTEX_BUFFER_OBJECT_
 
+#include "extension.h"
 #include "gl.h"
 #include <GL/glext.h>
 
 namespace Msp {
 namespace GL {
 
-extern PFNGLBINDBUFFERARBPROC glBindBufferARB;
-extern PFNGLDELETEBUFFERSARBPROC glDeleteBuffersARB;
-extern PFNGLGENBUFFERSARBPROC glGenBuffersARB;
-extern PFNGLISBUFFERARBPROC glIsBufferARB;
-extern PFNGLBUFFERDATAARBPROC glBufferDataARB;
-extern PFNGLBUFFERSUBDATAARBPROC glBufferSubDataARB;
-extern PFNGLGETBUFFERSUBDATAARBPROC glGetBufferSubDataARB;
-extern PFNGLMAPBUFFERARBPROC glMapBufferARB;
-extern PFNGLUNMAPBUFFERARBPROC glUnmapBufferARB;
-extern PFNGLGETBUFFERPARAMETERIVARBPROC glGetBufferParameterivARB;
-extern PFNGLGETBUFFERPOINTERVARBPROC glGetBufferPointervARB;
+extern PFNGLBINDBUFFERPROC glBindBuffer;
+extern PFNGLBUFFERDATAPROC glBufferData;
+extern PFNGLBUFFERSUBDATAPROC glBufferSubData;
+extern PFNGLDELETEBUFFERSPROC glDeleteBuffers;
+extern PFNGLGENBUFFERSPROC glGenBuffers;
+extern PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv;
+extern PFNGLGETBUFFERPOINTERVPROC glGetBufferPointerv;
+extern PFNGLGETBUFFERSUBDATAPROC glGetBufferSubData;
+extern PFNGLISBUFFERPROC glIsBuffer;
+extern PFNGLMAPBUFFERPROC glMapBuffer;
+extern PFNGLUNMAPBUFFERPROC glUnmapBuffer;
 
-void init_arb_vertex_buffer_object();
+extern Extension ARB_vertex_buffer_object;
 
 } // namespace GL
 } // namespace Msp
diff --git a/source/arb_vertex_program.cpp b/source/arb_vertex_program.cpp
deleted file mode 100644 (file)
index 41adaee..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-#include "extension.h"
-#include "arb_vertex_program.h"
-
-namespace Msp {
-namespace GL {
-
-PFNGLVERTEXATTRIB1DARBPROC glVertexAttrib1dARB = 0;
-PFNGLVERTEXATTRIB1DVARBPROC glVertexAttrib1dvARB = 0;
-PFNGLVERTEXATTRIB1FARBPROC glVertexAttrib1fARB = 0;
-PFNGLVERTEXATTRIB1FVARBPROC glVertexAttrib1fvARB = 0;
-PFNGLVERTEXATTRIB1SARBPROC glVertexAttrib1sARB = 0;
-PFNGLVERTEXATTRIB1SVARBPROC glVertexAttrib1svARB = 0;
-PFNGLVERTEXATTRIB2DARBPROC glVertexAttrib2dARB = 0;
-PFNGLVERTEXATTRIB2DVARBPROC glVertexAttrib2dvARB = 0;
-PFNGLVERTEXATTRIB2FARBPROC glVertexAttrib2fARB = 0;
-PFNGLVERTEXATTRIB2FVARBPROC glVertexAttrib2fvARB = 0;
-PFNGLVERTEXATTRIB2SARBPROC glVertexAttrib2sARB = 0;
-PFNGLVERTEXATTRIB2SVARBPROC glVertexAttrib2svARB = 0;
-PFNGLVERTEXATTRIB3DARBPROC glVertexAttrib3dARB = 0;
-PFNGLVERTEXATTRIB3DVARBPROC glVertexAttrib3dvARB = 0;
-PFNGLVERTEXATTRIB3FARBPROC glVertexAttrib3fARB = 0;
-PFNGLVERTEXATTRIB3FVARBPROC glVertexAttrib3fvARB = 0;
-PFNGLVERTEXATTRIB3SARBPROC glVertexAttrib3sARB = 0;
-PFNGLVERTEXATTRIB3SVARBPROC glVertexAttrib3svARB = 0;
-PFNGLVERTEXATTRIB4NBVARBPROC glVertexAttrib4NbvARB = 0;
-PFNGLVERTEXATTRIB4NIVARBPROC glVertexAttrib4NivARB = 0;
-PFNGLVERTEXATTRIB4NSVARBPROC glVertexAttrib4NsvARB = 0;
-PFNGLVERTEXATTRIB4NUBARBPROC glVertexAttrib4NubARB = 0;
-PFNGLVERTEXATTRIB4NUBVARBPROC glVertexAttrib4NubvARB = 0;
-PFNGLVERTEXATTRIB4NUIVARBPROC glVertexAttrib4NuivARB = 0;
-PFNGLVERTEXATTRIB4NUSVARBPROC glVertexAttrib4NusvARB = 0;
-PFNGLVERTEXATTRIB4BVARBPROC glVertexAttrib4bvARB = 0;
-PFNGLVERTEXATTRIB4DARBPROC glVertexAttrib4dARB = 0;
-PFNGLVERTEXATTRIB4DVARBPROC glVertexAttrib4dvARB = 0;
-PFNGLVERTEXATTRIB4FARBPROC glVertexAttrib4fARB = 0;
-PFNGLVERTEXATTRIB4FVARBPROC glVertexAttrib4fvARB = 0;
-PFNGLVERTEXATTRIB4IVARBPROC glVertexAttrib4ivARB = 0;
-PFNGLVERTEXATTRIB4SARBPROC glVertexAttrib4sARB = 0;
-PFNGLVERTEXATTRIB4SVARBPROC glVertexAttrib4svARB = 0;
-PFNGLVERTEXATTRIB4UBVARBPROC glVertexAttrib4ubvARB = 0;
-PFNGLVERTEXATTRIB4UIVARBPROC glVertexAttrib4uivARB = 0;
-PFNGLVERTEXATTRIB4USVARBPROC glVertexAttrib4usvARB = 0;
-PFNGLVERTEXATTRIBPOINTERARBPROC glVertexAttribPointerARB = 0;
-PFNGLENABLEVERTEXATTRIBARRAYARBPROC glEnableVertexAttribArrayARB = 0;
-PFNGLDISABLEVERTEXATTRIBARRAYARBPROC glDisableVertexAttribArrayARB = 0;
-PFNGLPROGRAMSTRINGARBPROC glProgramStringARB = 0;
-PFNGLBINDPROGRAMARBPROC glBindProgramARB = 0;
-PFNGLDELETEPROGRAMSARBPROC glDeleteProgramsARB = 0;
-PFNGLGENPROGRAMSARBPROC glGenProgramsARB = 0;
-PFNGLPROGRAMENVPARAMETER4DARBPROC glProgramEnvParameter4dARB = 0;
-PFNGLPROGRAMENVPARAMETER4DVARBPROC glProgramEnvParameter4dvARB = 0;
-PFNGLPROGRAMENVPARAMETER4FARBPROC glProgramEnvParameter4fARB = 0;
-PFNGLPROGRAMENVPARAMETER4FVARBPROC glProgramEnvParameter4fvARB = 0;
-PFNGLPROGRAMLOCALPARAMETER4DARBPROC glProgramLocalParameter4dARB = 0;
-PFNGLPROGRAMLOCALPARAMETER4DVARBPROC glProgramLocalParameter4dvARB = 0;
-PFNGLPROGRAMLOCALPARAMETER4FARBPROC glProgramLocalParameter4fARB = 0;
-PFNGLPROGRAMLOCALPARAMETER4FVARBPROC glProgramLocalParameter4fvARB = 0;
-PFNGLGETPROGRAMENVPARAMETERDVARBPROC glGetProgramEnvParameterdvARB = 0;
-PFNGLGETPROGRAMENVPARAMETERFVARBPROC glGetProgramEnvParameterfvARB = 0;
-PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC glGetProgramLocalParameterdvARB = 0;
-PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC glGetProgramLocalParameterfvARB = 0;
-PFNGLGETPROGRAMIVARBPROC glGetProgramivARB = 0;
-PFNGLGETPROGRAMSTRINGARBPROC glGetProgramStringARB = 0;
-PFNGLGETVERTEXATTRIBDVARBPROC glGetVertexAttribdvARB = 0;
-PFNGLGETVERTEXATTRIBFVARBPROC glGetVertexAttribfvARB = 0;
-PFNGLGETVERTEXATTRIBIVARBPROC glGetVertexAttribivARB = 0;
-PFNGLGETVERTEXATTRIBPOINTERVARBPROC glGetVertexAttribPointervARB = 0;
-PFNGLISPROGRAMARBPROC glIsProgramARB = 0;
-
-void init_arb_vertex_program()
-{
-       glVertexAttrib1dARB = reinterpret_cast<PFNGLVERTEXATTRIB1DARBPROC>(get_proc_address("glVertexAttrib1dARB"));
-       glVertexAttrib1dvARB = reinterpret_cast<PFNGLVERTEXATTRIB1DVARBPROC>(get_proc_address("glVertexAttrib1dvARB"));
-       glVertexAttrib1fARB = reinterpret_cast<PFNGLVERTEXATTRIB1FARBPROC>(get_proc_address("glVertexAttrib1fARB"));
-       glVertexAttrib1fvARB = reinterpret_cast<PFNGLVERTEXATTRIB1FVARBPROC>(get_proc_address("glVertexAttrib1fvARB"));
-       glVertexAttrib1sARB = reinterpret_cast<PFNGLVERTEXATTRIB1SARBPROC>(get_proc_address("glVertexAttrib1sARB"));
-       glVertexAttrib1svARB = reinterpret_cast<PFNGLVERTEXATTRIB1SVARBPROC>(get_proc_address("glVertexAttrib1svARB"));
-       glVertexAttrib2dARB = reinterpret_cast<PFNGLVERTEXATTRIB2DARBPROC>(get_proc_address("glVertexAttrib2dARB"));
-       glVertexAttrib2dvARB = reinterpret_cast<PFNGLVERTEXATTRIB2DVARBPROC>(get_proc_address("glVertexAttrib2dvARB"));
-       glVertexAttrib2fARB = reinterpret_cast<PFNGLVERTEXATTRIB2FARBPROC>(get_proc_address("glVertexAttrib2fARB"));
-       glVertexAttrib2fvARB = reinterpret_cast<PFNGLVERTEXATTRIB2FVARBPROC>(get_proc_address("glVertexAttrib2fvARB"));
-       glVertexAttrib2sARB = reinterpret_cast<PFNGLVERTEXATTRIB2SARBPROC>(get_proc_address("glVertexAttrib2sARB"));
-       glVertexAttrib2svARB = reinterpret_cast<PFNGLVERTEXATTRIB2SVARBPROC>(get_proc_address("glVertexAttrib2svARB"));
-       glVertexAttrib3dARB = reinterpret_cast<PFNGLVERTEXATTRIB3DARBPROC>(get_proc_address("glVertexAttrib3dARB"));
-       glVertexAttrib3dvARB = reinterpret_cast<PFNGLVERTEXATTRIB3DVARBPROC>(get_proc_address("glVertexAttrib3dvARB"));
-       glVertexAttrib3fARB = reinterpret_cast<PFNGLVERTEXATTRIB3FARBPROC>(get_proc_address("glVertexAttrib3fARB"));
-       glVertexAttrib3fvARB = reinterpret_cast<PFNGLVERTEXATTRIB3FVARBPROC>(get_proc_address("glVertexAttrib3fvARB"));
-       glVertexAttrib3sARB = reinterpret_cast<PFNGLVERTEXATTRIB3SARBPROC>(get_proc_address("glVertexAttrib3sARB"));
-       glVertexAttrib3svARB = reinterpret_cast<PFNGLVERTEXATTRIB3SVARBPROC>(get_proc_address("glVertexAttrib3svARB"));
-       glVertexAttrib4NbvARB = reinterpret_cast<PFNGLVERTEXATTRIB4NBVARBPROC>(get_proc_address("glVertexAttrib4NbvARB"));
-       glVertexAttrib4NivARB = reinterpret_cast<PFNGLVERTEXATTRIB4NIVARBPROC>(get_proc_address("glVertexAttrib4NivARB"));
-       glVertexAttrib4NsvARB = reinterpret_cast<PFNGLVERTEXATTRIB4NSVARBPROC>(get_proc_address("glVertexAttrib4NsvARB"));
-       glVertexAttrib4NubARB = reinterpret_cast<PFNGLVERTEXATTRIB4NUBARBPROC>(get_proc_address("glVertexAttrib4NubARB"));
-       glVertexAttrib4NubvARB = reinterpret_cast<PFNGLVERTEXATTRIB4NUBVARBPROC>(get_proc_address("glVertexAttrib4NubvARB"));
-       glVertexAttrib4NuivARB = reinterpret_cast<PFNGLVERTEXATTRIB4NUIVARBPROC>(get_proc_address("glVertexAttrib4NuivARB"));
-       glVertexAttrib4NusvARB = reinterpret_cast<PFNGLVERTEXATTRIB4NUSVARBPROC>(get_proc_address("glVertexAttrib4NusvARB"));
-       glVertexAttrib4bvARB = reinterpret_cast<PFNGLVERTEXATTRIB4BVARBPROC>(get_proc_address("glVertexAttrib4bvARB"));
-       glVertexAttrib4dARB = reinterpret_cast<PFNGLVERTEXATTRIB4DARBPROC>(get_proc_address("glVertexAttrib4dARB"));
-       glVertexAttrib4dvARB = reinterpret_cast<PFNGLVERTEXATTRIB4DVARBPROC>(get_proc_address("glVertexAttrib4dvARB"));
-       glVertexAttrib4fARB = reinterpret_cast<PFNGLVERTEXATTRIB4FARBPROC>(get_proc_address("glVertexAttrib4fARB"));
-       glVertexAttrib4fvARB = reinterpret_cast<PFNGLVERTEXATTRIB4FVARBPROC>(get_proc_address("glVertexAttrib4fvARB"));
-       glVertexAttrib4ivARB = reinterpret_cast<PFNGLVERTEXATTRIB4IVARBPROC>(get_proc_address("glVertexAttrib4ivARB"));
-       glVertexAttrib4sARB = reinterpret_cast<PFNGLVERTEXATTRIB4SARBPROC>(get_proc_address("glVertexAttrib4sARB"));
-       glVertexAttrib4svARB = reinterpret_cast<PFNGLVERTEXATTRIB4SVARBPROC>(get_proc_address("glVertexAttrib4svARB"));
-       glVertexAttrib4ubvARB = reinterpret_cast<PFNGLVERTEXATTRIB4UBVARBPROC>(get_proc_address("glVertexAttrib4ubvARB"));
-       glVertexAttrib4uivARB = reinterpret_cast<PFNGLVERTEXATTRIB4UIVARBPROC>(get_proc_address("glVertexAttrib4uivARB"));
-       glVertexAttrib4usvARB = reinterpret_cast<PFNGLVERTEXATTRIB4USVARBPROC>(get_proc_address("glVertexAttrib4usvARB"));
-       glVertexAttribPointerARB = reinterpret_cast<PFNGLVERTEXATTRIBPOINTERARBPROC>(get_proc_address("glVertexAttribPointerARB"));
-       glEnableVertexAttribArrayARB = reinterpret_cast<PFNGLENABLEVERTEXATTRIBARRAYARBPROC>(get_proc_address("glEnableVertexAttribArrayARB"));
-       glDisableVertexAttribArrayARB = reinterpret_cast<PFNGLDISABLEVERTEXATTRIBARRAYARBPROC>(get_proc_address("glDisableVertexAttribArrayARB"));
-       glProgramStringARB = reinterpret_cast<PFNGLPROGRAMSTRINGARBPROC>(get_proc_address("glProgramStringARB"));
-       glBindProgramARB = reinterpret_cast<PFNGLBINDPROGRAMARBPROC>(get_proc_address("glBindProgramARB"));
-       glDeleteProgramsARB = reinterpret_cast<PFNGLDELETEPROGRAMSARBPROC>(get_proc_address("glDeleteProgramsARB"));
-       glGenProgramsARB = reinterpret_cast<PFNGLGENPROGRAMSARBPROC>(get_proc_address("glGenProgramsARB"));
-       glProgramEnvParameter4dARB = reinterpret_cast<PFNGLPROGRAMENVPARAMETER4DARBPROC>(get_proc_address("glProgramEnvParameter4dARB"));
-       glProgramEnvParameter4dvARB = reinterpret_cast<PFNGLPROGRAMENVPARAMETER4DVARBPROC>(get_proc_address("glProgramEnvParameter4dvARB"));
-       glProgramEnvParameter4fARB = reinterpret_cast<PFNGLPROGRAMENVPARAMETER4FARBPROC>(get_proc_address("glProgramEnvParameter4fARB"));
-       glProgramEnvParameter4fvARB = reinterpret_cast<PFNGLPROGRAMENVPARAMETER4FVARBPROC>(get_proc_address("glProgramEnvParameter4fvARB"));
-       glProgramLocalParameter4dARB = reinterpret_cast<PFNGLPROGRAMLOCALPARAMETER4DARBPROC>(get_proc_address("glProgramLocalParameter4dARB"));
-       glProgramLocalParameter4dvARB = reinterpret_cast<PFNGLPROGRAMLOCALPARAMETER4DVARBPROC>(get_proc_address("glProgramLocalParameter4dvARB"));
-       glProgramLocalParameter4fARB = reinterpret_cast<PFNGLPROGRAMLOCALPARAMETER4FARBPROC>(get_proc_address("glProgramLocalParameter4fARB"));
-       glProgramLocalParameter4fvARB = reinterpret_cast<PFNGLPROGRAMLOCALPARAMETER4FVARBPROC>(get_proc_address("glProgramLocalParameter4fvARB"));
-       glGetProgramEnvParameterdvARB = reinterpret_cast<PFNGLGETPROGRAMENVPARAMETERDVARBPROC>(get_proc_address("glGetProgramEnvParameterdvARB"));
-       glGetProgramEnvParameterfvARB = reinterpret_cast<PFNGLGETPROGRAMENVPARAMETERFVARBPROC>(get_proc_address("glGetProgramEnvParameterfvARB"));
-       glGetProgramLocalParameterdvARB = reinterpret_cast<PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC>(get_proc_address("glGetProgramLocalParameterdvARB"));
-       glGetProgramLocalParameterfvARB = reinterpret_cast<PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC>(get_proc_address("glGetProgramLocalParameterfvARB"));
-       glGetProgramivARB = reinterpret_cast<PFNGLGETPROGRAMIVARBPROC>(get_proc_address("glGetProgramivARB"));
-       glGetProgramStringARB = reinterpret_cast<PFNGLGETPROGRAMSTRINGARBPROC>(get_proc_address("glGetProgramStringARB"));
-       glGetVertexAttribdvARB = reinterpret_cast<PFNGLGETVERTEXATTRIBDVARBPROC>(get_proc_address("glGetVertexAttribdvARB"));
-       glGetVertexAttribfvARB = reinterpret_cast<PFNGLGETVERTEXATTRIBFVARBPROC>(get_proc_address("glGetVertexAttribfvARB"));
-       glGetVertexAttribivARB = reinterpret_cast<PFNGLGETVERTEXATTRIBIVARBPROC>(get_proc_address("glGetVertexAttribivARB"));
-       glGetVertexAttribPointervARB = reinterpret_cast<PFNGLGETVERTEXATTRIBPOINTERVARBPROC>(get_proc_address("glGetVertexAttribPointervARB"));
-       glIsProgramARB = reinterpret_cast<PFNGLISPROGRAMARBPROC>(get_proc_address("glIsProgramARB"));
-}
-
-} // namespace GL
-} // namespace Msp
diff --git a/source/arb_vertex_program.h b/source/arb_vertex_program.h
deleted file mode 100644 (file)
index a4c8dd0..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-#ifndef MSP_GL_ARB_VERTEX_PROGRAM_
-#define MSP_GL_ARB_VERTEX_PROGRAM_
-
-#include "gl.h"
-#include <GL/glext.h>
-
-namespace Msp {
-namespace GL {
-
-extern PFNGLVERTEXATTRIB1DARBPROC glVertexAttrib1dARB;
-extern PFNGLVERTEXATTRIB1DVARBPROC glVertexAttrib1dvARB;
-extern PFNGLVERTEXATTRIB1FARBPROC glVertexAttrib1fARB;
-extern PFNGLVERTEXATTRIB1FVARBPROC glVertexAttrib1fvARB;
-extern PFNGLVERTEXATTRIB1SARBPROC glVertexAttrib1sARB;
-extern PFNGLVERTEXATTRIB1SVARBPROC glVertexAttrib1svARB;
-extern PFNGLVERTEXATTRIB2DARBPROC glVertexAttrib2dARB;
-extern PFNGLVERTEXATTRIB2DVARBPROC glVertexAttrib2dvARB;
-extern PFNGLVERTEXATTRIB2FARBPROC glVertexAttrib2fARB;
-extern PFNGLVERTEXATTRIB2FVARBPROC glVertexAttrib2fvARB;
-extern PFNGLVERTEXATTRIB2SARBPROC glVertexAttrib2sARB;
-extern PFNGLVERTEXATTRIB2SVARBPROC glVertexAttrib2svARB;
-extern PFNGLVERTEXATTRIB3DARBPROC glVertexAttrib3dARB;
-extern PFNGLVERTEXATTRIB3DVARBPROC glVertexAttrib3dvARB;
-extern PFNGLVERTEXATTRIB3FARBPROC glVertexAttrib3fARB;
-extern PFNGLVERTEXATTRIB3FVARBPROC glVertexAttrib3fvARB;
-extern PFNGLVERTEXATTRIB3SARBPROC glVertexAttrib3sARB;
-extern PFNGLVERTEXATTRIB3SVARBPROC glVertexAttrib3svARB;
-extern PFNGLVERTEXATTRIB4NBVARBPROC glVertexAttrib4NbvARB;
-extern PFNGLVERTEXATTRIB4NIVARBPROC glVertexAttrib4NivARB;
-extern PFNGLVERTEXATTRIB4NSVARBPROC glVertexAttrib4NsvARB;
-extern PFNGLVERTEXATTRIB4NUBARBPROC glVertexAttrib4NubARB;
-extern PFNGLVERTEXATTRIB4NUBVARBPROC glVertexAttrib4NubvARB;
-extern PFNGLVERTEXATTRIB4NUIVARBPROC glVertexAttrib4NuivARB;
-extern PFNGLVERTEXATTRIB4NUSVARBPROC glVertexAttrib4NusvARB;
-extern PFNGLVERTEXATTRIB4BVARBPROC glVertexAttrib4bvARB;
-extern PFNGLVERTEXATTRIB4DARBPROC glVertexAttrib4dARB;
-extern PFNGLVERTEXATTRIB4DVARBPROC glVertexAttrib4dvARB;
-extern PFNGLVERTEXATTRIB4FARBPROC glVertexAttrib4fARB;
-extern PFNGLVERTEXATTRIB4FVARBPROC glVertexAttrib4fvARB;
-extern PFNGLVERTEXATTRIB4IVARBPROC glVertexAttrib4ivARB;
-extern PFNGLVERTEXATTRIB4SARBPROC glVertexAttrib4sARB;
-extern PFNGLVERTEXATTRIB4SVARBPROC glVertexAttrib4svARB;
-extern PFNGLVERTEXATTRIB4UBVARBPROC glVertexAttrib4ubvARB;
-extern PFNGLVERTEXATTRIB4UIVARBPROC glVertexAttrib4uivARB;
-extern PFNGLVERTEXATTRIB4USVARBPROC glVertexAttrib4usvARB;
-extern PFNGLVERTEXATTRIBPOINTERARBPROC glVertexAttribPointerARB;
-extern PFNGLENABLEVERTEXATTRIBARRAYARBPROC glEnableVertexAttribArrayARB;
-extern PFNGLDISABLEVERTEXATTRIBARRAYARBPROC glDisableVertexAttribArrayARB;
-extern PFNGLPROGRAMSTRINGARBPROC glProgramStringARB;
-extern PFNGLBINDPROGRAMARBPROC glBindProgramARB;
-extern PFNGLDELETEPROGRAMSARBPROC glDeleteProgramsARB;
-extern PFNGLGENPROGRAMSARBPROC glGenProgramsARB;
-extern PFNGLPROGRAMENVPARAMETER4DARBPROC glProgramEnvParameter4dARB;
-extern PFNGLPROGRAMENVPARAMETER4DVARBPROC glProgramEnvParameter4dvARB;
-extern PFNGLPROGRAMENVPARAMETER4FARBPROC glProgramEnvParameter4fARB;
-extern PFNGLPROGRAMENVPARAMETER4FVARBPROC glProgramEnvParameter4fvARB;
-extern PFNGLPROGRAMLOCALPARAMETER4DARBPROC glProgramLocalParameter4dARB;
-extern PFNGLPROGRAMLOCALPARAMETER4DVARBPROC glProgramLocalParameter4dvARB;
-extern PFNGLPROGRAMLOCALPARAMETER4FARBPROC glProgramLocalParameter4fARB;
-extern PFNGLPROGRAMLOCALPARAMETER4FVARBPROC glProgramLocalParameter4fvARB;
-extern PFNGLGETPROGRAMENVPARAMETERDVARBPROC glGetProgramEnvParameterdvARB;
-extern PFNGLGETPROGRAMENVPARAMETERFVARBPROC glGetProgramEnvParameterfvARB;
-extern PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC glGetProgramLocalParameterdvARB;
-extern PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC glGetProgramLocalParameterfvARB;
-extern PFNGLGETPROGRAMIVARBPROC glGetProgramivARB;
-extern PFNGLGETPROGRAMSTRINGARBPROC glGetProgramStringARB;
-extern PFNGLGETVERTEXATTRIBDVARBPROC glGetVertexAttribdvARB;
-extern PFNGLGETVERTEXATTRIBFVARBPROC glGetVertexAttribfvARB;
-extern PFNGLGETVERTEXATTRIBIVARBPROC glGetVertexAttribivARB;
-extern PFNGLGETVERTEXATTRIBPOINTERVARBPROC glGetVertexAttribPointervARB;
-extern PFNGLISPROGRAMARBPROC glIsProgramARB;
-
-void init_arb_vertex_program();
-
-} // namespace GL
-} // namespace Msp
-
-#endif
index 612c5033fe0fe2fd50c4ecc00ef1b77b705cad67..918c131607bdd017829ce031c4e943614fce6a70 100644 (file)
-#include "extension.h"
 #include "arb_vertex_shader.h"
 
 namespace Msp {
 namespace GL {
 
-PFNGLBINDATTRIBLOCATIONARBPROC glBindAttribLocationARB = 0;
-PFNGLGETACTIVEATTRIBARBPROC glGetActiveAttribARB = 0;
-PFNGLGETATTRIBLOCATIONARBPROC glGetAttribLocationARB = 0;
+PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation = 0;
+PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray = 0;
+PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray = 0;
+PFNGLGETACTIVEATTRIBPROC glGetActiveAttrib = 0;
+PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation = 0;
+PFNGLGETVERTEXATTRIBPOINTERVPROC glGetVertexAttribPointerv = 0;
+PFNGLGETVERTEXATTRIBDVPROC glGetVertexAttribdv = 0;
+PFNGLGETVERTEXATTRIBFVPROC glGetVertexAttribfv = 0;
+PFNGLGETVERTEXATTRIBIVPROC glGetVertexAttribiv = 0;
+PFNGLVERTEXATTRIB1DPROC glVertexAttrib1d = 0;
+PFNGLVERTEXATTRIB1DVPROC glVertexAttrib1dv = 0;
+PFNGLVERTEXATTRIB1FPROC glVertexAttrib1f = 0;
+PFNGLVERTEXATTRIB1FVPROC glVertexAttrib1fv = 0;
+PFNGLVERTEXATTRIB1SPROC glVertexAttrib1s = 0;
+PFNGLVERTEXATTRIB1SVPROC glVertexAttrib1sv = 0;
+PFNGLVERTEXATTRIB2DPROC glVertexAttrib2d = 0;
+PFNGLVERTEXATTRIB2DVPROC glVertexAttrib2dv = 0;
+PFNGLVERTEXATTRIB2FPROC glVertexAttrib2f = 0;
+PFNGLVERTEXATTRIB2FVPROC glVertexAttrib2fv = 0;
+PFNGLVERTEXATTRIB2SPROC glVertexAttrib2s = 0;
+PFNGLVERTEXATTRIB2SVPROC glVertexAttrib2sv = 0;
+PFNGLVERTEXATTRIB3DPROC glVertexAttrib3d = 0;
+PFNGLVERTEXATTRIB3DVPROC glVertexAttrib3dv = 0;
+PFNGLVERTEXATTRIB3FPROC glVertexAttrib3f = 0;
+PFNGLVERTEXATTRIB3FVPROC glVertexAttrib3fv = 0;
+PFNGLVERTEXATTRIB3SPROC glVertexAttrib3s = 0;
+PFNGLVERTEXATTRIB3SVPROC glVertexAttrib3sv = 0;
+PFNGLVERTEXATTRIB4NBVPROC glVertexAttrib4Nbv = 0;
+PFNGLVERTEXATTRIB4NIVPROC glVertexAttrib4Niv = 0;
+PFNGLVERTEXATTRIB4NSVPROC glVertexAttrib4Nsv = 0;
+PFNGLVERTEXATTRIB4NUBPROC glVertexAttrib4Nub = 0;
+PFNGLVERTEXATTRIB4NUBVPROC glVertexAttrib4Nubv = 0;
+PFNGLVERTEXATTRIB4NUIVPROC glVertexAttrib4Nuiv = 0;
+PFNGLVERTEXATTRIB4NUSVPROC glVertexAttrib4Nusv = 0;
+PFNGLVERTEXATTRIB4BVPROC glVertexAttrib4bv = 0;
+PFNGLVERTEXATTRIB4DPROC glVertexAttrib4d = 0;
+PFNGLVERTEXATTRIB4DVPROC glVertexAttrib4dv = 0;
+PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f = 0;
+PFNGLVERTEXATTRIB4FVPROC glVertexAttrib4fv = 0;
+PFNGLVERTEXATTRIB4IVPROC glVertexAttrib4iv = 0;
+PFNGLVERTEXATTRIB4SPROC glVertexAttrib4s = 0;
+PFNGLVERTEXATTRIB4SVPROC glVertexAttrib4sv = 0;
+PFNGLVERTEXATTRIB4UBVPROC glVertexAttrib4ubv = 0;
+PFNGLVERTEXATTRIB4UIVPROC glVertexAttrib4uiv = 0;
+PFNGLVERTEXATTRIB4USVPROC glVertexAttrib4usv = 0;
+PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer = 0;
 
-void init_arb_vertex_shader()
+Extension::SupportLevel init_arb_vertex_shader()
 {
-       glBindAttribLocationARB = reinterpret_cast<PFNGLBINDATTRIBLOCATIONARBPROC>(get_proc_address("glBindAttribLocationARB"));
-       glGetActiveAttribARB = reinterpret_cast<PFNGLGETACTIVEATTRIBARBPROC>(get_proc_address("glGetActiveAttribARB"));
-       glGetAttribLocationARB = reinterpret_cast<PFNGLGETATTRIBLOCATIONARBPROC>(get_proc_address("glGetAttribLocationARB"));
+       if(is_version_at_least(2, 0))
+       {
+               glBindAttribLocation = reinterpret_cast<PFNGLBINDATTRIBLOCATIONPROC>(get_proc_address("glBindAttribLocation"));
+               glDisableVertexAttribArray = reinterpret_cast<PFNGLDISABLEVERTEXATTRIBARRAYPROC>(get_proc_address("glDisableVertexAttribArray"));
+               glEnableVertexAttribArray = reinterpret_cast<PFNGLENABLEVERTEXATTRIBARRAYPROC>(get_proc_address("glEnableVertexAttribArray"));
+               glGetActiveAttrib = reinterpret_cast<PFNGLGETACTIVEATTRIBPROC>(get_proc_address("glGetActiveAttrib"));
+               glGetAttribLocation = reinterpret_cast<PFNGLGETATTRIBLOCATIONPROC>(get_proc_address("glGetAttribLocation"));
+               glGetVertexAttribPointerv = reinterpret_cast<PFNGLGETVERTEXATTRIBPOINTERVPROC>(get_proc_address("glGetVertexAttribPointerv"));
+               glGetVertexAttribdv = reinterpret_cast<PFNGLGETVERTEXATTRIBDVPROC>(get_proc_address("glGetVertexAttribdv"));
+               glGetVertexAttribfv = reinterpret_cast<PFNGLGETVERTEXATTRIBFVPROC>(get_proc_address("glGetVertexAttribfv"));
+               glGetVertexAttribiv = reinterpret_cast<PFNGLGETVERTEXATTRIBIVPROC>(get_proc_address("glGetVertexAttribiv"));
+               glVertexAttrib1d = reinterpret_cast<PFNGLVERTEXATTRIB1DPROC>(get_proc_address("glVertexAttrib1d"));
+               glVertexAttrib1dv = reinterpret_cast<PFNGLVERTEXATTRIB1DVPROC>(get_proc_address("glVertexAttrib1dv"));
+               glVertexAttrib1f = reinterpret_cast<PFNGLVERTEXATTRIB1FPROC>(get_proc_address("glVertexAttrib1f"));
+               glVertexAttrib1fv = reinterpret_cast<PFNGLVERTEXATTRIB1FVPROC>(get_proc_address("glVertexAttrib1fv"));
+               glVertexAttrib1s = reinterpret_cast<PFNGLVERTEXATTRIB1SPROC>(get_proc_address("glVertexAttrib1s"));
+               glVertexAttrib1sv = reinterpret_cast<PFNGLVERTEXATTRIB1SVPROC>(get_proc_address("glVertexAttrib1sv"));
+               glVertexAttrib2d = reinterpret_cast<PFNGLVERTEXATTRIB2DPROC>(get_proc_address("glVertexAttrib2d"));
+               glVertexAttrib2dv = reinterpret_cast<PFNGLVERTEXATTRIB2DVPROC>(get_proc_address("glVertexAttrib2dv"));
+               glVertexAttrib2f = reinterpret_cast<PFNGLVERTEXATTRIB2FPROC>(get_proc_address("glVertexAttrib2f"));
+               glVertexAttrib2fv = reinterpret_cast<PFNGLVERTEXATTRIB2FVPROC>(get_proc_address("glVertexAttrib2fv"));
+               glVertexAttrib2s = reinterpret_cast<PFNGLVERTEXATTRIB2SPROC>(get_proc_address("glVertexAttrib2s"));
+               glVertexAttrib2sv = reinterpret_cast<PFNGLVERTEXATTRIB2SVPROC>(get_proc_address("glVertexAttrib2sv"));
+               glVertexAttrib3d = reinterpret_cast<PFNGLVERTEXATTRIB3DPROC>(get_proc_address("glVertexAttrib3d"));
+               glVertexAttrib3dv = reinterpret_cast<PFNGLVERTEXATTRIB3DVPROC>(get_proc_address("glVertexAttrib3dv"));
+               glVertexAttrib3f = reinterpret_cast<PFNGLVERTEXATTRIB3FPROC>(get_proc_address("glVertexAttrib3f"));
+               glVertexAttrib3fv = reinterpret_cast<PFNGLVERTEXATTRIB3FVPROC>(get_proc_address("glVertexAttrib3fv"));
+               glVertexAttrib3s = reinterpret_cast<PFNGLVERTEXATTRIB3SPROC>(get_proc_address("glVertexAttrib3s"));
+               glVertexAttrib3sv = reinterpret_cast<PFNGLVERTEXATTRIB3SVPROC>(get_proc_address("glVertexAttrib3sv"));
+               glVertexAttrib4Nbv = reinterpret_cast<PFNGLVERTEXATTRIB4NBVPROC>(get_proc_address("glVertexAttrib4Nbv"));
+               glVertexAttrib4Niv = reinterpret_cast<PFNGLVERTEXATTRIB4NIVPROC>(get_proc_address("glVertexAttrib4Niv"));
+               glVertexAttrib4Nsv = reinterpret_cast<PFNGLVERTEXATTRIB4NSVPROC>(get_proc_address("glVertexAttrib4Nsv"));
+               glVertexAttrib4Nub = reinterpret_cast<PFNGLVERTEXATTRIB4NUBPROC>(get_proc_address("glVertexAttrib4Nub"));
+               glVertexAttrib4Nubv = reinterpret_cast<PFNGLVERTEXATTRIB4NUBVPROC>(get_proc_address("glVertexAttrib4Nubv"));
+               glVertexAttrib4Nuiv = reinterpret_cast<PFNGLVERTEXATTRIB4NUIVPROC>(get_proc_address("glVertexAttrib4Nuiv"));
+               glVertexAttrib4Nusv = reinterpret_cast<PFNGLVERTEXATTRIB4NUSVPROC>(get_proc_address("glVertexAttrib4Nusv"));
+               glVertexAttrib4bv = reinterpret_cast<PFNGLVERTEXATTRIB4BVPROC>(get_proc_address("glVertexAttrib4bv"));
+               glVertexAttrib4d = reinterpret_cast<PFNGLVERTEXATTRIB4DPROC>(get_proc_address("glVertexAttrib4d"));
+               glVertexAttrib4dv = reinterpret_cast<PFNGLVERTEXATTRIB4DVPROC>(get_proc_address("glVertexAttrib4dv"));
+               glVertexAttrib4f = reinterpret_cast<PFNGLVERTEXATTRIB4FPROC>(get_proc_address("glVertexAttrib4f"));
+               glVertexAttrib4fv = reinterpret_cast<PFNGLVERTEXATTRIB4FVPROC>(get_proc_address("glVertexAttrib4fv"));
+               glVertexAttrib4iv = reinterpret_cast<PFNGLVERTEXATTRIB4IVPROC>(get_proc_address("glVertexAttrib4iv"));
+               glVertexAttrib4s = reinterpret_cast<PFNGLVERTEXATTRIB4SPROC>(get_proc_address("glVertexAttrib4s"));
+               glVertexAttrib4sv = reinterpret_cast<PFNGLVERTEXATTRIB4SVPROC>(get_proc_address("glVertexAttrib4sv"));
+               glVertexAttrib4ubv = reinterpret_cast<PFNGLVERTEXATTRIB4UBVPROC>(get_proc_address("glVertexAttrib4ubv"));
+               glVertexAttrib4uiv = reinterpret_cast<PFNGLVERTEXATTRIB4UIVPROC>(get_proc_address("glVertexAttrib4uiv"));
+               glVertexAttrib4usv = reinterpret_cast<PFNGLVERTEXATTRIB4USVPROC>(get_proc_address("glVertexAttrib4usv"));
+               glVertexAttribPointer = reinterpret_cast<PFNGLVERTEXATTRIBPOINTERPROC>(get_proc_address("glVertexAttribPointer"));
+               return Extension::CORE;
+       }
+       if(is_supported("GL_ARB_vertex_shader"))
+       {
+               glBindAttribLocation = reinterpret_cast<PFNGLBINDATTRIBLOCATIONPROC>(get_proc_address("glBindAttribLocationARB"));
+               glDisableVertexAttribArray = reinterpret_cast<PFNGLDISABLEVERTEXATTRIBARRAYPROC>(get_proc_address("glDisableVertexAttribArrayARB"));
+               glEnableVertexAttribArray = reinterpret_cast<PFNGLENABLEVERTEXATTRIBARRAYPROC>(get_proc_address("glEnableVertexAttribArrayARB"));
+               glGetActiveAttrib = reinterpret_cast<PFNGLGETACTIVEATTRIBPROC>(get_proc_address("glGetActiveAttribARB"));
+               glGetAttribLocation = reinterpret_cast<PFNGLGETATTRIBLOCATIONPROC>(get_proc_address("glGetAttribLocationARB"));
+               glGetVertexAttribPointerv = reinterpret_cast<PFNGLGETVERTEXATTRIBPOINTERVPROC>(get_proc_address("glGetVertexAttribPointervARB"));
+               glGetVertexAttribdv = reinterpret_cast<PFNGLGETVERTEXATTRIBDVPROC>(get_proc_address("glGetVertexAttribdvARB"));
+               glGetVertexAttribfv = reinterpret_cast<PFNGLGETVERTEXATTRIBFVPROC>(get_proc_address("glGetVertexAttribfvARB"));
+               glGetVertexAttribiv = reinterpret_cast<PFNGLGETVERTEXATTRIBIVPROC>(get_proc_address("glGetVertexAttribivARB"));
+               glVertexAttrib1d = reinterpret_cast<PFNGLVERTEXATTRIB1DPROC>(get_proc_address("glVertexAttrib1dARB"));
+               glVertexAttrib1dv = reinterpret_cast<PFNGLVERTEXATTRIB1DVPROC>(get_proc_address("glVertexAttrib1dvARB"));
+               glVertexAttrib1f = reinterpret_cast<PFNGLVERTEXATTRIB1FPROC>(get_proc_address("glVertexAttrib1fARB"));
+               glVertexAttrib1fv = reinterpret_cast<PFNGLVERTEXATTRIB1FVPROC>(get_proc_address("glVertexAttrib1fvARB"));
+               glVertexAttrib1s = reinterpret_cast<PFNGLVERTEXATTRIB1SPROC>(get_proc_address("glVertexAttrib1sARB"));
+               glVertexAttrib1sv = reinterpret_cast<PFNGLVERTEXATTRIB1SVPROC>(get_proc_address("glVertexAttrib1svARB"));
+               glVertexAttrib2d = reinterpret_cast<PFNGLVERTEXATTRIB2DPROC>(get_proc_address("glVertexAttrib2dARB"));
+               glVertexAttrib2dv = reinterpret_cast<PFNGLVERTEXATTRIB2DVPROC>(get_proc_address("glVertexAttrib2dvARB"));
+               glVertexAttrib2f = reinterpret_cast<PFNGLVERTEXATTRIB2FPROC>(get_proc_address("glVertexAttrib2fARB"));
+               glVertexAttrib2fv = reinterpret_cast<PFNGLVERTEXATTRIB2FVPROC>(get_proc_address("glVertexAttrib2fvARB"));
+               glVertexAttrib2s = reinterpret_cast<PFNGLVERTEXATTRIB2SPROC>(get_proc_address("glVertexAttrib2sARB"));
+               glVertexAttrib2sv = reinterpret_cast<PFNGLVERTEXATTRIB2SVPROC>(get_proc_address("glVertexAttrib2svARB"));
+               glVertexAttrib3d = reinterpret_cast<PFNGLVERTEXATTRIB3DPROC>(get_proc_address("glVertexAttrib3dARB"));
+               glVertexAttrib3dv = reinterpret_cast<PFNGLVERTEXATTRIB3DVPROC>(get_proc_address("glVertexAttrib3dvARB"));
+               glVertexAttrib3f = reinterpret_cast<PFNGLVERTEXATTRIB3FPROC>(get_proc_address("glVertexAttrib3fARB"));
+               glVertexAttrib3fv = reinterpret_cast<PFNGLVERTEXATTRIB3FVPROC>(get_proc_address("glVertexAttrib3fvARB"));
+               glVertexAttrib3s = reinterpret_cast<PFNGLVERTEXATTRIB3SPROC>(get_proc_address("glVertexAttrib3sARB"));
+               glVertexAttrib3sv = reinterpret_cast<PFNGLVERTEXATTRIB3SVPROC>(get_proc_address("glVertexAttrib3svARB"));
+               glVertexAttrib4Nbv = reinterpret_cast<PFNGLVERTEXATTRIB4NBVPROC>(get_proc_address("glVertexAttrib4NbvARB"));
+               glVertexAttrib4Niv = reinterpret_cast<PFNGLVERTEXATTRIB4NIVPROC>(get_proc_address("glVertexAttrib4NivARB"));
+               glVertexAttrib4Nsv = reinterpret_cast<PFNGLVERTEXATTRIB4NSVPROC>(get_proc_address("glVertexAttrib4NsvARB"));
+               glVertexAttrib4Nub = reinterpret_cast<PFNGLVERTEXATTRIB4NUBPROC>(get_proc_address("glVertexAttrib4NubARB"));
+               glVertexAttrib4Nubv = reinterpret_cast<PFNGLVERTEXATTRIB4NUBVPROC>(get_proc_address("glVertexAttrib4NubvARB"));
+               glVertexAttrib4Nuiv = reinterpret_cast<PFNGLVERTEXATTRIB4NUIVPROC>(get_proc_address("glVertexAttrib4NuivARB"));
+               glVertexAttrib4Nusv = reinterpret_cast<PFNGLVERTEXATTRIB4NUSVPROC>(get_proc_address("glVertexAttrib4NusvARB"));
+               glVertexAttrib4bv = reinterpret_cast<PFNGLVERTEXATTRIB4BVPROC>(get_proc_address("glVertexAttrib4bvARB"));
+               glVertexAttrib4d = reinterpret_cast<PFNGLVERTEXATTRIB4DPROC>(get_proc_address("glVertexAttrib4dARB"));
+               glVertexAttrib4dv = reinterpret_cast<PFNGLVERTEXATTRIB4DVPROC>(get_proc_address("glVertexAttrib4dvARB"));
+               glVertexAttrib4f = reinterpret_cast<PFNGLVERTEXATTRIB4FPROC>(get_proc_address("glVertexAttrib4fARB"));
+               glVertexAttrib4fv = reinterpret_cast<PFNGLVERTEXATTRIB4FVPROC>(get_proc_address("glVertexAttrib4fvARB"));
+               glVertexAttrib4iv = reinterpret_cast<PFNGLVERTEXATTRIB4IVPROC>(get_proc_address("glVertexAttrib4ivARB"));
+               glVertexAttrib4s = reinterpret_cast<PFNGLVERTEXATTRIB4SPROC>(get_proc_address("glVertexAttrib4sARB"));
+               glVertexAttrib4sv = reinterpret_cast<PFNGLVERTEXATTRIB4SVPROC>(get_proc_address("glVertexAttrib4svARB"));
+               glVertexAttrib4ubv = reinterpret_cast<PFNGLVERTEXATTRIB4UBVPROC>(get_proc_address("glVertexAttrib4ubvARB"));
+               glVertexAttrib4uiv = reinterpret_cast<PFNGLVERTEXATTRIB4UIVPROC>(get_proc_address("glVertexAttrib4uivARB"));
+               glVertexAttrib4usv = reinterpret_cast<PFNGLVERTEXATTRIB4USVPROC>(get_proc_address("glVertexAttrib4usvARB"));
+               glVertexAttribPointer = reinterpret_cast<PFNGLVERTEXATTRIBPOINTERPROC>(get_proc_address("glVertexAttribPointerARB"));
+               return Extension::EXTENSION;
+       }
+       return Extension::UNSUPPORTED;
 }
 
+Extension ARB_vertex_shader("GL_ARB_vertex_shader", init_arb_vertex_shader);
+
 } // namespace GL
 } // namespace Msp
index 6dab0c0ae36377a91a6ebbfe6b6e696c31d809cb..6ded1a092045ebd981dca2d87980d5b345b86dc5 100644 (file)
@@ -1,17 +1,61 @@
 #ifndef MSP_GL_ARB_VERTEX_SHADER_
 #define MSP_GL_ARB_VERTEX_SHADER_
 
+#include "extension.h"
 #include "gl.h"
 #include <GL/glext.h>
 
 namespace Msp {
 namespace GL {
 
-extern PFNGLBINDATTRIBLOCATIONARBPROC glBindAttribLocationARB;
-extern PFNGLGETACTIVEATTRIBARBPROC glGetActiveAttribARB;
-extern PFNGLGETATTRIBLOCATIONARBPROC glGetAttribLocationARB;
+extern PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation;
+extern PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray;
+extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray;
+extern PFNGLGETACTIVEATTRIBPROC glGetActiveAttrib;
+extern PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation;
+extern PFNGLGETVERTEXATTRIBPOINTERVPROC glGetVertexAttribPointerv;
+extern PFNGLGETVERTEXATTRIBDVPROC glGetVertexAttribdv;
+extern PFNGLGETVERTEXATTRIBFVPROC glGetVertexAttribfv;
+extern PFNGLGETVERTEXATTRIBIVPROC glGetVertexAttribiv;
+extern PFNGLVERTEXATTRIB1DPROC glVertexAttrib1d;
+extern PFNGLVERTEXATTRIB1DVPROC glVertexAttrib1dv;
+extern PFNGLVERTEXATTRIB1FPROC glVertexAttrib1f;
+extern PFNGLVERTEXATTRIB1FVPROC glVertexAttrib1fv;
+extern PFNGLVERTEXATTRIB1SPROC glVertexAttrib1s;
+extern PFNGLVERTEXATTRIB1SVPROC glVertexAttrib1sv;
+extern PFNGLVERTEXATTRIB2DPROC glVertexAttrib2d;
+extern PFNGLVERTEXATTRIB2DVPROC glVertexAttrib2dv;
+extern PFNGLVERTEXATTRIB2FPROC glVertexAttrib2f;
+extern PFNGLVERTEXATTRIB2FVPROC glVertexAttrib2fv;
+extern PFNGLVERTEXATTRIB2SPROC glVertexAttrib2s;
+extern PFNGLVERTEXATTRIB2SVPROC glVertexAttrib2sv;
+extern PFNGLVERTEXATTRIB3DPROC glVertexAttrib3d;
+extern PFNGLVERTEXATTRIB3DVPROC glVertexAttrib3dv;
+extern PFNGLVERTEXATTRIB3FPROC glVertexAttrib3f;
+extern PFNGLVERTEXATTRIB3FVPROC glVertexAttrib3fv;
+extern PFNGLVERTEXATTRIB3SPROC glVertexAttrib3s;
+extern PFNGLVERTEXATTRIB3SVPROC glVertexAttrib3sv;
+extern PFNGLVERTEXATTRIB4NBVPROC glVertexAttrib4Nbv;
+extern PFNGLVERTEXATTRIB4NIVPROC glVertexAttrib4Niv;
+extern PFNGLVERTEXATTRIB4NSVPROC glVertexAttrib4Nsv;
+extern PFNGLVERTEXATTRIB4NUBPROC glVertexAttrib4Nub;
+extern PFNGLVERTEXATTRIB4NUBVPROC glVertexAttrib4Nubv;
+extern PFNGLVERTEXATTRIB4NUIVPROC glVertexAttrib4Nuiv;
+extern PFNGLVERTEXATTRIB4NUSVPROC glVertexAttrib4Nusv;
+extern PFNGLVERTEXATTRIB4BVPROC glVertexAttrib4bv;
+extern PFNGLVERTEXATTRIB4DPROC glVertexAttrib4d;
+extern PFNGLVERTEXATTRIB4DVPROC glVertexAttrib4dv;
+extern PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f;
+extern PFNGLVERTEXATTRIB4FVPROC glVertexAttrib4fv;
+extern PFNGLVERTEXATTRIB4IVPROC glVertexAttrib4iv;
+extern PFNGLVERTEXATTRIB4SPROC glVertexAttrib4s;
+extern PFNGLVERTEXATTRIB4SVPROC glVertexAttrib4sv;
+extern PFNGLVERTEXATTRIB4UBVPROC glVertexAttrib4ubv;
+extern PFNGLVERTEXATTRIB4UIVPROC glVertexAttrib4uiv;
+extern PFNGLVERTEXATTRIB4USVPROC glVertexAttrib4usv;
+extern PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
 
-void init_arb_vertex_shader();
+extern Extension ARB_vertex_shader;
 
 } // namespace GL
 } // namespace Msp
index 375c52e9ca25da98131f76924eb457b80bf9f255..afb9787b4d7f8bd7f34c0491120f668efc3c163b 100644 (file)
@@ -2,10 +2,9 @@
 #include "bindable.h"
 #include "buffer.h"
 #include "error.h"
-#include "extension.h"
+#include "ext_draw_range_elements.h"
 #include "nv_primitive_restart.h"
 #include "vertexarray.h"
-#include "version_1_2.h"
 
 using namespace std;
 
@@ -28,7 +27,7 @@ Batch::Batch(PrimitiveType t):
 {
        /* XXX Should probably provide a fallback to glDrawElements since this class
        is pretty much required to render anything. */
-       static RequireVersion _ver(1, 2);
+       static Require _req(EXT_draw_range_elements);
 }
 
 Batch::~Batch()
@@ -165,12 +164,12 @@ void Batch::append(const Batch &other)
        else if(prim_type==POLYGON)
                throw incompatible_data("Batch::append");
        else if(prim_type==TRIANGLE_FAN)
-               static RequireExtension _ext("GL_NV_primitive_restart");
+               static Require _req(NV_primitive_restart);
 
        if(other.data.empty())
                return;
 
-       if(is_supported("GL_NV_primitive_restart"))
+       if(NV_primitive_restart)
        {
                restart = true;
                if(data_type==UNSIGNED_SHORT)
index 03fc0f02baf32c917e1be36ad9ec33f7237f9233..cecd562dc1019f389e151049b94d4c01e55b2623 100644 (file)
@@ -1,6 +1,6 @@
 #include "blend.h"
-#include "extension.h"
-#include "version_1_2.h"
+#include "ext_blend_minmax.h"
+#include "ext_blend_subtract.h"
 
 namespace Msp {
 namespace GL {
@@ -22,8 +22,10 @@ Blend::Blend(BlendEquation e, BlendFactor sf, BlendFactor df):
        src_factor(sf),
        dst_factor(df)
 {
-       if(eq!=ADD)
-               static RequireVersion _ver(1, 2);
+       if(eq==MIN || eq==MAX)
+               static Require _req(EXT_blend_minmax);
+       else if(eq==SUBTRACT || eq==REVERSE_SUBTRACT)
+               static Require _req(EXT_blend_subtract);
 }
 
 void Blend::bind() const
index f3b40da6ab469623f8d7e2a27a65a6964da657c1..84c72716d0e5da16cebb42fcd8e191c093ae1bd3 100644 (file)
@@ -1,8 +1,8 @@
 #include <stdexcept>
+#include "arb_pixel_buffer_object.h"
 #include "arb_uniform_buffer_object.h"
 #include "arb_vertex_buffer_object.h"
 #include "buffer.h"
-#include "extension.h"
 #include "misc.h"
 
 using namespace std;
@@ -19,21 +19,21 @@ Buffer::Buffer(BufferType t):
 {
        require_buffer_type(type);
 
-       glGenBuffersARB(1, &id);
+       glGenBuffers(1, &id);
 }
 
 Buffer::~Buffer()
 {
-       glDeleteBuffersARB(1, &id);
+       glDeleteBuffers(1, &id);
 }
 
 void Buffer::require_buffer_type(BufferType type)
 {
-       static RequireExtension _req_vbo("GL_ARB_vertex_buffer_object");
+       static Require _req_vbo(ARB_vertex_buffer_object);
        if(type==PIXEL_PACK_BUFFER || type==PIXEL_UNPACK_BUFFER)
-               static RequireExtension _req_pbo("GL_ARB_pixel_buffer_object");
+               static Require _req_pbo(ARB_pixel_buffer_object);
        else if(type==UNIFORM_BUFFER)
-               static RequireExtension _req_ubo("GL_ARB_uniform_buffer_object");
+               static Require _req_ubo(ARB_uniform_buffer_object);
 }
 
 void Buffer::set_usage(BufferUsage u)
@@ -45,7 +45,7 @@ void Buffer::data(unsigned sz, const void *d)
 {
        const Buffer *old = current(type);
        bind();
-       glBufferDataARB(type, sz, d, usage);
+       glBufferData(type, sz, d, usage);
        size = sz;
        restore(old, type);
 }
@@ -54,7 +54,7 @@ void Buffer::sub_data(unsigned off, unsigned sz, const void *d)
 {
        const Buffer *old = current(type);
        bind();
-       glBufferSubDataARB(type, off, sz, d);
+       glBufferSubData(type, off, sz, d);
        restore(old, type);
 }
 
@@ -68,13 +68,13 @@ void Buffer::bind_to(BufferType t) const
        if(t!=type)
                require_buffer_type(t);
        if(set_current(t, this))
-               glBindBufferARB(t, id);
+               glBindBuffer(t, id);
 }
 
 void Buffer::unbind_from(BufferType type)
 {
        if(set_current(type, 0))
-               glBindBufferARB(type, 0);
+               glBindBuffer(type, 0);
 }
 
 const Buffer *&Buffer::binding(BufferType type)
index 206cec8d0d2c580aef949b94acb4539c57a21a11..25ce46993f1080fb9641dcc9bcf4c206d8cafda7 100644 (file)
@@ -9,24 +9,24 @@ namespace GL {
 
 enum BufferType
 {
-       ARRAY_BUFFER         = GL_ARRAY_BUFFER_ARB,
-       ELEMENT_ARRAY_BUFFER = GL_ELEMENT_ARRAY_BUFFER_ARB,
-       PIXEL_PACK_BUFFER    = GL_PIXEL_PACK_BUFFER_ARB,
-       PIXEL_UNPACK_BUFFER  = GL_PIXEL_UNPACK_BUFFER_ARB,
+       ARRAY_BUFFER         = GL_ARRAY_BUFFER,
+       ELEMENT_ARRAY_BUFFER = GL_ELEMENT_ARRAY_BUFFER,
+       PIXEL_PACK_BUFFER    = GL_PIXEL_PACK_BUFFER,
+       PIXEL_UNPACK_BUFFER  = GL_PIXEL_UNPACK_BUFFER,
        UNIFORM_BUFFER       = GL_UNIFORM_BUFFER
 };
 
 enum BufferUsage
 {
-       STREAM_DRAW  = GL_STREAM_DRAW_ARB,
-       STREAM_READ  = GL_STREAM_READ_ARB,
-       STREAM_COPY  = GL_STREAM_COPY_ARB,
-       STATIC_DRAW  = GL_STATIC_DRAW_ARB,
-       STATIC_READ  = GL_STATIC_READ_ARB,
-       STATIC_COPY  = GL_STATIC_COPY_ARB,
-       DYNAMIC_DRAW = GL_DYNAMIC_DRAW_ARB,
-       DYNAMIC_READ = GL_DYNAMIC_READ_ARB,
-       DYNAMIC_COPY = GL_DYNAMIC_COPY_ARB
+       STREAM_DRAW  = GL_STREAM_DRAW,
+       STREAM_READ  = GL_STREAM_READ,
+       STREAM_COPY  = GL_STREAM_COPY,
+       STATIC_DRAW  = GL_STATIC_DRAW,
+       STATIC_READ  = GL_STATIC_READ,
+       STATIC_COPY  = GL_STATIC_COPY,
+       DYNAMIC_DRAW = GL_DYNAMIC_DRAW,
+       DYNAMIC_READ = GL_DYNAMIC_READ,
+       DYNAMIC_COPY = GL_DYNAMIC_COPY
 };
 
 class BufferRange;
diff --git a/source/ext_blend_minmax.cpp b/source/ext_blend_minmax.cpp
new file mode 100644 (file)
index 0000000..225a05f
--- /dev/null
@@ -0,0 +1,26 @@
+#include "ext_blend_minmax.h"
+
+namespace Msp {
+namespace GL {
+
+PFNGLBLENDEQUATIONPROC glBlendEquation = 0;
+
+Extension::SupportLevel init_ext_blend_minmax()
+{
+       if(is_version_at_least(1, 2))
+       {
+               glBlendEquation = reinterpret_cast<PFNGLBLENDEQUATIONPROC>(get_proc_address("glBlendEquation"));
+               return Extension::CORE;
+       }
+       if(is_supported("GL_EXT_blend_minmax"))
+       {
+               glBlendEquation = reinterpret_cast<PFNGLBLENDEQUATIONPROC>(get_proc_address("glBlendEquationEXT"));
+               return Extension::EXTENSION;
+       }
+       return Extension::UNSUPPORTED;
+}
+
+Extension EXT_blend_minmax("GL_EXT_blend_minmax", init_ext_blend_minmax);
+
+} // namespace GL
+} // namespace Msp
diff --git a/source/ext_blend_minmax.h b/source/ext_blend_minmax.h
new file mode 100644 (file)
index 0000000..5ca1a58
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef MSP_GL_EXT_BLEND_MINMAX_
+#define MSP_GL_EXT_BLEND_MINMAX_
+
+#include "extension.h"
+#include "gl.h"
+#include <GL/glext.h>
+
+namespace Msp {
+namespace GL {
+
+extern PFNGLBLENDEQUATIONPROC glBlendEquation;
+
+extern Extension EXT_blend_minmax;
+
+} // namespace GL
+} // namespace Msp
+
+#endif
diff --git a/source/ext_blend_subtract.cpp b/source/ext_blend_subtract.cpp
new file mode 100644 (file)
index 0000000..f15f3f5
--- /dev/null
@@ -0,0 +1,22 @@
+#include "ext_blend_subtract.h"
+
+namespace Msp {
+namespace GL {
+
+Extension::SupportLevel init_ext_blend_subtract()
+{
+       if(is_version_at_least(1, 2))
+       {
+               return Extension::CORE;
+       }
+       if(is_supported("GL_EXT_blend_subtract"))
+       {
+               return Extension::EXTENSION;
+       }
+       return Extension::UNSUPPORTED;
+}
+
+Extension EXT_blend_subtract("GL_EXT_blend_subtract", init_ext_blend_subtract);
+
+} // namespace GL
+} // namespace Msp
diff --git a/source/ext_blend_subtract.h b/source/ext_blend_subtract.h
new file mode 100644 (file)
index 0000000..243d530
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef MSP_GL_EXT_BLEND_SUBTRACT_
+#define MSP_GL_EXT_BLEND_SUBTRACT_
+
+#include "extension.h"
+#include "gl.h"
+#include <GL/glext.h>
+
+namespace Msp {
+namespace GL {
+
+extern Extension EXT_blend_subtract;
+
+} // namespace GL
+} // namespace Msp
+
+#endif
diff --git a/source/ext_draw_range_elements.cpp b/source/ext_draw_range_elements.cpp
new file mode 100644 (file)
index 0000000..2bccf00
--- /dev/null
@@ -0,0 +1,26 @@
+#include "ext_draw_range_elements.h"
+
+namespace Msp {
+namespace GL {
+
+PFNGLDRAWRANGEELEMENTSPROC glDrawRangeElements = 0;
+
+Extension::SupportLevel init_ext_draw_range_elements()
+{
+       if(is_version_at_least(1, 2))
+       {
+               glDrawRangeElements = reinterpret_cast<PFNGLDRAWRANGEELEMENTSPROC>(get_proc_address("glDrawRangeElements"));
+               return Extension::CORE;
+       }
+       if(is_supported("GL_EXT_draw_range_elements"))
+       {
+               glDrawRangeElements = reinterpret_cast<PFNGLDRAWRANGEELEMENTSPROC>(get_proc_address("glDrawRangeElementsEXT"));
+               return Extension::EXTENSION;
+       }
+       return Extension::UNSUPPORTED;
+}
+
+Extension EXT_draw_range_elements("GL_EXT_draw_range_elements", init_ext_draw_range_elements);
+
+} // namespace GL
+} // namespace Msp
diff --git a/source/ext_draw_range_elements.h b/source/ext_draw_range_elements.h
new file mode 100644 (file)
index 0000000..e8aba1d
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef MSP_GL_EXT_DRAW_RANGE_ELEMENTS_
+#define MSP_GL_EXT_DRAW_RANGE_ELEMENTS_
+
+#include "extension.h"
+#include "gl.h"
+#include <GL/glext.h>
+
+namespace Msp {
+namespace GL {
+
+extern PFNGLDRAWRANGEELEMENTSPROC glDrawRangeElements;
+
+extern Extension EXT_draw_range_elements;
+
+} // namespace GL
+} // namespace Msp
+
+#endif
index 7519e13cf24e3663870b22c24c7711fab9f89094..a198cdd176a55601834a78e8c22c1d87fcedf948 100644 (file)
@@ -1,15 +1,26 @@
-#include "extension.h"
 #include "ext_framebuffer_blit.h"
 
 namespace Msp {
 namespace GL {
 
-PFNGLBLITFRAMEBUFFEREXTPROC glBlitFramebufferEXT = 0;
+PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer = 0;
 
-void init_ext_framebuffer_blit()
+Extension::SupportLevel init_ext_framebuffer_blit()
 {
-       glBlitFramebufferEXT = reinterpret_cast<PFNGLBLITFRAMEBUFFEREXTPROC>(get_proc_address("glBlitFramebufferEXT"));
+       if(is_version_at_least(3, 0) || is_supported("GL_ARB_framebuffer_object"))
+       {
+               glBlitFramebuffer = reinterpret_cast<PFNGLBLITFRAMEBUFFERPROC>(get_proc_address("glBlitFramebuffer"));
+               return Extension::CORE;
+       }
+       if(is_supported("GL_EXT_framebuffer_blit"))
+       {
+               glBlitFramebuffer = reinterpret_cast<PFNGLBLITFRAMEBUFFERPROC>(get_proc_address("glBlitFramebufferEXT"));
+               return Extension::EXTENSION;
+       }
+       return Extension::UNSUPPORTED;
 }
 
+Extension EXT_framebuffer_blit("GL_EXT_framebuffer_blit", init_ext_framebuffer_blit);
+
 } // namespace GL
 } // namespace Msp
index 0b651970b10bfbae44fcae66d9ba4af441ea0676..75ca6c6eba6485dfb9ff4c0d8c6dcf3cdc57bff4 100644 (file)
@@ -1,15 +1,16 @@
 #ifndef MSP_GL_EXT_FRAMEBUFFER_BLIT_
 #define MSP_GL_EXT_FRAMEBUFFER_BLIT_
 
+#include "extension.h"
 #include "gl.h"
 #include <GL/glext.h>
 
 namespace Msp {
 namespace GL {
 
-extern PFNGLBLITFRAMEBUFFEREXTPROC glBlitFramebufferEXT;
+extern PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer;
 
-void init_ext_framebuffer_blit();
+extern Extension EXT_framebuffer_blit;
 
 } // namespace GL
 } // namespace Msp
index a0f3930c1948c3e65e557425d74c1bd83e08ecda..7be2f6d35ebe8e4f184f74880249b548976ab7d2 100644 (file)
@@ -1,15 +1,26 @@
-#include "extension.h"
 #include "ext_framebuffer_multisample.h"
 
 namespace Msp {
 namespace GL {
 
-PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glRenderbufferStorageMultisampleEXT = 0;
+PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glRenderbufferStorageMultisample = 0;
 
-void init_ext_framebuffer_multisample()
+Extension::SupportLevel init_ext_framebuffer_multisample()
 {
-       glRenderbufferStorageMultisampleEXT = reinterpret_cast<PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC>(get_proc_address("glRenderbufferStorageMultisampleEXT"));
+       if(is_version_at_least(3, 0) || is_supported("GL_ARB_framebuffer_object"))
+       {
+               glRenderbufferStorageMultisample = reinterpret_cast<PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC>(get_proc_address("glRenderbufferStorageMultisample"));
+               return Extension::CORE;
+       }
+       if(is_supported("GL_EXT_framebuffer_multisample"))
+       {
+               glRenderbufferStorageMultisample = reinterpret_cast<PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC>(get_proc_address("glRenderbufferStorageMultisampleEXT"));
+               return Extension::EXTENSION;
+       }
+       return Extension::UNSUPPORTED;
 }
 
+Extension EXT_framebuffer_multisample("GL_EXT_framebuffer_multisample", init_ext_framebuffer_multisample);
+
 } // namespace GL
 } // namespace Msp
index 479ef6932dbac321f2ba8c7dc89b5ba33aaf85dc..980ef9a9d01d304d62a0bad7314d57f45a7a779c 100644 (file)
@@ -1,15 +1,16 @@
 #ifndef MSP_GL_EXT_FRAMEBUFFER_MULTISAMPLE_
 #define MSP_GL_EXT_FRAMEBUFFER_MULTISAMPLE_
 
+#include "extension.h"
 #include "gl.h"
 #include <GL/glext.h>
 
 namespace Msp {
 namespace GL {
 
-extern PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glRenderbufferStorageMultisampleEXT;
+extern PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glRenderbufferStorageMultisample;
 
-void init_ext_framebuffer_multisample();
+extern Extension EXT_framebuffer_multisample;
 
 } // namespace GL
 } // namespace Msp
index ab5048d6bb8fe2521a890484988ef049591726d7..e9193e1773eba757656b106d4d9323a68e5ca42d 100644 (file)
@@ -1,47 +1,74 @@
-#include "extension.h"
 #include "ext_framebuffer_object.h"
 
 namespace Msp {
 namespace GL {
 
-PFNGLISRENDERBUFFEREXTPROC glIsRenderbufferEXT = 0;
-PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT = 0;
-PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT = 0;
-PFNGLGENRENDERBUFFERSEXTPROC glGenRenderbuffersEXT = 0;
-PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT = 0;
-PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC glGetRenderbufferParameterivEXT = 0;
-PFNGLISFRAMEBUFFEREXTPROC glIsFramebufferEXT = 0;
-PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT = 0;
-PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT = 0;
-PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT = 0;
-PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT = 0;
-PFNGLFRAMEBUFFERTEXTURE1DEXTPROC glFramebufferTexture1DEXT = 0;
-PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT = 0;
-PFNGLFRAMEBUFFERTEXTURE3DEXTPROC glFramebufferTexture3DEXT = 0;
-PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glFramebufferRenderbufferEXT = 0;
-PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC glGetFramebufferAttachmentParameterivEXT = 0;
-PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT = 0;
+PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer = 0;
+PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer = 0;
+PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus = 0;
+PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers = 0;
+PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers = 0;
+PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer = 0;
+PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D = 0;
+PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D = 0;
+PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D = 0;
+PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers = 0;
+PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers = 0;
+PFNGLGENERATEMIPMAPPROC glGenerateMipmap = 0;
+PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glGetFramebufferAttachmentParameteriv = 0;
+PFNGLGETRENDERBUFFERPARAMETERIVPROC glGetRenderbufferParameteriv = 0;
+PFNGLISFRAMEBUFFERPROC glIsFramebuffer = 0;
+PFNGLISRENDERBUFFERPROC glIsRenderbuffer = 0;
+PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage = 0;
 
-void init_ext_framebuffer_object()
+Extension::SupportLevel init_ext_framebuffer_object()
 {
-       glIsRenderbufferEXT = reinterpret_cast<PFNGLISRENDERBUFFEREXTPROC>(get_proc_address("glIsRenderbufferEXT"));
-       glBindRenderbufferEXT = reinterpret_cast<PFNGLBINDRENDERBUFFEREXTPROC>(get_proc_address("glBindRenderbufferEXT"));
-       glDeleteRenderbuffersEXT = reinterpret_cast<PFNGLDELETERENDERBUFFERSEXTPROC>(get_proc_address("glDeleteRenderbuffersEXT"));
-       glGenRenderbuffersEXT = reinterpret_cast<PFNGLGENRENDERBUFFERSEXTPROC>(get_proc_address("glGenRenderbuffersEXT"));
-       glRenderbufferStorageEXT = reinterpret_cast<PFNGLRENDERBUFFERSTORAGEEXTPROC>(get_proc_address("glRenderbufferStorageEXT"));
-       glGetRenderbufferParameterivEXT = reinterpret_cast<PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC>(get_proc_address("glGetRenderbufferParameterivEXT"));
-       glIsFramebufferEXT = reinterpret_cast<PFNGLISFRAMEBUFFEREXTPROC>(get_proc_address("glIsFramebufferEXT"));
-       glBindFramebufferEXT = reinterpret_cast<PFNGLBINDFRAMEBUFFEREXTPROC>(get_proc_address("glBindFramebufferEXT"));
-       glDeleteFramebuffersEXT = reinterpret_cast<PFNGLDELETEFRAMEBUFFERSEXTPROC>(get_proc_address("glDeleteFramebuffersEXT"));
-       glGenFramebuffersEXT = reinterpret_cast<PFNGLGENFRAMEBUFFERSEXTPROC>(get_proc_address("glGenFramebuffersEXT"));
-       glCheckFramebufferStatusEXT = reinterpret_cast<PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC>(get_proc_address("glCheckFramebufferStatusEXT"));
-       glFramebufferTexture1DEXT = reinterpret_cast<PFNGLFRAMEBUFFERTEXTURE1DEXTPROC>(get_proc_address("glFramebufferTexture1DEXT"));
-       glFramebufferTexture2DEXT = reinterpret_cast<PFNGLFRAMEBUFFERTEXTURE2DEXTPROC>(get_proc_address("glFramebufferTexture2DEXT"));
-       glFramebufferTexture3DEXT = reinterpret_cast<PFNGLFRAMEBUFFERTEXTURE3DEXTPROC>(get_proc_address("glFramebufferTexture3DEXT"));
-       glFramebufferRenderbufferEXT = reinterpret_cast<PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC>(get_proc_address("glFramebufferRenderbufferEXT"));
-       glGetFramebufferAttachmentParameterivEXT = reinterpret_cast<PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC>(get_proc_address("glGetFramebufferAttachmentParameterivEXT"));
-       glGenerateMipmapEXT = reinterpret_cast<PFNGLGENERATEMIPMAPEXTPROC>(get_proc_address("glGenerateMipmapEXT"));
+       if(is_version_at_least(3, 0) || is_supported("GL_ARB_framebuffer_object"))
+       {
+               glBindFramebuffer = reinterpret_cast<PFNGLBINDFRAMEBUFFERPROC>(get_proc_address("glBindFramebuffer"));
+               glBindRenderbuffer = reinterpret_cast<PFNGLBINDRENDERBUFFERPROC>(get_proc_address("glBindRenderbuffer"));
+               glCheckFramebufferStatus = reinterpret_cast<PFNGLCHECKFRAMEBUFFERSTATUSPROC>(get_proc_address("glCheckFramebufferStatus"));
+               glDeleteFramebuffers = reinterpret_cast<PFNGLDELETEFRAMEBUFFERSPROC>(get_proc_address("glDeleteFramebuffers"));
+               glDeleteRenderbuffers = reinterpret_cast<PFNGLDELETERENDERBUFFERSPROC>(get_proc_address("glDeleteRenderbuffers"));
+               glFramebufferRenderbuffer = reinterpret_cast<PFNGLFRAMEBUFFERRENDERBUFFERPROC>(get_proc_address("glFramebufferRenderbuffer"));
+               glFramebufferTexture1D = reinterpret_cast<PFNGLFRAMEBUFFERTEXTURE1DPROC>(get_proc_address("glFramebufferTexture1D"));
+               glFramebufferTexture2D = reinterpret_cast<PFNGLFRAMEBUFFERTEXTURE2DPROC>(get_proc_address("glFramebufferTexture2D"));
+               glFramebufferTexture3D = reinterpret_cast<PFNGLFRAMEBUFFERTEXTURE3DPROC>(get_proc_address("glFramebufferTexture3D"));
+               glGenFramebuffers = reinterpret_cast<PFNGLGENFRAMEBUFFERSPROC>(get_proc_address("glGenFramebuffers"));
+               glGenRenderbuffers = reinterpret_cast<PFNGLGENRENDERBUFFERSPROC>(get_proc_address("glGenRenderbuffers"));
+               glGenerateMipmap = reinterpret_cast<PFNGLGENERATEMIPMAPPROC>(get_proc_address("glGenerateMipmap"));
+               glGetFramebufferAttachmentParameteriv = reinterpret_cast<PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC>(get_proc_address("glGetFramebufferAttachmentParameteriv"));
+               glGetRenderbufferParameteriv = reinterpret_cast<PFNGLGETRENDERBUFFERPARAMETERIVPROC>(get_proc_address("glGetRenderbufferParameteriv"));
+               glIsFramebuffer = reinterpret_cast<PFNGLISFRAMEBUFFERPROC>(get_proc_address("glIsFramebuffer"));
+               glIsRenderbuffer = reinterpret_cast<PFNGLISRENDERBUFFERPROC>(get_proc_address("glIsRenderbuffer"));
+               glRenderbufferStorage = reinterpret_cast<PFNGLRENDERBUFFERSTORAGEPROC>(get_proc_address("glRenderbufferStorage"));
+               return Extension::CORE;
+       }
+       if(is_supported("GL_EXT_framebuffer_object"))
+       {
+               glBindFramebuffer = reinterpret_cast<PFNGLBINDFRAMEBUFFERPROC>(get_proc_address("glBindFramebufferEXT"));
+               glBindRenderbuffer = reinterpret_cast<PFNGLBINDRENDERBUFFERPROC>(get_proc_address("glBindRenderbufferEXT"));
+               glCheckFramebufferStatus = reinterpret_cast<PFNGLCHECKFRAMEBUFFERSTATUSPROC>(get_proc_address("glCheckFramebufferStatusEXT"));
+               glDeleteFramebuffers = reinterpret_cast<PFNGLDELETEFRAMEBUFFERSPROC>(get_proc_address("glDeleteFramebuffersEXT"));
+               glDeleteRenderbuffers = reinterpret_cast<PFNGLDELETERENDERBUFFERSPROC>(get_proc_address("glDeleteRenderbuffersEXT"));
+               glFramebufferRenderbuffer = reinterpret_cast<PFNGLFRAMEBUFFERRENDERBUFFERPROC>(get_proc_address("glFramebufferRenderbufferEXT"));
+               glFramebufferTexture1D = reinterpret_cast<PFNGLFRAMEBUFFERTEXTURE1DPROC>(get_proc_address("glFramebufferTexture1DEXT"));
+               glFramebufferTexture2D = reinterpret_cast<PFNGLFRAMEBUFFERTEXTURE2DPROC>(get_proc_address("glFramebufferTexture2DEXT"));
+               glFramebufferTexture3D = reinterpret_cast<PFNGLFRAMEBUFFERTEXTURE3DPROC>(get_proc_address("glFramebufferTexture3DEXT"));
+               glGenFramebuffers = reinterpret_cast<PFNGLGENFRAMEBUFFERSPROC>(get_proc_address("glGenFramebuffersEXT"));
+               glGenRenderbuffers = reinterpret_cast<PFNGLGENRENDERBUFFERSPROC>(get_proc_address("glGenRenderbuffersEXT"));
+               glGenerateMipmap = reinterpret_cast<PFNGLGENERATEMIPMAPPROC>(get_proc_address("glGenerateMipmapEXT"));
+               glGetFramebufferAttachmentParameteriv = reinterpret_cast<PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC>(get_proc_address("glGetFramebufferAttachmentParameterivEXT"));
+               glGetRenderbufferParameteriv = reinterpret_cast<PFNGLGETRENDERBUFFERPARAMETERIVPROC>(get_proc_address("glGetRenderbufferParameterivEXT"));
+               glIsFramebuffer = reinterpret_cast<PFNGLISFRAMEBUFFERPROC>(get_proc_address("glIsFramebufferEXT"));
+               glIsRenderbuffer = reinterpret_cast<PFNGLISRENDERBUFFERPROC>(get_proc_address("glIsRenderbufferEXT"));
+               glRenderbufferStorage = reinterpret_cast<PFNGLRENDERBUFFERSTORAGEPROC>(get_proc_address("glRenderbufferStorageEXT"));
+               return Extension::EXTENSION;
+       }
+       return Extension::UNSUPPORTED;
 }
 
+Extension EXT_framebuffer_object("GL_EXT_framebuffer_object", init_ext_framebuffer_object);
+
 } // namespace GL
 } // namespace Msp
index a92b30560751d8dc97f1be9be9f2484d9f14b355..69bf7466f503fbf115c03dddf93f195b879579ef 100644 (file)
@@ -1,31 +1,32 @@
 #ifndef MSP_GL_EXT_FRAMEBUFFER_OBJECT_
 #define MSP_GL_EXT_FRAMEBUFFER_OBJECT_
 
+#include "extension.h"
 #include "gl.h"
 #include <GL/glext.h>
 
 namespace Msp {
 namespace GL {
 
-extern PFNGLISRENDERBUFFEREXTPROC glIsRenderbufferEXT;
-extern PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT;
-extern PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT;
-extern PFNGLGENRENDERBUFFERSEXTPROC glGenRenderbuffersEXT;
-extern PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT;
-extern PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC glGetRenderbufferParameterivEXT;
-extern PFNGLISFRAMEBUFFEREXTPROC glIsFramebufferEXT;
-extern PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT;
-extern PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT;
-extern PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT;
-extern PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT;
-extern PFNGLFRAMEBUFFERTEXTURE1DEXTPROC glFramebufferTexture1DEXT;
-extern PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT;
-extern PFNGLFRAMEBUFFERTEXTURE3DEXTPROC glFramebufferTexture3DEXT;
-extern PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glFramebufferRenderbufferEXT;
-extern PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC glGetFramebufferAttachmentParameterivEXT;
-extern PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT;
+extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
+extern PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer;
+extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
+extern PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers;
+extern PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers;
+extern PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer;
+extern PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D;
+extern PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D;
+extern PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D;
+extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
+extern PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers;
+extern PFNGLGENERATEMIPMAPPROC glGenerateMipmap;
+extern PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glGetFramebufferAttachmentParameteriv;
+extern PFNGLGETRENDERBUFFERPARAMETERIVPROC glGetRenderbufferParameteriv;
+extern PFNGLISFRAMEBUFFERPROC glIsFramebuffer;
+extern PFNGLISRENDERBUFFERPROC glIsRenderbuffer;
+extern PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage;
 
-void init_ext_framebuffer_object();
+extern Extension EXT_framebuffer_object;
 
 } // namespace GL
 } // namespace Msp
diff --git a/source/ext_texture3d.cpp b/source/ext_texture3d.cpp
new file mode 100644 (file)
index 0000000..e75044a
--- /dev/null
@@ -0,0 +1,29 @@
+#include "ext_texture3d.h"
+
+namespace Msp {
+namespace GL {
+
+PFNGLTEXIMAGE3DPROC glTexImage3D = 0;
+PFNGLTEXSUBIMAGE3DPROC glTexSubImage3D = 0;
+
+Extension::SupportLevel init_ext_texture3d()
+{
+       if(is_version_at_least(1, 2))
+       {
+               glTexImage3D = reinterpret_cast<PFNGLTEXIMAGE3DPROC>(get_proc_address("glTexImage3D"));
+               glTexSubImage3D = reinterpret_cast<PFNGLTEXSUBIMAGE3DPROC>(get_proc_address("glTexSubImage3D"));
+               return Extension::CORE;
+       }
+       if(is_supported("GL_EXT_texture3D"))
+       {
+               glTexImage3D = reinterpret_cast<PFNGLTEXIMAGE3DPROC>(get_proc_address("glTexImage3DEXT"));
+               glTexSubImage3D = reinterpret_cast<PFNGLTEXSUBIMAGE3DPROC>(get_proc_address("glTexSubImage3DEXT"));
+               return Extension::EXTENSION;
+       }
+       return Extension::UNSUPPORTED;
+}
+
+Extension EXT_texture3D("GL_EXT_texture3D", init_ext_texture3d);
+
+} // namespace GL
+} // namespace Msp
diff --git a/source/ext_texture3d.h b/source/ext_texture3d.h
new file mode 100644 (file)
index 0000000..2f2d696
--- /dev/null
@@ -0,0 +1,19 @@
+#ifndef MSP_GL_EXT_TEXTURE3D_
+#define MSP_GL_EXT_TEXTURE3D_
+
+#include "extension.h"
+#include "gl.h"
+#include <GL/glext.h>
+
+namespace Msp {
+namespace GL {
+
+extern PFNGLTEXIMAGE3DPROC glTexImage3D;
+extern PFNGLTEXSUBIMAGE3DPROC glTexSubImage3D;
+
+extern Extension EXT_texture3D;
+
+} // namespace GL
+} // namespace Msp
+
+#endif
index bc43ae8bbbee902533c24a8c05b071aed1eb2b41..6ca4f08ce61728da8a1a9c994880be0d85810a97 100644 (file)
@@ -5,26 +5,41 @@
 #endif
 #include <msp/strings/format.h>
 #include <msp/strings/utils.h>
-#include "arb_shader_objects.h"
-#include "arb_uniform_buffer_object.h"
-#include "arb_vertex_buffer_object.h"
-#include "arb_vertex_program.h"
-#include "arb_vertex_shader.h"
 #include "error.h"
-#include "ext_framebuffer_blit.h"
-#include "ext_framebuffer_multisample.h"
-#include "ext_framebuffer_object.h"
 #include "extension.h"
 #include "gl.h"
-#include "nv_primitive_restart.h"
-#include "version_1_2.h"
-#include "version_1_3.h"
 
 using namespace std;
 
 namespace Msp {
 namespace GL {
 
+Extension::Extension(const char *n, InitFunc f):
+       name(n),
+       init_func(f),
+       init_done(false),
+       support(UNSUPPORTED)
+{ }
+
+Extension::operator bool() const
+{
+       if(!init_done)
+       {
+               support = init_func();
+               init_done = true;
+       }
+
+       return support>UNSUPPORTED;
+}
+
+
+Require::Require(const Extension &ext)
+{
+       if(!ext)
+               throw unsupported_extension(ext.get_name());
+}
+
+
 bool is_supported(const string &ext)
 {
        static set<string> extensions;
@@ -38,39 +53,12 @@ bool is_supported(const string &ext)
                        extensions.insert(exts.begin(), exts.end());
                }
 
-               /* XXX Conceptually a bit weird place for this, but I couldn't really come up
-               with anything better that would still be transparent. */
-               if(extensions.count("GL_ARB_shader_objects"))
-                       init_arb_shader_objects();
-               if(extensions.count("GL_ARB_vertex_shader"))
-                       init_arb_vertex_shader();
-               if(extensions.count("GL_ARB_vertex_program"))
-                       init_arb_vertex_program();
-               if(extensions.count("GL_EXT_framebuffer_object"))
-                       init_ext_framebuffer_object();
-               if(extensions.count("GL_EXT_framebuffer_blit"))
-                       init_ext_framebuffer_blit();
-               if(extensions.count("GL_EXT_framebuffer_multisample"))
-                       init_ext_framebuffer_multisample();
-               if(extensions.count("GL_ARB_vertex_buffer_object"))
-                       init_arb_vertex_buffer_object();
-               if(extensions.count("GL_NV_primitive_restart"))
-                       init_nv_primitive_restart();
-               if(extensions.count("GL_ARB_uniform_buffer_object"))
-                       init_arb_uniform_buffer_object();
-
                init_done = true;
        }
 
        return extensions.count(ext);
 }
 
-void require_extension(const string &ext)
-{
-       if(!is_supported(ext))
-               throw unsupported_extension(ext);
-}
-
 const Version &get_gl_version()
 {
        static Version version;
@@ -83,12 +71,6 @@ const Version &get_gl_version()
                version.major = lexical_cast<unsigned>(parts[0]);
                version.minor = lexical_cast<unsigned>(parts[1]);
 
-               unsigned combined = version.major*0x100+version.minor;
-               if(combined>=0x102)
-                       init_version_1_2();
-               if(combined>=0x103)
-                       init_version_1_3();
-
                init_done = true;
        }
 
@@ -101,12 +83,6 @@ bool is_version_at_least(unsigned a, unsigned b)
        return (ver.major>a || (ver.major==a && ver.minor>=b));
 }
 
-void require_version(unsigned a, unsigned b)
-{
-       if(!is_version_at_least(a, b))
-               throw unsupported_extension(format("OpenGL %d.%d", a, b));
-}
-
 ExtFunc *get_proc_address(const string &name)
 {
 #ifndef WIN32
index 4072869cc25662d8c76fe2d4ab94c5700515f2a3..e6c2aca045491e4a23005b87ac35d60c5cab3e64 100644 (file)
@@ -12,54 +12,52 @@ struct Version
        unsigned short minor;
 };
 
-typedef void ExtFunc();
 
-/**
-Indicates whether an extension is supported.  If this returns true, the
-functions of that extension are safe to use.
-*/
-bool is_supported(const std::string &);
+class Extension
+{
+public:
+       enum SupportLevel
+       {
+               UNSUPPORTED,
+               EXTENSION,
+               CORE
+       };
 
-/**
-Checks that an extension is supported and throws if it isn't.
-*/
-void require_extension(const std::string &);
+       typedef SupportLevel (*InitFunc)();
 
-/**
-RAII version of require_extension.  Useful as a static local variable.
-*/
-struct RequireExtension
-{
-       RequireExtension(const std::string &e) { require_extension(e); }
-};
+private:
+       const char *name;
+       InitFunc init_func;
+       mutable bool init_done;
+       mutable SupportLevel support;
 
-/**
-Returns the OpenGL version number, as reported by the implementation.
-Functions up to the returned version are safe to use.
-*/
-const Version &get_gl_version();
+public:
+       Extension(const char *, InitFunc);
 
-/**
-Indicates whether the OpenGL version is at least a.b.
-*/
-bool is_version_at_least(unsigned a, unsigned b);
+       const char *get_name() const { return name; }
+       operator bool() const;
+};
 
-/**
-Checks that the OpenGL version is at least a.b and throws if it isn't.
-*/
-void require_version(unsigned a, unsigned b);
 
-/**
-RAII version of require_version.  Useful as a static local variable.
-*/
-struct RequireVersion
+struct Require
 {
-       RequireVersion(unsigned a, unsigned b) { require_version(a, b); }
+       Require(const Extension &);
 };
 
-/**
-Returns the address of an extension function.  Only indended for internal use.
-*/
+
+typedef void ExtFunc();
+
+/** Indicates whether an extension is supported. */
+bool is_supported(const std::string &);
+
+/** Returns the OpenGL version number, as reported by the implementation. */
+const Version &get_gl_version();
+
+/** Indicates whether the OpenGL version is at least a.b. */
+bool is_version_at_least(unsigned a, unsigned b);
+
+/** Returns the address of an extension function.  Only indended for internal
+use. */
 ExtFunc *get_proc_address(const std::string &);
 
 } // namespace GL
index c4f714c64b7768e74989602ac023ce3e14655159..43b0f94b82e4c882327ef686491453a1bc7cf263 100644 (file)
@@ -1,5 +1,4 @@
 #include "error.h"
-#include "extension.h"
 #include "ext_framebuffer_blit.h"
 #include "ext_framebuffer_object.h"
 #include "framebuffer.h"
@@ -30,15 +29,15 @@ Framebuffer::Framebuffer():
        height(0),
        dirty(0)
 {
-       static RequireExtension _ext("GL_EXT_framebuffer_object");
+       static Require _req(EXT_framebuffer_object);
 
-       glGenFramebuffersEXT(1, &id);
+       glGenFramebuffers(1, &id);
 }
 
 Framebuffer::~Framebuffer()
 {
        if(id)
-               glDeleteFramebuffersEXT(1, &id);
+               glDeleteFramebuffers(1, &id);
        if(current()==this)
                unbind();
 }
@@ -53,20 +52,20 @@ void Framebuffer::update_attachment(unsigned mask) const
                        const Attachment &attch = attachments[i];
                        if(mask&(1<<i))
                        {
-                               if(attch.type==GL_RENDERBUFFER_EXT)
-                                       glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, attch.attachment, GL_RENDERBUFFER_EXT, attch.rbuf->get_id());
+                               if(attch.type==GL_RENDERBUFFER)
+                                       glFramebufferRenderbuffer(GL_FRAMEBUFFER, attch.attachment, GL_RENDERBUFFER, attch.rbuf->get_id());
                                else if(attch.type==GL_TEXTURE_2D)
                                {
                                        static_cast<Texture2D *>(attch.tex)->allocate(attch.level);
-                                       glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attch.attachment, attch.type, attch.tex->get_id(), attch.level);
+                                       glFramebufferTexture2D(GL_FRAMEBUFFER, attch.attachment, attch.type, attch.tex->get_id(), attch.level);
                                }
                                else if(attch.type==GL_TEXTURE_CUBE_MAP)
                                {
                                        static_cast<TextureCube *>(attch.tex)->allocate(attch.level);
-                                       glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attch.attachment, attch.cube_face, attch.tex->get_id(), attch.level);
+                                       glFramebufferTexture2D(GL_FRAMEBUFFER, attch.attachment, attch.cube_face, attch.tex->get_id(), attch.level);
                                }
                                else
-                                       glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, attch.attachment, 0, 0);
+                                       glFramebufferRenderbuffer(GL_FRAMEBUFFER, attch.attachment, 0, 0);
                        }
 
                        if(attch.attachment>=COLOR_ATTACHMENT0 && attch.attachment<=COLOR_ATTACHMENT3)
@@ -84,7 +83,7 @@ void Framebuffer::check_size()
        for(vector<Attachment>::iterator i=attachments.begin(); i!=attachments.end(); ++i)
                if(i->type)
                {
-                       if(i->type==GL_RENDERBUFFER_EXT)
+                       if(i->type==GL_RENDERBUFFER)
                        {
                                width = i->rbuf->get_width();
                                height = i->rbuf->get_height();
@@ -162,7 +161,7 @@ void Framebuffer::detach(FramebufferAttachment attch)
 FramebufferStatus Framebuffer::check_status() const
 {
        Bind _bind(this, true);
-       return static_cast<FramebufferStatus>(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT));
+       return static_cast<FramebufferStatus>(glCheckFramebufferStatus(GL_FRAMEBUFFER));
 }
 
 void Framebuffer::clear(BufferBits bits)
@@ -173,12 +172,12 @@ void Framebuffer::clear(BufferBits bits)
 
 void Framebuffer::blit_from(const Framebuffer &other, int sx0, int sy0, int sx1, int sy1, int dx0, int dy0, int dx1, int dy1, BufferBits bits, bool filter)
 {
-       static RequireExtension _ext("GL_EXT_framebuffer_blit");
+       static Require _req(EXT_framebuffer_blit);
 
        const Framebuffer *old = current();
        if(set_current(this))
        {
-               glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, id);
+               glBindFramebuffer(GL_DRAW_FRAMEBUFFER, id);
                if(dirty)
                {
                        update_attachment(dirty);
@@ -186,12 +185,12 @@ void Framebuffer::blit_from(const Framebuffer &other, int sx0, int sy0, int sx1,
                }
        }
        if(old!=&other)
-               glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, other.id);
+               glBindFramebuffer(GL_READ_FRAMEBUFFER, other.id);
 
-       glBlitFramebufferEXT(sx0, sy0, sx1, sy1, dx0, dy0, dx1, dy1, bits, (filter ? GL_LINEAR : GL_NEAREST));
+       glBlitFramebuffer(sx0, sy0, sx1, sy1, dx0, dy0, dx1, dy1, bits, (filter ? GL_LINEAR : GL_NEAREST));
 
        set_current(old);
-       glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, (old ? old->id : 0));
+       glBindFramebuffer(GL_FRAMEBUFFER, (old ? old->id : 0));
 }
 
 void Framebuffer::blit_from(const Framebuffer &other, int sx, int sy, unsigned wd, unsigned ht, int dx, int dy, BufferBits bits)
@@ -208,7 +207,7 @@ void Framebuffer::bind() const
 {
        if(set_current(this))
        {
-               glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, id);
+               glBindFramebuffer(GL_FRAMEBUFFER, id);
                if(dirty)
                {
                        update_attachment(dirty);
@@ -246,7 +245,7 @@ Framebuffer::Attachment::Attachment(FramebufferAttachment a):
 
 void Framebuffer::Attachment::set(Renderbuffer &r)
 {
-       type = GL_RENDERBUFFER_EXT;
+       type = GL_RENDERBUFFER;
        rbuf = &r;
        level = 0;
 }
index 8a97222c5ffac91a9c852119467130c7c8f5caad..236d29e6a3dd65a8fddcf3bdc567b92530b80c21 100644 (file)
@@ -15,24 +15,24 @@ class Texture2D;
 
 enum FramebufferAttachment
 {
-       COLOR_ATTACHMENT0  = GL_COLOR_ATTACHMENT0_EXT,
-       COLOR_ATTACHMENT1  = GL_COLOR_ATTACHMENT1_EXT,
-       COLOR_ATTACHMENT2  = GL_COLOR_ATTACHMENT2_EXT,
-       COLOR_ATTACHMENT3  = GL_COLOR_ATTACHMENT3_EXT,
-       DEPTH_ATTACHMENT   = GL_DEPTH_ATTACHMENT_EXT,
-       STENCIL_ATTACHMENT = GL_STENCIL_ATTACHMENT_EXT
+       COLOR_ATTACHMENT0  = GL_COLOR_ATTACHMENT0,
+       COLOR_ATTACHMENT1  = GL_COLOR_ATTACHMENT1,
+       COLOR_ATTACHMENT2  = GL_COLOR_ATTACHMENT2,
+       COLOR_ATTACHMENT3  = GL_COLOR_ATTACHMENT3,
+       DEPTH_ATTACHMENT   = GL_DEPTH_ATTACHMENT,
+       STENCIL_ATTACHMENT = GL_STENCIL_ATTACHMENT
 };
 
 enum FramebufferStatus
 {
-       FRAMEBUFFER_INCOMPLETE_ATTACHMENT         = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT,
-       FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT,
+       FRAMEBUFFER_INCOMPLETE_ATTACHMENT         = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT,
+       FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT,
        FRAMEBUFFER_INCOMPLETE_DIMENSIONS         = GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT,
        FRAMEBUFFER_INCOMPLETE_FORMATS            = GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT,
-       FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER        = GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT,
-       FRAMEBUFFER_INCOMPLETE_READ_BUFFER        = GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT,
-       FRAMEBUFFER_UNSUPPORTED                   = GL_FRAMEBUFFER_UNSUPPORTED_EXT,
-       FRAMEBUFFER_COMPLETE                      = GL_FRAMEBUFFER_COMPLETE_EXT
+       FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER        = GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER,
+       FRAMEBUFFER_INCOMPLETE_READ_BUFFER        = GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER,
+       FRAMEBUFFER_UNSUPPORTED                   = GL_FRAMEBUFFER_UNSUPPORTED,
+       FRAMEBUFFER_COMPLETE                      = GL_FRAMEBUFFER_COMPLETE
 };
 
 enum BufferBits
index c5e73ebd2afd625cda3d1d4041e8b7bd03145ed5..9757df5cc9e20f364ff96880f115b1707a1f8f5e 100644 (file)
@@ -1,6 +1,6 @@
 #include "buffer.h"
-#include "extension.h"
 #include "mesh.h"
+#include "nv_primitive_restart.h"
 #include "renderer.h"
 
 using namespace std;
@@ -69,7 +69,7 @@ void Mesh::add_batch(const Batch &b)
                PrimitiveType type = b.get_type();
                can_append = (type==batches.back().get_type() &&
                        type!=LINE_STRIP && type!=LINE_LOOP && type!=POLYGON &&
-                       (type!=TRIANGLE_FAN || is_supported("GL_NV_primitive_restart")));
+                       (type!=TRIANGLE_FAN || NV_primitive_restart));
        }
 
        if(defer_ibuf)
index b685e340740f91ee03dc7ffd08c489d4d59c4161..ed5a2664604c34c7282a7697758457e28c516c1f 100644 (file)
@@ -1,17 +1,23 @@
-#include "extension.h"
 #include "nv_primitive_restart.h"
 
 namespace Msp {
 namespace GL {
 
-PFNGLPRIMITIVERESTARTNVPROC glPrimitiveRestartNV = 0;
 PFNGLPRIMITIVERESTARTINDEXNVPROC glPrimitiveRestartIndexNV = 0;
+PFNGLPRIMITIVERESTARTNVPROC glPrimitiveRestartNV = 0;
 
-void init_nv_primitive_restart()
+Extension::SupportLevel init_nv_primitive_restart()
 {
-       glPrimitiveRestartNV = reinterpret_cast<PFNGLPRIMITIVERESTARTNVPROC>(get_proc_address("glPrimitiveRestartNV"));
-       glPrimitiveRestartIndexNV = reinterpret_cast<PFNGLPRIMITIVERESTARTINDEXNVPROC>(get_proc_address("glPrimitiveRestartIndexNV"));
+       if(is_supported("GL_NV_primitive_restart"))
+       {
+               glPrimitiveRestartIndexNV = reinterpret_cast<PFNGLPRIMITIVERESTARTINDEXNVPROC>(get_proc_address("glPrimitiveRestartIndexNV"));
+               glPrimitiveRestartNV = reinterpret_cast<PFNGLPRIMITIVERESTARTNVPROC>(get_proc_address("glPrimitiveRestartNV"));
+               return Extension::EXTENSION;
+       }
+       return Extension::UNSUPPORTED;
 }
 
+Extension NV_primitive_restart("GL_NV_primitive_restart", init_nv_primitive_restart);
+
 } // namespace GL
 } // namespace Msp
index b1ff5e160a49f73a38eda887c8f490727dfc627f..87358435548996b70a4a9b74360b83c698daa336 100644 (file)
@@ -1,16 +1,17 @@
 #ifndef MSP_GL_NV_PRIMITIVE_RESTART_
 #define MSP_GL_NV_PRIMITIVE_RESTART_
 
+#include "extension.h"
 #include "gl.h"
 #include <GL/glext.h>
 
 namespace Msp {
 namespace GL {
 
-extern PFNGLPRIMITIVERESTARTNVPROC glPrimitiveRestartNV;
 extern PFNGLPRIMITIVERESTARTINDEXNVPROC glPrimitiveRestartIndexNV;
+extern PFNGLPRIMITIVERESTARTNVPROC glPrimitiveRestartNV;
 
-void init_nv_primitive_restart();
+extern Extension NV_primitive_restart;
 
 } // namespace GL
 } // namespace Msp
index d962751994d38fe1e7fd93550bb51a545eaec9f6..adbb5c4cfd1a4ccf7ffd3fe41dc75646c33a1a6c 100644 (file)
@@ -8,7 +8,6 @@
 #include "arb_vertex_shader.h"
 #include "buffer.h"
 #include "error.h"
-#include "extension.h"
 #include "program.h"
 #include "shader.h"
 
@@ -133,24 +132,24 @@ Program::Program(const string &vert, const string &frag)
 
 void Program::init()
 {
-       static RequireExtension _ext("GL_ARB_shader_objects");
+       static Require _req(ARB_shader_objects);
 
        linked = false;
-       id = glCreateProgramObjectARB();
+       id = glCreateProgram();
 }
 
 Program::~Program()
 {
        for(ShaderList::iterator i=owned_data.begin(); i!=owned_data.end(); ++i)
                delete *i;
-       glDeleteObjectARB(id);
+       glDeleteProgram(id);
 }
 
 void Program::attach_shader(Shader &shader)
 {
        if(find(shaders.begin(), shaders.end(), &shader)==shaders.end())
        {
-               glAttachObjectARB(id, shader.get_id());
+               glAttachShader(id, shader.get_id());
                shaders.push_back(&shader);
        }
 }
@@ -168,7 +167,7 @@ void Program::detach_shader(Shader &shader)
        if(i!=shaders.end())
        {
                shaders.erase(i, shaders.end());
-               glDetachObjectARB(id, shader.get_id());
+               glDetachShader(id, shader.get_id());
        }
 }
 
@@ -220,8 +219,8 @@ string Program::process_standard_source(const char **source, const string &flags
 
 void Program::bind_attribute(unsigned index, const string &name)
 {
-       static RequireExtension _ext("GL_ARB_vertex_shader");
-       glBindAttribLocationARB(id, index, name.c_str());
+       static Require _req(ARB_vertex_shader);
+       glBindAttribLocation(id, index, name.c_str());
 }
 
 void Program::link()
@@ -232,13 +231,13 @@ void Program::link()
 
        uniforms.clear();
 
-       glLinkProgramARB(id);
+       glLinkProgram(id);
        int value;
-       glGetObjectParameterivARB(id, GL_OBJECT_LINK_STATUS_ARB, &value);
+       glGetProgramiv(id, GL_LINK_STATUS, &value);
        if(!(linked = value))
                throw compile_error(get_info_log());
 
-       glGetObjectParameterivARB(id, GL_OBJECT_ACTIVE_UNIFORMS_ARB, &value);
+       glGetProgramiv(id, GL_ACTIVE_UNIFORMS, &value);
        unsigned count = value;
        vector<UniformInfo *> uniforms_by_index(count);
        for(unsigned i=0; i<count; ++i)
@@ -247,7 +246,7 @@ void Program::link()
                int len = 0;
                int size;
                GLenum type;
-               glGetActiveUniformARB(id, i, 128, &len, &size, &type, name);
+               glGetActiveUniform(id, i, 128, &len, &size, &type, name);
                if(len && strncmp(name, "gl_", 3))
                {
                        UniformInfo &info = uniforms[name];
@@ -261,9 +260,9 @@ void Program::link()
                }
        }
 
-       if(is_supported("GL_ARB_uniform_buffer_object"))
+       if(ARB_uniform_buffer_object)
        {
-               glGetObjectParameterivARB(id, GL_ACTIVE_UNIFORM_BLOCKS, &value);
+               glGetProgramiv(id, GL_ACTIVE_UNIFORM_BLOCKS, &value);
                count = value;
                for(unsigned i=0; i<count; ++i)
                {
@@ -331,7 +330,7 @@ void Program::link()
        for(UniformMap::iterator i=uniforms.begin(); i!=uniforms.end(); ++i)
                if(!i->second.block)
                {
-                       i->second.location = glGetUniformLocationARB(id, i->second.name.c_str());
+                       i->second.location = glGetUniformLocation(id, i->second.name.c_str());
                        blockless_uniforms.push_back(&i->second);
                }
 
@@ -354,9 +353,9 @@ bool Program::uniform_location_compare(const UniformInfo *uni1, const UniformInf
 string Program::get_info_log() const
 {
        GLsizei len = 0;
-       glGetObjectParameterivARB(id, GL_OBJECT_INFO_LOG_LENGTH_ARB, &len);
+       glGetProgramiv(id, GL_INFO_LOG_LENGTH, &len);
        char *buf = new char[len+1];
-       glGetInfoLogARB(id, len+1, &len, buf);
+       glGetProgramInfoLog(id, len+1, &len, buf);
        string log(buf, len);
        delete[] buf;
        return log;
@@ -405,7 +404,7 @@ void Program::bind() const
        if(!set_current(this))
                return;
 
-       glUseProgramObjectARB(id);
+       glUseProgram(id);
 }
 
 void Program::unbind()
@@ -413,7 +412,7 @@ void Program::unbind()
        if(!set_current(0))
                return;
 
-       glUseProgramObjectARB(0);
+       glUseProgram(0);
 }
 
 
index f3f498f3e948966d9e1dd3524175b1d0ddc5060e..ed4b0a292b339ddc8c8bea858281949e96fca118 100644 (file)
@@ -1,7 +1,7 @@
+#include "arb_shader_objects.h"
 #include "buffer.h"
 #include "color.h"
 #include "error.h"
-#include "extension.h"
 #include "matrix.h"
 #include "program.h"
 #include "programdata.h"
@@ -19,7 +19,7 @@ ProgramData::ProgramData():
        buffer(0),
        changes(NO_CHANGES)
 {
-       static RequireExtension _ext("GL_ARB_shader_objects");
+       static Require _req(ARB_shader_objects);
 }
 
 // Blocks are intentionally left uncopied
index 240cf84c7a7285926c7ff8b6e14aa44f8c7c221c..c920633e0f2e0e84a009cab91477a1b0197a93c8 100644 (file)
@@ -1,4 +1,3 @@
-#include "extension.h"
 #include "ext_framebuffer_multisample.h"
 #include "ext_framebuffer_object.h"
 #include "renderbuffer.h"
@@ -8,14 +7,14 @@ namespace GL {
 
 Renderbuffer::Renderbuffer()
 {
-       static RequireExtension _ext("GL_EXT_framebuffer_object");
+       static Require _req(EXT_framebuffer_object);
 
-       glGenRenderbuffersEXT(1, &id);
+       glGenRenderbuffers(1, &id);
 }
 
 Renderbuffer::~Renderbuffer()
 {
-       glDeleteRenderbuffersEXT(1, &id);
+       glDeleteRenderbuffers(1, &id);
 }
 
 void Renderbuffer::storage(PixelFormat fmt, unsigned wd, unsigned ht)
@@ -23,29 +22,29 @@ void Renderbuffer::storage(PixelFormat fmt, unsigned wd, unsigned ht)
        Bind _bind(this, true);
        width = wd;
        height = ht;
-       glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, fmt, width, height);
+       glRenderbufferStorage(GL_RENDERBUFFER, fmt, width, height);
 }
 
 void Renderbuffer::storage_multisample(unsigned samples, PixelFormat fmt, unsigned wd, unsigned ht)
 {
-       static RequireExtension _ext("GL_EXT_framebuffer_multisample");
+       static Require _req(EXT_framebuffer_multisample);
 
        Bind _bind(this, true);
        width = wd;
        height = ht;
-       glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, samples, fmt, width, height);
+       glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, fmt, width, height);
 }
 
 void Renderbuffer::bind() const
 {
        if(set_current(this))
-               glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, id);
+               glBindRenderbuffer(GL_RENDERBUFFER, id);
 }
 
 void Renderbuffer::unbind()
 {
        if(set_current(0))
-               glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
+               glBindRenderbuffer(GL_RENDERBUFFER, 0);
 }
 
 } // namespace GL
diff --git a/source/sgis_generate_mipmap.cpp b/source/sgis_generate_mipmap.cpp
new file mode 100644 (file)
index 0000000..5080517
--- /dev/null
@@ -0,0 +1,18 @@
+#include "sgis_generate_mipmap.h"
+
+namespace Msp {
+namespace GL {
+
+Extension::SupportLevel init_sgis_generate_mipmap()
+{
+       if(is_supported("GL_SGIS_generate_mipmap"))
+       {
+               return Extension::EXTENSION;
+       }
+       return Extension::UNSUPPORTED;
+}
+
+Extension SGIS_generate_mipmap("GL_SGIS_generate_mipmap", init_sgis_generate_mipmap);
+
+} // namespace GL
+} // namespace Msp
diff --git a/source/sgis_generate_mipmap.h b/source/sgis_generate_mipmap.h
new file mode 100644 (file)
index 0000000..86d8802
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef MSP_GL_SGIS_GENERATE_MIPMAP_
+#define MSP_GL_SGIS_GENERATE_MIPMAP_
+
+#include "extension.h"
+#include "gl.h"
+#include <GL/glext.h>
+
+namespace Msp {
+namespace GL {
+
+extern Extension SGIS_generate_mipmap;
+
+} // namespace GL
+} // namespace Msp
+
+#endif
index cdb50c969d59edaf2dfc7edc044579192632eed7..b0cf5a3ec63d3f6ed93c4727b955f5a187232ad3 100644 (file)
@@ -1,6 +1,7 @@
+#include "arb_fragment_shader.h"
 #include "arb_shader_objects.h"
+#include "arb_vertex_shader.h"
 #include "error.h"
-#include "extension.h"
 #include "shader.h"
 
 using namespace std;
@@ -26,21 +27,21 @@ void Shader::init(ShaderType t)
        compiled = false;
 
        if(t==FRAGMENT_SHADER)
-               static RequireExtension _ext("GL_ARB_fragment_shader");
+               static Require _req(ARB_fragment_shader);
        else if(t==VERTEX_SHADER)
-               static RequireExtension _ext("GL_ARB_vertex_shader");
+               static Require _req(ARB_vertex_shader);
 
-       id = glCreateShaderObjectARB(t);
+       id = glCreateShader(t);
 }
 
 Shader::~Shader()
 {
-       glDeleteObjectARB(id);
+       glDeleteShader(id);
 }
 
 void Shader::source(unsigned count, const char **str, const int *len)
 {
-       glShaderSourceARB(id, count, str, len);
+       glShaderSource(id, count, str, len);
 }
 
 void Shader::source(const string &str)
@@ -55,9 +56,9 @@ void Shader::source(const char *str, int len)
 
 void Shader::compile()
 {
-       glCompileShaderARB(id);
+       glCompileShader(id);
        int value = 0;
-       glGetObjectParameterivARB(id, GL_OBJECT_COMPILE_STATUS_ARB, &value);
+       glGetShaderiv(id, GL_COMPILE_STATUS, &value);
        if(!(compiled = value))
                throw compile_error(get_info_log());
 }
@@ -65,9 +66,9 @@ void Shader::compile()
 string Shader::get_info_log() const
 {
        GLsizei len = 0;
-       glGetObjectParameterivARB(id, GL_OBJECT_INFO_LOG_LENGTH_ARB, &len);
+       glGetShaderiv(id, GL_INFO_LOG_LENGTH, &len);
        char *buf = new char[len+1];
-       glGetInfoLogARB(id, len+1, &len, buf);
+       glGetShaderInfoLog(id, len+1, &len, buf);
        string log(buf, len);
        delete[] buf;
        return log;
index 57b1b78dee6de407837b3b78d2bf980d189845e6..c8a1371c5b0a7724effdeb33ec7f529e70372a47 100644 (file)
@@ -1,6 +1,6 @@
 #include <msp/strings/format.h>
 #include "error.h"
-#include "extension.h"
+#include "sgis_generate_mipmap.h"
 #include "texture.h"
 #include "texunit.h"
 
@@ -126,7 +126,7 @@ void Texture::set_wrap_r(TextureWrap w)
 void Texture::set_generate_mipmap(bool gm)
 {
        if(gm)
-               static RequireExtension _ext("GL_SGIS_generate_mipmap");
+               static Require _req(SGIS_generate_mipmap);
        gen_mipmap = gm;
        update_parameter(GENERATE_MIPMAP);
 }
index 33b25cccdbacf6b2c417aff094781c3157d32e2a..0ad65f8887437da0bf1283c93ed00b7628efdc36 100644 (file)
@@ -2,9 +2,8 @@
 #include <msp/graphics/image.h>
 #include "bindable.h"
 #include "error.h"
-#include "extension.h"
+#include "ext_texture3d.h"
 #include "texture3d.h"
-#include "version_1_2.h"
 
 using namespace std;
 
@@ -18,7 +17,7 @@ Texture3D::Texture3D():
        depth(0),
        allocated(0)
 {
-       static RequireVersion _ver(1, 2);
+       static Require _req(EXT_texture3D);
 }
 
 void Texture3D::storage(PixelFormat fmt, unsigned wd, unsigned ht, unsigned dp)
index ddb0c1e05189113257d55d94656e1c4391fa3fa9..bbe6a6b679fe259915e6710036ed75336634816e 100644 (file)
@@ -1,6 +1,6 @@
+#include "arb_texture_cube_map.h"
 #include "bindable.h"
 #include "error.h"
-#include "extension.h"
 #include "texturecube.h"
 
 using namespace std;
@@ -23,7 +23,7 @@ TextureCube::TextureCube():
        size(0),
        allocated(0)
 {
-       static RequireVersion _ver(1, 3);
+       static Require _req(ARB_texture_cube_map);
 }
 
 void TextureCube::storage(PixelFormat fmt, unsigned sz)
index 7eb89a98c0515219dfd66d2a8448e622f2226dac..b19e791727c0e9f6d006c7a51eb58d3b0d634ed2 100644 (file)
@@ -1,8 +1,8 @@
 #include <stdexcept>
-#include "extension.h"
+#include "arb_multitexture.h"
+#include "arb_vertex_shader.h"
 #include "gl.h"
 #include "texunit.h"
-#include "version_1_3.h"
 
 using namespace std;
 
@@ -54,9 +54,9 @@ unsigned TexUnit::get_n_units()
        static int count = -1;
        if(count<0)
        {
-               if(is_version_at_least(2, 0) || is_supported("GL_ARB_vertex_shader"))
+               if(ARB_vertex_shader)
                        glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &count);
-               else if(is_version_at_least(1, 3))
+               else if(ARB_multitexture)
                        glGetIntegerv(GL_MAX_TEXTURE_UNITS, &count);
                else
                        count = 1;
@@ -66,6 +66,8 @@ unsigned TexUnit::get_n_units()
 
 TexUnit &TexUnit::activate(unsigned n)
 {
+       if(n>0)
+               static Require _req(ARB_multitexture);
        if(n>=get_n_units())
                throw out_of_range("TexUnit::activate");
 
index ac866cf5ddcdd9befbe6766750e0105149d3b756..09450a9a0962f991805ae0d7ba35698ff031f515 100644 (file)
@@ -7,39 +7,39 @@ namespace GL {
 template<>
 void UniformScalar<int>::apply(int index, unsigned size, const int *value)
 {
-       glUniform1ivARB(index, size, value);
+       glUniform1iv(index, size, value);
 }
 
 template<>
 void UniformScalar<float>::apply(int index, unsigned size, const float *value)
 {
-       glUniform1fvARB(index, size, value);
+       glUniform1fv(index, size, value);
 }
 
 
 template<>
 void UniformVector<float, 2>::apply(int index, unsigned size, const float *value)
 {
-       glUniform2fvARB(index, size, value);
+       glUniform2fv(index, size, value);
 }
 
 template<>
 void UniformVector<float, 3>::apply(int index, unsigned size, const float *value)
 {
-       glUniform3fvARB(index, size, value);
+       glUniform3fv(index, size, value);
 }
 
 template<>
 void UniformVector<float, 4>::apply(int index, unsigned size, const float *value)
 {
-       glUniform4fvARB(index, size, value);
+       glUniform4fv(index, size, value);
 }
 
 
 template<>
 void UniformMatrix<float, 4, 4>::apply(int index, unsigned size, const float *value)
 {
-       glUniformMatrix4fvARB(index, size, false, value);
+       glUniformMatrix4fv(index, size, false, value);
 }
 
 } // namespace GL
diff --git a/source/version_1_2.cpp b/source/version_1_2.cpp
deleted file mode 100644 (file)
index 9fed283..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-#include "extension.h"
-#include "version_1_2.h"
-
-namespace Msp {
-namespace GL {
-
-PFNGLBLENDCOLORPROC glBlendColor = 0;
-PFNGLBLENDEQUATIONPROC glBlendEquation = 0;
-PFNGLDRAWRANGEELEMENTSPROC glDrawRangeElements = 0;
-PFNGLCOLORTABLEPROC glColorTable = 0;
-PFNGLCOLORTABLEPARAMETERFVPROC glColorTableParameterfv = 0;
-PFNGLCOLORTABLEPARAMETERIVPROC glColorTableParameteriv = 0;
-PFNGLCOPYCOLORTABLEPROC glCopyColorTable = 0;
-PFNGLGETCOLORTABLEPROC glGetColorTable = 0;
-PFNGLGETCOLORTABLEPARAMETERFVPROC glGetColorTableParameterfv = 0;
-PFNGLGETCOLORTABLEPARAMETERIVPROC glGetColorTableParameteriv = 0;
-PFNGLCOLORSUBTABLEPROC glColorSubTable = 0;
-PFNGLCOPYCOLORSUBTABLEPROC glCopyColorSubTable = 0;
-PFNGLCONVOLUTIONFILTER1DPROC glConvolutionFilter1D = 0;
-PFNGLCONVOLUTIONFILTER2DPROC glConvolutionFilter2D = 0;
-PFNGLCONVOLUTIONPARAMETERFPROC glConvolutionParameterf = 0;
-PFNGLCONVOLUTIONPARAMETERFVPROC glConvolutionParameterfv = 0;
-PFNGLCONVOLUTIONPARAMETERIPROC glConvolutionParameteri = 0;
-PFNGLCONVOLUTIONPARAMETERIVPROC glConvolutionParameteriv = 0;
-PFNGLCOPYCONVOLUTIONFILTER1DPROC glCopyConvolutionFilter1D = 0;
-PFNGLCOPYCONVOLUTIONFILTER2DPROC glCopyConvolutionFilter2D = 0;
-PFNGLGETCONVOLUTIONFILTERPROC glGetConvolutionFilter = 0;
-PFNGLGETCONVOLUTIONPARAMETERFVPROC glGetConvolutionParameterfv = 0;
-PFNGLGETCONVOLUTIONPARAMETERIVPROC glGetConvolutionParameteriv = 0;
-PFNGLGETSEPARABLEFILTERPROC glGetSeparableFilter = 0;
-PFNGLSEPARABLEFILTER2DPROC glSeparableFilter2D = 0;
-PFNGLGETHISTOGRAMPROC glGetHistogram = 0;
-PFNGLGETHISTOGRAMPARAMETERFVPROC glGetHistogramParameterfv = 0;
-PFNGLGETHISTOGRAMPARAMETERIVPROC glGetHistogramParameteriv = 0;
-PFNGLGETMINMAXPROC glGetMinmax = 0;
-PFNGLGETMINMAXPARAMETERFVPROC glGetMinmaxParameterfv = 0;
-PFNGLGETMINMAXPARAMETERIVPROC glGetMinmaxParameteriv = 0;
-PFNGLHISTOGRAMPROC glHistogram = 0;
-PFNGLMINMAXPROC glMinmax = 0;
-PFNGLRESETHISTOGRAMPROC glResetHistogram = 0;
-PFNGLRESETMINMAXPROC glResetMinmax = 0;
-PFNGLTEXIMAGE3DPROC glTexImage3D = 0;
-PFNGLTEXSUBIMAGE3DPROC glTexSubImage3D = 0;
-PFNGLCOPYTEXSUBIMAGE3DPROC glCopyTexSubImage3D = 0;
-
-void init_version_1_2()
-{
-       glBlendColor = reinterpret_cast<PFNGLBLENDCOLORPROC>(get_proc_address("glBlendColor"));
-       glBlendEquation = reinterpret_cast<PFNGLBLENDEQUATIONPROC>(get_proc_address("glBlendEquation"));
-       glDrawRangeElements = reinterpret_cast<PFNGLDRAWRANGEELEMENTSPROC>(get_proc_address("glDrawRangeElements"));
-       glColorTable = reinterpret_cast<PFNGLCOLORTABLEPROC>(get_proc_address("glColorTable"));
-       glColorTableParameterfv = reinterpret_cast<PFNGLCOLORTABLEPARAMETERFVPROC>(get_proc_address("glColorTableParameterfv"));
-       glColorTableParameteriv = reinterpret_cast<PFNGLCOLORTABLEPARAMETERIVPROC>(get_proc_address("glColorTableParameteriv"));
-       glCopyColorTable = reinterpret_cast<PFNGLCOPYCOLORTABLEPROC>(get_proc_address("glCopyColorTable"));
-       glGetColorTable = reinterpret_cast<PFNGLGETCOLORTABLEPROC>(get_proc_address("glGetColorTable"));
-       glGetColorTableParameterfv = reinterpret_cast<PFNGLGETCOLORTABLEPARAMETERFVPROC>(get_proc_address("glGetColorTableParameterfv"));
-       glGetColorTableParameteriv = reinterpret_cast<PFNGLGETCOLORTABLEPARAMETERIVPROC>(get_proc_address("glGetColorTableParameteriv"));
-       glColorSubTable = reinterpret_cast<PFNGLCOLORSUBTABLEPROC>(get_proc_address("glColorSubTable"));
-       glCopyColorSubTable = reinterpret_cast<PFNGLCOPYCOLORSUBTABLEPROC>(get_proc_address("glCopyColorSubTable"));
-       glConvolutionFilter1D = reinterpret_cast<PFNGLCONVOLUTIONFILTER1DPROC>(get_proc_address("glConvolutionFilter1D"));
-       glConvolutionFilter2D = reinterpret_cast<PFNGLCONVOLUTIONFILTER2DPROC>(get_proc_address("glConvolutionFilter2D"));
-       glConvolutionParameterf = reinterpret_cast<PFNGLCONVOLUTIONPARAMETERFPROC>(get_proc_address("glConvolutionParameterf"));
-       glConvolutionParameterfv = reinterpret_cast<PFNGLCONVOLUTIONPARAMETERFVPROC>(get_proc_address("glConvolutionParameterfv"));
-       glConvolutionParameteri = reinterpret_cast<PFNGLCONVOLUTIONPARAMETERIPROC>(get_proc_address("glConvolutionParameteri"));
-       glConvolutionParameteriv = reinterpret_cast<PFNGLCONVOLUTIONPARAMETERIVPROC>(get_proc_address("glConvolutionParameteriv"));
-       glCopyConvolutionFilter1D = reinterpret_cast<PFNGLCOPYCONVOLUTIONFILTER1DPROC>(get_proc_address("glCopyConvolutionFilter1D"));
-       glCopyConvolutionFilter2D = reinterpret_cast<PFNGLCOPYCONVOLUTIONFILTER2DPROC>(get_proc_address("glCopyConvolutionFilter2D"));
-       glGetConvolutionFilter = reinterpret_cast<PFNGLGETCONVOLUTIONFILTERPROC>(get_proc_address("glGetConvolutionFilter"));
-       glGetConvolutionParameterfv = reinterpret_cast<PFNGLGETCONVOLUTIONPARAMETERFVPROC>(get_proc_address("glGetConvolutionParameterfv"));
-       glGetConvolutionParameteriv = reinterpret_cast<PFNGLGETCONVOLUTIONPARAMETERIVPROC>(get_proc_address("glGetConvolutionParameteriv"));
-       glGetSeparableFilter = reinterpret_cast<PFNGLGETSEPARABLEFILTERPROC>(get_proc_address("glGetSeparableFilter"));
-       glSeparableFilter2D = reinterpret_cast<PFNGLSEPARABLEFILTER2DPROC>(get_proc_address("glSeparableFilter2D"));
-       glGetHistogram = reinterpret_cast<PFNGLGETHISTOGRAMPROC>(get_proc_address("glGetHistogram"));
-       glGetHistogramParameterfv = reinterpret_cast<PFNGLGETHISTOGRAMPARAMETERFVPROC>(get_proc_address("glGetHistogramParameterfv"));
-       glGetHistogramParameteriv = reinterpret_cast<PFNGLGETHISTOGRAMPARAMETERIVPROC>(get_proc_address("glGetHistogramParameteriv"));
-       glGetMinmax = reinterpret_cast<PFNGLGETMINMAXPROC>(get_proc_address("glGetMinmax"));
-       glGetMinmaxParameterfv = reinterpret_cast<PFNGLGETMINMAXPARAMETERFVPROC>(get_proc_address("glGetMinmaxParameterfv"));
-       glGetMinmaxParameteriv = reinterpret_cast<PFNGLGETMINMAXPARAMETERIVPROC>(get_proc_address("glGetMinmaxParameteriv"));
-       glHistogram = reinterpret_cast<PFNGLHISTOGRAMPROC>(get_proc_address("glHistogram"));
-       glMinmax = reinterpret_cast<PFNGLMINMAXPROC>(get_proc_address("glMinmax"));
-       glResetHistogram = reinterpret_cast<PFNGLRESETHISTOGRAMPROC>(get_proc_address("glResetHistogram"));
-       glResetMinmax = reinterpret_cast<PFNGLRESETMINMAXPROC>(get_proc_address("glResetMinmax"));
-       glTexImage3D = reinterpret_cast<PFNGLTEXIMAGE3DPROC>(get_proc_address("glTexImage3D"));
-       glTexSubImage3D = reinterpret_cast<PFNGLTEXSUBIMAGE3DPROC>(get_proc_address("glTexSubImage3D"));
-       glCopyTexSubImage3D = reinterpret_cast<PFNGLCOPYTEXSUBIMAGE3DPROC>(get_proc_address("glCopyTexSubImage3D"));
-}
-
-} // namespace GL
-} // namespace Msp
diff --git a/source/version_1_2.h b/source/version_1_2.h
deleted file mode 100644 (file)
index d10ba53..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef MSP_GL_VERSION_1_2_
-#define MSP_GL_VERSION_1_2_
-
-#include "gl.h"
-#include <GL/glext.h>
-
-namespace Msp {
-namespace GL {
-
-extern PFNGLBLENDCOLORPROC glBlendColor;
-extern PFNGLBLENDEQUATIONPROC glBlendEquation;
-extern PFNGLDRAWRANGEELEMENTSPROC glDrawRangeElements;
-extern PFNGLCOLORTABLEPROC glColorTable;
-extern PFNGLCOLORTABLEPARAMETERFVPROC glColorTableParameterfv;
-extern PFNGLCOLORTABLEPARAMETERIVPROC glColorTableParameteriv;
-extern PFNGLCOPYCOLORTABLEPROC glCopyColorTable;
-extern PFNGLGETCOLORTABLEPROC glGetColorTable;
-extern PFNGLGETCOLORTABLEPARAMETERFVPROC glGetColorTableParameterfv;
-extern PFNGLGETCOLORTABLEPARAMETERIVPROC glGetColorTableParameteriv;
-extern PFNGLCOLORSUBTABLEPROC glColorSubTable;
-extern PFNGLCOPYCOLORSUBTABLEPROC glCopyColorSubTable;
-extern PFNGLCONVOLUTIONFILTER1DPROC glConvolutionFilter1D;
-extern PFNGLCONVOLUTIONFILTER2DPROC glConvolutionFilter2D;
-extern PFNGLCONVOLUTIONPARAMETERFPROC glConvolutionParameterf;
-extern PFNGLCONVOLUTIONPARAMETERFVPROC glConvolutionParameterfv;
-extern PFNGLCONVOLUTIONPARAMETERIPROC glConvolutionParameteri;
-extern PFNGLCONVOLUTIONPARAMETERIVPROC glConvolutionParameteriv;
-extern PFNGLCOPYCONVOLUTIONFILTER1DPROC glCopyConvolutionFilter1D;
-extern PFNGLCOPYCONVOLUTIONFILTER2DPROC glCopyConvolutionFilter2D;
-extern PFNGLGETCONVOLUTIONFILTERPROC glGetConvolutionFilter;
-extern PFNGLGETCONVOLUTIONPARAMETERFVPROC glGetConvolutionParameterfv;
-extern PFNGLGETCONVOLUTIONPARAMETERIVPROC glGetConvolutionParameteriv;
-extern PFNGLGETSEPARABLEFILTERPROC glGetSeparableFilter;
-extern PFNGLSEPARABLEFILTER2DPROC glSeparableFilter2D;
-extern PFNGLGETHISTOGRAMPROC glGetHistogram;
-extern PFNGLGETHISTOGRAMPARAMETERFVPROC glGetHistogramParameterfv;
-extern PFNGLGETHISTOGRAMPARAMETERIVPROC glGetHistogramParameteriv;
-extern PFNGLGETMINMAXPROC glGetMinmax;
-extern PFNGLGETMINMAXPARAMETERFVPROC glGetMinmaxParameterfv;
-extern PFNGLGETMINMAXPARAMETERIVPROC glGetMinmaxParameteriv;
-extern PFNGLHISTOGRAMPROC glHistogram;
-extern PFNGLMINMAXPROC glMinmax;
-extern PFNGLRESETHISTOGRAMPROC glResetHistogram;
-extern PFNGLRESETMINMAXPROC glResetMinmax;
-extern PFNGLTEXIMAGE3DPROC glTexImage3D;
-extern PFNGLTEXSUBIMAGE3DPROC glTexSubImage3D;
-extern PFNGLCOPYTEXSUBIMAGE3DPROC glCopyTexSubImage3D;
-
-void init_version_1_2();
-
-} // namespace GL
-} // namespace Msp
-
-#endif
diff --git a/source/version_1_3.cpp b/source/version_1_3.cpp
deleted file mode 100644 (file)
index d248a08..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-#include "extension.h"
-#include "version_1_3.h"
-
-namespace Msp {
-namespace GL {
-
-PFNGLACTIVETEXTUREPROC glActiveTexture = 0;
-PFNGLCLIENTACTIVETEXTUREPROC glClientActiveTexture = 0;
-PFNGLMULTITEXCOORD1DPROC glMultiTexCoord1d = 0;
-PFNGLMULTITEXCOORD1DVPROC glMultiTexCoord1dv = 0;
-PFNGLMULTITEXCOORD1FPROC glMultiTexCoord1f = 0;
-PFNGLMULTITEXCOORD1FVPROC glMultiTexCoord1fv = 0;
-PFNGLMULTITEXCOORD1IPROC glMultiTexCoord1i = 0;
-PFNGLMULTITEXCOORD1IVPROC glMultiTexCoord1iv = 0;
-PFNGLMULTITEXCOORD1SPROC glMultiTexCoord1s = 0;
-PFNGLMULTITEXCOORD1SVPROC glMultiTexCoord1sv = 0;
-PFNGLMULTITEXCOORD2DPROC glMultiTexCoord2d = 0;
-PFNGLMULTITEXCOORD2DVPROC glMultiTexCoord2dv = 0;
-PFNGLMULTITEXCOORD2FPROC glMultiTexCoord2f = 0;
-PFNGLMULTITEXCOORD2FVPROC glMultiTexCoord2fv = 0;
-PFNGLMULTITEXCOORD2IPROC glMultiTexCoord2i = 0;
-PFNGLMULTITEXCOORD2IVPROC glMultiTexCoord2iv = 0;
-PFNGLMULTITEXCOORD2SPROC glMultiTexCoord2s = 0;
-PFNGLMULTITEXCOORD2SVPROC glMultiTexCoord2sv = 0;
-PFNGLMULTITEXCOORD3DPROC glMultiTexCoord3d = 0;
-PFNGLMULTITEXCOORD3DVPROC glMultiTexCoord3dv = 0;
-PFNGLMULTITEXCOORD3FPROC glMultiTexCoord3f = 0;
-PFNGLMULTITEXCOORD3FVPROC glMultiTexCoord3fv = 0;
-PFNGLMULTITEXCOORD3IPROC glMultiTexCoord3i = 0;
-PFNGLMULTITEXCOORD3IVPROC glMultiTexCoord3iv = 0;
-PFNGLMULTITEXCOORD3SPROC glMultiTexCoord3s = 0;
-PFNGLMULTITEXCOORD3SVPROC glMultiTexCoord3sv = 0;
-PFNGLMULTITEXCOORD4DPROC glMultiTexCoord4d = 0;
-PFNGLMULTITEXCOORD4DVPROC glMultiTexCoord4dv = 0;
-PFNGLMULTITEXCOORD4FPROC glMultiTexCoord4f = 0;
-PFNGLMULTITEXCOORD4FVPROC glMultiTexCoord4fv = 0;
-PFNGLMULTITEXCOORD4IPROC glMultiTexCoord4i = 0;
-PFNGLMULTITEXCOORD4IVPROC glMultiTexCoord4iv = 0;
-PFNGLMULTITEXCOORD4SPROC glMultiTexCoord4s = 0;
-PFNGLMULTITEXCOORD4SVPROC glMultiTexCoord4sv = 0;
-PFNGLLOADTRANSPOSEMATRIXFPROC glLoadTransposeMatrixf = 0;
-PFNGLLOADTRANSPOSEMATRIXDPROC glLoadTransposeMatrixd = 0;
-PFNGLMULTTRANSPOSEMATRIXFPROC glMultTransposeMatrixf = 0;
-PFNGLMULTTRANSPOSEMATRIXDPROC glMultTransposeMatrixd = 0;
-PFNGLSAMPLECOVERAGEPROC glSampleCoverage = 0;
-PFNGLCOMPRESSEDTEXIMAGE3DPROC glCompressedTexImage3D = 0;
-PFNGLCOMPRESSEDTEXIMAGE2DPROC glCompressedTexImage2D = 0;
-PFNGLCOMPRESSEDTEXIMAGE1DPROC glCompressedTexImage1D = 0;
-PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glCompressedTexSubImage3D = 0;
-PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glCompressedTexSubImage2D = 0;
-PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glCompressedTexSubImage1D = 0;
-PFNGLGETCOMPRESSEDTEXIMAGEPROC glGetCompressedTexImage = 0;
-
-void init_version_1_3()
-{
-       glActiveTexture = reinterpret_cast<PFNGLACTIVETEXTUREPROC>(get_proc_address("glActiveTexture"));
-       glClientActiveTexture = reinterpret_cast<PFNGLCLIENTACTIVETEXTUREPROC>(get_proc_address("glClientActiveTexture"));
-       glMultiTexCoord1d = reinterpret_cast<PFNGLMULTITEXCOORD1DPROC>(get_proc_address("glMultiTexCoord1d"));
-       glMultiTexCoord1dv = reinterpret_cast<PFNGLMULTITEXCOORD1DVPROC>(get_proc_address("glMultiTexCoord1dv"));
-       glMultiTexCoord1f = reinterpret_cast<PFNGLMULTITEXCOORD1FPROC>(get_proc_address("glMultiTexCoord1f"));
-       glMultiTexCoord1fv = reinterpret_cast<PFNGLMULTITEXCOORD1FVPROC>(get_proc_address("glMultiTexCoord1fv"));
-       glMultiTexCoord1i = reinterpret_cast<PFNGLMULTITEXCOORD1IPROC>(get_proc_address("glMultiTexCoord1i"));
-       glMultiTexCoord1iv = reinterpret_cast<PFNGLMULTITEXCOORD1IVPROC>(get_proc_address("glMultiTexCoord1iv"));
-       glMultiTexCoord1s = reinterpret_cast<PFNGLMULTITEXCOORD1SPROC>(get_proc_address("glMultiTexCoord1s"));
-       glMultiTexCoord1sv = reinterpret_cast<PFNGLMULTITEXCOORD1SVPROC>(get_proc_address("glMultiTexCoord1sv"));
-       glMultiTexCoord2d = reinterpret_cast<PFNGLMULTITEXCOORD2DPROC>(get_proc_address("glMultiTexCoord2d"));
-       glMultiTexCoord2dv = reinterpret_cast<PFNGLMULTITEXCOORD2DVPROC>(get_proc_address("glMultiTexCoord2dv"));
-       glMultiTexCoord2f = reinterpret_cast<PFNGLMULTITEXCOORD2FPROC>(get_proc_address("glMultiTexCoord2f"));
-       glMultiTexCoord2fv = reinterpret_cast<PFNGLMULTITEXCOORD2FVPROC>(get_proc_address("glMultiTexCoord2fv"));
-       glMultiTexCoord2i = reinterpret_cast<PFNGLMULTITEXCOORD2IPROC>(get_proc_address("glMultiTexCoord2i"));
-       glMultiTexCoord2iv = reinterpret_cast<PFNGLMULTITEXCOORD2IVPROC>(get_proc_address("glMultiTexCoord2iv"));
-       glMultiTexCoord2s = reinterpret_cast<PFNGLMULTITEXCOORD2SPROC>(get_proc_address("glMultiTexCoord2s"));
-       glMultiTexCoord2sv = reinterpret_cast<PFNGLMULTITEXCOORD2SVPROC>(get_proc_address("glMultiTexCoord2sv"));
-       glMultiTexCoord3d = reinterpret_cast<PFNGLMULTITEXCOORD3DPROC>(get_proc_address("glMultiTexCoord3d"));
-       glMultiTexCoord3dv = reinterpret_cast<PFNGLMULTITEXCOORD3DVPROC>(get_proc_address("glMultiTexCoord3dv"));
-       glMultiTexCoord3f = reinterpret_cast<PFNGLMULTITEXCOORD3FPROC>(get_proc_address("glMultiTexCoord3f"));
-       glMultiTexCoord3fv = reinterpret_cast<PFNGLMULTITEXCOORD3FVPROC>(get_proc_address("glMultiTexCoord3fv"));
-       glMultiTexCoord3i = reinterpret_cast<PFNGLMULTITEXCOORD3IPROC>(get_proc_address("glMultiTexCoord3i"));
-       glMultiTexCoord3iv = reinterpret_cast<PFNGLMULTITEXCOORD3IVPROC>(get_proc_address("glMultiTexCoord3iv"));
-       glMultiTexCoord3s = reinterpret_cast<PFNGLMULTITEXCOORD3SPROC>(get_proc_address("glMultiTexCoord3s"));
-       glMultiTexCoord3sv = reinterpret_cast<PFNGLMULTITEXCOORD3SVPROC>(get_proc_address("glMultiTexCoord3sv"));
-       glMultiTexCoord4d = reinterpret_cast<PFNGLMULTITEXCOORD4DPROC>(get_proc_address("glMultiTexCoord4d"));
-       glMultiTexCoord4dv = reinterpret_cast<PFNGLMULTITEXCOORD4DVPROC>(get_proc_address("glMultiTexCoord4dv"));
-       glMultiTexCoord4f = reinterpret_cast<PFNGLMULTITEXCOORD4FPROC>(get_proc_address("glMultiTexCoord4f"));
-       glMultiTexCoord4fv = reinterpret_cast<PFNGLMULTITEXCOORD4FVPROC>(get_proc_address("glMultiTexCoord4fv"));
-       glMultiTexCoord4i = reinterpret_cast<PFNGLMULTITEXCOORD4IPROC>(get_proc_address("glMultiTexCoord4i"));
-       glMultiTexCoord4iv = reinterpret_cast<PFNGLMULTITEXCOORD4IVPROC>(get_proc_address("glMultiTexCoord4iv"));
-       glMultiTexCoord4s = reinterpret_cast<PFNGLMULTITEXCOORD4SPROC>(get_proc_address("glMultiTexCoord4s"));
-       glMultiTexCoord4sv = reinterpret_cast<PFNGLMULTITEXCOORD4SVPROC>(get_proc_address("glMultiTexCoord4sv"));
-       glLoadTransposeMatrixf = reinterpret_cast<PFNGLLOADTRANSPOSEMATRIXFPROC>(get_proc_address("glLoadTransposeMatrixf"));
-       glLoadTransposeMatrixd = reinterpret_cast<PFNGLLOADTRANSPOSEMATRIXDPROC>(get_proc_address("glLoadTransposeMatrixd"));
-       glMultTransposeMatrixf = reinterpret_cast<PFNGLMULTTRANSPOSEMATRIXFPROC>(get_proc_address("glMultTransposeMatrixf"));
-       glMultTransposeMatrixd = reinterpret_cast<PFNGLMULTTRANSPOSEMATRIXDPROC>(get_proc_address("glMultTransposeMatrixd"));
-       glSampleCoverage = reinterpret_cast<PFNGLSAMPLECOVERAGEPROC>(get_proc_address("glSampleCoverage"));
-       glCompressedTexImage3D = reinterpret_cast<PFNGLCOMPRESSEDTEXIMAGE3DPROC>(get_proc_address("glCompressedTexImage3D"));
-       glCompressedTexImage2D = reinterpret_cast<PFNGLCOMPRESSEDTEXIMAGE2DPROC>(get_proc_address("glCompressedTexImage2D"));
-       glCompressedTexImage1D = reinterpret_cast<PFNGLCOMPRESSEDTEXIMAGE1DPROC>(get_proc_address("glCompressedTexImage1D"));
-       glCompressedTexSubImage3D = reinterpret_cast<PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC>(get_proc_address("glCompressedTexSubImage3D"));
-       glCompressedTexSubImage2D = reinterpret_cast<PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC>(get_proc_address("glCompressedTexSubImage2D"));
-       glCompressedTexSubImage1D = reinterpret_cast<PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC>(get_proc_address("glCompressedTexSubImage1D"));
-       glGetCompressedTexImage = reinterpret_cast<PFNGLGETCOMPRESSEDTEXIMAGEPROC>(get_proc_address("glGetCompressedTexImage"));
-}
-
-} // namespace GL
-} // namespace Msp
diff --git a/source/version_1_3.h b/source/version_1_3.h
deleted file mode 100644 (file)
index bd0b4ea..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-#ifndef MSP_GL_VERSION_1_3_
-#define MSP_GL_VERSION_1_3_
-
-#include "gl.h"
-#include <GL/glext.h>
-
-namespace Msp {
-namespace GL {
-
-extern PFNGLACTIVETEXTUREPROC glActiveTexture;
-extern PFNGLCLIENTACTIVETEXTUREPROC glClientActiveTexture;
-extern PFNGLMULTITEXCOORD1DPROC glMultiTexCoord1d;
-extern PFNGLMULTITEXCOORD1DVPROC glMultiTexCoord1dv;
-extern PFNGLMULTITEXCOORD1FPROC glMultiTexCoord1f;
-extern PFNGLMULTITEXCOORD1FVPROC glMultiTexCoord1fv;
-extern PFNGLMULTITEXCOORD1IPROC glMultiTexCoord1i;
-extern PFNGLMULTITEXCOORD1IVPROC glMultiTexCoord1iv;
-extern PFNGLMULTITEXCOORD1SPROC glMultiTexCoord1s;
-extern PFNGLMULTITEXCOORD1SVPROC glMultiTexCoord1sv;
-extern PFNGLMULTITEXCOORD2DPROC glMultiTexCoord2d;
-extern PFNGLMULTITEXCOORD2DVPROC glMultiTexCoord2dv;
-extern PFNGLMULTITEXCOORD2FPROC glMultiTexCoord2f;
-extern PFNGLMULTITEXCOORD2FVPROC glMultiTexCoord2fv;
-extern PFNGLMULTITEXCOORD2IPROC glMultiTexCoord2i;
-extern PFNGLMULTITEXCOORD2IVPROC glMultiTexCoord2iv;
-extern PFNGLMULTITEXCOORD2SPROC glMultiTexCoord2s;
-extern PFNGLMULTITEXCOORD2SVPROC glMultiTexCoord2sv;
-extern PFNGLMULTITEXCOORD3DPROC glMultiTexCoord3d;
-extern PFNGLMULTITEXCOORD3DVPROC glMultiTexCoord3dv;
-extern PFNGLMULTITEXCOORD3FPROC glMultiTexCoord3f;
-extern PFNGLMULTITEXCOORD3FVPROC glMultiTexCoord3fv;
-extern PFNGLMULTITEXCOORD3IPROC glMultiTexCoord3i;
-extern PFNGLMULTITEXCOORD3IVPROC glMultiTexCoord3iv;
-extern PFNGLMULTITEXCOORD3SPROC glMultiTexCoord3s;
-extern PFNGLMULTITEXCOORD3SVPROC glMultiTexCoord3sv;
-extern PFNGLMULTITEXCOORD4DPROC glMultiTexCoord4d;
-extern PFNGLMULTITEXCOORD4DVPROC glMultiTexCoord4dv;
-extern PFNGLMULTITEXCOORD4FPROC glMultiTexCoord4f;
-extern PFNGLMULTITEXCOORD4FVPROC glMultiTexCoord4fv;
-extern PFNGLMULTITEXCOORD4IPROC glMultiTexCoord4i;
-extern PFNGLMULTITEXCOORD4IVPROC glMultiTexCoord4iv;
-extern PFNGLMULTITEXCOORD4SPROC glMultiTexCoord4s;
-extern PFNGLMULTITEXCOORD4SVPROC glMultiTexCoord4sv;
-extern PFNGLLOADTRANSPOSEMATRIXFPROC glLoadTransposeMatrixf;
-extern PFNGLLOADTRANSPOSEMATRIXDPROC glLoadTransposeMatrixd;
-extern PFNGLMULTTRANSPOSEMATRIXFPROC glMultTransposeMatrixf;
-extern PFNGLMULTTRANSPOSEMATRIXDPROC glMultTransposeMatrixd;
-extern PFNGLSAMPLECOVERAGEPROC glSampleCoverage;
-extern PFNGLCOMPRESSEDTEXIMAGE3DPROC glCompressedTexImage3D;
-extern PFNGLCOMPRESSEDTEXIMAGE2DPROC glCompressedTexImage2D;
-extern PFNGLCOMPRESSEDTEXIMAGE1DPROC glCompressedTexImage1D;
-extern PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glCompressedTexSubImage3D;
-extern PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glCompressedTexSubImage2D;
-extern PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glCompressedTexSubImage1D;
-extern PFNGLGETCOMPRESSEDTEXIMAGEPROC glGetCompressedTexImage;
-
-void init_version_1_3();
-
-} // namespace GL
-} // namespace Msp
-
-#endif
index e5e8120432bb856ce7170eb6168e190b206d67ec..13816a13fc04caf572559d592cd91ad2fe3ccdd0 100644 (file)
@@ -1,10 +1,8 @@
-#include "arb_vertex_program.h"
+#include "arb_multitexture.h"
+#include "arb_vertex_shader.h"
 #include "buffer.h"
 #include "error.h"
-#include "extension.h"
 #include "gl.h"
-#include "version_1_2.h"
-#include "version_1_3.h"
 #include "vertexarray.h"
 
 using namespace std;
@@ -68,9 +66,9 @@ void VertexArray::reset(const VertexFormat &f)
                        has_gen_attrs = true;
        }
        if(has_multitex)
-               static RequireVersion _ver(1, 3);
+               static Require _req(ARB_multitexture);
        if(has_gen_attrs)
-               static RequireExtension _ext("GL_ARB_vertex_program");
+               static Require _req(ARB_vertex_shader);
 }
 
 void VertexArray::apply() const
@@ -132,9 +130,9 @@ void VertexArray::apply() const
                        }
                        else
                        {
-                               glVertexAttribPointerARB(t-11, sz, GL_FLOAT, false, bpv, base+offset);
+                               glVertexAttribPointer(t-11, sz, GL_FLOAT, false, bpv, base+offset);
                                if(!en)
-                                       glEnableVertexAttribArrayARB(t-11);
+                                       glEnableVertexAttribArray(t-11);
                        }
                        break;
                }
@@ -159,7 +157,7 @@ void VertexArray::apply() const
                                active_tex = i-3;
                        }
                        else
-                               glDisableVertexAttribArrayARB(i-11);
+                               glDisableVertexAttribArray(i-11);
                }
 
        enabled_arrays = found;