Results 1 to 4 of 4

Thread: SetPixelFormat Fails

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2001
    Location
    Halifax,NS,Canada
    Posts
    16

    SetPixelFormat Fails

    Below is my code. I can't seem to understand whats wrong with it.

    I'm getting a very wierd error number too.
    m_GLPixelIndex = 4
    and
    errCode = 3221684230 ?

    Anyone has an idea ?


    bool GL3DView::setFormat()
    {
    //HWND hMainWnd = ::GetDesktopWindo();
    //HDC hMainDC = ::GetDC(hMainWnd);
    HDC hDC = qt_display_dc();

    PIXELFORMATDESCRIPTOR pixelDesc = // pfd Tells Windows How We Want Things To Be
    {
    sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
    1, // Version Number
    PFD_DRAW_TO_WINDOW | // Format Must Support Window
    PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
    PFD_DOUBLEBUFFER, // Must Support Double Buffering
    PFD_TYPE_RGBA, // Request An RGBA Format
    24, // Select Our Color Depth
    0, 0, 0, 0, 0, 0, // Color Bits Ignored
    0, // No Alpha Buffer
    0, // Shift Bit Ignored
    0, // No Accumulation Buffer
    0, 0, 0, 0, // Accumulation Bits Ignored
    16, // 16Bit Z-Buffer (Depth Buffer)
    0, // No Stencil Buffer
    0, // No Auxiliary Buffer
    PFD_MAIN_PLANE, // Main Drawing Layer
    0, // Reserved
    0, 0, 0 // Layer Masks Ignored
    };

    int m_GLPixelIndex = ChoosePixelFormat(hDC,&pixelDesc);

    if(SetPixelFormat(hDC,m_GLPixelIndex,&pixelDesc)== FALSE)
    {
    DWORD errCode = GetLastError();
    return FALSE;
    }

    return TRUE;
    }

  2. #2
    Senior Member Regular Contributor
    Join Date
    Apr 2001
    Posts
    340

    Re: SetPixelFormat Fails

    You could try to know what is in the pixel format to see if the format index sounds reasonnable (and matches your request) :

    DescribePixelFormat(hDC,FormatIndex,sizeof(PIXELFO RMATDESCRIPTOR),&pixelDesc);

    Add this line after the ChoosePixelFormat call and look at which fields of the pixeldesc change.

    Some ideas :
    are you sure the dc you get is valid?
    when do you call this 'setFormat' method?
    are you sure this method is called only once?
    are you sure qt does not use SetPixelFormat itself (MSDN states that SetPixelFormat is allowed only once per window)?
    also, SetPixelFormat must be called before creating the rendering context

    hope this helps
    regards

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2001
    Location
    Halifax,NS,Canada
    Posts
    16

    Re: SetPixelFormat Fails

    I know QT runs setFormat ..

    I was trying to override without having to reimplement the class ...


    Is there a way to release it then set it again ?

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: SetPixelFormat Fails

    Destroy and recreate the window, then call SetPixelFormat again.

Similar Threads

  1. [W32 OpenGL] second call to SetPixelFormat fails
    By aiscape in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 08-28-2003, 03:56 AM
  2. SetPixelFormat() fails
    By Condor in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 04-28-2002, 11:34 PM
  3. SetPixelFormat fails the second time it's called
    By CGameProgrammer in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 02-16-2001, 12:59 PM
  4. SetPixelFormat()
    By skippyj777 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-13-2000, 04:31 PM
  5. SetPixelFormat
    By in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 02-11-2000, 03:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean