]> git.tdb.fi Git - libs/gl.git/commitdiff
Windows compatibility:
authorMikko Rasa <tdb@tdb.fi>
Sat, 29 Dec 2007 20:47:08 +0000 (20:47 +0000)
committerMikko Rasa <tdb@tdb.fi>
Sat, 29 Dec 2007 20:47:08 +0000 (20:47 +0000)
- Tweak includes
- Fetch all functions from OpenGL 1.2+ with get_proc_address

39 files changed:
Build
extgen.py
source/arb_shader_objects.h
source/arb_vertex_buffer_object.cpp [new file with mode: 0644]
source/arb_vertex_buffer_object.h [new file with mode: 0644]
source/arb_vertex_shader.h
source/batch.cpp
source/batch.h
source/color.h
source/ext_framebuffer_object.h
source/extension.cpp
source/extension.h
source/font.cpp
source/framebuffer.h
source/gl.h [new file with mode: 0644]
source/material.cpp
source/matrix.h
source/misc.h
source/pixelformat.h
source/predicate.h
source/primitivetype.h
source/program.h
source/projection.cpp
source/rendermode.h
source/select.cpp
source/select.h
source/shader.h
source/stencil.h
source/tests.h
source/texture.h
source/texture3d.cpp
source/texunit.cpp
source/transform.cpp
source/version_1_2.cpp [new file with mode: 0644]
source/version_1_2.h [new file with mode: 0644]
source/version_1_3.cpp [new file with mode: 0644]
source/version_1_3.h [new file with mode: 0644]
source/vertexarray.cpp
source/vertexbuffer.cpp

diff --git a/Build b/Build
index b83b3c7c12c37f67140ce45ed70e2c13de3ce958..37e2ef7df93466310bd0d14303f61b71fe9e37c4 100644 (file)
--- a/Build
+++ b/Build
@@ -5,7 +5,18 @@ package "mspgl"
        description "C++ wrappers for OpenGL";
        version "0.1";
 
-       require "opengl";
+       // A bit of a hack until I get something better in builder
+       if "arch!=win32"
+       {
+               require "opengl";
+       };
+       if "arch=win32"
+       {
+               build_info
+               {
+                       library "opengl32";
+               };
+       };
        require "mspdatafile";
        require "devil";
        build_info
index 109802862b91d65f5d43479275ae2f303c3a9f3c..2d64cba78d060a6351a5411044a22725453348d0 100755 (executable)
--- a/extgen.py
+++ b/extgen.py
@@ -24,7 +24,8 @@ out.write("#ifndef MSP_GL_%s_\n"%ext.upper())
 out.write("#define MSP_GL_%s_\n"%ext.upper())
 
 out.write("""
-#include <GL/gl.h>
+#include "gl.h"
+#include <GL/glext.h>
 
 namespace Msp {
 namespace GL {
index 56200a9f2dd4612cdabac30ea3c10023d83e7330..e256d06837f0b0fa444d5db92f566c46c347e8a0 100644 (file)
@@ -1,7 +1,8 @@
 #ifndef MSP_GL_ARB_SHADER_OBJECTS_
 #define MSP_GL_ARB_SHADER_OBJECTS_
 
-#include <GL/gl.h>
+#include "gl.h"
+#include <GL/glext.h>
 
 namespace Msp {
 namespace GL {
diff --git a/source/arb_vertex_buffer_object.cpp b/source/arb_vertex_buffer_object.cpp
new file mode 100644 (file)
index 0000000..6e98fef
--- /dev/null
@@ -0,0 +1,35 @@
+#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;
+
+void init_arb_vertex_buffer_object()
+{
+       glBindBufferARB=reinterpret_cast<PFNGLBINDBUFFERARBPROC>(get_proc_address("glBindBufferARB"));
+       glDeleteBuffersARB=reinterpret_cast<PFNGLDELETEBUFFERSARBPROC>(get_proc_address("glDeleteBuffersARB"));
+       glGenBuffersARB=reinterpret_cast<PFNGLGENBUFFERSARBPROC>(get_proc_address("glGenBuffersARB"));
+       glIsBufferARB=reinterpret_cast<PFNGLISBUFFERARBPROC>(get_proc_address("glIsBufferARB"));
+       glBufferDataARB=reinterpret_cast<PFNGLBUFFERDATAARBPROC>(get_proc_address("glBufferDataARB"));
+       glBufferSubDataARB=reinterpret_cast<PFNGLBUFFERSUBDATAARBPROC>(get_proc_address("glBufferSubDataARB"));
+       glGetBufferSubDataARB=reinterpret_cast<PFNGLGETBUFFERSUBDATAARBPROC>(get_proc_address("glGetBufferSubDataARB"));
+       glMapBufferARB=reinterpret_cast<PFNGLMAPBUFFERARBPROC>(get_proc_address("glMapBufferARB"));
+       glUnmapBufferARB=reinterpret_cast<PFNGLUNMAPBUFFERARBPROC>(get_proc_address("glUnmapBufferARB"));
+       glGetBufferParameterivARB=reinterpret_cast<PFNGLGETBUFFERPARAMETERIVARBPROC>(get_proc_address("glGetBufferParameterivARB"));
+       glGetBufferPointervARB=reinterpret_cast<PFNGLGETBUFFERPOINTERVARBPROC>(get_proc_address("glGetBufferPointervARB"));
+}
+
+} // namespace GL
+} // namespace Msp
diff --git a/source/arb_vertex_buffer_object.h b/source/arb_vertex_buffer_object.h
new file mode 100644 (file)
index 0000000..8d3be97
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef MSP_GL_ARB_VERTEX_BUFFER_OBJECT_
+#define MSP_GL_ARB_VERTEX_BUFFER_OBJECT_
+
+#include "gl.h"
+#include <GL/glext.h>
+
+namespace Msp {
+namespace GL {
+
+extern PFNGLBINDBUFFERARBPROC glBindBufferARB;
+extern PFNGLDELETEBUFFERSARBPROC glDeleteBuffersARB;
+extern PFNGLGENBUFFERSARBPROC glGenBuffersARB;
+extern PFNGLISBUFFERARBPROC glIsBufferARB;
+extern PFNGLBUFFERDATAARBPROC glBufferDataARB;
+extern PFNGLBUFFERSUBDATAARBPROC glBufferSubDataARB;
+extern PFNGLGETBUFFERSUBDATAARBPROC glGetBufferSubDataARB;
+extern PFNGLMAPBUFFERARBPROC glMapBufferARB;
+extern PFNGLUNMAPBUFFERARBPROC glUnmapBufferARB;
+extern PFNGLGETBUFFERPARAMETERIVARBPROC glGetBufferParameterivARB;
+extern PFNGLGETBUFFERPOINTERVARBPROC glGetBufferPointervARB;
+
+void init_arb_vertex_buffer_object();
+
+} // namespace GL
+} // namespace Msp
+
+#endif
index bc447a352039810ad5f054feb7482e39356c1bc8..6dab0c0ae36377a91a6ebbfe6b6e696c31d809cb 100644 (file)
@@ -1,7 +1,8 @@
 #ifndef MSP_GL_ARB_VERTEX_SHADER_
 #define MSP_GL_ARB_VERTEX_SHADER_
 
-#include <GL/gl.h>
+#include "gl.h"
+#include <GL/glext.h>
 
 namespace Msp {
 namespace GL {
index df4e2fb828e0102989abd2ddacb069f59a33d3a9..385b4697085f6215e075344ac9a980007212e193 100644 (file)
@@ -5,8 +5,9 @@ Copyright © 2007 Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#define GL_GLEXT_PROTOTYPES
 #include "batch.h"
+#include "extension.h"
+#include "version_1_2.h"
 
 using namespace std;
 
@@ -17,7 +18,9 @@ Batch::Batch(PrimitiveType t):
        type(t),
        min_index(0),
        max_index(0)
-{ }
+{
+       require_version(1, 2);
+}
 
 Batch &Batch::append(uint i)
 {
index 237995dcd7698b60061836336524e9ce8181cdc0..4a2e4b340501a57c222eff7c44b8fb95750fe7dc 100644 (file)
@@ -9,7 +9,6 @@ Distributed under the LGPL
 #define MSP_GL_BATCH_H_
 
 #include <vector>
-#include <GL/gl.h>
 #include <msp/datafile/loader.h>
 #include "primitivetype.h"
 #include "types.h"
index d3710a9d64c745fb85d87a4216222854e4c08730..2c48cd494bbcae09e080e963f1b8d9634c67d839 100644 (file)
@@ -8,8 +8,6 @@ Distributed under the LGPL
 #ifndef MSP_GL_COLOR_H_
 #define MSP_GL_COLOR_H_
 
-#include <GL/gl.h>
-
 namespace Msp {
 namespace GL {
 
index f541c2ff7e5ec29e83ee587f5e0cb653fd4ee9f9..a92b30560751d8dc97f1be9be9f2484d9f14b355 100644 (file)
@@ -1,7 +1,8 @@
 #ifndef MSP_GL_EXT_FRAMEBUFFER_OBJECT_
 #define MSP_GL_EXT_FRAMEBUFFER_OBJECT_
 
-#include <GL/gl.h>
+#include "gl.h"
+#include <GL/glext.h>
 
 namespace Msp {
 namespace GL {
index e250bb249c9f04fd9fce24ebd3a42762ded9657d..a5ad3191b88e518bae3116039a200a784bc0d6a8 100644 (file)
@@ -6,16 +6,20 @@ Distributed under the LGPL
 */
 
 #include <set>
-#include <GL/gl.h>
 #ifndef WIN32
 #include <GL/glx.h>
 #endif
+#include <msp/strings/formatter.h>
 #include <msp/strings/utils.h>
 #include "arb_shader_objects.h"
+#include "arb_vertex_buffer_object.h"
 #include "arb_vertex_shader.h"
 #include "ext_framebuffer_object.h"
 #include "except.h"
 #include "extension.h"
+#include "gl.h"
+#include "version_1_2.h"
+#include "version_1_3.h"
 
 using namespace std;
 
@@ -43,6 +47,8 @@ bool is_supported(const string &ext)
                        init_arb_vertex_shader();
                if(extensions.count("GL_EXT_framebuffer_object"))
                        init_ext_framebuffer_object();
+               if(extensions.count("GL_ARB_vertex_buffer_object"))
+                       init_arb_vertex_buffer_object();
 
                init_done=true;
        }
@@ -50,16 +56,47 @@ bool is_supported(const string &ext)
        return extensions.count(ext);
 }
 
+const Version &get_gl_version()
+{
+       static Version version;
+       static bool init_done=false;
+
+       if(!init_done)
+       {
+               string gl_ver=reinterpret_cast<const char *>(glGetString(GL_VERSION));
+               vector<string> parts=split(gl_ver.substr(0, gl_ver.find(' ')), '.');
+               version.major=lexical_cast<unsigned>(parts[0]);
+               version.minor=lexical_cast<unsigned>(parts[1]);
+
+               unsigned combined=version.major*0x100+version.minor;
+               if(combined>=0x102)
+                       init_version_1_2();
+               if(combined>=0x103)
+                       init_version_1_3();
+       }
+
+       return version;
+}
+
 void require_extension(const string &ext)
 {
        if(!is_supported(ext))
-               throw UnsupportedExtension(ext+" is not supported");
+               throw UnsupportedExtension(ext);
+}
+
+void require_version(unsigned a, unsigned b)
+{
+       const Version &ver=get_gl_version();
+       if(ver.major<a || (ver.major==a && ver.minor<b))
+               throw UnsupportedExtension(format("OpenGL %d.%d", a, b));
 }
 
 ExtFunc *get_proc_address(const string &name)
 {
 #ifndef WIN32
        return glXGetProcAddressARB(reinterpret_cast<const GLubyte *>(name.c_str()));
+#else
+       return reinterpret_cast<ExtFunc *>(wglGetProcAddress(name.c_str()));
 #endif
 }
 
index d6eb75f6a396eccec9c17cd7e6a111e3cb7406aa..aec516e2766a3bce033f3bbd0e7942e04417c587 100644 (file)
@@ -13,6 +13,12 @@ Distributed under the LGPL
 namespace Msp {
 namespace GL {
 
+struct Version
+{
+       unsigned short major;
+       unsigned short minor;
+};
+
 typedef void ExtFunc();
 
 /**
@@ -21,11 +27,22 @@ functions of that extension are safe to use.
 */
 bool is_supported(const std::string &);
 
+/**
+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();
+
 /**
 Checks that an extension is supported and throws if it isn't.
 */
 void require_extension(const std::string &);
 
+/**
+Checks that the OpenGL version is at least a.b and throws if it isn't.
+*/
+void require_version(unsigned a, unsigned b);
+
 /**
 Returns the address of an extension function.
 */
index 60090e0148de8e3ebc587da94f04261c4b629fe6..637569f205358a8a08edf846fbac8c55a480e7e1 100644 (file)
@@ -5,7 +5,7 @@ Copyright © 2007  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#include <GL/gl.h>
+#include "gl.h"
 #include "font.h"
 #include "texture2d.h"
 
@@ -105,6 +105,9 @@ void Font::draw_glyph(unsigned code) const
        if(i==glyphs.end())
                return;
 
+       const Glyph &glyph=i->second;
+       (void)glyph;
+
        glDrawArrays(GL_QUADS, i->second.index*4, 4);
 
        glTranslatef(i->second.advance, 0, 0);
index 8563d2f98418d0f315720a9e4b734a3dc6c58817..437ac1afb79faeef5275df4d43403919c081cbba 100644 (file)
@@ -8,7 +8,7 @@ Distributed under the LGPL
 #ifndef MSP_GL_FRAMEBUFFER_H_
 #define MSP_GL_FRAMEBUFFER_H_
 
-#include <GL/gl.h>
+#include "gl.h"
 #include "types.h"
 
 namespace Msp {
diff --git a/source/gl.h b/source/gl.h
new file mode 100644 (file)
index 0000000..c033a37
--- /dev/null
@@ -0,0 +1,16 @@
+/* $Id$
+
+This file is part of libmspgl
+Copyright © 2007  Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#ifndef MSP_GL_GL_H_
+#define MSP_GL_GL_H_
+
+#ifdef WIN32
+#include <windows.h>
+#endif
+#include <GL/gl.h>
+
+#endif
index f165c744fcdf06277c362977954b800c06e6e6df..0b888ef519404e164ac32be278f3593fb85edc0e 100644 (file)
@@ -5,6 +5,7 @@ Copyright © 2007  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
+#include "gl.h"
 #include "material.h"
 
 namespace Msp {
index b4cc339ceccd3a46601e3529c4e21bcd563150b0..fe67ad7e4bf749693eedae982a2cbb0d10b40884 100644 (file)
@@ -8,7 +8,7 @@ Distributed under the LGPL
 #ifndef MSP_GL_MATRIX_H_
 #define MSP_GL_MATRIX_H_
 
-#include <GL/gl.h>
+#include "gl.h"
 
 namespace Msp {
 namespace GL {
index 071875cd43805db5db7f230849d1e2060c2972ca..8a956a5ab4a26306f06abd4869a2dd6b42a93d43 100644 (file)
@@ -8,7 +8,7 @@ Distributed under the LGPL
 #ifndef MSP_GL_MISC_H_
 #define MSP_GL_MISC_H_
 
-#include <GL/gl.h>
+#include "gl.h"
 
 namespace Msp {
 namespace GL {
index 87cbe7546c95a8ca0125c1ef5fbb784139d10f27..6579700d421e8329279a2c35147c4e4c7283bb4a 100644 (file)
@@ -8,7 +8,7 @@ Distributed under the LGPL
 #ifndef MSP_GL_PIXELFORMAT_H_
 #define MSP_GL_PIXELFORMAT_H_
 
-#include <GL/gl.h>
+#include "gl.h"
 
 namespace Msp {
 namespace GL {
index f5ff3b3cb4091a166b174d9cde08240c20530e47..707bc5d561bf6ac760670e5f8a785ca9bccbb426 100644 (file)
@@ -8,7 +8,7 @@ Distributed under the LGPL
 #ifndef MSP_GL_PREDICATE_H_
 #define MSP_GL_PREDICATE_H_
 
-#include <GL/gl.h>
+#include "gl.h"
 
 namespace Msp {
 namespace GL {
index 4001852575aa0a905a40ac253c1d2c1b4827de23..f4f665e3cd19744757b98399bd3d1f776c3a192f 100644 (file)
@@ -9,7 +9,7 @@ Distributed under the LGPL
 #define MSP_GL_PRIMITIVETYPE_H_
 
 #include <istream>
-#include <GL/gl.h>
+#include "gl.h"
 
 namespace Msp {
 namespace GL {
index 3b86a9c6d17d4af1af0ae0f1596eb67246799733..82d06a109a9dde15927409b6cdf8a3e1e7272ebd 100644 (file)
@@ -10,8 +10,8 @@ Distributed under the LGPL
 
 #include <list>
 #include <string>
-#include <GL/gl.h>
 #include <msp/datafile/loader.h>
+#include "gl.h"
 #include "types.h"
 
 namespace Msp {
index 3a8baf84af3f492925366702b434a46a75e6a478..2c234525ce63e0240bdc891f6d56c29be0484dcd 100644 (file)
@@ -6,15 +6,15 @@ Distributed under the LGPL
 */
 
 #include <cmath>
-#include <GL/gl.h>
+#include "gl.h"
 #include "projection.h"
 
 namespace Msp {
 namespace GL {
 
-void ortho(double left, double right, double bottom, double top, double near, double far)
+void ortho(double left, double right, double bottom, double top, double nearr, double farr)
 {
-       glOrtho(left, right, bottom, top, near, far);
+       glOrtho(left, right, bottom, top, nearr, farr);
 }
 
 void ortho_centered(double width, double height)
@@ -32,20 +32,20 @@ void ortho_topleft(double width, double height)
        ortho(0, width, height, 0, 0, 1);
 }
 
-void frustum(double left, double right, double bottom, double top, double near, double far)
+void frustum(double left, double right, double bottom, double top, double nearr, double farr)
 {
-       glFrustum(left, right, bottom, top, near, far);
+       glFrustum(left, right, bottom, top, nearr, farr);
 }
 
-void frustum_centered(double width, double height, double near, double far)
+void frustum_centered(double width, double height, double nearr, double farr)
 {
-       glFrustum(-width/2, width/2, -height/2, height/2, near, far);
+       glFrustum(-width/2, width/2, -height/2, height/2, nearr, farr);
 }
 
-void perspective(double fov_y, double aspect, double near, double far)
+void perspective(double fov_y, double aspect, double nearr, double farr)
 {
-       double hh=tan(fov_y*M_PI/360)*near;
-       frustum(-hh*aspect, hh*aspect, -hh, hh, near, far);
+       double hh=tan(fov_y*M_PI/360)*nearr;
+       frustum(-hh*aspect, hh*aspect, -hh, hh, nearr, farr);
 }
 
 } // namespace GL
index be893b21cfb81255a9900918ea7aa3b59066ea38..235dde5e7ad38de58bf6e0244a00fdccfcc2d571 100644 (file)
@@ -8,7 +8,7 @@ Distributed under the LGPL
 #ifndef MSP_GL_RENDERMODE_H_
 #define MSP_GL_RENDERMODE_H_
 
-#include <GL/gl.h>
+#include "gl.h"
 
 namespace Msp {
 namespace GL {
index 67420977323597738ebfac564c8c9514ce637799..e7037cbfb6e59137c36418da552106acbce7f496 100644 (file)
@@ -5,18 +5,16 @@ Copyright © 2007  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#include <GL/gl.h>
 #include "except.h"
+#include "gl.h"
 #include "select.h"
 
 using namespace std;
 
 namespace {
 
-using namespace Msp::GL;
-
-vector<SelectRecord> *select_buf=0;
-vector<uint> select_buf_int;
+vector<Msp::GL::SelectRecord> *select_buf=0;
+vector<Msp::GL::uint> select_buf_int;
 
 }
 
index 2ca28193d7924e63139304686777842b446d2ca0..3964b89414e415f17bb712b802de8239419bf1c4 100644 (file)
@@ -9,6 +9,7 @@ Distributed under the LGPL
 #define MSP_GL_SELECT_H_
 
 #include <vector>
+#include "types.h"
 
 namespace Msp {
 namespace GL {
index dfa5af3b5c18da91ed15fd062b32f7d5f8568ff0..cd01f2acda49a8c3374bc97c356263bccb653b91 100644 (file)
@@ -9,7 +9,7 @@ Distributed under the LGPL
 #define MSP_GL_SHADER_H_
 
 #include <string>
-#include <GL/gl.h>
+#include "gl.h"
 #include "types.h"
 
 namespace Msp {
index 6efb057776365cc2b8122d4e030687b21306be02..4d4ee6d30d68b78f85a5d8219763e8f39ff39fc7 100644 (file)
@@ -8,7 +8,7 @@ Distributed under the LGPL
 #ifndef MSP_GL_STENCIL_H_
 #define MSP_GL_STENCIL_H_
 
-#include <GL/gl.h>
+#include "gl.h"
 #include "predicate.h"
 #include "types.h"
 
index 0fa05b46562abc36c5bce18d68ab88d732adea52..223396fe7f44b6a00e5cd7bca24c30215f610991 100644 (file)
@@ -8,7 +8,7 @@ Distributed under the LGPL
 #ifndef MSP_GL_TESTS_H_
 #define MSP_GL_TESTS_H_
 
-#include <GL/gl.h>
+#include "gl.h"
 #include "predicate.h"
 #include "types.h"
 
index 6c3541d446ef01d817ae88e3611d3dccb0a05f9e..28f9cb328979efdcefc0c6934e250da56748cdb7 100644 (file)
@@ -8,7 +8,7 @@ Distributed under the LGPL
 #ifndef MSP_GL_TEXTURE_H_
 #define MSP_GL_TEXTURE_H_
 
-#include <GL/gl.h>
+#include "gl.h"
 #include "types.h"
 
 namespace Msp {
index 858ca47826afbdc7470df2d91970ba9909a22761..17adb6a109369ed6ca3053d43ee740f851cd6cb6 100644 (file)
@@ -5,11 +5,12 @@ Copyright © 2007  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#define GL_GLEXT_PROTOTYPES
 #include <cmath>
 #include "except.h"
+#include "extension.h"
 #include "ilwrap.h"
 #include "texture3d.h"
+#include "version_1_2.h"
 
 using namespace std;
 
@@ -21,6 +22,8 @@ Texture3D::Texture3D():
        height(0),
        depth(0)
 {
+       require_version(1, 3);
+
        target=GL_TEXTURE_3D;
        bind();
 }
index 91a33ecc378d966644e11aaf90c11524ffbc1bd0..bda7599143a11bf05abcf330a58eca6895c3da67 100644 (file)
@@ -5,10 +5,10 @@ Copyright © 2007  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#define GL_GLEXT_PROTOTYPES
-#include <GL/gl.h>
-#include <GL/glext.h>
+#include "extension.h"
+#include "gl.h"
 #include "texunit.h"
+#include "version_1_3.h"
 
 using namespace std;
 
@@ -17,7 +17,9 @@ namespace GL {
 
 TexUnit::TexUnit():
        texture(0)
-{ }
+{
+       require_version(1, 3);
+}
 
 bool TexUnit::set_texture(const Texture *tex)
 {
@@ -31,7 +33,7 @@ TexUnit &TexUnit::activate(unsigned n)
        if(units.size()<=n)
                units.resize(n+1);
 
-       glActiveTextureARB(GL_TEXTURE0+n);
+       glActiveTexture(GL_TEXTURE0+n);
        cur_unit=&units[n];
 
        return units[n];
index 78c3fb0f6bbbe92e16eeda3d0a7379de90d0cd09..98932b8327a5325b5d4452cee2985fdb833e9858 100644 (file)
@@ -5,7 +5,7 @@ Copyright © 2007  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#include <GL/gl.h>
+#include "gl.h"
 #include "transform.h"
 
 namespace Msp {
diff --git a/source/version_1_2.cpp b/source/version_1_2.cpp
new file mode 100644 (file)
index 0000000..d7c2734
--- /dev/null
@@ -0,0 +1,89 @@
+#include "extension.h"
+#include "version_1_2.h"
+
+namespace Msp {
+namespace GL {
+
+PFNGLBLENDCOLORPROC glBlendColor=0;
+PFNGLBLENDEQUATIONPROC glBlendEquation=0;
+PFNGLDRAWRANGEELEMENTSPROC glDrawRangeElements=0;
+PFNGLCOLORTABLEPROC glColorTable=0;
+PFNGLCOLORTABLEPARAMETERFVPROC glColorTableParameterfv=0;
+PFNGLCOLORTABLEPARAMETERIVPROC glColorTableParameteriv=0;
+PFNGLCOPYCOLORTABLEPROC glCopyColorTable=0;
+PFNGLGETCOLORTABLEPROC glGetColorTable=0;
+PFNGLGETCOLORTABLEPARAMETERFVPROC glGetColorTableParameterfv=0;
+PFNGLGETCOLORTABLEPARAMETERIVPROC glGetColorTableParameteriv=0;
+PFNGLCOLORSUBTABLEPROC glColorSubTable=0;
+PFNGLCOPYCOLORSUBTABLEPROC glCopyColorSubTable=0;
+PFNGLCONVOLUTIONFILTER1DPROC glConvolutionFilter1D=0;
+PFNGLCONVOLUTIONFILTER2DPROC glConvolutionFilter2D=0;
+PFNGLCONVOLUTIONPARAMETERFPROC glConvolutionParameterf=0;
+PFNGLCONVOLUTIONPARAMETERFVPROC glConvolutionParameterfv=0;
+PFNGLCONVOLUTIONPARAMETERIPROC glConvolutionParameteri=0;
+PFNGLCONVOLUTIONPARAMETERIVPROC glConvolutionParameteriv=0;
+PFNGLCOPYCONVOLUTIONFILTER1DPROC glCopyConvolutionFilter1D=0;
+PFNGLCOPYCONVOLUTIONFILTER2DPROC glCopyConvolutionFilter2D=0;
+PFNGLGETCONVOLUTIONFILTERPROC glGetConvolutionFilter=0;
+PFNGLGETCONVOLUTIONPARAMETERFVPROC glGetConvolutionParameterfv=0;
+PFNGLGETCONVOLUTIONPARAMETERIVPROC glGetConvolutionParameteriv=0;
+PFNGLGETSEPARABLEFILTERPROC glGetSeparableFilter=0;
+PFNGLSEPARABLEFILTER2DPROC glSeparableFilter2D=0;
+PFNGLGETHISTOGRAMPROC glGetHistogram=0;
+PFNGLGETHISTOGRAMPARAMETERFVPROC glGetHistogramParameterfv=0;
+PFNGLGETHISTOGRAMPARAMETERIVPROC glGetHistogramParameteriv=0;
+PFNGLGETMINMAXPROC glGetMinmax=0;
+PFNGLGETMINMAXPARAMETERFVPROC glGetMinmaxParameterfv=0;
+PFNGLGETMINMAXPARAMETERIVPROC glGetMinmaxParameteriv=0;
+PFNGLHISTOGRAMPROC glHistogram=0;
+PFNGLMINMAXPROC glMinmax=0;
+PFNGLRESETHISTOGRAMPROC glResetHistogram=0;
+PFNGLRESETMINMAXPROC glResetMinmax=0;
+PFNGLTEXIMAGE3DPROC glTexImage3D=0;
+PFNGLTEXSUBIMAGE3DPROC glTexSubImage3D=0;
+PFNGLCOPYTEXSUBIMAGE3DPROC glCopyTexSubImage3D=0;
+
+void init_version_1_2()
+{
+       glBlendColor=reinterpret_cast<PFNGLBLENDCOLORPROC>(get_proc_address("glBlendColor"));
+       glBlendEquation=reinterpret_cast<PFNGLBLENDEQUATIONPROC>(get_proc_address("glBlendEquation"));
+       glDrawRangeElements=reinterpret_cast<PFNGLDRAWRANGEELEMENTSPROC>(get_proc_address("glDrawRangeElements"));
+       glColorTable=reinterpret_cast<PFNGLCOLORTABLEPROC>(get_proc_address("glColorTable"));
+       glColorTableParameterfv=reinterpret_cast<PFNGLCOLORTABLEPARAMETERFVPROC>(get_proc_address("glColorTableParameterfv"));
+       glColorTableParameteriv=reinterpret_cast<PFNGLCOLORTABLEPARAMETERIVPROC>(get_proc_address("glColorTableParameteriv"));
+       glCopyColorTable=reinterpret_cast<PFNGLCOPYCOLORTABLEPROC>(get_proc_address("glCopyColorTable"));
+       glGetColorTable=reinterpret_cast<PFNGLGETCOLORTABLEPROC>(get_proc_address("glGetColorTable"));
+       glGetColorTableParameterfv=reinterpret_cast<PFNGLGETCOLORTABLEPARAMETERFVPROC>(get_proc_address("glGetColorTableParameterfv"));
+       glGetColorTableParameteriv=reinterpret_cast<PFNGLGETCOLORTABLEPARAMETERIVPROC>(get_proc_address("glGetColorTableParameteriv"));
+       glColorSubTable=reinterpret_cast<PFNGLCOLORSUBTABLEPROC>(get_proc_address("glColorSubTable"));
+       glCopyColorSubTable=reinterpret_cast<PFNGLCOPYCOLORSUBTABLEPROC>(get_proc_address("glCopyColorSubTable"));
+       glConvolutionFilter1D=reinterpret_cast<PFNGLCONVOLUTIONFILTER1DPROC>(get_proc_address("glConvolutionFilter1D"));
+       glConvolutionFilter2D=reinterpret_cast<PFNGLCONVOLUTIONFILTER2DPROC>(get_proc_address("glConvolutionFilter2D"));
+       glConvolutionParameterf=reinterpret_cast<PFNGLCONVOLUTIONPARAMETERFPROC>(get_proc_address("glConvolutionParameterf"));
+       glConvolutionParameterfv=reinterpret_cast<PFNGLCONVOLUTIONPARAMETERFVPROC>(get_proc_address("glConvolutionParameterfv"));
+       glConvolutionParameteri=reinterpret_cast<PFNGLCONVOLUTIONPARAMETERIPROC>(get_proc_address("glConvolutionParameteri"));
+       glConvolutionParameteriv=reinterpret_cast<PFNGLCONVOLUTIONPARAMETERIVPROC>(get_proc_address("glConvolutionParameteriv"));
+       glCopyConvolutionFilter1D=reinterpret_cast<PFNGLCOPYCONVOLUTIONFILTER1DPROC>(get_proc_address("glCopyConvolutionFilter1D"));
+       glCopyConvolutionFilter2D=reinterpret_cast<PFNGLCOPYCONVOLUTIONFILTER2DPROC>(get_proc_address("glCopyConvolutionFilter2D"));
+       glGetConvolutionFilter=reinterpret_cast<PFNGLGETCONVOLUTIONFILTERPROC>(get_proc_address("glGetConvolutionFilter"));
+       glGetConvolutionParameterfv=reinterpret_cast<PFNGLGETCONVOLUTIONPARAMETERFVPROC>(get_proc_address("glGetConvolutionParameterfv"));
+       glGetConvolutionParameteriv=reinterpret_cast<PFNGLGETCONVOLUTIONPARAMETERIVPROC>(get_proc_address("glGetConvolutionParameteriv"));
+       glGetSeparableFilter=reinterpret_cast<PFNGLGETSEPARABLEFILTERPROC>(get_proc_address("glGetSeparableFilter"));
+       glSeparableFilter2D=reinterpret_cast<PFNGLSEPARABLEFILTER2DPROC>(get_proc_address("glSeparableFilter2D"));
+       glGetHistogram=reinterpret_cast<PFNGLGETHISTOGRAMPROC>(get_proc_address("glGetHistogram"));
+       glGetHistogramParameterfv=reinterpret_cast<PFNGLGETHISTOGRAMPARAMETERFVPROC>(get_proc_address("glGetHistogramParameterfv"));
+       glGetHistogramParameteriv=reinterpret_cast<PFNGLGETHISTOGRAMPARAMETERIVPROC>(get_proc_address("glGetHistogramParameteriv"));
+       glGetMinmax=reinterpret_cast<PFNGLGETMINMAXPROC>(get_proc_address("glGetMinmax"));
+       glGetMinmaxParameterfv=reinterpret_cast<PFNGLGETMINMAXPARAMETERFVPROC>(get_proc_address("glGetMinmaxParameterfv"));
+       glGetMinmaxParameteriv=reinterpret_cast<PFNGLGETMINMAXPARAMETERIVPROC>(get_proc_address("glGetMinmaxParameteriv"));
+       glHistogram=reinterpret_cast<PFNGLHISTOGRAMPROC>(get_proc_address("glHistogram"));
+       glMinmax=reinterpret_cast<PFNGLMINMAXPROC>(get_proc_address("glMinmax"));
+       glResetHistogram=reinterpret_cast<PFNGLRESETHISTOGRAMPROC>(get_proc_address("glResetHistogram"));
+       glResetMinmax=reinterpret_cast<PFNGLRESETMINMAXPROC>(get_proc_address("glResetMinmax"));
+       glTexImage3D=reinterpret_cast<PFNGLTEXIMAGE3DPROC>(get_proc_address("glTexImage3D"));
+       glTexSubImage3D=reinterpret_cast<PFNGLTEXSUBIMAGE3DPROC>(get_proc_address("glTexSubImage3D"));
+       glCopyTexSubImage3D=reinterpret_cast<PFNGLCOPYTEXSUBIMAGE3DPROC>(get_proc_address("glCopyTexSubImage3D"));
+}
+
+} // namespace GL
+} // namespace Msp
diff --git a/source/version_1_2.h b/source/version_1_2.h
new file mode 100644 (file)
index 0000000..d10ba53
--- /dev/null
@@ -0,0 +1,54 @@
+#ifndef MSP_GL_VERSION_1_2_
+#define MSP_GL_VERSION_1_2_
+
+#include "gl.h"
+#include <GL/glext.h>
+
+namespace Msp {
+namespace GL {
+
+extern PFNGLBLENDCOLORPROC glBlendColor;
+extern PFNGLBLENDEQUATIONPROC glBlendEquation;
+extern PFNGLDRAWRANGEELEMENTSPROC glDrawRangeElements;
+extern PFNGLCOLORTABLEPROC glColorTable;
+extern PFNGLCOLORTABLEPARAMETERFVPROC glColorTableParameterfv;
+extern PFNGLCOLORTABLEPARAMETERIVPROC glColorTableParameteriv;
+extern PFNGLCOPYCOLORTABLEPROC glCopyColorTable;
+extern PFNGLGETCOLORTABLEPROC glGetColorTable;
+extern PFNGLGETCOLORTABLEPARAMETERFVPROC glGetColorTableParameterfv;
+extern PFNGLGETCOLORTABLEPARAMETERIVPROC glGetColorTableParameteriv;
+extern PFNGLCOLORSUBTABLEPROC glColorSubTable;
+extern PFNGLCOPYCOLORSUBTABLEPROC glCopyColorSubTable;
+extern PFNGLCONVOLUTIONFILTER1DPROC glConvolutionFilter1D;
+extern PFNGLCONVOLUTIONFILTER2DPROC glConvolutionFilter2D;
+extern PFNGLCONVOLUTIONPARAMETERFPROC glConvolutionParameterf;
+extern PFNGLCONVOLUTIONPARAMETERFVPROC glConvolutionParameterfv;
+extern PFNGLCONVOLUTIONPARAMETERIPROC glConvolutionParameteri;
+extern PFNGLCONVOLUTIONPARAMETERIVPROC glConvolutionParameteriv;
+extern PFNGLCOPYCONVOLUTIONFILTER1DPROC glCopyConvolutionFilter1D;
+extern PFNGLCOPYCONVOLUTIONFILTER2DPROC glCopyConvolutionFilter2D;
+extern PFNGLGETCONVOLUTIONFILTERPROC glGetConvolutionFilter;
+extern PFNGLGETCONVOLUTIONPARAMETERFVPROC glGetConvolutionParameterfv;
+extern PFNGLGETCONVOLUTIONPARAMETERIVPROC glGetConvolutionParameteriv;
+extern PFNGLGETSEPARABLEFILTERPROC glGetSeparableFilter;
+extern PFNGLSEPARABLEFILTER2DPROC glSeparableFilter2D;
+extern PFNGLGETHISTOGRAMPROC glGetHistogram;
+extern PFNGLGETHISTOGRAMPARAMETERFVPROC glGetHistogramParameterfv;
+extern PFNGLGETHISTOGRAMPARAMETERIVPROC glGetHistogramParameteriv;
+extern PFNGLGETMINMAXPROC glGetMinmax;
+extern PFNGLGETMINMAXPARAMETERFVPROC glGetMinmaxParameterfv;
+extern PFNGLGETMINMAXPARAMETERIVPROC glGetMinmaxParameteriv;
+extern PFNGLHISTOGRAMPROC glHistogram;
+extern PFNGLMINMAXPROC glMinmax;
+extern PFNGLRESETHISTOGRAMPROC glResetHistogram;
+extern PFNGLRESETMINMAXPROC glResetMinmax;
+extern PFNGLTEXIMAGE3DPROC glTexImage3D;
+extern PFNGLTEXSUBIMAGE3DPROC glTexSubImage3D;
+extern PFNGLCOPYTEXSUBIMAGE3DPROC glCopyTexSubImage3D;
+
+void init_version_1_2();
+
+} // namespace GL
+} // namespace Msp
+
+#endif
diff --git a/source/version_1_3.cpp b/source/version_1_3.cpp
new file mode 100644 (file)
index 0000000..088d5ba
--- /dev/null
@@ -0,0 +1,105 @@
+#include "extension.h"
+#include "version_1_3.h"
+
+namespace Msp {
+namespace GL {
+
+PFNGLACTIVETEXTUREPROC glActiveTexture=0;
+PFNGLCLIENTACTIVETEXTUREPROC glClientActiveTexture=0;
+PFNGLMULTITEXCOORD1DPROC glMultiTexCoord1d=0;
+PFNGLMULTITEXCOORD1DVPROC glMultiTexCoord1dv=0;
+PFNGLMULTITEXCOORD1FPROC glMultiTexCoord1f=0;
+PFNGLMULTITEXCOORD1FVPROC glMultiTexCoord1fv=0;
+PFNGLMULTITEXCOORD1IPROC glMultiTexCoord1i=0;
+PFNGLMULTITEXCOORD1IVPROC glMultiTexCoord1iv=0;
+PFNGLMULTITEXCOORD1SPROC glMultiTexCoord1s=0;
+PFNGLMULTITEXCOORD1SVPROC glMultiTexCoord1sv=0;
+PFNGLMULTITEXCOORD2DPROC glMultiTexCoord2d=0;
+PFNGLMULTITEXCOORD2DVPROC glMultiTexCoord2dv=0;
+PFNGLMULTITEXCOORD2FPROC glMultiTexCoord2f=0;
+PFNGLMULTITEXCOORD2FVPROC glMultiTexCoord2fv=0;
+PFNGLMULTITEXCOORD2IPROC glMultiTexCoord2i=0;
+PFNGLMULTITEXCOORD2IVPROC glMultiTexCoord2iv=0;
+PFNGLMULTITEXCOORD2SPROC glMultiTexCoord2s=0;
+PFNGLMULTITEXCOORD2SVPROC glMultiTexCoord2sv=0;
+PFNGLMULTITEXCOORD3DPROC glMultiTexCoord3d=0;
+PFNGLMULTITEXCOORD3DVPROC glMultiTexCoord3dv=0;
+PFNGLMULTITEXCOORD3FPROC glMultiTexCoord3f=0;
+PFNGLMULTITEXCOORD3FVPROC glMultiTexCoord3fv=0;
+PFNGLMULTITEXCOORD3IPROC glMultiTexCoord3i=0;
+PFNGLMULTITEXCOORD3IVPROC glMultiTexCoord3iv=0;
+PFNGLMULTITEXCOORD3SPROC glMultiTexCoord3s=0;
+PFNGLMULTITEXCOORD3SVPROC glMultiTexCoord3sv=0;
+PFNGLMULTITEXCOORD4DPROC glMultiTexCoord4d=0;
+PFNGLMULTITEXCOORD4DVPROC glMultiTexCoord4dv=0;
+PFNGLMULTITEXCOORD4FPROC glMultiTexCoord4f=0;
+PFNGLMULTITEXCOORD4FVPROC glMultiTexCoord4fv=0;
+PFNGLMULTITEXCOORD4IPROC glMultiTexCoord4i=0;
+PFNGLMULTITEXCOORD4IVPROC glMultiTexCoord4iv=0;
+PFNGLMULTITEXCOORD4SPROC glMultiTexCoord4s=0;
+PFNGLMULTITEXCOORD4SVPROC glMultiTexCoord4sv=0;
+PFNGLLOADTRANSPOSEMATRIXFPROC glLoadTransposeMatrixf=0;
+PFNGLLOADTRANSPOSEMATRIXDPROC glLoadTransposeMatrixd=0;
+PFNGLMULTTRANSPOSEMATRIXFPROC glMultTransposeMatrixf=0;
+PFNGLMULTTRANSPOSEMATRIXDPROC glMultTransposeMatrixd=0;
+PFNGLSAMPLECOVERAGEPROC glSampleCoverage=0;
+PFNGLCOMPRESSEDTEXIMAGE3DPROC glCompressedTexImage3D=0;
+PFNGLCOMPRESSEDTEXIMAGE2DPROC glCompressedTexImage2D=0;
+PFNGLCOMPRESSEDTEXIMAGE1DPROC glCompressedTexImage1D=0;
+PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glCompressedTexSubImage3D=0;
+PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glCompressedTexSubImage2D=0;
+PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glCompressedTexSubImage1D=0;
+PFNGLGETCOMPRESSEDTEXIMAGEPROC glGetCompressedTexImage=0;
+
+void init_version_1_3()
+{
+       glActiveTexture=reinterpret_cast<PFNGLACTIVETEXTUREPROC>(get_proc_address("glActiveTexture"));
+       glClientActiveTexture=reinterpret_cast<PFNGLCLIENTACTIVETEXTUREPROC>(get_proc_address("glClientActiveTexture"));
+       glMultiTexCoord1d=reinterpret_cast<PFNGLMULTITEXCOORD1DPROC>(get_proc_address("glMultiTexCoord1d"));
+       glMultiTexCoord1dv=reinterpret_cast<PFNGLMULTITEXCOORD1DVPROC>(get_proc_address("glMultiTexCoord1dv"));
+       glMultiTexCoord1f=reinterpret_cast<PFNGLMULTITEXCOORD1FPROC>(get_proc_address("glMultiTexCoord1f"));
+       glMultiTexCoord1fv=reinterpret_cast<PFNGLMULTITEXCOORD1FVPROC>(get_proc_address("glMultiTexCoord1fv"));
+       glMultiTexCoord1i=reinterpret_cast<PFNGLMULTITEXCOORD1IPROC>(get_proc_address("glMultiTexCoord1i"));
+       glMultiTexCoord1iv=reinterpret_cast<PFNGLMULTITEXCOORD1IVPROC>(get_proc_address("glMultiTexCoord1iv"));
+       glMultiTexCoord1s=reinterpret_cast<PFNGLMULTITEXCOORD1SPROC>(get_proc_address("glMultiTexCoord1s"));
+       glMultiTexCoord1sv=reinterpret_cast<PFNGLMULTITEXCOORD1SVPROC>(get_proc_address("glMultiTexCoord1sv"));
+       glMultiTexCoord2d=reinterpret_cast<PFNGLMULTITEXCOORD2DPROC>(get_proc_address("glMultiTexCoord2d"));
+       glMultiTexCoord2dv=reinterpret_cast<PFNGLMULTITEXCOORD2DVPROC>(get_proc_address("glMultiTexCoord2dv"));
+       glMultiTexCoord2f=reinterpret_cast<PFNGLMULTITEXCOORD2FPROC>(get_proc_address("glMultiTexCoord2f"));
+       glMultiTexCoord2fv=reinterpret_cast<PFNGLMULTITEXCOORD2FVPROC>(get_proc_address("glMultiTexCoord2fv"));
+       glMultiTexCoord2i=reinterpret_cast<PFNGLMULTITEXCOORD2IPROC>(get_proc_address("glMultiTexCoord2i"));
+       glMultiTexCoord2iv=reinterpret_cast<PFNGLMULTITEXCOORD2IVPROC>(get_proc_address("glMultiTexCoord2iv"));
+       glMultiTexCoord2s=reinterpret_cast<PFNGLMULTITEXCOORD2SPROC>(get_proc_address("glMultiTexCoord2s"));
+       glMultiTexCoord2sv=reinterpret_cast<PFNGLMULTITEXCOORD2SVPROC>(get_proc_address("glMultiTexCoord2sv"));
+       glMultiTexCoord3d=reinterpret_cast<PFNGLMULTITEXCOORD3DPROC>(get_proc_address("glMultiTexCoord3d"));
+       glMultiTexCoord3dv=reinterpret_cast<PFNGLMULTITEXCOORD3DVPROC>(get_proc_address("glMultiTexCoord3dv"));
+       glMultiTexCoord3f=reinterpret_cast<PFNGLMULTITEXCOORD3FPROC>(get_proc_address("glMultiTexCoord3f"));
+       glMultiTexCoord3fv=reinterpret_cast<PFNGLMULTITEXCOORD3FVPROC>(get_proc_address("glMultiTexCoord3fv"));
+       glMultiTexCoord3i=reinterpret_cast<PFNGLMULTITEXCOORD3IPROC>(get_proc_address("glMultiTexCoord3i"));
+       glMultiTexCoord3iv=reinterpret_cast<PFNGLMULTITEXCOORD3IVPROC>(get_proc_address("glMultiTexCoord3iv"));
+       glMultiTexCoord3s=reinterpret_cast<PFNGLMULTITEXCOORD3SPROC>(get_proc_address("glMultiTexCoord3s"));
+       glMultiTexCoord3sv=reinterpret_cast<PFNGLMULTITEXCOORD3SVPROC>(get_proc_address("glMultiTexCoord3sv"));
+       glMultiTexCoord4d=reinterpret_cast<PFNGLMULTITEXCOORD4DPROC>(get_proc_address("glMultiTexCoord4d"));
+       glMultiTexCoord4dv=reinterpret_cast<PFNGLMULTITEXCOORD4DVPROC>(get_proc_address("glMultiTexCoord4dv"));
+       glMultiTexCoord4f=reinterpret_cast<PFNGLMULTITEXCOORD4FPROC>(get_proc_address("glMultiTexCoord4f"));
+       glMultiTexCoord4fv=reinterpret_cast<PFNGLMULTITEXCOORD4FVPROC>(get_proc_address("glMultiTexCoord4fv"));
+       glMultiTexCoord4i=reinterpret_cast<PFNGLMULTITEXCOORD4IPROC>(get_proc_address("glMultiTexCoord4i"));
+       glMultiTexCoord4iv=reinterpret_cast<PFNGLMULTITEXCOORD4IVPROC>(get_proc_address("glMultiTexCoord4iv"));
+       glMultiTexCoord4s=reinterpret_cast<PFNGLMULTITEXCOORD4SPROC>(get_proc_address("glMultiTexCoord4s"));
+       glMultiTexCoord4sv=reinterpret_cast<PFNGLMULTITEXCOORD4SVPROC>(get_proc_address("glMultiTexCoord4sv"));
+       glLoadTransposeMatrixf=reinterpret_cast<PFNGLLOADTRANSPOSEMATRIXFPROC>(get_proc_address("glLoadTransposeMatrixf"));
+       glLoadTransposeMatrixd=reinterpret_cast<PFNGLLOADTRANSPOSEMATRIXDPROC>(get_proc_address("glLoadTransposeMatrixd"));
+       glMultTransposeMatrixf=reinterpret_cast<PFNGLMULTTRANSPOSEMATRIXFPROC>(get_proc_address("glMultTransposeMatrixf"));
+       glMultTransposeMatrixd=reinterpret_cast<PFNGLMULTTRANSPOSEMATRIXDPROC>(get_proc_address("glMultTransposeMatrixd"));
+       glSampleCoverage=reinterpret_cast<PFNGLSAMPLECOVERAGEPROC>(get_proc_address("glSampleCoverage"));
+       glCompressedTexImage3D=reinterpret_cast<PFNGLCOMPRESSEDTEXIMAGE3DPROC>(get_proc_address("glCompressedTexImage3D"));
+       glCompressedTexImage2D=reinterpret_cast<PFNGLCOMPRESSEDTEXIMAGE2DPROC>(get_proc_address("glCompressedTexImage2D"));
+       glCompressedTexImage1D=reinterpret_cast<PFNGLCOMPRESSEDTEXIMAGE1DPROC>(get_proc_address("glCompressedTexImage1D"));
+       glCompressedTexSubImage3D=reinterpret_cast<PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC>(get_proc_address("glCompressedTexSubImage3D"));
+       glCompressedTexSubImage2D=reinterpret_cast<PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC>(get_proc_address("glCompressedTexSubImage2D"));
+       glCompressedTexSubImage1D=reinterpret_cast<PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC>(get_proc_address("glCompressedTexSubImage1D"));
+       glGetCompressedTexImage=reinterpret_cast<PFNGLGETCOMPRESSEDTEXIMAGEPROC>(get_proc_address("glGetCompressedTexImage"));
+}
+
+} // namespace GL
+} // namespace Msp
diff --git a/source/version_1_3.h b/source/version_1_3.h
new file mode 100644 (file)
index 0000000..bd0b4ea
--- /dev/null
@@ -0,0 +1,62 @@
+#ifndef MSP_GL_VERSION_1_3_
+#define MSP_GL_VERSION_1_3_
+
+#include "gl.h"
+#include <GL/glext.h>
+
+namespace Msp {
+namespace GL {
+
+extern PFNGLACTIVETEXTUREPROC glActiveTexture;
+extern PFNGLCLIENTACTIVETEXTUREPROC glClientActiveTexture;
+extern PFNGLMULTITEXCOORD1DPROC glMultiTexCoord1d;
+extern PFNGLMULTITEXCOORD1DVPROC glMultiTexCoord1dv;
+extern PFNGLMULTITEXCOORD1FPROC glMultiTexCoord1f;
+extern PFNGLMULTITEXCOORD1FVPROC glMultiTexCoord1fv;
+extern PFNGLMULTITEXCOORD1IPROC glMultiTexCoord1i;
+extern PFNGLMULTITEXCOORD1IVPROC glMultiTexCoord1iv;
+extern PFNGLMULTITEXCOORD1SPROC glMultiTexCoord1s;
+extern PFNGLMULTITEXCOORD1SVPROC glMultiTexCoord1sv;
+extern PFNGLMULTITEXCOORD2DPROC glMultiTexCoord2d;
+extern PFNGLMULTITEXCOORD2DVPROC glMultiTexCoord2dv;
+extern PFNGLMULTITEXCOORD2FPROC glMultiTexCoord2f;
+extern PFNGLMULTITEXCOORD2FVPROC glMultiTexCoord2fv;
+extern PFNGLMULTITEXCOORD2IPROC glMultiTexCoord2i;
+extern PFNGLMULTITEXCOORD2IVPROC glMultiTexCoord2iv;
+extern PFNGLMULTITEXCOORD2SPROC glMultiTexCoord2s;
+extern PFNGLMULTITEXCOORD2SVPROC glMultiTexCoord2sv;
+extern PFNGLMULTITEXCOORD3DPROC glMultiTexCoord3d;
+extern PFNGLMULTITEXCOORD3DVPROC glMultiTexCoord3dv;
+extern PFNGLMULTITEXCOORD3FPROC glMultiTexCoord3f;
+extern PFNGLMULTITEXCOORD3FVPROC glMultiTexCoord3fv;
+extern PFNGLMULTITEXCOORD3IPROC glMultiTexCoord3i;
+extern PFNGLMULTITEXCOORD3IVPROC glMultiTexCoord3iv;
+extern PFNGLMULTITEXCOORD3SPROC glMultiTexCoord3s;
+extern PFNGLMULTITEXCOORD3SVPROC glMultiTexCoord3sv;
+extern PFNGLMULTITEXCOORD4DPROC glMultiTexCoord4d;
+extern PFNGLMULTITEXCOORD4DVPROC glMultiTexCoord4dv;
+extern PFNGLMULTITEXCOORD4FPROC glMultiTexCoord4f;
+extern PFNGLMULTITEXCOORD4FVPROC glMultiTexCoord4fv;
+extern PFNGLMULTITEXCOORD4IPROC glMultiTexCoord4i;
+extern PFNGLMULTITEXCOORD4IVPROC glMultiTexCoord4iv;
+extern PFNGLMULTITEXCOORD4SPROC glMultiTexCoord4s;
+extern PFNGLMULTITEXCOORD4SVPROC glMultiTexCoord4sv;
+extern PFNGLLOADTRANSPOSEMATRIXFPROC glLoadTransposeMatrixf;
+extern PFNGLLOADTRANSPOSEMATRIXDPROC glLoadTransposeMatrixd;
+extern PFNGLMULTTRANSPOSEMATRIXFPROC glMultTransposeMatrixf;
+extern PFNGLMULTTRANSPOSEMATRIXDPROC glMultTransposeMatrixd;
+extern PFNGLSAMPLECOVERAGEPROC glSampleCoverage;
+extern PFNGLCOMPRESSEDTEXIMAGE3DPROC glCompressedTexImage3D;
+extern PFNGLCOMPRESSEDTEXIMAGE2DPROC glCompressedTexImage2D;
+extern PFNGLCOMPRESSEDTEXIMAGE1DPROC glCompressedTexImage1D;
+extern PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glCompressedTexSubImage3D;
+extern PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glCompressedTexSubImage2D;
+extern PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glCompressedTexSubImage1D;
+extern PFNGLGETCOMPRESSEDTEXIMAGEPROC glGetCompressedTexImage;
+
+void init_version_1_3();
+
+} // namespace GL
+} // namespace Msp
+
+#endif
index a2d3936c35f9532b3cc73087b24f9a5e19fe8a55..6da0f9c0d44812ad6294d769200af558d5532bf0 100644 (file)
@@ -5,7 +5,7 @@ Copyright © 2007  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#include <GL/gl.h>
+#include "gl.h"
 #include "vertexarray.h"
 #include "vertexbuffer.h"
 
index d579a373c249da2b39460938fbc8a8ad5b02360a..e3680811dd9a8ccb59e1fb0e0b1f5b84b53ac6e3 100644 (file)
@@ -5,10 +5,8 @@ Copyright © 2007  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#define GL_GLEXT_PROTOTYPES
-#include <GL/gl.h>
-//XXX gl.h seems to include glext.h, but can I rely on this?
-//#include <GL/glext.h>
+#include "arb_vertex_buffer_object.h"
+#include "extension.h"
 #include "vertexbuffer.h"
 
 namespace Msp {
@@ -16,12 +14,14 @@ namespace GL {
 
 VertexBuffer::VertexBuffer()
 {
-       glGenBuffers(1, &id);
+       require_extension("GL_ARB_vertex_buffer_object");
+
+       glGenBuffersARB(1, &id);
 }
 
 void VertexBuffer::bind() const
 {
-       glBindBuffer(GL_ARRAY_BUFFER, id);
+       glBindBufferARB(GL_ARRAY_BUFFER, id);
        bound=this;
 }
 
@@ -29,19 +29,19 @@ void VertexBuffer::data(sizei size, void *d)
 {
        if(bound!=this) bind();
 
-       glBufferData(GL_ARRAY_BUFFER, size, d, GL_STATIC_DRAW);
+       glBufferDataARB(GL_ARRAY_BUFFER, size, d, GL_STATIC_DRAW);
 }
 
 VertexBuffer::~VertexBuffer()
 {
-       glDeleteBuffers(1, &id);
+       glDeleteBuffersARB(1, &id);
 }
 
 void VertexBuffer::unbind()
 {
        if(bound)
        {
-               glBindBuffer(GL_ARRAY_BUFFER, 0);
+               glBindBufferARB(GL_ARRAY_BUFFER, 0);
                bound=0;
        }
 }