Page 1 of 1

2d drawing confusion

Posted: Tue Jun 28, 2005 9:37 pm
by hagibaba
hi,

i've been messing around with the demos from the
Codearchive, in the Graphics section on 2d drawing,
some neat stuff in there btw!

i'm following a c++ tutorial on demomaking currently
to see if i can translate examples to pb... just finished
a linear starfield, wohoo! :)

but i'm left wondering about speed, and the drawing buffer...

you see it says in the help file using the drawingbuffer
allows "very fast pixel manipulation" which led me to
think that the drawingbuffer should be faster than using
plot(x,y,color) but from tests it seems they are both
exactly the same speed?

so can anyone help explain:

how the drawingbuffer is (or could be) faster, is it faster at all?
does plot(x,y,color) draw to the video memory as well perhaps?
and what is the video memory?
is it the hardware or the software buffer,
or is it just whatever is available?

thx.

feel free to answer as many as you like. :)

Posted: Tue Jun 28, 2005 9:51 pm
by Fred
Basically when you access the pixel buffer directly you can do it in a row (line by line) which doesn't requiers a multiply (x+y*linepitch) and save a call if you use a pointer. Also you can setup a color table to have the color to write in a right format, which should save some cycle as well. That said, may be the bottleneck is the CPU->VideoMem transfer so the Plot() command is nearly as fast (note than the Plot() command is done to be as fast as possible :-). How do you handle the pixel buffer ?

Posted: Wed Jun 29, 2005 12:01 am
by hagibaba
oh i see! thanks v.much for that Fred.

i was using code i found in Danilo's
"DrawingBuffer_MousePainter" demo, so
it was just writing one pixel at a time,
not a row, since i didn't know how to
set that up. must be why the speeds
are the same then! :)