From 413d6a21f849a689b5c83ea04395856b44fc65a8 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 26 May 2000 14:44:59 +0000 Subject: [PATCH] more work on GL_ARB_texture_cube_map --- src/mesa/drivers/osmesa/osmesa.c | 3 ++- src/mesa/main/context.c | 15 +++++++++++++-- src/mesa/main/state.c | 15 ++++++--------- src/mesa/main/teximage.c | 11 +++++++---- src/mesa/main/texobj.c | 4 ++++ 5 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c index 2edbb027d61..ee00032b116 100644 --- a/src/mesa/drivers/osmesa/osmesa.c +++ b/src/mesa/drivers/osmesa/osmesa.c @@ -1,4 +1,4 @@ -/* $Id: osmesa.c,v 1.16 2000/04/22 01:05:40 brianp Exp $ */ +/* $Id: osmesa.c,v 1.17 2000/05/26 14:44:59 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -226,6 +226,7 @@ OSMesaCreateContext( GLenum format, OSMesaContext sharelist ) return NULL; } gl_extensions_enable(&(osmesa->gl_ctx),"GL_HP_occlusion_test"); + gl_extensions_enable(&(osmesa->gl_ctx), "GL_ARB_texture_cube_map"); osmesa->gl_buffer = gl_create_framebuffer( osmesa->gl_visual, osmesa->gl_visual->DepthBits > 0, diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 2fd0045c8c0..1fa5fb83813 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1,4 +1,4 @@ -/* $Id: context.c,v 1.69 2000/05/24 15:04:45 brianp Exp $ */ +/* $Id: context.c,v 1.70 2000/05/26 14:44:59 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -467,6 +467,14 @@ alloc_shared_state( void ) ss->DefaultD[d]->RefCount++; /* don't free if not in use */ } + ss->DefaultCubeMap = gl_alloc_texture_object(ss, 0, 6); + if (!ss->DefaultCubeMap) { + outOfMemory = GL_TRUE; + } + else { + ss->DefaultCubeMap->RefCount++; + } + if (!ss->DisplayList || !ss->TexObjects || outOfMemory) { /* Ran out of memory at some point. Free everything and return NULL */ if (ss->DisplayList) @@ -479,6 +487,8 @@ alloc_shared_state( void ) gl_free_texture_object(ss, ss->DefaultD[2]); if (ss->DefaultD[3]) gl_free_texture_object(ss, ss->DefaultD[3]); + if (ss->DefaultCubeMap) + gl_free_texture_object(ss, ss->DefaultCubeMap); FREE(ss); return NULL; } @@ -603,6 +613,7 @@ init_texture_unit( GLcontext *ctx, GLuint unit ) texUnit->CurrentD[1] = ctx->Shared->DefaultD[1]; texUnit->CurrentD[2] = ctx->Shared->DefaultD[2]; texUnit->CurrentD[3] = ctx->Shared->DefaultD[3]; + texUnit->CurrentCubeMap = ctx->Shared->DefaultCubeMap; } @@ -1835,7 +1846,7 @@ _mesa_get_dispatch(GLcontext *ctx) void gl_problem( const GLcontext *ctx, const char *s ) { fprintf( stderr, "Mesa implementation error: %s\n", s ); - fprintf( stderr, "Report to mesa-bugs@mesa3d.org\n" ); + fprintf( stderr, "Report to Mesa bug database at www.mesa3d.org\n" ); (void) ctx; } diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index a2ba03a02a4..3093da2fe6b 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -1,4 +1,4 @@ -/* $Id: state.c,v 1.14 2000/05/24 15:04:45 brianp Exp $ */ +/* $Id: state.c,v 1.15 2000/05/26 14:44:59 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -931,8 +931,7 @@ void gl_update_state( GLcontext *ctx ) ctx->Enabled &= ~(ENABLE_TEXMAT0|ENABLE_TEXMAT1); for (i=0; i < MAX_TEXTURE_UNITS; i++) { - if (ctx->TextureMatrix[i].flags & MAT_DIRTY_ALL_OVER) - { + if (ctx->TextureMatrix[i].flags & MAT_DIRTY_ALL_OVER) { gl_matrix_analyze( &ctx->TextureMatrix[i] ); ctx->TextureMatrix[i].flags &= ~MAT_DIRTY_DEPENDENTS; @@ -946,7 +945,7 @@ void gl_update_state( GLcontext *ctx ) if (ctx->NewState & (NEW_TEXTURING | NEW_TEXTURE_ENABLE)) { ctx->Texture.NeedNormals = GL_FALSE; gl_update_dirty_texobjs(ctx); - ctx->Enabled &= ~(ENABLE_TEXGEN0|ENABLE_TEXGEN1); + ctx->Enabled &= ~(ENABLE_TEXGEN0 | ENABLE_TEXGEN1); ctx->Texture.ReallyEnabled = 0; for (i=0; i < MAX_TEXTURE_UNITS; i++) { @@ -954,19 +953,17 @@ void gl_update_state( GLcontext *ctx ) gl_update_texture_unit( ctx, &ctx->Texture.Unit[i] ); ctx->Texture.ReallyEnabled |= - ctx->Texture.Unit[i].ReallyEnabled<<(i*4); + ctx->Texture.Unit[i].ReallyEnabled << (i * 4); if (ctx->Texture.Unit[i].GenFlags != 0) { ctx->Enabled |= ENABLE_TEXGEN0 << i; - if (ctx->Texture.Unit[i].GenFlags & TEXGEN_NEED_NORMALS) - { + if (ctx->Texture.Unit[i].GenFlags & TEXGEN_NEED_NORMALS) { ctx->Texture.NeedNormals = GL_TRUE; ctx->Texture.NeedEyeCoords = GL_TRUE; } - if (ctx->Texture.Unit[i].GenFlags & TEXGEN_NEED_EYE_COORD) - { + if (ctx->Texture.Unit[i].GenFlags & TEXGEN_NEED_EYE_COORD) { ctx->Texture.NeedEyeCoords = GL_TRUE; } } diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index b0db8665611..af5bd3781b0 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -472,7 +472,7 @@ set_tex_image(struct gl_texture_object *tObj, tObj->Image[level] = texImage; return; case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: - tObj->PosX[level] = texImage; + tObj->Image[level] = texImage; return; case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: tObj->NegX[level] = texImage; @@ -630,7 +630,7 @@ _mesa_select_tex_image(GLcontext *ctx, const struct gl_texture_unit *texUnit, return ctx->Texture.Proxy3D->Image[level]; case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: if (ctx->Extensions.HaveTextureCubeMap) - return texUnit->CurrentCubeMap->PosX[level]; + return texUnit->CurrentCubeMap->Image[level]; else return NULL; case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: @@ -660,7 +660,7 @@ _mesa_select_tex_image(GLcontext *ctx, const struct gl_texture_unit *texUnit, return NULL; case GL_PROXY_TEXTURE_CUBE_MAP_ARB: if (ctx->Extensions.HaveTextureCubeMap) - return ctx->Texture.ProxyCubeMap->PosX[level]; + return ctx->Texture.ProxyCubeMap->Image[level]; else return NULL; default: @@ -903,7 +903,10 @@ texture_error_check( GLcontext *ctx, GLenum target, } else if (dimensions == 2) { isProxy = (GLboolean) (target == GL_PROXY_TEXTURE_2D); - if (target != GL_TEXTURE_2D && !isProxy) { + if (target != GL_TEXTURE_2D && !isProxy && + !(ctx->Extensions.HaveTextureCubeMap && + target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && + target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB)) { gl_error( ctx, GL_INVALID_ENUM, "glTexImage2D(target)" ); return GL_TRUE; } diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index 81833a3fa62..a5a8b373a23 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -306,6 +306,10 @@ _mesa_test_texobj_completeness( const GLcontext *ctx, return; /* found smallest needed mipmap, all done! */ } } + } + else if (t->Dimensions == 6) { /* cube map */ + + } else { /* Dimensions = ??? */ -- 2.30.2