SDL_UpdateRect prob

Hi Guys

I’m trying to write myself a polygon based graphics engine under SDL.
I have
optimised my line drawing routine nicely but I run into one snag. Knowing
that updating only the area that’s changed is faster than updating the
entire screen I modified the call to reflect, e.g.

SDL_UpdateRect(screen, start.x, start.y, lineend.x, lineend.y);

The prob is that I get unwanted artifacts (pixels) as the screen
starts to
fill. If I use

SDL_UpdateRect(screen, 0, 0, 0, 0)

I don’t get those artifacts, but it slows the code down somewhat. Is
there a
way around this?

Penn

James Takac wrote:

Hi Guys

I’m trying to write myself a polygon based graphics engine under SDL.
I have
optimised my line drawing routine nicely but I run into one snag. Knowing
that updating only the area that’s changed is faster than updating the
entire screen I modified the call to reflect, e.g.

SDL_UpdateRect(screen, start.x, start.y, lineend.x, lineend.y);

You probably want to change that into :
SDL_UpdateRect(screen, start.x, start.y, lineend.x-start.x,
lineend.y-start.y);

Since SDL_UpdateRect takes width and height as 3rd and 4th parameters.

Stephane

SDL_UpdateRect(screen, start.x, start.y, lineend.x, lineend.y);

The prob is that I get unwanted artifacts (pixels) as the screen
starts to
fill. If I use

SDL_UpdateRect(screen, 0, 0, 0, 0)

I don’t get those artifacts, but it slows the code down somewhat. Is
there a
way around this?

You should not get artifact using update rect with only the updated
region. Make sure to use the width and height of the rectangle as the
3rd and 4th params of SDL_UpdateRect().

What type of artifacts do you get? Are they only at the boundary of
your rect? then maybe you could enlarge it a little bit…