Hello
i'm having problems when i modified the QuadRotate.o2bas example code to draw cube and diamond
and the results are just blank screens.
can someone help me on this, the code is listed below
includepath "$\inc\"
$ FileName "QuadRotate.exe"
'include "RTL32.inc"
include "RTL64.inc"
$ title "Rotating Quad"
include "OpenglSceneFrame.inc"
sub initialize(sys hWnd)
'=======================
end sub
'
sub scene(sys hWnd)
'==================
'
static single s1,s2,s3,s4,ang1,angi1=1
'
glLoadIdentity
glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
' glClearColor 0.5, 0, 0, 0
glClearColor 1.1,.5,0,1
'
'
s1=.2 'x y
s2=-1 'z
s3=0.5 'color
s4=s3*.2 'color
'
glrotatef ang1, 0,0,1
'
' original square -- this work
' glbegin GL_QUADS
' glcolor4f 00, s3, s3, 1 : glvertex3f -s1, -s1, s2
' glcolor4f s3, s3, 00, 1 : glvertex3f s1, -s1, s2
' glcolor4f s4, 0, s3, 1 : glvertex3f s1, s1, s2
' glcolor4f s4, 0, s3, 1 : glvertex3f -s1, s1, s2
' glend
' draw triangle fan -- does NOT work
glBegin GL_QUADS
glcolor3ub 0,255,0 : glvertex2f 0,2 '1st triangle
glcolor3ub 255,0,255 : glvertex2f -2,0
glcolor3ub 0,255,255 : glvertex2f -1,-1
glcolor3ub 128,0,255 : glvertex2f 0,-0.8 '2nd
glcolor3ub 255,128,0 : glvertex2f 2,-1.1 '3rd
glcolor3ub 255,128,0 : glvertex2f 3,0 '4th
glEnd
' Draw cube -- does NOT work
' glBegin GL_QUADS
' glcolor3ub 255,0,0
' glVertex3f 0.5, 0.5, -0.5 ' Top right of the quad (Top)
' glVertex3f -0.5, 0.5, -0.5 ' Top left of the quad (Top)
' glVertex3f -0.5, 0.5, 0.5 ' Bottom left of the quad (Top)
' glVertex3f 0.5, 0.5, 0.5 ' Bottom right of the quad (Top)
' glcolor3ub 255,255,0
' glVertex3f 0.5, -0.5, 0.5 ' Top right of the quad (Bottom)
' glVertex3f -0.5, -0.5, 0.5 ' Top left of the quad (Bottom)
' glVertex3f -0.5, -0.5, -0.5 ' Bottom left of the quad (Bottom)
' glVertex3f 0.5, -0.5, -0.5 ' Bottom right of the quad (Bottom)
' glcolor3ub 255,0,255
' glVertex3f 0.5, 0.5, 0.5 ' Top right of the quad (Front)
' glVertex3f -0.5, 0.5, 0.5 ' Top left of the quad (Front)
' glVertex3f -0.5, -0.5, 0.5 ' Bottom left of the quad (Front)
' glVertex3f 0.5, -0.5, 0.5 ' Bottom right of the quad (Front)
' glcolor3ub 0,0,255
' glVertex3f 0.5, -0.5, -0.5 ' Top right of the quad (Back)
' glVertex3f -0.5, -0.5, -0.5 ' Top left of the quad (Back)
' glVertex3f -0.5, 0.5, -0.5 ' Bottom left of the quad (Back)
' glVertex3f 0.5, 0.5, -0.5 ' Bottom right of the quad (Back)
' glcolor3ub 0,255,255
' glVertex3f -0.5, 0.5, 0.5 ' Top right of the quad (Left)
' glVertex3f -0.5, 0.5, -0.5 ' Top left of the quad (Left)
' glVertex3f -0.5, -0.5, -0.5 ' Bottom left of the quad (Left)
' glVertex3f -0.5, -0.5, 0.5 ' Bottom right of the quad (Left)
' glcolor3ub 255,128,0
' glVertex3f 0.5, 0.5, -0.5 ' Top right of the quad (Right)
' glVertex3f 0.5, 0.5, 0.5 ' Top left of the quad (Right)
' glVertex3f 0.5, -0.5, 0.5 ' Bottom left of the quad (Right)
' glVertex3f 0.5, -0.5, -0.5 ' Bottom right of the quad (Right)
' glEnd
' DrawDiamond -- does NOT work
'glbegin GL_QUADS
' glcolor3ub 255, 0, 0 : glvertex3f 0, .1414, 0
' glcolor3ub 0, 255, 0 : glvertex3f .1, 0, 1
' glcolor3ub 0, 0, 255 : glvertex3f .1, 0,-1
' glcolor3ub 0, 255, 0 : glvertex3f -.1, 0,-1
' glcolor3ub 0, 0, 255 : glvertex3f -.1, 0, 1
' glcolor3ub 0, 255, 0 : glvertex3f .1, 0, 1
' glend
' glbegin GL_QUADS
' glcolor3ub 255, 0, 0 : glvertex3f 0,-.1414, 0
' glcolor3ub 0, 255, 0 : glvertex3f .1, 0, 1
' glcolor3ub 0, 0, 255 : glvertex3f -.1, 0, 1
' glcolor3ub 0, 255, 0 : glvertex3f -.1, 0,-1
' glcolor3ub 0, 0, 255 : glvertex3f .1, 0,-1
' glcolor3ub 0, 255, 0 : glvertex3f .1, 0, 1
' glend
'
'UPDATE ROTATION ANGLES
'----------------------
'
ang1+=angi1
if ang1>360 then ang1-=360
'
end sub
sub Release(sys hwnd)
'====================
end sub