problem on Enable buffer

I want to get information in the depth buffer, so in order to make the buffer work, I should first Enable this buffer. But every time I run the program and when excute the glEnble(…), it will pop out the error:can’t enable without a current contex. So which is this problem related to: display card failed or lib failed?

Thanks for your coming help!

this means that you haven’t created an OpenGL context yet. this basically involves creating a window and binding opengl to it.

in GLUT, it’s as simple as:

    glutInit(&argc, argv);

    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
    glutInitWindowSize( screenWidth, screenHeight );
    glutCreateWindow("My App");

(look up each of these functions to use them properly.) this sets up a double-buffered full color display with a depth buffer in a window screenWidth x screenHeight.

for information on doing this using native windows code, so NeHe’s tutorial http://nehe.gamedev.net/opengl.asp .

for info on doing this using DrawSprocket on a mac, see http://devworld.apple.com/samplecode/Sample_Code/Graphics_3D/OpenGL_DrawSprocket.htm .

and if you’re coding for X, i assume you know where to look. ^_-;

Got it!
I really created the OpenGL context, but I put the command glEnable(…) before glutCreateWindow(…), so that’s the problem. Your comment just reminded me that.
Thanks a lot. BTW, your homepage is very fancy. I like it.

Originally posted by phlake:
[b]this means that you haven’t created an OpenGL context yet. this basically involves creating a window and binding opengl to it.

in GLUT, it’s as simple as:

[quote]

    glutInit(&argc, argv);

    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
    glutInitWindowSize( screenWidth, screenHeight );
    glutCreateWindow("My App");

(look up each of these functions to use them properly.) this sets up a double-buffered full color display with a depth buffer in a window screenWidth x screenHeight.

for information on doing this using native windows code, so NeHe’s tutorial http://nehe.gamedev.net/opengl.asp .

for info on doing this using DrawSprocket on a mac, see http://devworld.apple.com/samplecode/Sample_Code/Graphics_3D/OpenGL_DrawSprocket.htm .

and if you’re coding for X, i assume you know where to look. ^_-;[/b][/QUOTE]