# OpenGL GLUT problem, or something else?

## Recommended Posts

Hi, I recently decided to learn OpenGL. I have a copy of the OpenGL Programming Guide (4th edition), which uses GLUT. My first program I took pretty much straight from the first code example in the book (with some minor modification to get it to compile); here's the code:
#include <Gl\glut.h>

void WinDisplay(void){
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
glVertex3f(0.25, 0.25, 0.0);
glVertex3f(0.75, 0.25, 0.0);
glVertex3f(0.75, 0.75, 0.0);
glVertex3f(0.25, 0.75, 0.0);
glEnd();
glFlush();
}

void (*winDisplayFunc)(void) = &WinDisplay;

void initGlutWin(void){
glClearColor(0.0, 1.0, 1.0, 0.0);
glMatrixMode(GL_PROJECTION);
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}

int main(int argc, char* *argv){
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(800, 600);
glutInitWindowPosition(1, 1);
glutCreateWindow(argv[0]);
initGlutWin();
glutDisplayFunc(winDisplayFunc);
glutMainLoop();

return 0;
}


I encountered several problems when trying to run this. At first the program would always crash when glutDisplayFunc was passed the display function. This happened even when the code inside WinDisplay was commented out. I couldn't figure out what the problem was, so I downgraded my version of GLUT from the 3.7.6 that I had gotten on the maintainer's page to 3.7beta which I found on opengl.org (don't ask me why I thought this would work). I then got a new error upon running the program; a message box which read something like "Procedure entry point for SetPixelFormat could not be located in opengl.dll". I looked at what I could of opengl32.lib; it has a function wglSetPixelFormat but no SetPixelFormat. I then looked at the code of GLUT, and in glutint.h it has a line "#define SetPixelFormat wglSetPixelFormat". It was inside another ifdef though so it made me wonder if somewhere else in the code there was a reference to SetPixelFormat that didn't get replaced be wglSetPixelFormat when it was compiled. I haven't looked into that yet, because I've been trying to get my code to work, and if that was the problem, I'm thinking I would have to recompile GLUT (I use Borland C++ 5.5 rather than MSVC++, so that would probably be pretty time consuming). However, I also googled the problem and it seemed like other people who apparently weren't using GLUT were having the same issue (Procedure entry point for SetPixelFormat not found in opengl.dll) So is it a GLUT problem or isn't it? I downgraded again to GLUT 3.6 and now the program runs fine, but I'd still like to know what the problems were caused by. Thanks for any help.

##### Share on other sites
Which version of the operating system are you using?
The OpenGL32.dll is the original one form Microsoft.

cheers

##### Share on other sites
Moreover at the end of the display function put a GlutPostRedisplay call.
The glFlush() seems to useless.

cheers

##### Share on other sites
Thanks for the replies.

I am using Windows XP, I just had to rename a copy of opengl32.dll to opengl.dll or the program complained about not being able to find opengl.dll. I also just reinstalled the operating system not too long ago and did all the updates, so the device driver for the graphics card should be the latest.

I think I see what you're saying with glutPostRedisplay (if I understand correctly, that posts a message to have the window update its contents), but would that really cause the program to crash if that function is not located in the WinDisplay function (that's the problem I was having when I was using GLUT 3.7.6)? I would think the window just wouldn't update its display.

I'm going to rephrase my question. Has anyone using GLUT 3.7.6 or 3.7beta encountered the same problems I have (program crashes when display function is passed to glutDisplayFunc, or a procedure entry point not being found in opengl.dll)? If so, what was the cause or how did you fix it? My program does work fine with GLUT 3.6.

##### Share on other sites
Renaiming opengl32.dll is not a good idea.
My advice is to download and install the most recent Driver for your 3D graphic card and to switch upon freeglut or OpenGLUT. GLUT is not maintained from a long time.
At present time I'm using freeglut.
Kind regards

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627682
• Total Posts
2978615
• ### Similar Content

• Both functions are available since 3.0, and I'm currently using glMapBuffer(), which works fine.
But, I was wondering if anyone has experienced advantage in using glMapBufferRange(), which allows to specify the range of the mapped buffer. Could this be only a safety measure or does it improve performance?
Note: I'm not asking about glBufferSubData()/glBufferData. Those two are irrelevant in this case.
• By xhcao
Before using void glBindImageTexture(    GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format), does need to make sure that texture is completeness.
• By cebugdev
hi guys,
are there any books, link online or any other resources that discusses on how to build special effects such as magic, lightning, etc. in OpenGL? i mean, yeah most of them are using particles but im looking for resources specifically on how to manipulate the particles to look like an effect that can be use for games,. i did fire particle before, and I want to learn how to do the other 'magic' as well.
Like are there one book or link(cant find in google) that atleast featured how to make different particle effects in OpenGL (or DirectX)? If there is no one stop shop for it, maybe ill just look for some tips on how to make a particle engine that is flexible enough to enable me to design different effects/magic
let me know if you guys have recommendations.
• By dud3
How do we rotate the camera around x axis 360 degrees, without having the strange effect as in my video below?
Mine behaves exactly the same way spherical coordinates would, I'm using euler angles.
Tried googling, but couldn't find a proper answer, guessing I don't know what exactly to google for, googled 'rotate 360 around x axis', got no proper answers.

References:
Code: https://pastebin.com/Hcshj3FQ
The video shows the difference between blender and my rotation:

• By Defend
I've had a Google around for this but haven't yet found some solid advice. There is a lot of "it depends", but I'm not sure on what.
My question is what's a good rule of thumb to follow when it comes to creating/using VBOs & VAOs? As in, when should I use multiple or when should I not? My understanding so far is that if I need a new VBO, then I need a new VAO. So when it comes to rendering multiple objects I can either:
* make lots of VAO/VBO pairs and flip through them to render different objects, or
* make one big VBO and jump around its memory to render different objects.
I also understand that if I need to render objects with different vertex attributes, then a new VAO is necessary in this case.
If that "it depends" really is quite variable, what's best for a beginner with OpenGL, assuming that better approaches can be learnt later with better understanding?

• 13
• 12
• 10
• 12
• 22