Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


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

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

Like
0Likes
Like

Posted 26 November 2012 - 01:50 PM

Sounds like screen tearing. What does your rendering code look like?
QWxsIHRvYXN0LXRvYXN0aW5nIHRvYXN0ZXJzIGNhbiB0b2FzdCB0b2FzdGVkIHRvYXN0LCBhbHRob3Vn aCByZS10b2FzdGluZyB0b2FzdGVkIHRvYXN0IGlzIGdlbmVyYWxseSBub3QgcmVjb21tZW5kZWQgYnkg dGhlIG1hbnVmYWN0dXJlcnMgb2YgdG9hc3QtdG9hc3RpbmcgdG9hc3RlcnMuLi4=

#3 leagal4ever   Members   -  Reputation: 562

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

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.

QWxsIHRvYXN0LXRvYXN0aW5nIHRvYXN0ZXJzIGNhbiB0b2FzdCB0b2FzdGVkIHRvYXN0LCBhbHRob3Vn aCByZS10b2FzdGluZyB0b2FzdGVkIHRvYXN0IGlzIGdlbmVyYWxseSBub3QgcmVjb21tZW5kZWQgYnkg dGhlIG1hbnVmYWN0dXJlcnMgb2YgdG9hc3QtdG9hc3RpbmcgdG9hc3RlcnMuLi4=

#5 leagal4ever   Members   -  Reputation: 562

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