more work on GL_ARB_texture_cube_map
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: enable.c,v 1.20 2000/05/22 16:33:21 brianp Exp $ */
|
/* $Id: enable.c,v 1.21 2000/05/23 15:17:12 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -508,23 +508,30 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
|
|||||||
|
|
||||||
/* GL_ARB_texture_cube_map */
|
/* GL_ARB_texture_cube_map */
|
||||||
case GL_TEXTURE_CUBE_MAP_ARB:
|
case GL_TEXTURE_CUBE_MAP_ARB:
|
||||||
#if 0
|
if (ctx->Extensions.HaveTextureCubeMap) {
|
||||||
if (ctx->Visual->RGBAflag) {
|
if (ctx->Visual->RGBAflag) {
|
||||||
const GLuint curr = ctx->Texture.CurrentUnit;
|
const GLuint curr = ctx->Texture.CurrentUnit;
|
||||||
const GLuint flag = TEXTURE0_CUBE << (curr * 4);
|
const GLuint flag = TEXTURE0_CUBE << (curr * 4);
|
||||||
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
|
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
|
||||||
ctx->NewState |= NEW_TEXTURE_ENABLE;
|
ctx->NewState |= NEW_TEXTURE_ENABLE;
|
||||||
if (state) {
|
if (state) {
|
||||||
texUnit->Enabled |= TEXTURE0_2D;
|
texUnit->Enabled |= TEXTURE0_CUBE;
|
||||||
ctx->Enabled |= flag;
|
ctx->Enabled |= flag;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
texUnit->Enabled &= ~TEXTURE0_2D;
|
texUnit->Enabled &= ~TEXTURE0_CUBE;
|
||||||
ctx->Enabled &= ~flag;
|
ctx->Enabled &= ~flag;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if (state)
|
||||||
|
gl_error(ctx, GL_INVALID_ENUM, "glEnable");
|
||||||
|
else
|
||||||
|
gl_error(ctx, GL_INVALID_ENUM, "glDisable");
|
||||||
|
return;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (state) {
|
if (state) {
|
||||||
@@ -760,23 +767,14 @@ _mesa_IsEnabled( GLenum cap )
|
|||||||
|
|
||||||
/* GL_ARB_texture_cube_map */
|
/* GL_ARB_texture_cube_map */
|
||||||
case GL_TEXTURE_CUBE_MAP_ARB:
|
case GL_TEXTURE_CUBE_MAP_ARB:
|
||||||
#if 0
|
if (ctx->Extensions.HaveTextureCubeMap) {
|
||||||
if (ctx->Visual->RGBAflag) {
|
const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
|
||||||
const GLuint curr = ctx->Texture.CurrentUnit;
|
return (texUnit->Enabled & TEXTURE0_CUBE) ? GL_TRUE : GL_FALSE;
|
||||||
const GLuint flag = TEXTURE0_CUBE << (curr * 4);
|
}
|
||||||
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
|
else {
|
||||||
ctx->NewState |= NEW_TEXTURE_ENABLE;
|
gl_error(ctx, GL_INVALID_ENUM, "glIsEnabled");
|
||||||
if (state) {
|
return GL_FALSE;
|
||||||
texUnit->Enabled |= TEXTURE0_2D;
|
|
||||||
ctx->Enabled |= flag;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
texUnit->Enabled &= ~TEXTURE0_2D;
|
|
||||||
ctx->Enabled &= ~flag;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" );
|
gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" );
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: get.c,v 1.26 2000/05/22 16:33:21 brianp Exp $ */
|
/* $Id: get.c,v 1.27 2000/05/23 15:17:13 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -963,7 +963,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
|
|||||||
return;
|
return;
|
||||||
case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
|
case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
|
||||||
if (ctx->Extensions.HaveTextureCubeMap)
|
if (ctx->Extensions.HaveTextureCubeMap)
|
||||||
*params = INT_TO_BOOL(textureUnit->CurrentPosX->Name);
|
*params = INT_TO_BOOL(textureUnit->CurrentCubeMap->Name);
|
||||||
else
|
else
|
||||||
gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
|
gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
|
||||||
return;
|
return;
|
||||||
@@ -2077,19 +2077,19 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params )
|
|||||||
if (ctx->Extensions.HaveTextureCubeMap)
|
if (ctx->Extensions.HaveTextureCubeMap)
|
||||||
*params = (GLdouble) _mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB);
|
*params = (GLdouble) _mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB);
|
||||||
else
|
else
|
||||||
gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
|
gl_error(ctx, GL_INVALID_ENUM, "glGetDoublev");
|
||||||
return;
|
return;
|
||||||
case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
|
case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
|
||||||
if (ctx->Extensions.HaveTextureCubeMap)
|
if (ctx->Extensions.HaveTextureCubeMap)
|
||||||
*params = (GLdouble) textureUnit->CurrentPosX->Name;
|
*params = (GLdouble) textureUnit->CurrentCubeMap->Name;
|
||||||
else
|
else
|
||||||
gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
|
gl_error(ctx, GL_INVALID_ENUM, "glGetDoublev");
|
||||||
return;
|
return;
|
||||||
case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB:
|
case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB:
|
||||||
if (ctx->Extensions.HaveTextureCubeMap)
|
if (ctx->Extensions.HaveTextureCubeMap)
|
||||||
*params = (GLdouble) ctx->Const.MaxCubeTextureSize;
|
*params = (GLdouble) ctx->Const.MaxCubeTextureSize;
|
||||||
else
|
else
|
||||||
gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
|
gl_error(ctx, GL_INVALID_ENUM, "glGetDoublev");
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* GL_PGI_misc_hints */
|
/* GL_PGI_misc_hints */
|
||||||
@@ -3194,19 +3194,19 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
|
|||||||
if (ctx->Extensions.HaveTextureCubeMap)
|
if (ctx->Extensions.HaveTextureCubeMap)
|
||||||
*params = (GLfloat) _mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB);
|
*params = (GLfloat) _mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB);
|
||||||
else
|
else
|
||||||
gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
|
gl_error(ctx, GL_INVALID_ENUM, "glGetFloatv");
|
||||||
return;
|
return;
|
||||||
case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
|
case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
|
||||||
if (ctx->Extensions.HaveTextureCubeMap)
|
if (ctx->Extensions.HaveTextureCubeMap)
|
||||||
*params = (GLfloat) textureUnit->CurrentPosX->Name;
|
*params = (GLfloat) textureUnit->CurrentCubeMap->Name;
|
||||||
else
|
else
|
||||||
gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
|
gl_error(ctx, GL_INVALID_ENUM, "glGetFloatv");
|
||||||
return;
|
return;
|
||||||
case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB:
|
case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB:
|
||||||
if (ctx->Extensions.HaveTextureCubeMap)
|
if (ctx->Extensions.HaveTextureCubeMap)
|
||||||
*params = (GLfloat) ctx->Const.MaxCubeTextureSize;
|
*params = (GLfloat) ctx->Const.MaxCubeTextureSize;
|
||||||
else
|
else
|
||||||
gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
|
gl_error(ctx, GL_INVALID_ENUM, "glGetFloatv");
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* GL_PGI_misc_hints */
|
/* GL_PGI_misc_hints */
|
||||||
@@ -4285,19 +4285,19 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
|
|||||||
if (ctx->Extensions.HaveTextureCubeMap)
|
if (ctx->Extensions.HaveTextureCubeMap)
|
||||||
*params = (GLint) _mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB);
|
*params = (GLint) _mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB);
|
||||||
else
|
else
|
||||||
gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
|
gl_error(ctx, GL_INVALID_ENUM, "glGetIntegerv");
|
||||||
return;
|
return;
|
||||||
case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
|
case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
|
||||||
if (ctx->Extensions.HaveTextureCubeMap)
|
if (ctx->Extensions.HaveTextureCubeMap)
|
||||||
*params = textureUnit->CurrentPosX->Name;
|
*params = textureUnit->CurrentCubeMap->Name;
|
||||||
else
|
else
|
||||||
gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
|
gl_error(ctx, GL_INVALID_ENUM, "glGetIntegerv");
|
||||||
return;
|
return;
|
||||||
case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB:
|
case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB:
|
||||||
if (ctx->Extensions.HaveTextureCubeMap)
|
if (ctx->Extensions.HaveTextureCubeMap)
|
||||||
*params = ctx->Const.MaxCubeTextureSize;
|
*params = ctx->Const.MaxCubeTextureSize;
|
||||||
else
|
else
|
||||||
gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
|
gl_error(ctx, GL_INVALID_ENUM, "glGetIntegerv");
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* GL_PGI_misc_hints */
|
/* GL_PGI_misc_hints */
|
||||||
|
@@ -400,17 +400,12 @@ select_tex_object(struct gl_texture_unit *unit, GLenum target)
|
|||||||
case GL_TEXTURE_3D:
|
case GL_TEXTURE_3D:
|
||||||
return unit->CurrentD[3];
|
return unit->CurrentD[3];
|
||||||
case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
|
case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
|
||||||
return unit->CurrentPosX;
|
|
||||||
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
|
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
|
||||||
return unit->CurrentNegX;
|
|
||||||
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
|
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
|
||||||
return unit->CurrentPosY;
|
|
||||||
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
|
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
|
||||||
return unit->CurrentNegY;
|
|
||||||
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
|
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
|
||||||
return unit->CurrentPosZ;
|
|
||||||
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
|
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
|
||||||
return unit->CurrentNegZ;
|
return unit->CurrentCubeMap;
|
||||||
default:
|
default:
|
||||||
gl_problem(NULL, "bad target in select_tex_object()");
|
gl_problem(NULL, "bad target in select_tex_object()");
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -418,6 +413,42 @@ select_tex_object(struct gl_texture_unit *unit, GLenum target)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_tex_image(struct gl_texture_object *tObj,
|
||||||
|
GLenum target, GLint level,
|
||||||
|
struct gl_texture_image *texImage)
|
||||||
|
{
|
||||||
|
ASSERT(tObj);
|
||||||
|
ASSERT(texImage);
|
||||||
|
switch (target) {
|
||||||
|
case GL_TEXTURE_2D:
|
||||||
|
tObj->Image[level] = texImage;
|
||||||
|
return;
|
||||||
|
case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
|
||||||
|
tObj->PosX[level] = texImage;
|
||||||
|
return;
|
||||||
|
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
|
||||||
|
tObj->NegX[level] = texImage;
|
||||||
|
return;
|
||||||
|
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
|
||||||
|
tObj->PosY[level] = texImage;
|
||||||
|
return;
|
||||||
|
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
|
||||||
|
tObj->NegY[level] = texImage;
|
||||||
|
return;
|
||||||
|
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
|
||||||
|
tObj->PosZ[level] = texImage;
|
||||||
|
return;
|
||||||
|
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
|
||||||
|
tObj->NegZ[level] = texImage;
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
gl_problem(NULL, "bad target in set_tex_image()");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return new gl_texture_image struct with all fields initialized to zero.
|
* Return new gl_texture_image struct with all fields initialized to zero.
|
||||||
*/
|
*/
|
||||||
@@ -475,6 +506,71 @@ _mesa_free_texture_image( struct gl_texture_image *teximage )
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the texture image struct which corresponds to target and level
|
||||||
|
* for the given texture unit.
|
||||||
|
*/
|
||||||
|
struct gl_texture_image *
|
||||||
|
_mesa_select_tex_image(GLcontext *ctx, const struct gl_texture_unit *texUnit,
|
||||||
|
GLenum target, GLint level)
|
||||||
|
{
|
||||||
|
ASSERT(texUnit);
|
||||||
|
switch (target) {
|
||||||
|
case GL_TEXTURE_1D:
|
||||||
|
return texUnit->CurrentD[1]->Image[level];
|
||||||
|
case GL_PROXY_TEXTURE_1D:
|
||||||
|
return ctx->Texture.Proxy1D->Image[level];
|
||||||
|
case GL_TEXTURE_2D:
|
||||||
|
return texUnit->CurrentD[2]->Image[level];
|
||||||
|
case GL_PROXY_TEXTURE_2D:
|
||||||
|
return ctx->Texture.Proxy2D->Image[level];
|
||||||
|
case GL_TEXTURE_3D:
|
||||||
|
return texUnit->CurrentD[3]->Image[level];
|
||||||
|
case GL_PROXY_TEXTURE_3D:
|
||||||
|
return ctx->Texture.Proxy3D->Image[level];
|
||||||
|
case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
|
||||||
|
if (ctx->Extensions.HaveTextureCubeMap)
|
||||||
|
return texUnit->CurrentCubeMap->PosX[level];
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
|
||||||
|
if (ctx->Extensions.HaveTextureCubeMap)
|
||||||
|
return texUnit->CurrentCubeMap->NegX[level];
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
|
||||||
|
if (ctx->Extensions.HaveTextureCubeMap)
|
||||||
|
return texUnit->CurrentCubeMap->PosY[level];
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
|
||||||
|
if (ctx->Extensions.HaveTextureCubeMap)
|
||||||
|
return texUnit->CurrentCubeMap->NegY[level];
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
|
||||||
|
if (ctx->Extensions.HaveTextureCubeMap)
|
||||||
|
return texUnit->CurrentCubeMap->PosZ[level];
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
|
||||||
|
if (ctx->Extensions.HaveTextureCubeMap)
|
||||||
|
return texUnit->CurrentCubeMap->NegZ[level];
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
|
||||||
|
if (ctx->Extensions.HaveTextureCubeMap)
|
||||||
|
return ctx->Texture.ProxyCubeMap->PosX[level];
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
default:
|
||||||
|
gl_problem(ctx, "bad target in _mesa_select_tex_image()");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Need this to prevent an out-of-bounds memory access when using
|
/* Need this to prevent an out-of-bounds memory access when using
|
||||||
* X86 optimized code.
|
* X86 optimized code.
|
||||||
*/
|
*/
|
||||||
@@ -830,7 +926,15 @@ subtexture_error_check( GLcontext *ctx, GLuint dimensions,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dimensions == 2) {
|
else if (dimensions == 2) {
|
||||||
if (target != GL_TEXTURE_2D) {
|
if (ctx->Extensions.HaveTextureCubeMap) {
|
||||||
|
if ((target < GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB ||
|
||||||
|
target > GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) &&
|
||||||
|
target != GL_TEXTURE_2D) {
|
||||||
|
gl_error( ctx, GL_INVALID_ENUM, "glTexSubImage2D(target)" );
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (target != GL_TEXTURE_2D) {
|
||||||
gl_error( ctx, GL_INVALID_ENUM, "glTexSubImage2D(target)" );
|
gl_error( ctx, GL_INVALID_ENUM, "glTexSubImage2D(target)" );
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
@@ -928,18 +1032,25 @@ copytexture_error_check( GLcontext *ctx, GLuint dimensions,
|
|||||||
{
|
{
|
||||||
GLint iformat;
|
GLint iformat;
|
||||||
|
|
||||||
if (target != GL_TEXTURE_1D && target != GL_TEXTURE_2D) {
|
if (dimensions == 1) {
|
||||||
gl_error( ctx, GL_INVALID_ENUM, "glCopyTexImage1/2D(target)" );
|
if (target != GL_TEXTURE_1D) {
|
||||||
return GL_TRUE;
|
gl_error( ctx, GL_INVALID_ENUM, "glCopyTexImage1D(target)" );
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else if (dimensions == 2) {
|
||||||
if (dimensions == 1 && target != GL_TEXTURE_1D) {
|
if (ctx->Extensions.HaveTextureCubeMap) {
|
||||||
gl_error( ctx, GL_INVALID_ENUM, "glCopyTexImage1D(target)" );
|
if ((target < GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB ||
|
||||||
return GL_TRUE;
|
target > GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) &&
|
||||||
}
|
target != GL_TEXTURE_2D) {
|
||||||
else if (dimensions == 2 && target != GL_TEXTURE_2D) {
|
gl_error( ctx, GL_INVALID_ENUM, "glCopyTexImage2D(target)" );
|
||||||
gl_error( ctx, GL_INVALID_ENUM, "glCopyTexImage2D(target)" );
|
return GL_TRUE;
|
||||||
return GL_TRUE;
|
}
|
||||||
|
}
|
||||||
|
else if (target != GL_TEXTURE_2D) {
|
||||||
|
gl_error( ctx, GL_INVALID_ENUM, "glCopyTexImage2D(target)" );
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Border */
|
/* Border */
|
||||||
@@ -1000,17 +1111,31 @@ copytexsubimage_error_check( GLcontext *ctx, GLuint dimensions,
|
|||||||
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
|
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
|
||||||
struct gl_texture_image *teximage;
|
struct gl_texture_image *teximage;
|
||||||
|
|
||||||
if (dimensions == 1 && target != GL_TEXTURE_1D) {
|
if (dimensions == 1) {
|
||||||
gl_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage1D(target)" );
|
if (target != GL_TEXTURE_1D) {
|
||||||
return GL_TRUE;
|
gl_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage1D(target)" );
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (dimensions == 2 && target != GL_TEXTURE_2D) {
|
else if (dimensions == 2) {
|
||||||
gl_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage2D(target)" );
|
if (ctx->Extensions.HaveTextureCubeMap) {
|
||||||
return GL_TRUE;
|
if ((target < GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB ||
|
||||||
|
target > GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) &&
|
||||||
|
target != GL_TEXTURE_2D) {
|
||||||
|
gl_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage2D(target)" );
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (target != GL_TEXTURE_2D) {
|
||||||
|
gl_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage2D(target)" );
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (dimensions == 3 && target != GL_TEXTURE_3D) {
|
else if (dimensions == 3) {
|
||||||
gl_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage3D(target)" );
|
if (target != GL_TEXTURE_3D) {
|
||||||
return GL_TRUE;
|
gl_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage3D(target)" );
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (level < 0 || level >= ctx->Const.MaxTextureLevels) {
|
if (level < 0 || level >= ctx->Const.MaxTextureLevels) {
|
||||||
@@ -1210,7 +1335,10 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
|
|||||||
GET_CURRENT_CONTEXT(ctx);
|
GET_CURRENT_CONTEXT(ctx);
|
||||||
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glTexImage2D");
|
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glTexImage2D");
|
||||||
|
|
||||||
if (target==GL_TEXTURE_2D) {
|
if (target==GL_TEXTURE_2D ||
|
||||||
|
(ctx->Extensions.HaveTextureCubeMap &&
|
||||||
|
target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
|
||||||
|
target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB)) {
|
||||||
struct gl_texture_unit *texUnit;
|
struct gl_texture_unit *texUnit;
|
||||||
struct gl_texture_object *texObj;
|
struct gl_texture_object *texObj;
|
||||||
struct gl_texture_image *texImage;
|
struct gl_texture_image *texImage;
|
||||||
@@ -1222,11 +1350,12 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
|
|||||||
|
|
||||||
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
|
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
|
||||||
texObj = select_tex_object(texUnit, target);
|
texObj = select_tex_object(texUnit, target);
|
||||||
texImage = texObj->Image[level];
|
texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
|
||||||
|
|
||||||
if (!texImage) {
|
if (!texImage) {
|
||||||
texImage = _mesa_alloc_texture_image();
|
texImage = _mesa_alloc_texture_image();
|
||||||
texObj->Image[level] = texImage;
|
set_tex_image(texObj, target, level, texImage);
|
||||||
|
/*texObj->Image[level] = texImage;*/
|
||||||
if (!texImage) {
|
if (!texImage) {
|
||||||
gl_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
|
gl_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
|
||||||
return;
|
return;
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: teximage.h,v 1.6 2000/03/27 17:54:17 brianp Exp $ */
|
/* $Id: teximage.h,v 1.7 2000/05/23 15:17:13 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -47,6 +47,11 @@ extern void
|
|||||||
_mesa_free_texture_image( struct gl_texture_image *teximage );
|
_mesa_free_texture_image( struct gl_texture_image *teximage );
|
||||||
|
|
||||||
|
|
||||||
|
extern struct gl_texture_image *
|
||||||
|
_mesa_select_tex_image(GLcontext *ctx, const struct gl_texture_unit *texUnit,
|
||||||
|
GLenum target, GLint level);
|
||||||
|
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
_mesa_get_teximage_from_driver( GLcontext *ctx, GLenum target, GLint level,
|
_mesa_get_teximage_from_driver( GLcontext *ctx, GLenum target, GLint level,
|
||||||
const struct gl_texture_object *texObj );
|
const struct gl_texture_object *texObj );
|
||||||
|
@@ -47,7 +47,7 @@
|
|||||||
* table.
|
* table.
|
||||||
* Input: shared - the shared GL state structure to contain the texture object
|
* Input: shared - the shared GL state structure to contain the texture object
|
||||||
* name - integer name for the texture object
|
* name - integer name for the texture object
|
||||||
* dimensions - either 1, 2 or 3
|
* dimensions - either 1, 2, 3 or 6 (cube map)
|
||||||
* Return: pointer to new texture object
|
* Return: pointer to new texture object
|
||||||
*/
|
*/
|
||||||
struct gl_texture_object *
|
struct gl_texture_object *
|
||||||
@@ -56,7 +56,7 @@ gl_alloc_texture_object( struct gl_shared_state *shared, GLuint name,
|
|||||||
{
|
{
|
||||||
struct gl_texture_object *obj;
|
struct gl_texture_object *obj;
|
||||||
|
|
||||||
ASSERT(dimensions <= 3);
|
ASSERT(dimensions <= 3 || dimensions == 6);
|
||||||
|
|
||||||
obj = CALLOC_STRUCT(gl_texture_object);
|
obj = CALLOC_STRUCT(gl_texture_object);
|
||||||
|
|
||||||
@@ -173,7 +173,7 @@ void gl_test_texture_object_completeness( const GLcontext *ctx, struct gl_textur
|
|||||||
if (t->Dimensions==1) {
|
if (t->Dimensions==1) {
|
||||||
t->P = t->Image[0]->WidthLog2;
|
t->P = t->Image[0]->WidthLog2;
|
||||||
}
|
}
|
||||||
else if (t->Dimensions==2) {
|
else if (t->Dimensions == 2 || t->Dimensions == 6) {
|
||||||
t->P = MAX2(t->Image[0]->WidthLog2, t->Image[0]->HeightLog2);
|
t->P = MAX2(t->Image[0]->WidthLog2, t->Image[0]->HeightLog2);
|
||||||
}
|
}
|
||||||
else if (t->Dimensions==3) {
|
else if (t->Dimensions==3) {
|
||||||
@@ -428,25 +428,37 @@ _mesa_BindTexture( GLenum target, GLuint texName )
|
|||||||
switch (target) {
|
switch (target) {
|
||||||
case GL_TEXTURE_1D:
|
case GL_TEXTURE_1D:
|
||||||
dim = 1;
|
dim = 1;
|
||||||
|
oldTexObj = texUnit->CurrentD[1];
|
||||||
break;
|
break;
|
||||||
case GL_TEXTURE_2D:
|
case GL_TEXTURE_2D:
|
||||||
dim = 2;
|
dim = 2;
|
||||||
|
oldTexObj = texUnit->CurrentD[2];
|
||||||
break;
|
break;
|
||||||
case GL_TEXTURE_3D:
|
case GL_TEXTURE_3D:
|
||||||
dim = 3;
|
dim = 3;
|
||||||
|
oldTexObj = texUnit->CurrentD[3];
|
||||||
break;
|
break;
|
||||||
|
case GL_TEXTURE_CUBE_MAP_ARB:
|
||||||
|
if (ctx->Extensions.HaveTextureCubeMap) {
|
||||||
|
dim = 6;
|
||||||
|
oldTexObj = texUnit->CurrentCubeMap;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* fallthrough */
|
||||||
default:
|
default:
|
||||||
gl_error( ctx, GL_INVALID_ENUM, "glBindTexture(target)" );
|
gl_error( ctx, GL_INVALID_ENUM, "glBindTexture(target)" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
oldTexObj = texUnit->CurrentD[dim];
|
|
||||||
|
|
||||||
if (oldTexObj->Name == texName)
|
if (oldTexObj->Name == texName)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (texName == 0)
|
if (texName == 0) {
|
||||||
newTexObj = ctx->Shared->DefaultD[dim];
|
if (target == GL_TEXTURE_CUBE_MAP_ARB)
|
||||||
|
newTexObj = ctx->Shared->DefaultCubeMap;
|
||||||
|
else
|
||||||
|
newTexObj = ctx->Shared->DefaultD[dim];
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
struct _mesa_HashTable *hash = ctx->Shared->TexObjects;
|
struct _mesa_HashTable *hash = ctx->Shared->TexObjects;
|
||||||
newTexObj = (struct gl_texture_object *) _mesa_HashLookup(hash, texName);
|
newTexObj = (struct gl_texture_object *) _mesa_HashLookup(hash, texName);
|
||||||
@@ -466,7 +478,22 @@ _mesa_BindTexture( GLenum target, GLuint texName )
|
|||||||
|
|
||||||
newTexObj->RefCount++;
|
newTexObj->RefCount++;
|
||||||
|
|
||||||
texUnit->CurrentD[dim] = newTexObj;
|
switch (target) {
|
||||||
|
case GL_TEXTURE_1D:
|
||||||
|
texUnit->CurrentD[1] = newTexObj;
|
||||||
|
break;
|
||||||
|
case GL_TEXTURE_2D:
|
||||||
|
texUnit->CurrentD[2] = newTexObj;
|
||||||
|
break;
|
||||||
|
case GL_TEXTURE_3D:
|
||||||
|
texUnit->CurrentD[3] = newTexObj;
|
||||||
|
break;
|
||||||
|
case GL_TEXTURE_CUBE_MAP_ARB:
|
||||||
|
texUnit->CurrentCubeMap = newTexObj;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
gl_problem(ctx, "bad target in BindTexture");
|
||||||
|
}
|
||||||
|
|
||||||
/* If we've changed the CurrentD[123] texture object then update the
|
/* If we've changed the CurrentD[123] texture object then update the
|
||||||
* ctx->Texture.Current pointer to point to the new texture object.
|
* ctx->Texture.Current pointer to point to the new texture object.
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: texstate.c,v 1.10 2000/05/22 16:33:21 brianp Exp $ */
|
/* $Id: texstate.c,v 1.11 2000/05/23 15:17:13 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -35,6 +35,7 @@
|
|||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
#include "matrix.h"
|
#include "matrix.h"
|
||||||
#include "texobj.h"
|
#include "texobj.h"
|
||||||
|
#include "teximage.h"
|
||||||
#include "texstate.h"
|
#include "texstate.h"
|
||||||
#include "texture.h"
|
#include "texture.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
@@ -275,7 +276,7 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
|
|||||||
break;
|
break;
|
||||||
case GL_TEXTURE_CUBE_MAP_ARB:
|
case GL_TEXTURE_CUBE_MAP_ARB:
|
||||||
if (ctx->Extensions.HaveTextureCubeMap) {
|
if (ctx->Extensions.HaveTextureCubeMap) {
|
||||||
texObj = texUnit->CurrentPosX;
|
texObj = texUnit->CurrentCubeMap;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
@@ -431,6 +432,28 @@ _mesa_GetTexLevelParameterfv( GLenum target, GLint level,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static GLuint
|
||||||
|
tex_image_dimensions(GLcontext *ctx, GLenum target)
|
||||||
|
{
|
||||||
|
switch (target) {
|
||||||
|
case GL_TEXTURE_1D:
|
||||||
|
case GL_PROXY_TEXTURE_1D:
|
||||||
|
return 1;
|
||||||
|
case GL_TEXTURE_2D:
|
||||||
|
case GL_PROXY_TEXTURE_2D:
|
||||||
|
return 2;
|
||||||
|
case GL_TEXTURE_3D:
|
||||||
|
case GL_PROXY_TEXTURE_3D:
|
||||||
|
return 3;
|
||||||
|
case GL_TEXTURE_CUBE_MAP_ARB:
|
||||||
|
case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
|
||||||
|
return ctx->Extensions.HaveTextureCubeMap ? 2 : 0;
|
||||||
|
default:
|
||||||
|
gl_problem(ctx, "bad target in _mesa_tex_target_dimensions()");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_mesa_GetTexLevelParameteriv( GLenum target, GLint level,
|
_mesa_GetTexLevelParameteriv( GLenum target, GLint level,
|
||||||
@@ -448,54 +471,12 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (target) {
|
dimensions = tex_image_dimensions(ctx, target); /* 1, 2 or 3 */
|
||||||
case GL_TEXTURE_1D:
|
img = _mesa_select_tex_image(ctx, texUnit, target, level);
|
||||||
img = texUnit->CurrentD[1]->Image[level];
|
|
||||||
dimensions = 1;
|
if (dimensions == 0) {
|
||||||
break;
|
gl_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(target)");
|
||||||
case GL_TEXTURE_2D:
|
return;
|
||||||
img = texUnit->CurrentD[2]->Image[level];
|
|
||||||
dimensions = 2;
|
|
||||||
break;
|
|
||||||
case GL_TEXTURE_3D:
|
|
||||||
img = texUnit->CurrentD[3]->Image[level];
|
|
||||||
dimensions = 3;
|
|
||||||
break;
|
|
||||||
case GL_TEXTURE_CUBE_MAP_ARB:
|
|
||||||
if (ctx->Extensions.HaveTextureCubeMap) {
|
|
||||||
img = texUnit->CurrentPosX->Image[level];
|
|
||||||
dimensions = 2;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
gl_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(target)");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GL_PROXY_TEXTURE_1D:
|
|
||||||
img = ctx->Texture.Proxy1D->Image[level];
|
|
||||||
dimensions = 1;
|
|
||||||
break;
|
|
||||||
case GL_PROXY_TEXTURE_2D:
|
|
||||||
img = ctx->Texture.Proxy2D->Image[level];
|
|
||||||
dimensions = 2;
|
|
||||||
break;
|
|
||||||
case GL_PROXY_TEXTURE_3D:
|
|
||||||
img = ctx->Texture.Proxy3D->Image[level];
|
|
||||||
dimensions = 3;
|
|
||||||
break;
|
|
||||||
case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
|
|
||||||
if (ctx->Extensions.HaveTextureCubeMap) {
|
|
||||||
img = ctx->Texture.ProxyCubeMap->Image[level];
|
|
||||||
dimensions = 2;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
gl_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(target)");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
gl_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(target)");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!img) {
|
if (!img) {
|
||||||
|
Reference in New Issue
Block a user