Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorEvan Goers <mega@osirion.org>2012-01-24 08:13:28 +0000
committerEvan Goers <mega@osirion.org>2012-01-24 08:13:28 +0000
commit656c8b2fc03164d13352c067780037e87b98b9f2 (patch)
tree81b5b81c33b7d3a00fd5957438b404dcbfa7e7ec /src/ui
parent5d4e993e485ae3432eabb45caf4e4d43c9bc54e6 (diff)
Renderer now checks and enables lights based on availability instead of using arbitrary GL_LIGHT#s.
Diffstat (limited to 'src/ui')
-rwxr-xr-xsrc/ui/modelview.cc29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/ui/modelview.cc b/src/ui/modelview.cc
index 65954d8..c36aa56 100755
--- a/src/ui/modelview.cc
+++ b/src/ui/modelview.cc
@@ -19,6 +19,8 @@
namespace ui
{
+GLenum modelview_gllight = GL_LIGHT0 + 7;
+
ModelView::ModelView(Widget *parent, const char *modelname) : Widget(parent)
{
set_border(false);
@@ -185,28 +187,33 @@ void ModelView::draw()
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
-
-
+
// we set up the light in camera space
+ for (size_t i = 0; i < (GL_LIGHT0 + 7); i++) {
+ // check if a light is available
+ if (!glIsEnabled(GL_LIGHT0 + i)) {
+ modelview_gllight = GL_LIGHT0 + i;
+ break;
+ }
+ }
+
GLfloat modelview_light[] = { -10.0f * model->radius(), 0, 0, 1.0f };
GLfloat ambient_light[] = { 0.1f, 0.1f, 0.1f, 1.0f };
GLfloat diffuse_light[] = { 0.75f, 0.75f, 0.75f, 1.0f };
GLfloat specular_light[] = { 0.75f, 0.75f, 0.75f, 1.0f };
- glLightfv(GL_LIGHT1, GL_POSITION, modelview_light);
- glLightfv(GL_LIGHT1, GL_AMBIENT, ambient_light);
- glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse_light);
- glLightfv(GL_LIGHT1, GL_SPECULAR, specular_light);
+ glLightfv(modelview_gllight, GL_POSITION, modelview_light);
+ glLightfv(modelview_gllight, GL_AMBIENT, ambient_light);
+ glLightfv(modelview_gllight, GL_DIFFUSE, diffuse_light);
+ glLightfv(modelview_gllight, GL_SPECULAR, specular_light);
- glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, 0.75f);
+ glLightf(modelview_gllight, GL_LINEAR_ATTENUATION, 0.05f);
- gl::enable(GL_LIGHT1);
+ gl::enable(modelview_gllight);
// push transformation matrix to stack
gl::push();
-
-
gl::multmatrix(modelview_axis);
gl::scale(modelscale, modelscale, modelscale);
@@ -226,7 +233,7 @@ void ModelView::draw()
gl::pop();
- gl::disable(GL_LIGHT1);
+ gl::disable(modelview_gllight);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);