From: Mikko Rasa Date: Mon, 27 Aug 2012 20:22:10 +0000 (+0300) Subject: Complete rewrite of extension handling X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=6afbace895a7bbcf216ab8e48280ea0303ab5892;p=libs%2Fgl.git Complete rewrite of extension handling 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. --- diff --git a/gl.spec.fixes b/gl.spec.fixes new file mode 100644 index 00000000..4a3cba1f --- /dev/null +++ b/gl.spec.fixes @@ -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 diff --git a/scripts/extgen.py b/scripts/extgen.py index f349d525..d6727123 100755 --- a/scripts/extgen.py +++ b/scripts/extgen.py @@ -2,39 +2,122 @@ import sys -ext = sys.argv[1] +if len(sys.argv)<2: + print """Usage: + extgen.py [] [ ...]" + +Reads gl.spec and generates files to use . Any promoted functions +are exposed with their promoted names. If extensions are given, +any promoted functions from those are pulled in as well. can be +given to override the version where 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 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(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(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(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 index 00000000..18524dcf --- /dev/null +++ b/source/arb_fragment_shader.cpp @@ -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 index 00000000..984f1555 --- /dev/null +++ b/source/arb_fragment_shader.h @@ -0,0 +1,16 @@ +#ifndef MSP_GL_ARB_FRAGMENT_SHADER_ +#define MSP_GL_ARB_FRAGMENT_SHADER_ + +#include "extension.h" +#include "gl.h" +#include + +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 index 00000000..391b0455 --- /dev/null +++ b/source/arb_multitexture.cpp @@ -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(get_proc_address("glActiveTexture")); + glClientActiveTexture = reinterpret_cast(get_proc_address("glClientActiveTexture")); + glMultiTexCoord1d = reinterpret_cast(get_proc_address("glMultiTexCoord1d")); + glMultiTexCoord1dv = reinterpret_cast(get_proc_address("glMultiTexCoord1dv")); + glMultiTexCoord1f = reinterpret_cast(get_proc_address("glMultiTexCoord1f")); + glMultiTexCoord1fv = reinterpret_cast(get_proc_address("glMultiTexCoord1fv")); + glMultiTexCoord1i = reinterpret_cast(get_proc_address("glMultiTexCoord1i")); + glMultiTexCoord1iv = reinterpret_cast(get_proc_address("glMultiTexCoord1iv")); + glMultiTexCoord1s = reinterpret_cast(get_proc_address("glMultiTexCoord1s")); + glMultiTexCoord1sv = reinterpret_cast(get_proc_address("glMultiTexCoord1sv")); + glMultiTexCoord2d = reinterpret_cast(get_proc_address("glMultiTexCoord2d")); + glMultiTexCoord2dv = reinterpret_cast(get_proc_address("glMultiTexCoord2dv")); + glMultiTexCoord2f = reinterpret_cast(get_proc_address("glMultiTexCoord2f")); + glMultiTexCoord2fv = reinterpret_cast(get_proc_address("glMultiTexCoord2fv")); + glMultiTexCoord2i = reinterpret_cast(get_proc_address("glMultiTexCoord2i")); + glMultiTexCoord2iv = reinterpret_cast(get_proc_address("glMultiTexCoord2iv")); + glMultiTexCoord2s = reinterpret_cast(get_proc_address("glMultiTexCoord2s")); + glMultiTexCoord2sv = reinterpret_cast(get_proc_address("glMultiTexCoord2sv")); + glMultiTexCoord3d = reinterpret_cast(get_proc_address("glMultiTexCoord3d")); + glMultiTexCoord3dv = reinterpret_cast(get_proc_address("glMultiTexCoord3dv")); + glMultiTexCoord3f = reinterpret_cast(get_proc_address("glMultiTexCoord3f")); + glMultiTexCoord3fv = reinterpret_cast(get_proc_address("glMultiTexCoord3fv")); + glMultiTexCoord3i = reinterpret_cast(get_proc_address("glMultiTexCoord3i")); + glMultiTexCoord3iv = reinterpret_cast(get_proc_address("glMultiTexCoord3iv")); + glMultiTexCoord3s = reinterpret_cast(get_proc_address("glMultiTexCoord3s")); + glMultiTexCoord3sv = reinterpret_cast(get_proc_address("glMultiTexCoord3sv")); + glMultiTexCoord4d = reinterpret_cast(get_proc_address("glMultiTexCoord4d")); + glMultiTexCoord4dv = reinterpret_cast(get_proc_address("glMultiTexCoord4dv")); + glMultiTexCoord4f = reinterpret_cast(get_proc_address("glMultiTexCoord4f")); + glMultiTexCoord4fv = reinterpret_cast(get_proc_address("glMultiTexCoord4fv")); + glMultiTexCoord4i = reinterpret_cast(get_proc_address("glMultiTexCoord4i")); + glMultiTexCoord4iv = reinterpret_cast(get_proc_address("glMultiTexCoord4iv")); + glMultiTexCoord4s = reinterpret_cast(get_proc_address("glMultiTexCoord4s")); + glMultiTexCoord4sv = reinterpret_cast(get_proc_address("glMultiTexCoord4sv")); + return Extension::CORE; + } + if(is_supported("GL_ARB_multitexture")) + { + glActiveTexture = reinterpret_cast(get_proc_address("glActiveTextureARB")); + glClientActiveTexture = reinterpret_cast(get_proc_address("glClientActiveTextureARB")); + glMultiTexCoord1d = reinterpret_cast(get_proc_address("glMultiTexCoord1dARB")); + glMultiTexCoord1dv = reinterpret_cast(get_proc_address("glMultiTexCoord1dvARB")); + glMultiTexCoord1f = reinterpret_cast(get_proc_address("glMultiTexCoord1fARB")); + glMultiTexCoord1fv = reinterpret_cast(get_proc_address("glMultiTexCoord1fvARB")); + glMultiTexCoord1i = reinterpret_cast(get_proc_address("glMultiTexCoord1iARB")); + glMultiTexCoord1iv = reinterpret_cast(get_proc_address("glMultiTexCoord1ivARB")); + glMultiTexCoord1s = reinterpret_cast(get_proc_address("glMultiTexCoord1sARB")); + glMultiTexCoord1sv = reinterpret_cast(get_proc_address("glMultiTexCoord1svARB")); + glMultiTexCoord2d = reinterpret_cast(get_proc_address("glMultiTexCoord2dARB")); + glMultiTexCoord2dv = reinterpret_cast(get_proc_address("glMultiTexCoord2dvARB")); + glMultiTexCoord2f = reinterpret_cast(get_proc_address("glMultiTexCoord2fARB")); + glMultiTexCoord2fv = reinterpret_cast(get_proc_address("glMultiTexCoord2fvARB")); + glMultiTexCoord2i = reinterpret_cast(get_proc_address("glMultiTexCoord2iARB")); + glMultiTexCoord2iv = reinterpret_cast(get_proc_address("glMultiTexCoord2ivARB")); + glMultiTexCoord2s = reinterpret_cast(get_proc_address("glMultiTexCoord2sARB")); + glMultiTexCoord2sv = reinterpret_cast(get_proc_address("glMultiTexCoord2svARB")); + glMultiTexCoord3d = reinterpret_cast(get_proc_address("glMultiTexCoord3dARB")); + glMultiTexCoord3dv = reinterpret_cast(get_proc_address("glMultiTexCoord3dvARB")); + glMultiTexCoord3f = reinterpret_cast(get_proc_address("glMultiTexCoord3fARB")); + glMultiTexCoord3fv = reinterpret_cast(get_proc_address("glMultiTexCoord3fvARB")); + glMultiTexCoord3i = reinterpret_cast(get_proc_address("glMultiTexCoord3iARB")); + glMultiTexCoord3iv = reinterpret_cast(get_proc_address("glMultiTexCoord3ivARB")); + glMultiTexCoord3s = reinterpret_cast(get_proc_address("glMultiTexCoord3sARB")); + glMultiTexCoord3sv = reinterpret_cast(get_proc_address("glMultiTexCoord3svARB")); + glMultiTexCoord4d = reinterpret_cast(get_proc_address("glMultiTexCoord4dARB")); + glMultiTexCoord4dv = reinterpret_cast(get_proc_address("glMultiTexCoord4dvARB")); + glMultiTexCoord4f = reinterpret_cast(get_proc_address("glMultiTexCoord4fARB")); + glMultiTexCoord4fv = reinterpret_cast(get_proc_address("glMultiTexCoord4fvARB")); + glMultiTexCoord4i = reinterpret_cast(get_proc_address("glMultiTexCoord4iARB")); + glMultiTexCoord4iv = reinterpret_cast(get_proc_address("glMultiTexCoord4ivARB")); + glMultiTexCoord4s = reinterpret_cast(get_proc_address("glMultiTexCoord4sARB")); + glMultiTexCoord4sv = reinterpret_cast(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 index 00000000..4c41f095 --- /dev/null +++ b/source/arb_multitexture.h @@ -0,0 +1,51 @@ +#ifndef MSP_GL_ARB_MULTITEXTURE_ +#define MSP_GL_ARB_MULTITEXTURE_ + +#include "extension.h" +#include "gl.h" +#include + +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 index 00000000..0243f8bd --- /dev/null +++ b/source/arb_pixel_buffer_object.cpp @@ -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 index 00000000..e7819821 --- /dev/null +++ b/source/arb_pixel_buffer_object.h @@ -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 + +namespace Msp { +namespace GL { + +extern Extension ARB_pixel_buffer_object; + +} // namespace GL +} // namespace Msp + +#endif diff --git a/source/arb_shader_objects.cpp b/source/arb_shader_objects.cpp index 18ea5482..3cb31bc5 100644 --- a/source/arb_shader_objects.cpp +++ b/source/arb_shader_objects.cpp @@ -1,91 +1,143 @@ -#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(get_proc_address("glDeleteObjectARB")); - glGetHandleARB = reinterpret_cast(get_proc_address("glGetHandleARB")); - glDetachObjectARB = reinterpret_cast(get_proc_address("glDetachObjectARB")); - glCreateShaderObjectARB = reinterpret_cast(get_proc_address("glCreateShaderObjectARB")); - glShaderSourceARB = reinterpret_cast(get_proc_address("glShaderSourceARB")); - glCompileShaderARB = reinterpret_cast(get_proc_address("glCompileShaderARB")); - glCreateProgramObjectARB = reinterpret_cast(get_proc_address("glCreateProgramObjectARB")); - glAttachObjectARB = reinterpret_cast(get_proc_address("glAttachObjectARB")); - glLinkProgramARB = reinterpret_cast(get_proc_address("glLinkProgramARB")); - glUseProgramObjectARB = reinterpret_cast(get_proc_address("glUseProgramObjectARB")); - glValidateProgramARB = reinterpret_cast(get_proc_address("glValidateProgramARB")); - glUniform1fARB = reinterpret_cast(get_proc_address("glUniform1fARB")); - glUniform2fARB = reinterpret_cast(get_proc_address("glUniform2fARB")); - glUniform3fARB = reinterpret_cast(get_proc_address("glUniform3fARB")); - glUniform4fARB = reinterpret_cast(get_proc_address("glUniform4fARB")); - glUniform1iARB = reinterpret_cast(get_proc_address("glUniform1iARB")); - glUniform2iARB = reinterpret_cast(get_proc_address("glUniform2iARB")); - glUniform3iARB = reinterpret_cast(get_proc_address("glUniform3iARB")); - glUniform4iARB = reinterpret_cast(get_proc_address("glUniform4iARB")); - glUniform1fvARB = reinterpret_cast(get_proc_address("glUniform1fvARB")); - glUniform2fvARB = reinterpret_cast(get_proc_address("glUniform2fvARB")); - glUniform3fvARB = reinterpret_cast(get_proc_address("glUniform3fvARB")); - glUniform4fvARB = reinterpret_cast(get_proc_address("glUniform4fvARB")); - glUniform1ivARB = reinterpret_cast(get_proc_address("glUniform1ivARB")); - glUniform2ivARB = reinterpret_cast(get_proc_address("glUniform2ivARB")); - glUniform3ivARB = reinterpret_cast(get_proc_address("glUniform3ivARB")); - glUniform4ivARB = reinterpret_cast(get_proc_address("glUniform4ivARB")); - glUniformMatrix2fvARB = reinterpret_cast(get_proc_address("glUniformMatrix2fvARB")); - glUniformMatrix3fvARB = reinterpret_cast(get_proc_address("glUniformMatrix3fvARB")); - glUniformMatrix4fvARB = reinterpret_cast(get_proc_address("glUniformMatrix4fvARB")); - glGetObjectParameterfvARB = reinterpret_cast(get_proc_address("glGetObjectParameterfvARB")); - glGetObjectParameterivARB = reinterpret_cast(get_proc_address("glGetObjectParameterivARB")); - glGetInfoLogARB = reinterpret_cast(get_proc_address("glGetInfoLogARB")); - glGetAttachedObjectsARB = reinterpret_cast(get_proc_address("glGetAttachedObjectsARB")); - glGetUniformLocationARB = reinterpret_cast(get_proc_address("glGetUniformLocationARB")); - glGetActiveUniformARB = reinterpret_cast(get_proc_address("glGetActiveUniformARB")); - glGetUniformfvARB = reinterpret_cast(get_proc_address("glGetUniformfvARB")); - glGetUniformivARB = reinterpret_cast(get_proc_address("glGetUniformivARB")); - glGetShaderSourceARB = reinterpret_cast(get_proc_address("glGetShaderSourceARB")); + if(is_version_at_least(2, 0)) + { + glAttachShader = reinterpret_cast(get_proc_address("glAttachShader")); + glCompileShader = reinterpret_cast(get_proc_address("glCompileShader")); + glCreateProgram = reinterpret_cast(get_proc_address("glCreateProgram")); + glCreateShader = reinterpret_cast(get_proc_address("glCreateShader")); + glDeleteProgram = reinterpret_cast(get_proc_address("glDeleteProgram")); + glDeleteShader = reinterpret_cast(get_proc_address("glDeleteShader")); + glDetachShader = reinterpret_cast(get_proc_address("glDetachShader")); + glGetActiveUniform = reinterpret_cast(get_proc_address("glGetActiveUniform")); + glGetAttachedShaders = reinterpret_cast(get_proc_address("glGetAttachedShaders")); + glGetProgramInfoLog = reinterpret_cast(get_proc_address("glGetProgramInfoLog")); + glGetProgramiv = reinterpret_cast(get_proc_address("glGetProgramiv")); + glGetShaderInfoLog = reinterpret_cast(get_proc_address("glGetShaderInfoLog")); + glGetShaderSource = reinterpret_cast(get_proc_address("glGetShaderSource")); + glGetShaderiv = reinterpret_cast(get_proc_address("glGetShaderiv")); + glGetUniformLocation = reinterpret_cast(get_proc_address("glGetUniformLocation")); + glGetUniformfv = reinterpret_cast(get_proc_address("glGetUniformfv")); + glGetUniformiv = reinterpret_cast(get_proc_address("glGetUniformiv")); + glLinkProgram = reinterpret_cast(get_proc_address("glLinkProgram")); + glShaderSource = reinterpret_cast(get_proc_address("glShaderSource")); + glUniform1f = reinterpret_cast(get_proc_address("glUniform1f")); + glUniform1fv = reinterpret_cast(get_proc_address("glUniform1fv")); + glUniform1i = reinterpret_cast(get_proc_address("glUniform1i")); + glUniform1iv = reinterpret_cast(get_proc_address("glUniform1iv")); + glUniform2f = reinterpret_cast(get_proc_address("glUniform2f")); + glUniform2fv = reinterpret_cast(get_proc_address("glUniform2fv")); + glUniform2i = reinterpret_cast(get_proc_address("glUniform2i")); + glUniform2iv = reinterpret_cast(get_proc_address("glUniform2iv")); + glUniform3f = reinterpret_cast(get_proc_address("glUniform3f")); + glUniform3fv = reinterpret_cast(get_proc_address("glUniform3fv")); + glUniform3i = reinterpret_cast(get_proc_address("glUniform3i")); + glUniform3iv = reinterpret_cast(get_proc_address("glUniform3iv")); + glUniform4f = reinterpret_cast(get_proc_address("glUniform4f")); + glUniform4fv = reinterpret_cast(get_proc_address("glUniform4fv")); + glUniform4i = reinterpret_cast(get_proc_address("glUniform4i")); + glUniform4iv = reinterpret_cast(get_proc_address("glUniform4iv")); + glUniformMatrix2fv = reinterpret_cast(get_proc_address("glUniformMatrix2fv")); + glUniformMatrix3fv = reinterpret_cast(get_proc_address("glUniformMatrix3fv")); + glUniformMatrix4fv = reinterpret_cast(get_proc_address("glUniformMatrix4fv")); + glUseProgram = reinterpret_cast(get_proc_address("glUseProgram")); + glValidateProgram = reinterpret_cast(get_proc_address("glValidateProgram")); + return Extension::CORE; + } + if(is_supported("GL_ARB_shader_objects")) + { + glAttachShader = reinterpret_cast(get_proc_address("glAttachObjectARB")); + glCompileShader = reinterpret_cast(get_proc_address("glCompileShaderARB")); + glCreateProgram = reinterpret_cast(get_proc_address("glCreateProgramObjectARB")); + glCreateShader = reinterpret_cast(get_proc_address("glCreateShaderObjectARB")); + glDeleteProgram = reinterpret_cast(get_proc_address("glDeleteObjectARB")); + glDeleteShader = reinterpret_cast(get_proc_address("glDeleteObjectARB")); + glDetachShader = reinterpret_cast(get_proc_address("glDetachObjectARB")); + glGetActiveUniform = reinterpret_cast(get_proc_address("glGetActiveUniformARB")); + glGetAttachedShaders = reinterpret_cast(get_proc_address("glGetAttachedObjectsARB")); + glGetProgramInfoLog = reinterpret_cast(get_proc_address("glGetInfoLogARB")); + glGetProgramiv = reinterpret_cast(get_proc_address("glGetObjectParameterivARB")); + glGetShaderInfoLog = reinterpret_cast(get_proc_address("glGetInfoLogARB")); + glGetShaderSource = reinterpret_cast(get_proc_address("glGetShaderSourceARB")); + glGetShaderiv = reinterpret_cast(get_proc_address("glGetObjectParameterivARB")); + glGetUniformLocation = reinterpret_cast(get_proc_address("glGetUniformLocationARB")); + glGetUniformfv = reinterpret_cast(get_proc_address("glGetUniformfvARB")); + glGetUniformiv = reinterpret_cast(get_proc_address("glGetUniformivARB")); + glLinkProgram = reinterpret_cast(get_proc_address("glLinkProgramARB")); + glShaderSource = reinterpret_cast(get_proc_address("glShaderSourceARB")); + glUniform1f = reinterpret_cast(get_proc_address("glUniform1fARB")); + glUniform1fv = reinterpret_cast(get_proc_address("glUniform1fvARB")); + glUniform1i = reinterpret_cast(get_proc_address("glUniform1iARB")); + glUniform1iv = reinterpret_cast(get_proc_address("glUniform1ivARB")); + glUniform2f = reinterpret_cast(get_proc_address("glUniform2fARB")); + glUniform2fv = reinterpret_cast(get_proc_address("glUniform2fvARB")); + glUniform2i = reinterpret_cast(get_proc_address("glUniform2iARB")); + glUniform2iv = reinterpret_cast(get_proc_address("glUniform2ivARB")); + glUniform3f = reinterpret_cast(get_proc_address("glUniform3fARB")); + glUniform3fv = reinterpret_cast(get_proc_address("glUniform3fvARB")); + glUniform3i = reinterpret_cast(get_proc_address("glUniform3iARB")); + glUniform3iv = reinterpret_cast(get_proc_address("glUniform3ivARB")); + glUniform4f = reinterpret_cast(get_proc_address("glUniform4fARB")); + glUniform4fv = reinterpret_cast(get_proc_address("glUniform4fvARB")); + glUniform4i = reinterpret_cast(get_proc_address("glUniform4iARB")); + glUniform4iv = reinterpret_cast(get_proc_address("glUniform4ivARB")); + glUniformMatrix2fv = reinterpret_cast(get_proc_address("glUniformMatrix2fvARB")); + glUniformMatrix3fv = reinterpret_cast(get_proc_address("glUniformMatrix3fvARB")); + glUniformMatrix4fv = reinterpret_cast(get_proc_address("glUniformMatrix4fvARB")); + glUseProgram = reinterpret_cast(get_proc_address("glUseProgramObjectARB")); + glValidateProgram = reinterpret_cast(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 diff --git a/source/arb_shader_objects.h b/source/arb_shader_objects.h index e256d068..6b35cee1 100644 --- a/source/arb_shader_objects.h +++ b/source/arb_shader_objects.h @@ -1,53 +1,55 @@ #ifndef MSP_GL_ARB_SHADER_OBJECTS_ #define MSP_GL_ARB_SHADER_OBJECTS_ +#include "extension.h" #include "gl.h" #include 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 index 00000000..b74993a9 --- /dev/null +++ b/source/arb_texture_cube_map.cpp @@ -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 index 00000000..3cde6e7d --- /dev/null +++ b/source/arb_texture_cube_map.h @@ -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 + +namespace Msp { +namespace GL { + +extern Extension ARB_texture_cube_map; + +} // namespace GL +} // namespace Msp + +#endif diff --git a/source/arb_uniform_buffer_object.cpp b/source/arb_uniform_buffer_object.cpp index b788e036..9b224ffb 100644 --- a/source/arb_uniform_buffer_object.cpp +++ b/source/arb_uniform_buffer_object.cpp @@ -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(get_proc_address("glGetUniformIndices")); - glGetActiveUniformsiv = reinterpret_cast(get_proc_address("glGetActiveUniformsiv")); - glGetActiveUniformName = reinterpret_cast(get_proc_address("glGetActiveUniformName")); - glGetUniformBlockIndex = reinterpret_cast(get_proc_address("glGetUniformBlockIndex")); - glGetActiveUniformBlockiv = reinterpret_cast(get_proc_address("glGetActiveUniformBlockiv")); - glGetActiveUniformBlockName = reinterpret_cast(get_proc_address("glGetActiveUniformBlockName")); - glUniformBlockBinding = reinterpret_cast(get_proc_address("glUniformBlockBinding")); - glBindBufferBase = reinterpret_cast(get_proc_address("glBindBufferBase")); - glBindBufferRange = reinterpret_cast(get_proc_address("glBindBufferRange")); + if(is_version_at_least(3, 0) || is_supported("GL_ARB_uniform_buffer_object")) + { + glBindBufferBase = reinterpret_cast(get_proc_address("glBindBufferBase")); + glBindBufferRange = reinterpret_cast(get_proc_address("glBindBufferRange")); + glGetActiveUniformBlockName = reinterpret_cast(get_proc_address("glGetActiveUniformBlockName")); + glGetActiveUniformBlockiv = reinterpret_cast(get_proc_address("glGetActiveUniformBlockiv")); + glGetActiveUniformName = reinterpret_cast(get_proc_address("glGetActiveUniformName")); + glGetActiveUniformsiv = reinterpret_cast(get_proc_address("glGetActiveUniformsiv")); + glGetUniformBlockIndex = reinterpret_cast(get_proc_address("glGetUniformBlockIndex")); + glGetUniformIndices = reinterpret_cast(get_proc_address("glGetUniformIndices")); + glUniformBlockBinding = reinterpret_cast(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 diff --git a/source/arb_uniform_buffer_object.h b/source/arb_uniform_buffer_object.h index 1b8ced53..5a259252 100644 --- a/source/arb_uniform_buffer_object.h +++ b/source/arb_uniform_buffer_object.h @@ -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 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 diff --git a/source/arb_vertex_buffer_object.cpp b/source/arb_vertex_buffer_object.cpp index 66ef40e5..cf623c47 100644 --- a/source/arb_vertex_buffer_object.cpp +++ b/source/arb_vertex_buffer_object.cpp @@ -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(get_proc_address("glBindBufferARB")); - glDeleteBuffersARB = reinterpret_cast(get_proc_address("glDeleteBuffersARB")); - glGenBuffersARB = reinterpret_cast(get_proc_address("glGenBuffersARB")); - glIsBufferARB = reinterpret_cast(get_proc_address("glIsBufferARB")); - glBufferDataARB = reinterpret_cast(get_proc_address("glBufferDataARB")); - glBufferSubDataARB = reinterpret_cast(get_proc_address("glBufferSubDataARB")); - glGetBufferSubDataARB = reinterpret_cast(get_proc_address("glGetBufferSubDataARB")); - glMapBufferARB = reinterpret_cast(get_proc_address("glMapBufferARB")); - glUnmapBufferARB = reinterpret_cast(get_proc_address("glUnmapBufferARB")); - glGetBufferParameterivARB = reinterpret_cast(get_proc_address("glGetBufferParameterivARB")); - glGetBufferPointervARB = reinterpret_cast(get_proc_address("glGetBufferPointervARB")); + if(is_version_at_least(1, 5)) + { + glBindBuffer = reinterpret_cast(get_proc_address("glBindBuffer")); + glBufferData = reinterpret_cast(get_proc_address("glBufferData")); + glBufferSubData = reinterpret_cast(get_proc_address("glBufferSubData")); + glDeleteBuffers = reinterpret_cast(get_proc_address("glDeleteBuffers")); + glGenBuffers = reinterpret_cast(get_proc_address("glGenBuffers")); + glGetBufferParameteriv = reinterpret_cast(get_proc_address("glGetBufferParameteriv")); + glGetBufferPointerv = reinterpret_cast(get_proc_address("glGetBufferPointerv")); + glGetBufferSubData = reinterpret_cast(get_proc_address("glGetBufferSubData")); + glIsBuffer = reinterpret_cast(get_proc_address("glIsBuffer")); + glMapBuffer = reinterpret_cast(get_proc_address("glMapBuffer")); + glUnmapBuffer = reinterpret_cast(get_proc_address("glUnmapBuffer")); + return Extension::CORE; + } + if(is_supported("GL_ARB_vertex_buffer_object")) + { + glBindBuffer = reinterpret_cast(get_proc_address("glBindBufferARB")); + glBufferData = reinterpret_cast(get_proc_address("glBufferDataARB")); + glBufferSubData = reinterpret_cast(get_proc_address("glBufferSubDataARB")); + glDeleteBuffers = reinterpret_cast(get_proc_address("glDeleteBuffersARB")); + glGenBuffers = reinterpret_cast(get_proc_address("glGenBuffersARB")); + glGetBufferParameteriv = reinterpret_cast(get_proc_address("glGetBufferParameterivARB")); + glGetBufferPointerv = reinterpret_cast(get_proc_address("glGetBufferPointervARB")); + glGetBufferSubData = reinterpret_cast(get_proc_address("glGetBufferSubDataARB")); + glIsBuffer = reinterpret_cast(get_proc_address("glIsBufferARB")); + glMapBuffer = reinterpret_cast(get_proc_address("glMapBufferARB")); + glUnmapBuffer = reinterpret_cast(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 diff --git a/source/arb_vertex_buffer_object.h b/source/arb_vertex_buffer_object.h index 8d3be978..1154446d 100644 --- a/source/arb_vertex_buffer_object.h +++ b/source/arb_vertex_buffer_object.h @@ -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 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 index 41adaee6..00000000 --- a/source/arb_vertex_program.cpp +++ /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(get_proc_address("glVertexAttrib1dARB")); - glVertexAttrib1dvARB = reinterpret_cast(get_proc_address("glVertexAttrib1dvARB")); - glVertexAttrib1fARB = reinterpret_cast(get_proc_address("glVertexAttrib1fARB")); - glVertexAttrib1fvARB = reinterpret_cast(get_proc_address("glVertexAttrib1fvARB")); - glVertexAttrib1sARB = reinterpret_cast(get_proc_address("glVertexAttrib1sARB")); - glVertexAttrib1svARB = reinterpret_cast(get_proc_address("glVertexAttrib1svARB")); - glVertexAttrib2dARB = reinterpret_cast(get_proc_address("glVertexAttrib2dARB")); - glVertexAttrib2dvARB = reinterpret_cast(get_proc_address("glVertexAttrib2dvARB")); - glVertexAttrib2fARB = reinterpret_cast(get_proc_address("glVertexAttrib2fARB")); - glVertexAttrib2fvARB = reinterpret_cast(get_proc_address("glVertexAttrib2fvARB")); - glVertexAttrib2sARB = reinterpret_cast(get_proc_address("glVertexAttrib2sARB")); - glVertexAttrib2svARB = reinterpret_cast(get_proc_address("glVertexAttrib2svARB")); - glVertexAttrib3dARB = reinterpret_cast(get_proc_address("glVertexAttrib3dARB")); - glVertexAttrib3dvARB = reinterpret_cast(get_proc_address("glVertexAttrib3dvARB")); - glVertexAttrib3fARB = reinterpret_cast(get_proc_address("glVertexAttrib3fARB")); - glVertexAttrib3fvARB = reinterpret_cast(get_proc_address("glVertexAttrib3fvARB")); - glVertexAttrib3sARB = reinterpret_cast(get_proc_address("glVertexAttrib3sARB")); - glVertexAttrib3svARB = reinterpret_cast(get_proc_address("glVertexAttrib3svARB")); - glVertexAttrib4NbvARB = reinterpret_cast(get_proc_address("glVertexAttrib4NbvARB")); - glVertexAttrib4NivARB = reinterpret_cast(get_proc_address("glVertexAttrib4NivARB")); - glVertexAttrib4NsvARB = reinterpret_cast(get_proc_address("glVertexAttrib4NsvARB")); - glVertexAttrib4NubARB = reinterpret_cast(get_proc_address("glVertexAttrib4NubARB")); - glVertexAttrib4NubvARB = reinterpret_cast(get_proc_address("glVertexAttrib4NubvARB")); - glVertexAttrib4NuivARB = reinterpret_cast(get_proc_address("glVertexAttrib4NuivARB")); - glVertexAttrib4NusvARB = reinterpret_cast(get_proc_address("glVertexAttrib4NusvARB")); - glVertexAttrib4bvARB = reinterpret_cast(get_proc_address("glVertexAttrib4bvARB")); - glVertexAttrib4dARB = reinterpret_cast(get_proc_address("glVertexAttrib4dARB")); - glVertexAttrib4dvARB = reinterpret_cast(get_proc_address("glVertexAttrib4dvARB")); - glVertexAttrib4fARB = reinterpret_cast(get_proc_address("glVertexAttrib4fARB")); - glVertexAttrib4fvARB = reinterpret_cast(get_proc_address("glVertexAttrib4fvARB")); - glVertexAttrib4ivARB = reinterpret_cast(get_proc_address("glVertexAttrib4ivARB")); - glVertexAttrib4sARB = reinterpret_cast(get_proc_address("glVertexAttrib4sARB")); - glVertexAttrib4svARB = reinterpret_cast(get_proc_address("glVertexAttrib4svARB")); - glVertexAttrib4ubvARB = reinterpret_cast(get_proc_address("glVertexAttrib4ubvARB")); - glVertexAttrib4uivARB = reinterpret_cast(get_proc_address("glVertexAttrib4uivARB")); - glVertexAttrib4usvARB = reinterpret_cast(get_proc_address("glVertexAttrib4usvARB")); - glVertexAttribPointerARB = reinterpret_cast(get_proc_address("glVertexAttribPointerARB")); - glEnableVertexAttribArrayARB = reinterpret_cast(get_proc_address("glEnableVertexAttribArrayARB")); - glDisableVertexAttribArrayARB = reinterpret_cast(get_proc_address("glDisableVertexAttribArrayARB")); - glProgramStringARB = reinterpret_cast(get_proc_address("glProgramStringARB")); - glBindProgramARB = reinterpret_cast(get_proc_address("glBindProgramARB")); - glDeleteProgramsARB = reinterpret_cast(get_proc_address("glDeleteProgramsARB")); - glGenProgramsARB = reinterpret_cast(get_proc_address("glGenProgramsARB")); - glProgramEnvParameter4dARB = reinterpret_cast(get_proc_address("glProgramEnvParameter4dARB")); - glProgramEnvParameter4dvARB = reinterpret_cast(get_proc_address("glProgramEnvParameter4dvARB")); - glProgramEnvParameter4fARB = reinterpret_cast(get_proc_address("glProgramEnvParameter4fARB")); - glProgramEnvParameter4fvARB = reinterpret_cast(get_proc_address("glProgramEnvParameter4fvARB")); - glProgramLocalParameter4dARB = reinterpret_cast(get_proc_address("glProgramLocalParameter4dARB")); - glProgramLocalParameter4dvARB = reinterpret_cast(get_proc_address("glProgramLocalParameter4dvARB")); - glProgramLocalParameter4fARB = reinterpret_cast(get_proc_address("glProgramLocalParameter4fARB")); - glProgramLocalParameter4fvARB = reinterpret_cast(get_proc_address("glProgramLocalParameter4fvARB")); - glGetProgramEnvParameterdvARB = reinterpret_cast(get_proc_address("glGetProgramEnvParameterdvARB")); - glGetProgramEnvParameterfvARB = reinterpret_cast(get_proc_address("glGetProgramEnvParameterfvARB")); - glGetProgramLocalParameterdvARB = reinterpret_cast(get_proc_address("glGetProgramLocalParameterdvARB")); - glGetProgramLocalParameterfvARB = reinterpret_cast(get_proc_address("glGetProgramLocalParameterfvARB")); - glGetProgramivARB = reinterpret_cast(get_proc_address("glGetProgramivARB")); - glGetProgramStringARB = reinterpret_cast(get_proc_address("glGetProgramStringARB")); - glGetVertexAttribdvARB = reinterpret_cast(get_proc_address("glGetVertexAttribdvARB")); - glGetVertexAttribfvARB = reinterpret_cast(get_proc_address("glGetVertexAttribfvARB")); - glGetVertexAttribivARB = reinterpret_cast(get_proc_address("glGetVertexAttribivARB")); - glGetVertexAttribPointervARB = reinterpret_cast(get_proc_address("glGetVertexAttribPointervARB")); - glIsProgramARB = reinterpret_cast(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 index a4c8dd0d..00000000 --- a/source/arb_vertex_program.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef MSP_GL_ARB_VERTEX_PROGRAM_ -#define MSP_GL_ARB_VERTEX_PROGRAM_ - -#include "gl.h" -#include - -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 diff --git a/source/arb_vertex_shader.cpp b/source/arb_vertex_shader.cpp index 612c5033..918c1316 100644 --- a/source/arb_vertex_shader.cpp +++ b/source/arb_vertex_shader.cpp @@ -1,19 +1,161 @@ -#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(get_proc_address("glBindAttribLocationARB")); - glGetActiveAttribARB = reinterpret_cast(get_proc_address("glGetActiveAttribARB")); - glGetAttribLocationARB = reinterpret_cast(get_proc_address("glGetAttribLocationARB")); + if(is_version_at_least(2, 0)) + { + glBindAttribLocation = reinterpret_cast(get_proc_address("glBindAttribLocation")); + glDisableVertexAttribArray = reinterpret_cast(get_proc_address("glDisableVertexAttribArray")); + glEnableVertexAttribArray = reinterpret_cast(get_proc_address("glEnableVertexAttribArray")); + glGetActiveAttrib = reinterpret_cast(get_proc_address("glGetActiveAttrib")); + glGetAttribLocation = reinterpret_cast(get_proc_address("glGetAttribLocation")); + glGetVertexAttribPointerv = reinterpret_cast(get_proc_address("glGetVertexAttribPointerv")); + glGetVertexAttribdv = reinterpret_cast(get_proc_address("glGetVertexAttribdv")); + glGetVertexAttribfv = reinterpret_cast(get_proc_address("glGetVertexAttribfv")); + glGetVertexAttribiv = reinterpret_cast(get_proc_address("glGetVertexAttribiv")); + glVertexAttrib1d = reinterpret_cast(get_proc_address("glVertexAttrib1d")); + glVertexAttrib1dv = reinterpret_cast(get_proc_address("glVertexAttrib1dv")); + glVertexAttrib1f = reinterpret_cast(get_proc_address("glVertexAttrib1f")); + glVertexAttrib1fv = reinterpret_cast(get_proc_address("glVertexAttrib1fv")); + glVertexAttrib1s = reinterpret_cast(get_proc_address("glVertexAttrib1s")); + glVertexAttrib1sv = reinterpret_cast(get_proc_address("glVertexAttrib1sv")); + glVertexAttrib2d = reinterpret_cast(get_proc_address("glVertexAttrib2d")); + glVertexAttrib2dv = reinterpret_cast(get_proc_address("glVertexAttrib2dv")); + glVertexAttrib2f = reinterpret_cast(get_proc_address("glVertexAttrib2f")); + glVertexAttrib2fv = reinterpret_cast(get_proc_address("glVertexAttrib2fv")); + glVertexAttrib2s = reinterpret_cast(get_proc_address("glVertexAttrib2s")); + glVertexAttrib2sv = reinterpret_cast(get_proc_address("glVertexAttrib2sv")); + glVertexAttrib3d = reinterpret_cast(get_proc_address("glVertexAttrib3d")); + glVertexAttrib3dv = reinterpret_cast(get_proc_address("glVertexAttrib3dv")); + glVertexAttrib3f = reinterpret_cast(get_proc_address("glVertexAttrib3f")); + glVertexAttrib3fv = reinterpret_cast(get_proc_address("glVertexAttrib3fv")); + glVertexAttrib3s = reinterpret_cast(get_proc_address("glVertexAttrib3s")); + glVertexAttrib3sv = reinterpret_cast(get_proc_address("glVertexAttrib3sv")); + glVertexAttrib4Nbv = reinterpret_cast(get_proc_address("glVertexAttrib4Nbv")); + glVertexAttrib4Niv = reinterpret_cast(get_proc_address("glVertexAttrib4Niv")); + glVertexAttrib4Nsv = reinterpret_cast(get_proc_address("glVertexAttrib4Nsv")); + glVertexAttrib4Nub = reinterpret_cast(get_proc_address("glVertexAttrib4Nub")); + glVertexAttrib4Nubv = reinterpret_cast(get_proc_address("glVertexAttrib4Nubv")); + glVertexAttrib4Nuiv = reinterpret_cast(get_proc_address("glVertexAttrib4Nuiv")); + glVertexAttrib4Nusv = reinterpret_cast(get_proc_address("glVertexAttrib4Nusv")); + glVertexAttrib4bv = reinterpret_cast(get_proc_address("glVertexAttrib4bv")); + glVertexAttrib4d = reinterpret_cast(get_proc_address("glVertexAttrib4d")); + glVertexAttrib4dv = reinterpret_cast(get_proc_address("glVertexAttrib4dv")); + glVertexAttrib4f = reinterpret_cast(get_proc_address("glVertexAttrib4f")); + glVertexAttrib4fv = reinterpret_cast(get_proc_address("glVertexAttrib4fv")); + glVertexAttrib4iv = reinterpret_cast(get_proc_address("glVertexAttrib4iv")); + glVertexAttrib4s = reinterpret_cast(get_proc_address("glVertexAttrib4s")); + glVertexAttrib4sv = reinterpret_cast(get_proc_address("glVertexAttrib4sv")); + glVertexAttrib4ubv = reinterpret_cast(get_proc_address("glVertexAttrib4ubv")); + glVertexAttrib4uiv = reinterpret_cast(get_proc_address("glVertexAttrib4uiv")); + glVertexAttrib4usv = reinterpret_cast(get_proc_address("glVertexAttrib4usv")); + glVertexAttribPointer = reinterpret_cast(get_proc_address("glVertexAttribPointer")); + return Extension::CORE; + } + if(is_supported("GL_ARB_vertex_shader")) + { + glBindAttribLocation = reinterpret_cast(get_proc_address("glBindAttribLocationARB")); + glDisableVertexAttribArray = reinterpret_cast(get_proc_address("glDisableVertexAttribArrayARB")); + glEnableVertexAttribArray = reinterpret_cast(get_proc_address("glEnableVertexAttribArrayARB")); + glGetActiveAttrib = reinterpret_cast(get_proc_address("glGetActiveAttribARB")); + glGetAttribLocation = reinterpret_cast(get_proc_address("glGetAttribLocationARB")); + glGetVertexAttribPointerv = reinterpret_cast(get_proc_address("glGetVertexAttribPointervARB")); + glGetVertexAttribdv = reinterpret_cast(get_proc_address("glGetVertexAttribdvARB")); + glGetVertexAttribfv = reinterpret_cast(get_proc_address("glGetVertexAttribfvARB")); + glGetVertexAttribiv = reinterpret_cast(get_proc_address("glGetVertexAttribivARB")); + glVertexAttrib1d = reinterpret_cast(get_proc_address("glVertexAttrib1dARB")); + glVertexAttrib1dv = reinterpret_cast(get_proc_address("glVertexAttrib1dvARB")); + glVertexAttrib1f = reinterpret_cast(get_proc_address("glVertexAttrib1fARB")); + glVertexAttrib1fv = reinterpret_cast(get_proc_address("glVertexAttrib1fvARB")); + glVertexAttrib1s = reinterpret_cast(get_proc_address("glVertexAttrib1sARB")); + glVertexAttrib1sv = reinterpret_cast(get_proc_address("glVertexAttrib1svARB")); + glVertexAttrib2d = reinterpret_cast(get_proc_address("glVertexAttrib2dARB")); + glVertexAttrib2dv = reinterpret_cast(get_proc_address("glVertexAttrib2dvARB")); + glVertexAttrib2f = reinterpret_cast(get_proc_address("glVertexAttrib2fARB")); + glVertexAttrib2fv = reinterpret_cast(get_proc_address("glVertexAttrib2fvARB")); + glVertexAttrib2s = reinterpret_cast(get_proc_address("glVertexAttrib2sARB")); + glVertexAttrib2sv = reinterpret_cast(get_proc_address("glVertexAttrib2svARB")); + glVertexAttrib3d = reinterpret_cast(get_proc_address("glVertexAttrib3dARB")); + glVertexAttrib3dv = reinterpret_cast(get_proc_address("glVertexAttrib3dvARB")); + glVertexAttrib3f = reinterpret_cast(get_proc_address("glVertexAttrib3fARB")); + glVertexAttrib3fv = reinterpret_cast(get_proc_address("glVertexAttrib3fvARB")); + glVertexAttrib3s = reinterpret_cast(get_proc_address("glVertexAttrib3sARB")); + glVertexAttrib3sv = reinterpret_cast(get_proc_address("glVertexAttrib3svARB")); + glVertexAttrib4Nbv = reinterpret_cast(get_proc_address("glVertexAttrib4NbvARB")); + glVertexAttrib4Niv = reinterpret_cast(get_proc_address("glVertexAttrib4NivARB")); + glVertexAttrib4Nsv = reinterpret_cast(get_proc_address("glVertexAttrib4NsvARB")); + glVertexAttrib4Nub = reinterpret_cast(get_proc_address("glVertexAttrib4NubARB")); + glVertexAttrib4Nubv = reinterpret_cast(get_proc_address("glVertexAttrib4NubvARB")); + glVertexAttrib4Nuiv = reinterpret_cast(get_proc_address("glVertexAttrib4NuivARB")); + glVertexAttrib4Nusv = reinterpret_cast(get_proc_address("glVertexAttrib4NusvARB")); + glVertexAttrib4bv = reinterpret_cast(get_proc_address("glVertexAttrib4bvARB")); + glVertexAttrib4d = reinterpret_cast(get_proc_address("glVertexAttrib4dARB")); + glVertexAttrib4dv = reinterpret_cast(get_proc_address("glVertexAttrib4dvARB")); + glVertexAttrib4f = reinterpret_cast(get_proc_address("glVertexAttrib4fARB")); + glVertexAttrib4fv = reinterpret_cast(get_proc_address("glVertexAttrib4fvARB")); + glVertexAttrib4iv = reinterpret_cast(get_proc_address("glVertexAttrib4ivARB")); + glVertexAttrib4s = reinterpret_cast(get_proc_address("glVertexAttrib4sARB")); + glVertexAttrib4sv = reinterpret_cast(get_proc_address("glVertexAttrib4svARB")); + glVertexAttrib4ubv = reinterpret_cast(get_proc_address("glVertexAttrib4ubvARB")); + glVertexAttrib4uiv = reinterpret_cast(get_proc_address("glVertexAttrib4uivARB")); + glVertexAttrib4usv = reinterpret_cast(get_proc_address("glVertexAttrib4usvARB")); + glVertexAttribPointer = reinterpret_cast(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 diff --git a/source/arb_vertex_shader.h b/source/arb_vertex_shader.h index 6dab0c0a..6ded1a09 100644 --- a/source/arb_vertex_shader.h +++ b/source/arb_vertex_shader.h @@ -1,17 +1,61 @@ #ifndef MSP_GL_ARB_VERTEX_SHADER_ #define MSP_GL_ARB_VERTEX_SHADER_ +#include "extension.h" #include "gl.h" #include 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 diff --git a/source/batch.cpp b/source/batch.cpp index 375c52e9..afb9787b 100644 --- a/source/batch.cpp +++ b/source/batch.cpp @@ -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) diff --git a/source/blend.cpp b/source/blend.cpp index 03fc0f02..cecd562d 100644 --- a/source/blend.cpp +++ b/source/blend.cpp @@ -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 diff --git a/source/buffer.cpp b/source/buffer.cpp index f3b40da6..84c72716 100644 --- a/source/buffer.cpp +++ b/source/buffer.cpp @@ -1,8 +1,8 @@ #include +#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) diff --git a/source/buffer.h b/source/buffer.h index 206cec8d..25ce4699 100644 --- a/source/buffer.h +++ b/source/buffer.h @@ -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 index 00000000..225a05f8 --- /dev/null +++ b/source/ext_blend_minmax.cpp @@ -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(get_proc_address("glBlendEquation")); + return Extension::CORE; + } + if(is_supported("GL_EXT_blend_minmax")) + { + glBlendEquation = reinterpret_cast(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 index 00000000..5ca1a58c --- /dev/null +++ b/source/ext_blend_minmax.h @@ -0,0 +1,18 @@ +#ifndef MSP_GL_EXT_BLEND_MINMAX_ +#define MSP_GL_EXT_BLEND_MINMAX_ + +#include "extension.h" +#include "gl.h" +#include + +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 index 00000000..f15f3f50 --- /dev/null +++ b/source/ext_blend_subtract.cpp @@ -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 index 00000000..243d5301 --- /dev/null +++ b/source/ext_blend_subtract.h @@ -0,0 +1,16 @@ +#ifndef MSP_GL_EXT_BLEND_SUBTRACT_ +#define MSP_GL_EXT_BLEND_SUBTRACT_ + +#include "extension.h" +#include "gl.h" +#include + +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 index 00000000..2bccf00e --- /dev/null +++ b/source/ext_draw_range_elements.cpp @@ -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(get_proc_address("glDrawRangeElements")); + return Extension::CORE; + } + if(is_supported("GL_EXT_draw_range_elements")) + { + glDrawRangeElements = reinterpret_cast(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 index 00000000..e8aba1da --- /dev/null +++ b/source/ext_draw_range_elements.h @@ -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 + +namespace Msp { +namespace GL { + +extern PFNGLDRAWRANGEELEMENTSPROC glDrawRangeElements; + +extern Extension EXT_draw_range_elements; + +} // namespace GL +} // namespace Msp + +#endif diff --git a/source/ext_framebuffer_blit.cpp b/source/ext_framebuffer_blit.cpp index 7519e13c..a198cdd1 100644 --- a/source/ext_framebuffer_blit.cpp +++ b/source/ext_framebuffer_blit.cpp @@ -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(get_proc_address("glBlitFramebufferEXT")); + if(is_version_at_least(3, 0) || is_supported("GL_ARB_framebuffer_object")) + { + glBlitFramebuffer = reinterpret_cast(get_proc_address("glBlitFramebuffer")); + return Extension::CORE; + } + if(is_supported("GL_EXT_framebuffer_blit")) + { + glBlitFramebuffer = reinterpret_cast(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 diff --git a/source/ext_framebuffer_blit.h b/source/ext_framebuffer_blit.h index 0b651970..75ca6c6e 100644 --- a/source/ext_framebuffer_blit.h +++ b/source/ext_framebuffer_blit.h @@ -1,15 +1,16 @@ #ifndef MSP_GL_EXT_FRAMEBUFFER_BLIT_ #define MSP_GL_EXT_FRAMEBUFFER_BLIT_ +#include "extension.h" #include "gl.h" #include namespace Msp { namespace GL { -extern PFNGLBLITFRAMEBUFFEREXTPROC glBlitFramebufferEXT; +extern PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer; -void init_ext_framebuffer_blit(); +extern Extension EXT_framebuffer_blit; } // namespace GL } // namespace Msp diff --git a/source/ext_framebuffer_multisample.cpp b/source/ext_framebuffer_multisample.cpp index a0f3930c..7be2f6d3 100644 --- a/source/ext_framebuffer_multisample.cpp +++ b/source/ext_framebuffer_multisample.cpp @@ -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(get_proc_address("glRenderbufferStorageMultisampleEXT")); + if(is_version_at_least(3, 0) || is_supported("GL_ARB_framebuffer_object")) + { + glRenderbufferStorageMultisample = reinterpret_cast(get_proc_address("glRenderbufferStorageMultisample")); + return Extension::CORE; + } + if(is_supported("GL_EXT_framebuffer_multisample")) + { + glRenderbufferStorageMultisample = reinterpret_cast(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 diff --git a/source/ext_framebuffer_multisample.h b/source/ext_framebuffer_multisample.h index 479ef693..980ef9a9 100644 --- a/source/ext_framebuffer_multisample.h +++ b/source/ext_framebuffer_multisample.h @@ -1,15 +1,16 @@ #ifndef MSP_GL_EXT_FRAMEBUFFER_MULTISAMPLE_ #define MSP_GL_EXT_FRAMEBUFFER_MULTISAMPLE_ +#include "extension.h" #include "gl.h" #include namespace Msp { namespace GL { -extern PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glRenderbufferStorageMultisampleEXT; +extern PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glRenderbufferStorageMultisample; -void init_ext_framebuffer_multisample(); +extern Extension EXT_framebuffer_multisample; } // namespace GL } // namespace Msp diff --git a/source/ext_framebuffer_object.cpp b/source/ext_framebuffer_object.cpp index ab5048d6..e9193e17 100644 --- a/source/ext_framebuffer_object.cpp +++ b/source/ext_framebuffer_object.cpp @@ -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(get_proc_address("glIsRenderbufferEXT")); - glBindRenderbufferEXT = reinterpret_cast(get_proc_address("glBindRenderbufferEXT")); - glDeleteRenderbuffersEXT = reinterpret_cast(get_proc_address("glDeleteRenderbuffersEXT")); - glGenRenderbuffersEXT = reinterpret_cast(get_proc_address("glGenRenderbuffersEXT")); - glRenderbufferStorageEXT = reinterpret_cast(get_proc_address("glRenderbufferStorageEXT")); - glGetRenderbufferParameterivEXT = reinterpret_cast(get_proc_address("glGetRenderbufferParameterivEXT")); - glIsFramebufferEXT = reinterpret_cast(get_proc_address("glIsFramebufferEXT")); - glBindFramebufferEXT = reinterpret_cast(get_proc_address("glBindFramebufferEXT")); - glDeleteFramebuffersEXT = reinterpret_cast(get_proc_address("glDeleteFramebuffersEXT")); - glGenFramebuffersEXT = reinterpret_cast(get_proc_address("glGenFramebuffersEXT")); - glCheckFramebufferStatusEXT = reinterpret_cast(get_proc_address("glCheckFramebufferStatusEXT")); - glFramebufferTexture1DEXT = reinterpret_cast(get_proc_address("glFramebufferTexture1DEXT")); - glFramebufferTexture2DEXT = reinterpret_cast(get_proc_address("glFramebufferTexture2DEXT")); - glFramebufferTexture3DEXT = reinterpret_cast(get_proc_address("glFramebufferTexture3DEXT")); - glFramebufferRenderbufferEXT = reinterpret_cast(get_proc_address("glFramebufferRenderbufferEXT")); - glGetFramebufferAttachmentParameterivEXT = reinterpret_cast(get_proc_address("glGetFramebufferAttachmentParameterivEXT")); - glGenerateMipmapEXT = reinterpret_cast(get_proc_address("glGenerateMipmapEXT")); + if(is_version_at_least(3, 0) || is_supported("GL_ARB_framebuffer_object")) + { + glBindFramebuffer = reinterpret_cast(get_proc_address("glBindFramebuffer")); + glBindRenderbuffer = reinterpret_cast(get_proc_address("glBindRenderbuffer")); + glCheckFramebufferStatus = reinterpret_cast(get_proc_address("glCheckFramebufferStatus")); + glDeleteFramebuffers = reinterpret_cast(get_proc_address("glDeleteFramebuffers")); + glDeleteRenderbuffers = reinterpret_cast(get_proc_address("glDeleteRenderbuffers")); + glFramebufferRenderbuffer = reinterpret_cast(get_proc_address("glFramebufferRenderbuffer")); + glFramebufferTexture1D = reinterpret_cast(get_proc_address("glFramebufferTexture1D")); + glFramebufferTexture2D = reinterpret_cast(get_proc_address("glFramebufferTexture2D")); + glFramebufferTexture3D = reinterpret_cast(get_proc_address("glFramebufferTexture3D")); + glGenFramebuffers = reinterpret_cast(get_proc_address("glGenFramebuffers")); + glGenRenderbuffers = reinterpret_cast(get_proc_address("glGenRenderbuffers")); + glGenerateMipmap = reinterpret_cast(get_proc_address("glGenerateMipmap")); + glGetFramebufferAttachmentParameteriv = reinterpret_cast(get_proc_address("glGetFramebufferAttachmentParameteriv")); + glGetRenderbufferParameteriv = reinterpret_cast(get_proc_address("glGetRenderbufferParameteriv")); + glIsFramebuffer = reinterpret_cast(get_proc_address("glIsFramebuffer")); + glIsRenderbuffer = reinterpret_cast(get_proc_address("glIsRenderbuffer")); + glRenderbufferStorage = reinterpret_cast(get_proc_address("glRenderbufferStorage")); + return Extension::CORE; + } + if(is_supported("GL_EXT_framebuffer_object")) + { + glBindFramebuffer = reinterpret_cast(get_proc_address("glBindFramebufferEXT")); + glBindRenderbuffer = reinterpret_cast(get_proc_address("glBindRenderbufferEXT")); + glCheckFramebufferStatus = reinterpret_cast(get_proc_address("glCheckFramebufferStatusEXT")); + glDeleteFramebuffers = reinterpret_cast(get_proc_address("glDeleteFramebuffersEXT")); + glDeleteRenderbuffers = reinterpret_cast(get_proc_address("glDeleteRenderbuffersEXT")); + glFramebufferRenderbuffer = reinterpret_cast(get_proc_address("glFramebufferRenderbufferEXT")); + glFramebufferTexture1D = reinterpret_cast(get_proc_address("glFramebufferTexture1DEXT")); + glFramebufferTexture2D = reinterpret_cast(get_proc_address("glFramebufferTexture2DEXT")); + glFramebufferTexture3D = reinterpret_cast(get_proc_address("glFramebufferTexture3DEXT")); + glGenFramebuffers = reinterpret_cast(get_proc_address("glGenFramebuffersEXT")); + glGenRenderbuffers = reinterpret_cast(get_proc_address("glGenRenderbuffersEXT")); + glGenerateMipmap = reinterpret_cast(get_proc_address("glGenerateMipmapEXT")); + glGetFramebufferAttachmentParameteriv = reinterpret_cast(get_proc_address("glGetFramebufferAttachmentParameterivEXT")); + glGetRenderbufferParameteriv = reinterpret_cast(get_proc_address("glGetRenderbufferParameterivEXT")); + glIsFramebuffer = reinterpret_cast(get_proc_address("glIsFramebufferEXT")); + glIsRenderbuffer = reinterpret_cast(get_proc_address("glIsRenderbufferEXT")); + glRenderbufferStorage = reinterpret_cast(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 diff --git a/source/ext_framebuffer_object.h b/source/ext_framebuffer_object.h index a92b3056..69bf7466 100644 --- a/source/ext_framebuffer_object.h +++ b/source/ext_framebuffer_object.h @@ -1,31 +1,32 @@ #ifndef MSP_GL_EXT_FRAMEBUFFER_OBJECT_ #define MSP_GL_EXT_FRAMEBUFFER_OBJECT_ +#include "extension.h" #include "gl.h" #include 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 index 00000000..e75044a8 --- /dev/null +++ b/source/ext_texture3d.cpp @@ -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(get_proc_address("glTexImage3D")); + glTexSubImage3D = reinterpret_cast(get_proc_address("glTexSubImage3D")); + return Extension::CORE; + } + if(is_supported("GL_EXT_texture3D")) + { + glTexImage3D = reinterpret_cast(get_proc_address("glTexImage3DEXT")); + glTexSubImage3D = reinterpret_cast(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 index 00000000..2f2d696d --- /dev/null +++ b/source/ext_texture3d.h @@ -0,0 +1,19 @@ +#ifndef MSP_GL_EXT_TEXTURE3D_ +#define MSP_GL_EXT_TEXTURE3D_ + +#include "extension.h" +#include "gl.h" +#include + +namespace Msp { +namespace GL { + +extern PFNGLTEXIMAGE3DPROC glTexImage3D; +extern PFNGLTEXSUBIMAGE3DPROC glTexSubImage3D; + +extern Extension EXT_texture3D; + +} // namespace GL +} // namespace Msp + +#endif diff --git a/source/extension.cpp b/source/extension.cpp index bc43ae8b..6ca4f08c 100644 --- a/source/extension.cpp +++ b/source/extension.cpp @@ -5,26 +5,41 @@ #endif #include #include -#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 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(parts[0]); version.minor = lexical_cast(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 diff --git a/source/extension.h b/source/extension.h index 4072869c..e6c2aca0 100644 --- a/source/extension.h +++ b/source/extension.h @@ -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 diff --git a/source/framebuffer.cpp b/source/framebuffer.cpp index c4f714c6..43b0f94b 100644 --- a/source/framebuffer.cpp +++ b/source/framebuffer.cpp @@ -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<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(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(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::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(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)); + return static_cast(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; } diff --git a/source/framebuffer.h b/source/framebuffer.h index 8a97222c..236d29e6 100644 --- a/source/framebuffer.h +++ b/source/framebuffer.h @@ -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 diff --git a/source/mesh.cpp b/source/mesh.cpp index c5e73ebd..9757df5c 100644 --- a/source/mesh.cpp +++ b/source/mesh.cpp @@ -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) diff --git a/source/nv_primitive_restart.cpp b/source/nv_primitive_restart.cpp index b685e340..ed5a2664 100644 --- a/source/nv_primitive_restart.cpp +++ b/source/nv_primitive_restart.cpp @@ -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(get_proc_address("glPrimitiveRestartNV")); - glPrimitiveRestartIndexNV = reinterpret_cast(get_proc_address("glPrimitiveRestartIndexNV")); + if(is_supported("GL_NV_primitive_restart")) + { + glPrimitiveRestartIndexNV = reinterpret_cast(get_proc_address("glPrimitiveRestartIndexNV")); + glPrimitiveRestartNV = reinterpret_cast(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 diff --git a/source/nv_primitive_restart.h b/source/nv_primitive_restart.h index b1ff5e16..87358435 100644 --- a/source/nv_primitive_restart.h +++ b/source/nv_primitive_restart.h @@ -1,16 +1,17 @@ #ifndef MSP_GL_NV_PRIMITIVE_RESTART_ #define MSP_GL_NV_PRIMITIVE_RESTART_ +#include "extension.h" #include "gl.h" #include 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 diff --git a/source/program.cpp b/source/program.cpp index d9627519..adbb5c4c 100644 --- a/source/program.cpp +++ b/source/program.cpp @@ -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 uniforms_by_index(count); for(unsigned i=0; isecond.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); } diff --git a/source/programdata.cpp b/source/programdata.cpp index f3f498f3..ed4b0a29 100644 --- a/source/programdata.cpp +++ b/source/programdata.cpp @@ -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 diff --git a/source/renderbuffer.cpp b/source/renderbuffer.cpp index 240cf84c..c920633e 100644 --- a/source/renderbuffer.cpp +++ b/source/renderbuffer.cpp @@ -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 index 00000000..50805172 --- /dev/null +++ b/source/sgis_generate_mipmap.cpp @@ -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 index 00000000..86d8802b --- /dev/null +++ b/source/sgis_generate_mipmap.h @@ -0,0 +1,16 @@ +#ifndef MSP_GL_SGIS_GENERATE_MIPMAP_ +#define MSP_GL_SGIS_GENERATE_MIPMAP_ + +#include "extension.h" +#include "gl.h" +#include + +namespace Msp { +namespace GL { + +extern Extension SGIS_generate_mipmap; + +} // namespace GL +} // namespace Msp + +#endif diff --git a/source/shader.cpp b/source/shader.cpp index cdb50c96..b0cf5a3e 100644 --- a/source/shader.cpp +++ b/source/shader.cpp @@ -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; diff --git a/source/texture.cpp b/source/texture.cpp index 57b1b78d..c8a1371c 100644 --- a/source/texture.cpp +++ b/source/texture.cpp @@ -1,6 +1,6 @@ #include #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); } diff --git a/source/texture3d.cpp b/source/texture3d.cpp index 33b25ccc..0ad65f88 100644 --- a/source/texture3d.cpp +++ b/source/texture3d.cpp @@ -2,9 +2,8 @@ #include #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) diff --git a/source/texturecube.cpp b/source/texturecube.cpp index ddb0c1e0..bbe6a6b6 100644 --- a/source/texturecube.cpp +++ b/source/texturecube.cpp @@ -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) diff --git a/source/texunit.cpp b/source/texunit.cpp index 7eb89a98..b19e7917 100644 --- a/source/texunit.cpp +++ b/source/texunit.cpp @@ -1,8 +1,8 @@ #include -#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"); diff --git a/source/uniform.cpp b/source/uniform.cpp index ac866cf5..09450a9a 100644 --- a/source/uniform.cpp +++ b/source/uniform.cpp @@ -7,39 +7,39 @@ namespace GL { template<> void UniformScalar::apply(int index, unsigned size, const int *value) { - glUniform1ivARB(index, size, value); + glUniform1iv(index, size, value); } template<> void UniformScalar::apply(int index, unsigned size, const float *value) { - glUniform1fvARB(index, size, value); + glUniform1fv(index, size, value); } template<> void UniformVector::apply(int index, unsigned size, const float *value) { - glUniform2fvARB(index, size, value); + glUniform2fv(index, size, value); } template<> void UniformVector::apply(int index, unsigned size, const float *value) { - glUniform3fvARB(index, size, value); + glUniform3fv(index, size, value); } template<> void UniformVector::apply(int index, unsigned size, const float *value) { - glUniform4fvARB(index, size, value); + glUniform4fv(index, size, value); } template<> void UniformMatrix::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 index 9fed2834..00000000 --- a/source/version_1_2.cpp +++ /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(get_proc_address("glBlendColor")); - glBlendEquation = reinterpret_cast(get_proc_address("glBlendEquation")); - glDrawRangeElements = reinterpret_cast(get_proc_address("glDrawRangeElements")); - glColorTable = reinterpret_cast(get_proc_address("glColorTable")); - glColorTableParameterfv = reinterpret_cast(get_proc_address("glColorTableParameterfv")); - glColorTableParameteriv = reinterpret_cast(get_proc_address("glColorTableParameteriv")); - glCopyColorTable = reinterpret_cast(get_proc_address("glCopyColorTable")); - glGetColorTable = reinterpret_cast(get_proc_address("glGetColorTable")); - glGetColorTableParameterfv = reinterpret_cast(get_proc_address("glGetColorTableParameterfv")); - glGetColorTableParameteriv = reinterpret_cast(get_proc_address("glGetColorTableParameteriv")); - glColorSubTable = reinterpret_cast(get_proc_address("glColorSubTable")); - glCopyColorSubTable = reinterpret_cast(get_proc_address("glCopyColorSubTable")); - glConvolutionFilter1D = reinterpret_cast(get_proc_address("glConvolutionFilter1D")); - glConvolutionFilter2D = reinterpret_cast(get_proc_address("glConvolutionFilter2D")); - glConvolutionParameterf = reinterpret_cast(get_proc_address("glConvolutionParameterf")); - glConvolutionParameterfv = reinterpret_cast(get_proc_address("glConvolutionParameterfv")); - glConvolutionParameteri = reinterpret_cast(get_proc_address("glConvolutionParameteri")); - glConvolutionParameteriv = reinterpret_cast(get_proc_address("glConvolutionParameteriv")); - glCopyConvolutionFilter1D = reinterpret_cast(get_proc_address("glCopyConvolutionFilter1D")); - glCopyConvolutionFilter2D = reinterpret_cast(get_proc_address("glCopyConvolutionFilter2D")); - glGetConvolutionFilter = reinterpret_cast(get_proc_address("glGetConvolutionFilter")); - glGetConvolutionParameterfv = reinterpret_cast(get_proc_address("glGetConvolutionParameterfv")); - glGetConvolutionParameteriv = reinterpret_cast(get_proc_address("glGetConvolutionParameteriv")); - glGetSeparableFilter = reinterpret_cast(get_proc_address("glGetSeparableFilter")); - glSeparableFilter2D = reinterpret_cast(get_proc_address("glSeparableFilter2D")); - glGetHistogram = reinterpret_cast(get_proc_address("glGetHistogram")); - glGetHistogramParameterfv = reinterpret_cast(get_proc_address("glGetHistogramParameterfv")); - glGetHistogramParameteriv = reinterpret_cast(get_proc_address("glGetHistogramParameteriv")); - glGetMinmax = reinterpret_cast(get_proc_address("glGetMinmax")); - glGetMinmaxParameterfv = reinterpret_cast(get_proc_address("glGetMinmaxParameterfv")); - glGetMinmaxParameteriv = reinterpret_cast(get_proc_address("glGetMinmaxParameteriv")); - glHistogram = reinterpret_cast(get_proc_address("glHistogram")); - glMinmax = reinterpret_cast(get_proc_address("glMinmax")); - glResetHistogram = reinterpret_cast(get_proc_address("glResetHistogram")); - glResetMinmax = reinterpret_cast(get_proc_address("glResetMinmax")); - glTexImage3D = reinterpret_cast(get_proc_address("glTexImage3D")); - glTexSubImage3D = reinterpret_cast(get_proc_address("glTexSubImage3D")); - glCopyTexSubImage3D = reinterpret_cast(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 index d10ba532..00000000 --- a/source/version_1_2.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef MSP_GL_VERSION_1_2_ -#define MSP_GL_VERSION_1_2_ - -#include "gl.h" -#include - -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 index d248a083..00000000 --- a/source/version_1_3.cpp +++ /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(get_proc_address("glActiveTexture")); - glClientActiveTexture = reinterpret_cast(get_proc_address("glClientActiveTexture")); - glMultiTexCoord1d = reinterpret_cast(get_proc_address("glMultiTexCoord1d")); - glMultiTexCoord1dv = reinterpret_cast(get_proc_address("glMultiTexCoord1dv")); - glMultiTexCoord1f = reinterpret_cast(get_proc_address("glMultiTexCoord1f")); - glMultiTexCoord1fv = reinterpret_cast(get_proc_address("glMultiTexCoord1fv")); - glMultiTexCoord1i = reinterpret_cast(get_proc_address("glMultiTexCoord1i")); - glMultiTexCoord1iv = reinterpret_cast(get_proc_address("glMultiTexCoord1iv")); - glMultiTexCoord1s = reinterpret_cast(get_proc_address("glMultiTexCoord1s")); - glMultiTexCoord1sv = reinterpret_cast(get_proc_address("glMultiTexCoord1sv")); - glMultiTexCoord2d = reinterpret_cast(get_proc_address("glMultiTexCoord2d")); - glMultiTexCoord2dv = reinterpret_cast(get_proc_address("glMultiTexCoord2dv")); - glMultiTexCoord2f = reinterpret_cast(get_proc_address("glMultiTexCoord2f")); - glMultiTexCoord2fv = reinterpret_cast(get_proc_address("glMultiTexCoord2fv")); - glMultiTexCoord2i = reinterpret_cast(get_proc_address("glMultiTexCoord2i")); - glMultiTexCoord2iv = reinterpret_cast(get_proc_address("glMultiTexCoord2iv")); - glMultiTexCoord2s = reinterpret_cast(get_proc_address("glMultiTexCoord2s")); - glMultiTexCoord2sv = reinterpret_cast(get_proc_address("glMultiTexCoord2sv")); - glMultiTexCoord3d = reinterpret_cast(get_proc_address("glMultiTexCoord3d")); - glMultiTexCoord3dv = reinterpret_cast(get_proc_address("glMultiTexCoord3dv")); - glMultiTexCoord3f = reinterpret_cast(get_proc_address("glMultiTexCoord3f")); - glMultiTexCoord3fv = reinterpret_cast(get_proc_address("glMultiTexCoord3fv")); - glMultiTexCoord3i = reinterpret_cast(get_proc_address("glMultiTexCoord3i")); - glMultiTexCoord3iv = reinterpret_cast(get_proc_address("glMultiTexCoord3iv")); - glMultiTexCoord3s = reinterpret_cast(get_proc_address("glMultiTexCoord3s")); - glMultiTexCoord3sv = reinterpret_cast(get_proc_address("glMultiTexCoord3sv")); - glMultiTexCoord4d = reinterpret_cast(get_proc_address("glMultiTexCoord4d")); - glMultiTexCoord4dv = reinterpret_cast(get_proc_address("glMultiTexCoord4dv")); - glMultiTexCoord4f = reinterpret_cast(get_proc_address("glMultiTexCoord4f")); - glMultiTexCoord4fv = reinterpret_cast(get_proc_address("glMultiTexCoord4fv")); - glMultiTexCoord4i = reinterpret_cast(get_proc_address("glMultiTexCoord4i")); - glMultiTexCoord4iv = reinterpret_cast(get_proc_address("glMultiTexCoord4iv")); - glMultiTexCoord4s = reinterpret_cast(get_proc_address("glMultiTexCoord4s")); - glMultiTexCoord4sv = reinterpret_cast(get_proc_address("glMultiTexCoord4sv")); - glLoadTransposeMatrixf = reinterpret_cast(get_proc_address("glLoadTransposeMatrixf")); - glLoadTransposeMatrixd = reinterpret_cast(get_proc_address("glLoadTransposeMatrixd")); - glMultTransposeMatrixf = reinterpret_cast(get_proc_address("glMultTransposeMatrixf")); - glMultTransposeMatrixd = reinterpret_cast(get_proc_address("glMultTransposeMatrixd")); - glSampleCoverage = reinterpret_cast(get_proc_address("glSampleCoverage")); - glCompressedTexImage3D = reinterpret_cast(get_proc_address("glCompressedTexImage3D")); - glCompressedTexImage2D = reinterpret_cast(get_proc_address("glCompressedTexImage2D")); - glCompressedTexImage1D = reinterpret_cast(get_proc_address("glCompressedTexImage1D")); - glCompressedTexSubImage3D = reinterpret_cast(get_proc_address("glCompressedTexSubImage3D")); - glCompressedTexSubImage2D = reinterpret_cast(get_proc_address("glCompressedTexSubImage2D")); - glCompressedTexSubImage1D = reinterpret_cast(get_proc_address("glCompressedTexSubImage1D")); - glGetCompressedTexImage = reinterpret_cast(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 index bd0b4eae..00000000 --- a/source/version_1_3.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef MSP_GL_VERSION_1_3_ -#define MSP_GL_VERSION_1_3_ - -#include "gl.h" -#include - -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 diff --git a/source/vertexarray.cpp b/source/vertexarray.cpp index e5e81204..13816a13 100644 --- a/source/vertexarray.cpp +++ b/source/vertexarray.cpp @@ -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;