summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2004-11-27 22:47:59 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2004-11-27 22:47:59 +0000
commit65a66f5bc37383c00423c21baf8ba9d6771e0259 (patch)
tree0d98e004b457adde579dd27b9fe32182d54268b6 /src/mesa
parent118a8bad73bda88fc54f802b2beeb687c8ddb45a (diff)
Remove _mesa_ResizeBuffersMESA() call from _mesa_set_viewport().
Now, the driver's Viewport routine should call _mesa_ResizeBuffersMESA() if necessary. Cleaned up code related to GLframebuffer width/height initialization. Set initial viewport/scissor params in _mesa_make_current2(), instead of in the drivers' MakeCurrent functions.
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/allegro/amesa.c15
-rw-r--r--src/mesa/drivers/beos/GLView.cpp9
-rw-r--r--src/mesa/drivers/dos/dmesa.c17
-rw-r--r--src/mesa/drivers/dri/fb/fb_dri.c14
-rw-r--r--src/mesa/drivers/dri/ffb/ffb_state.c3
-rw-r--r--src/mesa/drivers/dri/ffb/ffb_xmesa.c6
-rw-r--r--src/mesa/drivers/dri/gamma/gamma_state.c3
-rw-r--r--src/mesa/drivers/dri/gamma/gamma_xmesa.c5
-rw-r--r--src/mesa/drivers/dri/i810/i810context.c3
-rw-r--r--src/mesa/drivers/dri/i810/i810state.c3
-rw-r--r--src/mesa/drivers/dri/i830/i830_context.c4
-rw-r--r--src/mesa/drivers/dri/i830/i830_state.c3
-rw-r--r--src/mesa/drivers/dri/i915/intel_context.c3
-rw-r--r--src/mesa/drivers/dri/mach64/mach64_context.c5
-rw-r--r--src/mesa/drivers/dri/mach64/mach64_state.c3
-rw-r--r--src/mesa/drivers/dri/mga/mga_xmesa.c5
-rw-r--r--src/mesa/drivers/dri/mga/mgastate.c3
-rw-r--r--src/mesa/drivers/dri/r128/r128_context.c6
-rw-r--r--src/mesa/drivers/dri/r128/r128_state.c3
-rw-r--r--src/mesa/drivers/dri/r200/r200_context.c5
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_context.c5
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_state.c3
-rw-r--r--src/mesa/drivers/dri/savage/savage_xmesa.c4
-rw-r--r--src/mesa/drivers/dri/savage/savagestate.c3
-rw-r--r--src/mesa/drivers/dri/sis/sis_context.c5
-rw-r--r--src/mesa/drivers/dri/sis/sis_state.c3
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_context.c4
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_state.c3
-rw-r--r--src/mesa/drivers/dri/unichrome/via_context.c3
-rw-r--r--src/mesa/drivers/dri/unichrome/via_state.c3
-rw-r--r--src/mesa/drivers/dri/x11/x11_dri.c5
-rw-r--r--src/mesa/drivers/fbdev/glfbdev.c10
-rw-r--r--src/mesa/drivers/ggi/ggimesa.c18
-rw-r--r--src/mesa/drivers/glide/fxapi.c4
-rw-r--r--src/mesa/drivers/glide/fxdd.c12
-rw-r--r--src/mesa/drivers/svga/svgamesa.c11
-rw-r--r--src/mesa/drivers/windows/gdi/wmesa.c18
-rw-r--r--src/mesa/drivers/x11/xm_dd.c19
-rw-r--r--src/mesa/main/context.c56
-rw-r--r--src/mesa/main/matrix.c17
-rw-r--r--src/mesa/main/mtypes.h2
41 files changed, 175 insertions, 151 deletions
diff --git a/src/mesa/drivers/allegro/amesa.c b/src/mesa/drivers/allegro/amesa.c
index 92fd1b7068..cb46efa56a 100644
--- a/src/mesa/drivers/allegro/amesa.c
+++ b/src/mesa/drivers/allegro/amesa.c
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <allegro.h>
+#include "buffers.h"
#include "context.h"
#include "imports.h"
#include "matrix.h"
@@ -144,6 +145,13 @@ static void get_buffer_size(GLcontext *ctx, GLuint *width, GLuint *height)
}
+static void viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ /* poll for window size change and realloc software Z/stencil/etc if needed */
+ _mesa_ResizeBuffersMESA();
+}
+
+
/**********************************************************************/
/**********************************************************************/
@@ -155,8 +163,9 @@ static void setup_dd_pointers(GLcontext *ctx)
/* a new context is made current or we change buffers via set_buffer! */
ctx->Driver.UpdateState = setup_dd_pointers;
- ctx->Driver.SetBuffer = set_buffer;
- ctx->Driver.GetBufferSize = get_buffer_size;
+ ctx->Driver.SetBuffer = set_buffer;
+ ctx->Driver.GetBufferSize = get_buffer_size;
+ ctx->Driver.Viewport = viewport;
ctx->Driver.Color = set_color_generic;
ctx->Driver.ClearColor = clear_color_generic;
@@ -371,9 +380,9 @@ GLboolean AMesaMakeCurrent(AMesaContext context, AMesaBuffer buffer)
setup_dd_pointers(context->GLContext);
_mesa_make_current(context->GLContext, buffer->GLBuffer);
- _mesa_set_viewport(context->GLContext, 0, 0, buffer->Width, buffer->Height);
}
else {
+ /* XXX I don't think you want to destroy anything here! */
destroy_bitmap(context->Buffer->Screen);
context->Buffer->Screen = NULL;
context->Buffer->Active = NULL;
diff --git a/src/mesa/drivers/beos/GLView.cpp b/src/mesa/drivers/beos/GLView.cpp
index 43aa13e701..45473a8ef2 100644
--- a/src/mesa/drivers/beos/GLView.cpp
+++ b/src/mesa/drivers/beos/GLView.cpp
@@ -153,6 +153,7 @@ private:
GLuint *height);
static void Error(GLcontext *ctx);
static const GLubyte * GetString(GLcontext *ctx, GLenum name);
+ static void Viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
// Front-buffer functions
static void WriteRGBASpanFront(const GLcontext *ctx, GLuint n,
@@ -317,6 +318,7 @@ BGLView::BGLView(BRect rect, char *name,
functions.ClearIndex = md->ClearIndex;
functions.ClearColor = md->ClearColor;
functions.Error = md->Error;
+ functions.Viewport = md->Viewport;
// create core context
GLcontext *ctx = _mesa_create_context(visual, NULL, &functions, md);
@@ -1028,6 +1030,13 @@ void MesaDriver::GetBufferSize(GLframebuffer * framebuffer, GLuint *width,
}
+void MesaDriver::Viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ /* poll for window size change and realloc software Z/stencil/etc if needed */
+ _mesa_ResizeBuffersMESA();
+}
+
+
const GLubyte *MesaDriver::GetString(GLcontext *ctx, GLenum name)
{
switch (name) {
diff --git a/src/mesa/drivers/dos/dmesa.c b/src/mesa/drivers/dos/dmesa.c
index 41e0f4d8b3..e0b2cf52b1 100644
--- a/src/mesa/drivers/dos/dmesa.c
+++ b/src/mesa/drivers/dos/dmesa.c
@@ -36,6 +36,7 @@
#include "imports.h"
#ifndef FX
#include "bufferobj.h"
+#include "buffers.h"
#include "extensions.h"
#include "macros.h"
#include "matrix.h"
@@ -812,6 +813,14 @@ get_buffer_size (GLframebuffer *buffer, GLuint *width, GLuint *height)
}
+static void
+viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ /* poll for window size change and realloc software Z/stencil/etc if needed */
+ _mesa_ResizeBuffersMESA();
+}
+
+
static const GLubyte *
get_string (GLcontext *ctx, GLenum name)
{
@@ -898,6 +907,7 @@ dmesa_init_driver_functions (DMesaVisual visual,
driver->UpdateState = dmesa_update_state;
driver->GetString = get_string;
driver->GetBufferSize = get_buffer_size;
+ driver->Viewport = viewport;
driver->Flush = flush;
driver->Finish = finish;
driver->Clear = clear;
@@ -1271,11 +1281,8 @@ DMesaMakeCurrent (DMesaContext c, DMesaBuffer b)
c->buffer = b;
_mesa_make_current((GLcontext *)c, (GLframebuffer *)b);
- if (((GLcontext *)c)->Viewport.Width == 0) {
- /* initialize viewport to window size */
- _mesa_Viewport(0, 0, b->width, b->height);
- }
- } else {
+ }
+ else {
/* Detach */
_mesa_make_current(NULL, NULL);
}
diff --git a/src/mesa/drivers/dri/fb/fb_dri.c b/src/mesa/drivers/dri/fb/fb_dri.c
index 49ae5c98e8..16540ed051 100644
--- a/src/mesa/drivers/dri/fb/fb_dri.c
+++ b/src/mesa/drivers/dri/fb/fb_dri.c
@@ -63,6 +63,7 @@
#include "miniglxP.h" /* window-system-specific */
#include "dri_util.h" /* window-system-specific-ish */
+#include "buffers.h"
#include "context.h"
#include "extensions.h"
#include "imports.h"
@@ -133,6 +134,13 @@ get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
}
+static void
+viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ _mesa_ResizeBuffersMESA();
+}
+
+
/* specifies the buffer for swrast span rendering/reading */
static void
set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit )
@@ -166,6 +174,7 @@ init_core_functions( struct dd_function_table *functions )
functions->UpdateState = update_state;
functions->ResizeBuffers = _swrast_alloc_buffers;
functions->GetBufferSize = get_buffer_size;
+ functions->Viewport = viewport;
functions->Clear = _swrast_Clear; /* could accelerate with blits */
}
@@ -536,11 +545,6 @@ fbMakeCurrent( __DRIcontextPrivate *driContextPriv,
_mesa_make_current2( newFbCtx->glCtx,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate );
-
- if ( !newFbCtx->glCtx->Viewport.Width ) {
- _mesa_set_viewport( newFbCtx->glCtx, 0, 0,
- driDrawPriv->w, driDrawPriv->h );
- }
} else {
_mesa_make_current( 0, 0 );
}
diff --git a/src/mesa/drivers/dri/ffb/ffb_state.c b/src/mesa/drivers/dri/ffb/ffb_state.c
index 86f92c83db..53d56d2043 100644
--- a/src/mesa/drivers/dri/ffb/ffb_state.c
+++ b/src/mesa/drivers/dri/ffb/ffb_state.c
@@ -26,6 +26,7 @@
*/
#include "mtypes.h"
+#include "buffers.h"
#include "colormac.h"
#include "mm.h"
#include "ffb_dd.h"
@@ -444,6 +445,8 @@ void ffbCalcViewport(GLcontext *ctx)
static void ffbDDViewport(GLcontext *ctx, GLint x, GLint y,
GLsizei width, GLsizei height)
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
ffbCalcViewport(ctx);
}
diff --git a/src/mesa/drivers/dri/ffb/ffb_xmesa.c b/src/mesa/drivers/dri/ffb/ffb_xmesa.c
index 43c1f34661..4e38d08237 100644
--- a/src/mesa/drivers/dri/ffb/ffb_xmesa.c
+++ b/src/mesa/drivers/dri/ffb/ffb_xmesa.c
@@ -494,12 +494,6 @@ ffbMakeCurrent(__DRIcontextPrivate *driContextPriv,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate);
- if (!fmesa->glCtx->Viewport.Width)
- _mesa_set_viewport(fmesa->glCtx,
- 0, 0,
- driDrawPriv->w,
- driDrawPriv->h);
-
first_time = 0;
if (fmesa->wid == ~0) {
first_time = 1;
diff --git a/src/mesa/drivers/dri/gamma/gamma_state.c b/src/mesa/drivers/dri/gamma/gamma_state.c
index 7beabc6926..29f1a57959 100644
--- a/src/mesa/drivers/dri/gamma/gamma_state.c
+++ b/src/mesa/drivers/dri/gamma/gamma_state.c
@@ -27,6 +27,7 @@
#include "gamma_context.h"
#include "gamma_macros.h"
+#include "buffers.h"
#include "macros.h"
#include "glint_dri.h"
#include "colormac.h"
@@ -1098,6 +1099,8 @@ void gammaUpdateWindow( GLcontext *ctx )
static void gammaDDViewport( GLcontext *ctx, GLint x, GLint y,
GLsizei width, GLsizei height )
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
gammaUpdateWindow( ctx );
}
diff --git a/src/mesa/drivers/dri/gamma/gamma_xmesa.c b/src/mesa/drivers/dri/gamma/gamma_xmesa.c
index 64ba0d909a..00f6aa32ae 100644
--- a/src/mesa/drivers/dri/gamma/gamma_xmesa.c
+++ b/src/mesa/drivers/dri/gamma/gamma_xmesa.c
@@ -225,11 +225,6 @@ newGammaCtx->new_state |= GAMMA_NEW_WINDOW; /* FIXME */
_mesa_make_current2( newGammaCtx->glCtx,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate );
-
- if (!newGammaCtx->glCtx->Viewport.Width) {
- _mesa_set_viewport(newGammaCtx->glCtx, 0, 0,
- driDrawPriv->w, driDrawPriv->h);
- }
} else {
_mesa_make_current( 0, 0 );
}
diff --git a/src/mesa/drivers/dri/i810/i810context.c b/src/mesa/drivers/dri/i810/i810context.c
index 7db354d193..4443c7eac5 100644
--- a/src/mesa/drivers/dri/i810/i810context.c
+++ b/src/mesa/drivers/dri/i810/i810context.c
@@ -431,9 +431,6 @@ i810MakeCurrent(__DRIcontextPrivate *driContextPriv,
/* Are these necessary?
*/
i810XMesaWindowMoved( imesa );
- if (!imesa->glCtx->Viewport.Width)
- _mesa_set_viewport(imesa->glCtx, 0, 0,
- driDrawPriv->w, driDrawPriv->h);
}
else {
_mesa_make_current(0,0);
diff --git a/src/mesa/drivers/dri/i810/i810state.c b/src/mesa/drivers/dri/i810/i810state.c
index 35fad6529c..42df2e8b9e 100644
--- a/src/mesa/drivers/dri/i810/i810state.c
+++ b/src/mesa/drivers/dri/i810/i810state.c
@@ -3,6 +3,7 @@
#include <stdio.h>
#include "glheader.h"
+#include "buffers.h"
#include "context.h"
#include "macros.h"
#include "enums.h"
@@ -682,6 +683,8 @@ static void i810Viewport( GLcontext *ctx,
GLint x, GLint y,
GLsizei width, GLsizei height )
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
i810CalcViewport( ctx );
}
diff --git a/src/mesa/drivers/dri/i830/i830_context.c b/src/mesa/drivers/dri/i830/i830_context.c
index 3e6f8a9a1f..082476f211 100644
--- a/src/mesa/drivers/dri/i830/i830_context.c
+++ b/src/mesa/drivers/dri/i830/i830_context.c
@@ -530,10 +530,6 @@ GLboolean i830MakeCurrent(__DRIcontextPrivate *driContextPriv,
_mesa_make_current2(imesa->glCtx,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate);
-
- if (!imesa->glCtx->Viewport.Width)
- _mesa_set_viewport(imesa->glCtx, 0, 0,
- driDrawPriv->w, driDrawPriv->h);
} else {
_mesa_make_current(0,0);
}
diff --git a/src/mesa/drivers/dri/i830/i830_state.c b/src/mesa/drivers/dri/i830/i830_state.c
index 12cec35c3d..f8979c7018 100644
--- a/src/mesa/drivers/dri/i830/i830_state.c
+++ b/src/mesa/drivers/dri/i830/i830_state.c
@@ -36,6 +36,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "glheader.h"
+#include "buffers.h"
#include "context.h"
#include "macros.h"
#include "enums.h"
@@ -1228,6 +1229,8 @@ static void i830Viewport( GLcontext *ctx,
GLint x, GLint y,
GLsizei width, GLsizei height )
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
i830CalcViewport( ctx );
}
diff --git a/src/mesa/drivers/dri/i915/intel_context.c b/src/mesa/drivers/dri/i915/intel_context.c
index 302ddfa840..1ff7b8be7f 100644
--- a/src/mesa/drivers/dri/i915/intel_context.c
+++ b/src/mesa/drivers/dri/i915/intel_context.c
@@ -534,9 +534,6 @@ GLboolean intelMakeCurrent(__DRIcontextPrivate *driContextPriv,
_mesa_make_current2(&intel->ctx,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate);
-
- if (!intel->ctx.Viewport.Width)
- _mesa_set_viewport(&intel->ctx, 0, 0, driDrawPriv->w, driDrawPriv->h);
} else {
_mesa_make_current(0,0);
}
diff --git a/src/mesa/drivers/dri/mach64/mach64_context.c b/src/mesa/drivers/dri/mach64/mach64_context.c
index 0bbda3a43d..1978c5d615 100644
--- a/src/mesa/drivers/dri/mach64/mach64_context.c
+++ b/src/mesa/drivers/dri/mach64/mach64_context.c
@@ -312,11 +312,6 @@ mach64MakeCurrent( __DRIcontextPrivate *driContextPriv,
newMach64Ctx->new_state |= MACH64_NEW_CLIP;
-
- if ( !newMach64Ctx->glCtx->Viewport.Width ) {
- _mesa_set_viewport(newMach64Ctx->glCtx, 0, 0,
- driDrawPriv->w, driDrawPriv->h);
- }
} else {
_mesa_make_current( 0, 0 );
}
diff --git a/src/mesa/drivers/dri/mach64/mach64_state.c b/src/mesa/drivers/dri/mach64/mach64_state.c
index 91f588bb78..ea55124d91 100644
--- a/src/mesa/drivers/dri/mach64/mach64_state.c
+++ b/src/mesa/drivers/dri/mach64/mach64_state.c
@@ -37,6 +37,7 @@
#include "mach64_tex.h"
#include "context.h"
+#include "buffers.h"
#include "enums.h"
#include "colormac.h"
#include "swrast/swrast.h"
@@ -646,6 +647,8 @@ static void mach64Viewport( GLcontext *ctx,
GLint x, GLint y,
GLsizei width, GLsizei height )
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
mach64CalcViewport( ctx );
}
diff --git a/src/mesa/drivers/dri/mga/mga_xmesa.c b/src/mesa/drivers/dri/mga/mga_xmesa.c
index 8bed48c423..6fcef0c448 100644
--- a/src/mesa/drivers/dri/mga/mga_xmesa.c
+++ b/src/mesa/drivers/dri/mga/mga_xmesa.c
@@ -802,11 +802,6 @@ mgaMakeCurrent(__DRIcontextPrivate *driContextPriv,
_mesa_make_current2(mmesa->glCtx,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate);
-
- if (!mmesa->glCtx->Viewport.Width)
- _mesa_set_viewport(mmesa->glCtx, 0, 0,
- driDrawPriv->w, driDrawPriv->h);
-
}
else {
_mesa_make_current(NULL, NULL);
diff --git a/src/mesa/drivers/dri/mga/mgastate.c b/src/mesa/drivers/dri/mga/mgastate.c
index 295d3f5a08..69cc0f33a7 100644
--- a/src/mesa/drivers/dri/mga/mgastate.c
+++ b/src/mesa/drivers/dri/mga/mgastate.c
@@ -28,6 +28,7 @@
#include "mtypes.h"
+#include "buffers.h"
#include "colormac.h"
#include "dd.h"
@@ -695,6 +696,8 @@ static void mgaViewport( GLcontext *ctx,
GLint x, GLint y,
GLsizei width, GLsizei height )
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
mgaCalcViewport( ctx );
}
diff --git a/src/mesa/drivers/dri/r128/r128_context.c b/src/mesa/drivers/dri/r128/r128_context.c
index 287f041a81..2f417d9097 100644
--- a/src/mesa/drivers/dri/r128/r128_context.c
+++ b/src/mesa/drivers/dri/r128/r128_context.c
@@ -341,13 +341,7 @@ r128MakeCurrent( __DRIcontextPrivate *driContextPriv,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate );
-
newR128Ctx->new_state |= R128_NEW_WINDOW | R128_NEW_CLIP;
-
- if ( !newR128Ctx->glCtx->Viewport.Width ) {
- _mesa_set_viewport(newR128Ctx->glCtx, 0, 0,
- driDrawPriv->w, driDrawPriv->h);
- }
} else {
_mesa_make_current( 0, 0 );
}
diff --git a/src/mesa/drivers/dri/r128/r128_state.c b/src/mesa/drivers/dri/r128/r128_state.c
index 4e43629f49..320865c67b 100644
--- a/src/mesa/drivers/dri/r128/r128_state.c
+++ b/src/mesa/drivers/dri/r128/r128_state.c
@@ -41,6 +41,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r128_tex.h"
#include "context.h"
+#include "buffers.h"
#include "enums.h"
#include "colormac.h"
#include "swrast/swrast.h"
@@ -664,6 +665,8 @@ static void r128Viewport( GLcontext *ctx,
GLint x, GLint y,
GLsizei width, GLsizei height )
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
r128CalcViewport( ctx );
}
diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c
index d5d2ce150a..7bf097b125 100644
--- a/src/mesa/drivers/dri/r200/r200_context.c
+++ b/src/mesa/drivers/dri/r200/r200_context.c
@@ -624,11 +624,6 @@ r200MakeCurrent( __DRIcontextPrivate *driContextPriv,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate );
- if ( !newCtx->glCtx->Viewport.Width ) {
- _mesa_set_viewport( newCtx->glCtx, 0, 0,
- driDrawPriv->w, driDrawPriv->h );
- }
-
if (newCtx->vb.enabled)
r200VtxfmtMakeCurrent( newCtx->glCtx );
diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c
index fc69ec1b5b..9231697a49 100644
--- a/src/mesa/drivers/dri/radeon/radeon_context.c
+++ b/src/mesa/drivers/dri/radeon/radeon_context.c
@@ -593,11 +593,6 @@ radeonMakeCurrent( __DRIcontextPrivate *driContextPriv,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate );
- if ( !newCtx->glCtx->Viewport.Width ) {
- _mesa_set_viewport( newCtx->glCtx, 0, 0,
- driDrawPriv->w, driDrawPriv->h );
- }
-
if (newCtx->vb.enabled)
radeonVtxfmtMakeCurrent( newCtx->glCtx );
diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c b/src/mesa/drivers/dri/radeon/radeon_state.c
index bc94882a66..851b62035a 100644
--- a/src/mesa/drivers/dri/radeon/radeon_state.c
+++ b/src/mesa/drivers/dri/radeon/radeon_state.c
@@ -39,6 +39,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "enums.h"
#include "colormac.h"
#include "state.h"
+#include "buffers.h"
#include "context.h"
#include "swrast/swrast.h"
@@ -1451,6 +1452,8 @@ void radeonUpdateWindow( GLcontext *ctx )
static void radeonViewport( GLcontext *ctx, GLint x, GLint y,
GLsizei width, GLsizei height )
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
/* Don't pipeline viewport changes, conflict with window offset
* setting below. Could apply deltas to rescue pipelined viewport
* values, or keep the originals hanging around.
diff --git a/src/mesa/drivers/dri/savage/savage_xmesa.c b/src/mesa/drivers/dri/savage/savage_xmesa.c
index adb7f2c82d..a80ffce5d7 100644
--- a/src/mesa/drivers/dri/savage/savage_xmesa.c
+++ b/src/mesa/drivers/dri/savage/savage_xmesa.c
@@ -676,10 +676,6 @@ savageMakeCurrent(__DRIcontextPrivate *driContextPriv,
(GLframebuffer *) driReadPriv->driverPrivate);
savageXMesaWindowMoved( imesa );
-
- if (!imesa->glCtx->Viewport.Width)
- _mesa_set_viewport(imesa->glCtx, 0, 0,
- driDrawPriv->w, driDrawPriv->h);
}
else
{
diff --git a/src/mesa/drivers/dri/savage/savagestate.c b/src/mesa/drivers/dri/savage/savagestate.c
index c6545fbcca..75289fcbfd 100644
--- a/src/mesa/drivers/dri/savage/savagestate.c
+++ b/src/mesa/drivers/dri/savage/savagestate.c
@@ -26,6 +26,7 @@
#include <stdio.h>
#include "mtypes.h"
+#include "buffers.h"
#include "enums.h"
#include "macros.h"
#include "dd.h"
@@ -704,6 +705,8 @@ static void savageViewport( GLcontext *ctx,
GLint x, GLint y,
GLsizei width, GLsizei height )
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
savageCalcViewport( ctx );
}
diff --git a/src/mesa/drivers/dri/sis/sis_context.c b/src/mesa/drivers/dri/sis/sis_context.c
index 0d15bfa5e9..3b23b7df4e 100644
--- a/src/mesa/drivers/dri/sis/sis_context.c
+++ b/src/mesa/drivers/dri/sis/sis_context.c
@@ -312,11 +312,6 @@ sisMakeCurrent( __DRIcontextPrivate *driContextPriv,
sisUpdateBufferSize( newSisCtx );
sisUpdateClipping( newSisCtx->glCtx );
-
- if ( newSisCtx->glCtx->Viewport.Width == 0 ) {
- _mesa_set_viewport(newSisCtx->glCtx, 0, 0,
- driDrawPriv->w, driDrawPriv->h);
- }
} else {
_mesa_make_current( 0, 0 );
}
diff --git a/src/mesa/drivers/dri/sis/sis_state.c b/src/mesa/drivers/dri/sis/sis_state.c
index 2cca1611df..b269d694b0 100644
--- a/src/mesa/drivers/dri/sis/sis_state.c
+++ b/src/mesa/drivers/dri/sis/sis_state.c
@@ -39,6 +39,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "sis_tex.h"
#include "context.h"
+#include "buffers.h"
#include "enums.h"
#include "colormac.h"
#include "swrast/swrast.h"
@@ -436,6 +437,8 @@ static void sisDDViewport( GLcontext *ctx,
GLint x, GLint y,
GLsizei width, GLsizei height )
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
sisCalcViewport( ctx );
}
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_context.c b/src/mesa/drivers/dri/tdfx/tdfx_context.c
index 56b1e459b7..683c9bd5f2 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_context.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_context.c
@@ -666,10 +666,6 @@ tdfxMakeCurrent( __DRIcontextPrivate *driContextPriv,
_mesa_make_current2( newCtx,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate );
-
- if ( !newCtx->Viewport.Width ) {
- _mesa_set_viewport( newCtx, 0, 0, driDrawPriv->w, driDrawPriv->h );
- }
} else {
_mesa_make_current( 0, 0 );
}
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_state.c b/src/mesa/drivers/dri/tdfx/tdfx_state.c
index 818a9bc23f..6edf804b2e 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_state.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_state.c
@@ -40,6 +40,7 @@
*/
#include "mtypes.h"
+#include "buffers.h"
#include "colormac.h"
#include "texformat.h"
#include "texstore.h"
@@ -902,6 +903,8 @@ static void tdfxDDViewport( GLcontext *ctx, GLint x, GLint y,
GLsizei w, GLsizei h )
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
FLUSH_BATCH( fxMesa );
fxMesa->new_state |= TDFX_NEW_VIEWPORT;
}
diff --git a/src/mesa/drivers/dri/unichrome/via_context.c b/src/mesa/drivers/dri/unichrome/via_context.c
index f058424e64..490f574ad1 100644
--- a/src/mesa/drivers/dri/unichrome/via_context.c
+++ b/src/mesa/drivers/dri/unichrome/via_context.c
@@ -959,9 +959,6 @@ viaMakeCurrent(__DRIcontextPrivate *driContextPriv,
if (VIA_DEBUG) fprintf(stderr, "Context %d MakeCurrent\n", vmesa->hHWContext);
#endif
viaXMesaWindowMoved(vmesa);
- if (!vmesa->glCtx->Viewport.Width)
- _mesa_set_viewport(vmesa->glCtx, 0, 0,
- driDrawPriv->w, driDrawPriv->h);
}
else {
_mesa_make_current(0,0);
diff --git a/src/mesa/drivers/dri/unichrome/via_state.c b/src/mesa/drivers/dri/unichrome/via_state.c
index 79ce4cbe88..4c78a3f263 100644
--- a/src/mesa/drivers/dri/unichrome/via_state.c
+++ b/src/mesa/drivers/dri/unichrome/via_state.c
@@ -25,6 +25,7 @@
#include <stdio.h>
#include "glheader.h"
+#include "buffers.h"
#include "context.h"
#include "macros.h"
#include "colormac.h"
@@ -464,6 +465,8 @@ static void viaViewport(GLcontext *ctx,
GLint x, GLint y,
GLsizei width, GLsizei height)
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
viaCalcViewport(ctx);
}
diff --git a/src/mesa/drivers/dri/x11/x11_dri.c b/src/mesa/drivers/dri/x11/x11_dri.c
index f7d25271fb..f414b7e424 100644
--- a/src/mesa/drivers/dri/x11/x11_dri.c
+++ b/src/mesa/drivers/dri/x11/x11_dri.c
@@ -409,11 +409,6 @@ x11MakeCurrent(__DRIcontextPrivate *driContextPriv,
_mesa_make_current2(newFbCtx->glCtx,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate);
-
- if (!newFbCtx->glCtx->Viewport.Width) {
- _mesa_set_viewport(newFbCtx->glCtx, 0, 0,
- driDrawPriv->w, driDrawPriv->h);
- }
} else {
_mesa_make_current(0, 0);
}
diff --git a/src/mesa/drivers/fbdev/glfbdev.c b/src/mesa/drivers/fbdev/glfbdev.c
index cfb6a70f60..9cf0be0e16 100644
--- a/src/mesa/drivers/fbdev/glfbdev.c
+++ b/src/mesa/drivers/fbdev/glfbdev.c
@@ -45,6 +45,7 @@
#include "glheader.h"
#include <linux/fb.h>
#include "GL/glfbdev.h"
+#include "buffers.h"
#include "context.h"
#include "extensions.h"
#include "imports.h"
@@ -151,6 +152,14 @@ get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
}
+static void
+viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ /* poll for window size change and realloc software Z/stencil/etc if needed */
+ _mesa_ResizeBuffersMESA();
+}
+
+
/* specifies the buffer for swrast span rendering/reading */
static void
set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit )
@@ -639,6 +648,7 @@ glFBDevCreateContext( const GLFBDevVisualPtr visual, GLFBDevContextPtr share )
functions.GetString = get_string;
functions.UpdateState = update_state;
functions.GetBufferSize = get_buffer_size;
+ functions.Viewport = viewport;
if (!_mesa_initialize_context(&ctx->glcontext, &visual->glvisual,
share ? &share->glcontext : NULL,
diff --git a/src/mesa/drivers/ggi/ggimesa.c b/src/mesa/drivers/ggi/ggimesa.c
index cb34c1a541..0652d76248 100644
--- a/src/mesa/drivers/ggi/ggimesa.c
+++ b/src/mesa/drivers/ggi/ggimesa.c
@@ -30,6 +30,7 @@
#include <ggi/mesa/ggimesa_int.h>
#include <ggi/mesa/debug.h>
#include "extensions.h"
+#include "buffers.h"
#include "colormac.h"
#include "imports.h"
#include "matrix.h"
@@ -256,6 +257,13 @@ static void gl_ggiGetSize(GLframebuffer *fb, GLuint *width, GLuint *height)
printf("returning %d, %d\n", *width, *height);
}
+static void gl_ggiViewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ /* poll for window size change and realloc software Z/stencil/etc if needed */
+ _mesa_ResizeBuffersMESA();
+}
+
+
static void gl_ggiSetIndex(GLcontext *ctx, GLuint ci)
{
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
@@ -400,6 +408,7 @@ static void gl_ggiSetupPointers(GLcontext *ctx)
/* General information */
ctx->Driver.GetString = gl_ggiGetString;
ctx->Driver.GetBufferSize = gl_ggiGetSize;
+ ctx->Driver.Viewport = gl_ggiViewport;
ctx->Driver.Finish = gl_ggiFlush;
ctx->Driver.Flush = gl_ggiFlush;
@@ -632,15 +641,6 @@ void ggiMesaMakeCurrent(ggi_mesa_context_t ctx, ggi_visual_t vis)
}
_mesa_make_current(ctx->gl_ctx, &LIBGGI_MESAEXT(vis)->mesa_buffer);
-
- if (ctx->gl_ctx->Viewport.Width == 0)
- {
- _mesa_Viewport(0, 0,
- LIBGGI_VIRTX(vis),
- LIBGGI_VIRTY(vis));
- ctx->gl_ctx->Scissor.Width = LIBGGI_VIRTX(vis);
- ctx->gl_ctx->Scissor.Height = LIBGGI_VIRTY(vis);
- }
}
diff --git a/src/mesa/drivers/glide/fxapi.c b/src/mesa/drivers/glide/fxapi.c
index 708dad51f4..a96709c4fa 100644
--- a/src/mesa/drivers/glide/fxapi.c
+++ b/src/mesa/drivers/glide/fxapi.c
@@ -873,10 +873,6 @@ fxMesaMakeCurrent(fxMesaContext fxMesa)
_mesa_make_current(fxMesa->glCtx, fxMesa->glBuffer);
fxSetupDDPointers(fxMesa->glCtx);
-
- /* The first time we call MakeCurrent we set the initial viewport size */
- if (fxMesa->glCtx->Viewport.Width == 0)
- _mesa_set_viewport(fxMesa->glCtx, 0, 0, fxMesa->width, fxMesa->height);
}
diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c
index a54bf8fb9c..e222db951d 100644
--- a/src/mesa/drivers/glide/fxdd.c
+++ b/src/mesa/drivers/glide/fxdd.c
@@ -43,6 +43,7 @@
#include "image.h"
#include "mtypes.h"
#include "fxdrv.h"
+#include "buffers.h"
#include "enums.h"
#include "extensions.h"
#include "macros.h"
@@ -106,7 +107,7 @@ static void fxDisableColor (fxMesaContext fxMesa)
/* Return buffer size information */
static void
-fxDDBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
+fxDDGetBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
{
GET_CURRENT_CONTEXT(ctx);
if (ctx && FX_CONTEXT(ctx)) {
@@ -121,6 +122,12 @@ fxDDBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
}
}
+static void
+fxDDViewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ /* poll for window size change and realloc software Z/stencil/etc if needed */
+ _mesa_ResizeBuffersMESA();
+}
/* Implements glClearColor() */
static void
@@ -2106,7 +2113,8 @@ fxSetupDDPointers(GLcontext * ctx)
ctx->Driver.ClearColor = fxDDClearColor;
ctx->Driver.Clear = fxDDClear;
ctx->Driver.DrawBuffer = fxDDSetDrawBuffer;
- ctx->Driver.GetBufferSize = fxDDBufferSize;
+ ctx->Driver.GetBufferSize = fxDDGetBufferSize;
+ ctx->Driver.Viewport = fxDDViewport;
switch (fxMesa->colDepth) {
case 15:
ctx->Driver.DrawPixels = fxDDDrawPixels555;
diff --git a/src/mesa/drivers/svga/svgamesa.c b/src/mesa/drivers/svga/svgamesa.c
index 5f636e14af..980daf30e9 100644
--- a/src/mesa/drivers/svga/svgamesa.c
+++ b/src/mesa/drivers/svga/svgamesa.c
@@ -1,4 +1,4 @@
-/* $Id: svgamesa.c,v 1.23 2002/11/11 18:42:38 brianp Exp $ */
+/* $Id: svgamesa.c,v 1.24 2004/11/27 22:48:00 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -39,6 +39,7 @@
#include <string.h>
#include <vga.h>
#include "GL/svgamesa.h"
+#include "buffers.h"
#include "context.h"
#include "extensions.h"
#include "imports.h"
@@ -212,6 +213,11 @@ static void get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *heigh
*height = SVGAMesa->height = vga_getydim();
}
+static void viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ /* poll for window size change and realloc software Z/stencil/etc if needed */
+ _mesa_ResizeBuffersMESA();
+}
static void set_buffer( GLcontext *ctx, GLframebuffer *colorBuffer,
GLenum buffer )
@@ -258,6 +264,7 @@ static void svgamesa_update_state( GLcontext *ctx, GLuint new_state )
ctx->Driver.GetBufferSize = get_buffer_size;
ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
+ ctx->Driver.Viewport = viewport;
/* Software rasterizer pixel paths:
*/
@@ -446,10 +453,8 @@ void SVGAMesaMakeCurrent( SVGAMesaContext ctx )
_mesa_make_current( ctx->gl_ctx, ctx->gl_buffer );
if (ctx->width==0 || ctx->height==0) {
- /* setup initial viewport */
ctx->width = vga_getxdim();
ctx->height = vga_getydim();
- _mesa_set_viewport( ctx->gl_ctx, 0, 0, ctx->width, ctx->height );
}
#endif
}
diff --git a/src/mesa/drivers/windows/gdi/wmesa.c b/src/mesa/drivers/windows/gdi/wmesa.c
index acd5f4a34f..5d7e260c4b 100644
--- a/src/mesa/drivers/windows/gdi/wmesa.c
+++ b/src/mesa/drivers/windows/gdi/wmesa.c
@@ -29,6 +29,7 @@
//#include "mesa_extend.h"
#include "glheader.h"
+#include "buffers.h"
#include "colors.h"
#include "context.h"
#include "colormac.h"
@@ -614,7 +615,7 @@ static void set_buffer(GLcontext *ctx, GLframebuffer *colorBuffer,
/* Return characteristics of the output buffer. */
-static void buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
+static void get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
{
/*GET_CURRENT_CONTEXT(ctx);*/
int New_Size;
@@ -658,6 +659,12 @@ static void buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
}
+static void viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ /* poll for window size change and realloc software Z/stencil/etc if needed */
+ _mesa_ResizeBuffersMESA();
+}
+
/**********************************************************************/
/***** Accelerated point, line, polygon rendering *****/
@@ -1094,7 +1101,8 @@ static void SetFunctionPointers( struct dd_function_table *functions )
functions->GetString = get_string;
functions->UpdateState = wmesa_update_state;
functions->ResizeBuffers = _swrast_alloc_buffers;
- functions->GetBufferSize = buffer_size;
+ functions->GetBufferSize = get_buffer_size;
+ functions->Viewport = viewport;
functions->Clear = clear;
@@ -1491,12 +1499,6 @@ void WMesaMakeCurrent( WMesaContext c )
Current = c;
wmesa_update_state(c->gl_ctx, 0);
_mesa_make_current(c->gl_ctx, c->gl_buffer);
- if (Current->gl_ctx->Viewport.Width==0) {
- /* initialize viewport to window size */
- _mesa_Viewport( 0, 0, Current->width, Current->height );
- Current->gl_ctx->Scissor.Width = Current->width;
- Current->gl_ctx->Scissor.Height = Current->height;
- }
if ((c->cColorBits <= 8 ) && (c->rgb_flag == GL_TRUE)){
WMesaPaletteChange(c->hPalHalfTone);
}
diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c
index d8f3e22cfc..4afc81484a 100644
--- a/src/mesa/drivers/x11/xm_dd.c
+++ b/src/mesa/drivers/x11/xm_dd.c
@@ -25,6 +25,7 @@
#include "glxheader.h"
#include "bufferobj.h"
+#include "buffers.h"
#include "context.h"
#include "colormac.h"
#include "depth.h"
@@ -1203,6 +1204,23 @@ choose_tex_format( GLcontext *ctx, GLint internalFormat,
/**
+ * Called by glViewport.
+ * This is a good time for us to poll the current X window size and adjust
+ * our ancillary (back color, depth, stencil, etc) buffers to match the
+ * current window size. Remember, we have no opportunity to respond to
+ * conventional X Resize/StructureNotify events since the X driver has no
+ * event loop. Thus, we poll.
+ * Note that this trick isn't fool-proof. If the application never calls
+ * glViewport, our notion of the current window size may be incorrect.
+ */
+static void
+xmesa_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ _mesa_ResizeBuffersMESA();
+}
+
+
+/**
* Initialize the device driver function table with the functions
* we implement in this driver.
*/
@@ -1222,6 +1240,7 @@ xmesa_init_driver_functions( XMesaVisual xmvisual,
driver->Enable = enable;
driver->Clear = clear_buffers;
driver->ResizeBuffers = xmesa_resize_buffers;
+ driver->Viewport = xmesa_viewport;
#ifndef XFree86Server
driver->CopyPixels = xmesa_CopyPixels;
if (xmvisual->undithered_pf == PF_8R8G8B &&
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 6248016d21..2423b68ddc 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1606,6 +1606,10 @@ _mesa_free_context_data( GLcontext *ctx )
_mesa_delete_buffer_object(ctx, ctx->Array.NullBufferObj);
#endif
+ /* free dispatch tables */
+ _mesa_free(ctx->Exec);
+ _mesa_free(ctx->Save);
+
/* Shared context state (display lists, textures, etc) */
_glthread_LOCK_MUTEX(ctx->Shared->Mutex);
ctx->Shared->RefCount--;
@@ -1618,9 +1622,6 @@ _mesa_free_context_data( GLcontext *ctx )
if (ctx->Extensions.String)
FREE((void *) ctx->Extensions.String);
-
- FREE(ctx->Exec);
- FREE(ctx->Save);
}
@@ -1877,41 +1878,36 @@ _mesa_make_current2( GLcontext *newCtx, GLframebuffer *drawBuffer,
newCtx->NewState |= _NEW_BUFFERS;
#if _HAVE_FULL_GL
- if (drawBuffer->Width == 0 && drawBuffer->Height == 0) {
+ if (!drawBuffer->Initialized) {
/* get initial window size */
GLuint bufWidth, bufHeight;
-
- /* ask device driver for size of output buffer */
- (*newCtx->Driver.GetBufferSize)( drawBuffer, &bufWidth, &bufHeight );
-
- if (drawBuffer->Width != bufWidth ||
- drawBuffer->Height != bufHeight) {
-
- drawBuffer->Width = bufWidth;
- drawBuffer->Height = bufHeight;
-
- newCtx->Driver.ResizeBuffers( drawBuffer );
- }
+ /* ask device driver for size of the buffer */
+ (*newCtx->Driver.GetBufferSize)(drawBuffer, &bufWidth, &bufHeight);
+ /* set initial buffer size */
+ drawBuffer->Width = bufWidth;
+ drawBuffer->Height = bufHeight;
+ newCtx->Driver.ResizeBuffers( drawBuffer );
+ drawBuffer->Initialized = GL_TRUE;
}
- if (readBuffer != drawBuffer &&
- readBuffer->Width == 0 && readBuffer->Height == 0) {
+ if (readBuffer != drawBuffer && !readBuffer->Initialized) {
/* get initial window size */
GLuint bufWidth, bufHeight;
-
- /* ask device driver for size of output buffer */
- (*newCtx->Driver.GetBufferSize)( readBuffer, &bufWidth, &bufHeight );
-
- if (readBuffer->Width != bufWidth ||
- readBuffer->Height != bufHeight) {
-
- readBuffer->Width = bufWidth;
- readBuffer->Height = bufHeight;
-
- newCtx->Driver.ResizeBuffers( readBuffer );
- }
+ /* ask device driver for size of the buffer */
+ (*newCtx->Driver.GetBufferSize)(readBuffer, &bufWidth, &bufHeight);
+ /* set initial buffer size */
+ readBuffer->Width = bufWidth;
+ readBuffer->Height = bufHeight;
+ newCtx->Driver.ResizeBuffers( readBuffer );
+ readBuffer->Initialized = GL_TRUE;
}
#endif
+ if (newCtx->FirstTimeCurrent) {
+ /* set initial viewport and scissor size now */
+ _mesa_set_viewport(newCtx, 0, 0, drawBuffer->Width, drawBuffer->Height);
+ newCtx->Scissor.Width = drawBuffer->Width;
+ newCtx->Scissor.Height = drawBuffer->Height;
+ }
}
/* Alert the driver - usually passed on to the sw t&l module,
diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c
index 3a4bfe3096..82ea37508d 100644
--- a/src/mesa/main/matrix.c
+++ b/src/mesa/main/matrix.c
@@ -35,7 +35,6 @@
#include "glheader.h"
#include "imports.h"
-#include "buffers.h"
#include "context.h"
#include "enums.h"
#include "macros.h"
@@ -556,11 +555,6 @@ _mesa_Viewport( GLint x, GLint y, GLsizei width, GLsizei height )
* Set new viewport parameters and update derived state (the _WindowMap
* matrix). Usually called from _mesa_Viewport().
*
- * \note We also call _mesa_ResizeBuffersMESA() because this is a good
- * time to check if the window has been resized. Many device drivers
- * can't get direct notification from the window system of size changes
- * so this is an ad-hoc solution to that problem.
- *
* \param ctx GL context.
* \param x, y coordinates of the lower left corner of the viewport rectangle.
* \param width width of the viewport rectangle.
@@ -618,15 +612,10 @@ _mesa_set_viewport( GLcontext *ctx, GLint x, GLint y,
ctx->Viewport._WindowMap.type = MATRIX_3D_NO_ROT;
ctx->NewState |= _NEW_VIEWPORT;
- /* Check if window/buffer has been resized and if so, reallocate the
- * ancillary buffers. This is an ad-hoc solution to detecting window
- * size changes. 99% of all GL apps call glViewport when a window is
- * resized so this is a good time to check for new window dims and
- * reallocate color buffers and ancilliary buffers.
- */
- _mesa_ResizeBuffersMESA();
-
if (ctx->Driver.Viewport) {
+ /* Many drivers will use this call to check for window size changes
+ * and reallocate the z/stencil/accum/etc buffers if needed.
+ */
(*ctx->Driver.Viewport)( ctx, x, y, width, height );
}
}
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 5586e68510..a53fb12753 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1869,6 +1869,8 @@ struct gl_frame_buffer
GLuint Width, Height; /**< size of frame buffer in pixels */
+ GLboolean Initialized;
+
GLboolean UseSoftwareDepthBuffer;
GLboolean UseSoftwareAccumBuffer;
GLboolean UseSoftwareStencilBuffer;