Fastest HUD Rendering

Blitz3D Forums/Blitz3D Programming/Fastest HUD Rendering

LostCargo(Posted 2003) [#1]
Has anyone produced a very fast HUD. I am currently trying to figure out the best way to build a HUD for my game, but i want to be able to interact with the hud. Ie clickable buttons, etc.

I was considering sprite objects, but i suspect that this would take a fair amount of time to render.

Any takers?


Warren(Posted 2003) [#2]
Why do you suspect that sprites would be slow?


LostCargo(Posted 2003) [#3]
Some of the other posts that i have read stated that using large sprites would not be as effective as using a 2d overlay. However, yet other posts state that 2d overlay is still slow since 2d and 3d are not best when done togeather.


sswift(Posted 2003) [#4]
Sprites are not slow.


Mustang(Posted 2003) [#5]
using large sprites would not be as effective


It's because of the fill... if you use several almost screen sized sprites or meshes it will slow things down (you run out of fillrate). But that is "pilot error" ie you should NOT do that; instead use smaller sprites or meshes that are sized to cover just the needed screen area for the info (like compass, button or whatever).

Doing several 2D operations on the 3D-screen will also slow things down because they take time, and alpha-effects are generally speaking impossible, like smooth borders or transparency. If done right 3D (sprites or meshes) is always faster than using 2D.


Al Mackey(Posted 2003) [#6]
I've had very good results making my own textured quads parented to the camera, and rendering them with their EntityOrder set to -1. I've had over 50 of them on the screen at once, with no noticable slowdown even on my 2-year-old laptop. The code below uses the globals Camera, ScrWidth, and ScrHeight. It also uses "quit.png", which should be a 24-bit PNG image of a button with transparency. The CreateButton routine expects the arguments of Brush handle, X position, Y position, Width and Height.

BtnImgQuit = LoadBrush("quit.png",3)
QuitBtn = CreateButton(BtnImgQuit, 0, -2.6, .8, .2)
While(1)
	If (MouseHit(1))
		BtnHit = CameraPick(Camera, MouseX(), MouseY())
		If (BtnHit = QuitBtn) End
	EndIf
	UpdateWorld():RenderWorld():Flip()
Wend

Function CreateButton(img, x#, y#, w#, h#)
	BtnMesh = CreateMesh(Camera)
	BtnSurf = CreateSurface(BtnMesh, img)
	AddVertex (BtnSurf, -w, -h, 0)
	AddVertex (BtnSurf, -w, h, 0)
	AddVertex (BtnSurf, w, h, 0)
	AddVertex (BtnSurf, w, -h, 0)
	VertexTexCoords (BtnSurf, 0, 0, 1)
	VertexTexCoords (BtnSurf, 1, 0, 0)
	VertexTexCoords (BtnSurf, 2, 1, 0)
	VertexTexCoords (BtnSurf, 3, 1, 1)
	AddTriangle (BtnSurf, 0, 1, 2)
	AddTriangle (BtnSurf, 2, 3, 0)
	EntityParent (BtnMesh, Camera)
	EntityOrder (BtnMesh, -2)
	EntityBox (BtnMesh, -w, -h, 0, w*2, h*2, .01)
	EntityPickMode (BtnMesh, 3)
	EntityFX (BtnMesh, 1)
	PositionEntity (BtnMesh, x, y, 3.5 * ScrWidth / ScrHeight)
	Return BtnMesh
End Function



Ziltch(Posted 2003) [#7]
Useful function!


LostCargo(Posted 2003) [#8]
Hey Al, Excellent. I have done something similar over the last day or so.
Thanks for the help.
I think i am going to build up an easy to use gadget system. The more i look at this the more it looks like it needs to be dynamic.


EOF(Posted 2003) [#9]
This is worth a look:

Jeppe Nielsons AlphaGUI


GfK(Posted 2003) [#10]
Use FONText. It does everything that you want it to do, and more besides.


Rob(Posted 2003) [#11]
FONText is single surface, it's incredibly fast, cheap and basically brilliant.


Beaker(Posted 2003) [#12]
*nod*


Michael Reitzenstein(Posted 2003) [#13]
I am using FonText in Juno.


Madcap13(Posted 2003) [#14]
I just thought I'd mention that I overlay 2d and 3d all the fricken time. More than most I think. And I find it goes really quite fast. Just remember that for certain things its best to put all your 2d in one screen sized image before pasting it to the backbuffer..


LostCargo(Posted 2003) [#15]
thanks for the help guys ill take a look at fontext and AlphaGUI


Michael Reitzenstein(Posted 2003) [#16]
I just thought I'd mention that I overlay 2d and 3d all the fricken time. More than most I think. And I find it goes really quite fast. Just remember that for certain things its best to put all your 2d in one screen sized image before pasting it to the backbuffer..

On your card, maybe. Many older cards do not even support this.


LostCargo(Posted 2003) [#17]
see... now this is what i mean .lol thx michael