📄 attrib.c
字号:
if (ctx->Driver.ClipPlane) ctx->Driver.ClipPlane( ctx, GL_CLIP_PLANE0 + i, eyePlane ); } /* normalize/rescale */ if (xform->Normalize != ctx->Transform.Normalize) _mesa_set_enable(ctx, GL_NORMALIZE,ctx->Transform.Normalize); if (xform->RescaleNormals != ctx->Transform.RescaleNormals) _mesa_set_enable(ctx, GL_RESCALE_NORMAL_EXT, ctx->Transform.RescaleNormals); } break; case GL_TEXTURE_BIT: /* Take care of texture object reference counters */ { struct texture_state *texstate = (struct texture_state *) attr->data; pop_texture_group(ctx, texstate); ctx->NewState |= _NEW_TEXTURE; } break; case GL_VIEWPORT_BIT: { const struct gl_viewport_attrib *vp; vp = (const struct gl_viewport_attrib *) attr->data; _mesa_Viewport(vp->X, vp->Y, vp->Width, vp->Height); _mesa_DepthRange(vp->Near, vp->Far); } break; case GL_MULTISAMPLE_BIT_ARB: { const struct gl_multisample_attrib *ms; ms = (const struct gl_multisample_attrib *) attr->data; _mesa_SampleCoverageARB(ms->SampleCoverageValue, ms->SampleCoverageInvert); } break; default: _mesa_problem( ctx, "Bad attrib flag in PopAttrib"); break; } next = attr->next; FREE( attr->data ); FREE( attr ); attr = next; }}/** * Helper for incrementing/decrementing vertex buffer object reference * counts when pushing/popping the GL_CLIENT_VERTEX_ARRAY_BIT attribute group. */static voidadjust_buffer_object_ref_counts(struct gl_array_attrib *array, GLint step){ GLuint i; 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->ArrayObj->TexCoord[i].BufferObj->RefCount += step; for (i = 0; i < VERT_ATTRIB_MAX; i++) array->ArrayObj->VertexAttrib[i].BufferObj->RefCount += step; array->ArrayBufferObj->RefCount += step; array->ElementArrayBufferObj->RefCount += step;}/** * Copy gl_pixelstore_attrib from src to dst, updating buffer * object refcounts. */static voidcopy_pixelstore(GLcontext *ctx, struct gl_pixelstore_attrib *dst, const struct gl_pixelstore_attrib *src){ dst->Alignment = src->Alignment; dst->RowLength = src->RowLength; dst->SkipPixels = src->SkipPixels; dst->SkipRows = src->SkipRows; dst->ImageHeight = src->ImageHeight; dst->SkipImages = src->SkipImages; dst->SwapBytes = src->SwapBytes; dst->LsbFirst = src->LsbFirst; dst->ClientStorage = src->ClientStorage; dst->Invert = src->Invert; _mesa_reference_buffer_object(ctx, &dst->BufferObj, src->BufferObj);}#define GL_CLIENT_PACK_BIT (1<<20)#define GL_CLIENT_UNPACK_BIT (1<<21)void GLAPIENTRY_mesa_PushClientAttrib(GLbitfield mask){ struct gl_attrib_node *newnode; struct gl_attrib_node *head; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); if (ctx->ClientAttribStackDepth >= MAX_CLIENT_ATTRIB_STACK_DEPTH) { _mesa_error( ctx, GL_STACK_OVERFLOW, "glPushClientAttrib" ); return; } /* Build linked list of attribute nodes which save all attribute * groups specified by the mask. */ head = NULL; if (mask & GL_CLIENT_PIXEL_STORE_BIT) { struct gl_pixelstore_attrib *attr; /* packing attribs */ attr = CALLOC_STRUCT( gl_pixelstore_attrib ); copy_pixelstore(ctx, attr, &ctx->Pack); newnode = new_attrib_node( GL_CLIENT_PACK_BIT ); newnode->data = attr; newnode->next = head; head = newnode; /* unpacking attribs */ attr = CALLOC_STRUCT( gl_pixelstore_attrib ); copy_pixelstore(ctx, attr, &ctx->Unpack); newnode = new_attrib_node( GL_CLIENT_UNPACK_BIT ); newnode->data = attr; newnode->next = head; head = newnode; } 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; head = newnode; /* bump reference counts on buffer objects */ adjust_buffer_object_ref_counts(&ctx->Array, 1); } ctx->ClientAttribStack[ctx->ClientAttribStackDepth] = head; ctx->ClientAttribStackDepth++;}void GLAPIENTRY_mesa_PopClientAttrib(void){ struct gl_attrib_node *node, *next; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); if (ctx->ClientAttribStackDepth == 0) { _mesa_error( ctx, GL_STACK_UNDERFLOW, "glPopClientAttrib" ); return; } ctx->ClientAttribStackDepth--; node = ctx->ClientAttribStack[ctx->ClientAttribStackDepth]; while (node) { switch (node->kind) { case GL_CLIENT_PACK_BIT: { struct gl_pixelstore_attrib *store = (struct gl_pixelstore_attrib *) node->data; copy_pixelstore(ctx, &ctx->Pack, store); _mesa_reference_buffer_object(ctx, &store->BufferObj, NULL); } ctx->NewState |= _NEW_PACKUNPACK; break; case GL_CLIENT_UNPACK_BIT: { struct gl_pixelstore_attrib *store = (struct gl_pixelstore_attrib *) node->data; copy_pixelstore(ctx, &ctx->Unpack, store); _mesa_reference_buffer_object(ctx, &store->BufferObj, NULL); } ctx->NewState |= _NEW_PACKUNPACK; break; case GL_CLIENT_VERTEX_ARRAY_BIT: { struct gl_array_attrib * data = (struct gl_array_attrib *) node->data; adjust_buffer_object_ref_counts(&ctx->Array, -1); ctx->Array.ActiveTexture = data->ActiveTexture; if (data->LockCount != 0) _mesa_LockArraysEXT(data->LockFirst, data->LockCount); else if (ctx->Array.LockCount) _mesa_UnlockArraysEXT(); _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; } next = node->next; FREE( node->data ); FREE( node ); node = next; }}/** * Free any attribute state data that might be attached to the context. */void_mesa_free_attrib_data(GLcontext *ctx){ while (ctx->AttribStackDepth > 0) { struct gl_attrib_node *attr, *next; ctx->AttribStackDepth--; attr = ctx->AttribStack[ctx->AttribStackDepth]; while (attr) { if (attr->kind == GL_TEXTURE_BIT) { struct texture_state *texstate = (struct texture_state*)attr->data; GLuint u, tgt; /* clear references to the saved texture objects */ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { _mesa_reference_texobj(&texstate->SavedTexRef[u][tgt], NULL); } } } else { /* any other chunks of state that requires special handling? */ } next = attr->next; _mesa_free(attr->data); _mesa_free(attr); attr = next; } }}void _mesa_init_attrib( GLcontext *ctx ){ /* Renderer and client attribute stacks */ ctx->AttribStackDepth = 0; ctx->ClientAttribStackDepth = 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -