OpenGL under Windows2000 -- SetPixelFormat failed during window create

OpenGL under Windows2000

I get the message “SetPixelFormat failed during window create” when I try to execute the file. The same error for hello.c, bezcurve.c, really basic programs.

I am using Visual C++ to compile the programs, but I do not think it should make a difference.

Any ideas, tips on how to fix it?

Yusuf

You aren’t running your desktop in 8 bit color depth, are you?

Nope, running at 24 bits, but tried ther resolutions with no luck.

There is a Microsoft bug related to this

<Microsoft Support;

but it does not provide a solution except to get new glut dlls.

Yusuf

Well, have you tried that solution? Glut for windows can be found here .

Does that happen only on Win2000?

My program works fine.
Maybe you can show us your code snippet, then we can help you.

I am trying to compile the programs that come with the red book, such as hello.c, bezcurve.c. I am including bezcurve.c which is widely available.

It compiles fine under Win98, but fail under Win2000 with the error message “SetPixelFormat failed during window create”

I was using glut37beta dlls I got from: <http://www.opengl.org/developers/documentation/glut/glutdlls37beta.zip&gt; and placed them in the following dirs

place glut.h in …\VC98\include\GL
place glut32.lib in …\VC98\lib
place glut32.dll in …\windows\system
(…\winnt\system for win2000)

As well as trying general Visual C++ configuration ie:

=====

CREATE YOUR PROJECT AS A WIN32 CONSOLE APPLICATION!! If you don’t, you won’t be able to build your project.
You need to include the OpenGL libraries in your project. To do this:
Select Project->Settings from the menu bar.
Click on the Link tab
Add the following to the list of libraries in the Object\Library Modules text box: opengl32.lib glut32.lib glu32.lib
Click OK.

=====

There is something very basic that is going wrong, possibly with Win2000 privilidges, possibly with DLL conflict.

Any ideas?

Yusuf

=====

/* bezcurve.c

  • This program uses evaluators to draw a Bezier curve.
    */
    #include <GL/glut.h>
    #include <stdlib.h>

GLfloat ctrlpoints[4][3] = {
{ -4.0, -4.0, 0.0}, { -2.0, 4.0, 0.0},
{2.0, -4.0, 0.0}, {4.0, 4.0, 0.0}};

void init(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_FLAT);
glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, &ctrlpoints[0][0]);
glEnable(GL_MAP1_VERTEX_3);
}

void display(void)
{
int i;

glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_LINE_STRIP);
for (i = 0; i <= 30; i++)
glEvalCoord1f((GLfloat) i/30.0);
glEnd();
/* The following code displays the control points as dots. */
glPointSize(5.0);
glColor3f(1.0, 1.0, 0.0);
glBegin(GL_POINTS);
for (i = 0; i < 4; i++)
glVertex3fv(&ctrlpoints[i][0]);
glEnd();
glFlush();
}

void reshape(int w, int h)
{
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if (w <= h)
glOrtho(-5.0, 5.0, -5.0*(GLfloat)h/(GLfloat)w,
5.0*(GLfloat)h/(GLfloat)w, -5.0, 5.0);
else
glOrtho(-5.0*(GLfloat)w/(GLfloat)h,
5.0*(GLfloat)w/(GLfloat)h, -5.0, 5.0, -5.0, 5.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

void keyboard(unsigned char key, int x, int y)
{
switch (key) {
case 27:
exit(0);
break;
}
}

int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (500, 500);
glutInitWindowPosition (100, 100);
glutCreateWindow (argv[0]);
init ();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc (keyboard);
glutMainLoop();
return 0;
}

I have no knowledge of glut whatsoever, but I guess this

glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);

asks for a single buffered mode.

try GLUT_DOUBLE

I could be COMPLETELY wrong here, but it looks likely.

Fixed.

It drove me crazy. I replaced all the dlls, reinstalled VC++, uninstalled a whole series of programs but it would still give the same error.

The problem was with the matrox drivers for the graphics card. Once I installed the latest driver for Win2000 the problem disappeared.

Thanks to all who tried to help.

Yusuf

You said you use a 24 Bit Desktop resolution.
I don´t think you will get an accelerated pixelformat with this color depth.

Diapolo

I am having a similar problem. I updated the driver, udpated my dlls, but it still crashes if I use double buffering on full accellaration. it’s fine for single buffering.

[This message has been edited by mandyV (edited 03-06-2002).]

yusuf: Glad to hear that it works now
But you should still get the newer non-beta glut version at the link I gave you in my second post.

Did that as well. Thanks.

Yusuf

Originally posted by zeckensack:
yusuf: Glad to hear that it works now
But you should still get the newer non-beta glut version at the link I gave you in my second post.