/*
* Mesa 3-D graphics library
- * Version: 6.3
+ * Version: 6.5
*
- * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2005 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"),
case GL_PIXEL_MAP_S_TO_S:
ctx->Pixel.MapStoSsize = mapsize;
for (i = 0; i < mapsize; i++) {
- ctx->Pixel.MapStoS[i] = (GLint) values[i];
+ ctx->Pixel.MapStoS[i] = IROUND(values[i]);
}
break;
case GL_PIXEL_MAP_I_TO_I:
ctx->Pixel.MapItoIsize = mapsize;
for (i = 0; i < mapsize; i++) {
- ctx->Pixel.MapItoI[i] = (GLint) values[i];
+ ctx->Pixel.MapItoI[i] = values[i];
}
break;
case GL_PIXEL_MAP_I_TO_R:
GLubyte *buf;
/* Note, need to use DefaultPacking and Unpack's buffer object */
ctx->DefaultPacking.BufferObj = ctx->Unpack.BufferObj;
- if (!_mesa_validate_pbo_access(&ctx->DefaultPacking, mapsize, 1, 1,
+ if (!_mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1,
GL_INTENSITY, GL_FLOAT, values)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glPixelMapfv(invalid PBO access)");
GLubyte *buf;
/* Note, need to use DefaultPacking and Unpack's buffer object */
ctx->DefaultPacking.BufferObj = ctx->Unpack.BufferObj;
- if (!_mesa_validate_pbo_access(&ctx->DefaultPacking, mapsize, 1, 1,
+ if (!_mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1,
GL_INTENSITY, GL_UNSIGNED_INT, values)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glPixelMapuiv(invalid PBO access)");
GLubyte *buf;
/* Note, need to use DefaultPacking and Unpack's buffer object */
ctx->DefaultPacking.BufferObj = ctx->Unpack.BufferObj;
- if (!_mesa_validate_pbo_access(&ctx->DefaultPacking, mapsize, 1, 1,
+ if (!_mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1,
GL_INTENSITY, GL_UNSIGNED_SHORT,
values)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
GLubyte *buf;
/* Note, need to use DefaultPacking and Pack's buffer object */
ctx->DefaultPacking.BufferObj = ctx->Pack.BufferObj;
- if (!_mesa_validate_pbo_access(&ctx->DefaultPacking, mapsize, 1, 1,
+ if (!_mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1,
GL_INTENSITY, GL_FLOAT, values)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetPixelMapfv(invalid PBO access)");
switch (map) {
case GL_PIXEL_MAP_I_TO_I:
- for (i = 0; i < mapsize; i++) {
- values[i] = (GLfloat) ctx->Pixel.MapItoI[i];
- }
+ MEMCPY(values, ctx->Pixel.MapItoI, mapsize * sizeof(GLfloat));
break;
case GL_PIXEL_MAP_S_TO_S:
for (i = 0; i < mapsize; i++) {
GLubyte *buf;
/* Note, need to use DefaultPacking and Pack's buffer object */
ctx->DefaultPacking.BufferObj = ctx->Pack.BufferObj;
- if (!_mesa_validate_pbo_access(&ctx->DefaultPacking, mapsize, 1, 1,
+ if (!_mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1,
GL_INTENSITY, GL_UNSIGNED_INT, values)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetPixelMapuiv(invalid PBO access)");
switch (map) {
case GL_PIXEL_MAP_I_TO_I:
- MEMCPY(values, ctx->Pixel.MapItoI, mapsize * sizeof(GLint));
+ for (i = 0; i < mapsize; i++) {
+ values[i] = FLOAT_TO_UINT( ctx->Pixel.MapItoI[i] );
+ }
break;
case GL_PIXEL_MAP_S_TO_S:
MEMCPY(values, ctx->Pixel.MapStoS, mapsize * sizeof(GLint));
GLubyte *buf;
/* Note, need to use DefaultPacking and Pack's buffer object */
ctx->DefaultPacking.BufferObj = ctx->Pack.BufferObj;
- if (!_mesa_validate_pbo_access(&ctx->DefaultPacking, mapsize, 1, 1,
+ if (!_mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1,
GL_INTENSITY, GL_UNSIGNED_SHORT,
values)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
switch (map) {
case GL_PIXEL_MAP_I_TO_I:
for (i = 0; i < mapsize; i++) {
- values[i] = (GLushort) ctx->Pixel.MapItoI[i];
+ values[i] = (GLushort) CLAMP(ctx->Pixel.MapItoI[i], 0.0, 65535.0);
}
break;
case GL_PIXEL_MAP_S_TO_S:
for (i = 0; i < mapsize; i++) {
- values[i] = (GLushort) ctx->Pixel.MapStoS[i];
+ values[i] = (GLushort) CLAMP(ctx->Pixel.MapStoS[i], 0.0, 65535.0);
}
break;
case GL_PIXEL_MAP_I_TO_R:
for (i = 0; i < mapsize; i++) {
- values[i] = FLOAT_TO_USHORT( ctx->Pixel.MapItoR[i] );
+ CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapItoR[i] );
}
break;
case GL_PIXEL_MAP_I_TO_G:
for (i = 0; i < mapsize; i++) {
- values[i] = FLOAT_TO_USHORT( ctx->Pixel.MapItoG[i] );
+ CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapItoG[i] );
}
break;
case GL_PIXEL_MAP_I_TO_B:
for (i = 0; i < mapsize; i++) {
- values[i] = FLOAT_TO_USHORT( ctx->Pixel.MapItoB[i] );
+ CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapItoB[i] );
}
break;
case GL_PIXEL_MAP_I_TO_A:
for (i = 0; i < mapsize; i++) {
- values[i] = FLOAT_TO_USHORT( ctx->Pixel.MapItoA[i] );
+ CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapItoA[i] );
}
break;
case GL_PIXEL_MAP_R_TO_R:
for (i = 0; i < mapsize; i++) {
- values[i] = FLOAT_TO_USHORT( ctx->Pixel.MapRtoR[i] );
+ CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapRtoR[i] );
}
break;
case GL_PIXEL_MAP_G_TO_G:
for (i = 0; i < mapsize; i++) {
- values[i] = FLOAT_TO_USHORT( ctx->Pixel.MapGtoG[i] );
+ CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapGtoG[i] );
}
break;
case GL_PIXEL_MAP_B_TO_B:
for (i = 0; i < mapsize; i++) {
- values[i] = FLOAT_TO_USHORT( ctx->Pixel.MapBtoB[i] );
+ CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapBtoB[i] );
}
break;
case GL_PIXEL_MAP_A_TO_A:
for (i = 0; i < mapsize; i++) {
- values[i] = FLOAT_TO_USHORT( ctx->Pixel.MapAtoA[i] );
+ CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapAtoA[i] );
}
break;
default:
* Apply scale and bias factors to an array of RGBA pixels.
*/
void
-_mesa_scale_and_bias_rgba(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
+_mesa_scale_and_bias_rgba(GLuint n, GLfloat rgba[][4],
GLfloat rScale, GLfloat gScale,
GLfloat bScale, GLfloat aScale,
GLfloat rBias, GLfloat gBias,
GLfloat bBias, GLfloat aBias)
{
- (void) ctx;
-
if (rScale != 1.0 || rBias != 0.0) {
GLuint i;
for (i = 0; i < n; i++) {
if (!table->Table || table->Size == 0)
return;
- switch (table->Format) {
+ switch (table->_BaseFormat) {
case GL_INTENSITY:
/* replace RGBA with I */
if (table->Type == GL_FLOAT) {
if (!table->Table || table->Size == 0)
return;
- switch (table->Format) {
+ switch (table->_BaseFormat) {
case GL_INTENSITY:
/* replace RGBA with I */
if (table->Type == GL_FLOAT) {
void
_mesa_map_ci( const GLcontext *ctx, GLuint n, GLuint index[] )
{
- GLuint mask = ctx->Pixel.MapItoIsize - 1;
+ const GLuint mask = ctx->Pixel.MapItoIsize - 1;
GLuint i;
- for (i=0;i<n;i++) {
- index[i] = ctx->Pixel.MapItoI[ index[i] & mask ];
+ for (i = 0; i < n; i++) {
+ const GLuint j = index[i] & mask;
+ index[i] = IROUND(ctx->Pixel.MapItoI[j]);
}
}
}
+void
+_mesa_scale_and_bias_depth(const GLcontext *ctx, GLuint n,
+ GLfloat depthValues[])
+{
+ const GLfloat scale = ctx->Pixel.DepthScale;
+ const GLfloat bias = ctx->Pixel.DepthBias;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLfloat d = depthValues[i] * scale + bias;
+ depthValues[i] = CLAMP(d, 0.0F, 1.0F);
+ }
+}
+
/*
* This function converts an array of GLchan colors to GLfloat colors.
ctx->Pixel.MapBtoBsize = 1;
ctx->Pixel.MapAtoAsize = 1;
ctx->Pixel.MapStoS[0] = 0;
- ctx->Pixel.MapItoI[0] = 0;
+ ctx->Pixel.MapItoI[0] = 0.0;
ctx->Pixel.MapItoR[0] = 0.0;
ctx->Pixel.MapItoG[0] = 0.0;
ctx->Pixel.MapItoB[0] = 0.0;
ctx->Pixel.MapAtoA[0] = 0.0;
ctx->Pixel.HistogramEnabled = GL_FALSE;
ctx->Pixel.MinMaxEnabled = GL_FALSE;
- ctx->Pixel.PixelTextureEnabled = GL_FALSE;
- ctx->Pixel.FragmentRgbSource = GL_PIXEL_GROUP_COLOR_SGIS;
- ctx->Pixel.FragmentAlphaSource = GL_PIXEL_GROUP_COLOR_SGIS;
ASSIGN_4V(ctx->Pixel.PostColorMatrixScale, 1.0, 1.0, 1.0, 1.0);
ASSIGN_4V(ctx->Pixel.PostColorMatrixBias, 0.0, 0.0, 0.0, 0.0);
ASSIGN_4V(ctx->Pixel.ColorTableScale, 1.0, 1.0, 1.0, 1.0);
if (ctx->Visual.doubleBufferMode) {
ctx->Pixel.ReadBuffer = GL_BACK;
- ctx->Pixel._ReadSrcMask = DD_BACK_LEFT_BIT;
}
else {
ctx->Pixel.ReadBuffer = GL_FRONT;
- ctx->Pixel._ReadSrcMask = DD_FRONT_LEFT_BIT;
}
/* Miscellaneous */