Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: Matrox G400 initialisation

  1. #1
    Junior Member Regular Contributor
    Join Date
    Apr 2000
    Posts
    117

    Matrox G400 initialisation

    I'm having trouble getting a matrox G400 to initalise properly to do openGL rendering. The same code works fine on Voodoo 1 (!) (when set to 16 bit), TNT, and GeForce cards, but the matrox card falls over on SetPixelFormat() using the latest drivers (on NT4SP6a). Here's a snippet of init code:

    // Initialise directdraw:
    if (DirectDrawCreate(NULL, &lpdd, NULL) != DD_OK)
    {
    printf("Failed to create directdraw\n");
    return -1;
    }

    // Step 1: set cooperative level so that we get exclusive access to the whole
    // screen.
    if (lpdd->SetCooperativeLevel(hWnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT) != DD_OK)
    {
    printf("Failed to set cooperative level\n");
    Destroy();
    return -1;
    }

    // Step 2: set the display mode to 640x480x32
    if (lpdd->SetDisplayMode(
    640,
    480,
    32
    ) != DD_OK)
    {
    printf("Failed to set screen mode\n");
    Destroy();
    return -1;
    }

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

    hdc = GetWindowDC(hWnd);

    // get the best available match of pixel format for the device context
    iPixelFormat = ChoosePixelFormat(hdc, &pfd);
    if (iPixelFormat == 0) {
    printf("Failed to choose pixel format.\n");
    Destroy();
    return -1;
    }

    printf("Pixel format is %d\n", iPixelFormat);

    // make that the pixel format of the device context
    if (SetPixelFormat(hdc, iPixelFormat, &pfd) == FALSE) {
    printf("Failed to set pixel format\n");
    Destroy();
    return -1;
    }

    printf("Created display\n");

    // Hide the mouse
    ShowCursor(FALSE);

    return 1;

  2. #2
    Intern Contributor
    Join Date
    Feb 2000
    Location
    Germany
    Posts
    87

    Re: Matrox G400 initialisation

    Try using 16 or 32 for color depth instead of 24. I remember having trouble with some cards / drivers when using 24 bit.

  3. #3
    Junior Member Regular Contributor
    Join Date
    Apr 2000
    Posts
    117

    Re: Matrox G400 initialisation

    OK, tried 32, and it didn't like it. Tried 16 and finally it gets past the initialisation, but displays totally unrecognisable textures. (My test program displays a string 0123456789ABCDEFH...Z which follows the mouse; on the G400, I get a bizarre embossed grey "Z" shape which follows the mouse in place of the 0, and nothing else).

    No OpenGL errors are being reported so glTexImage2D would appear to be doing its business correctly.

    It's a little difficult to post the demo program because most of it's in Java and quite large...

  4. #4
    Senior Member OpenGL Guru Humus's Avatar
    Join Date
    Mar 2000
    Location
    Stockholm, Sweden
    Posts
    2,345

    Re: Matrox G400 initialisation

    Try to do the inititalzation without directdraw. Do it with only opengl calls instead.

  5. #5
    Junior Member Regular Contributor
    Join Date
    Apr 2000
    Posts
    117

    Re: Matrox G400 initialisation

    Ah, the directdraw stuff's kinda important, order to force the display nicely into the screen mode I want it to be in (which is fullscreen 640x480x32 - this is for a game, y'see). Is there a better way to do this? I specifically don't want to render to a window or have anything do to with window management in any way (I use directinput for keyboard and mouse too).

  6. #6
    Junior Member Regular Contributor
    Join Date
    Mar 2000
    Location
    Germany
    Posts
    184

    Re: Matrox G400 initialisation

    Hi there!

    Hum, well I hadn't had the pleasure yet to run into an G400, but I think it could be the stencil flag, causing your trouble.

    Try again in 640x480x32 without the stencil flag.

    Regards,

    LG

  7. #7
    Junior Member Regular Contributor
    Join Date
    Apr 2000
    Posts
    117

    Re: Matrox G400 initialisation

    Will have a go.

  8. #8
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,982

    Re: Matrox G400 initialisation

    A rule of thumb: don't mix two API's

    Using one API to do one thing, then all of a sudden change to another API to take over (setting videomode with DirectX and render with OpenGL) is baaad programming.

    Bob

  9. #9
    Senior Member OpenGL Guru Humus's Avatar
    Join Date
    Mar 2000
    Location
    Stockholm, Sweden
    Posts
    2,345

    Re: Matrox G400 initialisation

    Use this to change to fullscreen rendering in OpenGL:
    ChangeDisplaySettings(&devmode, CDS_FULLSCREEN);

  10. #10
    Junior Member Regular Contributor
    Join Date
    Apr 2000
    Posts
    117

    Re: Matrox G400 initialisation

    Tried it. Basically no change, except that when the process abruptly crashes now, I don't get the display settings restored (directdraw was kind enough to do it properly).

    The call to SetPixelFormat causes the process to exit without error codes or access violations - bang! Gone. I've got a valid pixelformat number so the ICD is presumably matching this OK.

    (So far all the tweaks I've done I've tested on nvidia cards and they still work)

Posting Permissions

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