Gamma Control with DX8?

This is a discussion on Gamma Control with DX8? within the Game Programming forums, part of the General Programming Boards category; Hey, Could someone explain to me how to do a fade out/in using the gamma control with DX8? Thanks ahead ...

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    1

    Gamma Control with DX8?

    Hey,

    Could someone explain to me how to do a fade out/in using the gamma control with DX8?

    Thanks ahead of time.

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    4

    Lightbulb Here's how I do it

    here's some code:

    // Globals
    LPDIRECTDRAW lpdd = NULL;
    LPDIRECTDRAWSURFACE lpddsPrimary = NULL;
    LPDIRECTDRAWGAMMACONTROL lpddgc = NULL;
    bool GammaOK = false;

    // Initialises gamma ramping control. Must be called for fading to work. Stores pointer
    // to gamma control in lpddgc, and set GammaOK to true if successful.
    bool InitGammaRamp(void)
    {
    // Get driver capabilities to determine gamma support.
    DDCAPS ddcaps;
    ZeroMemory(&ddcaps, sizeof(ddcaps));
    ddcaps.dwSize = sizeof(ddcaps);
    lpdd->GetCaps(&ddcaps, NULL);

    // Does the driver support gamma?
    if(!ddcaps.dwCaps2 && DDCAPS2_PRIMARYGAMMA)
    {
    return FALSE;
    }

    // Get the actual gamma control object
    if(lpddsPrimary->QueryInterface(IID_IDirectDrawGammaControl,(LPVOI D*)&lpddgc) != DD_OK)
    {
    return FALSE;
    }

    GammaOK = TRUE;
    return TRUE;
    }


    // This will set the screen brightness to a percentage of total brightness
    // (eg. 0 = black, 100 = normal). It doesn't perform a full fade on it's own,
    // that's up to your program (eg. increment fade variable, call FadeBlack, repeat till 100%)
    // This is so it doesn't tie up control of your program, and so you can still move objects
    // while fading.
    void FadeBlack(int Percent)
    {
    // Check gamma control is initialised
    if (!GammaOK)
    {
    return;
    }

    // Convert 0-100 Percentage to 0-255 Byte
    int NewPercent = (int)((float)Percent * 2.55);

    DDGAMMARAMP ddgr;
    WORD dwGamma;

    ZeroMemory(&ddgr, sizeof(ddgr));

    if (lpddgc->GetGammaRamp(0, &ddgr) != DD_OK)
    {
    return;
    }

    dwGamma = 0;

    for(int iColor = 0; iColor < 256; iColor++)
    {
    ddgr.red[iColor] = dwGamma;
    ddgr.green[iColor] = dwGamma;
    ddgr.blue[iColor] = dwGamma;
    dwGamma+=(WORD)NewPercent;
    }

    lpddgc->SetGammaRamp(0, &ddgr);
    }

    also, if you downloaded the dx8vcsdk.exe (~50MB) from microsoft, check the samples, there's an example there somewhere in the DirectDraw section.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. (Multiline) Edit Control Limit
    By P4R4N01D in forum Windows Programming
    Replies: 9
    Last Post: 05-17-2008, 11:56 AM
  2. line number on a rich edit control
    By rakan in forum Windows Programming
    Replies: 1
    Last Post: 02-18-2008, 06:58 AM
  3. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 05:23 AM
  4. very weird .h problem
    By royuco77 in forum C++ Programming
    Replies: 1
    Last Post: 09-11-2005, 07:55 AM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21