Jump to content

  • Log In with Google      Sign In   
  • Create Account

sdl distorted SDL_FillRect and images


Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
4 replies to this topic

#1   Members   

570
Like
0Likes
Like

Posted 26 November 2012 - 01:42 PM

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

Posted Image
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, 26 November 2012 - 01:44 PM.


#2   Moderators   

9735
Like
0Likes
Like

Posted 26 November 2012 - 01:50 PM

Sounds like screen tearing. What does your rendering code look like?
zlib: eJzVVLsSAiEQ6/1qCwoK i7PxA/2S2zMOZljYB1TO ZG7OhUtiduH9egZQCJH9 KcJyo4Wq9t0/RXkKmjx+ cgU4FIMWHhKCU+o/Nx2R LEPgQWLtnfcErbiEl0u4 0UrMghhZewgYcptoEF42 YMj+Z1kg+bVvqxhyo17h nUf+h4b2W4bR4XO01TJ7 qFNzA7jjbxyL71Avh6Tv odnFk4hnxxAf4w6496Kd OgH7/RxC

#3   Members   

570
Like
0Likes
Like

Posted 26 November 2012 - 02:00 PM

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;

#4   Moderators   

9735
Like
0Likes
Like

Posted 26 November 2012 - 02:21 PM

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, 26 November 2012 - 02:21 PM.

zlib: eJzVVLsSAiEQ6/1qCwoK i7PxA/2S2zMOZljYB1TO ZG7OhUtiduH9egZQCJH9 KcJyo4Wq9t0/RXkKmjx+ cgU4FIMWHhKCU+o/Nx2R LEPgQWLtnfcErbiEl0u4 0UrMghhZewgYcptoEF42 YMj+Z1kg+bVvqxhyo17h nUf+h4b2W4bR4XO01TJ7 qFNzA7jjbxyL71Avh6Tv odnFk4hnxxAf4w6496Kd OgH7/RxC

#5   Members   

570
Like
0Likes
Like

Posted 26 November 2012 - 02:38 PM

No, Init(); is in constructor it run only once, Render(); , Update(); and Fps(); run every frame




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.