Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/render/draw.cc50
-rw-r--r--src/render/gl.cc134
-rw-r--r--src/render/gl.h56
-rw-r--r--src/render/state.cc27
-rw-r--r--src/render/state.h4
5 files changed, 230 insertions, 41 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc
index dea0c6b..59f4a59 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -91,7 +91,7 @@ void pass_prepare(float seconds)
zone_ambient[i] = core::localplayer()->zone()->ambient_color()[i];
}
zone_ambient[3] = 1.0f;
- glLightModelfv(GL_LIGHT_MODEL_AMBIENT, zone_ambient);
+ gl::lightmodel(GL_LIGHT_MODEL_AMBIENT, zone_ambient);
// zone light sources
for (core::Zone::Content::iterator it = zone->content().begin(); it != zone->content().end(); it++) {
@@ -249,13 +249,13 @@ void draw_globe_corona(const math::Vector3f location, const math::Color & color,
gl::color(drawcolor);
gl::begin(gl::Quads);
- glTexCoord2f(0, 1);
+ gl::texcoord(0, 1);
gl::vertex((Camera::axis().up() - Camera::axis().left()) * radius * 4.0f);
- glTexCoord2f(0, 0);
+ gl::texcoord(0, 0);
gl::vertex((Camera::axis().up() + Camera::axis().left()) * radius * 4.0f);
- glTexCoord2f(1, 0);
+ gl::texcoord(1, 0);
gl::vertex((Camera::axis().up() * -1 + Camera::axis().left()) * radius * 4.0f);
- glTexCoord2f(1, 1);
+ gl::texcoord(1, 1);
gl::vertex((Camera::axis().up() * -1 - Camera::axis().left()) * radius * 4.0f);
gl::end();
@@ -272,7 +272,7 @@ void draw_pass_globes()
{
// FIXME is this ever reset ?
GLfloat globe_specular[] = { 0.25f, 0.25f, 0.25f, 1.0f };
- glMaterialfv(GL_FRONT, GL_SPECULAR, globe_specular);
+ gl::material(GL_FRONT, GL_SPECULAR, globe_specular);
// Globes have to be rendered distance sorted, closest last.
// Globes behind farplane are rescaled and repositioned.
@@ -852,13 +852,13 @@ void draw_model_lights(model::Model *model, const float scale,
// draw the quad
gl::color(color);
- glTexCoord2f(1, 0);
+ gl::texcoord(1, 0);
gl::vertex(location + (Camera::axis().up() - Camera::axis().left()) * light_size);
- glTexCoord2f(0, 0);
+ gl::texcoord(0, 0);
gl::vertex(location + (Camera::axis().up() + Camera::axis().left()) * light_size);
- glTexCoord2f(0, 1);
+ gl::texcoord(0, 1);
gl::vertex(location + (Camera::axis().up() * -1 + Camera::axis().left()) * light_size);
- glTexCoord2f(1, 1);
+ gl::texcoord(1, 1);
gl::vertex(location + (Camera::axis().up() * -1 - Camera::axis().left()) * light_size);
Stats::quads++;
@@ -946,13 +946,13 @@ void draw_model_lights(model::Model *model, const float scale,
// draw the quad
gl::color(color);
- glTexCoord2f(1, 0);
+ gl::texcoord(1, 0);
gl::vertex(location + (flare_axis.up() + flare_axis.left()) * light_size);
- glTexCoord2f(0, 0);
+ gl::texcoord(0, 0);
gl::vertex(location + (flare_axis.up() - flare_axis.left()) * light_size);
- glTexCoord2f(0, 1);
+ gl::texcoord(0, 1);
gl::vertex(location + (flare_axis.up() * -1 - flare_axis.left()) * light_size);
- glTexCoord2f(1, 1);
+ gl::texcoord(1, 1);
gl::vertex(location + (flare_axis.up() * -1 + flare_axis.left()) * light_size);
Stats::quads++;
@@ -1096,7 +1096,7 @@ void draw(float seconds)
gl::disable(GL_DEPTH_TEST); // disable depth testing
gl::depthmask(GL_FALSE); // disable depth buffer writing
- glPolygonMode(GL_FRONT, GL_FILL);
+ gl::polygonmode(GL_FRONT, GL_FILL);
draw_pass_sky(); // draw the skybox
@@ -1124,20 +1124,20 @@ void draw(float seconds)
// Interleaved format is GL_T2F_N3F_V3F
// void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr )
- glTexCoordPointer(2, GL_FLOAT, 8 * sizeof(GLfloat), 0);
+ gl::texcoordpointer(2, GL_FLOAT, 8 * sizeof(GLfloat), 0);
// void glNormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
- glNormalPointer(GL_FLOAT, 8 * sizeof(GLfloat), (void*) (2 * sizeof(GLfloat)));
+ gl::normalpointer(GL_FLOAT, 8 * sizeof(GLfloat), (void*) (2 * sizeof(GLfloat)));
// void glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
- glVertexPointer(3, GL_FLOAT, 8 * sizeof(GLfloat), (void*) (5 * sizeof(GLfloat)));
+ gl::vertexpointer(3, GL_FLOAT, 8 * sizeof(GLfloat), (void*) (5 * sizeof(GLfloat)));
} else {
- glInterleavedArrays(GL_T2F_N3F_V3F, 0, core::game()->vertexarray()->ptr());
+ gl::interleavedarrays(GL_T2F_N3F_V3F, 0, core::game()->vertexarray()->ptr());
}
// enable vertex arrays
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glEnableClientState(GL_NORMAL_ARRAY);
- glEnableClientState(GL_VERTEX_ARRAY);
+ gl::enableclientstate(GL_TEXTURE_COORD_ARRAY);
+ gl::enableclientstate(GL_NORMAL_ARRAY);
+ gl::enableclientstate(GL_VERTEX_ARRAY);
State::set_normalize(true);
@@ -1198,9 +1198,9 @@ void draw(float seconds)
}
}
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_NORMAL_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ gl::disableclientstate(GL_VERTEX_ARRAY);
+ gl::disableclientstate(GL_NORMAL_ARRAY);
+ gl::disableclientstate(GL_TEXTURE_COORD_ARRAY);
// draw physics
if (r_physics && r_physics->value()) {
diff --git a/src/render/gl.cc b/src/render/gl.cc
index 48b9b52..8debb8e 100644
--- a/src/render/gl.cc
+++ b/src/render/gl.cc
@@ -104,6 +104,16 @@ void disable(GLenum cap)
::glDisable(cap);
}
+void enableclientstate(GLenum cap)
+{
+ glEnableClientState(cap);
+}
+
+void disableclientstate(GLenum cap)
+{
+ glDisableClientState(cap);
+}
+
void clear(GLbitfield mask)
{
glClear(mask);
@@ -193,6 +203,26 @@ void texcoord(const float x, const float y, const float z)
glTexCoord3f(x, y, z);
}
+void texcoordpointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
+{
+ glTexCoordPointer(size, type, stride, pointer);
+}
+
+void normalpointer(GLenum type, GLsizei stride, const GLvoid* pointer)
+{
+ glNormalPointer(type, stride, pointer);
+}
+
+void vertexpointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
+{
+ glVertexPointer(size, type, stride, pointer);
+}
+
+void interleavedarrays(GLenum format, GLsizei stride, const GLvoid* pointer)
+{
+ glInterleavedArrays(format, stride, pointer);
+}
+
void push()
{
glPushMatrix();
@@ -243,15 +273,115 @@ void frustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdou
glFrustum(left, right, bottom, top, znear, zfar);
}
-void texgeni(GLenum coord, GLenum param, GLenum value)
+void lightmodel(GLenum pname, GLfloat param)
+{
+ glLightModelf(pname, param);
+}
+
+void lightmodel(GLenum pname, GLint param)
+{
+ glLightModeli(pname, param);
+}
+
+void lightmodel(GLenum pname, const GLfloat* param)
+{
+ glLightModelfv(pname, param);
+}
+
+void lightmodel(GLenum pname, const GLint* param)
+{
+ glLightModeliv(pname, param);
+}
+
+void polygonmode(GLenum face, GLenum mode)
+{
+ glPolygonMode(face, mode);
+}
+
+void colormaterial(GLenum face, GLenum mode)
+{
+ glColorMaterial(face, mode);
+}
+
+void material(GLenum face, GLenum pname, GLfloat param)
+{
+ glMaterialf(face, pname, param);
+}
+
+void material(GLenum face, GLenum pname, GLint param)
+{
+ glMateriali(face, pname, param);
+}
+
+void material(GLenum face, GLenum pname, const GLfloat* param)
+{
+ glMaterialfv(face, pname, param);
+}
+
+void material(GLenum face, GLenum pname, const GLint* param)
+{
+ glMaterialiv(face, pname, param);
+}
+
+void texenv(GLenum target, GLenum pname, GLfloat param)
+{
+ glTexEnvf(target, pname, param);
+}
+
+void texenv(GLenum target, GLenum pname, GLint param)
+{
+ glTexEnvi(target, pname, param);
+}
+
+void texenv(GLenum target, GLenum pname, const GLfloat* param)
+{
+ glTexEnvfv(target, pname, param);
+}
+
+void texenv(GLenum target, GLenum pname, const GLint* param)
+{
+ glTexEnviv(target, pname, param);
+}
+
+void texgen(GLenum coord, GLenum param, GLint value)
{
glTexGeni(coord, param, value);
}
-void texgenfv(GLenum coord, GLenum param, const GLfloat* value)
+void texgen(GLenum coord, GLenum param, GLfloat value)
+{
+ glTexGenf(coord, param, value);
+}
+
+void texgen(GLenum coord, GLenum param, GLdouble value)
+{
+ glTexGend(coord, param, value);
+}
+
+void texgen(GLenum coord, GLenum param, const GLint* value)
+{
+ glTexGeniv(coord, param, value);
+}
+
+void texgen(GLenum coord, GLenum param, const GLfloat* value)
{
glTexGenfv(coord, param, value);
}
+void texgen(GLenum coord, GLenum param, const GLdouble* value)
+{
+ glTexGendv(coord, param, value);
+}
+
+void activetexture(GLenum texture)
+{
+ glActiveTexture(texture);
+}
+
+void clientactivetexture(GLenum texture)
+{
+ glClientActiveTexture(texture);
+}
+
} // namespace gl
diff --git a/src/render/gl.h b/src/render/gl.h
index 4dea544..8d8e48e 100644
--- a/src/render/gl.h
+++ b/src/render/gl.h
@@ -116,6 +116,12 @@ void enable(GLenum cap);
/// glDisable
void disable(GLenum cap);
+/// glEnableClientState
+void enableclientstate(GLenum cap);
+
+/// glDisableClientState
+void disableclientstate(GLenum cap);
+
/// glShadeModel
void shademodel(GLenum mode);
@@ -174,6 +180,18 @@ void texcoord(const math::Vector2f& vector);
/// glTexCoord
void texcoord(const float x, const float y, const float z);
+/// glTexCoordPointer
+void texcoordpointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
+
+/// glNormalPointer
+void normalpointer(GLenum type, GLsizei stride, const GLvoid* pointer);
+
+/// glVertexPointer
+void vertexpointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
+
+/// glInterleavedArrays
+void interleavedarrays(GLenum format, GLsizei stride, const GLvoid* pointer);
+
/// glNormal
void normal(const math::Vector3f & vector);
@@ -250,10 +268,42 @@ void loadidentity();
/// Perspective matrix
void frustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble znear, GLdouble zfar);
-/// Texture coordinate generation
-void texgeni(GLenum coord, GLenum param, GLenum value);
+/// Light model
+void lightmodel(GLenum pname, GLfloat param);
+void lightmodel(GLenum pname, GLint param);
+void lightmodel(GLenum pname, const GLfloat* param);
+void lightmodel(GLenum pname, const GLint* param);
+
+/// Polygon mode
+void polygonmode(GLenum face, GLenum mode);
+
+/// Color material parameters
+void colormaterial(GLenum face, GLenum mode);
-void texgenfv(GLenum coord, GLenum param, const GLfloat* value);
+/// Material parameters
+void material(GLenum face, GLenum pname, GLfloat param);
+void material(GLenum face, GLenum pname, GLint param);
+void material(GLenum face, GLenum pname, const GLfloat* param);
+void material(GLenum face, GLenum pname, const GLint* param);
+
+/// Texture environment parameters
+void texenv(GLenum target, GLenum pname, GLfloat param);
+void texenv(GLenum target, GLenum pname, GLint param);
+void texenv(GLenum target, GLenum pname, const GLfloat* param);
+void texenv(GLenum target, GLenum pname, const GLint* param);
+
+/// Texture coordinate generation
+void texgen(GLenum coord, GLenum param, GLint value);
+void texgen(GLenum coord, GLenum param, GLfloat value);
+void texgen(GLenum coord, GLenum param, GLdouble value);
+void texgen(GLenum coord, GLenum param, const GLint* value);
+void texgen(GLenum coord, GLenum param, const GLfloat* value);
+void texgen(GLenum coord, GLenum param, const GLdouble* value);
+
+/// Active server-side texture
+void activetexture(GLenum texture);
+/// Active client-side texture
+void clientactivetexture(GLenum texture);
typedef void (* APIENTRY genbuffers_func)(GLuint count, GLuint *id);
typedef void (* APIENTRY deletebuffers_func)(GLuint count, GLuint *id);
diff --git a/src/render/state.cc b/src/render/state.cc
index ce3a0ab..83f2704 100644
--- a/src/render/state.cc
+++ b/src/render/state.cc
@@ -23,6 +23,7 @@ bool State::state_has_generate_mipmaps = false;
bool State::state_has_vbo = false;
GLuint State::state_vbo = 0;
int State::state_maxlights;
+int State::state_maxtextureunits;
math::Color State::state_color_primary;
@@ -90,7 +91,7 @@ void State::init(int width, int height)
state_has_vbo = false;
}
- con_print << " vertex bufer objects ";
+ con_print << " vertex buffer objects ";
if (state_has_vbo)
con_print << "enabled" << std::endl;
else
@@ -99,6 +100,10 @@ void State::init(int width, int height)
// probe maximal number of lights
glGetIntegerv(GL_MAX_LIGHTS, &state_maxlights);
con_debug << " maximum number of OpenGL lights is " << state_maxlights << std::endl;
+
+ // probe maximal number of texture units
+ glGetIntegerv(GL_MAX_TEXTURE_UNITS, &state_maxtextureunits);
+ con_debug << " maximum number of OpenGL texture units is " << state_maxtextureunits << std::endl;
// Generate VBO
if (state_has_vbo)
@@ -142,11 +147,11 @@ void State::clear()
//gl::shademodel(GL_FLAT);
// lighting model
- glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
- glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
+ gl::lightmodel(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
+ gl::lightmodel(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
// color tracking
- glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
+ gl::colormaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
// alpha blending function
gl::blendfunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -217,7 +222,7 @@ void State::use_material(const model::Material * material) {
reset();
// default specular shininess setting
- glMateriali(GL_FRONT, GL_SHININESS, 8);
+ gl::material(GL_FRONT, GL_SHININESS, 8);
if (!material) {
color.assign(1.0f, 0.0f, 1.0f);
@@ -291,8 +296,8 @@ void State::use_material(const model::Material * material) {
gl::enable(GL_TEXTURE_2D);
if (material->flags() & model::Material::Environment) {
- gl::texgeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
- gl::texgeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
+ gl::texgen(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
+ gl::texgen(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
gl::enable(GL_TEXTURE_GEN_S);
gl::enable(GL_TEXTURE_GEN_T);
@@ -304,9 +309,9 @@ void State::use_material(const model::Material * material) {
if (core::localplayer()->zone()->sky().size()) {
gl::enable(GL_TEXTURE_CUBE_MAP);
- glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
- glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
- glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
+ gl::texgen(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
+ gl::texgen(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
+ gl::texgen(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
gl::enable(GL_TEXTURE_GEN_S);
gl::enable(GL_TEXTURE_GEN_T);
@@ -314,7 +319,7 @@ void State::use_material(const model::Material * material) {
} else {
color.assign(0.0f, 0.0f, 0.0f);
}
- glMateriali(GL_FRONT, GL_SHININESS, 4);
+ gl::material(GL_FRONT, GL_SHININESS, 4);
}
}
diff --git a/src/render/state.h b/src/render/state.h
index cda64d5..ea55602 100644
--- a/src/render/state.h
+++ b/src/render/state.h
@@ -104,6 +104,9 @@ public:
inline static int max_lights() {
return state_maxlights;
}
+ inline static int max_textureunits() {
+ return state_maxtextureunits;
+ }
static void set_normalize(const bool enable=true);
@@ -116,6 +119,7 @@ private:
static bool state_has_vbo;
static GLuint state_vbo;
static int state_maxlights;
+ static int state_maxtextureunits;
static math::Color state_color_primary; // current primary color
static math::Color state_color_secondary; // current secondary color