mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-02 11:00:27 +01:00
Color clamping fixes.
This commit is contained in:
parent
919cd2c3ba
commit
0b26e826bd
6 changed files with 52 additions and 8 deletions
|
|
@ -516,6 +516,37 @@ _mesa_ColorMask( GLboolean red, GLboolean green,
|
|||
}
|
||||
|
||||
|
||||
extern void GLAPIENTRY
|
||||
_mesa_ClampColorARB(GLenum target, GLenum clamp)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
|
||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||
|
||||
if (clamp != GL_TRUE && clamp != GL_FALSE && clamp != GL_FIXED_ONLY_ARB) {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glClampColorARB(clamp)");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (target) {
|
||||
case GL_CLAMP_VERTEX_COLOR_ARB:
|
||||
ctx->Light.ClampVertexColor = clamp;
|
||||
break;
|
||||
case GL_CLAMP_FRAGMENT_COLOR_ARB:
|
||||
ctx->Color.ClampFragmentColor = clamp;
|
||||
break;
|
||||
case GL_CLAMP_READ_COLOR_ARB:
|
||||
ctx->Color.ClampReadColor = clamp;
|
||||
break;
|
||||
default:
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glClampColorARB(target)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/** \name Initialization */
|
||||
/*@{*/
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@
|
|||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 3.5
|
||||
* Version: 6.5.2
|
||||
*
|
||||
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
|
|
@ -72,6 +72,11 @@ extern void GLAPIENTRY
|
|||
_mesa_ColorMask( GLboolean red, GLboolean green,
|
||||
GLboolean blue, GLboolean alpha );
|
||||
|
||||
|
||||
extern void GLAPIENTRY
|
||||
_mesa_ClampColorARB(GLenum target, GLenum clamp);
|
||||
|
||||
|
||||
extern void
|
||||
_mesa_init_color( GLcontext * ctx );
|
||||
|
||||
|
|
|
|||
|
|
@ -1340,6 +1340,7 @@ _mesa_init_lighting( GLcontext *ctx )
|
|||
NULL );
|
||||
|
||||
ctx->Light.ColorMaterialEnabled = GL_FALSE;
|
||||
ctx->Light.ClampVertexColor = GL_TRUE;
|
||||
|
||||
/* Lighting miscellaneous */
|
||||
ctx->_ShineTabList = MALLOC_STRUCT( gl_shine_tab );
|
||||
|
|
|
|||
|
|
@ -888,6 +888,7 @@ struct gl_light_attrib
|
|||
GLenum ColorMaterialMode; /**< GL_AMBIENT, GL_DIFFUSE, etc */
|
||||
GLbitfield ColorMaterialBitmask; /**< bitmask formed from Face and Mode */
|
||||
GLboolean ColorMaterialEnabled;
|
||||
GLenum ClampVertexColor;
|
||||
|
||||
struct gl_light EnabledList; /**< List sentinel */
|
||||
|
||||
|
|
|
|||
|
|
@ -202,7 +202,8 @@ fast_read_rgba_pixels( GLcontext *ctx,
|
|||
GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type,
|
||||
GLvoid *pixels,
|
||||
const struct gl_pixelstore_attrib *packing )
|
||||
const struct gl_pixelstore_attrib *packing,
|
||||
GLbitfield transferOps)
|
||||
{
|
||||
struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
|
||||
|
||||
|
|
@ -213,7 +214,7 @@ fast_read_rgba_pixels( GLcontext *ctx,
|
|||
ASSERT(y + height <= rb->Height);
|
||||
|
||||
/* check for things we can't handle here */
|
||||
if (ctx->_ImageTransferState ||
|
||||
if (transferOps ||
|
||||
packing->SwapBytes ||
|
||||
packing->LsbFirst) {
|
||||
return GL_FALSE;
|
||||
|
|
@ -309,15 +310,20 @@ read_rgba_pixels( GLcontext *ctx,
|
|||
const struct gl_pixelstore_attrib *packing )
|
||||
{
|
||||
SWcontext *swrast = SWRAST_CONTEXT(ctx);
|
||||
const GLbitfield transferOps = ctx->_ImageTransferState;
|
||||
GLbitfield transferOps = ctx->_ImageTransferState;
|
||||
struct gl_framebuffer *fb = ctx->ReadBuffer;
|
||||
struct gl_renderbuffer *rb = fb->_ColorReadBuffer;
|
||||
|
||||
ASSERT(rb);
|
||||
|
||||
if (type == GL_FLOAT && ((ctx->Color.ClampReadColor == GL_TRUE) ||
|
||||
(ctx->Color.ClampReadColor == GL_FIXED_ONLY_ARB &&
|
||||
rb->DataType != GL_FLOAT)))
|
||||
transferOps |= IMAGE_CLAMP_BIT;
|
||||
|
||||
/* Try optimized path first */
|
||||
if (fast_read_rgba_pixels(ctx, x, y, width, height,
|
||||
format, type, pixels, packing)) {
|
||||
format, type, pixels, packing, transferOps)) {
|
||||
return; /* done! */
|
||||
}
|
||||
|
||||
|
|
@ -419,7 +425,7 @@ read_rgba_pixels( GLcontext *ctx,
|
|||
|
||||
/* pack the row of RGBA pixels into user's buffer */
|
||||
_mesa_pack_rgba_span_float(ctx, width, rgba, format, type, dst,
|
||||
packing, ctx->_ImageTransferState);
|
||||
packing, transferOps);
|
||||
|
||||
dst += dstStride;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1583,7 +1583,7 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span)
|
|||
}
|
||||
|
||||
/* Clamp color/alpha values over the range [0.0, 1.0] before storage */
|
||||
if (ctx->Color.ClampFragmentColor &&
|
||||
if (ctx->Color.ClampFragmentColor == GL_TRUE &&
|
||||
span->array->ChanType == GL_FLOAT) {
|
||||
clamp_colors(span);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue