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
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 {
#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 {
--- /dev/null
+#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
--- /dev/null
+#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
#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 {
Distributed under the LGPL
*/
-#define GL_GLEXT_PROTOTYPES
#include "batch.h"
+#include "extension.h"
+#include "version_1_2.h"
using namespace std;
type(t),
min_index(0),
max_index(0)
-{ }
+{
+ require_version(1, 2);
+}
Batch &Batch::append(uint i)
{
#define MSP_GL_BATCH_H_
#include <vector>
-#include <GL/gl.h>
#include <msp/datafile/loader.h>
#include "primitivetype.h"
#include "types.h"
#ifndef MSP_GL_COLOR_H_
#define MSP_GL_COLOR_H_
-#include <GL/gl.h>
-
namespace Msp {
namespace GL {
#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 {
*/
#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;
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;
}
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
}
namespace Msp {
namespace GL {
+struct Version
+{
+ unsigned short major;
+ unsigned short minor;
+};
+
typedef void ExtFunc();
/**
*/
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.
*/
Distributed under the LGPL
*/
-#include <GL/gl.h>
+#include "gl.h"
#include "font.h"
#include "texture2d.h"
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);
#ifndef MSP_GL_FRAMEBUFFER_H_
#define MSP_GL_FRAMEBUFFER_H_
-#include <GL/gl.h>
+#include "gl.h"
#include "types.h"
namespace Msp {
--- /dev/null
+/* $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
Distributed under the LGPL
*/
+#include "gl.h"
#include "material.h"
namespace Msp {
#ifndef MSP_GL_MATRIX_H_
#define MSP_GL_MATRIX_H_
-#include <GL/gl.h>
+#include "gl.h"
namespace Msp {
namespace GL {
#ifndef MSP_GL_MISC_H_
#define MSP_GL_MISC_H_
-#include <GL/gl.h>
+#include "gl.h"
namespace Msp {
namespace GL {
#ifndef MSP_GL_PIXELFORMAT_H_
#define MSP_GL_PIXELFORMAT_H_
-#include <GL/gl.h>
+#include "gl.h"
namespace Msp {
namespace GL {
#ifndef MSP_GL_PREDICATE_H_
#define MSP_GL_PREDICATE_H_
-#include <GL/gl.h>
+#include "gl.h"
namespace Msp {
namespace GL {
#define MSP_GL_PRIMITIVETYPE_H_
#include <istream>
-#include <GL/gl.h>
+#include "gl.h"
namespace Msp {
namespace GL {
#include <list>
#include <string>
-#include <GL/gl.h>
#include <msp/datafile/loader.h>
+#include "gl.h"
#include "types.h"
namespace Msp {
*/
#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)
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
#ifndef MSP_GL_RENDERMODE_H_
#define MSP_GL_RENDERMODE_H_
-#include <GL/gl.h>
+#include "gl.h"
namespace Msp {
namespace GL {
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;
}
#define MSP_GL_SELECT_H_
#include <vector>
+#include "types.h"
namespace Msp {
namespace GL {
#define MSP_GL_SHADER_H_
#include <string>
-#include <GL/gl.h>
+#include "gl.h"
#include "types.h"
namespace Msp {
#ifndef MSP_GL_STENCIL_H_
#define MSP_GL_STENCIL_H_
-#include <GL/gl.h>
+#include "gl.h"
#include "predicate.h"
#include "types.h"
#ifndef MSP_GL_TESTS_H_
#define MSP_GL_TESTS_H_
-#include <GL/gl.h>
+#include "gl.h"
#include "predicate.h"
#include "types.h"
#ifndef MSP_GL_TEXTURE_H_
#define MSP_GL_TEXTURE_H_
-#include <GL/gl.h>
+#include "gl.h"
#include "types.h"
namespace Msp {
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;
height(0),
depth(0)
{
+ require_version(1, 3);
+
target=GL_TEXTURE_3D;
bind();
}
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;
TexUnit::TexUnit():
texture(0)
-{ }
+{
+ require_version(1, 3);
+}
bool TexUnit::set_texture(const Texture *tex)
{
if(units.size()<=n)
units.resize(n+1);
- glActiveTextureARB(GL_TEXTURE0+n);
+ glActiveTexture(GL_TEXTURE0+n);
cur_unit=&units[n];
return units[n];
Distributed under the LGPL
*/
-#include <GL/gl.h>
+#include "gl.h"
#include "transform.h"
namespace Msp {
--- /dev/null
+#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
--- /dev/null
+#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
--- /dev/null
+#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
--- /dev/null
+#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
Distributed under the LGPL
*/
-#include <GL/gl.h>
+#include "gl.h"
#include "vertexarray.h"
#include "vertexbuffer.h"
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 {
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;
}
{
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;
}
}