void meta_restore_texcoords(struct dri_metaops *meta) { GLcontext *ctx = meta->ctx; /* Restore the old TexCoordPointer */ if (meta->saved_texcoord_vbo) { _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, meta->saved_texcoord_vbo->Name); _mesa_reference_buffer_object(ctx, &meta->saved_texcoord_vbo, NULL); } else { _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, 0); } _mesa_TexCoordPointer(meta->saved_texcoord_size, meta->saved_texcoord_type, meta->saved_texcoord_stride, meta->saved_texcoord_ptr); if (!meta->saved_texcoord_enable) _mesa_Disable(GL_TEXTURE_COORD_ARRAY); _mesa_ClientActiveTextureARB(GL_TEXTURE0 + meta->saved_active_texture); if (meta->saved_array_vbo) { _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, meta->saved_array_vbo->Name); _mesa_reference_buffer_object(ctx, &meta->saved_array_vbo, NULL); } else { _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, 0); } }
void GLAPIENTRY _mesa_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *ptr) { (void) count; _mesa_TexCoordPointer(size, type, stride, ptr); }
void meta_set_default_texrect(struct dri_metaops *meta) { GLcontext *ctx = meta->ctx; struct gl_client_array *old_texcoord_array; meta->saved_active_texture = ctx->Texture.CurrentUnit; if (meta->saved_array_vbo == NULL) { _mesa_reference_buffer_object(ctx, &meta->saved_array_vbo, ctx->Array.ArrayBufferObj); } old_texcoord_array = &ctx->Array.ArrayObj->TexCoord[0]; meta->saved_texcoord_type = old_texcoord_array->Type; meta->saved_texcoord_size = old_texcoord_array->Size; meta->saved_texcoord_stride = old_texcoord_array->Stride; meta->saved_texcoord_enable = old_texcoord_array->Enabled; meta->saved_texcoord_ptr = old_texcoord_array->Ptr; _mesa_reference_buffer_object(ctx, &meta->saved_texcoord_vbo, old_texcoord_array->BufferObj); _mesa_ClientActiveTextureARB(GL_TEXTURE0); if (meta->texcoord_vbo == NULL) { GLuint vbo_name; _mesa_GenBuffersARB(1, &vbo_name); _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, vbo_name); _mesa_BufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(default_texcoords), default_texcoords, GL_STATIC_DRAW_ARB); _mesa_reference_buffer_object(ctx, &meta->texcoord_vbo, ctx->Array.ArrayBufferObj); } else { _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, meta->texcoord_vbo->Name); } _mesa_TexCoordPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), NULL); _mesa_Enable(GL_TEXTURE_COORD_ARRAY); }
void GLAPIENTRY _mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer) { GET_CURRENT_CONTEXT(ctx); GLboolean tflag, cflag, nflag; /* enable/disable flags */ GLint tcomps, ccomps, vcomps; /* components per texcoord, color, vertex */ GLenum ctype = 0; /* color type */ GLint coffset = 0, noffset = 0, voffset;/* color, normal, vertex offsets */ const GLint toffset = 0; /* always zero */ GLint defstride; /* default stride */ GLint c, f; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); f = sizeof(GLfloat); c = f * ((4 * sizeof(GLubyte) + (f - 1)) / f); if (stride < 0) { _mesa_error( ctx, GL_INVALID_VALUE, "glInterleavedArrays(stride)" ); return; } switch (format) { case GL_V2F: tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE; tcomps = 0; ccomps = 0; vcomps = 2; voffset = 0; defstride = 2*f; break; case GL_V3F: tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE; tcomps = 0; ccomps = 0; vcomps = 3; voffset = 0; defstride = 3*f; break; case GL_C4UB_V2F: tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE; tcomps = 0; ccomps = 4; vcomps = 2; ctype = GL_UNSIGNED_BYTE; coffset = 0; voffset = c; defstride = c + 2*f; break; case GL_C4UB_V3F: tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE; tcomps = 0; ccomps = 4; vcomps = 3; ctype = GL_UNSIGNED_BYTE; coffset = 0; voffset = c; defstride = c + 3*f; break; case GL_C3F_V3F: tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE; tcomps = 0; ccomps = 3; vcomps = 3; ctype = GL_FLOAT; coffset = 0; voffset = 3*f; defstride = 6*f; break; case GL_N3F_V3F: tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_TRUE; tcomps = 0; ccomps = 0; vcomps = 3; noffset = 0; voffset = 3*f; defstride = 6*f; break; case GL_C4F_N3F_V3F: tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_TRUE; tcomps = 0; ccomps = 4; vcomps = 3; ctype = GL_FLOAT; coffset = 0; noffset = 4*f; voffset = 7*f; defstride = 10*f; break; case GL_T2F_V3F: tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE; tcomps = 2; ccomps = 0; vcomps = 3; voffset = 2*f; defstride = 5*f; break; case GL_T4F_V4F: tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE; tcomps = 4; ccomps = 0; vcomps = 4; voffset = 4*f; defstride = 8*f; break; case GL_T2F_C4UB_V3F: tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE; tcomps = 2; ccomps = 4; vcomps = 3; ctype = GL_UNSIGNED_BYTE; coffset = 2*f; voffset = c+2*f; defstride = c+5*f; break; case GL_T2F_C3F_V3F: tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE; tcomps = 2; ccomps = 3; vcomps = 3; ctype = GL_FLOAT; coffset = 2*f; voffset = 5*f; defstride = 8*f; break; case GL_T2F_N3F_V3F: tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_TRUE; tcomps = 2; ccomps = 0; vcomps = 3; noffset = 2*f; voffset = 5*f; defstride = 8*f; break; case GL_T2F_C4F_N3F_V3F: tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE; tcomps = 2; ccomps = 4; vcomps = 3; ctype = GL_FLOAT; coffset = 2*f; noffset = 6*f; voffset = 9*f; defstride = 12*f; break; case GL_T4F_C4F_N3F_V4F: tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE; tcomps = 4; ccomps = 4; vcomps = 4; ctype = GL_FLOAT; coffset = 4*f; noffset = 8*f; voffset = 11*f; defstride = 15*f; break; default: _mesa_error( ctx, GL_INVALID_ENUM, "glInterleavedArrays(format)" ); return; } if (stride==0) { stride = defstride; } _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY ); _mesa_DisableClientState( GL_INDEX_ARRAY ); /* XXX also disable secondary color and generic arrays? */ /* Texcoords */ if (tflag) { _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY ); _mesa_TexCoordPointer( tcomps, GL_FLOAT, stride, (GLubyte *) pointer + toffset ); } else { _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY ); } /* Color */ if (cflag) { _mesa_EnableClientState( GL_COLOR_ARRAY ); _mesa_ColorPointer( ccomps, ctype, stride, (GLubyte *) pointer + coffset ); } else { _mesa_DisableClientState( GL_COLOR_ARRAY ); } /* Normals */ if (nflag) { _mesa_EnableClientState( GL_NORMAL_ARRAY ); _mesa_NormalPointer( GL_FLOAT, stride, (GLubyte *) pointer + noffset ); } else { _mesa_DisableClientState( GL_NORMAL_ARRAY ); } /* Vertices */ _mesa_EnableClientState( GL_VERTEX_ARRAY ); _mesa_VertexPointer( vcomps, GL_FLOAT, stride, (GLubyte *) pointer + voffset ); }