summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast/s_depth.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/swrast/s_depth.c')
-rw-r--r--src/mesa/swrast/s_depth.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c
index a62926cc42b..cadb0ecd109 100644
--- a/src/mesa/swrast/s_depth.c
+++ b/src/mesa/swrast/s_depth.c
@@ -1,4 +1,4 @@
-/* $Id: s_depth.c,v 1.17 2002/02/06 03:22:00 brianp Exp $ */
+/* $Id: s_depth.c,v 1.18 2002/03/16 00:53:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -1513,32 +1513,33 @@ _mesa_read_depth_span_float( GLcontext *ctx,
* This function is only called through Driver.alloc_depth_buffer.
*/
void
-_mesa_alloc_depth_buffer( GLcontext *ctx )
+_mesa_alloc_depth_buffer( GLframebuffer *buffer )
{
- /* deallocate current depth buffer if present */
- if (ctx->DrawBuffer->UseSoftwareDepthBuffer) {
- GLint bytesPerValue;
+ GLint bytesPerValue;
- if (ctx->DrawBuffer->DepthBuffer) {
- FREE(ctx->DrawBuffer->DepthBuffer);
- ctx->DrawBuffer->DepthBuffer = NULL;
- }
+ ASSERT(buffer->UseSoftwareDepthBuffer);
- /* allocate new depth buffer, but don't initialize it */
- if (ctx->Visual.depthBits <= 16)
- bytesPerValue = sizeof(GLushort);
- else
- bytesPerValue = sizeof(GLuint);
+ /* deallocate current depth buffer if present */
+ if (buffer->DepthBuffer) {
+ FREE(buffer->DepthBuffer);
+ buffer->DepthBuffer = NULL;
+ }
+
+ /* allocate new depth buffer, but don't initialize it */
+ if (buffer->Visual.depthBits <= 16)
+ bytesPerValue = sizeof(GLushort);
+ else
+ bytesPerValue = sizeof(GLuint);
- ctx->DrawBuffer->DepthBuffer = MALLOC( ctx->DrawBuffer->Width
- * ctx->DrawBuffer->Height
- * bytesPerValue );
+ buffer->DepthBuffer =MALLOC(buffer->Width * buffer->Height * bytesPerValue);
- if (!ctx->DrawBuffer->DepthBuffer) {
- /* out of memory */
+ if (!buffer->DepthBuffer) {
+ /* out of memory */
+ GET_CURRENT_CONTEXT(ctx);
+ if (ctx) {
ctx->Depth.Test = GL_FALSE;
ctx->NewState |= _NEW_DEPTH;
- _mesa_error( ctx, GL_OUT_OF_MEMORY, "Couldn't allocate depth buffer" );
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "Couldn't allocate depth buffer");
}
}
}