diff options
Diffstat (limited to 'gl.cpp')
-rw-r--r-- | gl.cpp | 74 |
1 files changed, 74 insertions, 0 deletions
@@ -0,0 +1,74 @@ +#include "gl.h" + +#include <SDL.h> + +#ifdef WIN32 + +void (*glGenBuffers)(GLsizei, GLuint*); +void (*glDeleteBuffers)(GLsizei, GLuint*); +void (*glBindBuffer)(GLenum, GLuint); +void (*glBufferData)(GLenum, GLsizeiptr, const GLvoid*, GLenum); +GLvoid* (*glMapBuffer)(GLenum, GLenum); +GLboolean (*glUnmapBuffer)(GLenum); + +/* uniform */ +GLint (*glGetUniformLocation)(GLuint, const GLchar*); +void (*glUniform1i)(GLint, GLint); +void (*glUniform3f)(GLint, GLfloat, GLfloat, GLfloat); + +/* texture */ +void (*glActiveTexture)(GLenum); + +/* program/shader */ +GLuint (*glCreateProgram)(void); +void (*glLinkProgram)(GLuint); +void (*glGetProgramiv)(GLuint, GLenum, GLint*); +void (*glGetProgramInfoLog)(GLuint, GLsizei, GLsizei*, GLchar*); +void (*glUseProgram)(GLuint); +void (*glDeleteProgram)(GLuint); + +GLuint (*glCreateShader)(GLenum); +void (*glShaderSource)(GLuint, GLsizei, const GLchar**, const GLint*); +void (*glCompileShader)(GLuint); +void (*glGetShaderiv)(GLuint, GLenum, GLint*); +void (*glGetShaderInfoLog)(GLuint, GLsizei, GLsizei*, GLchar*); + +void (*glAttachShader)(GLuint, GLuint); +void (*glDetachShader)(GLuint, GLuint); +void (*glDeleteShader)(GLuint); + +//GL_DeleteBuffers glDeleteBuffers = NULL; + +void win32_gl_init() { + glGenBuffers = (void(*)(GLsizei, GLuint*))SDL_GL_GetProcAddress("glGenBuffers"); + glDeleteBuffers = (void(*)(GLsizei, GLuint*))SDL_GL_GetProcAddress("glDeleteBuffers"); + glBindBuffer = (void(*)(GLenum, GLuint))SDL_GL_GetProcAddress("glBindBuffer"); + glBufferData = (void(*)(GLenum, GLsizeiptr, const GLvoid*, GLenum))SDL_GL_GetProcAddress("glBufferData"); + glMapBuffer = (GLvoid*(*)(GLenum, GLenum))SDL_GL_GetProcAddress("glMapBuffer"); + glUnmapBuffer = (GLboolean(*)(GLenum))SDL_GL_GetProcAddress("glUnmapBuffer"); + + glGetUniformLocation = (GLint(*)(GLuint, const GLchar*))SDL_GL_GetProcAddress("glGetUniformLocation"); + glUniform1i = (void(*)(GLint, GLint))SDL_GL_GetProcAddress("glUniform1i"); + glUniform3f = (void(*)(GLint, GLfloat, GLfloat, GLfloat))SDL_GL_GetProcAddress("glUniform3f"); + + glActiveTexture = (void(*)(GLenum))SDL_GL_GetProcAddress("glActiveTexture"); + + glCreateProgram = (GLuint(*)(void))SDL_GL_GetProcAddress("glCreateProgram"); + glLinkProgram = (void(*)(GLuint))SDL_GL_GetProcAddress("glLinkProgram"); + glGetProgramiv = (void(*)(GLuint, GLenum, GLint*))SDL_GL_GetProcAddress("glGetProgramiv"); + glGetProgramInfoLog = (void(*)(GLuint, GLsizei, GLsizei*, GLchar*))SDL_GL_GetProcAddress("glGetProgramInfoLog"); + glUseProgram = (void(*)(GLuint))SDL_GL_GetProcAddress("glUseProgram"); + glDeleteProgram = (void(*)(GLuint))SDL_GL_GetProcAddress("glDeleteProgram"); + + glCreateShader = (GLuint(*)(GLenum))SDL_GL_GetProcAddress("glCreateShader"); + glShaderSource = (void(*)(GLuint, GLsizei, const GLchar**, const GLint*))SDL_GL_GetProcAddress("glShaderSource"); + glCompileShader = (void(*)(GLuint))SDL_GL_GetProcAddress("glCompileShader"); + glGetShaderiv = (void(*)(GLuint, GLenum, GLint*))SDL_GL_GetProcAddress("glGetShaderiv"); + glGetShaderInfoLog = (void(*)(GLuint, GLsizei, GLsizei*, GLchar*))SDL_GL_GetProcAddress("glGetShaderInfoLog"); + + glAttachShader = (void(*)(GLuint, GLuint))SDL_GL_GetProcAddress("glAttachShader"); + glDetachShader = (void(*)(GLuint, GLuint))SDL_GL_GetProcAddress("glDetachShader"); + glDeleteShader = (void(*)(GLuint))SDL_GL_GetProcAddress("glDeleteShader"); +} + +#endif |