GL Test

BlitzMax Forums/BlitzMax Programming/GL Test

I was beginning my foray into GL programming and ended up with this as my first test program:

Const SCREENWIDTH = 800
Const SCREENHEIGHT= 600
Const HALFSCREENWIDTH:Float = SCREENWIDTH / 2.0
Const HALFSCREENHEIGHT:Float = SCREENHEIGHT/ 2.0

bglCreateContext(SCREENWIDTH, SCREENHEIGHT, 32, 1000, BGL_FULLSCREEN|BGL_BACKBUFFER|BGL_DEPTHBUFFER)
bglSetSwapInterval 0
glShadeModel(GL_SMOOTH)


Global QuadList:TList = New TList

Type TQuad
	Field X : Float
	Field Y : Float
	Field Width : Float
	Field Height : Float
	Method Update()
		X = X + RndFloat()-RndFloat()
		Y = Y + RndFloat()-RndFloat()
	End Method
End Type

SeedRnd MilliSecs()

For Local t = 1 To 10000
	Local tempQuad:TQuad = New TQuad
		tempQuad.X = Rnd!(0.0, SCREENWIDTH)
		tempQuad.Y = Rnd!(0.0, SCREENHEIGHT)
		tempQuad.Width = Rnd!(16,64)
		tempQuad.Height = Rnd!(16,64)
		QuadList.AddLast(tempQuad)
Next

Local LastTime:Int
Local TimeDiff : Int
Local StartTime:Int
Local timecount:Int = 0
Local counter :Int =0
HideMouse()



While Not KeyDown(KEY_ESCAPE)
StartTime = MilliSecs()

	
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

	For Local a:TQuad = EachIn QuadList
		a.Update()
		DrawQuad(a.X, a.Y, a.Width, a.Height)
	Next

	bglSwapBuffers()


TimeDiff = MilliSecs()-StartTime
TimeCount :+TimeDiff
counter :+ 1

Wend



ShowMouse()


Print timecount
Print counter
Print TimeCount/counter +"ms/frame"
Print "FPS: "+1000/(TimeCount/counter)

bglDeleteContext()

QuadList.Clear()
QuadList = Null


Function DrawQuad( qX:Float, qY:Float, qWidth:Float, qHeight:Float)
	qX = (qx-HALFSCREENWIDTH)/HALFSCREENWIDTH
	qY = -((qY-HALFSCREENHEIGHT)/HALFSCREENHEIGHT)
	qWidth = qWidth/HALFSCREENWIDTH
	qHeight = qHeight/HALFSCREENHEIGHT

	glBegin(GL_QUADS)
		glColor3f(1.0, 0.0, 0.0)
		glVertex3f(qX, qY - qHeight, -1.0)
		glVertex3f(qX + qWidth , qY - qHeight, -1.0)
		glColor3f(1.0, 1.0, 0.0)
		glVertex3f(qX + qWidth, qY, -1.0)
		glVertex3f(qX, qY, -1.0)
	glEnd()
End Function


WARNING!: Bright colours contained within, may well nauseate.

I get a constant 10ms/frame (100fps) regardless of whether I use 16bit mode or 32 bit mode.
Tested the same on my Dad's PC while I was at his house, he has an Athlon64 3200 and a Radeon Atlantis (9800 128MB I think).
He gets 8ms in 16bit mode and 16 in 32bit mode.

Could some of you guys test this and tell me what your specs are and what you get?

I get

5124
198
25ms/frame
FPS: 40

which seems about right, one third the speed of a recent model PC.

After you call bglCreateContext you don't need to set the swap interval. It does that on its own.

4924
335
14ms/frame
FPS: 71

AMD 64 3000+ 2ghz, 1gb ram, ATI X800 XT 256mb.

On mine:

13421
727
18ms/frame
FPS: 55

Pentium 4, 2.66GHz, 1GB RAM, ATI Radeon 9000 64MB, ATI VER008.004.010.000

21018
617
34ms/frame
FPS: 29


PII 400Mhz 256 ram geforce 4mx 440

In not debug mode I had:
2613
231
11ms/frame
FPS: 90

In debug mode:
3969
246
16ms/frame
FPS: 62

On my AMD 1600, 512 Mb Ram, NVIDIA GeForce FX 5600 Ultra 128 Mb, Windows 2000

Thanks guys :)

14903
1830
8ms/frame
FPS: 125

os|win32 xp+sp1, cpu|p4 2.8 gig, ram|1 gig, gfx|radeon 9800pro, sfx|audigy


Greetings,

taumel

15889
49
324ms/frame
FPS: 3

on a Mobile Pentium4-1.8ghz, 1gb ram, NVIDIA GeForce2GO 32mb (oh dear)

Pentium 4 3,0 GHz HT
1 GB DDR RAM
Radeon 9800 Pro (128 MB)

11519
1418
8ms/frame
FPS: 125

@Perturbatio

Neat little test, but one point for consistency - you should really seed the random number generator with a fixed value (e.g. 1), rather than MilliSecs(), to ensure the same 10,000 squares are generated each time. I know you intended this as just a quick test, but thought I'd point that out.

Cheers,

Stu

yeah I noticed that, but couldn't be bothered to change it, the results seemed consistent enough on my system to suggest that they would be good enough on other's too.