2 from wxPython
.wx
import *
4 from wxPython
.glcanvas
import *
9 #----------------------------------------------------------------------
12 def runTest(frame
, nb
, log
):
13 dlg
= wxMessageDialog(frame
, 'The wxGLCanvas has not been included with this build of wxPython!',
14 'Sorry', wxOK | wxICON_INFORMATION
)
21 def runTest(frame
, nb
, log
):
22 win
= TestGLCanvas(nb
)
27 class TestGLCanvas(wxGLCanvas
):
28 def __init__(self
, parent
):
29 wxGLCanvas
.__init
__(self
, parent
, -1)
30 EVT_ERASE_BACKGROUND(self
, self
.OnEraseBackground
)
33 def OnEraseBackground(self
, event
):
34 pass # Do nothing, to avoid flashing.
37 def OnSize(self
, event
):
38 size
= self
.GetClientSize()
39 if self
.GetContext() != 'NULL':
41 glViewport(0, 0, size
.width
, size
.height
)
44 def OnPaint(self
, event
):
47 ctx
= self
.GetContext()
48 if ctx
== "NULL": return
57 # clear color and depth buffers
58 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT
);
60 # draw six faces of a cube
62 glNormal3f( 0.0, 0.0, 1.0)
63 glVertex3f( 0.5, 0.5, 0.5)
64 glVertex3f(-0.5, 0.5, 0.5)
65 glVertex3f(-0.5,-0.5, 0.5)
66 glVertex3f( 0.5,-0.5, 0.5)
68 glNormal3f( 0.0, 0.0,-1.0)
69 glVertex3f(-0.5,-0.5,-0.5)
70 glVertex3f(-0.5, 0.5,-0.5)
71 glVertex3f( 0.5, 0.5,-0.5)
72 glVertex3f( 0.5,-0.5,-0.5)
74 glNormal3f( 0.0, 1.0, 0.0)
75 glVertex3f( 0.5, 0.5, 0.5)
76 glVertex3f( 0.5, 0.5,-0.5)
77 glVertex3f(-0.5, 0.5,-0.5)
78 glVertex3f(-0.5, 0.5, 0.5)
80 glNormal3f( 0.0,-1.0, 0.0)
81 glVertex3f(-0.5,-0.5,-0.5)
82 glVertex3f( 0.5,-0.5,-0.5)
83 glVertex3f( 0.5,-0.5, 0.5)
84 glVertex3f(-0.5,-0.5, 0.5)
86 glNormal3f( 1.0, 0.0, 0.0)
87 glVertex3f( 0.5, 0.5, 0.5)
88 glVertex3f( 0.5,-0.5, 0.5)
89 glVertex3f( 0.5,-0.5,-0.5)
90 glVertex3f( 0.5, 0.5,-0.5)
92 glNormal3f(-1.0, 0.0, 0.0)
93 glVertex3f(-0.5,-0.5,-0.5)
94 glVertex3f(-0.5,-0.5, 0.5)
95 glVertex3f(-0.5, 0.5, 0.5)
96 glVertex3f(-0.5, 0.5,-0.5)
103 # set viewing projection
104 glMatrixMode(GL_PROJECTION
);
105 glFrustum(-0.5, 0.5, -0.5, 0.5, 1.0, 3.0);
108 glMatrixMode(GL_MODELVIEW
);
109 glTranslatef(0.0, 0.0, -2.0);
112 glRotatef(30.0, 1.0, 0.0, 0.0);
113 glRotatef(30.0, 0.0, 1.0, 0.0);
115 glEnable(GL_DEPTH_TEST
);
116 glEnable(GL_LIGHTING
);
138 #----------------------------------------------------------------------
143 frame
= wxFrame(NULL
, -1, "HELP ME!!")
144 win
= TestGLCanvas(frame
)
146 self
.SetTopWindow(frame
)
152 if __name__
== '__main__':