'
' -- openGL example pyramid + cube, nehe 5 by frank bruebach, 22-10-2023, 14-07-2024
' -- oxygenbasic, with fonts
'
'includepath "$\inc\"
$ FileName "testOpglNehe5.exe"
'include "RTL32.inc"
'include "RTL64.inc"
$ title "Rotating cube + pyramid (nehe 5) + fonts"
$ fontA = "Arial",FW_SEMIBOLD
int width=640
int height=480
uses OpenglSceneFrame.inc
sub Initialize(sys hWnd)
'=======================
end sub
'
procedure drawPyramid() 'test
=======================
static single ang1,angi1
static single framecounter
framecounter++
gltranslatef -0.5,0.5,-1
glrotatef angi1,0.0,1.0,0.0
'glscalef 0.01,0.01,0.01
glscalef 1.5,1.5,1.5
glBegin GL_TRIANGLE_FAN
glColor3f 0, 128, 255 : glVertex3i 0.0, 1.0, 0.0
glColor3f 255, 0, 0 : glVertex3i -1.0, -1.0, 1.0
glColor3f 255, 255, 255 : glVertex3i 1.0, -1.0, 1.0
glColor3f 0, 0, 255 : glVertex3i 1.0, -1.0, -1.0
glColor3f 0, 255, 0 : glVertex3i -1.0, -1.0, -1.0
glColor3f 255, 0, 0 : glVertex3i -1.0, -1.0, 1.0
glEnd
angi1 += 180.0/framecounter
end procedure
sub Scene(sys hWnd)
'==================
'
static single ang1,angi1=1
'
NewFrame
glClearColor 0.5, 0.5, 0.7, 0.0
glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
Fog 0.5, 0.5, 0.7, 0.05 'rgb and density
glLoadIdentity
gltranslatef -1.0, -1.0, -8.0 '-6.0
glrotatef ang1, 0.0, 0.0, 1.0
'
''glBegin GL_TRIANGLES
''glColor3f 1.0, 0.0, 0.0 : glVertex3f 0.0, 1.0, 0.0
''glColor3f 0.0, 1.0, 0.0 : glVertex3f -1.0, -1.0, 0.0
''glColor3f 0.0, 0.0, 1.0 : glVertex3f 1.0, -1.0, 0.0
''glEnd
glLoadIdentity
gltranslatef 2.0, 0.0, -6.0
glscalef 0.75,0.75,0.75
glrotatef ang1, 0.0, 1.0, 1.0
glBegin GL_QUADS ' Drawing using Quads
' Top Quad
glColor3f 0, 255, 0 ' Green
glVertex3f 1.0, 1.0, -1.0 ' Top Right
glVertex3f -1.0, 1.0, -1.0 ' Top Left
glVertex3f -1.0, 1.0, 1.0 ' Bottom Left
glVertex3f 1.0, 1.0, 1.0 ' Bottom Right
' Bottom Quad
glColor3f 255, 127, 0 ' Orange
glVertex3f 1.0, -1.0, 1.0 ' Top Right
glVertex3f -1.0, -1.0, 1.0 ' Top left
glVertex3f -1.0, -1.0, -1.0 ' Bottom Left
glVertex3f 1.0, -1.0, -1.0 ' Bottom Right
' Front Quad
glColor3f 255, 0, 0 ' Red
glVertex3f 1.0, 1.0, 1.0 ' Top Right
glVertex3f -1.0, 1.0, 1.0 ' Top Left
glVertex3f -1.0, -1.0, 1.0 ' Bottom Left
glVertex3f 1.0, -1.0, 1.0 ' Bottom Right
' Back Quad
glColor3f 255, 255, 0 ' Yellow
glVertex3f 1.0, -1.0, -1.0 ' Bottom Left
glVertex3f -1.0, -1.0, -1.0 ' Bottom Right
glVertex3f -1.0, 1.0, -1.0 ' Top Right
glVertex3f 1.0, 1.0, -1.0 ' Top Left
' Left Quad
glColor3f 0, 0, 255 ' Blue
glVertex3f -1.0, 1.0, -1.0 ' Top Right
glVertex3f -1.0, -1.0, -1.0 ' Top Left
glVertex3f -1.0, -1.0, 1.0 ' Bottom Left
glVertex3f -1.0, 1.0, 1.0 ' Bottom Right
' Right Quad
glColor3f 255, 0, 255 ' Violet
glVertex3f 1.0, 1.0, -1.0 ' Top Right
glVertex3f 1.0, 1.0, 1.0 ' Top Left
glVertex3f 1.0, -1.0, 1.0 ' Bottom Left
glVertex3f 1.0, -1.0, -1.0 ' Bottom Right
glEnd
'UPDATE ROTATION ANGLES
'----------------------
'
glLoadIdentity
gltranslatef -1.0, 0.0, -6.0 '-4.0
drawpyramid()
'---------------- //
glPushMatrix
'
glLoadIdentity
static int framecount
sys x,y
framecount++
gltranslatef -.5,.25,-4.0
'glColor3f .99,.50,.50
glColor3f .99,.20,.20
glscalef .2,.2,.01
gprint str(framecount)
'
glpopmatrix
glpushMatrix
'glClearColor 0.8, 0.3, 0.5, 0
glscalef .2,.2,.01
glRotatef 90.0,0,0,1
gprint "Hello Oxygen OpenGL"
glPopMatrix
ang1+=angi1
if ang1>360 then ang1-=360
'
glLoadIdentity
glpushMatrix
gltranslatef 2.0, 0.0, -4.0
'glClearColor 0.8, 0.3, 0.5, 0
glscalef .2,.2,.01
glRotatef 90.0,0,0,1
gprint "Hello nehe 5 example"
glPopMatrix
ang1+=angi1
if ang1>360 then ang1-=360
'
end sub
sub Release(sys hwnd)
'====================
end sub
' test macros
'
macro join (a,b) 'macro join ? (a,b) 'no way
'a & b 'doesnt work with &
a + b
end macro
print join 2,4 '6 go
print join "a","b" '' ab go
print join ("a","b") '' ab go
dim s1 as string = join (3,8) '11 -> ok
'dim s1 as string = join 3,8 ' doesnt work without () , not ok, undefined type for 8
print s1 '11 ok
dim s1 as string = join ("W","Y") + join ("X", "Y")
'dim s1 as string = join "W","Y" '' + join + "X", "Y" ' undefined type for "Y" problem
print s1
dim s2 as string = join ("W","Y") + join ("X", "Y")
'dim s3 as string = join( "W" + join( "X", "Y") ) ' not found [b
'dim s4 as string = join + join ("W", "X") '' not found [b
print s2 '' WYXY WYXY
'print s3
'print s4
macro cube(v)
v*v*v
end macro
print cube 3 '27 ok
macro cube(v)
v+v-v
end macro
print cube "a","c" 'aaac ok
'
' problem with testing and calling a function for a dll
'
declare function dosome lib "Avengerbasic2.dll" () as sys
declare function recursivefactorial lib "Avengerbasic2.dll" (int s) as sys
' missing or unloadable recursivefactorial
Solved! Sorry.. "recursiveFactorial" must be the Name of the function exactly Like in my dll
'recursiveFactorial (ByVal n As Integer) As sys export
dosome
Print recursiveFactorial(4) ' 24 ''
Print recursiveFactorial(6) ' 720
All OK Here .. my mistake
'
' problem with testing and calling a function for a dll
'
declare function dosome lib "Avengerbasic2.dll" () as sys
declare function recursivefactorial(byval n as integer) lib "Avengerbasic2.dll" () as sys
' line 5 not found as
'recursiveFactorial (ByVal n As Integer) As sys export
dosome
Print recursiveFactorial(4) ' 24 ''
Print recursiveFactorial(6) ' 720
uses console
cls
printl "Redim String Test in procedure"
printl
int count = 20
redim string dat(count)
printl "count = " count
dat(10) = "Hello" : dat(11) = "World!"
printl dat(10) " " dat(11) : printl
'dat(40) = "Goodbye!" // will crash, which is ok
count += 20
printl "count = " count
redim string dat(count)
dat(40) = "Goodbye!"
printl dat(10) " " dat(11) " " dat(40) : printl
sub Extend_dat(string *data(Redim), int *cnt)
printl "in Extend_dat procedure:"
printl "cnt = " cnt
printl data(10) " " data(11) " " data(40) : printl
cnt +=20
printl "cnt = " cnt
redim string data(cnt)
data(60) = "See you later!"
printl data(10) " " data(11) " " data(40) " " data(60) : printl
end sub
Extend_dat(dat(), count)
printl "After Extend_dat procedure:"
printl "count = " count
printl dat(10) " " dat(11) " " dat(40) " " dat(60)
printl
printl "Enter ..." : waitkey
sub Extend_dat(string* dat(redim), int count)
sub Extend_dat(int count)
Page created in 0.375 seconds with 10 queries.