Initializing graphics without a z-buffer?

BlitzMax Forums/BlitzMax Programming/Initializing graphics without a z-buffer?

JoshK(Posted 2007) [#1]
Is there a way to initialize gl graphics without a z-buffer? I don't need it for a deferred renderer, and it only consumes RAM.


ImaginaryHuman(Posted 2007) [#2]
The Z buffer is the Depth buffer. You do not always have a choice as to whether you get one or not.

If you ask for one you will *probably* get one, but it depends on the ram available, the way that data is aligned in memory, and how the driver works. You'll get different behavior, for example, from a software driver than a hardware one.

If you do not ask for one, you *might* get one anyway. Again for the same reasons. For example most 16-bit modes will give you a 16-bit depth buffer as well, or not, depending on the system. And even if you did not ask for it, it may supply you with one, which of course uses more video ram

You can only *request* that you get or do not get a depth buffer, but this does not mean you will or won't, and there's nothing blitzmax can do about it.

You set the default buffers you want when you choose the driver. I forgot what the command is. If you include |GRAPHICS_DEPTHBUFFER in the buffer flags you are asking OpenGL for a depth/z buffer. If you don't include it you're asking OpenGL not to have one. But again, this has nothing to do with whether you will actually get one or not.

When you do get one, you do not have to use it if you don't want to. e.g. glDisable(GL_DEPTH_BUFFER_BIT) or whatever it is to switch it of.. or glDisable(GL_DEPTH_TEST).

Unfortunately you can't always be sure you won't get the buffer.

What I do is I ask for a given set of buffers/specs, then I open the screen, then I test to see what actual buffers were given to me, then decide if I can work with that and if there's anything I need to do to switch things on/off to prevent unexpected behavior.

So you can go ahead and do:

GLGraphics(640,480,32,0,GRAPHICS_BACKBUFFER|GRAPHICS_ALPHABUFFER)

And it will make you an OpenGL context without a depth buffer.... *sometimes* ;-)