a) here's a little "openGL Class" example with a pyramid and a grid.
b) my question:
is there any example for a "cWindows" class example (like Jose Roca did it for powerbasic) for simple "helloWin" sdk win api?
a) example code:
'updated 6/18/2011
'08:47 22/06/2011 CP
'2011.06.30 00:55 KS
'2013.03.11 09:30 Frankolino :-)
'$ FileName "t.exe"
'include "..\..\inc\RTL32.inc"
'include "..\..\inc\RTL64.inc"
'When you see a method that starts with Create
'that means you must also at the end call an
'appropriate method that starts with Destroy
'Parameters/Arguements have an "a" prefix standing for arguement
'
'OxygenBasic Folder "projectsB"/"GLWINDOW"
#include "cGLWindow3.inc"
class ctest
dim cGLWindow win
static sys lucy 'TTFont
static sys funny 'TTFont
dim cTimerLowRes t
dim as sys i,j,lList,lPos,lSize
method main()
'============
win.Constructor(aInputProc = @Input, aRenderProc = @Render)
win.Create ( aWidth = 800, aHeight = 600 )'( aWidth = 1024, aHeight = 768 )
lucy = win.CreateTTFont "Lucida Console", 16
funny = win.CreateTTFont "Comic Sans MS" , 12
t.Constructor
win.MsgLoop
win.Destructor
end method
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
end if
'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
glbegin GL_TRIANGLE_FAN
glColor3f 0, 128, 255 : glVertex3f 0.0, 1.0, 0.0
glColor3f 255, 0, 0 : glVertex3f -1.0, -1.0, 1.0
glColor3f 255, 255, 255 : glVertex3f 1.0, -1.0, 1.0
glColor3f 0, 0, 255 : glVertex3f 1.0, -1.0, -1.0
glColor3f 0, 255, 0 : glVertex3f -1.0, -1.0, -1.0
glColor3f 255, 0, 0 : glVertex3f -1.0, -1.0, 1.0
glend
GLBegin GL_LINES
GLColor3f 0,255,0
'For i = -lSize To lSize
For i = -10 To 10
'For j = -lSize To lSize
For j = -10 To 10
'glVertex3f -lSize, lPos, j
glVertex3f -10, -1, j
'glVertex3f lSize, lPos, j
glVertex3f 10, -1, j
'glVertex3f i, lPos, -lSize
glVertex3f i, -1, -10
'glVertex3f i, lPos, lSize
glVertex3f i, -1, 10
Next
Next
GLEnd
glPopMatrix
win.BeginTextMode
win.SetTTFont lucy
glColor3f 0, 255, 0
win.Print 0.1 * Win.GetWidth, 0.75 * win.GetHeight, "Just Testing the GLWindow Class"
win.SetTTFont funny
glColor3f 255, 200, 0
string p=str(t.GetFPS(),2)
win.Print 0.1 * Win.GetWidth, .25 * Win.GetHeight, "Comic Sans MS fps: " p
win.EndTextMode
win.Flip
end sub
function Shutdown() as bool
win.Destroy()
win.DestroyTTFont lucy
win.DestroyTTFont funny
return 1
end function
sub Input() callback
select case win.KeyEvent 'read once and clear
case 0
exit sub
case VK_ESCAPE
Shutdown
case "Q"
Shutdown
case VK_RETURN
win.Reset
win.DestroyTTFont lucy
win.DestroyTTFont funny
win.ToggleFullScreen
win.Remake
lucy = win.CreateTTFont "Lucida Console", 16
funny = win.CreateTTFont "Comic Sans MS" , 12
end select
end sub
sub drawPyramid()
glbegin GL_TRIANGLE_FAN
glColor3f 0, 128, 255 : glVertex3f 0.0, 1.0, 0.0
glColor3f 255, 0, 0 : glVertex3f -1.0, -1.0, 1.0
glColor3f 255, 255, 255 : glVertex3f 1.0, -1.0, 1.0
glColor3f 0, 0, 255 : glVertex3f 1.0, -1.0, -1.0
glColor3f 0, 255, 0 : glVertex3f -1.0, -1.0, -1.0
glColor3f 255, 0, 0 : glVertex3f -1.0, -1.0, 1.0
glend
end sub
end class
ctest t
t.main
you need the #include "cGLWindow3.inc" file for it : OxygenBasic Folder "projectsB"/"GLWINDOW"
best regards, frank
X