Multisampling crash problem

Hello

I?m working on a project made with SDL that has the ability for the user to
choose various video settings at run-time. The problem is that when
multisampling is changed at runtime, other than once on program start, the
program crashes.

Here is some example code below. Help much appreciated.
Thanks.

SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS,1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES,6);

SDL_Surface* screen = SDL_SetVideoMode(640, 480, 32, SDL_OPENGL);
if ( !screen )
return 1;

//…
//User wants anti-aliasing disabled
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS,0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES,1);

//Crash
screen = SDL_SetVideoMode(640, 480, 32, SDL_OPENGL);
if ( !screen )
return 1;

Don’t quote me on this, but I don’t think this is legal as SDL goes.

Try shutting down SDL, free the screen surface then restart SDL with the new settings.

Ed> ----- Original Message -----

From: willeom@gmail.com (Will)
To: sdl at libsdl.org
Sent: Sunday, 1 July, 2007 8:11:24 PM
Subject: [SDL] Multisampling crash problem

Hello

I?m working on a project made with SDL that has the ability for the user to
choose various video settings at run-time. The problem is that when
multisampling is changed at runtime, other than once on program start, the
program crashes.

Here is some example code below. Help much appreciated.
Thanks.

SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS,1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES,6);

SDL_Surface* screen = SDL_SetVideoMode(640, 480, 32, SDL_OPENGL);
if ( !screen )
return 1;

//…
//User wants anti-aliasing disabled
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS,0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES,1);

//Crash
screen = SDL_SetVideoMode(640, 480, 32, SDL_OPENGL);
if ( !screen )
return 1;


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

  ___________________________________________________________ 

Yahoo! Mail is the world’s favourite email. Don’t settle for less, sign up for
your free account today http://uk.rd.yahoo.com/evt=44106/*http://uk.docs.yahoo.com/mail/winter07.html

It works!

A bit hacky though because the window gets destroyed and recreated
again (flickers).

Thanks.

Try shutting down SDL, free the screen surface then restart SDL with the
new settings.

You shouldn’t have to (and you shouldn’t ever free the screen surface
directly…SDL_Quit() does that).

I’ll take a look into this, it’s probably a bug in SDL.

–ryan.

I’ll take a look into this, it’s probably a bug in SDL.
Thanks
That would help a lot :~)

I?m working on a project made with SDL that has the ability for the user to
choose various video settings at run-time. The problem is that when
multisampling is changed at runtime, other than once on program start, the
program crashes.

I just tried the attached program on Linux/x11 and Mac OS X/quartz and
it worked on both without crashing (although the Linux
SDL_SetVideoMode() returned NULL with 6 MULTISAMPLESAMPLES, 2 got the
same effect).

What platform is this crashing on? What version of SDL and the OS?

Test program was compiled as:

gcc -Wall -O0 -g -o test test.c `sdl-config --cflags --libs`

with the latest Subversion of SDL, on Ubuntu 7.04, and Mac OS X
10.4.10/intel.

–ryan.

-------------- next part --------------
A non-text attachment was scrubbed…
Name: test.c
Type: text/x-csrc
Size: 881 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20070702/ae49f4e5/attachment.c

What platform is this crashing on? What version of SDL and the OS?

Sorry, I’m using SDL-1.2.11 on windows vista compiled with MinGW GCC through the
Code::Blocks IDE.

I get this message when run:
Checking for existence: C:\dev\C++\Expariment\sdl\sdl.exe
Executing: “C:\dev\C++\Expariment\sdl\sdl.exe” (in C:\dev\C++\Expariment\sdl.)
Process terminated with status 3 (0 minutes, 1 seconds)

For convenience, the full source follows:

#include <GL/gl.h>
#include <SDL.h>

int main (int argc,char** argv)
{
//Initialize SDL video
if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
return 1;
atexit(SDL_Quit);

SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS,1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES,4);

SDL_Surface* screen = SDL_SetVideoMode(640, 480, 32, SDL_OPENGL);
if ( !screen )
    return 1;

//Ant-Aliasing disabled by user
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS,0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES,0);
screen = SDL_SetVideoMode(640, 480, 32, SDL_OPENGL);
if ( !screen )
    return 1;

glScalef(0.5f,0.5f,0.5f);

// program main loop
bool done = false;
while (!done)
{
    // message processing loop
    SDL_Event event;
    while (SDL_PollEvent(&event))
    {
        switch (event.type)
        {
            case SDL_QUIT:
                done = true;
                break;
            case SDL_KEYDOWN:
                if (event.key.keysym.sym == SDLK_ESCAPE)
                    done = true;
                break;
        }
    }

    glClear(GL_COLOR_BUFFER_BIT);
    glRotatef((22.0f/7.0f)*(1.0f/128.0f),0,0,1);
    glBegin(GL_TRIANGLES);
        glColor3ub(255,0,0);
        glVertex2f(-1,-1);
        glColor3ub(0,255,0);
        glVertex2f(1,-1);
        glColor3ub(0,0,255);
        glVertex2f(0,1);
    glEnd();

    SDL_GL_SwapBuffers();
}

return 0;

}