#include <stdio.h>\r
#include <stdlib.h>\r
#include <allegro.h>\r
+#include "buffers.h"\r
#include "context.h"\r
#include "imports.h"\r
#include "matrix.h"\r
}\r
\r
\r
+static void viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)\r
+{\r
+ /* poll for window size change and realloc software Z/stencil/etc if needed */\r
+ _mesa_ResizeBuffersMESA();\r
+}\r
+\r
+\r
/**********************************************************************/\r
/**********************************************************************/\r
\r
/* a new context is made current or we change buffers via set_buffer! */\r
\r
ctx->Driver.UpdateState = setup_dd_pointers;\r
- ctx->Driver.SetBuffer = set_buffer;\r
- ctx->Driver.GetBufferSize = get_buffer_size;\r
+ ctx->Driver.SetBuffer = set_buffer;\r
+ ctx->Driver.GetBufferSize = get_buffer_size;\r
+ ctx->Driver.Viewport = viewport;\r
\r
ctx->Driver.Color = set_color_generic;\r
ctx->Driver.ClearColor = clear_color_generic;\r
\r
setup_dd_pointers(context->GLContext);\r
_mesa_make_current(context->GLContext, buffer->GLBuffer);\r
- _mesa_set_viewport(context->GLContext, 0, 0, buffer->Width, buffer->Height);\r
}\r
else {\r
+ /* XXX I don't think you want to destroy anything here! */
destroy_bitmap(context->Buffer->Screen);\r
context->Buffer->Screen = NULL;\r
context->Buffer->Active = NULL;\r
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,
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);
}
+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) {
#include "imports.h"
#ifndef FX
#include "bufferobj.h"
+#include "buffers.h"
#include "extensions.h"
#include "macros.h"
#include "matrix.h"
}
+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)
{
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;
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);
}
#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"
}
+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 )
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 */
}
_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 );
}
*/
#include "mtypes.h"
+#include "buffers.h"
#include "colormac.h"
#include "mm.h"
#include "ffb_dd.h"
static void ffbDDViewport(GLcontext *ctx, GLint x, GLint y,
GLsizei width, GLsizei height)
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
ffbCalcViewport(ctx);
}
(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;
#include "gamma_context.h"
#include "gamma_macros.h"
+#include "buffers.h"
#include "macros.h"
#include "glint_dri.h"
#include "colormac.h"
static void gammaDDViewport( GLcontext *ctx, GLint x, GLint y,
GLsizei width, GLsizei height )
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
gammaUpdateWindow( ctx );
}
_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 );
}
/* 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);
#include <stdio.h>
#include "glheader.h"
+#include "buffers.h"
#include "context.h"
#include "macros.h"
#include "enums.h"
GLint x, GLint y,
GLsizei width, GLsizei height )
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
i810CalcViewport( ctx );
}
_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);
}
*/
#include "glheader.h"
+#include "buffers.h"
#include "context.h"
#include "macros.h"
#include "enums.h"
GLint x, GLint y,
GLsizei width, GLsizei height )
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
i830CalcViewport( ctx );
}
_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);
}
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 );
}
#include "mach64_tex.h"
#include "context.h"
+#include "buffers.h"
#include "enums.h"
#include "colormac.h"
#include "swrast/swrast.h"
GLint x, GLint y,
GLsizei width, GLsizei height )
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
mach64CalcViewport( ctx );
}
_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);
#include "mtypes.h"
+#include "buffers.h"
#include "colormac.h"
#include "dd.h"
GLint x, GLint y,
GLsizei width, GLsizei height )
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
mgaCalcViewport( ctx );
}
(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 );
}
#include "r128_tex.h"
#include "context.h"
+#include "buffers.h"
#include "enums.h"
#include "colormac.h"
#include "swrast/swrast.h"
GLint x, GLint y,
GLsizei width, GLsizei height )
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
r128CalcViewport( ctx );
}
(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 );
(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 );
#include "enums.h"
#include "colormac.h"
#include "state.h"
+#include "buffers.h"
#include "context.h"
#include "swrast/swrast.h"
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.
(GLframebuffer *) driReadPriv->driverPrivate);
savageXMesaWindowMoved( imesa );
-
- if (!imesa->glCtx->Viewport.Width)
- _mesa_set_viewport(imesa->glCtx, 0, 0,
- driDrawPriv->w, driDrawPriv->h);
}
else
{
#include <stdio.h>
#include "mtypes.h"
+#include "buffers.h"
#include "enums.h"
#include "macros.h"
#include "dd.h"
GLint x, GLint y,
GLsizei width, GLsizei height )
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
savageCalcViewport( ctx );
}
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 );
}
#include "sis_tex.h"
#include "context.h"
+#include "buffers.h"
#include "enums.h"
#include "colormac.h"
#include "swrast/swrast.h"
GLint x, GLint y,
GLsizei width, GLsizei height )
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
sisCalcViewport( ctx );
}
_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 );
}
*/
#include "mtypes.h"
+#include "buffers.h"
#include "colormac.h"
#include "texformat.h"
#include "texstore.h"
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;
}
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);
#include <stdio.h>
#include "glheader.h"
+#include "buffers.h"
#include "context.h"
#include "macros.h"
#include "colormac.h"
GLint x, GLint y,
GLsizei width, GLsizei height)
{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
viaCalcViewport(ctx);
}
_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);
}
#include "glheader.h"
#include <linux/fb.h>
#include "GL/glfbdev.h"
+#include "buffers.h"
#include "context.h"
#include "extensions.h"
#include "imports.h"
}
+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 )
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,
#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"
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;
/* 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;
}
_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);
- }
}
_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);
}
#include "image.h"
#include "mtypes.h"
#include "fxdrv.h"
+#include "buffers.h"
#include "enums.h"
#include "extensions.h"
#include "macros.h"
/* 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)) {
}
}
+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
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;
-/* $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
#include <string.h>
#include <vga.h>
#include "GL/svgamesa.h"
+#include "buffers.h"
#include "context.h"
#include "extensions.h"
#include "imports.h"
*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 )
ctx->Driver.GetBufferSize = get_buffer_size;
ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
+ ctx->Driver.Viewport = viewport;
/* Software rasterizer pixel paths:
*/
_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
}
//#include "mesa_extend.h"
#include "glheader.h"
+#include "buffers.h"
#include "colors.h"
#include "context.h"
#include "colormac.h"
/* 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;
}
+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 *****/
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;
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);
}
#include "glxheader.h"
#include "bufferobj.h"
+#include "buffers.h"
#include "context.h"
#include "colormac.h"
#include "depth.h"
}
+/**
+ * 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.
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 &&
_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--;
if (ctx->Extensions.String)
FREE((void *) ctx->Extensions.String);
-
- FREE(ctx->Exec);
- FREE(ctx->Save);
}
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,
#include "glheader.h"
#include "imports.h"
-#include "buffers.h"
#include "context.h"
#include "enums.h"
#include "macros.h"
* 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.
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 );
}
}
GLuint Width, Height; /**< size of frame buffer in pixels */
+ GLboolean Initialized;
+
GLboolean UseSoftwareDepthBuffer;
GLboolean UseSoftwareAccumBuffer;
GLboolean UseSoftwareStencilBuffer;