From 86fc370d399167ec9bb978d053d4a72215c86c16 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 22 May 2000 16:33:20 +0000 Subject: initial code for GL_ARB_texture_cube_map --- src/mesa/main/teximage.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'src/mesa/main/teximage.c') diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index ae50558bf26..2f3c0f12c80 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -385,6 +385,38 @@ set_teximage_component_sizes( struct gl_texture_image *texImage ) } +/* + * Given a texture unit and a texture target, return the corresponding + * texture object. + */ +static struct gl_texture_object * +select_tex_object(struct gl_texture_unit *unit, GLenum target) +{ + switch (target) { + case GL_TEXTURE_1D: + return unit->CurrentD[1]; + case GL_TEXTURE_2D: + return unit->CurrentD[2]; + case GL_TEXTURE_3D: + return unit->CurrentD[3]; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: + return unit->CurrentPosX; + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: + return unit->CurrentNegX; + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: + return unit->CurrentPosY; + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: + return unit->CurrentNegY; + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: + return unit->CurrentPosZ; + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: + return unit->CurrentNegZ; + default: + gl_problem(NULL, "bad target in select_tex_object()"); + return NULL; + } +} + /* * Return new gl_texture_image struct with all fields initialized to zero. @@ -1189,7 +1221,7 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat, } texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - texObj = texUnit->CurrentD[2]; + texObj = select_tex_object(texUnit, target); texImage = texObj->Image[level]; if (!texImage) { @@ -1756,7 +1788,7 @@ _mesa_TexSubImage2D( GLenum target, GLint level, } texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - texObj = texUnit->CurrentD[2]; + texObj = select_tex_object(texUnit, target); texImage = texObj->Image[level]; assert(texImage); -- cgit v1.2.3