Depth test using Glu instead of Glut?

Do I really have to make use of Glut or is it possible to make use of depth testing when you only make use of glu.h?
If you can depthtest without making use of glut.h how does that code look like?

Thanks John

glut only provides event-handling [and providing a window-rendering context]. glut does not handle depth testing.

to do depth testing, simply call the opengl command:

glEnable(GL_DEPTH_TEST);

i hope that helps.

-=[ regards ]=-

GLUT is a wrapper around platform specific windowing and i/o system libraries. To use OpenGL and depth testing without GLUT you make platform specific calls, both the windowing calls and the OpenGL “glue” that gives you the ability to create OpenGL contexts in those windows and then you can make your OpenGL calls. So on Windows you’d use Win32 and WGL calls to create an OpenGL context with a depth buffer included in the “pixelformatdescriptor” and then make OpenGL calls to render.

On something like Linux, you’d typically make X11 calls and GLX calls to get an OpenGL context with depth buffer visual attributes and then do your rendering in OpenGL.

This is why GLUT and other libraries are so useful, because using it eliminates the need to write different code on different platforms and simplifies a lot of moderately complex windowing setup code you’d normally need even for a very simple OpenGL program.

GLU has nothing to do with any of this, GLU is a separate library that offers an eclectic mix of utility functions to help you do things like build MIP maps and generate viewing matrices.

If you’re already rendering OpenGL without glut then there are simple calls to enable depth buffering, but a prerequisite is to have a depth buffer as part of your rendering context and as I mentioned that can require platform specific setup in the visual attributes or pixelformatdescriptor, you may or may not already have that.

I already tried to use glEnable(GL_DEPTH_TEST) without glut.h but that doesn’t work.
I think I will follow the advice of dorbie and will make use of glut.h.
Thanks ce11Out and dorbie for the very fast reply.

regards John

As stated glEnable(GL_DEPTH_TEST) is not dependent on GLUT, just that glut does some of the setup when opening a rendering contex in the window that maybe you did not have when not using glut.

At nehe.gamedev.net has tutors on opening a window in plain windows code in which to create the correct context in which to render to.

Or you could look at www.libSDL.org which also can be use in place of the GLUT library for opening a openGL context in a window.

Originally posted by <john>:
[b]I already tried to use glEnable(GL_DEPTH_TEST) without glut.h but that doesn’t work.
I think I will follow the advice of dorbie and will make use of glut.h.
Thanks ce11Out and dorbie for the very fast reply.

regards John[/b]