Commit f5a95e54 authored by Guillaume Seguin's avatar Guillaume Seguin

Add lights to gcview

parent 5b454175
...@@ -22,9 +22,11 @@ from . import gcoder ...@@ -22,9 +22,11 @@ from . import gcoder
from .gl.panel import wxGLPanel from .gl.panel import wxGLPanel
from .gl.trackball import build_rotmatrix from .gl.trackball import build_rotmatrix
from .gl.libtatlin import actors from .gl.libtatlin import actors
from .gl.libtatlin.actors import vec
from pyglet.gl import glPushMatrix, glPopMatrix, \ from pyglet.gl import glPushMatrix, glPopMatrix, \
glTranslatef, glRotatef, glScalef, glMultMatrixd glTranslatef, glRotatef, glScalef, glMultMatrixd
from pyglet.gl import *
from .gviz import GvizBaseFrame from .gviz import GvizBaseFrame
...@@ -71,6 +73,10 @@ class GcodeViewPanel(wxGLPanel): ...@@ -71,6 +73,10 @@ class GcodeViewPanel(wxGLPanel):
self.parent.loadcb() self.parent.loadcb()
self.parent.filenames = None self.parent.filenames = None
glEnable(GL_LIGHTING)
glEnable(GL_LIGHT0)
glEnable(GL_LIGHT1)
def create_objects(self): def create_objects(self):
'''create opengl objects when opengl is initialized''' '''create opengl objects when opengl is initialized'''
for obj in self.parent.objects: for obj in self.parent.objects:
...@@ -97,6 +103,14 @@ class GcodeViewPanel(wxGLPanel): ...@@ -97,6 +103,14 @@ class GcodeViewPanel(wxGLPanel):
platformy0 = -self.build_dimensions[4] - self.parent.platform.depth / 2 platformy0 = -self.build_dimensions[4] - self.parent.platform.depth / 2
glTranslatef(platformx0, platformy0, 0) glTranslatef(platformx0, platformy0, 0)
light_z = max(self.parent.platform.width, self.parent.platform.depth)
glLightfv(GL_LIGHT0, GL_POSITION, vec(0,
self.parent.platform.depth / 2,
light_z, 0))
glLightfv(GL_LIGHT0, GL_POSITION, vec(self.parent.platform.width,
self.parent.platform.depth / 2,
light_z, 0))
for obj in self.parent.objects: for obj in self.parent.objects:
if not obj.model \ if not obj.model \
or not obj.model.loaded \ or not obj.model.loaded \
......
...@@ -36,6 +36,9 @@ from pyglet.graphics.vertexbuffer import create_buffer, VertexBufferObject ...@@ -36,6 +36,9 @@ from pyglet.graphics.vertexbuffer import create_buffer, VertexBufferObject
from printrun.printrun_utils import install_locale from printrun.printrun_utils import install_locale
install_locale('pronterface') install_locale('pronterface')
def vec(*args):
return (GLfloat * len(args))(*args)
def compile_display_list(func, *options): def compile_display_list(func, *options):
display_list = glGenLists(1) display_list = glGenLists(1)
glNewList(display_list, GL_COMPILE) glNewList(display_list, GL_COMPILE)
......
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