how to optimize drawing?

Blitz3D Forums/Blitz3D Beginners Area/how to optimize drawing?

coffeeaddict(Posted 2011) [#1]
Is there a way to create a 2d surface in memory, draw several images to said 2d surface, then draw that 2d surface onto the buffer and flip?

I ask because right now I am just using the DrawImage command and drawing everything piecemeal directly onto the buffer one by one at the end of the game loop. I would think it would be easier on the hardware if I just did one draw rather than several onto the buffer.


xtremegamr(Posted 2011) [#2]
Yes, there is a way to do what you are asking, but it's not any faster than just drawing directly onto the buffer :)

Just in case you were wondering how:
Local buffer=CreateImage( GraphicsWidth(), GraphicsHeight() ) ;create a buffer the size of the screen

;;in your main loop...
SetBuffer ImageBuffer(buffer)
Cls

;draw all of your images here

;now, we draw our buffer to the backbuffer, and flip
SetBuffer BackBuffer()
Cls

DrawImage buffer,0,0


EDIT: Wait a sec...are you working in 2D or 3D?

Last edited 2011


coffeeaddict(Posted 2011) [#3]
I'm working in 3d. This is for a user menu.


Matty(Posted 2011) [#4]
If you're working in 3d you're better off not using the 2d commands, but using 2d-in-3d by using quads/billboards for your gui interface.

2d commands over 3d scenes can slow things down on some cards.


Yasha(Posted 2011) [#5]
Seconded. There's very little reason to use the builtin 2D at all; it's slower than 2D-in-3D. Lookup Draw3D and Draw3D 2 for some nice free libraries that take care of this using the 3D engine.


_PJ_(Posted 2011) [#6]
^^ What they said!

2D is way slow these days, so, although it's a littl emore work, it is much more practical to use the 3D rendering with flat quads etc. for 2-D images.