Hmm I've had some time to tinker with this a bit and there are still some concepts that are escaping me. I sort of don't know what I don't know with OpenGL. Since I've read the responses here and am still feeling a bit lost perhaps I could post what I do have.
Here is my initial setup.
' initiates Opengl
AppTitle = "Gun Ranger X Recode"
GLGraphics 800, 600
glEnable(GL_DEPTH_TEST)
glEnable(GL_LIGHTING)
glEnable(GL_LIGHT0)
glMatrixMode(GL_PROJECTION)
glOrtho(0, 800, 600, 0, 1000, - 1000)
glMatrixMode(GL_MODELVIEW)
glClearColor(color_1.r, color_1.g, color_1.b, 1.0)
Global light_position:Float[] =[- .5, - .5, - .5, 0.0]
glLightfv(GL_LIGHT0, GL_POSITION, light_position)
glShadeModel(GL_SMOOTH)
Please feel free to correct me on anything in this.
This is my rendering loop.
Method draw()
glLoadIdentity()
' enable lights for rendering
glEnable(GL_LIGHTING)
glEnable(GL_LIGHT0)
' set perspective to draw sky scrapers with perspective
set_perspective()
update_scrapers()
' attempt to return to ortho mode for rendeing shapes without perspective
set_ortho()
cell_material.set_material()
update_cells()
'disable lighting for our flat 2d elements
glDisable(GL_LIGHTING)
update_ship_shots()
player.update()
update_cell_shots()
glColor3f(color_3.r, color_3.g, color_3.b)
glTranslatef(0.0, 0.0, 0.0)
GLDrawRect(0, 0, 200, 600)
GLDrawRect(600, 0, 200, 600)
glColor3f(color_2.r, color_2.g, color_2.b)
glTranslatef(0.0, 0.0, - 0.1)
GLDrawRect(192, 0, 4, 600)
GLDrawRect(604, 0, 4, 600)
GLDrawRect(200, 400, 400, 1)
GLDrawText("Score: " + score, 16, 16)
GLDrawText("Level: " + level, 16, 32)
' draw lives
For Local i:Int = 0 To lives - 1
GLDrawRect(8 + (i * 16), 64, 14, 14)
Next
glTranslatef(0.0, 0.0, - 0.2)
glColor3f(color_1.r, color_1.g, color_1.b)
For Local i:Int = 0 To lives - 1
GLDrawRect(9 + (i * 16), 65, 12, 12)
Next
GLDrawText("Bomb: " + Int(player.scrape_percent * 100) + "%", 200, 600 - 14)
End Method
' functions for switching modes
Function set_ortho()
glViewport(0, 0, 800, 600) ;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 800.0, 600.0, 0.0) ;
glTranslatef(0.0, 0.0, 0.0)
End Function
Function set_perspective()
glMatrixMode(GL_PROJECTION) ;
gluPerspective(10.0, 800.0 / 600.0, 0.1, 100.0) ;
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
End Function
As soon as the perspective part finishes it refuses to draw my 3D shapes.
My 3D shapes are drawn like this maybe the problem lies there.
glloadidentity() ' reset any rotations and scaling
gltranslatef( position_x,position_y,position,z) ' move to desired location
glrotate(direction_of_travel) ' rotate to direction of travel
draw_shape() ' call the shape
Sorry, I don't want it to seem that I'm not listening but I am reading the provided links and trying to grasp what is going on. I thought maybe the information clashes with something that I am doing wrong.