CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Pixel Problem

  1. #1
    Guest

    Pixel Problem

    I'm trying to create a simple OpenGL/Mesa app and when I execute the program I get:
    GLUT: Fatal Error in E:\test2\Debug\test2.exe: pixel format with necessary capabilities not found.

    I've messed with ChoosePixelFormat and SetPixelFormat but to no avail. What should I be looking for?

    Here's a snippet of my code:

    int main(int argc, char** argv)
    {

    PIXELFORMATDESCRIPTOR pfd = {
    sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
    1, // version number
    PFD_DRAW_TO_WINDOW | // support window
    PFD_SUPPORT_OPENGL | // support OpenGL
    PFD_DOUBLEBUFFER, // double buffered
    PFD_TYPE_RGBA, // RGBA type
    24, // 24-bit 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, // accum bits ignored
    32, // 32-bit z-buffer
    0, // no stencil buffer
    0, // no auxiliary buffer
    PFD_MAIN_PLANE, // main layer
    0, // reserved
    0, 0, 0 // layer masks ignored
    };
    HDC hdc;
    int iPixelFormat;


    glutInit(&argc, argv);
    glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize(250,250);
    glutInitWindowPosition(100,100);
    iPixelFormat = ChoosePixelFormat(hdc, &pfd);
    SetPixelFormat(hdc, iPixelFormat, &pfd);
    glutCreateWindow("hello");


    }




    Mark Bishop
    [email protected]


  2. #2
    Join Date
    Apr 1999
    Posts
    5

    Re: Pixel Problem

    Mark,

    First thing I can see is that you don't need the whole PIXELFORMATDECRIPTOR block when writing a program using GLUT. IF you removed:

    PIXELFORMATDESCRIPTOR pfd = {
    sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
    1, // version number
    PFD_DRAW_TO_WINDOW | // support window
    PFD_SUPPORT_OPENGL | // support OpenGL
    PFD_DOUBLEBUFFER, // double buffered
    PFD_TYPE_RGBA, // RGBA type
    24, // 24-bit 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, // accum bits ignored
    32, // 32-bit z-buffer
    0, // no stencil buffer
    0, // no auxiliary buffer
    PFD_MAIN_PLANE, // main layer
    0, // reserved
    0, 0, 0 // layer masks ignored
    };
    HDC hdc;
    int iPixelFormat;

    and

    iPixelFormat = ChoosePixelFormat(hdc, &pfd);
    SetPixelFormat(hdc, iPixelFormat, &pfd);

    it should work fine if you specify the appropriate arguments to glutInitDisplayMode(...). For example, if you wanted a double-buffered rgba window with a depth buffer, you would write:

    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);


    Doing what you did may work if you change the PIXELFORMATDESCRIPTOR... what kind of machine/graphics card do you have? My guess is that you don't actually have a 32 bit z-buffer as you were requesting. That could make the call to ChoosePixelFormat fail. Also, by calling glutInitDisplayMode with the args that you did, and then trying to change the PixelFormat manually may also be causing it to fail. Sounds like you've got a couple of things fighting each other there.

    Hope that helps,

    Jeff



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured