PDA

View Full Version : glFlush() exception on Win7 x64



sentinelstatue
05-06-2011, 11:31 PM
I'm having a problem with OpenGL using Visual Studio 2010 on a Windows7 x64 machine. I was originally porting code from a linux machine but upon encountering a problem I created a small test program to test whether OpenGL was performing properly.

In this case, I'm just using freeglut (Ver. 2.6) to create a window, which works fine, then trying to paint the window background color, but the program throws an exception on calling glFlush() and doesn't draw anything in the graphics region of the created window, code provided below.

The exception reads: "First-chance exception at 0x7579e977 in HelloWorld.exe: 0xC000000D: An invalid parameter was passed to a service or function."

I've already considered the possiblity of old drivers, those have been verified as up to date (Intel G33 integrated graphics card). Also, upon compiling freeglut, they provide a number of demo programs (e.g. smooth_opengl3) which also produce similar errors. Any ideas?

//----------------------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------------------
#include <freeglut.h>

//----------------------------------------------------------------------------------
// Function Declarations
//----------------------------------------------------------------------------------

void init();
void display();

//----------------------------------------------------------------------------------
// Main
//----------------------------------------------------------------------------------

int main(int argc, char **argv) {
glutInit(&amp;argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(250,250);
glutInitWindowPosition(100,100);
glutCreateWindow("Hello");
init();
glutDisplayFunc(display);

glutMainLoop();
return 0;
}

//----------------------------------------------------------------------------------
// Init
//----------------------------------------------------------------------------------

void init() {
// Define basic OpenGL settings.
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0,1.0,0.0,1.0,-1.0,1.0);
}

//----------------------------------------------------------------------------------
// Display
//----------------------------------------------------------------------------------

void display() {
glClear(GL_COLOR_BUFFER_BIT);

glFlush();
}

mhagain
05-07-2011, 03:59 AM
OpenGL works perfectly on Windows 7 x64 (assuming no driver problems of course) so it's not that.

There are a few things that you need to watch out for, however; one of them is mixing GDI calls with OpenGL (not relevant here) and another one is single buffered contexts.

What happens if you create a double-buffered context instead?

sentinelstatue
05-07-2011, 06:58 AM
Ok, I've changed the code to take a double buffered context (code below). This still produces the same exception message and as before the viewport portion of the window fails to update (still shows windows that were behind it at time of creation).

I have also tried a number of context versions (1.1, 1.4, 2.1, 3.0) in case that was the problem, no effect unfortunately.

Thank you for the assistance.

//----------------------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------------------

#include <freeglut.h>

//----------------------------------------------------------------------------------
// Function Declarations
//----------------------------------------------------------------------------------

void init();
void display();

//----------------------------------------------------------------------------------
// Main
//----------------------------------------------------------------------------------

int main(int argc, char **argv) {
glutInit(&amp;argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(250,250);
glutInitWindowPosition(100,100);
glutCreateWindow("Hello World!");
init();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}

//----------------------------------------------------------------------------------
// Init
//----------------------------------------------------------------------------------

void init() {
// Define basic OpenGL settings.
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0,1.0,0.0,1.0,-1.0,1.0);
}

//----------------------------------------------------------------------------------
// Display
//----------------------------------------------------------------------------------

void display() {
glClear(GL_COLOR_BUFFER_BIT);
glutSwapBuffers();
}

V-man
05-07-2011, 09:05 AM
What video card do you have and which driver version?
Can you run games that use OpenGL like Quake 3 Arena (demo), American' Mcgee's Alice (demo), Minecraft, Half-life?
Can you run some of the code found at http://nehe.gamedev.net/lesson.asp?index=02

sentinelstatue
05-08-2011, 12:26 PM
Alrighty, the video card is an Intel G33 integrated graphics card (it's an office machine) running driver version 8.15.10.1930 (Intel driver updates list this as current).

That being said, neither Quake 3 Arena nor Alice demos will display graphics (though you can hear the sound effects in the background). So it seems to be that OpenGL wasn't installed or was installed improperly. Currently it's a fresh install of Windows 7 Pro, all updates installed according to automatic updates.

Should I replace the OpenGL related .dll files?

mhagain
05-08-2011, 01:08 PM
You may have a Microsoft or OEM driver that does not have OpenGL support; if that's the case then you need to download and install a driver from the Intel site (and check out the "have disk" install method too as you'll probably need it).

Manually replacing DLLs is most definitely not recommended, especially where hardware drivers are concerned. It will just cause A World Of Pain And Suffering From Which You Will Never Escape. Use the proper install methods (either the installer or "have disk" as appropriate).

Having said all that, Intel OpenGL drivers are generally acknowledged to be rubbish. But not so rubbish that glFlush will cause a crash.