initial work on OpenGL
This commit is contained in:
parent
3ff0c79189
commit
a30d6e1170
26
svlgui.py
26
svlgui.py
|
|
@ -40,6 +40,9 @@ FRAMERATE=50
|
|||
#Width and height are the width and height of the document
|
||||
WIDTH, HEIGHT = 500, 500
|
||||
|
||||
#Whether we are using OpenGL for rendering.
|
||||
USING_GL = True
|
||||
|
||||
#Object which has the keyboard focus.
|
||||
FOCUS = None
|
||||
|
||||
|
|
@ -166,6 +169,9 @@ if sys.platform=="linux2":
|
|||
from GUI.StdMenus import basic_menus, file_cmds, print_cmds
|
||||
from GUI.StdButtons import DefaultButton, CancelButton
|
||||
from GUI.Files import FileType
|
||||
if USING_GL:
|
||||
from OpenGL.GL import *
|
||||
from GUI import GL
|
||||
from GUI.Geometry import offset_rect, rect_sized
|
||||
|
||||
#If we can import this, we are in the install directory. Mangle media paths accordingly.
|
||||
|
|
@ -789,6 +795,23 @@ class Canvas(Widget):
|
|||
self.canvas.connect("button-release-event", onMouseUp)
|
||||
self.canvas.connect("motion_notify_event", onMouseMove)
|
||||
elif SYSTEM=="osx":
|
||||
if USING_GL:
|
||||
class OSXCanvas(GL.GLView):
|
||||
def init_context(self):
|
||||
glViewport(0, 0, width, height);
|
||||
def init_projection(self):
|
||||
glEnable( GL_TEXTURE_2D );
|
||||
glEnable (GL_BLEND);
|
||||
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
def render(self):
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glLoadIdentity();
|
||||
gluOrtho2D(0, width, 0, height); #TODO: width, height
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
for i in self.objs:
|
||||
i.draw(None)
|
||||
self.canvas = OSXCanvas(double_buffer=True,multisample=True,samples_per_pixel=8)
|
||||
else:
|
||||
class OSXCanvas (ScrollableView):
|
||||
def draw(self, canvas, update_rect):
|
||||
canvas.erase_rect(update_rect)
|
||||
|
|
@ -1161,6 +1184,9 @@ class Shape (object):
|
|||
tb+="cr.stroke()\n"
|
||||
tb+="cr.restore()\n"
|
||||
elif SYSTEM=="osx":
|
||||
if USING_GL:
|
||||
pass
|
||||
else:
|
||||
cr.gsave()
|
||||
if sep=="\\":
|
||||
# Very ugly hack for Windows. :(
|
||||
|
|
|
|||
Loading…
Reference in New Issue