Sdl Screen Problems


care to share what you actually ported? Are you ready for a release yet?
 
QUOTE
care to share what you actually ported? Are you ready for a release yet?


It's Zoid's Quest.

I'm not ready yet, might be in a couple of days. I just need to pull a few more fps from the game as it's being quite slow.

This is what it's doing:
If I press the jump button the music will, for a short time, quicken up to normal pace, before slowing down and the character will jump slowly.

If I can work out how to shift the music bit to the 940 then I may just be able to get this out before xmas, but then again the 940 doesn't do libs and this uses SDL_mixer. But either way, we'll see. :)

QUOTE
Just out of interest, what difference does that make..? Does it add a vsync call?


This was the original code that caused problems (with the asterix's):

CODE

videoFlags = SDL_DOUBLEBUF;
videoFlags = SDL_HWPALETTE; /* Store the palette in hardware */

***if(video_info->hw_available)videoFlags|=SDL_HWSURFACE;****
else videoFlags|=SDL_SWSURFACE;

//if(video_info->blit_hw)videoFlags|=SDL_HWACCEL;



This caused the annoying flicker as when I changed the asterix'ed line to SDL_SWSURFACE, the flickering stopped.

As for vsync calls? I couldn't see one, but my experience in SDL is still not quite there so I'm not too sure what I'd be looking for.
 
The screen flickers unless you use SD_HW_SURFACE|SDL_DOUBLEBUF with a bpp of 16
 
namco: don't worry, I remember when I was first learning SDL. In fact, I still have some old bookmarks on my other computer relating to the flickering.

Going back to SDL_HWSURFACE will really help speed you up (as long as all surfaces are 16bit or 8 bit and you use Paeryn's SDL or the SDL that comes with the pre-configured codeblocks). However, you also need to use the flag SDL_DOUBLEBUF

Do a forums search for DOUBLE_BUF and you'll see lots of explanations. You either need to use it, or blit everything to a temporary surface, then blit that temp surface all at once to the real video screen every frame. Otherwise, you'll be randomly blitting to regions of the screen currently visible and causing this flickering. SW_SURFACEs are slow in comparison (don't let that fool you, though, they can actually be perfectly fine in the right situations). When you use SDL_DOUBLEBUF, you need to call SDL_Flip(); every frame instead of UpdateRects. Do a google search for double buffering for an explanation.

Also for sound, make sure you change sample rate to 22050hz and the buffer size to 128 (normally it's 4096!). If you use OGGs for music, be sure to use libTremor. If you use MP3's don't use SDL_Mixer to play them, use libmad.
 
QUOTE
Also for sound, make sure you change sample rate to 22050hz and the buffer size to 128 (normally it's 4096!). If you use OGGs for music, be sure to use libTremor. If you use MP3's don't use SDL_Mixer to play them, use libmad.


I did notice a speed jump when I changed the buffer size from 4096 to 512, but it still wasn't enough.

I'll look at libmad and others tonight.

Thanks all!
 
Back
Top