Quick hack of Nehe Tutorial 5. I got a yellow max2d box on screen and a rotating triangle. Problems:
- DrawText removes all OpenGL stuff from screen. - I can't clear the color buffer of use Cls as either Max2D or GL stuff disappears.
I would appreciate any help towards a rock solid Max2D/OpenGL implementation :)
Framework BRL.GLMax2D
SetGraphicsDriver GLMax2DDriver()
Graphics 640,480,0
Global rtri:Float 'Angle For The Triangle ( New )
While Not KeyHit( KEY_ESCAPE )
SetColor(255,255,0)
DrawRect(0,0,640,100)
SetColor(0,0,255)
'DrawText("Hello GL!",0,0) '<- This removes all OpenGL stuff on screen
' Triangle background not cleared, as I can't clear the color buffer or use CLS
DoGl()
Flip()
Wend
Function DoGL()
glPushMatrix
glenable GL_DEPTH_TEST 'Enables Depth Testing
glMatrixMode GL_PROJECTION 'Select The Projection Matrix
glLoadIdentity 'Reset The Projection Matrix
glFrustum -0.1, 0.1,-0.1, 0.1, 0.1, 100.0 'Setup The Projection Matrix Frustum
glMatrixMode GL_MODELVIEW 'Select The ModelView Matrix
glLoadIdentity 'Reset The ModelView Matrix
glClear GL_DEPTH_BUFFER_BIT 'Clear The Screen And The Depth Buffer
glLoadIdentity 'Reset The ModelView Matrix
glTranslatef -1.5,0.0,-6.0 'Move Left 1.5 Units And Into The Screen 6.0
glRotatef rtri,1.0,1.0,0.0 'Rotate The Triangle On The Y axis ( New )
glBegin GL_TRIANGLES 'Drawing Using Triangles
glColor3f 1.0,0.0,0.0 'Red
glVertex3f 0.0, 1.0, 0.0 'Top Of Triangle (Front)
glColor3f 0.0,1.0,0.0 'Green
glVertex3f -1.0,-1.0, 1.0 'Left Of Triangle (Front)
glColor3f 0.0,0.0,1.0 'Blue
glVertex3f 1.0,-1.0, 1.0 'Right Of Triangle (Front)
glColor3f 1.0,0.0,0.0 'Red
glVertex3f 0.0, 1.0, 0.0 'Top Of Triangle (Right)
glColor3f 0.0,0.0,1.0 'Blue
glVertex3f 1.0,-1.0, 1.0 'Left Of Triangle (Right)
glColor3f 0.0,1.0,0.0 'Green
glVertex3f 1.0,-1.0, -1.0 'Right Of Triangle (Right)
glColor3f 1.0,0.0,0.0 'Red
glVertex3f 0.0, 1.0, 0.0 'Top Of Triangle (Back)
glColor3f 0.0,1.0,0.0 'Green
glVertex3f 1.0,-1.0, -1.0 'Left Of Triangle (Back)
glColor3f 0.0,0.0,1.0 'Blue
glVertex3f -1.0,-1.0, -1.0 'Right Of Triangle (Back)
glColor3f 1.0,0.0,0.0 'Red
glVertex3f 0.0, 1.0, 0.0 'Top Of Triangle (Left)
glColor3f 0.0,0.0,1.0 'Blue
glVertex3f -1.0,-1.0,-1.0 'Left Of Triangle (Left)
glColor3f 0.0,1.0,0.0 'Green
glVertex3f -1.0,-1.0, 1.0 'Right Of Triangle (Left)
glEnd 'Finished Drawing The Pyramid
rtri:+1
glPopMatrix
End Function
|