Sign in to follow this  
leagal4ever

sdl distorted SDL_FillRect and images

Recommended Posts

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

[URL=http://imageshack.us/photo/my-images/580/examplejy.png/][IMG]http://img580.imageshack.us/img580/1310/examplejy.png[/IMG][/URL]
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
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[i]->rect, box_vec[i]->color); // problem rect
}
SDL_Flip(screen);

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

Share this post


Link to post
Share on other sites
You're not calling [tt]SDL_Init[/tt] and [tt]SDL_SetVideoMode[/tt] 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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this