Polygons and Frames Per Second

Blitz3D Forums/Blitz3D Beginners Area/Polygons and Frames Per Second

Can anyone give me the code for just a simple polygon count
and frames per second? And have it display on screen. I just
got blitz today and still a little confused. I am use to
darkbasic commands and am lost. So far blitz 3d seems to
have a faster engine that darkbasic. Thanks for any help.
Doug

Polycount (sort of):

http://www.blitzbasic.com/b3ddocs/command.php?name=TrisRendered&ref=3d_cat

FPS code:

http://www.blitzbasic.com/codearcs/codearcs.php?code=441

http://www.blitzbasic.com/codearcs/codearcs.php?code=438

Hi dugzilla.

Just to add to what Mustang posted, you might be interested in this small piece of code.

	Graphics3D 800,600,32
	SetBuffer BackBuffer()

	WireFrame 0
	AntiAlias 0

	SeedRnd MilliSecs()

	Global frame_count%
	Global fps%
	Global slowest_fps%
	Global fps_timeout%
	Global frame_time%
	Global slowest_frame%
	Global frame_start%
	fps_timer = CreateTimer(60) ; Lock to 60FPS.
	slowmo% = False
	wiref% = False
	
	cam = CreateCamera()
	PositionEntity cam,0,0,-15
	
	light = CreateLight()
	
	
	
	; --- Main loop ---

	While Not KeyHit(1)
		frame_start = MilliSecs()
	
		; Press ENTER to toggle slow motion.
		If KeyHit(28) Then slowmo = Not slowmo
		
		; Press BACKSPACE to toggle wireframe.
		If KeyHit(14) Then wiref = Not wiref : WireFrame wiref


	

		UpdateWorld
		RenderWorld
		
		frame_time = MilliSecs() - frame_start	
		show_info()

		WaitTimer(fps_timer)
		Flip True

		If slowmo Then Delay 200
	Wend

	End


;
; Display debug info
;
Function show_info()
	
	If fps_timeout
		frame_count = frame_count + 1

		If MilliSecs() > fps_timeout Then
			fps_timeout = MilliSecs() + 1000 
			fps = frame_count 
			frame_count = 0 
		
			If fps < slowest_fps Or slowest_fps = 0 Then slowest_fps = fps
		EndIf 
		
		If frame_time > slowest_frame Then slowest_frame = frame_time
		
		Color 0,255,0
		Text 10,10," Triangles: " + TrisRendered()
		Color 255,255,0
		Text 10,25," Millisecs: " + frame_time
		Text 10,40,"   Slowest: " + slowest_frame
		Color 0,255,255
		Text 10,55,"       FPS: " + fps
		Text 10,70,"     Worst: " + slowest_fps
		Color 255,255,255
	Else
		; First call initialization.
		fps_timeout = MilliSecs() + 1000 
	EndIf
	
End Function


I have that code stored in a file called 'template.bb' which I load whenever I want to quickly try an idea out in B3D. It contains all the basic stuff, including an FPS timer.

I also changed the file's attributes to make it 'read only'. This forces me to save it under a different name (usually test.bb) when using it to do a test prog.

Here's the FPS counter code I use.

	; -- Frames Per Second counter.
	; Place into the main program loop where it will be executed each frame, after 'RenderWorld' but before 'Flip'. The variables used here do not need to be declared globlly as this will occur automatically if the routine is placed in the main program. The value of 'milli_secs' should be set from the 'MilliSecs()' Blitz function at the start of the main program loop.
	FPS_framecounter = FPS_framecounter + 1
	If milli_secs >= FPS_timeout
		FPS_timeout = milli_secs + 1000
		FPS_framecount = FPS_framecounter
		FPS_framecounter = 0
	EndIf
	Text 10, 10, "FPS"
	Text 40, 10, FPS_framecount
	;^^^^^^


Thanks agiain for the help!