📄 ac_import.c
字号:
ac->IsCached.EdgeFlag = GL_TRUE;}static voidimport_attrib( GLcontext *ctx, GLuint index, GLenum type, GLuint stride ){ ACcontext *ac = AC_CONTEXT(ctx); const struct gl_client_array *from = &ac->Raw.Attrib[index]; struct gl_client_array *to = &ac->Cache.Attrib[index]; (void) type; (void) stride; ASSERT(index < MAX_VERTEX_PROGRAM_ATTRIBS); /* Limited choices at this stage: */ ASSERT(type == GL_FLOAT); ASSERT(stride == 4*sizeof(GLfloat) || stride == 0); ASSERT(ac->count - ac->start < ctx->Const.MaxArrayLockSize); _math_trans_4f( (GLfloat (*)[4]) to->Ptr, from->Ptr, from->StrideB, from->Type, from->Size, 0, ac->count - ac->start); to->Size = from->Size; to->StrideB = 4 * sizeof(GLfloat); to->Type = GL_FLOAT; ac->IsCached.Attrib[index] = GL_TRUE;}/* * Externals to request arrays with specific properties: */struct gl_client_array *_ac_import_texcoord( GLcontext *ctx, GLuint unit, GLenum type, GLuint reqstride, GLuint reqsize, GLboolean reqwriteable, GLboolean *writeable ){ ACcontext *ac = AC_CONTEXT(ctx); ASSERT(unit < MAX_TEXTURE_COORD_UNITS); /* Can we keep the existing version? */ if (ac->NewArrayState & _NEW_ARRAY_TEXCOORD(unit)) reset_texcoord( ctx, unit ); /* Is the request impossible? */ if (reqsize != 0 && ac->Raw.TexCoord[unit].Size > (GLint) reqsize) return NULL; /* Do we need to pull in a copy of the client data: */ if (ac->Raw.TexCoord[unit].Type != type || (reqstride != 0 && ac->Raw.TexCoord[unit].StrideB != (GLint)reqstride) || reqwriteable) { if (!ac->IsCached.TexCoord[unit]) import_texcoord(ctx, unit, type, reqstride ); *writeable = GL_TRUE; return &ac->Cache.TexCoord[unit]; } else { *writeable = GL_FALSE; return &ac->Raw.TexCoord[unit]; }}struct gl_client_array *_ac_import_vertex( GLcontext *ctx, GLenum type, GLuint reqstride, GLuint reqsize, GLboolean reqwriteable, GLboolean *writeable ){ ACcontext *ac = AC_CONTEXT(ctx); /* Can we keep the existing version? */ if (ac->NewArrayState & _NEW_ARRAY_VERTEX) reset_vertex( ctx ); /* Is the request impossible? */ if (reqsize != 0 && ac->Raw.Vertex.Size > (GLint) reqsize) return NULL; /* Do we need to pull in a copy of the client data: */ if (ac->Raw.Vertex.Type != type || (reqstride != 0 && ac->Raw.Vertex.StrideB != (GLint) reqstride) || reqwriteable) { if (!ac->IsCached.Vertex) import_vertex(ctx, type, reqstride ); *writeable = GL_TRUE; return &ac->Cache.Vertex; } else { *writeable = GL_FALSE; return &ac->Raw.Vertex; }}struct gl_client_array *_ac_import_normal( GLcontext *ctx, GLenum type, GLuint reqstride, GLboolean reqwriteable, GLboolean *writeable ){ ACcontext *ac = AC_CONTEXT(ctx); /* Can we keep the existing version? */ if (ac->NewArrayState & _NEW_ARRAY_NORMAL) reset_normal( ctx ); /* Do we need to pull in a copy of the client data: */ if (ac->Raw.Normal.Type != type || (reqstride != 0 && ac->Raw.Normal.StrideB != (GLint) reqstride) || reqwriteable) { if (!ac->IsCached.Normal) import_normal(ctx, type, reqstride ); *writeable = GL_TRUE; return &ac->Cache.Normal; } else { *writeable = GL_FALSE; return &ac->Raw.Normal; }}struct gl_client_array *_ac_import_color( GLcontext *ctx, GLenum type, GLuint reqstride, GLuint reqsize, GLboolean reqwriteable, GLboolean *writeable ){ ACcontext *ac = AC_CONTEXT(ctx); /* Can we keep the existing version? */ if (ac->NewArrayState & _NEW_ARRAY_COLOR0) reset_color( ctx ); /* Is the request impossible? */ if (reqsize != 0 && ac->Raw.Color.Size > (GLint) reqsize) { return NULL; } /* Do we need to pull in a copy of the client data: */ if ((type != 0 && ac->Raw.Color.Type != type) || (reqstride != 0 && ac->Raw.Color.StrideB != (GLint) reqstride) || reqwriteable) { if (!ac->IsCached.Color) { import_color(ctx, type, reqstride ); } *writeable = GL_TRUE; return &ac->Cache.Color; } else { *writeable = GL_FALSE; return &ac->Raw.Color; }}struct gl_client_array *_ac_import_index( GLcontext *ctx, GLenum type, GLuint reqstride, GLboolean reqwriteable, GLboolean *writeable ){ ACcontext *ac = AC_CONTEXT(ctx); /* Can we keep the existing version? */ if (ac->NewArrayState & _NEW_ARRAY_INDEX) reset_index( ctx ); /* Do we need to pull in a copy of the client data: */ if (ac->Raw.Index.Type != type || (reqstride != 0 && ac->Raw.Index.StrideB != (GLint) reqstride) || reqwriteable) { if (!ac->IsCached.Index) import_index(ctx, type, reqstride ); *writeable = GL_TRUE; return &ac->Cache.Index; } else { *writeable = GL_FALSE; return &ac->Raw.Index; }}struct gl_client_array *_ac_import_secondarycolor( GLcontext *ctx, GLenum type, GLuint reqstride, GLuint reqsize, GLboolean reqwriteable, GLboolean *writeable ){ ACcontext *ac = AC_CONTEXT(ctx); /* Can we keep the existing version? */ if (ac->NewArrayState & _NEW_ARRAY_COLOR1) reset_secondarycolor( ctx ); /* Is the request impossible? */ if (reqsize != 0 && ac->Raw.SecondaryColor.Size > (GLint) reqsize) return NULL; /* Do we need to pull in a copy of the client data: */ if ((type != 0 && ac->Raw.SecondaryColor.Type != type) || (reqstride != 0 && ac->Raw.SecondaryColor.StrideB != (GLint)reqstride) || reqwriteable) { if (!ac->IsCached.SecondaryColor) import_secondarycolor(ctx, type, reqstride ); *writeable = GL_TRUE; return &ac->Cache.SecondaryColor; } else { *writeable = GL_FALSE; return &ac->Raw.SecondaryColor; }}struct gl_client_array *_ac_import_fogcoord( GLcontext *ctx, GLenum type, GLuint reqstride, GLboolean reqwriteable, GLboolean *writeable ){ ACcontext *ac = AC_CONTEXT(ctx); /* Can we keep the existing version? */ if (ac->NewArrayState & _NEW_ARRAY_FOGCOORD) reset_fogcoord( ctx ); /* Do we need to pull in a copy of the client data: */ if (ac->Raw.FogCoord.Type != type || (reqstride != 0 && ac->Raw.FogCoord.StrideB != (GLint) reqstride) || reqwriteable) { if (!ac->IsCached.FogCoord) import_fogcoord(ctx, type, reqstride ); *writeable = GL_TRUE; return &ac->Cache.FogCoord; } else { *writeable = GL_FALSE; return &ac->Raw.FogCoord; }}struct gl_client_array *_ac_import_edgeflag( GLcontext *ctx, GLenum type, GLuint reqstride, GLboolean reqwriteable, GLboolean *writeable ){ ACcontext *ac = AC_CONTEXT(ctx); /* Can we keep the existing version? */ if (ac->NewArrayState & _NEW_ARRAY_EDGEFLAG) reset_edgeflag( ctx ); /* Do we need to pull in a copy of the client data: */ if (ac->Raw.EdgeFlag.Type != type || (reqstride != 0 && ac->Raw.EdgeFlag.StrideB != (GLint) reqstride) || reqwriteable) { if (!ac->IsCached.EdgeFlag) import_edgeflag(ctx, type, reqstride ); *writeable = GL_TRUE; return &ac->Cache.EdgeFlag; } else { *writeable = GL_FALSE; return &ac->Raw.EdgeFlag; }}/* GL_NV_vertex_program */struct gl_client_array *_ac_import_attrib( GLcontext *ctx, GLuint index, GLenum type, GLuint reqstride, GLuint reqsize, GLboolean reqwriteable, GLboolean *writeable ){ ACcontext *ac = AC_CONTEXT(ctx); ASSERT(index < VERT_ATTRIB_MAX); /* Can we keep the existing version? */ if (ac->NewArrayState & _NEW_ARRAY_ATTRIB(index)) reset_attrib( ctx, index ); /* Is the request impossible? */ if (reqsize != 0 && ac->Raw.Attrib[index].Size > (GLint) reqsize) return NULL; /* Do we need to pull in a copy of the client data: */ if (ac->Raw.Attrib[index].Type != type || (reqstride != 0 && ac->Raw.Attrib[index].StrideB != (GLint)reqstride) || reqwriteable) { if (!ac->IsCached.Attrib[index]) import_attrib(ctx, index, type, reqstride ); *writeable = GL_TRUE; return &ac->Cache.Attrib[index]; } else { *writeable = GL_FALSE; return &ac->Raw.Attrib[index]; }}/* Clients must call this function to validate state and set bounds * before importing any data: */void_ac_import_range( GLcontext *ctx, GLuint start, GLuint count ){ ACcontext *ac = AC_CONTEXT(ctx); if (!ctx->Array.LockCount) { /* Not locked, discard cached data. Changes to lock * status are caught via. _ac_invalidate_state(). */ ac->NewArrayState = _NEW_ARRAY_ALL; ac->start = start; ac->count = count; } else { /* Locked, discard data for any disabled arrays. Require that * the whole locked range always be dealt with, otherwise hard to * maintain cached data in the face of clipping. */ ac->NewArrayState |= ~ctx->Array._Enabled; ac->start = ctx->Array.LockFirst; ac->count = ctx->Array.LockCount; ASSERT(ac->start == start); /* hmm? */ ASSERT(ac->count == count); }}/* Additional convienence function for importing the element list * for glDrawElements() and glDrawRangeElements(). */CONST void *_ac_import_elements( GLcontext *ctx, GLenum new_type, GLuint count, GLenum old_type, CONST void *indices ){ ACcontext *ac = AC_CONTEXT(ctx); if (old_type == new_type) return indices; if (ac->elt_size < count * sizeof(GLuint)) { if (ac->Elts) FREE(ac->Elts); while (ac->elt_size < count * sizeof(GLuint)) ac->elt_size *= 2; ac->Elts = (GLuint *) MALLOC(ac->elt_size); } switch (new_type) { case GL_UNSIGNED_BYTE: ASSERT(0); return NULL; case GL_UNSIGNED_SHORT: ASSERT(0); return NULL; case GL_UNSIGNED_INT: { GLuint *out = (GLuint *)ac->Elts; GLuint i; switch (old_type) { case GL_UNSIGNED_BYTE: { CONST GLubyte *in = (CONST GLubyte *)indices; for (i = 0 ; i < count ; i++) out[i] = in[i]; break; } case GL_UNSIGNED_SHORT: { CONST GLushort *in = (CONST GLushort *)indices; for (i = 0 ; i < count ; i++) out[i] = in[i]; break; } default: ASSERT(0); } return (CONST void *)out; } default: ASSERT(0); break; } return NULL;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -