00001 #ifndef GLFUNCS_H
00002 #define GLFUNCS_H
00003
00004 #include <stdio.h>
00005 #include <stdlib.h>
00006 #include <string>
00007
00008 #include "SDL.h"
00009 #include "SDL_image.h"
00010 #include "SDL_opengl.h"
00011 #include "SDL_syswm.h"
00012
00013 class glfuncs
00014 {
00015 public:
00016 static glfuncs* instance();
00017
00018 void(APIENTRY*glBegin)(GLenum);
00019 void(APIENTRY*glEnd)();
00020 void(APIENTRY*glVertex3f)(GLfloat, GLfloat, GLfloat);
00021 void(APIENTRY*glClearColor)(GLfloat, GLfloat, GLfloat, GLfloat);
00022 void(APIENTRY*glClear)(GLbitfield);
00023 void(APIENTRY*glDisable)(GLenum);
00024 void(APIENTRY*glEnable)(GLenum);
00025 void(APIENTRY*glColor4ub)(GLubyte,GLubyte,GLubyte,GLubyte);
00026 void(APIENTRY*glPointSize)(GLfloat);
00027 void(APIENTRY*glHint)(GLenum,GLenum);
00028 void(APIENTRY*glBlendFunc)(GLenum,GLenum);
00029 void(APIENTRY*glMatrixMode)(GLenum);
00030 void(APIENTRY*glLoadIdentity)();
00031 void(APIENTRY*glOrtho)(GLdouble,GLdouble,GLdouble,GLdouble,GLdouble,GLdouble);
00032 void(APIENTRY*glRotatef)(GLfloat,GLfloat,GLfloat,GLfloat);
00033 void(APIENTRY*glViewport)(GLint,GLint,GLsizei,GLsizei);
00034 void(APIENTRY*glFogf)(GLenum,GLfloat);
00035 void(APIENTRY*glGenTextures)(GLsizei,GLuint*);
00036 void(APIENTRY*glBindTexture)(GLenum,GLuint);
00037 void(APIENTRY*glTexParameteri)(GLenum,GLenum,GLint);
00038 void(APIENTRY*glTexImage2D)(GLenum,GLint,GLint,GLsizei,GLsizei,GLint,GLenum,GLenum,const GLvoid *);
00039 void(APIENTRY*glColor3f)(GLfloat,GLfloat,GLfloat);
00040 void(APIENTRY*glVertex2f)(GLfloat,GLfloat);
00041 void(APIENTRY*glTexCoord2f)(GLfloat,GLfloat);
00042 void(APIENTRY*glTexEnvf)(GLenum,GLenum,GLfloat);
00043 void(APIENTRY*glColor4f)(GLfloat,GLfloat,GLfloat,GLfloat);
00044 void(APIENTRY*glDepthMask)(GLboolean);
00045 void(APIENTRY*glClearDepth)(GLclampd);
00046 void(APIENTRY*glDepthFunc)(GLenum);
00047 void(APIENTRY*glShadeModel)(GLenum);
00048 void(APIENTRY*glFinish)();
00049 GLuint(APIENTRY*glGenLists)(GLsizei);
00050 void(APIENTRY*glDeleteLists)(GLuint,GLsizei);
00051 void(APIENTRY*glPopAttrib)();
00052 void(APIENTRY*glCallLists)(GLsizei,GLenum,const GLvoid*);
00053 void(APIENTRY*glListBase)(GLuint);
00054 void(APIENTRY*glPushAttrib)(GLbitfield);
00055 void(APIENTRY*glRasterPos2f)(GLfloat,GLfloat);
00056 void(APIENTRY*glGetBooleanv)(GLenum, GLboolean *);
00057
00058 void(APIENTRY*wglUseFontBitmapsA)(HDC,long,long,long);
00059
00060 GLuint buildFont(GLvoid);
00061 GLvoid killFont();
00062 GLvoid glPrint(std::string fmt);
00063
00064
00065 GLuint SDL_GL_LoadTexture(SDL_Surface *surface, GLfloat *texcoord);
00066 int loadTexture(std::string filename, GLfloat coords[4], SDL_Rect & rect);
00067
00068 static SDL_Surface *load_image( std::string filename );
00069 static int power_of_two(int input);
00070 static bool intersect(SDL_Rect &A, SDL_Rect &B, int*x = NULL , int*y = NULL);
00071 static bool intersectX(SDL_Rect &A, SDL_Rect &B, int* x = NULL);
00072 static bool intersectY(SDL_Rect &A, SDL_Rect &B, int* y = NULL);
00073
00074 private:
00075 GLuint base;
00076
00077 glfuncs();
00078 static glfuncs* _instance;
00079 void* get_funcaddr(const char* p);
00080 void init_glfuncs();
00081
00082 };
00083
00084 #endif