2 # demo of laminar.PanelOverlaySurface, by
4 # based on version of Nehe's OpenGL lesson04
5 # by Paul Furber 2001 - m@verick.co.za
7 # you need pgu to be installed, and you need a copy of the default theme directory
8 # as 'test_theme', and you need the accompanying config.txt in that test_theme dir.
11 sys
.path
.insert( 0, '..' )
13 from OpenGL
.GL
import *
14 from OpenGL
.GLU
import *
16 from pygame
.locals import *
19 from pgu
import gui
as pgui
26 def resize((width
, height
)):
29 glViewport(0, 0, width
, height
)
30 glMatrixMode(GL_PROJECTION
)
32 gluPerspective(45, 1.0*width
/height
, 0.1, 100.0)
33 glMatrixMode(GL_MODELVIEW
)
37 glShadeModel(GL_SMOOTH
)
38 glClearColor(0.0, 0.5, 0.0, 0.0)
40 glEnable(GL_DEPTH_TEST
)
41 glDepthFunc(GL_LEQUAL
)
42 glHint(GL_PERSPECTIVE_CORRECTION_HINT
, GL_NICEST
)
46 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT
)
48 glTranslatef(-1.5, 0.0, -6.0)
52 glRotatef(rtri
, 0.0, 1.0, 0.0)
55 glColor3f(1.0, 0.0, 0.0)
56 glVertex3f(0.0, 1.0, 0.0)
57 glColor3f(0.0, 1.0, 0.0)
58 glVertex3f(-1.0, -1.0, 0)
59 glColor3f(0.0, 0.0, 1.0)
60 glVertex3f(1.0, -1.0, 0)
65 glTranslatef(1.5, 0.0, -6.0)
67 glRotatef(rquad
, 1.0, 0.0, 0.0)
69 glColor3f(0.5, 0.5, 1.0)
71 glVertex3f(-1.0, 1.0, 0)
72 glVertex3f(1.0, 1.0, 0)
73 glVertex3f(1.0, -1.0, 0)
74 glVertex3f(-1.0, -1.0, 0)
85 global rtri
, rquad
, gui_screen
86 video_flags
= OPENGL|DOUBLEBUF
89 pygame
.display
.set_mode((640,480), video_flags
)
90 font
= pygame
.font
.SysFont("default", 18)
91 fontBig
= pygame
.font
.SysFont("default", 24)
92 fontSub
= pygame
.font
.SysFont("default", 20)
93 theme
= pgui
.Theme('test_theme');
99 # create PanelOverlaySurface
100 # gui_screen = lamina.LaminaPanelSurface((640,480), (-3.3, 2.5, 6.6, 5))
101 gui_screen
= lamina
.LaminaScreenSurface()
103 gui
= pgui
.App(theme
=theme
)
104 gui
._screen
= gui_screen
.surf
106 # func to toggle triangle spin
110 # func to toggle quad spin
115 # create page # layout using document
116 lo
= pgui
.Container(width
=640)
119 title
= pgui
.Label("Lamina Demo : PGU", font
=fontBig
)
122 # create triangle button, connect to triTog handler function,
124 btn1
= pgui
.Button("Stop/Start Triangle")
125 btn1
.connect(pgui
.CLICK
, triTog
)
127 btn2
= pgui
.Button("Stop/Start Quad")
128 btn2
.connect(pgui
.CLICK
, quadTog
)
133 ticks
= pygame
.time
.get_ticks()
135 event
= pygame
.event
.poll()
136 if event
.type == QUIT
or (event
.type == KEYDOWN
and event
.key
== K_ESCAPE
):
139 # handle gui events and raster updating
141 chg
= gui
.update(gui_screen
.surf
)
143 gui_screen
.refresh(chg
)
148 # update rotation counters
154 # make changes visible
155 pygame
.display
.flip()
158 print "fps: %d" % ((frames
*1000)/(pygame
.time
.get_ticks()-ticks
))
161 if __name__
== '__main__': main()