[SDL] Loop Setting Pixels
geometrian at gmail.com
Thu Jul 22 18:38:08 PDT 2010
On Thu, Jul 22, 2010 at 2:56 PM, Brian Barrett <brian.ripoff at gmail.com>wrote:
> I believe you should be using image_size - y -1. Consider that y
> never reaches image_size, therefore the 0 pixel line will be black.
> I suspect that SDL_FillRect is clipping your rectangle by setting w or
> h to 0, due to the above off-by-one which writes out of the screen
Thanks, this fixes it. Still, this seems very counter-intuitive behavior to
me. I see why it needs an extra -1, but not why it should cause the whole
screen to go black if it can't write one pixel.
> Finally, you probably should be use SDL_LockSurface(), followed by
> direct manipulation of the surface->pixels array, followed by
> SDL_UnlockSurface() for this. Lots of 1x1 FillRect calls are bound to
> add up.
It fills the whole screen in about a quarter second, but yes, that's true;
I'll add that.
On Thu, Jul 22, 2010 at 6:21 PM, Andreas Schiffler
<aschiffler at ferzkopp.net>wrote:
> Since you are ray-tracing probably purely CPU-memory, for best performance
> one should keep pixel accesses in memory as well. I would render all pixels
> into a local buffer first, then create a surface from it in a single call
> using SDL_CreateRGBSurfaceFrom using the current display format and then
> blit that one to the screen in one shot. Here is some info:
True, but for this ray-tracer, I want to see intermediate results; in this
case, one row at a time. Again, I'm not too concerned about the time it
takes to draw the screen.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SDL