Plot vs. Writepixel

BlitzMax Forums/BlitzMax Beginners Area/Plot vs. Writepixel

NickFalk(Posted 2007) [#1]
Just reading through the 2D section of the Blitz3D docs in order to increase my general knowledge of possible uh, possibilities, in BlitzMax.

Does anyone have an opinion about the plot command compared to the writepixel command? As far as I understand if I use writepixel i will not change the setcolor parameter which affects all graphics? Is there any difference in speed between the two? Is writepixel even viable in BlitzMax?

Any light shed on the subject would be greatly appreciated.


grable(Posted 2007) [#2]
WritePixel only works on Pixmaps, so youd have to do a DrawPixmap later.

I would imagine Plot being slower, but i havent tested it.


tonyg(Posted 2007) [#3]
What is it you are trying to do?


NickFalk(Posted 2007) [#4]
It's not so much that I have a specific task I need to do, as I'm trying to get some bearings of the different possibilities.

I do however already have a working paralax-starfield created with the plot-command and was curious whether writepixel would for some reason be a better solution.


tonyg(Posted 2007) [#5]
Wouldn't it be better to use drawoval? Writepixel would involve too much image manipulation for a parallax starfield while plot is slow.
<edit> It might even be OK to use a single image.


NickFalk(Posted 2007) [#6]
Could be, I have the handicap of owning a 4x3,00Ghz Xeon and it really doesn't show any sign of strugling with this stuff.

In either case, I'm really just experimenting (while creating a small shmup) just to see what's possible.


NickFalk(Posted 2007) [#7]
Another related question: Does plot use OpenGL or is OpenGL only used for commands related to "image" I guess this would make all the diference in the world...


tonyg(Posted 2007) [#8]
The commands use whatever driver you have specified in the setgraphicsdriver command. Default is DX driver.
Personally, I would use drawoval but, depending on the task and fi you're trying to squeeze every ms out of the process, might use multiple images from the same texture using SetUV. Could be OTT but search using 'setuv' if you're interested.


EOF(Posted 2007) [#9]
Nick,
Have a look at the code samples here (which use OpenGL) ..

The first example demonstrates Plot using two methods:

First, using the standard BLitzMax Plot
Then, using an unwrapped version with glBegin and glEnd being called at the start and end of a batch of pixels to plot (instead of every plot)

The speed difference only shows up if you plot 1000's of stars per frame.






This code is more complicated (using the WritePixel command)
Its certainly pretty damn fast but you need to run it with Debug Off:



FlameDuck(Posted 2007) [#10]
Like the man says, if you intend on using plot in any significance, you really need to batch process your plots, so you aren't calling glBegin/glEnd all the time. Very wasteful.

WritePixel certainly executes faster, but the time taken to DrawPixmap (or LoadImage/DrawImage) might offset the speed gain some what.

In either case, like tony said, it depends a lot on what you want to do (and probably what hardware you want to do it on).


NickFalk(Posted 2007) [#11]
Thanks Jim, I'll keep that GL-bit in mind for when I feel ready to jump onto the GL-bandawagon... ;)


EOF(Posted 2007) [#12]
Forgot to mention the particle demo is using a FastDrawPixmap() routine which, on my Sony craptop, boosts the realtime blured particles from 2770 to 3810!