Some SDL Issues
Moderator: Coders of Rage
-
- ES Beta Backer
- Posts: 61
- Joined: Sun Sep 21, 2008 4:46 am
- Location: U.K.
Some SDL Issues
So, I've been building a little platformer to help me learn SDL. Unfortunately, I've been having a couple of issues.
1) I'm not sure how best to describe this, and I can't seem to catch it to take a screenshot of it, but when the sprites move across the screen, sometimes the rows of pixels are out of alignment, and it flickers a bit, sort of like scan lines are being drawn over it. Does anybody know what causes this, and/or how to fix it?
2) Second, it runs slow, REALLY slow, especially when my laptop isn't plugged in (I have a 2.2GHz processor and 2Gigs of RAM, and I sometimes struggle to get 40fps). I'm not really asking for any direct fixes here, just some general optimisation tips. (On this topic, is loading PNGs with SDL image faster than loading BMPs with regular old SDL?)
Thanks.
1) I'm not sure how best to describe this, and I can't seem to catch it to take a screenshot of it, but when the sprites move across the screen, sometimes the rows of pixels are out of alignment, and it flickers a bit, sort of like scan lines are being drawn over it. Does anybody know what causes this, and/or how to fix it?
2) Second, it runs slow, REALLY slow, especially when my laptop isn't plugged in (I have a 2.2GHz processor and 2Gigs of RAM, and I sometimes struggle to get 40fps). I'm not really asking for any direct fixes here, just some general optimisation tips. (On this topic, is loading PNGs with SDL image faster than loading BMPs with regular old SDL?)
Thanks.
Last edited by Chaos Clown on Mon Feb 02, 2009 1:59 pm, edited 1 time in total.
¡SÃ! ¡He dejado en libertad los prisioneros y ahora vengo por ti!
~El Pollo Diablo
~El Pollo Diablo
- LeonBlade
- Chaos Rift Demigod
- Posts: 1314
- Joined: Thu Jan 22, 2009 12:22 am
- Current Project: Trying to make my first engine in C++ using OGL
- Favorite Gaming Platforms: PS3
- Programming Language of Choice: C++
- Location: Blossvale, NY
Re: Some SDL Issues
Yeah... I don't think it should be running that slow LOL...
I just set up SDL on my computer with Visual C++ 2008 Express Edition...
Let me see your source.
I just set up SDL on my computer with Visual C++ 2008 Express Edition...
Let me see your source.
There's no place like ~/
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: Some SDL Issues
I had an issue that sounds kind of similar. I had a chessboard png that I made with an older version of gimp and every time it was drawn or loaded in a different editor it was slanted. If you're using gimp, update or use something else, perhaps.Chaos Clown wrote:1) I'm not sure how best to describe this, and I can't seem to catch it to take a screenshot of it, but when the sprites move across the screen, sometimes the rows of pixels are out of alignment, and it flickers a bit, sort of like scan lines are being drawn over it. Does anybody know what causes this, and/or how to fix it
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
- programmerinprogress
- Chaos Rift Devotee
- Posts: 632
- Joined: Wed Oct 29, 2008 7:31 am
- Current Project: some crazy stuff, i'll tell soon :-)
- Favorite Gaming Platforms: PC
- Programming Language of Choice: C++!
- Location: The UK
- Contact:
Re: Some SDL Issues
I'm not quite sure, but I can probably guess so, due to the smaller file sizes of the PNG, I always use IMG_Load instead of LoadBMPChaos Clown wrote: (On this topic, is loading PNGs with SDL image faster than loading BMPs with regular old SDL?)
---------------------------------------------------------------------------------------
I think I can program pretty well, it's my compiler that needs convincing!
---------------------------------------------------------------------------------------
And now a joke to lighten to mood :D
I wander what programming language anakin skywalker used to program C3-PO's AI back on tatooine? my guess is Jawa :P
I think I can program pretty well, it's my compiler that needs convincing!
---------------------------------------------------------------------------------------
And now a joke to lighten to mood :D
I wander what programming language anakin skywalker used to program C3-PO's AI back on tatooine? my guess is Jawa :P
Re: Some SDL Issues
Not sure, but it seems like you're describing tearing: http://en.wikipedia.org/wiki/Screen_tearing.Chaos Clown wrote: 1) I'm not sure how best to describe this, and I can't seem to catch it to take a screenshot of it, but when the sprites move across the screen, sometimes the rows of pixels are out of alignment, and it flickers a bit, sort of like scan lines are being drawn over it. Does anybody know what causes this, and/or how to fix it?
177
Re: Some SDL Issues
Jesus. I was surprised as to how easy this SDL problem was to solve.
Here is the solution, thank me later
Here is the solution, thank me later
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: Some SDL Issues
sparda wrote:Jesus. I was surprised as to how easy this SDL problem was to solve.
Here is the solution, thank me later
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
-
- ES Beta Backer
- Posts: 61
- Joined: Sun Sep 21, 2008 4:46 am
- Location: U.K.
Re: Some SDL Issues
I read that a little while ago, I don't think that's it, since it only seems to affect moving sprites (the player and enemies).Amarant wrote:Not sure, but it seems like you're describing tearing: http://en.wikipedia.org/wiki/Screen_tearing.Chaos Clown wrote: 1) I'm not sure how best to describe this, and I can't seem to catch it to take a screenshot of it, but when the sprites move across the screen, sometimes the rows of pixels are out of alignment, and it flickers a bit, sort of like scan lines are being drawn over it. Does anybody know what causes this, and/or how to fix it?
Marauder - I only used GIMP for the background, so I'm not sure that's the problem. I'll try changing it though, see if it makes a difference.
I'll play around with the code tonight after college, hopefully the answer will be glaringly obvious after not looking at it for a while (it usually is).
Any Ideas about the slowdown, or is it just my computer (running vista)?
¡SÃ! ¡He dejado en libertad los prisioneros y ahora vengo por ti!
~El Pollo Diablo
~El Pollo Diablo
Re: Some SDL Issues
As far as I can tell the reason you say it isn't tearing is in fact the reason it is tearing.Chaos Clown wrote:I read that a little while ago, I don't think that's it, since it only seems to affect moving sprites (the player and enemies).Amarant wrote: Not sure, but it seems like you're describing tearing: http://en.wikipedia.org/wiki/Screen_tearing.
Tearing can only be seen with moving sprites.
It occurs when the screen displays two different gamestates/frames at the same time, the top half being the older of the two.
Non moving objects will be in the same position in both of the halves and that's why you won't see them tear.
edit:
Hmm, re-read your post and now I'm not sure what you mean by 'it'. If by 'it' you mean tearing, ignore the above, otherwise it still applies.
177
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: Some SDL Issues
So in short try enabling vsync.
As for your slowdown, you probably have horrible implementation happening somewhere. Post some code?
As for your slowdown, you probably have horrible implementation happening somewhere. Post some code?
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
Re: Some SDL Issues
I want to see a screenshot to see what you're rendering, then I would probably need to see how you're rendering it.
For the flickering, you are double buffering, right?
For the flickering, you are double buffering, right?
- M_D_K
- Chaos Rift Demigod
- Posts: 1087
- Joined: Tue Oct 28, 2008 10:33 am
- Favorite Gaming Platforms: PC
- Programming Language of Choice: C/++
- Location: UK
Re: Some SDL Issues
I doubt it. Flickering would likely be the result of using a single buffer. As for the the "scan line" thing, it might just be that you screen refresh rate is too low. If its LCD I've seen what your talking about, and you can't get a screenshot since eveything in the screens buffer is fine.GyroVorbis wrote:I want to see a screenshot to see what you're rendering, then I would probably need to see how you're rendering it.
For the flickering, you are double buffering, right?
Hmm all that is a bit conflicting.
Gyro Sheen wrote:you pour their inventory onto my life
IRC wrote: <sparda> The routine had a stack overflow, sorry.
<sparda> Apparently the stack was full of shit.
-
- ES Beta Backer
- Posts: 61
- Joined: Sun Sep 21, 2008 4:46 am
- Location: U.K.
Re: Some SDL Issues
Here's a screenshot. I'll have a look at double buffering. (It is screen tearing, I'm such an idiot )
Thanks for the help everyone.
EDIT: I tried the whole double buffering thing - It made little to no difference. It may just be my laptop screen, since I can't grab a screenshot of it, no matter how hard I try.
EDIT EDIT: Also, about the slowdown. I found the source of the problem (a bug in the text system, it shouldn't be too hard to fix).
EDIT EDIT EDIT: Removing the text reduces the tearing a LOT. It's almost unnoticable now.
Thanks for the help everyone.
EDIT: I tried the whole double buffering thing - It made little to no difference. It may just be my laptop screen, since I can't grab a screenshot of it, no matter how hard I try.
EDIT EDIT: Also, about the slowdown. I found the source of the problem (a bug in the text system, it shouldn't be too hard to fix).
EDIT EDIT EDIT: Removing the text reduces the tearing a LOT. It's almost unnoticable now.
- Attachments
-
- ScreenShot.png (141.34 KiB) Viewed 1345 times
¡SÃ! ¡He dejado en libertad los prisioneros y ahora vengo por ti!
~El Pollo Diablo
~El Pollo Diablo
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: Some SDL Issues
Are you drawing everything to the backbuffer, not the frontbuffer? If you're drawing to the front buffer and you flip you wouldn't have any difference =) I'm not even sure you can do that in SDL, though.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
- Ginto8
- ES Beta Backer
- Posts: 1064
- Joined: Tue Jan 06, 2009 4:12 pm
- Programming Language of Choice: C/C++, Java
Re: Some SDL Issues
LusikkaMage doubled-buffered her music-showing program...MarauderIIC wrote:Are you drawing everything to the backbuffer, not the frontbuffer? If you're drawing to the front buffer and you flip you wouldn't have any difference =) I'm not even sure you can do that in SDL, though.
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.