diff options
Diffstat (limited to 'src/gl/osiriongl.cc')
-rw-r--r-- | src/gl/osiriongl.cc | 214 |
1 files changed, 214 insertions, 0 deletions
diff --git a/src/gl/osiriongl.cc b/src/gl/osiriongl.cc new file mode 100644 index 0000000..0917eec --- /dev/null +++ b/src/gl/osiriongl.cc @@ -0,0 +1,214 @@ +/* gl.cc + * This file is part of the Osirion project + */ + +// SDL headers +#include <SDL/SDL.h> + +#include "osiriongl.h" + +namespace gl +{ + +typedef void (APIENTRY *glBegin_func)(GLenum); +typedef void (APIENTRY *glEnd_func)(); +typedef void (APIENTRY *glViewport_func)(GLint, GLint, GLsizei, GLsizei); +typedef void (APIENTRY *glDepthMask_func)(GLenum); +typedef void (APIENTRY *glFrontFace_func)(GLenum); +typedef void (APIENTRY *glCullFace_func)(GLenum); +typedef void (APIENTRY *glShadeModel_func)(GLenum); +typedef void (APIENTRY *glEnable_func)(GLenum); +typedef void (APIENTRY *glClear_func)(GLbitfield); +typedef void (APIENTRY *glClearColor_func)(GLclampf, GLclampf, GLclampf,GLclampf); +typedef void (APIENTRY *glRotatef_func)(GLfloat, GLfloat, GLfloat, GLfloat); +typedef void (APIENTRY *glTranslatef_func)(GLfloat, GLfloat, GLfloat); +typedef void (APIENTRY *glScalef_func)(GLfloat, GLfloat, GLfloat); +typedef void (APIENTRY *glVertex3f_func)(GLfloat, GLfloat, GLfloat); +typedef void (APIENTRY *glPushMatrix_func)(); +typedef void (APIENTRY *glPopMatrix_func)(); +typedef void (APIENTRY *glColor4f_func)(GLfloat, GLfloat, GLfloat, GLfloat); +typedef void (APIENTRY *glMatrixMode_func)(GLenum); +typedef void (APIENTRY *glLoadIdentity_func)(); +typedef void (APIENTRY *glFrustum_func)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble); + +glBegin_func osglBegin = 0; +glEnd_func osglEnd = 0; +glViewport_func osglViewport = 0; +glDepthMask_func osglDepthMask = 0; +glFrontFace_func osglFrontFace = 0; +glCullFace_func osglCullFace = 0; +glShadeModel_func osglShadeModel = 0; +glEnable_func osglEnable = 0; +glClear_func osglClear = 0; +glClearColor_func osglClearColor = 0; +glRotatef_func osglRotatef = 0; +glTranslatef_func osglTranslatef = 0; +glScalef_func osglScalef = 0; +glVertex3f_func osglVertex3f = 0; +glPushMatrix_func osglPushMatrix = 0; +glPopMatrix_func osglPopMatrix = 0; +glColor4f_func osglColor4f = 0; +glMatrixMode_func osglMatrixMode = 0; +glLoadIdentity_func osglLoadIdentity = 0; +glFrustum_func osglFrustum = 0; + +// ------------- INITIALIZE FUNCTION POINTERS --------------// +void init() +{ + osglBegin = (glBegin_func) SDL_GL_GetProcAddress("glBegin"); + osglEnd = (glEnd_func) SDL_GL_GetProcAddress("glEnd"); + osglViewport = (glViewport_func) SDL_GL_GetProcAddress("glViewport"); + osglDepthMask = (glDepthMask_func) SDL_GL_GetProcAddress("glDepthMask"); + osglFrontFace = (glFrontFace_func) SDL_GL_GetProcAddress("glFrontFace"); + osglCullFace = (glCullFace_func) SDL_GL_GetProcAddress("glCullFace"); + osglShadeModel = (glShadeModel_func) SDL_GL_GetProcAddress("glShadeModel"); + osglEnable = (glEnable_func) SDL_GL_GetProcAddress("glEnable"); + osglClear = (glClear_func) SDL_GL_GetProcAddress("glClear"); + osglClearColor = (glClearColor_func) SDL_GL_GetProcAddress("glClearColor"); + osglRotatef = (glRotatef_func) SDL_GL_GetProcAddress("glRotatef"); + osglTranslatef = (glTranslatef_func) SDL_GL_GetProcAddress("glTranslatef"); + osglScalef = (glScalef_func) SDL_GL_GetProcAddress("glScalef"); + osglVertex3f = (glVertex3f_func) SDL_GL_GetProcAddress("glVertex3f"); + osglPushMatrix = (glPushMatrix_func) SDL_GL_GetProcAddress("glPushMatrix"); + osglPopMatrix = (glPopMatrix_func) SDL_GL_GetProcAddress("glPopMatrix"); + osglColor4f = (glColor4f_func) SDL_GL_GetProcAddress("glColor4f"); + osglMatrixMode = (glMatrixMode_func) SDL_GL_GetProcAddress("glMatrixMode"); + osglLoadIdentity = (glLoadIdentity_func) SDL_GL_GetProcAddress("glLoadIdentity"); + osglFrustum = (glFrustum_func) SDL_GL_GetProcAddress("glFrustum"); +} + + +void shutdown() +{ + osglBegin = 0; + osglEnd = 0; + osglViewport = 0; + osglDepthMask = 0; + osglFrontFace = 0; + osglCullFace = 0; + osglShadeModel = 0; + osglEnable = 0; + osglClear = 0; + osglClearColor = 0; + osglRotatef = 0; + osglTranslatef = 0; + osglScalef = 0; + osglVertex3f = 0; + osglPushMatrix = 0; + osglPopMatrix = 0; + osglColor4f = 0; + osglMatrixMode = 0; + osglLoadIdentity = 0; +} + +void begin(Primitive primitive) { + osglBegin(primitive); +} + +void end() { + osglEnd(); +} + +void viewport(GLint x, GLint y, GLsizei width, GLsizei height) +{ + osglViewport(x, y, width, height); +} + +void depthmask(GLenum mode) +{ + osglDepthMask(mode); +} + + +void frontface(GLenum mode) +{ + osglFrontFace(mode); +} + +void cullface(GLenum mode) +{ + osglCullFace(mode); +} + +void shademodel(GLenum mode) +{ + osglShadeModel(mode); +} + +void enable(GLenum cap) +{ + osglEnable(cap); +} + +void clear (GLbitfield mask) { + osglClear(mask); +} + +void clearcolor(Color const & color) { + osglClearColor(color.red(), color.green(), color.blue(), color.alpha()); +} + +void clearcolor(const float r, const float g, const float b, const float a) { + osglClearColor(r,g,b, a); +} + +void rotate(const float angle, const Vector3f& vector) { + osglRotatef(angle, vector[0], vector[1], vector[2]); +} + +void rotate(const float angle, const float x, const float y, const float z) { + osglRotatef(angle, x, y, z); +} + +void translate(const Vector3f& vector) { + osglTranslatef(vector[0], vector[1], vector[2]); +} + +void translate(const float x, const float y, const float z) { + osglTranslatef(x, y, z); +} +void scale(const Vector3f& vector) { + osglScalef(vector[0], vector[1], vector[2]); +} + +void scale(const float x, const float y, const float z) { + osglScalef(x, y, z); +} + +void vertex(const Vector3f& vector) { + osglVertex3f(vector[0], vector[1], vector[2]); +} + +void vertex(const float x, const float y, const float z) { + osglVertex3f(x, y, z); +} + +void push() { + osglPushMatrix(); +} + +void pop() { + osglPopMatrix(); +} + +void color(const float r, const float g, const float b, const float a) { + osglColor4f(r,g,b,a); +} +void color(Color const & color) { + osglColor4f(color.red(), color.green(), color.blue(), color.alpha()); +} + +void matrixmode(GLenum mode) { + osglMatrixMode(mode); +} + +void loadidentity() { + osglLoadIdentity(); +} + +void frustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble znear, GLdouble zfar) +{ + osglFrustum(left, right, bottom, top, znear, zfar); +} + +} // namespace gl |