Commit 317eff86 authored by Guillaume Seguin's avatar Guillaume Seguin

Allow preventing glpanel from setting up lights

This is probably a good call for the future... Changing lights in
glpanel/gcview won't break stlview anymore
parent 5bca892f
...@@ -45,6 +45,7 @@ class wxGLPanel(wx.Panel): ...@@ -45,6 +45,7 @@ class wxGLPanel(wx.Panel):
orthographic = True orthographic = True
color_background = (0.98, 0.98, 0.78, 1) color_background = (0.98, 0.98, 0.78, 1)
do_lights = True
def __init__(self, parent, id, pos = wx.DefaultPosition, def __init__(self, parent, id, pos = wx.DefaultPosition,
size = wx.DefaultSize, style = 0, size = wx.DefaultSize, style = 0,
...@@ -172,6 +173,8 @@ class wxGLPanel(wx.Panel): ...@@ -172,6 +173,8 @@ class wxGLPanel(wx.Panel):
self.update_object_resize() self.update_object_resize()
def setup_lights(self): def setup_lights(self):
if not self.do_lights:
return
glEnable(GL_LIGHTING) glEnable(GL_LIGHTING)
glDisable(GL_LIGHT0) glDisable(GL_LIGHT0)
glLightfv(GL_LIGHT0, GL_AMBIENT, vec(0.4, 0.4, 0.4, 1.0)) glLightfv(GL_LIGHT0, GL_AMBIENT, vec(0.4, 0.4, 0.4, 1.0))
......
...@@ -57,6 +57,8 @@ class stlview(object): ...@@ -57,6 +57,8 @@ class stlview(object):
class StlViewPanel(wxGLPanel): class StlViewPanel(wxGLPanel):
do_lights = False
def __init__(self, parent, size, id = wx.ID_ANY, def __init__(self, parent, size, id = wx.ID_ANY,
build_dimensions = None, circular = False): build_dimensions = None, circular = False):
super(StlViewPanel, self).__init__(parent, id, wx.DefaultPosition, size, 0) super(StlViewPanel, self).__init__(parent, id, wx.DefaultPosition, size, 0)
...@@ -109,7 +111,6 @@ class StlViewPanel(wxGLPanel): ...@@ -109,7 +111,6 @@ class StlViewPanel(wxGLPanel):
glEnable(GL_LIGHTING) glEnable(GL_LIGHTING)
glEnable(GL_LIGHT0) glEnable(GL_LIGHT0)
glEnable(GL_LIGHT1) glEnable(GL_LIGHT1)
glDisable(GL_LIGHT2)
glLightfv(GL_LIGHT0, GL_POSITION, vec(.5, .5, 1, 0)) glLightfv(GL_LIGHT0, GL_POSITION, vec(.5, .5, 1, 0))
glLightfv(GL_LIGHT0, GL_SPECULAR, vec(.5, .5, 1, 1)) glLightfv(GL_LIGHT0, GL_SPECULAR, vec(.5, .5, 1, 1))
...@@ -117,6 +118,7 @@ class StlViewPanel(wxGLPanel): ...@@ -117,6 +118,7 @@ class StlViewPanel(wxGLPanel):
glLightfv(GL_LIGHT1, GL_POSITION, vec(1, 0, .5, 0)) glLightfv(GL_LIGHT1, GL_POSITION, vec(1, 0, .5, 0))
glLightfv(GL_LIGHT1, GL_DIFFUSE, vec(.5, .5, .5, 1)) glLightfv(GL_LIGHT1, GL_DIFFUSE, vec(.5, .5, .5, 1))
glLightfv(GL_LIGHT1, GL_SPECULAR, vec(1, 1, 1, 1)) glLightfv(GL_LIGHT1, GL_SPECULAR, vec(1, 1, 1, 1))
glShadeModel(GL_SMOOTH)
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, vec(0.5, 0, 0.3, 1)) glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, vec(0.5, 0, 0.3, 1))
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, vec(1, 1, 1, 1)) glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, vec(1, 1, 1, 1))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment