Hello i have problem with distorted rectangle, this problem also happen with images.
Distorted rectangle looks like this.
Its happen only for moment every few seconds, it become obvious while moving ,any idea how to fix it?
sdl distorted SDL_FillRect and images
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;
// 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;
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...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement