Commit 381c52b6 authored by Guillaume Seguin's avatar Guillaume Seguin

Code cleanup

parent c2557e72
......@@ -23,7 +23,6 @@ import logging
from ctypes import sizeof
from pyglet.gl import *
from pyglet.gl import glPushMatrix, glPopMatrix, glTranslatef, \
glGenLists, glNewList, GL_COMPILE, glEndList, glCallList, \
GL_ELEMENT_ARRAY_BUFFER, GL_UNSIGNED_INT, GL_TRIANGLES, GL_LINE_LOOP, \
......@@ -33,9 +32,7 @@ from pyglet.gl import glPushMatrix, glPopMatrix, glTranslatef, \
glVertexPointer, glColorPointer, glDrawArrays, glDrawRangeElements, \
glEnableClientState, glDisableClientState, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, \
GL_FRONT_AND_BACK, GL_FRONT, glMaterialfv, GL_SPECULAR, GL_EMISSION, \
GL_DIFFUSE, GL_AMBIENT, GL_LIGHTING, GL_LIGHT0, glLightfv, \
glColorMaterial, GL_AMBIENT_AND_DIFFUSE, glMaterialf, GL_SHININESS, \
GL_LIGHT1, GL_LIGHT2, GL_POSITION, GL_SPOT_EXPONENT, glShadeModel, GL_SMOOTH
glColorMaterial, GL_AMBIENT_AND_DIFFUSE, glMaterialf, GL_SHININESS
from pyglet.graphics.vertexbuffer import create_buffer, VertexBufferObject
from printrun.utils import install_locale
......
......@@ -23,9 +23,21 @@ from wx import glcanvas
import pyglet
pyglet.options['debug_gl'] = True
from pyglet.gl import *
from pyglet.gl import glEnable, glDisable, GL_LIGHTING, glLightfv, \
GL_LIGHT0, GL_LIGHT1, GL_LIGHT2, GL_POSITION, GL_DIFFUSE, \
GL_AMBIENT, GL_SPECULAR, GL_COLOR_MATERIAL, \
glShadeModel, GL_SMOOTH, GL_NORMALIZE, \
GL_BLEND, glBlendFunc, glClear, glClearColor, \
glClearDepth, GL_COLOR_BUFFER_BIT, GL_CULL_FACE, \
GL_DEPTH_BUFFER_BIT, glDepthFunc, GL_DEPTH_TEST, \
GLdouble, glGetDoublev, glGetIntegerv, GLint, \
GL_LEQUAL, glLoadIdentity, glMatrixMode, GL_MODELVIEW, \
GL_MODELVIEW_MATRIX, GL_ONE_MINUS_SRC_ALPHA, glOrtho, \
GL_PROJECTION, GL_PROJECTION_MATRIX, glScalef, \
GL_SRC_ALPHA, glTranslatef, gluPerspective, gluUnProject, \
glViewport, GL_VIEWPORT
from pyglet import gl
from .trackball import trackball, mulquat, build_rotmatrix
from .trackball import trackball, mulquat
from .libtatlin.actors import vec
class wxGLPanel(wx.Panel):
......@@ -101,19 +113,19 @@ class wxGLPanel(wx.Panel):
# call the super method
super(wxGLPanel, self).Destroy()
#==========================================================================
# ==========================================================================
# GLFrame OpenGL Event Handlers
#==========================================================================
# ==========================================================================
def OnInitGL(self, call_reshape = True):
'''Initialize OpenGL for use in the window.'''
if self.GLinitialized:
return
self.GLinitialized = True
#create a pyglet context for this panel
# create a pyglet context for this panel
self.pygletcontext = gl.Context(gl.current_context)
self.pygletcontext.canvas = self
self.pygletcontext.set_current()
#normal gl init
# normal gl init
glClearColor(*self.color_background)
glClearDepth(1.0) # set depth value to 1
glDepthFunc(GL_LEQUAL)
......@@ -194,9 +206,9 @@ class wxGLPanel(wx.Panel):
self.draw_objects()
self.canvas.SwapBuffers()
#==========================================================================
# ==========================================================================
# To be implemented by a sub class
#==========================================================================
# ==========================================================================
def create_objects(self):
'''create opengl objects when opengl is initialized'''
pass
......@@ -209,15 +221,15 @@ class wxGLPanel(wx.Panel):
'''called in the middle of ondraw after the buffer has been cleared'''
pass
#==========================================================================
# ==========================================================================
# Utils
#==========================================================================
# ==========================================================================
def mouse_to_3d(self, x, y, z = 1.0):
x = float(x)
y = self.height - float(y)
# The following could work if we were not initially scaling to zoom on
# the bed
#if self.orthographic:
# if self.orthographic:
# return (x - self.width / 2, y - self.height / 2, 0)
pmat = (GLdouble * 16)()
mvmat = (GLdouble * 16)()
......
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