'updated 6/18/2011
'04:56 21/06/2011 CP
#include "g.inc"
'global vars
'
zxGLWindow win
sys lucy 'TTFont
sys funny 'TTFont
'
'main program
'
win.constructor
win.RenderCallBack @Render
win.InputCallBack @input
win.Create (iwidth=800, iheight=600)
lucy = win.CreateTTFont "Lucida Console", 16
funny = win.CreateTTFont "Comic Sans MS", 12
win.HandleMessages
win.destructor
'end program
'==========
' functions
'==========
sub Render() callback
'====================
static float rotation = 0
glClearColor 0, 0, 0, 0
glClear GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT
glLoadIdentity
glPushMatrix
glTranslatef 0, 0, -5
glRotatef rotation, 0, 1, 0
rotation+=.5
if rotation>360 then rotation-=360
glBegin GL_TRIANGLES
glColor3f 1, 0, 0 glVertex2f 0, 1
glColor3f 0, 1, 0 glVertex2f 0.87, -0.5
glColor3f 0, 0, 1 glVertex2f -0.87, -0.5
glEnd
glPopMatrix
'render some text to the screen
win.BeginTextMode
'set the color for the text
win.Font = lucy
glColor3f 0, 255, 0
win.Print win.Width * 0.1, win.Height * 0.75, "Just Testing the GLWindow Class"
win.Font = funny
glColor3f 255, 200, 0
win.Print win.Width * 0.1, win.Height * 0.25, "Testing Comic Sans MS"
win.EndTextMode
glFlush
SwapBuffers win.hDC
end sub
function Shutdown() as bool callback
'===================================
win.Destroy()
win.DestroyTTFont lucy
win.DestroyTTFont funny
return 1
end function
sub Input() callback
'===================
'exit the program
if win.KeyDown VK_ESCAPE then shutdown
'exit the program
if win.KeyDown 0x51 then shutdown
if win.KeyDown VK_RETURN then
win.Keys[ VK_RETURN ] = 0
win.DestroyWin()
win.DestroyTTFont lucy
win.DestroyTTFont funny
win.Fullscreen = 1-win.Fullscreen ' bool op
win.CreateWin()
lucy = win.CreateTTFont "Lucida Console", 16
funny = win.CreateTTFont "Comic Sans MS", 12
end if
end sub