CVS update (resizing windows)

The latest CVS snapshot has support for user-resizable video modes:
http://www.devolution.com/~slouken/SDL/cvs.html

You have to pass SDL_RESIZABLE to SDL_SetVideoMode(), and then when the
window manager resizes your window, an SDL_VIDEORESIZE event is sent to
your application, and you have to set a new video mode, otherwise your
existing video surface is blitted in the upper left corner of the window
and clipped.

The latest CVS of SMPEG takes advantage of this support to provide
arbitrarily stretched MPEG video playback. :slight_smile:

This is only implemented on UNIX at the moment.

Enjoy! :slight_smile:
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

Sam Lantinga wrote in message …

The latest CVS snapshot has support for user-resizable
video modes:

You da man :slight_smile:

This is only implemented on UNIX at the moment.

I can look at the Win32 resize implementation. Has there been any
preliminary work done on the Win32 fullscreen toggle?

  • Randi

Regimental Command
Generic Armored Combat System
http://www-users.cs.umn.edu/~relander/regcom/index.html

You da man :slight_smile:

Thanks. :slight_smile:

I can look at the Win32 resize implementation.

It should be fairly straightforward - accept the SDL_RESIZABLE flag,
and if that’s set on the video surface, allow resizes and call
SDL_PrivateResize() when they happen. It might be a little complicated
by the fact that DirectDraw surfaces will be invalid.

This is a general problem for the fullscreen toggle too. The DIB code
should be fairly straightforward - just change the screen resolution
and window style, but for DirectDraw, my impression is that you have to
create the primary surface anew, and one of the requirements of the
fullscreen toggle is that the pixel surface doesn’t change pitch or
address.

If you think of a better way to handle the DirectDraw primary surface,
let me know! :slight_smile:

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

Sam Lantinga wrote:

It should be fairly straightforward - accept the
SDL_RESIZABLE flag, and if that’s set on the video
surface, allow resizes and call SDL_PrivateResize()
when they happen.

I’ve got the preliminary DIB version working. Two general questions:

  1. If the current surface is palettized, should the palette be duplicated in
    the new surface? Right now the palette is being initialized as if you were
    starting from scratch and my application has to reload the pallete after
    calling SDL_SetVideoMode.

  2. Would we be better off with a seperate SDL_ResizeVideoMode rather than
    using SDL_SetVideoMode? Right now we are kind of “guessing” if a resize is
    being requested and are forced to pass redundant depth and flag information.

for DirectDraw, my impression is that you have to
create the primary surface anew, and one of the
requirements of the fullscreen toggle is that the pixel
surface doesn’t change pitch or address

Isn’t that what the lock/unlock stuff is for? I guess you might be able to
make assumptions on pitch (maybe) but the address should only be valid
between the lock/unlock. I’ll have to look at the DX5 implementation some
more. (Use the Source, Luke … :slight_smile:

  • Randi

Regimental Command
Generic Armored Combat System
http://www-users.cs.umn.edu/~relander/regcom/index.html

I’ve got the preliminary DIB version working. Two general questions:

  1. If the current surface is palettized, should the palette be duplicated in
    the new surface? Right now the palette is being initialized as if you were
    starting from scratch and my application has to reload the pallete after
    calling SDL_SetVideoMode.

Yes, this is the way it’s currently set up.

  1. Would we be better off with a seperate SDL_ResizeVideoMode rather than
    using SDL_SetVideoMode? Right now we are kind of “guessing” if a resize is
    being requested and are forced to pass redundant depth and flag information.

Possibly, although I’m trying to avoid cluttering the API.
SDL_ResizeVideoMode would be as simple as:

SDL_Surface *SDL_ResizeVideoMode(int w, int h)
{
SDL_Surface *old_screen, *new_screen;
int num_colors;
SDL_Color *old_pal;

old_screen = SDL_GetVideoSurface();
old_pal = NULL;
if ( old_screen->format->palette ) {
	SDL_Palette *pal = old_screen->format->palette;
	num_colors = pal->ncolors;
	old_pal = (SDL_Color *)malloc(num_colors*sizeof(SDL_Color));
	if ( ! old_pal ) {
		return(NULL);
	}
	memcpy(old_pal, pal->colors, num_colors*sizeof(SDL_Color));
}
new_screen = SDL_SetVideoMode(w, h, old_screen->format->BitsPerPixel,
                              old_screen->flags);
if ( new_screen ) {
	if ( old_pal ) {
		SDL_SetColors(new_screen, old_pal, 0, num_colors);
	}
}
return new_screen;

}

Okay, so it’s a little involved. :slight_smile:

for DirectDraw, my impression is that you have to
create the primary surface anew, and one of the
requirements of the fullscreen toggle is that the pixel
surface doesn’t change pitch or address

Isn’t that what the lock/unlock stuff is for? I guess you might be able to
make assumptions on pitch (maybe) but the address should only be valid
between the lock/unlock. I’ll have to look at the DX5 implementation some
more. (Use the Source, Luke … :slight_smile:

That’s correct, although if you don’t specify SDL_HWSURFACE, you’ll get
a software surface that you don’t have to lock, and which can’t change.

See ya,
-Sam Lantinga, Lead Programmer, Loki Entertainment Software