PDA

View Full Version : glutInitDisplayMode(GLUT_SINGLE) doesn't work?



sk5065
03-19-2014, 09:14 AM
I am new for OPENGL.
environment is WIN7 64 + vs2010.
I'm sure that the problem is nothing concerned with the software environment.
In my laptop,glutInitDisplayMode(GLUT_SINGLE) doesn't work
I have to use glutInitDisplayMode(GLUT_double) to make the results all right.
let me give you an eample:

#include<gl/glut.h>
void renderScene(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glVertex2f(0.5, -0.5);
glEnd();
glFlush();
}
int main(int argc, char** argv){
glutCreateWindow("simple");
glutDisplayFunc(mydisplay);
glutMainLoop();
}

codes above operated in my laptop only show all white,title is right but no black background and no square.
But if i use glutInitDisplayMode(GLUT_double) and glutSwapBuffers(); everything is right.
why this happened? is it resulted from my graphics card?Is there any thing i can do to revise the problem?

mhagain
03-19-2014, 10:30 AM
Single buffered modes are problematic since the introduction of WDDM and desktop compositing in Windows Vista. To be honest this isn't a problem - there's no real valid reason to use a single buffered mode and double buffered modes aren't particularly advanced or difficult to set up or manage, so just create double buffered modes instead.

Agent D
03-19-2014, 12:36 PM
You could try calling glFlush( ) at the end of the drawing functions with a singlebuffered context. I once had a similar issue with GLX (see here (http://www.opengl.org/discussion_boards/showthread.php/183666-xlib-glX-dedicated-rendering-thread?p=1258041#post1258041))

sk5065
03-19-2014, 05:55 PM
Sorry for that I wrote it wrong in codes above,I have fixed it.Single buffered with glFlush() just doesn't give an expected result.

sk5065
03-19-2014, 06:01 PM
Single buffered modes are problematic since the introduction of WDDM and desktop compositing in Windows Vista. To be honest this isn't a problem - there's no real valid reason to use a single buffered mode and double buffered modes aren't particularly advanced or difficult to set up or manage, so just create double buffered modes instead.

Thanks that u telling me these,however there must be some differences between my computer with others . I wonder if it will lead other problems?

mhagain
03-19-2014, 11:10 PM
Thanks that u telling me these,however there must be some differences between my computer with others . I wonder if it will lead other problems?

Maybe, maybe not. I doubt there is a difference - you have standard hardware, a widely used OS, presumably you keep your drivers up to date. You're doing everything right.

The problem is that a lot of GLUT tutorials are old. Really really old. Like 20 or more years old. And back then hardware was different and some hardware might not support a double-buffered context. But a single-buffered context would work on everything, so these really really old GLUT tutorials for really really old hardware used single-buffered contexts. Time passes, hardware changes, drivers change, but GLUT tutorials are never updated properly so they're no longer suitable to modern hardware.