Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: 0917eec1d63fa412f210a1a20ed3ed193d5c0da2 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
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