SDL question

I have one question about SDL: Is it possible to change the window size
interactively ?

You mean by using the mouse? Not now. You can change the window size by
calling SDL_SetVideoMode(), but not interactively.

If not, will it be possible in the future?

Unlikely. SDL is designed to be a fixed framebuffer application, at the
moment. This of course could change in the future.

See ya!
-Sam Lantinga (slouken at devolution.com)–
Author of Simple DirectMedia Layer -
http://www.devolution.com/~slouken/SDL/

My name is Christian Granstr?m. My question is very simple but I
couldn?t find the answer in the documentation. Since Im a long time
Demo-coder from the Amiga Im realy interested in how SDL handles the
concept of VerticalBlanking synchronization before swapping
framebuffers. Does SDL synchronize with the VBL before switching buffers
if possible or is it just ignored and swapping occurs at once?

If you’re talking about the new SDL_Flip() API in 0.9.x, then yes, SDL
sets up a flip in hardware and waits for vertical retrace before switching
buffers. If you’re talking about the standard SDL_UpdateRects(), then no,
it doesn’t. Note that calling SDL_Flip() in windowed mode is equivalent
to calling SDL_UpdateRect(0, 0, 0, 0)

I had some strange problems initializing fullscreenmodes under XFree86
with my Matrox Mystique 220. It seems as if XFree keeps it?s current
resolution but the surface I draw to is kind of centered to that screen.
Looks realy strange. Bug in XFree MGA-server???

Under XFree86, SDL is limited to the modes available in the X configuration
file, /etc/XF86Config. You can toggle between them manually using Ctrl-Alt-+
SDL works around this limitation by providing an offset address for modes
smaller than the smallest one defined, providing a virtual screen at the
proper mode. If SDL is stuck at your current mode, you might try seeing if
you can manually toggle to another mode, and if you can’t, run XF86Setup
to enable more modes.

I’m CC’ing this to the SDL list, since these are good questions. :slight_smile:

CU
-Sam Lantinga (slouken at devolution.com)–
Author of Simple DirectMedia Layer -
http://www.devolution.com/~slouken/SDL/

I have a quick question about SDL. What is the best way to load multiple
sprites from one BMP file?

Load the BMP file as a single surface, and use SDL_BlitSurface() to blit
the portion of that surface corresponding to your sprite to the screen.

e.g. Let’s say your sprites are 32x32 and they are in a 32xVeryWide surface.
Then:

spritesurf = SDL_LoadBMP(blahblahblah)
for ( i=0; i<numsprites; ++i ) {
spriterect[i].x = i*32;
spriterect[i].y = 0;
spriterect[i].w = 32;
spriterect[i].h = 32;
}

Now let’s say you’re blitting sprite at index 3 to location (37, 24)

dstrect.x = 37;
dstrect.y = 24;
dstrect.w = 32;
dstrect.h = 32;
SDL_BlitSurface(spritesurf, &spriterect[3], screen, &dstrect);
SDL_UpdateRects(screen, 1, &dstrect);

See ya!
-Sam Lantinga (slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
Author of Simple DirectMedia Layer -
http://www.devolution.com/~slouken/SDL/

doh! i should have thought of that. :slight_smile:

ok, that’s very useful.

i did notice one unusual thing when traveling down the (unnecessary)
unbeaten path. the function “SDL_MapSource()” could not be found when
linking the object files. this may be on purpose, but the documentation
seemed to imply that this is not a private function.

thanks for your help,
kiptonOn Thu, 18 Mar 1999, Sam Lantinga wrote:

I have a quick question about SDL. What is the best way to load multiple
sprites from one BMP file?

Load the BMP file as a single surface, and use SDL_BlitSurface() to blit
the portion of that surface corresponding to your sprite to the screen.