/*
* Mesa 3-D graphics library
- * Version: 6.5
+ * Version: 6.5.3
*
- * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2007 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"),
#include "glheader.h"
#include "imports.h"
#include "accum.h"
+#include "arrayobj.h"
#include "attrib.h"
#include "blend.h"
#include "buffers.h"
attr->Blend = ctx->Color.BlendEnabled;
attr->ClipPlanes = ctx->Transform.ClipPlanesEnabled;
attr->ColorMaterial = ctx->Light.ColorMaterialEnabled;
- attr->ColorTable = ctx->Pixel.ColorTableEnabled;
- attr->PostColorMatrixColorTable = ctx->Pixel.PostColorMatrixColorTableEnabled;
- attr->PostConvolutionColorTable = ctx->Pixel.PostConvolutionColorTableEnabled;
+ for (i = 0; i < COLORTABLE_MAX; i++) {
+ attr->ColorTable[i] = ctx->Pixel.ColorTableEnabled[i];
+ }
attr->Convolution1D = ctx->Pixel.Convolution1DEnabled;
attr->Convolution2D = ctx->Pixel.Convolution2DEnabled;
attr->Separable2D = ctx->Pixel.Separable2DEnabled;
MEMCPY(attr->Map2Attrib, ctx->Eval.Map2Attrib, sizeof(ctx->Eval.Map2Attrib));
attr->Normalize = ctx->Transform.Normalize;
attr->RasterPositionUnclipped = ctx->Transform.RasterPositionUnclipped;
- attr->PixelTexture = ctx->Pixel.PixelTextureEnabled;
attr->PointSmooth = ctx->Point.SmoothFlag;
attr->PointSprite = ctx->Point.PointSprite;
attr->PolygonOffsetPoint = ctx->Polygon.OffsetPoint;
struct gl_pixel_attrib *attr;
attr = MALLOC_STRUCT( gl_pixel_attrib );
MEMCPY( attr, &ctx->Pixel, sizeof(struct gl_pixel_attrib) );
+ /* push the Read FBO's ReadBuffer state, not ctx->Pixel.ReadBuffer */
+ attr->ReadBuffer = ctx->ReadBuffer->ColorReadBuffer;
newnode = new_attrib_node( GL_PIXEL_MODE_BIT );
newnode->data = attr;
newnode->next = head;
if (mask & GL_TEXTURE_BIT) {
struct gl_texture_attrib *attr;
GLuint u;
+
+ _mesa_lock_context_textures(ctx);
/* Bump the texture object reference counts so that they don't
* inadvertantly get deleted.
*/
attr->Unit[u].CurrentCubeMap);
_mesa_copy_texture_object(&attr->Unit[u].SavedRect,
attr->Unit[u].CurrentRect);
+ _mesa_copy_texture_object(&attr->Unit[u].Saved1DArray,
+ attr->Unit[u].Current1DArray);
+ _mesa_copy_texture_object(&attr->Unit[u].Saved2DArray,
+ attr->Unit[u].Current2DArray);
}
+
+ _mesa_unlock_context_textures(ctx);
+
newnode = new_attrib_node( GL_TEXTURE_BIT );
newnode->data = attr;
newnode->next = head;
TEST_AND_UPDATE(ctx->Light.ColorMaterialEnabled, enable->ColorMaterial,
GL_COLOR_MATERIAL);
- TEST_AND_UPDATE(ctx->Pixel.ColorTableEnabled, enable->ColorTable,
+ TEST_AND_UPDATE(ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION],
+ enable->ColorTable[COLORTABLE_PRECONVOLUTION],
GL_COLOR_TABLE);
- TEST_AND_UPDATE(ctx->Pixel.PostColorMatrixColorTableEnabled,
- enable->PostColorMatrixColorTable,
- GL_POST_COLOR_MATRIX_COLOR_TABLE);
- TEST_AND_UPDATE(ctx->Pixel.PostConvolutionColorTableEnabled,
- enable->PostConvolutionColorTable,
+ TEST_AND_UPDATE(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION],
+ enable->ColorTable[COLORTABLE_POSTCONVOLUTION],
GL_POST_CONVOLUTION_COLOR_TABLE);
+ TEST_AND_UPDATE(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX],
+ enable->ColorTable[COLORTABLE_POSTCOLORMATRIX],
+ GL_POST_COLOR_MATRIX_COLOR_TABLE);
TEST_AND_UPDATE(ctx->Polygon.CullFlag, enable->CullFace, GL_CULL_FACE);
TEST_AND_UPDATE(ctx->Depth.Test, enable->DepthTest, GL_DEPTH_TEST);
TEST_AND_UPDATE(ctx->Color.DitherFlag, enable->Dither, GL_DITHER);
TEST_AND_UPDATE(ctx->Transform.RasterPositionUnclipped,
enable->RasterPositionUnclipped,
GL_RASTER_POSITION_UNCLIPPED_IBM);
- TEST_AND_UPDATE(ctx->Pixel.PixelTextureEnabled, enable->PixelTexture,
- GL_POINT_SMOOTH);
TEST_AND_UPDATE(ctx->Point.SmoothFlag, enable->PointSmooth,
GL_POINT_SMOOTH);
if (ctx->Extensions.NV_point_sprite || ctx->Extensions.ARB_point_sprite) {
TEST_AND_UPDATE(ctx->Multisample.SampleCoverageInvert,
enable->SampleCoverageInvert,
GL_SAMPLE_COVERAGE_INVERT_ARB);
- /* GL_NV_vertex_program */
+ /* GL_ARB_vertex_program, GL_NV_vertex_program */
TEST_AND_UPDATE(ctx->VertexProgram.Enabled,
enable->VertexProgram,
- GL_VERTEX_PROGRAM_NV);
+ GL_VERTEX_PROGRAM_ARB);
TEST_AND_UPDATE(ctx->VertexProgram.PointSizeEnabled,
enable->VertexProgramPointSize,
- GL_VERTEX_PROGRAM_POINT_SIZE_NV);
+ GL_VERTEX_PROGRAM_POINT_SIZE_ARB);
TEST_AND_UPDATE(ctx->VertexProgram.TwoSideEnabled,
enable->VertexProgramTwoSide,
- GL_VERTEX_PROGRAM_TWO_SIDE_NV);
+ GL_VERTEX_PROGRAM_TWO_SIDE_ARB);
#undef TEST_AND_UPDATE
target = GL_TEXTURE_RECTANGLE_NV;
obj = &unit->SavedRect;
break;
+ case 5:
+ if (!ctx->Extensions.MESA_texture_array)
+ continue;
+ target = GL_TEXTURE_1D_ARRAY_EXT;
+ obj = &unit->Saved1DArray;
+ break;
+ case 6:
+ if (!ctx->Extensions.MESA_texture_array)
+ continue;
+ target = GL_TEXTURE_2D_ARRAY_EXT;
+ obj = &unit->Saved2DArray;
+ break;
default:
; /* silence warnings */
}
_mesa_TexParameterf(target, GL_TEXTURE_MIN_LOD, obj->MinLod);
_mesa_TexParameterf(target, GL_TEXTURE_MAX_LOD, obj->MaxLod);
_mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, obj->BaseLevel);
- _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, obj->MaxLevel);
+ if (target != GL_TEXTURE_RECTANGLE_ARB)
+ _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, obj->MaxLevel);
if (ctx->Extensions.EXT_texture_filter_anisotropic) {
_mesa_TexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT,
obj->MaxAnisotropy);
(GLboolean) (color->ColorMask[1] != 0),
(GLboolean) (color->ColorMask[2] != 0),
(GLboolean) (color->ColorMask[3] != 0));
- _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers,
- color->DrawBuffer, NULL);
+ {
+ /* Need to determine if more than one color output is
+ * specified. If so, call glDrawBuffersARB, else call
+ * glDrawBuffer(). This is a subtle, but essential point
+ * since GL_FRONT (for example) is illegal for the former
+ * function, but legal for the later.
+ */
+ GLboolean multipleBuffers = GL_FALSE;
+ if (ctx->Extensions.ARB_draw_buffers) {
+ GLuint i;
+ for (i = 1; i < ctx->Const.MaxDrawBuffers; i++) {
+ if (color->DrawBuffer[i] != GL_NONE) {
+ multipleBuffers = GL_TRUE;
+ break;
+ }
+ }
+ }
+ /* Call the API_level functions, not _mesa_drawbuffers()
+ * since we need to do error checking on the pop'd
+ * GL_DRAW_BUFFER.
+ * Ex: if GL_FRONT were pushed, but we're popping with a
+ * user FBO bound, GL_FRONT will be illegal and we'll need
+ * to record that error. Per OpenGL ARB decision.
+ */
+ if (multipleBuffers)
+ _mesa_DrawBuffersARB(ctx->Const.MaxDrawBuffers,
+ color->DrawBuffer);
+ else
+ _mesa_DrawBuffer(color->DrawBuffer[0]);
+ }
_mesa_set_enable(ctx, GL_ALPHA_TEST, color->AlphaEnabled);
_mesa_AlphaFunc(color->AlphaFunc, color->AlphaRef);
_mesa_set_enable(ctx, GL_BLEND, color->BlendEnabled);
(GLfloat) light->Model.TwoSide);
_mesa_LightModelf(GL_LIGHT_MODEL_COLOR_CONTROL,
(GLfloat) light->Model.ColorControl);
- /* materials */
- MEMCPY(&ctx->Light.Material, &light->Material,
- sizeof(struct gl_material));
/* shade model */
_mesa_ShadeModel(light->ShadeModel);
/* color material */
light->ColorMaterialMode);
_mesa_set_enable(ctx, GL_COLOR_MATERIAL,
light->ColorMaterialEnabled);
+ /* materials */
+ MEMCPY(&ctx->Light.Material, &light->Material,
+ sizeof(struct gl_material));
}
break;
case GL_LINE_BIT:
adjust_buffer_object_ref_counts(struct gl_array_attrib *array, GLint step)
{
GLuint i;
- array->Vertex.BufferObj->RefCount += step;
- array->Normal.BufferObj->RefCount += step;
- array->Color.BufferObj->RefCount += step;
- array->SecondaryColor.BufferObj->RefCount += step;
- array->FogCoord.BufferObj->RefCount += step;
- array->Index.BufferObj->RefCount += step;
- array->EdgeFlag.BufferObj->RefCount += step;
+ array->ArrayObj->Vertex.BufferObj->RefCount += step;
+ array->ArrayObj->Normal.BufferObj->RefCount += step;
+ array->ArrayObj->Color.BufferObj->RefCount += step;
+ array->ArrayObj->SecondaryColor.BufferObj->RefCount += step;
+ array->ArrayObj->FogCoord.BufferObj->RefCount += step;
+ array->ArrayObj->Index.BufferObj->RefCount += step;
+ array->ArrayObj->EdgeFlag.BufferObj->RefCount += step;
for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++)
- array->TexCoord[i].BufferObj->RefCount += step;
+ array->ArrayObj->TexCoord[i].BufferObj->RefCount += step;
for (i = 0; i < VERT_ATTRIB_MAX; i++)
- array->VertexAttrib[i].BufferObj->RefCount += step;
+ array->ArrayObj->VertexAttrib[i].BufferObj->RefCount += step;
array->ArrayBufferObj->RefCount += step;
array->ElementArrayBufferObj->RefCount += step;
}
if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
struct gl_array_attrib *attr;
+ struct gl_array_object *obj;
+
attr = MALLOC_STRUCT( gl_array_attrib );
+ obj = MALLOC_STRUCT( gl_array_object );
+
+#if FEATURE_ARB_vertex_buffer_object
+ /* increment ref counts since we're copying pointers to these objects */
+ ctx->Array.ArrayBufferObj->RefCount++;
+ ctx->Array.ElementArrayBufferObj->RefCount++;
+#endif
+
MEMCPY( attr, &ctx->Array, sizeof(struct gl_array_attrib) );
+ MEMCPY( obj, ctx->Array.ArrayObj, sizeof(struct gl_array_object) );
+
+ attr->ArrayObj = obj;
+
newnode = new_attrib_node( GL_CLIENT_VERTEX_ARRAY_BIT );
newnode->data = attr;
newnode->next = head;
sizeof(struct gl_pixelstore_attrib) );
ctx->NewState |= _NEW_PACKUNPACK;
break;
- case GL_CLIENT_VERTEX_ARRAY_BIT:
+ case GL_CLIENT_VERTEX_ARRAY_BIT: {
+ struct gl_array_attrib * data =
+ (struct gl_array_attrib *) attr->data;
+
adjust_buffer_object_ref_counts(&ctx->Array, -1);
- MEMCPY( &ctx->Array, attr->data,
- sizeof(struct gl_array_attrib) );
- /* decrement reference counts on buffer objects */
+
+ ctx->Array.ActiveTexture = data->ActiveTexture;
+ ctx->Array.LockFirst = data->LockFirst;
+ ctx->Array.LockCount = data->LockCount;
+
+ _mesa_BindVertexArrayAPPLE( data->ArrayObj->Name );
+
+#if FEATURE_ARB_vertex_buffer_object
+ _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB,
+ data->ArrayBufferObj->Name);
+ _mesa_BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB,
+ data->ElementArrayBufferObj->Name);
+#endif
+
+ MEMCPY( ctx->Array.ArrayObj, data->ArrayObj,
+ sizeof( struct gl_array_object ) );
+
+ FREE( data->ArrayObj );
+
+ /* FIXME: Should some bits in ctx->Array->NewState also be set
+ * FIXME: here? It seems like it should be set to inclusive-or
+ * FIXME: of the old ArrayObj->_Enabled and the new _Enabled.
+ */
+
ctx->NewState |= _NEW_ARRAY;
break;
+ }
default:
_mesa_problem( ctx, "Bad attrib flag in PopClientAttrib");
break;