Skip to main content
GameDev.net gamedev.net
🔒 Locked

Question about SDL?

Started by mits Sep 5, 2003 at 1:56 PM 8 replies 1.1k views
Original Post
mits
mits
I don''t if this is the right place to post a question about SDL so sorry if it isn''t.So , what''s the SDL function which clears the buffer in every frame similar to , let''s say , OpenGL''s glClear()? Thanks in advance
Sabbac
Sabbac
Take a look at SDL_FillRect(...) or A. Schiffler''s SDL_gfxPrimitives library for boxColor(...) and boxRGBA(...)
mits
mits
What exactly SDL_UpdateRect does?Thanks
Sabbac
Sabbac
I think SDL_UpdateRect(..) works simular to SDL_Flip except only a portion of the screen is copied from the back buffer.
_SKOTTIE_
_SKOTTIE_
if you are printing a background image to teh screen... dont use fillrect because it is slow. only use fillrect if there is no background image.
Because you touch yourself at night!
Sabbac
Sabbac
quote:
Original post by _SKOTTIE_
if you are printing a background image to teh screen... dont use fillrect because it is slow. only use fillrect if there is no background image.


True. Also if you know your going to completely fill the screen every time there is no need to clear the buffer.
mits
mits
Thanks guys for the answers.However , I have another last question.I have just started dealing with SDL.Is it possible to make an Arkanoid game with SDL since I''ll have to use float numbers for the position of the ball,the speed and other things and I can see that e.g SDL_BlitSurface() uses only short integers?
Thanks
Sabbac
Sabbac
quote:
Original post by mits
Thanks guys for the answers.However , I have another last question.I have just started dealing with SDL.Is it possible to make an Arkanoid game with SDL since I''ll have to use float numbers for the position of the ball,the speed and other things and I can see that e.g SDL_BlitSurface() uses only short integers?
Thanks



The first game I wrote while evaluating SDL was an Arkanoid clone (I think... That''s just a Breakout clone, right?)

In order to use use floating point for positioning, just convert to int''s before you draw. It isn''t that expensive. I usually use floats to represent positions and velocities so I know you''ll be fine.
mits
mits
Ok but if I convert floats to ints , won''t I have loss of data?
Thanks
stepman
stepman
quote:
Original post by mits
Ok but if I convert floats to ints , won''t I have loss of data?
Thanks



well, (statistically speaking) the position you''re displaying will be about a half pixel off. i don''t think that''s too much of a problem for a breakout type of game...

since you''d only convert your values to integer for the display function, and keep the floats for further calculations, the error won''t be accumulating over time.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.