• Advertisement
Sign in to follow this  

sdl distorted SDL_FillRect and images

This topic is 1882 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello i have problem with distorted rectangle, this problem also happen with images.

examplejy.png
Distorted rectangle looks like this.

Its happen only for moment every few seconds, it become obvious while moving ,any idea how to fix it? Edited by leagal4ever

Share this post


Link to post
Share on other sites
Advertisement
Yeah its tearning.

// init
SDL_Init(SDL_INIT_EVERYTHING);
screen = SDL_SetVideoMode(800, 600, 32, SDL_SWSURFACE | SDL_DOUBLEBUF);

// render
SDL_FillRect(screen, NULL, 0);
for(int i=0; i<box_vec.size(); i++)
{
SDL_FillRect(screen, &box_vec->rect, box_vec->color); // problem rect
}
SDL_Flip(screen);

// update
box_vec->rect.x += box_vec->xvel;
box_vec->rect.y += box_vec->yvel;

Share this post


Link to post
Share on other sites
You're not calling SDL_Init and SDL_SetVideoMode every frame, are you? Those are a at-initialization-resource-loading things and should not be mixed with realtime code... Edited by fastcall22

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement