aglSetDrawable desperation

Oldtimer
Posts: 832
Joined: 2002.09
Post: #1
Some of you may have heard me whine about this in the #idevgames channel for about a month now... The trouble is suspending the context to be able to check mail and stuff, and then get back into the game again. What I think happens is that memory is overwritten somewhere, causing a QuickTime movie (mp3) to think it's a video movie, and it crashes a few seconds down the line. Here's the relevant parts:
(Edited for brevity)

Code:
bmErrCode bmAGL_DSpContext::Suspend (void)
{    
    if (!aglGetDrawable (aglContext)) return kOK;
    
    if (shouldFade)
        DSpContext_FadeGammaOut (NULL, NULL);
    
    glClear (GL_COLOR_BUFFER_BIT);
    theGLController->SwapBuffers();

    aglSetDrawable (aglContext, NULL);
    
    if (shouldFade)
        DSpContext_FadeGammaIn (NULL, NULL);

    ShowCursor();
    return kOK;
}

Code:
bmErrCode bmAGL_DSpContext::Resume (void)
{
    if (aglGetDrawable (aglContext)) return kOK;
    if (shouldFade)
        DSpContext_FadeGammaOut (NULL, NULL);
        
    
       #if __MACH__
       float     refreshRate = GetRefreshRate();
       #else
       float refreshRate = 60.0;
       #endif
      
       aglSetFullScreen (aglContext, width, height, refreshRate, 0);
    glViewport (0, 0, width, height);

    if (contextType != kWindowedCtx) HideCursor();
    glClear (GL_COLOR_BUFFER_BIT);
    aglSwapBuffers (aglContext);
    
    if (shouldFade)
        DSpContext_FadeGammaIn (NULL, NULL);
    
    return kOK;
}

(Argh, messed-up whitespace. Sorry.)

The line that causes the crash is the aglSetDrawable (aglContext, NULL); in Suspend(). I've checked for it's return value, and aglGetError() is silent. Is there anything obvious that I've done wrong?

Desperately yours,
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
tried adding an aglSetCurrentContext(NULL)?
Quote this message in a reply
Member
Posts: 79
Joined: 2002.08
Post: #3
I don't know what exactly you are trying to do but it sounds like the problem I had a long time ago. I was playing music via QT and then swapped out of my full screen context to Finder. After switching back to the full screen context it always crashed after a little while. I never got it solved but it looks like QT gets hosed somewhere somehow when you switch out of the full screen context.

I tried all kinds of things to set ports, etc that could possible affect QT somehow but no luck. It's still one of the things I'd like to know how to do.

KenD

CodeBlender Software - http://www.codeblender.com
Quote this message in a reply
Member
Posts: 157
Joined: 2002.12
Post: #4
when you switch out, is the sound playing?

try not making gl calls after Resume(), if still crashes then it must be quicktime, if it does not then something gets messup in the ctx. try re-creating the ctx.
Quote this message in a reply
Oldtimer
Posts: 832
Joined: 2002.09
Post: #5
I finally solved this, after months of hacking. I didn't find a good solution however but a workaround. What happens is the following: when I switch out of fullscreen, memory gets corrupted somewhere, and in this case the background music gets thrashed. Thrashed so bad that QuickTime thinks it is a movie and not a music track, and subsequently tries to SetPortRGBForeColor on it. My workaround is to delete the music track before switching out, and then re-loading it when I switch back in. Perhaps this can help someone. Smile
Quote this message in a reply
Post Reply