Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


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

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

Like
0Likes
Like

Posted 26 November 2012 - 01:50 PM

Sounds like screen tearing. What does your rendering code look like?
c3RhdGljIGNoYXIgeW91cl9tb21bMVVMTCA8PCA2NF07CnNwcmludGYoeW91cl9tb20sICJpcyBmYXQiKTs=

#3 leagal4ever   Members   -  Reputation: 529

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

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.

c3RhdGljIGNoYXIgeW91cl9tb21bMVVMTCA8PCA2NF07CnNwcmludGYoeW91cl9tb20sICJpcyBmYXQiKTs=

#5 leagal4ever   Members   -  Reputation: 529

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