summaryrefslogtreecommitdiff
path: root/gl.cpp
blob: a14ae44dbf6de06fdb75f9eb0a96b6f2469c03af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "gl.h"

#include <SDL.h>

#ifdef WIN32

void (APIENTRY *glGenBuffers)(GLsizei, GLuint*);
void (APIENTRY *glDeleteBuffers)(GLsizei, GLuint*);
void (APIENTRY *glBindBuffer)(GLenum, GLuint);
void (APIENTRY *glBufferData)(GLenum, GLsizeiptr, const GLvoid*, GLenum);
GLvoid* (APIENTRY *glMapBuffer)(GLenum, GLenum);
GLboolean (APIENTRY *glUnmapBuffer)(GLenum);

/* uniform */
GLint (APIENTRY *glGetUniformLocation)(GLuint, const GLchar*);
void (APIENTRY *glUniform1i)(GLint, GLint);
void (APIENTRY *glUniform1f)(GLint, GLfloat);
void (APIENTRY *glUniform2f)(GLint, GLfloat, GLfloat);
void (APIENTRY *glUniform3f)(GLint, GLfloat, GLfloat, GLfloat);
void (APIENTRY *glUniform1iv)(GLint, GLsizei, const GLint*);

/* texture */
void (APIENTRY *glActiveTexture)(GLenum);

/* program/shader */
GLuint (APIENTRY *glCreateProgram)(void);
void (APIENTRY *glLinkProgram)(GLuint);
void (APIENTRY *glGetProgramiv)(GLuint, GLenum, GLint*);
void (APIENTRY *glGetProgramInfoLog)(GLuint, GLsizei, GLsizei*, GLchar*);
void (APIENTRY *glUseProgram)(GLuint);
void (APIENTRY *glDeleteProgram)(GLuint);

GLuint (APIENTRY *glCreateShader)(GLenum);
void (APIENTRY *glShaderSource)(GLuint, GLsizei, const GLchar**, const GLint*);
void (APIENTRY *glCompileShader)(GLuint);
void (APIENTRY *glGetShaderiv)(GLuint, GLenum, GLint*);
void (APIENTRY *glGetShaderInfoLog)(GLuint, GLsizei, GLsizei*, GLchar*);

void (APIENTRY *glAttachShader)(GLuint, GLuint);
void (APIENTRY *glDetachShader)(GLuint, GLuint);
void (APIENTRY *glDeleteShader)(GLuint);

//GL_DeleteBuffers glDeleteBuffers = NULL;

void win32_gl_init() {
	glGenBuffers = (void(APIENTRY*)(GLsizei, GLuint*))SDL_GL_GetProcAddress("glGenBuffers");
	glDeleteBuffers = (void(APIENTRY*)(GLsizei, GLuint*))SDL_GL_GetProcAddress("glDeleteBuffers");
	glBindBuffer = (void(APIENTRY*)(GLenum, GLuint))SDL_GL_GetProcAddress("glBindBuffer");
	glBufferData = (void(APIENTRY*)(GLenum, GLsizeiptr, const GLvoid*, GLenum))SDL_GL_GetProcAddress("glBufferData");
	glMapBuffer = (GLvoid*(APIENTRY*)(GLenum, GLenum))SDL_GL_GetProcAddress("glMapBuffer");
	glUnmapBuffer = (GLboolean(APIENTRY*)(GLenum))SDL_GL_GetProcAddress("glUnmapBuffer");

	glGetUniformLocation = (GLint(APIENTRY*)(GLuint, const GLchar*))SDL_GL_GetProcAddress("glGetUniformLocation");
	glUniform1i = (void(APIENTRY*)(GLint, GLint))SDL_GL_GetProcAddress("glUniform1i");
	glUniform1f = (void(APIENTRY*)(GLint, GLfloat))SDL_GL_GetProcAddress("glUniform1f");
	glUniform2f = (void(APIENTRY*)(GLint, GLfloat, GLfloat))SDL_GL_GetProcAddress("glUniform2f");
	glUniform3f = (void(APIENTRY*)(GLint, GLfloat, GLfloat, GLfloat))SDL_GL_GetProcAddress("glUniform3f");
	glUniform1iv = (void(APIENTRY*)(GLint, GLsizei, const GLint*))SDL_GL_GetProcAddress("glUniform1iv");

	glActiveTexture = (void(APIENTRY*)(GLenum))SDL_GL_GetProcAddress("glActiveTexture");

	glCreateProgram = (GLuint(APIENTRY*)(void))SDL_GL_GetProcAddress("glCreateProgram");
	glLinkProgram = (void(APIENTRY*)(GLuint))SDL_GL_GetProcAddress("glLinkProgram");
	glGetProgramiv = (void(APIENTRY*)(GLuint, GLenum, GLint*))SDL_GL_GetProcAddress("glGetProgramiv");
	glGetProgramInfoLog = (void(APIENTRY*)(GLuint, GLsizei, GLsizei*, GLchar*))SDL_GL_GetProcAddress("glGetProgramInfoLog");
	glUseProgram = (void(APIENTRY*)(GLuint))SDL_GL_GetProcAddress("glUseProgram");
	glDeleteProgram = (void(APIENTRY*)(GLuint))SDL_GL_GetProcAddress("glDeleteProgram");

	glCreateShader = (GLuint(APIENTRY*)(GLenum))SDL_GL_GetProcAddress("glCreateShader");
	glShaderSource = (void(APIENTRY*)(GLuint, GLsizei, const GLchar**, const GLint*))SDL_GL_GetProcAddress("glShaderSource");
	glCompileShader = (void(APIENTRY*)(GLuint))SDL_GL_GetProcAddress("glCompileShader");
	glGetShaderiv = (void(APIENTRY*)(GLuint, GLenum, GLint*))SDL_GL_GetProcAddress("glGetShaderiv");
	glGetShaderInfoLog = (void(APIENTRY*)(GLuint, GLsizei, GLsizei*, GLchar*))SDL_GL_GetProcAddress("glGetShaderInfoLog");

	glAttachShader = (void(APIENTRY*)(GLuint, GLuint))SDL_GL_GetProcAddress("glAttachShader");
	glDetachShader = (void(APIENTRY*)(GLuint, GLuint))SDL_GL_GetProcAddress("glDetachShader");
	glDeleteShader = (void(APIENTRY*)(GLuint))SDL_GL_GetProcAddress("glDeleteShader");
}

#endif