summaryrefslogtreecommitdiff
path: root/src/mesa/main/buffers.c
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2002-03-16 00:53:15 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2002-03-16 00:53:15 +0000
commit18a285a5e244b7405b85feb7315a30d99920ec5d (patch)
tree02fbfa95292ef56eef26bb2e8456f65cf1348f18 /src/mesa/main/buffers.c
parent8d687e7e58a148f3f16573636023e54755372010 (diff)
Lots of changes related to framebuffer/window buffer resizing. Basically,
instead of passing a GLcontext* to ResizeBuffers(), pass a GLframebuffer*. The idea is that a window can be resized without it being bound to a rendering context. This makes for a nice clean-up in the XFree86 server-side GLX code. Renamed ctx->Driver.ResizeBuffersMESA() to ctx->Driver.ResizeBuffers().
Diffstat (limited to 'src/mesa/main/buffers.c')
-rw-r--r--src/mesa/main/buffers.c56
1 files changed, 41 insertions, 15 deletions
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index b4feb219fb..be793417d4 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -1,4 +1,4 @@
-/* $Id: buffers.c,v 1.32 2002/02/15 16:25:16 brianp Exp $ */
+/* $Id: buffers.c,v 1.33 2002/03/16 00:53:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -350,33 +350,59 @@ _mesa_ReadBuffer( GLenum mode )
/*
* GL_MESA_resize_buffers extension
+ * When this function is called, we'll ask the window system how large
+ * the current window is. If it's not what we expect, we'll have to
+ * resize/reallocate the software accum/stencil/depth/alpha buffers.
*/
void
_mesa_ResizeBuffersMESA( void )
{
GLcontext *ctx = _mesa_get_current_context();
- GLuint buf_width, buf_height;
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx );
-
if (MESA_VERBOSE & VERBOSE_API)
fprintf(stderr, "glResizeBuffersMESA\n");
- /* ask device driver for size of output buffer */
- (*ctx->Driver.GetBufferSize)( ctx, &buf_width, &buf_height );
+ if (ctx) {
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx );
- /* see if size of device driver's color buffer (window) has changed */
- if (ctx->DrawBuffer->Width == (GLint) buf_width &&
- ctx->DrawBuffer->Height == (GLint) buf_height)
- return;
+ if (ctx->DrawBuffer) {
+ GLuint buf_width, buf_height;
+ GLframebuffer *buffer = ctx->DrawBuffer;
+
+ /* ask device driver for size of output buffer */
+ (*ctx->Driver.GetBufferSize)( buffer, &buf_width, &buf_height );
- ctx->NewState |= _NEW_BUFFERS; /* to update scissor / window bounds */
+ /* see if size of device driver's color buffer (window) has changed */
+ if (buffer->Width == (GLint) buf_width &&
+ buffer->Height == (GLint) buf_height)
+ return; /* size is as expected */
+
+ buffer->Width = buf_width;
+ buffer->Height = buf_height;
+
+ ctx->Driver.ResizeBuffers( buffer );
+ }
- /* save buffer size */
- ctx->DrawBuffer->Width = buf_width;
- ctx->DrawBuffer->Height = buf_height;
+ if (ctx->ReadBuffer && ctx->ReadBuffer != ctx->DrawBuffer) {
+ GLuint buf_width, buf_height;
+ GLframebuffer *buffer = ctx->DrawBuffer;
- ctx->Driver.ResizeBuffersMESA( ctx );
+ /* ask device driver for size of output buffer */
+ (*ctx->Driver.GetBufferSize)( buffer, &buf_width, &buf_height );
+
+ /* see if size of device driver's color buffer (window) has changed */
+ if (buffer->Width == (GLint) buf_width &&
+ buffer->Height == (GLint) buf_height)
+ return; /* size is as expected */
+
+ buffer->Width = buf_width;
+ buffer->Height = buf_height;
+
+ ctx->Driver.ResizeBuffers( buffer );
+ }
+
+ ctx->NewState |= _NEW_BUFFERS; /* to update scissor / window bounds */
+ }
}