-/* $Id: s_copypix.c,v 1.16 2001/03/19 02:25:36 keithw Exp $ */
+/* $Id: s_copypix.c,v 1.21 2001/06/26 21:15:36 brianp Exp $ */
/*
* Mesa 3-D graphics library
#include "s_context.h"
#include "s_depth.h"
+#include "s_fog.h"
#include "s_histogram.h"
#include "s_pixeltex.h"
#include "s_span.h"
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLdepth zspan[MAX_WIDTH];
+ GLfloat fogSpan[MAX_WIDTH];
GLboolean quick_draw;
GLint row;
GLboolean changeBuffer;
if (ctx->Depth.Test || ctx->Fog.Enabled) {
/* fill in array of z values */
- GLdepth z = (GLdepth)
- (ctx->Current.RasterPos[2] * ctx->DepthMax);
+ GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * ctx->DepthMax);
+ GLfloat fog;
GLint i;
+
+ if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT)
+ fog = _mesa_z_to_fogfactor(ctx, ctx->Current.RasterFogCoord);
+ else
+ fog = _mesa_z_to_fogfactor(ctx, ctx->Current.RasterDistance);
+
for (i = 0; i < width; i++) {
zspan[i] = z;
+ fogSpan[i] = fog;
}
}
(const GLchan (*)[4])rgba, NULL );
}
else if (zoom) {
- _mesa_write_zoomed_rgba_span( ctx, width, destx, dy, zspan, 0,
+ _mesa_write_zoomed_rgba_span( ctx, width, destx, dy, zspan, fogSpan,
(const GLchan (*)[4])rgba, desty);
}
else {
- _mesa_write_rgba_span( ctx, width, destx, dy, zspan, 0, rgba, GL_BITMAP );
+ _mesa_write_rgba_span( ctx, width, destx, dy, zspan, fogSpan, rgba,
+ NULL, GL_BITMAP );
}
}
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLdepth zspan[MAX_WIDTH];
+ GLfloat fogSpan[MAX_WIDTH];
GLchan rgba[MAX_WIDTH][4];
GLchan *tmpImage,*p;
GLboolean quick_draw;
if (ctx->Depth.Test || ctx->Fog.Enabled) {
/* fill in array of z values */
GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * ctx->DepthMax);
+ GLfloat fog;
+
+ if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT)
+ fog = _mesa_z_to_fogfactor(ctx, ctx->Current.RasterFogCoord);
+ else
+ fog = _mesa_z_to_fogfactor(ctx, ctx->Current.RasterDistance);
+
for (i=0;i<width;i++) {
zspan[i] = z;
+ fogSpan[i] = fog;
}
}
if (transferOps) {
const GLfloat scale = (1.0F / CHAN_MAXF);
- GLfloat rgbaFloat[MAX_WIDTH][4];
GLint k;
+ DEFMARRAY(GLfloat, rgbaFloat, MAX_WIDTH, 4); /* mac 32k limitation */
+ CHECKARRAY(rgbaFloat, return);
+
/* convert chan to float */
for (k = 0; k < width; k++) {
rgbaFloat[k][RCOMP] = (GLfloat) rgba[k][RCOMP] * scale;
rgba[k][BCOMP] = (GLchan) CLAMP(b, 0, CHAN_MAX);
rgba[k][ACOMP] = (GLchan) CLAMP(a, 0, CHAN_MAX);
}
+ UNDEFARRAY(rgbaFloat); /* mac 32k limitation */
}
if (ctx->Texture._ReallyEnabled && ctx->Pixel.PixelTextureEnabled) {
- GLfloat s[MAX_WIDTH], t[MAX_WIDTH], r[MAX_WIDTH], q[MAX_WIDTH];
- GLchan primary_rgba[MAX_WIDTH][4];
GLuint unit;
- /* XXX not sure how multitexture is supposed to work here */
+ GLchan primary_rgba[MAX_WIDTH][4];
+ DEFARRAY(GLfloat, s, MAX_WIDTH); /* mac 32k limitation */
+ DEFARRAY(GLfloat, t, MAX_WIDTH); /* mac 32k limitation */
+ DEFARRAY(GLfloat, r, MAX_WIDTH); /* mac 32k limitation */
+ DEFARRAY(GLfloat, q, MAX_WIDTH); /* mac 32k limitation */
+ CHECKARRAY(s, return); /* mac 32k limitation */
+ CHECKARRAY(t, return);
+ CHECKARRAY(r, return);
+ CHECKARRAY(q, return);
+ /* XXX not sure how multitexture is supposed to work here */
MEMCPY(primary_rgba, rgba, 4 * width * sizeof(GLchan));
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
(CONST GLchan (*)[4]) primary_rgba,
rgba);
}
+
+ UNDEFARRAY(s); /* mac 32k limitation */
+ UNDEFARRAY(t);
+ UNDEFARRAY(r);
+ UNDEFARRAY(q);
}
if (quick_draw && dy >= 0 && dy < ctx->DrawBuffer->Height) {
(const GLchan (*)[4])rgba, NULL );
}
else if (zoom) {
- _mesa_write_zoomed_rgba_span( ctx, width, destx, dy, zspan, 0,
+ _mesa_write_zoomed_rgba_span( ctx, width, destx, dy, zspan, fogSpan,
(const GLchan (*)[4])rgba, desty);
}
else {
- _mesa_write_rgba_span( ctx, width, destx, dy, zspan, 0, rgba, GL_BITMAP );
+ _mesa_write_rgba_span( ctx, width, destx, dy, zspan, fogSpan, rgba,
+ NULL, GL_BITMAP );
}
}
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLdepth zspan[MAX_WIDTH];
+ GLfloat fogSpan[MAX_WIDTH];
GLuint *tmpImage,*p;
GLint sy, dy, stepy;
GLint i, j;
if (ctx->Depth.Test || ctx->Fog.Enabled) {
/* fill in array of z values */
GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * ctx->DepthMax);
+ GLfloat fog;
+
+ if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT)
+ fog = _mesa_z_to_fogfactor(ctx, ctx->Current.RasterFogCoord);
+ else
+ fog = _mesa_z_to_fogfactor(ctx, ctx->Current.RasterDistance);
+
for (i=0;i<width;i++) {
zspan[i] = z;
+ fogSpan[i] = fog;
}
}
}
if (zoom) {
- _mesa_write_zoomed_index_span( ctx, width, destx, dy, zspan, 0, indexes, desty );
+ _mesa_write_zoomed_index_span(ctx, width, destx, dy, zspan, fogSpan,
+ indexes, desty );
}
else {
- _mesa_write_index_span(ctx, width, destx, dy, zspan, 0, indexes, GL_BITMAP);
+ _mesa_write_index_span(ctx, width, destx, dy, zspan, fogSpan, indexes,
+ NULL, GL_BITMAP);
}
}
{
GLfloat depth[MAX_WIDTH];
GLdepth zspan[MAX_WIDTH];
+ GLfloat fogSpan[MAX_WIDTH];
GLfloat *p, *tmpImage;
GLuint indexes[MAX_WIDTH];
- GLchan rgba[MAX_WIDTH][4];
GLint sy, dy, stepy;
GLint i, j;
const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
GLint overlapping;
+ DEFMARRAY(GLubyte, rgba, MAX_WIDTH, 4); /* mac 32k limitation */
+ CHECKARRAY(rgba, return); /* mac 32k limitation */
if (!ctx->Visual.depthBits) {
_mesa_error( ctx, GL_INVALID_OPERATION, "glCopyPixels" );
+ UNDEFARRAY(rgba); /* mac 32k limitation */
return;
}
}
}
+ if (ctx->Fog.Enabled) {
+ GLfloat fog;
+
+ if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT)
+ fog = _mesa_z_to_fogfactor(ctx, ctx->Current.RasterFogCoord);
+ else
+ fog = _mesa_z_to_fogfactor(ctx, ctx->Current.RasterDistance);
+
+ for (i = 0; i < width; i++) {
+ fogSpan[i] = fog;
+ }
+ }
+
if (overlapping) {
GLint ssy = sy;
tmpImage = (GLfloat *) MALLOC(width * height * sizeof(GLfloat));
if (!tmpImage) {
_mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" );
+ UNDEFARRAY(rgba); /* mac 32k limitation */
return;
}
p = tmpImage;
if (ctx->Visual.rgbMode) {
if (zoom) {
- _mesa_write_zoomed_rgba_span( ctx, width, destx, dy, zspan, 0,
- (const GLchan (*)[4])rgba, desty );
+ _mesa_write_zoomed_rgba_span( ctx, width, destx, dy, zspan,
+ fogSpan, (const GLchan (*)[4])rgba, desty );
}
else {
- _mesa_write_rgba_span( ctx, width, destx, dy, zspan, 0,
- rgba, GL_BITMAP);
+ _mesa_write_rgba_span( ctx, width, destx, dy, zspan, fogSpan,
+ rgba, NULL, GL_BITMAP);
}
}
else {
if (zoom) {
_mesa_write_zoomed_index_span( ctx, width, destx, dy,
- zspan, 0, indexes, desty );
+ zspan, fogSpan, indexes, desty );
}
else {
_mesa_write_index_span( ctx, width, destx, dy,
- zspan, 0, indexes, GL_BITMAP );
+ zspan, fogSpan, indexes, NULL, GL_BITMAP );
}
}
}
- if (overlapping)
- FREE(tmpImage);
+ UNDEFARRAY(rgba); /* mac 32k limitation */
+
+ if (overlapping)
+ FREE(tmpImage);
}