home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-

New Paste :: Recent Pastes:: No Line Numbers

setting/resetting SDL by godecho
bool ScreenMgr::Screen::SetVideoMode()
    unsigned int oldWidth    = width;
    unsigned int oldHeight    = height;
    SDL_SetGamma(gamma, gamma, gamma);
    flags = SDL_OPENGL | isFullScreen*SDL_FULLSCREEN;        // Other places that I use a bool like an int it complains, but not here. *shrug*
    ratio = float(width)/float(height);

    if(SDL_SetVideoMode(width, height, bpp, flags) == 0)
        width    = oldWidth;
        height    = oldHeight;
        bpp        = unsigned int(SDL_GetVideoInfo()->vfmt->BitsPerPixel);
        LogMgr        ::Inst()->LogErr ("* Video mode set failed: %s", SDL_GetError());
        ConsoleMgr    ::Inst()->AddText("* Video mode set failed: %s", SDL_GetError());
        return false;

    glViewport(0, 0, width, height);
    bpp = unsigned int(SDL_GetVideoInfo()->vfmt->BitsPerPixel);
    // Hip Hop our text over back to where it ought to be
        pFps->x  = width-(strlen(fps.GetFpsText())*10);
        pFps->y  = height-20;

        pTime->x = width-(strlen(timeText)*10);
        pTime->y = height-35;

    /* When we change contexts (going to fullscreen, etc
    everything in vram gets blown away.  What all gets
    held in vram is a subject that I cant find an
    authoritative source on.  Some sources seem to think
    that it could depend on hardware implementation. 
    Things known to get lost: textures, display lists.
    static bool fswitch = false;
        fswitch = true;
    //StateMgr::Inst()->StateSync();        // State *should* be preserved in context change
                                            // However, things like the values of glBlendFunc
                                            // are NOT preserved. Those things aren't handled
                                            // by the the state manager.
    return true;