Learning bumps...

BlitzMax Forums/BlitzMax OpenGL Programming/Learning bumps...

Hey, I'm trying to learn some raw openGL, unsurprisingly, using this is ungodly fast, I'm getting like 6000-8000+fps :O

Anyways, i'm trying to keep this box's orientation for the Y axis straight up and down.

Here's an example illistrating the problem... S/A for rotation increments, and UP/DOWN cursors for movement

SuperStrict

GLGraphics 800, 600

Global Vertices:Float[] = [-1.0, 1.0, -10.0, 1.0, 1.0, -10.0, 1.0, -1.0, -10.0, -1.0, -1.0, -10.0]' X Y X?
Global Colors:Float[] = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0] ' R G B?

'initalize stuff
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(45.0, 1.3333, 1, 1000)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()


Local r:Float = 0 'Rotation

Local _FPS:Int ' FPS
Local _FPSTICK:Int ' FPS ticker
Local _FPSTIME:Int = MilliSecs() ' FPS Timer

While Not KeyDown(KEY_ESCAPE)
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) 'Cls
	
	'Add/Subtract rotation value with S/A
	If KeyHit(KEY_S) r:+2
	If KeyHit(KEY_A) r:-2
	If r > 359 r = 0
	If r < 0 r = 359
	
	'TRY to move block up and down... Problems... trying to increment the Y value
	If KeyDown(KEY_UP) Vertices[1]:+.2 Vertices[4]:+.2 Vertices[7]:+.2 Vertices[10]:+.2
	If KeyDown(KEY_DOWN) Vertices[1]:-.2 Vertices[4]:-.2 Vertices[7]:-.2 Vertices[10]:-.2
	
	'Enable certain drawing states
	glEnableClientState(GL_VERTEX_ARRAY)
	glEnableClientState(GL_COLOR_ARRAY)
	
	'Draw box
	glRotated(r,0,0,-10.0) 'Setrotation() ?
	glColorPointer(3, GL_FLOAT, 0, Colors)
	glVertexPointer(3, GL_FLOAT, 0, Vertices)
	glDrawArrays(GL_QUADS, 0, 4)
	
	'Disable the enabled drawing states
	glDisableClientState(GL_VERTEX_ARRAY)
	glDisableClientState(GL_COLOR_ARRAY)
	
	'FPS updating
	GLDrawText _FPS,0,0
	_FPSTICK:+1
	If MilliSecs() > _FPSTIME+1000
		_FPS = _FPSTICK
		_FPSTICK = 0
		_FPSTIME = MilliSecs()
	End If
	
	Flip 1
Wend
End


Basicly, when the box is rotated, if you try to move it, it will move in the direction it's rotated in. NOT the direction up and down like I want it too.

Anyone know what i'm doing wrong?

Also any tutorials out there that can help me learn openGL would be appriciated!

Usually something like that would be to do with the order in which you are doing your `translates` and `rotates`. If you rotate first and then translate, the object will move along its rotated axis. You need to translate first to move it up, then do rotation.

Also in your example you are basically increasing the Y coordinates but within the `object's rotated coordinate space`, so you're moving up and down within the objects axis, not the screen axis. That's what happens when you add to the object's coordinates, trying to translate it manually. You have to move the entire object's coordinate system vertically, not just the vertexes within it. I think.

I'm not sure I get what you mean exactly.

I moved around the rotating routine, (notice the astriks)

SuperStrict

GLGraphics 800, 600

Global Vertices:Float[] = [-1.0, 1.0, -10.0, 1.0, 1.0, -10.0, 1.0, -1.0, -10.0, -1.0, -1.0, -10.0]' X Y X?
Global Colors:Float[] = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0] ' R G B?

'initalize stuff
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(45.0, 1.3333, 1, 1000)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()


Local r:Float = 0 'Rotation

Local _FPS:Int ' FPS
Local _FPSTICK:Int ' FPS ticker
Local _FPSTIME:Int = MilliSecs() ' FPS Timer

While Not KeyDown(KEY_ESCAPE)
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) 'Cls
	
	'Add/Subtract rotation value with S/A
	If KeyHit(KEY_S) r:+2
	If KeyHit(KEY_A) r:-2
	If r > 359 r = 0
	If r < 0 r = 359
	
	'TRY to move block up and down... Problems... trying to increment the Y value
	If KeyDown(KEY_UP) Vertices[1]:+.2 Vertices[4]:+.2 Vertices[7]:+.2 Vertices[10]:+.2
	If KeyDown(KEY_DOWN) Vertices[1]:-.2 Vertices[4]:-.2 Vertices[7]:-.2 Vertices[10]:-.2
	
	'Enable certain drawing states
	glEnableClientState(GL_VERTEX_ARRAY)
	glEnableClientState(GL_COLOR_ARRAY)
	
	'Draw box
	glColorPointer(3, GL_FLOAT, 0, Colors)
	glVertexPointer(3, GL_FLOAT, 0, Vertices)
	glDrawArrays(GL_QUADS, 0, 4)
	glRotated(r,0,0,-10.0) 'Setrotation() ? *************************************************
	
	'Disable the enabled drawing states
	glDisableClientState(GL_VERTEX_ARRAY)
	glDisableClientState(GL_COLOR_ARRAY)
	
	'FPS updating
	GLDrawText _FPS,0,0
	_FPSTICK:+1
	If MilliSecs() > _FPSTIME+1000
		_FPS = _FPSTICK
		_FPSTICK = 0
		_FPSTIME = MilliSecs()
	End If
	
	Flip 1
Wend
End


Also, what's the difference between rotatef and rotated?

Both produce the same error for me.

I was trying to learn ogl a while back. so I downloaded a few tutorial examples to help me learn but I got impatioent and gave up. follow the link to my signature and download the textured cube. it moves it along the z axis I thik all you have to do change from z to y and it should do what you want. it uses the mouse to rotate.

hmm, I tried gltranslatef()

still no avail...

SuperStrict

GLGraphics 800, 600

Global Vertices:Float[] = [-1.0, 1.0, -10.0, 1.0, 1.0, -10.0, 1.0, -1.0, -10.0, -1.0, -1.0, -10.0]' X Y X?
Global Colors:Float[] = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0] ' R G B?

'initalize stuff
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(45.0, 1.3333, 1, 1000)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()


Local r:Float = 0 'Rotation

Local _FPS:Int ' FPS
Local _FPSTICK:Int ' FPS ticker
Local _FPSTIME:Int = MilliSecs() ' FPS Timer

While Not KeyDown(KEY_ESCAPE)
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) 'Cls
	
	'Add/Subtract rotation value with S/A
	If KeyHit(KEY_S) r:+2
	If KeyHit(KEY_A) r:-2
	If r > 359 r = 0
	If r < 0 r = 359
	glRotatef(r,0,0,-10.0) 'Setrotation() ? *************************************************
	
	
	'TRY to move block up and down... Problems... trying to increment the Y value
	If KeyDown(KEY_UP) glTranslatef(0,-.2,0)
	If KeyDown(KEY_DOWN) glTranslatef(0,.2,0)
	
	'Enable certain drawing states
	glEnableClientState(GL_VERTEX_ARRAY)
	glEnableClientState(GL_COLOR_ARRAY)
	
	'Draw box
	glColorPointer(3, GL_FLOAT, 0, Colors)
	glVertexPointer(3, GL_FLOAT, 0, Vertices)
	glDrawArrays(GL_QUADS, 0, 4)
	
	'Disable the enabled drawing states
	glDisableClientState(GL_VERTEX_ARRAY)
	glDisableClientState(GL_COLOR_ARRAY)
	
	'FPS updating
	GLDrawText _FPS,0,0
	_FPSTICK:+1
	If MilliSecs() > _FPSTIME+1000
		_FPS = _FPSTICK
		_FPSTICK = 0
		_FPSTIME = MilliSecs()
	End If
	
	Flip 1
Wend
End


on the bright side that change did get rid of the 'off center' rotating...

Hmm, could it be because OpenGL by default assumes that the coordinate 0,0 are in the bottom left corner of the screen, and therefore a larger Y coord is actually nearer the top of the screen, so you're looking at your game world upside down?

SuperStrict

GLGraphics 800, 600

Global Vertices:Float[] = [-1.0, 1.0, -10.0, 1.0, 1.0, -10.0, 1.0, -1.0, -10.0, -1.0, -1.0, -10.0]' X Y X?
Global Colors:Float[] = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0] ' R G B?

'initalize stuff
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(45.0, 1.3333, 1, 1000)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()

Local r:Float = 0 'Rotation

Local _FPS:Int ' FPS
Local _FPSTICK:Int ' FPS ticker
Local _FPSTIME:Int = MilliSecs() ' FPS Timer
Local a:Float = 0
Local t:Float = 0.0
While Not KeyDown(KEY_ESCAPE)
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) 'Cls
	
	'Add/Subtract rotation value with S/A
	glLoadIdentity
	If KeyHit(KEY_LEFT) r:+2
	If KeyHit(KEY_RIGHT) r:-2
	If KeyDown(KEY_UP)  t:- 0.2
	If KeyDown(KEY_DOWN)t:+ 0.2
	a :+r
	a = a Mod 360 

	glTranslatef(0, t,0.0)
	'TRY to move block up and down... Problems... trying to increment the Y value
	glRotatef(a,0,0,1.0) 'Setrotation() ? *************************************************
	
	'Enable certain drawing states
	glEnableClientState(GL_VERTEX_ARRAY)
	glEnableClientState(GL_COLOR_ARRAY)
	
	'Draw box
	glColorPointer(3, GL_FLOAT, 0, Colors)
	glVertexPointer(3, GL_FLOAT, 0, Vertices)
	glDrawArrays(GL_QUADS, 0, 4)
	
	'Disable the enabled drawing states
	'glDisableClientState(GL_VERTEX_ARRAY)
	'glDisableClientState(GL_COLOR_ARRAY)
	
	'FPS updating
	GLDrawText _FPS,0,0
	_FPSTICK:+1
	If MilliSecs() > _FPSTIME+1000
		_FPS = _FPSTICK
		_FPSTICK = 0
		_FPSTIME = MilliSecs()
	End If
	
	Flip 1
Wend
End


Interesting, thanks jesse, i'll look it over...

Edit, can you explain what a/t are ?

Alright, I got that much, but now i'm trying to create a little mini engine to draw rects around...

How do I...

-Change prepective to 0,0 = top left cornor?
-Draw dimensions in pixels?

here's what I have so far, i'm stumped...

SuperStrict
Framework pub.OpenGL
Import BRL.GLGraphics

GLGraphics 800, 600


Type TGLPrimative
	Field X:Float,Y:Float
	Field Ox:Float,Oy:Float
	Field RotAngle:Int
	Field Width:Int,Height:Int
End Type


Type TGLQuad Extends TGLPrimative
	Field v1x:Float, v1y:Float
	Field v2x:Float, v2y:Float
	Field v3x:Float, v3y:Float
	Field v4x:Float, v4y:Float


	Method Init(_x:Float,_y:Float,w:Int,h:Int)
		X = _x/800
		Y = _y/600
		Width = w/800
		Height = h/600
		Ox = X
		Oy = Y
		
		'top left
		v1x = X
		v1y = Y
		'top right
		v2x = X+Width
		v2y = Y
		'bottom right
		v3x = X+Width
		v3y = Y-Height
		'bottom left
		v4x = X
		v4y = Y-Height
	End Method
	
	Method Render()
		glTranslatef(x-Ox, y-Oy,0)
		glRotatef(RotAngle,0,0,1.0)
		
		glBegin(GL_QUADS)
		
		glColor3f(.2,.6,.55)
		glVertex3f(v1x,v1y,-.0001)
		
		glColor3f(.22,.7,.9)
		glVertex3f(v2x,v2y,-.0001)
		
		glColor3f(.56,.2,.5)
		glVertex3f(v3x,v3y,-.0001)
		
		glColor3f(.33,.9,.2)
		glVertex3f(v4x,v4y,-.0001)
		
		glEnd()
	End Method
End Type


'other initalizing stuff
InitalizeGL() 'initalize opengl stuff (beyound my comprehension at the moment)
Local _FPS:Int ' FPS
Local _FPSTICK:Int ' FPS ticker
Local _FPSTIME:Int = MilliSecs() ' FPS Timer


Local MyBox:TGLQuad = New TGLQuad
MyBox.Init(200,200,100,100)


'Main loop, quit on KEY_ESCAPE
While Not KeyDown(KEY_ESCAPE)
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) 'Cls but opengl
	glLoadIdentity
	MyBox.Render()
	
	
	'FPS updating
	GLDrawText _FPS,0,0
	_FPSTICK:+1
	If MilliSecs() > _FPSTIME+1000
		_FPS = _FPSTICK
		_FPSTICK = 0
		_FPSTIME = MilliSecs()
	End If
	Flip 1
Wend
End

Function InitalizeGL()
	glMatrixMode(GL_PROJECTION)
	glLoadIdentity()
	gluPerspective(45.0, 1.3333, 1, 1000)
	glMatrixMode(GL_MODELVIEW)
	glLoadIdentity()
End Function


Nothing is being drawn oddly enough... I thought that 1.0 ment the whole screen so I divided 1 by 800 for x, which should give me pixels? I did the same for Y.

I also looked at the DrawRect function in GLGraphics.mod... What is BeginOrtho and EndOrtho? Does that have to do with changing prepective?

Thanks in advance!

Just to clarify(because my post above doesn't seem very clear):

-How does max2D draw in pixel units vs. whatever OGL uses (what does OGL use exactly?) And how many OGL measurements = how many pixels? This probably depends on the depth.

-How does Max2D draw from the top cornor of the screen?

-How do you move images seperatly, because Transitionf() seems to move the camera as a whole and not individual images.


PS. I'm not looking at 3d, simply 3d accelerated 2d like max2d (i'm trying to figure out how it works)

Thanks!

Have you tried the nehe tutorials? they might help you figure things out.

Just read them, they don't really explain a whole lot, other than how to do 3d tricks...

there is not much I can help you with either sence I am kind of where you are at right now.

I have some more code that might help you. hopefully this will help you with objects creation:
'********************************************************************
'********************************************************************
'* Example 3: A fully interactive 3D world with OpenGL              *
'********************************************************************
SuperStrict
Framework pub.OpenGL
Import BRL.GLGraphics

Global is_depth:Int; ' depth testing flag 

	GLGraphics 800, 600


	glMatrixMode(GL_PROJECTION)
	glLoadIdentity()
	gluPerspective(45.0, 1.3333, 1, 1000)
	glMatrixMode(GL_MODELVIEW)
	glLoadIdentity()
	init();
Repeat 
	display()
	keyboard()
 
	'this time we're going to keep the aspect ratio
	'constant by trapping the window resizes 

	resize()  
	Flip()
Until KeyDown(KEY_ESCAPE)


Function init()

	glClearColor(0.0, 0.0, 0.0, 0.0);
	glEnable(GL_DEPTH_TEST);
	is_depth = 1;
	glMatrixMode(GL_MODELVIEW);
End Function

Function display()

	If (is_depth)
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	Else
		glClear(GL_COLOR_BUFFER_BIT);
	EndIf
	' draw the Floor 
	glBegin(GL_QUADS);
		glColor3f(0.2, 0.2, 0.2);
		glVertex3f(-100.0, 0.0, -100.0);
		glColor3f(0.4, 0.4, 0.4);
		glVertex3f(-100.0, 0.0, 100.0);
		glColor3f(0.6, 0.6, 0.6);
		glVertex3f(100.0, 0.0, 100.0);
		glColor3f(0.8, 0.8, 0.8);
		glVertex3f(100.0, 0.0, -100.0);		
	glEnd();
	' draw 12 cubes with different colors 
	drawcube(75, 57, 2);
	drawcube(-65, -12, 3);
	drawcube(50, -50, 1);
	drawcube(-56, 17, 2);
	drawcube(67, 12, 3);
	drawcube(-87, 32, 1);
	drawcube(-26, 75, 2);
	drawcube(57, 82, 3);
	drawcube(-3, 12, 1);
	drawcube(46, 35, 2);
	drawcube(37, -2, 3);
End Function

Function keyboard()

	Rem This time the controls are:
	
	  "a": move Left
	  "d": move Right
	  "w": move forward
	  "s": move back
	  "t": toggle depth-testing

	EndRem
	Select True
	
		Case KeyDown(key_A)
			glTranslatef(5.0, 0.0, 0.0);
		Case KeyDown(KEY_D)
			glTranslatef(-5.0, 0.0, 0.0);
		Case KeyDown(KEY_W)
			glTranslatef(0.0, 0.0, 5.0);
		Case KeyDown(KEY_S)
			glTranslatef(0.0, 0.0, -5.0);
		Case KeyDown(KEY_T)
			If (is_depth)
			
				is_depth = 0;
				glDisable(GL_DEPTH_TEST);
			
			Else
			
				is_depth = 1;
				glEnable(GL_DEPTH_TEST);
			EndIf	
	EndSelect
	display();
End Function

Function resize(width:Int=1, height:Int=1)

	If height = 0 Then height = 1;
	
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	' note we divide our width by our height To get the aspect ratio 
	gluPerspective(45.0, width / height, 1.0, 400.0);

	' set initial position 
	glTranslatef(0.0, -5.0, -150.0);

	glMatrixMode(GL_MODELVIEW);

End Function

Function drawcube(x_offset:Int, z_offset:Int, color:Int)

	' this Function draws a cube centerd at (x_offset, z_offset)
	'x And z _big are the back And rightmost points, x And z _small are
	'the front And leftmost points 
	Local x_big:Float   = Float(x_offset + 5)
	Local z_big:Float   = Float(z_offset + 5)
	Local x_small:Float = Float(x_offset - 5)
	Local z_small:Float = Float(z_offset - 5)
	Select color
		Case 1
			glColor3f(1.0,0.0,0.0)
		Case 2
			glColor3f(0.0,1.0,0.0)
		Case 3
			glColor3f(0.0,0.0,1.0)
	End Select
	glBegin(GL_QUADS);
		glVertex3f(x_small,10.0,z_big); 'front
		glVertex3f(x_small,0.0,z_big);
		glVertex3f(x_big,0.0,z_big);
		glVertex3f(x_big,10.0,z_big);

		glVertex3f(x_big,10.0,z_small); ' back 
		glVertex3f(x_big,0.0,z_small);
		glVertex3f(x_small,0.0,z_small);
		glVertex3f(x_small,10.0,z_small);

		glVertex3f(x_big,10.0,z_big); ' Right 
		glVertex3f(x_big,0.0,z_big);
		glVertex3f(x_big,0.0,z_small);
		glVertex3f(x_big,10.0,z_small);

		glVertex3f(x_small,10.0,z_small); ' Left
		glVertex3f(x_small,0.0,z_small);
		glVertex3f(x_small,0.0,z_big);
		glVertex3f(x_small,10.0,z_big);

		glVertex3f(x_small,10.0,z_big); ' top 
		glVertex3f(x_big,10.0,z_big);
		glVertex3f(x_big,10.0,z_small);
		glVertex3f(x_small,10.0,z_small);

		glVertex3f(x_small,0.0,z_small); ' bottom 
		glVertex3f(x_big,0.0,z_small);
		glVertex3f(x_big,0.0,z_big);
		glVertex3f(x_small,0.0,z_big);
	glEnd();
End Function


Interesting, i'm trying to add rotation to your code (turning)


'********************************************************************
'********************************************************************
'* Example 3: A fully interactive 3D world with OpenGL *
'********************************************************************
SuperStrict
Framework pub.OpenGL
Import BRL.GLGraphics

Global is_depth:Int; ' depth testing flag 

GLGraphics 800, 600


glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(45.0, 1.3333, 1, 1000)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
init();
Repeat 
display()
keyboard()

'this time we're going to keep the aspect ratio
'constant by trapping the window resizes 

resize() 
Flip()
Until KeyDown(KEY_ESCAPE)


Function init()

glClearColor(0.0, 0.0, 0.0, 0.0);
glEnable(GL_DEPTH_TEST);
is_depth = 1;
glMatrixMode(GL_MODELVIEW);
End Function

Function display()

If (is_depth)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
Else
glClear(GL_COLOR_BUFFER_BIT);
EndIf
' draw the Floor 
glBegin(GL_QUADS);
glColor3f(0.2, 0.2, 0.2);
glVertex3f(-100.0, 0.0, -100.0);
glColor3f(0.4, 0.4, 0.4);
glVertex3f(-100.0, 0.0, 100.0);
glColor3f(0.6, 0.6, 0.6);
glVertex3f(100.0, 0.0, 100.0);
glColor3f(0.8, 0.8, 0.8);
glVertex3f(100.0, 0.0, -100.0); 
glEnd();
' draw 12 cubes with different colors 
drawcube(75, 57, 2);
drawcube(-65, -12, 3);
drawcube(50, -50, 1);
drawcube(-56, 17, 2);
drawcube(67, 12, 3);
drawcube(-87, 32, 1);
drawcube(-26, 75, 2);
drawcube(57, 82, 3);
drawcube(-3, 12, 1);
drawcube(46, 35, 2);
drawcube(37, -2, 3);
End Function

Function keyboard()

Rem This time the controls are:

"a": move Left
"d": move Right
"w": move forward
"s": move back
"t": toggle depth-testing

EndRem
Select True

Case KeyDown(key_A)
glTranslatef(5.0, 0.0, 0.0);
Case KeyDown(KEY_D)
glTranslatef(-5.0, 0.0, 0.0);
Case KeyDown(KEY_W)
glTranslatef(0.0, 0.0, 5.0);
Case KeyDown(KEY_S)
glTranslatef(0.0, 0.0, -5.0);
Case KeyDown(KEY_T)
If (is_depth)

is_depth = 0;
glDisable(GL_DEPTH_TEST);

Else

is_depth = 1;
glEnable(GL_DEPTH_TEST);
EndIf 
Case KeyDown(KEY_LEFT)
glRotatef(.5,0,-1,0)
Case KeyDown(KEY_RIGHT)
glRotatef(.5,0,1,0)
EndSelect
display();
End Function

Function resize(width:Int=1, height:Int=1)

If height = 0 Then height = 1;

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

' note we divide our width by our height To get the aspect ratio 
gluPerspective(45.0, width / height, 1.0, 400.0);

' set initial position 
glTranslatef(0.0, -5.0, -150.0);

glMatrixMode(GL_MODELVIEW);

End Function

Function drawcube(x_offset:Int, z_offset:Int, color:Int)

' this Function draws a cube centerd at (x_offset, z_offset)
'x And z _big are the back And rightmost points, x And z _small are
'the front And leftmost points 
Local x_big:Float = Float(x_offset + 5)
Local z_big:Float = Float(z_offset + 5)
Local x_small:Float = Float(x_offset - 5)
Local z_small:Float = Float(z_offset - 5)
Select color
Case 1
glColor3f(1.0,0.0,0.0)
Case 2
glColor3f(0.0,1.0,0.0)
Case 3
glColor3f(0.0,0.0,1.0)
End Select
glBegin(GL_QUADS);
glVertex3f(x_small,10.0,z_big); 'front
glVertex3f(x_small,0.0,z_big);
glVertex3f(x_big,0.0,z_big);
glVertex3f(x_big,10.0,z_big);

glVertex3f(x_big,10.0,z_small); ' back 
glVertex3f(x_big,0.0,z_small);
glVertex3f(x_small,0.0,z_small);
glVertex3f(x_small,10.0,z_small);

glVertex3f(x_big,10.0,z_big); ' Right 
glVertex3f(x_big,0.0,z_big);
glVertex3f(x_big,0.0,z_small);
glVertex3f(x_big,10.0,z_small);

glVertex3f(x_small,10.0,z_small); ' Left
glVertex3f(x_small,0.0,z_small);
glVertex3f(x_small,0.0,z_big);
glVertex3f(x_small,10.0,z_big);

glVertex3f(x_small,10.0,z_big); ' top 
glVertex3f(x_big,10.0,z_big);
glVertex3f(x_big,10.0,z_small);
glVertex3f(x_small,10.0,z_small);

glVertex3f(x_small,0.0,z_small); ' bottom 
glVertex3f(x_big,0.0,z_small);
glVertex3f(x_big,0.0,z_big);
glVertex3f(x_small,0.0,z_big);
glEnd();
End Function


It seems to be rotating the geometry and not the camera.

Oh well, I'll learn eventually, just got to keep at it :)

there are some video tutorials here if you are interested:
http://www.videotutorialsrock.com/
it is in c but most of it works in bmax and the concept should be the same.

If you use gluPerspective and you give it a `field of view angle`, it's very difficult to correlate that to an exact number of pixels so that you have a 1:1 match between pixel coords and world coords. I recommend that instead you use glFrustum() to create your perspective projection. You can then specify that you want the edges of your `near edge` to be 0,0 to 800,600 or whatever, and it should then map directly to the pixels on the screen so long as you don't move in Z and your near plane is at, I think, -1.0

If you use gluPerspective it's going to give you whatever coordinate system it comes up with based on the field of view.

What exactly IS max2d in it's open GL form? And how does it do everything in pixels?

I believe this is similar on how bmax does 2d.
but you can always look at the module source.
STRIPPED DOWN nehe tutorial 21:
Framework brl.GLGraphics 'Framework brl.blitzgl
Import brl.freeaudioaudio
Import brl.bmploader
Import brl.max2d
Import brl.random
Import brl.wavloader
Import brl.timer
Global ScreenWidth:Int=640
Global ScreenHeight:Int=480
Global ScreenDepth:Int=32

Global vline:Byte[11,11]							' Keeps Track Of Verticle Lines
Global hline:Byte[11,11]							' Keeps Track Of Horizontal Lines
Global filled:Byte								' Done Filling In The Grid?
Global gameover:Byte								' Is The Game Over?
Global anti:Byte=True								' Antialiasing?
Global active:Byte=True							' Window Active Flag Set To True By Default

Global loop1:Int									' Generic Loop1
Global loop2:Int									' Generic Loop2
Global pause:Int									' Enemy Delay
Global adjust:Int=3								' Speed Adjustment For Really Slow Video Cards
Global lives:Int=5								' Player Lives
Global level:Int=1								' Internal Game Level
Global level2:Int=level							' Displayed Game Level
Global stage:Int=1								' Game Stage

Type Objet										' Create A Structure For Our Player
	Field fx:Int, fy:Int							' Fine Movement Position
	Field x:Int, y:Int							' Current Player Position
	Field spin:Float								' Spin Direction
End Type

Global player:objet=New objet						' Player Information
Global timer=CreateTimer(60)						' Create a Timer (60 Hertz)
Global steps:Int[]=[1, 2, 4, 5, 10, 20]				' Stepping Values For Slow Video Adjustment
Global base:Int

result=Proceed("Would You Like To Run In Fullscreen Mode?")

Select result
	Case -1
		End
	Case 0
		GLGraphics(screenwidth,screenheight,0,0,gl_backbuffer | gl_depthbuffer | gl_window) '		bglCreateContext(ScreenWidth,ScreenHeight,ScreenDepth,0,BGL_BACKBUFFER | BGL_DEPTHBUFFER) ' | BGL_FULLSCREEN)
	Case 1
		GLGraphics(screenwidth,screenheight,screendepth,0,gl_backbuffer | gl_depthbuffer | gl_fullscreen) '		bglCreateContext(ScreenWidth,ScreenHeight,ScreenDepth,0,BGL_BACKBUFFER | BGL_DEPTHBUFFER | BGL_FULLSCREEN)
End Select

InitGl()

While Not KeyHit( KEY_ESCAPE )
	nehe21()
	Flip
Wend
End

Function InitGl()
	ResetObjects()
	glShadeModel(GL_SMOOTH)													' Enable Smooth Shading
	glClearColor(0.0, 0.0, 0.0, 0.5)										' Black Background
	glClearDepth(1.0)														' Depth Buffer Setup
	glHint(GL_LINE_SMOOTH_HINT, GL_NICEST)									' Set Line Antialiasing
	glEnable(GL_BLEND)														' Enable Blending
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)						' Type Of Blending To Use

	glViewport(0,0,ScreenWidth,ScreenHeight)								' Set viewport
	glMatrixMode(GL_PROJECTION)												' Select The Projection Matrix
	glLoadIdentity()														' Reset The Projection Matrix
	glOrtho(0.0,ScreenWidth,ScreenHeight,0.0,-1.0,1.0)						' Create Ortho 640x480 View (0,0 At Top Left)
	glMatrixMode(GL_MODELVIEW)												' Select The Modelview Matrix
	glLoadIdentity()
End Function

Function nehe21()
	WaitTimer(timer)

	If KeyHit(KEY_A)														' If 'A' Key Is Pressed And Not Held
		anti=Not anti														' Toggle Antialiasing
	EndIf
	
	If Not gameover														' If Game Isn't Over : Active Move Objects
		If (KeyDown(KEY_RIGHT)) And (player.x<10) And (player.fx=player.x*60) And (player.fy=player.y*40) Then
			hline[player.x,player.y]=True									' Mark The Current Horizontal Border As Filled
			player.x:+1													' Move The Player Right
		EndIf
		If (KeyDown(KEY_LEFT)) And (player.x>0) And (player.fx=player.x*60) And (player.fy=player.y*40) Then
			player.x:-1													' Move The Player Left
			hline[player.x,player.y]=True									' Mark The Current Horizontal Border As Filled
		EndIf
		If (KeyDown(KEY_DOWN)) And (player.y<10) And (player.fx=player.x*60) And (player.fy=player.y*40) Then
			vline[player.x,player.y]=True									' Mark The Current Verticle Border As Filled
			player.y:+1													' Move The Player Down
		EndIf
		If (KeyDown(KEY_UP)) And (player.y>0) And (player.fx=player.x*60) And (player.fy=player.y*40) Then
			player.y:-1													' Move The Player Up
			vline[player.x,player.y]=True									' Mark The Current Verticle Border As Filled
		EndIf

		If player.fx<player.x*60 Then										' Is Fine Position On X Axis Lower Than Intended Position?
			player.fx:+steps[adjust]										' If So, Increase The Fine X Position
		EndIf
		If player.fx>player.x*60 Then										' Is Fine Position On X Axis Greater Than Intended Position?
			player.fx:-steps[adjust]										' If So, Decrease The Fine X Position
		EndIf
		If player.fy<player.y*40 Then										' Is Fine Position On Y Axis Lower Than Intended Position?
			player.fy:+steps[adjust]										' If So, Increase The Fine Y Position
		EndIf
		If (player.fy>player.y*40) Then										' Is Fine Position On Y Axis Lower Than Intended Position?
			player.fy:-steps[adjust]										' If So, Decrease The Fine Y Position
		EndIf
			
		player.spin:+0.5*steps[adjust]										' Spin The Player Clockwise
		If player.spin>360.0 Then											' Is The spin Value Greater Than 360?
			player.spin:-360												' If So, Subtract 360
		EndIf
		pause:+1
	Else																	' Otherwise
		If KeyHit(KEY_SPACE) Then											' If Spacebar Is Being Pressed
			gameover=False												' gameover Becomes False
			filled=True													' filled Becomes True
			level=1														' Starting Level Is Set Back To One
			level2=1														' Displayed Level Is Also Set To One
			stage=0														' Game Stage Is Set To Zero
			lives=5														' Lives Is Set To Five
		EndIf
	EndIf

	If filled Then														' Is The Grid Filled In?
		stage:+1															' Increase The Stage
		If stage>3 Then													' Is The Stage Higher Than 3?
			stage=1														' If So, Set The Stage To One
			level:+1														' Increase The Level
			level2:+1													' Increase The Displayed Level
			If level>3 Then												' Is The Level Greater Than 3?
				level=3													' If So, Set The Level To 3
				lives:+1													' Give The Player A Free Life
				If lives>5 Then 											' Does The Player Have More Than 5 Lives?
					lives=5												' If So, Set Lives To Five
				EndIf
			EndIf
		EndIf
		ResetObjects()													' Reset Player / Enemy Positions
		For loop1=0 To 10													' Loop Through The Grid X Coordinates
			For loop2=0 To 10												' Loop Through The Grid Y Coordinates
				If loop1<10 Then											' If X Coordinate Is Less Than 10
					hline[loop1,loop2]=False								' Set The Current Horizontal Value To False
				EndIf
				If loop2<10 Then											' If Y Coordinate Is Less Than 10
					vline[loop1,loop2]=False								' Set The Current Vertical Value To False
				EndIf
			Next
		Next
	EndIf
	
	' Here we draw the game
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)						' Clear Screen And Depth Buffer
	For loop1=0 To lives-2													' Loop Through Lives Minus Current Life
		glLoadIdentity()													' Reset The View
		glTranslatef(490.0+(loop1*40.0),40.0,0.0)							' Move To The Right Of Our Title Text
		glRotatef(-player.spin,0.0,0.0,1.0)									' Rotate Counter Clockwise
		glColor3f(0.0,1.0,0.0)												' Set Player Color To Light Green
		glBegin(GL_LINES)													' Start Drawing Our Player Using Lines
			glVertex2d(-5,-5)												' Top Left Of Player
			glVertex2d( 5, 5)												' Bottom Right Of Player
			glVertex2d( 5,-5)												' Top Right Of Player
			glVertex2d(-5, 5)												' Bottom Left Of Player
		glEnd()															' Done Drawing The Player
		glRotatef(-player.spin*0.5,0.0,0.0,1.0)								' Rotate Counter Clockwise
		glColor3f(0.0,0.75,0.0)											' Set Player Color To Dark Green
		glBegin(GL_LINES)													' Start Drawing Our Player Using Lines
			glVertex2d(-7, 0)												' Left Center Of Player
			glVertex2d( 7, 0)												' Right Center Of Player
			glVertex2d( 0,-7)												' Top Center Of Player
			glVertex2d( 0, 7)												' Bottom Center Of Player
		glEnd()															' Done Drawing The Player
	Next

	filled=True															' Set Filled To True Before Testing
	glLineWidth(2.0)														' Set Line Width For Cells To 2.0f
	glDisable(GL_LINE_SMOOTH)												' Disable Antialiasing
	glLoadIdentity()														' Reset The Current Modelview Matrix
	For loop1=0 To 10														' Loop From Left To Right
		For loop2=0 To 10													' Loop From Top To Bottom
			glColor3f(0.0,0.5,1.0)											' Set Line Color To Blue
			If hline[loop1,loop2]											' Has The Horizontal Line Been Traced
				glColor3f(1.0,1.0,1.0)										' If So, Set Line Color To White
			EndIf

			If loop1<10													' Dont Draw To Far Right
				If Not hline[loop1,loop2]									' If A Horizontal Line Isn't Filled
					filled=False											' filled Becomes False
				EndIf
				glBegin(GL_LINES)											' Start Drawing Horizontal Cell Borders
					glVertex2d(20+(loop1*60),70+(loop2*40))					' Left Side Of Horizontal Line
					glVertex2d(80+(loop1*60),70+(loop2*40))					' Right Side Of Horizontal Line
				glEnd()													' Done Drawing Horizontal Cell Borders
			EndIf

			glColor3f(0.0,0.5,1.0)											' Set Line Color To Blue
			If vline[loop1,loop2]											' Has The Horizontal Line Been Traced
				glColor3f(1.0,1.0,1.0)										' If So, Set Line Color To White
			EndIf
			If loop2<10													' Dont Draw To Far Down
				If Not vline[loop1,loop2]									' If A Verticle Line Isn't Filled
					filled=False											' filled Becomes False
				EndIf
				glBegin(GL_LINES)											' Start Drawing Verticle Cell Borders
					glVertex2d(20+(loop1*60),70+(loop2*40))					' Left Side Of Horizontal Line
					glVertex2d(20+(loop1*60),110+(loop2*40))				' Right Side Of Horizontal Line
				glEnd()													' Done Drawing Verticle Cell Borders
			EndIf

			glEnable(GL_TEXTURE_2D)										' Enable Texture Mapping
			glColor3f(1.0,1.0,1.0)											' Bright White Color
			If (loop1<10) And (loop2<10)									' If In Bounds, Fill In Traced Boxes
				' Are All Sides Of The Box Traced?
				If (hline[loop1,loop2]) And (hline[loop1,loop2+1]) And (vline[loop1,loop2]) And (vline[loop1+1,loop2])
					glBegin(GL_QUADS)										' Draw A Textured Quad
						glTexCoord2f((Float(loop1)/10.0)+0.1,1.0-(Float(loop2)/10.0))
						glVertex2d(20+(loop1*60)+59,(70+loop2*40+1))					' Top Right
						glTexCoord2f(Float(loop1)/10.0,1.0-(Float(loop2)/10.0))
						glVertex2d(20+(loop1*60)+1,(70+loop2*40+1))					' Top Left
						glTexCoord2f(Float(loop1)/10.0,1.0-((Float(loop2)/10.0)+0.1))
						glVertex2d(20+(loop1*60)+1,(70+loop2*40)+39)					' Bottom Left
						glTexCoord2f((Float(loop1)/10.0)+0.1,1.0-((Float(loop2)/10.0)+0.1))
						glVertex2d(20+(loop1*60)+59,(70+loop2*40)+39)				' Bottom Right
					glEnd()												' Done Texturing The Box
				EndIf
			EndIf
			glDisable(GL_TEXTURE_2D)										' Disable Texture Mapping
		Next
	Next
	glLineWidth(2.0)														' Set The Line Width To 1.0f

	If anti Then															' Is Anti True?
		glEnable(GL_LINE_SMOOTH)											' If So, Enable Antialiasing
	EndIf
	glLoadIdentity()														' Reset The Modelview Matrix
	glTranslatef(player.fx+20.0,player.fy+70.0,0.0)							' Move To The Fine Player Position
	glRotatef(player.spin,0.0,0.0,1.0)										' Rotate Clockwise
	glColor3f(0.0,1.0,0.0)													' Set Player Color To Light Green
	glBegin(GL_LINES)														' Start Drawing Our Player Using Lines
		glVertex2d(-5,-5)													' Top Left Of Player
		glVertex2d( 5, 5)													' Bottom Right Of Player
		glVertex2d( 5,-5)													' Top Right Of Player
		glVertex2d(-5, 5)													' Bottom Left Of Player
	glEnd()																' Done Drawing The Player
	glRotatef(player.spin*0.5,0.0,0.0,1.0)									' Rotate Clockwise
	glColor3f(0.0,0.75,0.0)												' Set Player Color To Dark Green
	glBegin(GL_LINES)														' Start Drawing Our Player Using Lines
		glVertex2d(-7, 0)													' Left Center Of Player
		glVertex2d( 7, 0)													' Right Center Of Player
		glVertex2d( 0,-7)													' Top Center Of Player
		glVertex2d( 0, 7)													' Bottom Center Of Player
	glEnd()																' Done Drawing The Player
End Function 

Function ResetObjects()													' Reset Player And Enemies
	player.x=0															' Reset Player X Position To Far Left Of The Screen
	player.y=0															' Reset Player Y Position To The Top Of The Screen
	player.fx=0															' Set Fine X Position To Match
	player.fy=0															' Set Fine Y Position To Match
End Function


it has a lot to do with the ortho settings.

Interesting!

From the Nehe tutorial:


The first parameter (0.0f) is the value that we want for the far left side of the screen. You wanted to know how to use actual pixel values, so instead of using a negative number for far left, I've set the value to 0. The second parameter is the value for the far right side of the screen. If our window is 640x480, the value stored in width will be 640. So the far right side of the screen effectively becomes 640. Therefore our screen runs from 0 to 639 on the x-axis (640 pixels).

The third parameter (height) would normally be our negative y-axis value (bottom of the screen). But because we want exact pixels, we wont have a negative value. Instead we will make the bottom of the screen equal the height of our window. If our window is 640x480, height will be equal to 480. So the bottom of our screen will be 479. The fourth parameter would normally be the positive value for the top of our screen. We want the top of the screen to be 0 (good old fashioned screen coordinates) so we just set the fourth parameter to 0. This gives us from 0 to 479 on the y-axis (480 pixels).

The last two parameters are for the z-axis. We don't really care about the z-axis so we'll set the range from -1.0f to 1.0f. Just enough that we can see anything drawn at 0.0f on the z-axis.




So thats how you do pixel positioning... That would explain why the max2dGL source has a 'beginortho()' and 'Endortho()' functions. You still get all the 3d rotation/blending and stuff right?

Very cool:

'SuperStrict
Framework pub.OpenGL
Import BRL.GLGraphics

GLGraphics 1024, 768


Type TPlayer
	Field x:Int, y:Int
	
	Method New()
		x = 492
		y = 364
	End Method
	
	Method Update()
		If KeyDown(KEY_UP) y:-4
		If KeyDown(KEY_DOWN) y:+4
		If KeyDown(KEY_LEFT) x:-4
		If KeyDown(KEY_RIGHT) x:+4
		If y > 748 y = 748
		If y < 0 y = 0
		If x > 1004 x = 1004
		If x < 0 x = 0
	End Method
	
	Method Render()
		glBegin(GL_QUADS)
			glVertex2d(x,y)
			glVertex2d(x+20,y)
			glVertex2d(x+20,y+20)
			glVertex2d(x,y+20)
		glEnd()
	End Method
End Type

Local MyPlayer:TPlayer = New TPlayer

'other initalizing stuff
InitalizeGL() 'initalize opengl stuff (beyound my comprehension at the moment)
Local _FPS:Int ' FPS
Local _FPSTICK:Int ' FPS ticker
Local _FPSTIME:Int = MilliSecs() ' FPS Timer

'Main loop, quit on KEY_ESCAPE
While Not KeyDown(KEY_ESCAPE)
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) 'Cls but opengl
	glLoadIdentity() 	
	
	MyPlayer.Update()
	MyPlayer.Render()


	'FPS updating
	GLDrawText "FPS: "+_FPS,0,0
	_FPSTICK:+1
	If MilliSecs() > _FPSTIME+1000
		_FPS = _FPSTICK
		_FPSTICK = 0
		_FPSTIME = MilliSecs()
	End If
	Flip 1
Wend
End

Function InitalizeGL()
	glShadeModel(GL_SMOOTH)
	glClearColor(0.0, 0.0, 0.0, 0.5)
	glClearDepth(1.0)
	glHint(GL_LINE_SMOOTH_HINT, GL_NICEST)
	glEnable(GL_BLEND)
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

	glViewport(0,0,1024,768)
	glMatrixMode(GL_PROJECTION)
	glLoadIdentity()
	glOrtho(0.0,1024,768,0.0,-1.0,1.0)
	glMatrixMode(GL_MODELVIEW)
	glLoadIdentity()
End Function


Now I need to figure out how to make that box an image :)

How'd you do the rotation? This is producing some wierd results...

'SuperStrict
Framework pub.OpenGL
Import BRL.GLGraphics

GLGraphics 1024, 768


Type TPlayer
	Field x:Int, y:Int
	Field rot:Int
	
	Method New()
		x = 492
		y = 364
	End Method
	
	Method Update()
		If KeyDown(KEY_UP) y:-4
		If KeyDown(KEY_DOWN) y:+4
		If KeyDown(KEY_LEFT) x:-4
		If KeyDown(KEY_RIGHT) x:+4
		If y > 748 y = 748
		If y < 0 y = 0
		If x > 1004 x = 1004
		If x < 0 x = 0
		rot:+4
		If rot > 359 rot:-360
	End Method
	
	Method Render()
		glRotatef(-rot,0,0,1.0)
		glBegin(GL_QUADS)
			glVertex2d(x,y)
			glVertex2d(x+20,y)
			glVertex2d(x+20,y+20)
			glVertex2d(x,y+20)
		glEnd()
	End Method
End Type
InitalizeGL() 'initalize opengl stuff (beyound my comprehension at the moment)
Local MyPlayer:TPlayer = New TPlayer

'other initalizing stuff
'InitalizeGL() 'initalize opengl stuff (beyound my comprehension at the moment)
Local _FPS:Int ' FPS
Local _FPSTICK:Int ' FPS ticker
Local _FPSTIME:Int = MilliSecs() ' FPS Timer

'Main loop, quit on KEY_ESCAPE
While Not KeyDown(KEY_ESCAPE)
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) 'Cls but opengl
	glLoadIdentity() 	
	
	MyPlayer.Update()
	MyPlayer.Render()


	'FPS updating
	GLDrawText "FPS: "+_FPS,0,0
	_FPSTICK:+1
	If MilliSecs() > _FPSTIME+1000
		_FPS = _FPSTICK
		_FPSTICK = 0
		_FPSTIME = MilliSecs()
	End If
	Flip 1
Wend
End

Function InitalizeGL()
	glShadeModel(GL_SMOOTH)
	glClearColor(0.0, 0.0, 0.0, 0.5)
	glClearDepth(1.0)
	glHint(GL_LINE_SMOOTH_HINT, GL_NICEST)
	glEnable(GL_BLEND)
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

	glViewport(0,0,1024,768)
	glMatrixMode(GL_PROJECTION)
	glLoadIdentity()
	glOrtho(0.0,1024,768,0.0,-1.0,1.0)
	glMatrixMode(GL_MODELVIEW)
	glLoadIdentity()
End Function


Ok, I fixed the problem, You have to translate to the x/y and draw at 0,0 rather then draw at the x/y ?

Anyways, this causes problems with multible objects:

'SuperStrict
Framework pub.OpenGL
Import BRL.GLGraphics
Import BRL.Random

GLGraphics 1024, 768
SeedRnd MilliSecs()

Type TObject
	Field x:Int, y:Int
	Field rot:Int
	
End Type

Type TPlayer Extends TObject
	'Field x:Int, y:Int
	'Field rot:Int
	Field MH:Byte
	
	Method New()
		x = 492
		y = 364
		MH = True
	End Method
	
	Method Update()
		If KeyDown(KEY_UP) y:-4
		If KeyDown(KEY_DOWN) y:+4
		If KeyDown(KEY_LEFT) x:-4
		If KeyDown(KEY_RIGHT) x:+4
		If y > 748 y = 748
		If y < 0 y = 0
		If x > 1004 x = 1004
		If x < 0 x = 0
		rot:+4
		If rot > 359 rot:-360
	End Method
	
	Method Render()
		glTranslatef(x,y,0.0)
		glRotatef(-rot,0,0,1.0)
		If Not MH
			glBegin(GL_QUADS)
				glVertex2d(0,0)
				glVertex2d(0+20,0)
				glVertex2d(0+20,0+20)
				glVertex2d(0,0+20)
			glEnd()
		Else
			glBegin(GL_QUADS)
				glVertex2d(-10,-10)
				glVertex2d(10,-10)
				glVertex2d(10,10)
				glVertex2d(-10,+10)
			glEnd()
		End If
	End Method
End Type

Type TThing Extends TObject
	Method New()
		x = 300
		y = 300
	End Method
	
	Method Update()
		x:+Rand(-2,2)
		y:+Rand(-2,2)
		If y > 748 y = 748
		If y < 0 y = 0
		If x > 1004 x = 1004
		If x < 0 x = 0
		rot:+4
		If rot > 359 rot:-360
	End Method
	
	Method Render()
		glTranslatef(x,y,0.0)
		glRotatef(-rot,0,0,1.0)
		glBegin(GL_QUADS)
			glVertex2d(-10,-10)
			glVertex2d(10,-10)
			glVertex2d(10,10)
			glVertex2d(-10,+10)
		glEnd()
	End Method
End Type
	
	


InitalizeGL() 'initalize opengl stuff (beyound my comprehension at the moment)
Local MyPlayer:TPlayer = New TPlayer
Local MyThing:TThing = New TThing



'other initalizing stuff
'InitalizeGL() 'initalize opengl stuff (beyound my comprehension at the moment)
Local _FPS:Int ' FPS
Local _FPSTICK:Int ' FPS ticker
Local _FPSTIME:Int = MilliSecs() ' FPS Timer

'Main loop, quit on KEY_ESCAPE
While Not KeyDown(KEY_ESCAPE)
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) 'Cls but opengl
	glLoadIdentity() 	
	
	If KeyHit(KEY_A) MyPlayer.MH = Not MyPlayer.MH
	
	MyPlayer.Update()
	MyThing.Update()
	MyPlayer.Render()
	MyThing.Render()

	'FPS updating
	GLDrawText "FPS: "+_FPS,0,0
	_FPSTICK:+1
	If MilliSecs() > _FPSTIME+1000
		_FPS = _FPSTICK
		_FPSTICK = 0
		_FPSTIME = MilliSecs()
	End If
	Flip 1
Wend
End

Function InitalizeGL()
	glShadeModel(GL_SMOOTH)
	glClearColor(0.0, 0.0, 0.0, 0.5)
	glClearDepth(1.0)
	glHint(GL_LINE_SMOOTH_HINT, GL_NICEST)
	glEnable(GL_BLEND)
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

	glViewport(0,0,1024,768)
	glMatrixMode(GL_PROJECTION)
	glLoadIdentity()
	glOrtho(0.0,1024,768,0.0,-1.0,1.0)
	glMatrixMode(GL_MODELVIEW)
	glLoadIdentity()
End Function


Any ideas?

I looked at your code and couldn't find anything wrong. what exactly is it you want to do? and what is it not doing?


extra:
here at http://www.glprogramming.com/red/
is just about the whole OGL red book 1.1
if you go here:
http://www.glprogramming.com/red/chapter01.html
you can read the "OpenGL Command Syntax" section which you don't seem to understand.:)

[edit]
I couldn't remember this one so I had to google it:
ogl blue book:
http://www.talisman.org/opengl-1.1/Reference.html

Thanks for the links I'll look at them... I found the fix to my code... If you draw multible things you have to glLoadIdentity() between drawing them.

here's a little stress test:

'SuperStrict
Framework pub.OpenGL
Import BRL.GLGraphics
Import BRL.Random

GLGraphics 1024, 768
SeedRnd MilliSecs()

Type TObject
	Field x:Int, y:Int
	Field rot:Int
	
End Type

Type TPlayer Extends TObject
	'Field x:Int, y:Int
	'Field rot:Int
	Field MH:Byte
	
	Method New()
		x = 492
		y = 364
		MH = True
	End Method
	
	Method Update()
		If KeyDown(KEY_UP) y:-4
		If KeyDown(KEY_DOWN) y:+4
		If KeyDown(KEY_LEFT) x:-4
		If KeyDown(KEY_RIGHT) x:+4
		If y > 748 y = 748
		If y < 0 y = 0
		If x > 1004 x = 1004
		If x < 0 x = 0
		rot:+4
		If rot > 359 rot:-360
	End Method
	
	Method Render()
		glTranslatef(x,y,0.0)
		glRotatef(-rot,0,0,1.0)
		If Not MH
			glBegin(GL_QUADS)
				glVertex2d(0,0)
				glVertex2d(0+20,0)
				glVertex2d(0+20,0+20)
				glVertex2d(0,0+20)
			glEnd()
		Else
			glBegin(GL_QUADS)
				glVertex2d(-10,-10)
				glVertex2d(10,-10)
				glVertex2d(10,10)
				glVertex2d(-10,+10)
			glEnd()
		End If
		glLoadIdentity()
	End Method
End Type

Type TThing Extends TObject
	Method New()
		x = 300
		y = 300
	End Method
	
	Method Update()
		x:+Rand(-10,10)
		y:+Rand(-10,10)
		If y > 748 y = 748
		If y < 0 y = 0
		If x > 1004 x = 1004
		If x < 0 x = 0
		rot:+4
		If rot > 359 rot:-360
	End Method
	
	Method Render()
		glTranslatef(x,y,0.0)
		glRotatef(-rot,0,0,1.0)
		glColor3f(.2,.2,1.0)
		glBegin(GL_QUADS)
			glVertex2d(-10,-10)
			glVertex2d(10,-10)
			glVertex2d(10,10)
			glVertex2d(-10,+10)
		glEnd()
		glLoadIdentity()
	End Method
End Type
	
	


InitalizeGL() 'initalize opengl stuff (beyound my comprehension at the moment)
Local thinglist:TThing[6000]

Local MyPlayer:TPlayer = New TPlayer

For Local i:Int = 0 To 5999
	Local MyThing:TThing = New TThing
	thinglist[i] = MyThing
Next



'other initalizing stuff
'InitalizeGL() 'initalize opengl stuff (beyound my comprehension at the moment)
Local _FPS:Int ' FPS
Local _FPSTICK:Int ' FPS ticker
Local _FPSTIME:Int = MilliSecs() ' FPS Timer

'Main loop, quit on KEY_ESCAPE
While Not KeyDown(KEY_ESCAPE)
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) 'Cls but opengl
	glLoadIdentity() 	
	
	If KeyHit(KEY_A) MyPlayer.MH = Not MyPlayer.MH
	
	MyPlayer.Update()
	MyPlayer.Render()
	
	For i = 0 To 5999
		thinglist[i].Update()
		thinglist[i].Render()
	Next

	'FPS updating
	glColor3f(1.0,1.0,1.0)
	GLDrawText "FPS: "+_FPS,0,0
	_FPSTICK:+1
	If MilliSecs() > _FPSTIME+1000
		_FPS = _FPSTICK
		_FPSTICK = 0
		_FPSTIME = MilliSecs()
	End If
	Flip 0
Wend
End

Function InitalizeGL()
	glShadeModel(GL_SMOOTH)
	glClearColor(0.0, 0.0, 0.0, 0.5)
	glClearDepth(1.0)
	glHint(GL_LINE_SMOOTH_HINT, GL_NICEST)
	glEnable(GL_BLEND)
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

	glViewport(0,0,1024,768)
	glMatrixMode(GL_PROJECTION)
	glLoadIdentity()
	glOrtho(0.0,1024,768,0.0,-1.0,1.0)
	glMatrixMode(GL_MODELVIEW)
	glLoadIdentity()
End Function


I got 80 FPS... seems kind of slow, I mean when in 3d, for example, the leadwerks engine (uses opengl if I recall right), renders hundreds of thousands if not millions of polys. This is only 6000... Why the difference between 2d and 3d?

Also just to mess around what little 'tricks' could I use to speed it up?

if you read the whole red book chapter 2 you'll get an idea on how it works.
most of the speed is gained by using vector arrays fo the different type of objects drawn. There is not much you can improve on what you are doing because all you are doing is quads. But for terrain and shapes it would really help the speed If you send a single triangle array with hundreds of triangles to the graphics card instead of sending a bunch of triangle/quads objects separately. you get me?

So is my code above 'single surface'? It would seem not because i'm rendering each box seperately

correct.
and sorry I can't help you beyound this point. This is up to where my skills reach(I know, not much :) ) and I don't want to confuse you.
I think, eitherway it should be faster than the bmax version sence you are not initializing ortho everytime you draw a box(orthobegin/orthoend).

Cool thanks for the help jesse, I'm doing to try and do a basic sprite system just for learning experience, after that i'll try my hand at creating a system for outputting basic 3d primatives (sphere, cube, polyhedron, prisms, ect.)

Next step: Textures for images... fun :)