2002-02-15 16:25:16 +00:00
|
|
|
/* $Id: buffers.c,v 1.32 2002/02/15 16:25:16 brianp Exp $ */
|
2000-02-02 19:14:56 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Mesa 3-D graphics library
|
2002-02-15 16:25:16 +00:00
|
|
|
* Version: 4.1
|
2000-11-22 07:32:16 +00:00
|
|
|
*
|
2002-02-15 16:25:16 +00:00
|
|
|
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
|
2000-11-22 07:32:16 +00:00
|
|
|
*
|
2000-02-02 19:14:56 +00:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
2000-11-22 07:32:16 +00:00
|
|
|
*
|
2000-02-02 19:14:56 +00:00
|
|
|
* The above copyright notice and this permission notice shall be included
|
|
|
|
* in all copies or substantial portions of the Software.
|
2000-11-22 07:32:16 +00:00
|
|
|
*
|
2000-02-02 19:14:56 +00:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
|
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef PC_HEADER
|
|
|
|
#include "all.h"
|
|
|
|
#else
|
|
|
|
#include "glheader.h"
|
|
|
|
#include "accum.h"
|
|
|
|
#include "buffers.h"
|
2001-01-24 00:04:58 +00:00
|
|
|
#include "colormac.h"
|
2000-02-02 19:14:56 +00:00
|
|
|
#include "context.h"
|
|
|
|
#include "depth.h"
|
|
|
|
#include "enums.h"
|
|
|
|
#include "macros.h"
|
|
|
|
#include "mem.h"
|
|
|
|
#include "stencil.h"
|
|
|
|
#include "state.h"
|
2000-11-22 07:32:16 +00:00
|
|
|
#include "mtypes.h"
|
2000-02-02 19:14:56 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
_mesa_ClearIndex( GLfloat c )
|
|
|
|
{
|
|
|
|
GET_CURRENT_CONTEXT(ctx);
|
2000-12-26 05:09:27 +00:00
|
|
|
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
|
|
|
|
2001-01-24 00:04:58 +00:00
|
|
|
if (ctx->Color.ClearIndex == (GLuint) c)
|
2000-12-26 05:09:27 +00:00
|
|
|
return;
|
2001-03-12 00:48:37 +00:00
|
|
|
|
2000-12-26 05:09:27 +00:00
|
|
|
FLUSH_VERTICES(ctx, _NEW_COLOR);
|
2000-02-02 19:14:56 +00:00
|
|
|
ctx->Color.ClearIndex = (GLuint) c;
|
2000-10-30 13:31:59 +00:00
|
|
|
|
2001-01-24 00:04:58 +00:00
|
|
|
if (!ctx->Visual.rgbMode && ctx->Driver.ClearIndex) {
|
2000-02-02 19:14:56 +00:00
|
|
|
/* it's OK to call glClearIndex in RGBA mode but it should be a NOP */
|
|
|
|
(*ctx->Driver.ClearIndex)( ctx, ctx->Color.ClearIndex );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2001-01-24 00:04:58 +00:00
|
|
|
_mesa_ClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha )
|
2000-02-02 19:14:56 +00:00
|
|
|
{
|
2001-01-24 00:04:58 +00:00
|
|
|
GLchan tmp[4];
|
2000-02-02 19:14:56 +00:00
|
|
|
GET_CURRENT_CONTEXT(ctx);
|
2000-12-26 05:09:27 +00:00
|
|
|
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
2000-02-02 19:14:56 +00:00
|
|
|
|
2001-01-24 00:04:58 +00:00
|
|
|
UNCLAMPED_FLOAT_TO_CHAN(tmp[0], red);
|
|
|
|
UNCLAMPED_FLOAT_TO_CHAN(tmp[1], green);
|
|
|
|
UNCLAMPED_FLOAT_TO_CHAN(tmp[2], blue);
|
|
|
|
UNCLAMPED_FLOAT_TO_CHAN(tmp[3], alpha);
|
2000-12-26 05:09:27 +00:00
|
|
|
|
|
|
|
if (TEST_EQ_4V(tmp, ctx->Color.ClearColor))
|
|
|
|
return;
|
|
|
|
|
|
|
|
FLUSH_VERTICES(ctx, _NEW_COLOR);
|
2001-01-24 00:04:58 +00:00
|
|
|
COPY_CHAN4(ctx->Color.ClearColor, tmp);
|
|
|
|
|
|
|
|
if (ctx->Visual.rgbMode && ctx->Driver.ClearColor) {
|
|
|
|
/* it's OK to call glClearColor in CI mode but it should be a NOP */
|
|
|
|
(*ctx->Driver.ClearColor)(ctx, ctx->Color.ClearColor);
|
2000-02-02 19:14:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-11-22 07:32:16 +00:00
|
|
|
void
|
2000-02-02 19:14:56 +00:00
|
|
|
_mesa_Clear( GLbitfield mask )
|
|
|
|
{
|
|
|
|
GET_CURRENT_CONTEXT(ctx);
|
2000-12-26 05:09:27 +00:00
|
|
|
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
|
2000-02-02 19:14:56 +00:00
|
|
|
|
|
|
|
if (MESA_VERBOSE & VERBOSE_API)
|
|
|
|
fprintf(stderr, "glClear 0x%x\n", mask);
|
|
|
|
|
2002-02-15 16:25:16 +00:00
|
|
|
if (mask & ~(GL_COLOR_BUFFER_BIT |
|
|
|
|
GL_DEPTH_BUFFER_BIT |
|
|
|
|
GL_STENCIL_BUFFER_BIT |
|
|
|
|
GL_ACCUM_BUFFER_BIT)) {
|
|
|
|
/* invalid bit set */
|
|
|
|
_mesa_error( ctx, GL_INVALID_VALUE, "glClear(mask)");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-02-02 19:14:56 +00:00
|
|
|
if (ctx->NewState) {
|
2001-03-03 20:33:27 +00:00
|
|
|
_mesa_update_state( ctx ); /* update _Xmin, etc */
|
2000-02-02 19:14:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ctx->RenderMode==GL_RENDER) {
|
2000-11-13 20:02:56 +00:00
|
|
|
const GLint x = ctx->DrawBuffer->_Xmin;
|
|
|
|
const GLint y = ctx->DrawBuffer->_Ymin;
|
|
|
|
const GLint height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
|
|
|
|
const GLint width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
|
2000-02-02 19:14:56 +00:00
|
|
|
GLbitfield ddMask;
|
|
|
|
|
|
|
|
/* don't clear depth buffer if depth writing disabled */
|
|
|
|
if (!ctx->Depth.Mask)
|
|
|
|
CLEAR_BITS(mask, GL_DEPTH_BUFFER_BIT);
|
|
|
|
|
|
|
|
/* Build bitmask to send to driver Clear function */
|
|
|
|
ddMask = mask & (GL_DEPTH_BUFFER_BIT |
|
|
|
|
GL_STENCIL_BUFFER_BIT |
|
|
|
|
GL_ACCUM_BUFFER_BIT);
|
|
|
|
if (mask & GL_COLOR_BUFFER_BIT) {
|
|
|
|
ddMask |= ctx->Color.DrawDestMask;
|
|
|
|
}
|
|
|
|
|
|
|
|
ASSERT(ctx->Driver.Clear);
|
2001-09-14 21:36:43 +00:00
|
|
|
ctx->Driver.Clear( ctx, ddMask, (GLboolean) !ctx->Scissor.Enabled,
|
2001-01-29 20:47:39 +00:00
|
|
|
x, y, width, height );
|
2000-02-02 19:14:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
_mesa_DrawBuffer( GLenum mode )
|
|
|
|
{
|
|
|
|
GET_CURRENT_CONTEXT(ctx);
|
2000-12-26 05:09:27 +00:00
|
|
|
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* too complex... */
|
|
|
|
|
2000-02-02 19:14:56 +00:00
|
|
|
|
|
|
|
if (MESA_VERBOSE & VERBOSE_API)
|
2001-03-03 20:33:27 +00:00
|
|
|
fprintf(stderr, "glDrawBuffer %s\n", _mesa_lookup_enum_by_nr(mode));
|
2000-02-02 19:14:56 +00:00
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case GL_AUX0:
|
|
|
|
case GL_AUX1:
|
|
|
|
case GL_AUX2:
|
|
|
|
case GL_AUX3:
|
|
|
|
/* AUX buffers not implemented in Mesa at this time */
|
2001-03-03 20:33:27 +00:00
|
|
|
_mesa_error( ctx, GL_INVALID_OPERATION, "glDrawBuffer" );
|
2000-02-02 19:14:56 +00:00
|
|
|
return;
|
|
|
|
case GL_RIGHT:
|
2001-01-23 23:39:36 +00:00
|
|
|
if (!ctx->Visual.stereoMode) {
|
2001-03-03 20:33:27 +00:00
|
|
|
_mesa_error( ctx, GL_INVALID_OPERATION, "glDrawBuffer" );
|
2000-09-26 20:53:53 +00:00
|
|
|
return;}
|
2001-01-23 23:39:36 +00:00
|
|
|
if (ctx->Visual.doubleBufferMode)
|
2000-02-02 19:14:56 +00:00
|
|
|
ctx->Color.DrawDestMask = FRONT_RIGHT_BIT | BACK_RIGHT_BIT;
|
|
|
|
else
|
|
|
|
ctx->Color.DrawDestMask = FRONT_RIGHT_BIT;
|
|
|
|
break;
|
|
|
|
case GL_FRONT_RIGHT:
|
2001-01-23 23:39:36 +00:00
|
|
|
if (!ctx->Visual.stereoMode) {
|
2001-03-03 20:33:27 +00:00
|
|
|
_mesa_error( ctx, GL_INVALID_OPERATION, "glDrawBuffer" );
|
2000-02-02 19:14:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
ctx->Color.DrawDestMask = FRONT_RIGHT_BIT;
|
|
|
|
break;
|
|
|
|
case GL_BACK_RIGHT:
|
2001-01-23 23:39:36 +00:00
|
|
|
if (!ctx->Visual.stereoMode) {
|
2001-03-03 20:33:27 +00:00
|
|
|
_mesa_error( ctx, GL_INVALID_OPERATION, "glDrawBuffer" );
|
2000-02-02 19:14:56 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-01-23 23:39:36 +00:00
|
|
|
if (!ctx->Visual.doubleBufferMode) {
|
2001-03-03 20:33:27 +00:00
|
|
|
_mesa_error( ctx, GL_INVALID_OPERATION, "glDrawBuffer" );
|
2000-02-02 19:14:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
ctx->Color.DrawDestMask = BACK_RIGHT_BIT;
|
|
|
|
break;
|
|
|
|
case GL_BACK_LEFT:
|
2001-01-23 23:39:36 +00:00
|
|
|
if (!ctx->Visual.doubleBufferMode) {
|
2001-03-03 20:33:27 +00:00
|
|
|
_mesa_error( ctx, GL_INVALID_OPERATION, "glDrawBuffer" );
|
2000-02-02 19:14:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
ctx->Color.DrawDestMask = BACK_LEFT_BIT;
|
|
|
|
break;
|
|
|
|
case GL_FRONT_AND_BACK:
|
2001-01-23 23:39:36 +00:00
|
|
|
if (!ctx->Visual.doubleBufferMode) {
|
2001-03-03 20:33:27 +00:00
|
|
|
_mesa_error( ctx, GL_INVALID_OPERATION, "glDrawBuffer" );
|
2000-02-02 19:14:56 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-01-23 23:39:36 +00:00
|
|
|
if (ctx->Visual.stereoMode)
|
2000-02-02 19:14:56 +00:00
|
|
|
ctx->Color.DrawDestMask = FRONT_LEFT_BIT | BACK_LEFT_BIT
|
|
|
|
| FRONT_RIGHT_BIT | BACK_RIGHT_BIT;
|
|
|
|
else
|
|
|
|
ctx->Color.DrawDestMask = FRONT_LEFT_BIT | BACK_LEFT_BIT;
|
|
|
|
break;
|
|
|
|
case GL_BACK:
|
2001-01-23 23:39:36 +00:00
|
|
|
if (!ctx->Visual.doubleBufferMode) {
|
2001-03-03 20:33:27 +00:00
|
|
|
_mesa_error( ctx, GL_INVALID_OPERATION, "glDrawBuffer" );
|
2000-02-02 19:14:56 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-01-23 23:39:36 +00:00
|
|
|
if (ctx->Visual.stereoMode)
|
2000-02-02 19:14:56 +00:00
|
|
|
ctx->Color.DrawDestMask = BACK_LEFT_BIT | BACK_RIGHT_BIT;
|
|
|
|
else
|
|
|
|
ctx->Color.DrawDestMask = BACK_LEFT_BIT;
|
|
|
|
break;
|
|
|
|
case GL_LEFT:
|
|
|
|
/* never an error */
|
2001-01-23 23:39:36 +00:00
|
|
|
if (ctx->Visual.doubleBufferMode)
|
2000-02-02 19:14:56 +00:00
|
|
|
ctx->Color.DrawDestMask = FRONT_LEFT_BIT | BACK_LEFT_BIT;
|
|
|
|
else
|
|
|
|
ctx->Color.DrawDestMask = FRONT_LEFT_BIT;
|
|
|
|
break;
|
|
|
|
case GL_FRONT_LEFT:
|
|
|
|
/* never an error */
|
|
|
|
ctx->Color.DrawDestMask = FRONT_LEFT_BIT;
|
|
|
|
break;
|
|
|
|
case GL_FRONT:
|
|
|
|
/* never an error */
|
2001-01-23 23:39:36 +00:00
|
|
|
if (ctx->Visual.stereoMode)
|
2000-02-02 19:14:56 +00:00
|
|
|
ctx->Color.DrawDestMask = FRONT_LEFT_BIT | FRONT_RIGHT_BIT;
|
|
|
|
else
|
|
|
|
ctx->Color.DrawDestMask = FRONT_LEFT_BIT;
|
|
|
|
break;
|
|
|
|
case GL_NONE:
|
|
|
|
/* never an error */
|
|
|
|
ctx->Color.DrawDestMask = 0;
|
|
|
|
break;
|
|
|
|
default:
|
2001-03-03 20:33:27 +00:00
|
|
|
_mesa_error( ctx, GL_INVALID_ENUM, "glDrawBuffer" );
|
2000-02-02 19:14:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make the dest buffer mode more precise if possible
|
|
|
|
*/
|
2001-01-23 23:39:36 +00:00
|
|
|
if (mode == GL_LEFT && !ctx->Visual.doubleBufferMode)
|
2000-02-02 19:14:56 +00:00
|
|
|
ctx->Color.DriverDrawBuffer = GL_FRONT_LEFT;
|
2001-01-23 23:39:36 +00:00
|
|
|
else if (mode == GL_RIGHT && !ctx->Visual.doubleBufferMode)
|
2000-02-02 19:14:56 +00:00
|
|
|
ctx->Color.DriverDrawBuffer = GL_FRONT_RIGHT;
|
2001-01-23 23:39:36 +00:00
|
|
|
else if (mode == GL_FRONT && !ctx->Visual.stereoMode)
|
2000-02-02 19:14:56 +00:00
|
|
|
ctx->Color.DriverDrawBuffer = GL_FRONT_LEFT;
|
2001-01-23 23:39:36 +00:00
|
|
|
else if (mode == GL_BACK && !ctx->Visual.stereoMode)
|
2000-02-02 19:14:56 +00:00
|
|
|
ctx->Color.DriverDrawBuffer = GL_BACK_LEFT;
|
|
|
|
else
|
|
|
|
ctx->Color.DriverDrawBuffer = mode;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set current alpha buffer pointer
|
|
|
|
*/
|
2000-05-04 13:53:55 +00:00
|
|
|
if (ctx->DrawBuffer->UseSoftwareAlphaBuffers) {
|
2000-02-02 19:14:56 +00:00
|
|
|
if (ctx->Color.DriverDrawBuffer == GL_FRONT_LEFT)
|
|
|
|
ctx->DrawBuffer->Alpha = ctx->DrawBuffer->FrontLeftAlpha;
|
|
|
|
else if (ctx->Color.DriverDrawBuffer == GL_BACK_LEFT)
|
|
|
|
ctx->DrawBuffer->Alpha = ctx->DrawBuffer->BackLeftAlpha;
|
|
|
|
else if (ctx->Color.DriverDrawBuffer == GL_FRONT_RIGHT)
|
|
|
|
ctx->DrawBuffer->Alpha = ctx->DrawBuffer->FrontRightAlpha;
|
|
|
|
else if (ctx->Color.DriverDrawBuffer == GL_BACK_RIGHT)
|
|
|
|
ctx->DrawBuffer->Alpha = ctx->DrawBuffer->BackRightAlpha;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we get here there can't have been an error.
|
|
|
|
* Now see if device driver can implement the drawing to the target
|
|
|
|
* buffer(s). The driver may not be able to do GL_FRONT_AND_BACK mode
|
|
|
|
* for example. We'll take care of that in the core code by looping
|
|
|
|
* over the individual buffers.
|
|
|
|
*/
|
|
|
|
ASSERT(ctx->Driver.SetDrawBuffer);
|
|
|
|
if ( (*ctx->Driver.SetDrawBuffer)(ctx, ctx->Color.DriverDrawBuffer) ) {
|
|
|
|
/* All OK, the driver will do all buffer writes */
|
|
|
|
ctx->Color.MultiDrawBuffer = GL_FALSE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* We'll have to loop over the multiple draw buffer targets */
|
|
|
|
ctx->Color.MultiDrawBuffer = GL_TRUE;
|
|
|
|
/* Set drawing buffer to front for now */
|
|
|
|
(void) (*ctx->Driver.SetDrawBuffer)(ctx, GL_FRONT_LEFT);
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx->Color.DrawBuffer = mode;
|
2000-10-30 13:31:59 +00:00
|
|
|
ctx->NewState |= _NEW_COLOR;
|
2000-02-02 19:14:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
_mesa_ReadBuffer( GLenum mode )
|
|
|
|
{
|
|
|
|
GET_CURRENT_CONTEXT(ctx);
|
2000-12-26 05:09:27 +00:00
|
|
|
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
|
2000-02-02 19:14:56 +00:00
|
|
|
|
|
|
|
if (MESA_VERBOSE & VERBOSE_API)
|
2001-03-03 20:33:27 +00:00
|
|
|
fprintf(stderr, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(mode));
|
2000-02-02 19:14:56 +00:00
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case GL_AUX0:
|
|
|
|
case GL_AUX1:
|
|
|
|
case GL_AUX2:
|
|
|
|
case GL_AUX3:
|
|
|
|
/* AUX buffers not implemented in Mesa at this time */
|
2001-03-03 20:33:27 +00:00
|
|
|
_mesa_error( ctx, GL_INVALID_OPERATION, "glReadBuffer" );
|
2000-02-02 19:14:56 +00:00
|
|
|
return;
|
|
|
|
case GL_LEFT:
|
|
|
|
case GL_FRONT:
|
|
|
|
case GL_FRONT_LEFT:
|
|
|
|
/* Front-Left buffer, always exists */
|
|
|
|
ctx->Pixel.DriverReadBuffer = GL_FRONT_LEFT;
|
|
|
|
break;
|
|
|
|
case GL_BACK:
|
|
|
|
case GL_BACK_LEFT:
|
|
|
|
/* Back-Left buffer, requires double buffering */
|
2001-01-23 23:39:36 +00:00
|
|
|
if (!ctx->Visual.doubleBufferMode) {
|
2001-03-03 20:33:27 +00:00
|
|
|
_mesa_error( ctx, GL_INVALID_OPERATION, "glReadBuffer" );
|
2000-02-02 19:14:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
ctx->Pixel.DriverReadBuffer = GL_BACK_LEFT;
|
|
|
|
break;
|
|
|
|
case GL_FRONT_RIGHT:
|
|
|
|
case GL_RIGHT:
|
2001-01-23 23:39:36 +00:00
|
|
|
if (!ctx->Visual.stereoMode) {
|
2001-03-03 20:33:27 +00:00
|
|
|
_mesa_error( ctx, GL_INVALID_OPERATION, "glReadBuffer" );
|
2000-02-02 19:14:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
ctx->Pixel.DriverReadBuffer = GL_FRONT_RIGHT;
|
|
|
|
break;
|
|
|
|
case GL_BACK_RIGHT:
|
2001-01-23 23:39:36 +00:00
|
|
|
if (!ctx->Visual.stereoMode || !ctx->Visual.doubleBufferMode) {
|
2001-03-03 20:33:27 +00:00
|
|
|
_mesa_error( ctx, GL_INVALID_OPERATION, "glReadBuffer" );
|
2000-02-02 19:14:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
ctx->Pixel.DriverReadBuffer = GL_BACK_RIGHT;
|
|
|
|
break;
|
|
|
|
default:
|
2001-03-03 20:33:27 +00:00
|
|
|
_mesa_error( ctx, GL_INVALID_ENUM, "glReadBuffer" );
|
2000-02-02 19:14:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx->Pixel.ReadBuffer = mode;
|
2000-10-30 13:31:59 +00:00
|
|
|
ctx->NewState |= _NEW_PIXEL;
|
2000-02-02 19:14:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* GL_MESA_resize_buffers extension
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
_mesa_ResizeBuffersMESA( void )
|
|
|
|
{
|
2000-09-26 20:53:53 +00:00
|
|
|
GLcontext *ctx = _mesa_get_current_context();
|
2000-02-02 19:14:56 +00:00
|
|
|
GLuint buf_width, buf_height;
|
2001-01-05 02:26:48 +00:00
|
|
|
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx );
|
|
|
|
|
2000-02-02 19:14:56 +00:00
|
|
|
|
|
|
|
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 );
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
2000-10-30 13:31:59 +00:00
|
|
|
ctx->NewState |= _NEW_BUFFERS; /* to update scissor / window bounds */
|
2000-02-02 19:14:56 +00:00
|
|
|
|
|
|
|
/* save buffer size */
|
|
|
|
ctx->DrawBuffer->Width = buf_width;
|
|
|
|
ctx->DrawBuffer->Height = buf_height;
|
|
|
|
|
2001-01-29 20:47:39 +00:00
|
|
|
ctx->Driver.ResizeBuffersMESA( ctx );
|
2000-02-02 19:14:56 +00:00
|
|
|
}
|
2001-05-29 15:23:48 +00:00
|
|
|
|
|
|
|
|
2001-06-18 17:26:08 +00:00
|
|
|
void
|
|
|
|
_mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height )
|
|
|
|
{
|
|
|
|
GET_CURRENT_CONTEXT(ctx);
|
|
|
|
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
|
|
|
|
|
|
|
if (width < 0 || height < 0) {
|
|
|
|
_mesa_error( ctx, GL_INVALID_VALUE, "glScissor" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (MESA_VERBOSE & VERBOSE_API)
|
|
|
|
fprintf(stderr, "glScissor %d %d %d %d\n", x, y, width, height);
|
|
|
|
|
|
|
|
if (x == ctx->Scissor.X &&
|
|
|
|
y == ctx->Scissor.Y &&
|
|
|
|
width == ctx->Scissor.Width &&
|
|
|
|
height == ctx->Scissor.Height)
|
|
|
|
return;
|
|
|
|
|
|
|
|
FLUSH_VERTICES(ctx, _NEW_SCISSOR);
|
|
|
|
ctx->Scissor.X = x;
|
|
|
|
ctx->Scissor.Y = y;
|
|
|
|
ctx->Scissor.Width = width;
|
|
|
|
ctx->Scissor.Height = height;
|
|
|
|
|
|
|
|
if (ctx->Driver.Scissor)
|
|
|
|
ctx->Driver.Scissor( ctx, x, y, width, height );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-29 15:23:48 +00:00
|
|
|
/*
|
|
|
|
* XXX move somewhere else someday?
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
_mesa_SampleCoverageARB(GLclampf value, GLboolean invert)
|
|
|
|
{
|
|
|
|
GLcontext *ctx = _mesa_get_current_context();
|
|
|
|
|
|
|
|
if (!ctx->Extensions.ARB_multisample) {
|
|
|
|
_mesa_error(ctx, GL_INVALID_OPERATION, "glSampleCoverageARB");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx );
|
2001-09-14 21:36:43 +00:00
|
|
|
ctx->Multisample.SampleCoverageValue = (GLfloat) CLAMP(value, 0.0, 1.0);
|
2001-05-29 15:23:48 +00:00
|
|
|
ctx->Multisample.SampleCoverageInvert = invert;
|
|
|
|
ctx->NewState |= _NEW_MULTISAMPLE;
|
|
|
|
}
|
|
|
|
|