Resizeable windows on the MacOS

I wrote some window resizeing code on the MacOS and would like to commit
it to the SDL comunity. ( Sam ? )

But I had some problems:

  1. My Voodoo 3 doesn’t accelerate OpenGL usign the toolbox, no idea why,
    because Fullscreen with DSp works quite great ( But that did never work
    :slight_smile: )
  2. When resizing the window, the SDLGears that I use for testing has to
    resize the window, too. This causes the window to
    always be centered in the middle of the screen. All right up to now. But
    then I do not see anything rendered.
    The alternative to resize the window and to not post a resizeEvent onto
    theSDL event queue causes the viewport to be wrong (as expected). The
    same is true for zooming the window.
    Collaping works fine though. :slight_smile:

Perhaps you have a guess ?

Sven.

Organization: Loki Entertainment Software
Newsgroups: loki.open-source.sdl

I wrote some window resizeing code on the MacOS and would like to commit
it to the SDL comunity. ( Sam ? )

But I had some problems:

  1. My Voodoo 3 doesn’t accelerate OpenGL usign the toolbox, no idea why,
    because Fullscreen with DSp works quite great ( But that did never work
    :slight_smile: )

I have a fix for this. There is an error in the AGL attributes setup. See
code snippet below.

  1. When resizing the window, the SDLGears that I use for testing has to
    resize the window, too. This causes the window to
    always be centered in the middle of the screen. All right up to now. But
    then I do not see anything rendered.

If a window (OpenGL) is resized, you have to reattach the drawable
(AGL_SetDrawable) and also make it current (SDL_GL_MakeCurrent() ). Then do
a buffer swap (SDL_GL_SwapBuffers()). I’m not sure, is the buffer swap up to
the application or do we do that?

The alternative to resize the window and to not post a resizeEvent onto
theSDL event queue causes the viewport to be wrong (as expected).

We should post a resize event, so the app can make the necessary adjustments
to the viewport and/or viewing projection.

Here is my fix for Mac_GL_Init(). You should rip out the existing attributes
code and put this in.

AGLPixelFormat format;
GLboolean noerr;
GLint attributes [ 24 ]; /* 24 is max attributes possible in this setup
*/
int i = 0;

attributes[i++] = AGL_RGBA;

if ( this->gl_config.double_buffer )
attributes[i++] = AGL_DOUBLEBUFFER;

if ( this->gl_config.depth_size != 0 ) {

  attributes[i++] = AGL_DEPTH_SIZE;
  attributes[i++] = this->gl_config.depth_size;

}

attributes[i++] = AGL_RED_SIZE;
attributes[i++] = this->gl_config.red_size;
attributes[i++] = AGL_GREEN_SIZE;
attributes[i++] = this->gl_config.green_size;
attributes[i++] = AGL_BLUE_SIZE;
attributes[i++] = this->gl_config.blue_size;
attributes[i++] = AGL_ALPHA_SIZE;
attributes[i++] = this->gl_config.alpha_size;

if ( this->gl_config.stencil_size != 0 ) {
attributes[i++] = AGL_STENCIL_SIZE;
attributes[i++] = this->gl_config.stencil_size;
}

if ( this->gl_config.accum_red_size != 0 &&
this->gl_config.accum_blue_size != 0 &&
this->gl_config.accum_green_size != 0 ) {

  attributes[i++] = AGL_ACCUM_RED_SIZE;
  attributes[i++] = this->gl_config.accum_red_size;
  attributes[i++] = AGL_ACCUM_GREEN_SIZE;
  attributes[i++] = this->gl_config.accum_green_size;
  attributes[i++] = AGL_ACCUM_BLUE_SIZE;
  attributes[i++] = this->gl_config.accum_blue_size;
  attributes[i++] = AGL_ACCUM_ALPHA_SIZE;
  attributes[i++] = this->gl_config.accum_alpha_size;
}

attributes[i++] = AGL_ALL_RENDERERS;
attributes[i] = AGL_NONE;

format = aglChoosePixelFormat(NULL, 0, attributes);
if ( format == NULL ) {
    SDL_SetError("Couldn't match OpenGL desired format");
    return(-1);
}> From: Sven Schaefer <sschafer at rbg.informatik.tu-darmstadt.de>

Reply-To: sdl at lokigames.com
Date: Wed, 20 Sep 2000 02:20:20 +0200
To: sdl at lokigames.com
Subject: [SDL] Resizeable windows on the MacOS

If a window (OpenGL) is resized, you have to reattach the drawable
(AGL_SetDrawable) and also make it current (SDL_GL_MakeCurrent() ). Then do
a buffer swap (SDL_GL_SwapBuffers()). I’m not sure, is the buffer swap up to
the application or do we do that?

If a buffer swap is needed, it’s very possible the scene needs to be
redrawn first, so I suspect this should be left to the app.
(knowing nothing about MacGL, but a general OpenGL property is the back
buffer contents are undefined after a swap and thus a 2nd swap could
potentially mean garbage)

Yess. Hardware accelerated OpenGL is cool :slight_smile:

Thanks Darrell, but what exactly was the problem ? Didn’t look myself :slight_smile:

Sven

Darrell Walisser wrote:>

I have a fix for this. There is an error in the AGL attributes setup. See
code snippet below.

Here is my fix for Mac_GL_Init(). You should rip out the existing attributes
code and put this in.

I wrote some window resizeing code on the MacOS and would like to commit
it to the SDL comunity. ( Sam ? )

Yes! :slight_smile:
Please send it to @slouken

I have a fix for this. There is an error in the AGL attributes setup. See
code snippet below.

I’ll add this to CVS.

We should post a resize event, so the app can make the necessary adjustments
to the viewport and/or viewing projection.

That’s correct. If you look at the other SDL_RESIZABLE implementations,
you’ll see that’s exactly what they do.

Here is my fix for Mac_GL_Init(). You should rip out the existing attributes
code and put this in.

Thanks!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software