PDA

View Full Version : OpenGL under Windows2000 -- SetPixelFormat failed during window create



yusuf
03-05-2002, 12:32 PM
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

zeckensack
03-05-2002, 12:48 PM
You aren't running your desktop in 8 bit color depth, are you? http://www.opengl.org/discussion_boards/ubb/smile.gif

yusuf
03-05-2002, 01:05 PM
Nope, running at 24 bits, but tried ther resolutions with no luck.

There is a Microsoft bug related to this

<http://support.microsoft.com/default.aspx?scid=kb;en-us;Q126019>

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

Yusuf

zeckensack
03-05-2002, 01:23 PM
Well, have you tried that solution? Glut for windows can be found here (http://www.xmission.com/~nate/glut.html) .

Ryo
03-05-2002, 01:55 PM
Does that happen only on Win2000?

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

yusuf
03-05-2002, 03:03 PM
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> 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;
}

Shag
03-05-2002, 09:41 PM
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.

yusuf
03-05-2002, 11:48 PM
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

Diapolo
03-06-2002, 10:16 AM
You said you use a 24 Bit Desktop resolution.
I donīt think you will get an accelerated pixelformat with this color depth.

Diapolo

mandyV
03-06-2002, 11:03 AM
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).]

zeckensack
03-06-2002, 11:37 AM
yusuf: Glad to hear that it works now http://www.opengl.org/discussion_boards/ubb/smile.gif
But you should still get the newer non-beta glut version at the link I gave you in my second post.

yusuf
03-06-2002, 04:49 PM
Did that as well. Thanks.

Yusuf


Originally posted by zeckensack:
yusuf: Glad to hear that it works now http://www.opengl.org/discussion_boards/ubb/smile.gif
But you should still get the newer non-beta glut version at the link I gave you in my second post.