Jump to content

  • Log In with Google      Sign In   
  • Create Account

Calling all IT Pros from Canada and Australia.. we need your help! Support our site by taking a quick sponsored surveyand win a chance at a $50 Amazon gift card. Click here to get started!


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 leagal4ever   Members   -  Reputation: 566

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.


Sponsor:

#2 fastcall22   Crossbones+   -  Reputation: 6250

Like
0Likes
Like

Posted 26 November 2012 - 01:50 PM

Sounds like screen tearing. What does your rendering code look like?
gzip: H4sIAAAAAAAEAG1QTUvEMBC991e8nvaiFfYoS7yo sLCo6MnjtJ1ugmkiyWRL/72z3T1YEQIJ8z4zA2Xp yPvt1qBpGrRFIJZkk9FyRyUzHCbKIHgn4hnZOrm1 TD0mG0HCCs+QGDGWziKXI6Wm2n++GYwUVH2mrGEE PnGCVQ8K8+JYfXA6URDEQfMZh5h6g5eoAlWJdeEI bbH2qYZf7XMUfw8f/Q0oMeZYNL9/WHF0uFEshvMr XYujd9SycFb+F18QcSOvlJauZ8ejqevdnV7/d550 e0t6prmunh73Bu+vz4c/XUeOQXfJgvKNkhf95U8/ Dtgmy5IBAAA=

#3 leagal4ever   Members   -  Reputation: 566

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 fastcall22   Crossbones+   -  Reputation: 6250

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.

gzip: H4sIAAAAAAAEAG1QTUvEMBC991e8nvaiFfYoS7yo sLCo6MnjtJ1ugmkiyWRL/72z3T1YEQIJ8z4zA2Xp yPvt1qBpGrRFIJZkk9FyRyUzHCbKIHgn4hnZOrm1 TD0mG0HCCs+QGDGWziKXI6Wm2n++GYwUVH2mrGEE PnGCVQ8K8+JYfXA6URDEQfMZh5h6g5eoAlWJdeEI bbH2qYZf7XMUfw8f/Q0oMeZYNL9/WHF0uFEshvMr XYujd9SycFb+F18QcSOvlJauZ8ejqevdnV7/d550 e0t6prmunh73Bu+vz4c/XUeOQXfJgvKNkhf95U8/ Dtgmy5IBAAA=

#5 leagal4ever   Members   -  Reputation: 566

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.



PARTNERS