How am I supposed to use resize events in SDL1.2?

Hi,

I’ve created a simple app in ocaml and run it under X on Linux. I’ve set
the video mode to resizable so the user can resize the window. All of
that works just fine and the app gets resize events whenever the user
resizes.

BUT: The resize does not seem to reisze the surface of the window.

When the window shrinks I can clip the output to the visible portion
of the surface. Not so when the window grows. The surface is too
small. And the only way to get a bigger surface seems to be to call
set_video_mode to create a new surface.

Now the problem is that set_video_mode will resize the window. In my
window manager the window contents are redrawn in real-time while the
window is resized. So I get a resize event for every pixel the window
is resized. And while the WM is resizing the window the app’s resize
requests are queued up for later consideration. Then when I lift my
finger from the mouse button and end the resize all the queued up
resize requests from set_video_mode get processed. So the window
iterates over all the inbetween sizes. This even seems to spawn new
resize events to the size changes keep going and feed themself and the
window never comes to rest.

So how am I supposed to use resize events?

MfG
Goswin

It sounds like you’re not scaling your output when a resize occurs. For
instance, if you are drawing based on 800x600, if the user resizes to
500x600, is your rendering still based on 800x600? If so, it will clip 300
pixels on the right. If you resized to 900x600, 100pixels on the right
will be blank. SDL 1.2, afaik, does not scale your rendering output.

Hopefully that helps,
-AlexOn Thu, Jul 25, 2013 at 10:42 AM, Goswin von Brederlow wrote:

Hi,

I’ve created a simple app in ocaml and run it under X on Linux. I’ve set
the video mode to resizable so the user can resize the window. All of
that works just fine and the app gets resize events whenever the user
resizes.

BUT: The resize does not seem to reisze the surface of the window.

When the window shrinks I can clip the output to the visible portion
of the surface. Not so when the window grows. The surface is too
small. And the only way to get a bigger surface seems to be to call
set_video_mode to create a new surface.

Now the problem is that set_video_mode will resize the window. In my
window manager the window contents are redrawn in real-time while the
window is resized. So I get a resize event for every pixel the window
is resized. And while the WM is resizing the window the app’s resize
requests are queued up for later consideration. Then when I lift my
finger from the mouse button and end the resize all the queued up
resize requests from set_video_mode get processed. So the window
iterates over all the inbetween sizes. This even seems to spawn new
resize events to the size changes keep going and feed themself and the
window never comes to rest.

So how am I supposed to use resize events?

MfG
Goswin


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

It sounds like you’re not scaling your output when a resize occurs. For instance, if you are drawing based on 800x600, if the user resizes to 500x600, is your rendering still based on 800x600? If so, it will clip 300 pixels on the right. If you resized to 900x600, 100pixels on the right will be blank. SDL 1.2, afaik, does not scale your rendering output.

This is not what the poster is saying.

When you hold down the mouse and start resizing the window,
the OS is redrawing the window contents as the window is resized,
but SDL is NOT issuing any resize events.
The resize events are queued up instead.

Then, when the mouse is released, the queued up resize events
flood in.

On OSX, I only get one size_changed and one resize event,
in that order, so again, there is no way to redraw the surface during
the resize operation.

It looks horrible. On OSX I get mouse droppings all over the bottom
right corner, and only the smallest part of the window surface exposed
during the resize is retained by the OS.

This is clearly a bug in SDL. The resize (or size changed?) events should be
posted during the resize before the mouse is released. And on OSX they
should be posted regularly not just once.

If the size is changed under program control, I guess only one of these
should be posted (so the program can redraw asynchronously with
the size change request).On 26/07/2013, at 1:02 AM, Alex Barry wrote:


john skaller
@john_skaller
http://felix-lang.org

It sounds like you’re not scaling your output when a resize occurs. For instance, if you are drawing based on 800x600, if the user resizes to 500x600, is your rendering still based on 800x600? If so, it will clip 300 pixels on the right. If you resized to 900x600, 100pixels on the right will be blank. SDL 1.2, afaik, does not scale your rendering output.

I don’t want to scale, that would blur. I want to draw more.

This is not what the poster is saying.

When you hold down the mouse and start resizing the window,
the OS is redrawing the window contents as the window is resized,
but SDL is NOT issuing any resize events.
The resize events are queued up instead.

No, that isn’t what I’m saying either.

I’m getting resize events just fine. The surface of the window just
does no change size.

So I start with a window that is 800x600 pixel:On Fri, Jul 26, 2013 at 01:22:35PM +1000, john skaller wrote:

On 26/07/2013, at 1:02 AM, Alex Barry wrote:

±---------------+
|################|
|################|
|################|
|################|
|################|
|################|
±---------------+

and then resize to 1000x800 pixel:

±-------------------+
|################ |
|################ |
|################ |
|################ |
|################ |
|################ |
| |
| |
±-------------------+

The surface remains at 800x600 pixel and it looks bad.

As said I don’t want the surface to scale. I want to get a 1000x800
pixel surface to draw in.

The only way, it seems, to get the surface to change to 1000x800 pixel
is to init the video mode again. But if I do that, THAT is blocked by
the window manager having the window in resize mode. The SDLs resize
only happens after the mouse button is released and the window snaps
back to the original size + 1 pixel, then +2 pixle, +3, +4, +5, …
till it gets to 1000x800 pixel and then it starts all over again
because for some reason the resize from SDL triggers another resize
event.

MfG
Goswin

No, that isn’t what I’m saying either.

Ooops, sorry.

I’m getting resize events just fine. The surface of the window just
does no change size.

So I start with a window that is 800x600 pixel:

±---------------+
|################|
|################|
|################|
|################|
|################|
|################|
±---------------+

and then resize to 1000x800 pixel:

±-------------------+
|################ |
|################ |
|################ |
|################ |
|################ |
|################ |
| |
| |
±-------------------+

The surface remains at 800x600 pixel and it looks bad.

Are you re-fetching the surface from the Window?

The way I understand it, SDL_GetWindowSurface creates
an in memory software surface with the same pixel format and
size as the window at the time it is called. It has a pointer
to the window. You draw on the surface but nothing happens
until you update, which copies the pixels to the actual window.

If the window is resized, the surface is no longer valid and a new
one must be fetched.On 28/07/2013, at 8:04 PM, Goswin von Brederlow wrote:


john skaller
@john_skaller
http://felix-lang.org