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;
}