diff options
author | clifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c> | 2009-06-29 11:03:15 (GMT) |
---|---|---|
committer | clifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c> | 2009-06-29 11:03:15 (GMT) |
commit | b8ce36f7e7e76c5cd6c51bc44f651ea43f85a8d7 (patch) | |
tree | 8a8fb60cd2f79854b2a3588d885d9ff301b7810a /glview.cc | |
parent | c16507211f270805f5223c3d84af6b989f173551 (diff) |
Clifford Wolf:
Added support for OpenGL Lights
git-svn-id: http://svn.clifford.at/openscad/trunk@35 b57f626f-c46c-0410-a088-ec61d464b74c
Diffstat (limited to 'glview.cc')
-rw-r--r-- | glview.cc | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -41,6 +41,8 @@ GLView::GLView(QWidget *parent) : QGLWidget(parent) for (int i = 0; i < 10; i++) shaderinfo[i] = 0; + useLights = false; + setMouseTracking(true); } @@ -164,11 +166,31 @@ void GLView::paintGL() glMatrixMode(GL_MODELVIEW); glLoadIdentity(); + + if (useLights) + { + GLfloat light_diffuse[] = {1.0, 1.0, 1.0, 1.0}; + GLfloat light_position0[] = {-1.0, -1.0, +1.0, 0.0}; + GLfloat light_position1[] = {+1.0, +1.0, -1.0, 0.0}; + + glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); + glLightfv(GL_LIGHT0, GL_POSITION, light_position0); + glEnable(GL_LIGHT0); + glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse); + glLightfv(GL_LIGHT1, GL_POSITION, light_position1); + glEnable(GL_LIGHT1); + glEnable(GL_LIGHTING); + glEnable(GL_NORMALIZE); + } + else + { + glDisable(GL_LIGHTING); + } + glRotated(object_rot_y, 1.0, 0.0, 0.0); glRotated(object_rot_z, 0.0, 0.0, 1.0); glDepthFunc(GL_LESS); - glDisable(GL_LIGHTING); #if 0 glLineWidth(1); |