Advertisement Jump to content
Sign in to follow this  

sdl distorted SDL_FillRect and images

This topic is 2249 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.

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
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

// 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

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!