head	3.37;
access;
symbols
	merge-1:3.26.2.5
	autoconf:3.26.0.4
	experimental-1:3.26.0.2
	mesa-3-1-with-kw3:3.22
	mesa-3-1-prior-to-kw3:3.21;
locks; strict;
comment	@ * @;


3.37
date	99.07.20.00.31.55;	author brianp;	state Exp;
branches;
next	3.36;

3.36
date	99.07.16.22.00.01;	author brianp;	state Exp;
branches;
next	3.35;

3.35
date	99.07.16.03.33.15;	author tjump;	state Exp;
branches;
next	3.34;

3.34
date	99.07.15.12.35.26;	author tjump;	state Exp;
branches;
next	3.33;

3.33
date	99.07.15.02.47.12;	author brianp;	state Exp;
branches;
next	3.32;

3.32
date	99.07.15.01.56.45;	author brianp;	state Exp;
branches;
next	3.31;

3.31
date	99.07.15.01.50.49;	author brianp;	state Exp;
branches;
next	3.30;

3.30
date	99.07.12.14.58.42;	author brianp;	state Exp;
branches;
next	3.29;

3.29
date	99.07.12.12.05.25;	author keithw;	state Exp;
branches;
next	3.28;

3.28
date	99.06.25.01.51.24;	author brianp;	state Exp;
branches;
next	3.27;

3.27
date	99.06.23.22.01.32;	author brianp;	state Exp;
branches;
next	3.26;

3.26
date	99.05.17.21.27.31;	author brianp;	state Exp;
branches
	3.26.2.1;
next	3.25;

3.25
date	99.05.02.00.59.24;	author keithw;	state Exp;
branches;
next	3.24;

3.24
date	99.03.31.20.18.40;	author keithw;	state Exp;
branches;
next	3.23;

3.23
date	99.03.10.12.43.12;	author sio2;	state Exp;
branches;
next	3.22;

3.22
date	99.02.25.14.12.32;	author keithw;	state Exp;
branches;
next	3.21;

3.21
date	99.02.24.22.48.07;	author jens;	state Exp;
branches;
next	3.20;

3.20
date	99.02.14.03.46.34;	author brianp;	state Exp;
branches;
next	3.19;

3.19
date	99.01.22.04.34.13;	author brianp;	state Exp;
branches;
next	3.18;

3.18
date	98.11.27.14.13.15;	author brianp;	state Exp;
branches;
next	3.17;

3.17
date	98.11.17.01.52.47;	author brianp;	state Exp;
branches;
next	3.16;

3.16
date	98.11.08.22.34.07;	author brianp;	state Exp;
branches;
next	3.15;

3.15
date	98.11.03.01.40.37;	author brianp;	state Exp;
branches;
next	3.14;

3.14
date	98.11.03.01.16.57;	author brianp;	state Exp;
branches;
next	3.13;

3.13
date	98.10.31.17.07.46;	author brianp;	state Exp;
branches;
next	3.12;

3.12
date	98.10.20.02.27.56;	author brianp;	state Exp;
branches;
next	3.11;

3.11
date	98.08.21.01.50.14;	author brianp;	state Exp;
branches;
next	3.10;

3.10
date	98.07.18.03.35.28;	author brianp;	state Exp;
branches;
next	3.9;

3.9
date	98.06.17.01.21.06;	author brianp;	state Exp;
branches;
next	3.8;

3.8
date	98.06.07.22.18.52;	author brianp;	state Exp;
branches;
next	3.7;

3.7
date	98.04.20.23.55.13;	author brianp;	state Exp;
branches;
next	3.6;

3.6
date	98.03.27.04.17.31;	author brianp;	state Exp;
branches;
next	3.5;

3.5
date	98.03.15.17.55.03;	author brianp;	state Exp;
branches;
next	3.4;

3.4
date	98.02.20.04.53.37;	author brianp;	state Exp;
branches;
next	3.3;

3.3
date	98.02.04.05.00.07;	author brianp;	state Exp;
branches;
next	3.2;

3.2
date	98.02.03.04.27.54;	author brianp;	state Exp;
branches;
next	3.1;

3.1
date	98.02.01.19.39.09;	author brianp;	state Exp;
branches;
next	3.0;

3.0
date	98.01.31.21.04.38;	author brianp;	state Exp;
branches;
next	;

3.26.2.1
date	99.05.21.21.29.27;	author keithw;	state Exp;
branches;
next	3.26.2.2;

3.26.2.2
date	99.05.22.19.14.40;	author keithw;	state Exp;
branches;
next	3.26.2.3;

3.26.2.3
date	99.06.01.00.45.21;	author keithw;	state Exp;
branches;
next	3.26.2.4;

3.26.2.4
date	99.06.06.22.35.55;	author keithw;	state Exp;
branches;
next	3.26.2.5;

3.26.2.5
date	99.06.19.15.04.14;	author keithw;	state Exp;
branches;
next	;


desc
@texture state functions
@


3.37
log
@gl_GetTexLevelParameteri() rewritten
@
text
@/* $Id: texstate.c,v 3.36 1999/07/16 22:00:01 brianp Exp $ */

/*
 * Mesa 3-D graphics library
 * Version:  3.1
 * 
 * Copyright (C) 1999  Brian Paul   All Rights Reserved.
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */



#ifdef PC_HEADER
#include "all.h"
#else
#include <assert.h>
#include <stdio.h>
#include "context.h"
#include "enums.h"
#include "macros.h"
#include "matrix.h"
#include "texobj.h"
#include "texstate.h"
#include "texture.h"
#include "types.h"
#include "xform.h"
#ifdef XFree86Server
#include "GL/xf86glx.h"
#endif
#endif



#ifdef SPECIALCAST
/* Needed for an Amiga compiler */
#define ENUM_TO_FLOAT(X) ((GLfloat)(GLint)(X))
#define ENUM_TO_DOUBLE(X) ((GLdouble)(GLint)(X))
#else
/* all other compilers */
#define ENUM_TO_FLOAT(X) ((GLfloat)(X))
#define ENUM_TO_DOUBLE(X) ((GLdouble)(X))
#endif




/**********************************************************************/
/*                       Texture Environment                          */
/**********************************************************************/


void gl_TexEnvfv( GLcontext *ctx,
                  GLenum target, GLenum pname, const GLfloat *param )
{
   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];

   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glTexEnv");

   if (target!=GL_TEXTURE_ENV) {
      gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(target)" );
      return;
   }

   if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE))
      fprintf(stderr, "glTexEnv %s %s %.1f(%s) ...\n",  
	      gl_lookup_enum_by_nr(target),
	      gl_lookup_enum_by_nr(pname),
	      *param,
	      gl_lookup_enum_by_nr((GLenum) (GLint) *param));


   if (pname==GL_TEXTURE_ENV_MODE) {
      GLenum mode = (GLenum) (GLint) *param;
      switch (mode) {
	 case GL_MODULATE:
	 case GL_BLEND:
	 case GL_DECAL:
	 case GL_REPLACE:
	    /* A small optimization for drivers */ 
	    if (texUnit->EnvMode == mode)
               return;

	    if (MESA_VERBOSE & (VERBOSE_STATE|VERBOSE_TEXTURE))
	       fprintf(stderr, "glTexEnv: old mode %s, new mode %s\n",
		       gl_lookup_enum_by_nr(texUnit->EnvMode),
		       gl_lookup_enum_by_nr(mode));

	    texUnit->EnvMode = mode;
	    ctx->NewState |= NEW_TEXTURE_ENV;
	    break;
	 default:
	    gl_error( ctx, GL_INVALID_VALUE, "glTexEnv(param)" );
	    return;
      }
   }
   else if (pname==GL_TEXTURE_ENV_COLOR) {
      texUnit->EnvColor[0] = CLAMP( param[0], 0.0, 1.0 );
      texUnit->EnvColor[1] = CLAMP( param[1], 0.0, 1.0 );
      texUnit->EnvColor[2] = CLAMP( param[2], 0.0, 1.0 );
      texUnit->EnvColor[3] = CLAMP( param[3], 0.0, 1.0 );
   }
   else {
      gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" );
      return;
   }

   /* Tell device driver about the new texture environment */
   if (ctx->Driver.TexEnv) {
      (*ctx->Driver.TexEnv)( ctx, pname, param );
   }
}





void gl_GetTexEnvfv( GLcontext *ctx,
                     GLenum target, GLenum pname, GLfloat *params )
{
   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
   if (target!=GL_TEXTURE_ENV) {
      gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(target)" );
      return;
   }
   switch (pname) {
      case GL_TEXTURE_ENV_MODE:
         *params = ENUM_TO_FLOAT(texUnit->EnvMode);
	 break;
      case GL_TEXTURE_ENV_COLOR:
	 COPY_4FV( params, texUnit->EnvColor );
	 break;
      default:
         gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)" );
   }
}


void gl_GetTexEnviv( GLcontext *ctx,
                     GLenum target, GLenum pname, GLint *params )
{
   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
   if (target!=GL_TEXTURE_ENV) {
      gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(target)" );
      return;
   }
   switch (pname) {
      case GL_TEXTURE_ENV_MODE:
         *params = (GLint) texUnit->EnvMode;
	 break;
      case GL_TEXTURE_ENV_COLOR:
	 params[0] = FLOAT_TO_INT( texUnit->EnvColor[0] );
	 params[1] = FLOAT_TO_INT( texUnit->EnvColor[1] );
	 params[2] = FLOAT_TO_INT( texUnit->EnvColor[2] );
	 params[3] = FLOAT_TO_INT( texUnit->EnvColor[3] );
	 break;
      default:
         gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)" );
   }
}




/**********************************************************************/
/*                       Texture Parameters                           */
/**********************************************************************/


void gl_TexParameterfv( GLcontext *ctx,
                        GLenum target, GLenum pname, const GLfloat *params )
{
   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
   GLenum eparam = (GLenum) (GLint) params[0];
   struct gl_texture_object *texObj;

   if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE))
      fprintf(stderr, "texPARAM %s %s %d...\n", 
	      gl_lookup_enum_by_nr(target),
	      gl_lookup_enum_by_nr(pname),
	      eparam);


   switch (target) {
      case GL_TEXTURE_1D:
         texObj = texUnit->CurrentD[1];
         break;
      case GL_TEXTURE_2D:
         texObj = texUnit->CurrentD[2];
         break;
      case GL_TEXTURE_3D_EXT:
         texObj = texUnit->CurrentD[3];
         break;
      default:
         gl_error( ctx, GL_INVALID_ENUM, "glTexParameter(target)" );
         return;
   }

   switch (pname) {
      case GL_TEXTURE_MIN_FILTER:
         /* A small optimization */
         if (texObj->MinFilter == eparam)
            return;

         if (eparam==GL_NEAREST || eparam==GL_LINEAR
             || eparam==GL_NEAREST_MIPMAP_NEAREST
             || eparam==GL_LINEAR_MIPMAP_NEAREST
             || eparam==GL_NEAREST_MIPMAP_LINEAR
             || eparam==GL_LINEAR_MIPMAP_LINEAR) {
            texObj->MinFilter = eparam;
            ctx->NewState |= NEW_TEXTURING;
         }
         else {
            gl_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
            return;
         }
         break;
      case GL_TEXTURE_MAG_FILTER:
         /* A small optimization */
         if (texObj->MagFilter == eparam)
            return;

         if (eparam==GL_NEAREST || eparam==GL_LINEAR) {
            texObj->MagFilter = eparam;
            ctx->NewState |= NEW_TEXTURING;
         }
         else {
            gl_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
            return;
         }
         break;
      case GL_TEXTURE_WRAP_S:
         if (texObj->WrapS == eparam)
            return;

         if (eparam==GL_CLAMP || eparam==GL_REPEAT || eparam==GL_CLAMP_TO_EDGE) {
            texObj->WrapS = eparam;
            ctx->NewState |= NEW_TEXTURING;
         }
         else {
            gl_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
            return;
         }
         break;
      case GL_TEXTURE_WRAP_T:
         if (texObj->WrapT == eparam)
            return;

         if (eparam==GL_CLAMP || eparam==GL_REPEAT || eparam==GL_CLAMP_TO_EDGE) {
            texObj->WrapT = eparam;
            ctx->NewState |= NEW_TEXTURING;
         }
         else {
            gl_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
            return;
         }
         break;
      case GL_TEXTURE_WRAP_R_EXT:
         if (texObj->WrapR == eparam)
            return;

         if (eparam==GL_CLAMP || eparam==GL_REPEAT || eparam==GL_CLAMP_TO_EDGE) {
            texObj->WrapR = eparam;
            ctx->NewState |= NEW_TEXTURING;
         }
         else {
            gl_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
         }
         break;
      case GL_TEXTURE_BORDER_COLOR:
         texObj->BorderColor[0] = CLAMP((GLint)(params[0]*255.0), 0, 255);
         texObj->BorderColor[1] = CLAMP((GLint)(params[1]*255.0), 0, 255);
         texObj->BorderColor[2] = CLAMP((GLint)(params[2]*255.0), 0, 255);
         texObj->BorderColor[3] = CLAMP((GLint)(params[3]*255.0), 0, 255);
         break;
      case GL_TEXTURE_MIN_LOD:
         texObj->MinLod = params[0];
         ctx->NewState |= NEW_TEXTURING;
         break;
      case GL_TEXTURE_MAX_LOD:
         texObj->MaxLod = params[0];
         ctx->NewState |= NEW_TEXTURING;
         break;
      case GL_TEXTURE_BASE_LEVEL:
         if (params[0] < 0.0) {
            gl_error(ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
            return;
         }
         texObj->BaseLevel = (GLint) params[0];
         ctx->NewState |= NEW_TEXTURING;
         break;
      case GL_TEXTURE_MAX_LEVEL:
         if (params[0] < 0.0) {
            gl_error(ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
            return;
         }
         texObj->MaxLevel = (GLint) params[0];
         ctx->NewState |= NEW_TEXTURING;
         break;
      case GL_TEXTURE_PRIORITY:
         /* (keithh@@netcomuk.co.uk) */
         texObj->Priority = CLAMP( params[0], 0.0, 1.0 );
         break;
      default:
         gl_error( ctx, GL_INVALID_ENUM, "glTexParameter(pname)" );
         return;
   }

   gl_put_texobj_on_dirty_list( ctx, texObj );

   if (ctx->Driver.TexParameter) {
      (*ctx->Driver.TexParameter)( ctx, target, texObj, pname, params );
   }
}



void gl_GetTexLevelParameterfv( GLcontext *ctx, GLenum target, GLint level,
                                GLenum pname, GLfloat *params )
{
   GLint iparam;
   gl_GetTexLevelParameteriv( ctx, target, level, pname, &iparam );
   *params = (GLfloat) iparam;
}



void gl_GetTexLevelParameteriv( GLcontext *ctx, GLenum target, GLint level,
                                GLenum pname, GLint *params )
{
   const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
   const struct gl_texture_image *img = NULL;
   GLuint dimensions;

   if (level < 0 || level >= ctx->Const.MaxTextureLevels) {
      gl_error( ctx, GL_INVALID_VALUE, "glGetTexLevelParameter[if]v" );
      return;
   }

   switch (target) {
      case GL_TEXTURE_1D:
         img = texUnit->CurrentD[1]->Image[level];
         dimensions = 1;
         break;
      case GL_TEXTURE_2D:
         img = texUnit->CurrentD[2]->Image[level];
         dimensions = 2;
         break;
      case GL_TEXTURE_3D:
         img = texUnit->CurrentD[3]->Image[level];
         dimensions = 3; 
        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;
      default:
	 gl_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(target)");
         return;
   }

   if (!img) {
      if (pname == GL_TEXTURE_COMPONENTS)
         *params = 1;
      else
         *params = 0;
      return;
   }

   switch (pname) {
      case GL_TEXTURE_WIDTH:
         *params = img->Width;
         return;
      case GL_TEXTURE_HEIGHT:
         if (dimensions > 1) {
            *params = img->Height;
         }
         else {
            gl_error( ctx, GL_INVALID_ENUM,
                      "glGetTexLevelParameter[if]v(pname=GL_TEXTURE_HEIGHT)" );
         }
         return;
      case GL_TEXTURE_DEPTH:
         if (dimensions > 2) {
            *params = img->Depth;
         }
         else {
            gl_error( ctx, GL_INVALID_ENUM,
                      "glGetTexLevelParameter[if]v(pname=GL_TEXTURE_DEPTH)" );
         }
         return;
      case GL_TEXTURE_COMPONENTS:
         *params = img->IntFormat;
         return;
      case GL_TEXTURE_BORDER:
         *params = img->Border;
         return;
      case GL_TEXTURE_RED_SIZE:
         *params = img->RedBits;
         return;
      case GL_TEXTURE_GREEN_SIZE:
         *params = img->GreenBits;
         return;
      case GL_TEXTURE_BLUE_SIZE:
         *params = img->BlueBits;
         return;
      case GL_TEXTURE_ALPHA_SIZE:
         *params = img->AlphaBits;
         return;
      case GL_TEXTURE_INTENSITY_SIZE:
         *params = img->IntensityBits;
         return;
      case GL_TEXTURE_LUMINANCE_SIZE:
         *params = img->LuminanceBits;
         return;
      case GL_TEXTURE_INDEX_SIZE_EXT:
         *params = img->IndexBits;
         return;
      default:
         gl_error( ctx, GL_INVALID_ENUM,
                   "glGetTexLevelParameter[if]v(pname)" );
   }
}




void gl_GetTexParameterfv( GLcontext *ctx,
                           GLenum target, GLenum pname, GLfloat *params )
{
   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
   struct gl_texture_object *obj;

   switch (target) {
      case GL_TEXTURE_1D:
         obj = texUnit->CurrentD[1];
         break;
      case GL_TEXTURE_2D:
         obj = texUnit->CurrentD[2];
         break;
      case GL_TEXTURE_3D_EXT:
         obj = texUnit->CurrentD[3];
         break;
      default:
         gl_error(ctx, GL_INVALID_ENUM, "glGetTexParameterfv(target)");
         return;
   }

   switch (pname) {
      case GL_TEXTURE_MAG_FILTER:
	 *params = ENUM_TO_FLOAT(obj->MagFilter);
	 break;
      case GL_TEXTURE_MIN_FILTER:
         *params = ENUM_TO_FLOAT(obj->MinFilter);
         break;
      case GL_TEXTURE_WRAP_S:
         *params = ENUM_TO_FLOAT(obj->WrapS);
         break;
      case GL_TEXTURE_WRAP_T:
         *params = ENUM_TO_FLOAT(obj->WrapT);
         break;
      case GL_TEXTURE_WRAP_R_EXT:
         *params = ENUM_TO_FLOAT(obj->WrapR);
         break;
      case GL_TEXTURE_BORDER_COLOR:
         params[0] = obj->BorderColor[0] / 255.0F;
         params[1] = obj->BorderColor[1] / 255.0F;
         params[2] = obj->BorderColor[2] / 255.0F;
         params[3] = obj->BorderColor[3] / 255.0F;
         break;
      case GL_TEXTURE_RESIDENT:
         *params = ENUM_TO_FLOAT(GL_TRUE);
         break;
      case GL_TEXTURE_PRIORITY:
         *params = obj->Priority;
         break;
      case GL_TEXTURE_MIN_LOD:
         *params = obj->MinLod;
         break;
      case GL_TEXTURE_MAX_LOD:
         *params = obj->MaxLod;
         break;
      case GL_TEXTURE_BASE_LEVEL:
         *params = obj->BaseLevel;
         break;
      case GL_TEXTURE_MAX_LEVEL:
         *params = obj->MaxLevel;
         break;
      default:
         gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameterfv(pname)" );
   }
}


void gl_GetTexParameteriv( GLcontext *ctx,
                           GLenum target, GLenum pname, GLint *params )
{
   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
   struct gl_texture_object *obj;

   switch (target) {
      case GL_TEXTURE_1D:
         obj = texUnit->CurrentD[1];
         break;
      case GL_TEXTURE_2D:
         obj = texUnit->CurrentD[2];
         break;
      case GL_TEXTURE_3D_EXT:
         obj = texUnit->CurrentD[3];
         break;
      default:
         gl_error(ctx, GL_INVALID_ENUM, "glGetTexParameterfv(target)");
         return;
   }

   switch (pname) {
      case GL_TEXTURE_MAG_FILTER:
         *params = (GLint) obj->MagFilter;
         break;
      case GL_TEXTURE_MIN_FILTER:
         *params = (GLint) obj->MinFilter;
         break;
      case GL_TEXTURE_WRAP_S:
         *params = (GLint) obj->WrapS;
         break;
      case GL_TEXTURE_WRAP_T:
         *params = (GLint) obj->WrapT;
         break;
      case GL_TEXTURE_WRAP_R_EXT:
         *params = (GLint) obj->WrapR;
         break;
      case GL_TEXTURE_BORDER_COLOR:
         {
            GLfloat color[4];
            color[0] = obj->BorderColor[0]/255.0;
            color[1] = obj->BorderColor[1]/255.0;
            color[2] = obj->BorderColor[2]/255.0;
            color[3] = obj->BorderColor[3]/255.0;
            params[0] = FLOAT_TO_INT( color[0] );
            params[1] = FLOAT_TO_INT( color[1] );
            params[2] = FLOAT_TO_INT( color[2] );
            params[3] = FLOAT_TO_INT( color[3] );
         }
         break;
      case GL_TEXTURE_RESIDENT:
         *params = (GLint) GL_TRUE;
         break;
      case GL_TEXTURE_PRIORITY:
         *params = (GLint) obj->Priority;
         break;
      case GL_TEXTURE_MIN_LOD:
         *params = (GLint) obj->MinLod;
         break;
      case GL_TEXTURE_MAX_LOD:
         *params = (GLint) obj->MaxLod;
         break;
      case GL_TEXTURE_BASE_LEVEL:
         *params = obj->BaseLevel;
         break;
      case GL_TEXTURE_MAX_LEVEL:
         *params = obj->MaxLevel;
         break;
      default:
         gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameteriv(pname)" );
   }
}




/**********************************************************************/
/*                    Texture Coord Generation                        */
/**********************************************************************/


void gl_TexGenfv( GLcontext *ctx,
                  GLenum coord, GLenum pname, const GLfloat *params )
{
   GLuint tUnit = ctx->Texture.CurrentTransformUnit;
   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[tUnit];
   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glTexGenfv");

   if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE))
      fprintf(stderr, "texGEN %s %s %x...\n", 
	      gl_lookup_enum_by_nr(coord),
	      gl_lookup_enum_by_nr(pname),
	      *(int *)params);

   switch( coord ) {
      case GL_S:
         if (pname==GL_TEXTURE_GEN_MODE) {
	    GLenum mode = (GLenum) (GLint) *params;
	    switch (mode) {
	    case GL_OBJECT_LINEAR:
	       texUnit->GenModeS = mode;
	       texUnit->GenBitS = TEXGEN_OBJ_LINEAR;
	       break;
	    case GL_EYE_LINEAR:
	       texUnit->GenModeS = mode;
	       texUnit->GenBitS = TEXGEN_EYE_LINEAR;
	       break;
	    case GL_REFLECTION_MAP_NV:
	       texUnit->GenModeS = mode;
	       texUnit->GenBitS = TEXGEN_REFLECTION_MAP_NV;
	       break;
	    case GL_NORMAL_MAP_NV:
	       texUnit->GenModeS = mode;
	       texUnit->GenBitS = TEXGEN_NORMAL_MAP_NV;
	       break;
	    case GL_SPHERE_MAP:
	       texUnit->GenModeS = mode;
	       texUnit->GenBitS = TEXGEN_SPHERE_MAP;
	       break;
	    default:
	       gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" );
	       return;
	    }
	 }
	 else if (pname==GL_OBJECT_PLANE) {
	    texUnit->ObjectPlaneS[0] = params[0];
	    texUnit->ObjectPlaneS[1] = params[1];
	    texUnit->ObjectPlaneS[2] = params[2];
	    texUnit->ObjectPlaneS[3] = params[3];
	 }
	 else if (pname==GL_EYE_PLANE) {
            /* Transform plane equation by the inverse modelview matrix */
            if (ctx->ModelView.flags & MAT_DIRTY_INVERSE) {
               gl_matrix_analyze( &ctx->ModelView );
            }
            gl_transform_vector( texUnit->EyePlaneS, params,
                                 ctx->ModelView.inv );
	 }
	 else {
	    gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" );
	    return;
	 }
	 break;
      case GL_T:
         if (pname==GL_TEXTURE_GEN_MODE) {
	    GLenum mode = (GLenum) (GLint) *params;
	    switch(mode) {
	    case GL_OBJECT_LINEAR:
	       texUnit->GenModeT = GL_OBJECT_LINEAR;
	       texUnit->GenBitT = TEXGEN_OBJ_LINEAR;
	       break;
	    case GL_EYE_LINEAR:
	       texUnit->GenModeT = GL_EYE_LINEAR;
	       texUnit->GenBitT = TEXGEN_EYE_LINEAR;
	       break;
	    case GL_REFLECTION_MAP_NV:
	       texUnit->GenModeT = GL_REFLECTION_MAP_NV;
	       texUnit->GenBitT = TEXGEN_REFLECTION_MAP_NV;
	       break;
	    case GL_NORMAL_MAP_NV:
	       texUnit->GenModeT = GL_NORMAL_MAP_NV;
	       texUnit->GenBitT = TEXGEN_NORMAL_MAP_NV;
	       break;
	    case GL_SPHERE_MAP:
	       texUnit->GenModeT = GL_SPHERE_MAP;
	       texUnit->GenBitT = TEXGEN_SPHERE_MAP;
	       break;
	    default:
	       gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" );
	       return;
	    }
	 }
	 else if (pname==GL_OBJECT_PLANE) {
	    texUnit->ObjectPlaneT[0] = params[0];
	    texUnit->ObjectPlaneT[1] = params[1];
	    texUnit->ObjectPlaneT[2] = params[2];
	    texUnit->ObjectPlaneT[3] = params[3];
	 }
	 else if (pname==GL_EYE_PLANE) {
            /* Transform plane equation by the inverse modelview matrix */
            if (ctx->ModelView.flags & MAT_DIRTY_INVERSE) {
               gl_matrix_analyze( &ctx->ModelView );
            }
            gl_transform_vector( texUnit->EyePlaneT, params,
                                 ctx->ModelView.inv );
	 }
	 else {
	    gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" );
	    return;
	 }
	 break;
      case GL_R:
         if (pname==GL_TEXTURE_GEN_MODE) {
	    GLenum mode = (GLenum) (GLint) *params;
	    switch (mode) {
	    case GL_OBJECT_LINEAR:
	       texUnit->GenModeR = GL_OBJECT_LINEAR;
	       texUnit->GenBitR = TEXGEN_OBJ_LINEAR;
	       break;
	    case GL_REFLECTION_MAP_NV:
	       texUnit->GenModeR = GL_REFLECTION_MAP_NV;
	       texUnit->GenBitR = TEXGEN_REFLECTION_MAP_NV;
	       break;
	    case GL_NORMAL_MAP_NV:
	       texUnit->GenModeR = GL_NORMAL_MAP_NV;
	       texUnit->GenBitR = TEXGEN_NORMAL_MAP_NV;
	       break;
	    case GL_EYE_LINEAR:
	       texUnit->GenModeR = GL_EYE_LINEAR;
	       texUnit->GenBitR = TEXGEN_EYE_LINEAR;
	       break;
	    default:
	       gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" );
	       return;
	    }
	 }
	 else if (pname==GL_OBJECT_PLANE) {
	    texUnit->ObjectPlaneR[0] = params[0];
	    texUnit->ObjectPlaneR[1] = params[1];
	    texUnit->ObjectPlaneR[2] = params[2];
	    texUnit->ObjectPlaneR[3] = params[3];
	 }
	 else if (pname==GL_EYE_PLANE) {
            /* Transform plane equation by the inverse modelview matrix */
            if (ctx->ModelView.flags & MAT_DIRTY_INVERSE) {
               gl_matrix_analyze( &ctx->ModelView );
            }
            gl_transform_vector( texUnit->EyePlaneR, params,
                                 ctx->ModelView.inv );
	 }
	 else {
	    gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" );
	    return;
	 }
	 break;
      case GL_Q:
         if (pname==GL_TEXTURE_GEN_MODE) {
	    GLenum mode = (GLenum) (GLint) *params;
	    switch (mode) {
	    case GL_OBJECT_LINEAR: 
	       texUnit->GenModeQ = GL_OBJECT_LINEAR;
	       texUnit->GenBitQ = TEXGEN_OBJ_LINEAR;
	       break;
	    case GL_EYE_LINEAR:
	       texUnit->GenModeQ = GL_EYE_LINEAR;
	       texUnit->GenBitQ = TEXGEN_EYE_LINEAR;
	       break;
	    default:
	       gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" );
	       return;
	    }
	 }
	 else if (pname==GL_OBJECT_PLANE) {
	    texUnit->ObjectPlaneQ[0] = params[0];
	    texUnit->ObjectPlaneQ[1] = params[1];
	    texUnit->ObjectPlaneQ[2] = params[2];
	    texUnit->ObjectPlaneQ[3] = params[3];
	 }
	 else if (pname==GL_EYE_PLANE) {
            /* Transform plane equation by the inverse modelview matrix */
            if (ctx->ModelView.flags & MAT_DIRTY_INVERSE) {
               gl_matrix_analyze( &ctx->ModelView );
            }
            gl_transform_vector( texUnit->EyePlaneQ, params,
                                 ctx->ModelView.inv );
	 }
	 else {
	    gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" );
	    return;
	 }
	 break;
      default:
         gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(coord)" );
	 return;
   }

   ctx->NewState |= NEW_TEXTURING;
}



void gl_GetTexGendv( GLcontext *ctx,
                     GLenum coord, GLenum pname, GLdouble *params )
{
   GLuint tUnit = ctx->Texture.CurrentTransformUnit;
   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[tUnit];

   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexGendv");

   switch( coord ) {
      case GL_S:
         if (pname==GL_TEXTURE_GEN_MODE) {
            params[0] = ENUM_TO_DOUBLE(texUnit->GenModeS);
	 }
	 else if (pname==GL_OBJECT_PLANE) {
            COPY_4V( params, texUnit->ObjectPlaneS );
	 }
	 else if (pname==GL_EYE_PLANE) {
            COPY_4V( params, texUnit->EyePlaneS );
	 }
	 else {
	    gl_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" );
	    return;
	 }
	 break;
      case GL_T:
         if (pname==GL_TEXTURE_GEN_MODE) {
            params[0] = ENUM_TO_DOUBLE(texUnit->GenModeT);
	 }
	 else if (pname==GL_OBJECT_PLANE) {
            COPY_4V( params, texUnit->ObjectPlaneT );
	 }
	 else if (pname==GL_EYE_PLANE) {
            COPY_4V( params, texUnit->EyePlaneT );
	 }
	 else {
	    gl_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" );
	    return;
	 }
	 break;
      case GL_R:
         if (pname==GL_TEXTURE_GEN_MODE) {
            params[0] = ENUM_TO_DOUBLE(texUnit->GenModeR);
	 }
	 else if (pname==GL_OBJECT_PLANE) {
            COPY_4V( params, texUnit->ObjectPlaneR );
	 }
	 else if (pname==GL_EYE_PLANE) {
            COPY_4V( params, texUnit->EyePlaneR );
	 }
	 else {
	    gl_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" );
	    return;
	 }
	 break;
      case GL_Q:
         if (pname==GL_TEXTURE_GEN_MODE) {
            params[0] = ENUM_TO_DOUBLE(texUnit->GenModeQ);
	 }
	 else if (pname==GL_OBJECT_PLANE) {
            COPY_4V( params, texUnit->ObjectPlaneQ );
	 }
	 else if (pname==GL_EYE_PLANE) {
            COPY_4V( params, texUnit->EyePlaneQ );
	 }
	 else {
	    gl_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" );
	    return;
	 }
	 break;
      default:
         gl_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(coord)" );
	 return;
   }
}



void gl_GetTexGenfv( GLcontext *ctx,
                     GLenum coord, GLenum pname, GLfloat *params )
{
   GLuint tUnit = ctx->Texture.CurrentTransformUnit;
   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[tUnit];

   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexGenfv");

   switch( coord ) {
      case GL_S:
         if (pname==GL_TEXTURE_GEN_MODE) {
            params[0] = ENUM_TO_FLOAT(texUnit->GenModeS);
	 }
	 else if (pname==GL_OBJECT_PLANE) {
            COPY_4V( params, texUnit->ObjectPlaneS );
	 }
	 else if (pname==GL_EYE_PLANE) {
            COPY_4V( params, texUnit->EyePlaneS );
	 }
	 else {
	    gl_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" );
	    return;
	 }
	 break;
      case GL_T:
         if (pname==GL_TEXTURE_GEN_MODE) {
            params[0] = ENUM_TO_FLOAT(texUnit->GenModeT);
	 }
	 else if (pname==GL_OBJECT_PLANE) {
            COPY_4V( params, texUnit->ObjectPlaneT );
	 }
	 else if (pname==GL_EYE_PLANE) {
            COPY_4V( params, texUnit->EyePlaneT );
	 }
	 else {
	    gl_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" );
	    return;
	 }
	 break;
      case GL_R:
         if (pname==GL_TEXTURE_GEN_MODE) {
            params[0] = ENUM_TO_FLOAT(texUnit->GenModeR);
	 }
	 else if (pname==GL_OBJECT_PLANE) {
            COPY_4V( params, texUnit->ObjectPlaneR );
	 }
	 else if (pname==GL_EYE_PLANE) {
            COPY_4V( params, texUnit->EyePlaneR );
	 }
	 else {
	    gl_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" );
	    return;
	 }
	 break;
      case GL_Q:
         if (pname==GL_TEXTURE_GEN_MODE) {
            params[0] = ENUM_TO_FLOAT(texUnit->GenModeQ);
	 }
	 else if (pname==GL_OBJECT_PLANE) {
            COPY_4V( params, texUnit->ObjectPlaneQ );
	 }
	 else if (pname==GL_EYE_PLANE) {
            COPY_4V( params, texUnit->EyePlaneQ );
	 }
	 else {
	    gl_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" );
	    return;
	 }
	 break;
      default:
         gl_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(coord)" );
	 return;
   }
}



void gl_GetTexGeniv( GLcontext *ctx,
                     GLenum coord, GLenum pname, GLint *params )
{
   GLuint tUnit = ctx->Texture.CurrentTransformUnit;
   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[tUnit];

   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexGeniv");

   switch( coord ) {
      case GL_S:
         if (pname==GL_TEXTURE_GEN_MODE) {
            params[0] = texUnit->GenModeS;
	 }
	 else if (pname==GL_OBJECT_PLANE) {
            COPY_4V( params, texUnit->ObjectPlaneS );
	 }
	 else if (pname==GL_EYE_PLANE) {
            COPY_4V( params, texUnit->EyePlaneS );
	 }
	 else {
	    gl_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" );
	    return;
	 }
	 break;
      case GL_T:
         if (pname==GL_TEXTURE_GEN_MODE) {
            params[0] = texUnit->GenModeT;
	 }
	 else if (pname==GL_OBJECT_PLANE) {
            COPY_4V( params, texUnit->ObjectPlaneT );
	 }
	 else if (pname==GL_EYE_PLANE) {
            COPY_4V( params, texUnit->EyePlaneT );
	 }
	 else {
	    gl_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" );
	    return;
	 }
	 break;
      case GL_R:
         if (pname==GL_TEXTURE_GEN_MODE) {
            params[0] = texUnit->GenModeR;
	 }
	 else if (pname==GL_OBJECT_PLANE) {
            COPY_4V( params, texUnit->ObjectPlaneR );
	 }
	 else if (pname==GL_EYE_PLANE) {
            COPY_4V( params, texUnit->EyePlaneR );
	 }
	 else {
	    gl_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" );
	    return;
	 }
	 break;
      case GL_Q:
         if (pname==GL_TEXTURE_GEN_MODE) {
            params[0] = texUnit->GenModeQ;
	 }
	 else if (pname==GL_OBJECT_PLANE) {
            COPY_4V( params, texUnit->ObjectPlaneQ );
	 }
	 else if (pname==GL_EYE_PLANE) {
            COPY_4V( params, texUnit->EyePlaneQ );
	 }
	 else {
	    gl_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" );
	    return;
	 }
	 break;
      default:
         gl_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(coord)" );
	 return;
   }
}


/* GL_ARB_multitexture */
void gl_ActiveTexture( GLcontext *ctx, GLenum target )
{
   GLint maxUnits = ctx->Const.MaxTextureUnits;

   ASSERT_OUTSIDE_BEGIN_END( ctx, "glActiveTextureARB" );

   if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
      fprintf(stderr, "glActiveTexture %s\n", 
	      gl_lookup_enum_by_nr(target));

   if (target >= GL_TEXTURE0_ARB && target < GL_TEXTURE0_ARB + maxUnits) {
      GLint texUnit = target - GL_TEXTURE0_ARB;
      ctx->TexCoordUnit = texUnit;
      ctx->Texture.CurrentUnit = texUnit;
      ctx->Texture.CurrentTransformUnit = texUnit;
      if (ctx->Driver.ActiveTexture) {
         (*ctx->Driver.ActiveTexture)( ctx, (GLuint) texUnit );
      }
   }
   else {
      gl_error(ctx, GL_INVALID_OPERATION, "glActiveTextureARB(target)");
   }
}


/* GL_ARB_multitexture */
void gl_ClientActiveTexture( GLcontext *ctx, GLenum target )
{
   GLint maxUnits = ctx->Const.MaxTextureUnits;

   ASSERT_OUTSIDE_BEGIN_END( ctx, "glClientActiveTextureARB" );

   if (target >= GL_TEXTURE0_ARB && target < GL_TEXTURE0_ARB + maxUnits) {
      GLint texUnit = target - GL_TEXTURE0_ARB;
      ctx->Array.ActiveTexture = texUnit;
   }
   else {
      gl_error(ctx, GL_INVALID_OPERATION, "glActiveTextureARB(target)");
   }
}



/*
 * Put the given texture object into the list of dirty texture objects.
 * When a texture object is dirty we have to reexamine it for completeness
 * and perhaps choose a different texture sampling function.
 */
void gl_put_texobj_on_dirty_list( GLcontext *ctx, struct gl_texture_object *t )
{
   ASSERT(ctx);
   ASSERT(t);
   /* Only insert if not already in the dirty list.
    * The Dirty flag is only set iff the texture object is in the dirty list.
    */
   if (!t->Dirty) {
      ASSERT(t->NextDirty == NULL);
      t->Dirty = GL_TRUE;
      t->NextDirty = ctx->Shared->DirtyTexObjList;
      ctx->Shared->DirtyTexObjList = t;
   }
#ifdef DEBUG
   else {
      /* make sure t is in the list */
      struct gl_texture_object *obj = ctx->Shared->DirtyTexObjList;
      while (obj) {
         if (obj == t) {
            return;
         }
         obj = obj->NextDirty;
      }
      gl_problem(ctx, "Error in gl_put_texobj_on_dirty_list");
   }
#endif
}


/*
 * Remove a texture object from the dirty texture list.
 */
void gl_remove_texobj_from_dirty_list( struct gl_shared_state *shared,
                                       struct gl_texture_object *tObj )
{
   struct gl_texture_object *t, *prev = NULL;
   ASSERT(shared);
   ASSERT(tObj);
   for (t = shared->DirtyTexObjList; t; t = t->NextDirty) {
      if (t == tObj) {
         if (prev) {
            prev->NextDirty = t->NextDirty;
         }
         else {
            shared->DirtyTexObjList = t->NextDirty;
         }
         return;
      }
      prev = t;
   }
}


/*
 * This is called by gl_update_state() if the NEW_TEXTURING bit in
 * ctx->NewState is unit.
 */
void gl_update_dirty_texobjs( GLcontext *ctx )
{
   struct gl_texture_object *t, *next;
   for (t = ctx->Shared->DirtyTexObjList; t; t = next) {
      next = t->NextDirty;
      gl_test_texture_object_completeness(ctx, t);
      gl_set_texture_sampler(t);
      t->NextDirty = NULL;
      t->Dirty = GL_FALSE;
   }
   ctx->Shared->DirtyTexObjList = NULL;
}
@


3.36
log
@fixed a few problems in gl_GetTexLevelParameteriv()
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.35 1999/07/16 03:33:15 tjump Exp $ */
d347 2
a348 1
   const struct gl_texture_image *img;
d358 2
a359 37
         if (!img) {
            if (pname == GL_TEXTURE_COMPONENTS)
               *params = 1;
            else
               *params = 0;
            return;
         }
         switch (pname) {
	    case GL_TEXTURE_WIDTH:
	       *params = img->Width;
	       break;
	    case GL_TEXTURE_COMPONENTS:
               /* alias for case GL_TEXTURE_INTERNAL_FORMAT */
               /* XXX should query device driver in the future */
	       *params = img->IntFormat;
	       break;
	    case GL_TEXTURE_BORDER:
	       *params = img->Border;
	       break;
            case GL_TEXTURE_RED_SIZE:
            case GL_TEXTURE_GREEN_SIZE:
            case GL_TEXTURE_BLUE_SIZE:
            case GL_TEXTURE_ALPHA_SIZE:
            case GL_TEXTURE_INTENSITY_SIZE:
            case GL_TEXTURE_LUMINANCE_SIZE:
               /* XXX should query device driver in the future */
               *params = 8;  /* 8-bits */
               break;
            case GL_TEXTURE_INDEX_SIZE_EXT:
               /* XXX should query device driver in the future */
               *params = 8;
               break;
	    default:
	       gl_error( ctx, GL_INVALID_ENUM,
                         "glGetTexLevelParameter[if]v(pname)" );
	 }
	 break;
d362 2
a363 40
         if (!img) {
            if (pname == GL_TEXTURE_COMPONENTS)
               *params = 1;
            else
               *params = 0;
            return;
         }
	 switch (pname) {
	    case GL_TEXTURE_WIDTH:
	       *params = img->Width;
	       break;
	    case GL_TEXTURE_HEIGHT:
	       *params = img->Height;
	       break;
	    case GL_TEXTURE_COMPONENTS:
               /* alias for case GL_TEXTURE_INTERNAL_FORMAT */
               /* XXX should query device driver in the future */
	       *params = img->IntFormat;
	       break;
	    case GL_TEXTURE_BORDER:
	       *params = img->Border;
	       break;
            case GL_TEXTURE_RED_SIZE:
            case GL_TEXTURE_GREEN_SIZE:
            case GL_TEXTURE_BLUE_SIZE:
            case GL_TEXTURE_ALPHA_SIZE:
            case GL_TEXTURE_INTENSITY_SIZE:
            case GL_TEXTURE_LUMINANCE_SIZE:
               /* XXX should query device driver in the future */
               *params = 8;  /* 8-bits */
               break;
            case GL_TEXTURE_INDEX_SIZE_EXT:
               /* XXX should query device driver in the future */
               *params = 8;
               break;
	    default:
	       gl_error( ctx, GL_INVALID_ENUM,
                         "glGetTexLevelParameter[if]v(pname)" );
	 }
	 break;
d366 2
a367 42
         if (!img) {
            if (pname == GL_TEXTURE_COMPONENTS)
               *params = 1;
            else
               *params = 0;
            return;
         }
         switch (pname) {
            case GL_TEXTURE_WIDTH:
               *params = img->Width;
               break;
            case GL_TEXTURE_HEIGHT:
               *params = img->Height;
               break;
            case GL_TEXTURE_DEPTH:
               *params = img->Depth;
               break;
            case GL_TEXTURE_COMPONENTS:
               /* alias for case GL_TEXTURE_INTERNAL_FORMAT */
               /* XXX should query device driver in the future */
	       *params = img->IntFormat;
               break;
            case GL_TEXTURE_BORDER:
               *params = img->Border;
               break;
            case GL_TEXTURE_RED_SIZE:
            case GL_TEXTURE_GREEN_SIZE:
            case GL_TEXTURE_BLUE_SIZE:
            case GL_TEXTURE_ALPHA_SIZE:
            case GL_TEXTURE_INTENSITY_SIZE:
            case GL_TEXTURE_LUMINANCE_SIZE:
               /* XXX should query device driver in the future */
               *params = 8;  /* 8-bits */
               break;
            case GL_TEXTURE_INDEX_SIZE_EXT:
               *params = 8;
               break;
            default:
               gl_error( ctx, GL_INVALID_ENUM,
                         "glGetTexLevelParameter[if]v(pname)" );
         }
         break;
d370 2
a371 34
         if (!img) {
            if (pname == GL_TEXTURE_COMPONENTS)
               *params = 1;
            else
               *params = 0;
            return;
         }
         switch (pname) {
	    case GL_TEXTURE_WIDTH:
	       *params = img->Width;
	       break;
	    case GL_TEXTURE_COMPONENTS:
               /* alias for case GL_TEXTURE_INTERNAL_FORMAT */
	       *params = img->IntFormat;
	       break;
	    case GL_TEXTURE_BORDER:
	       *params = img->Border;
	       break;
            case GL_TEXTURE_RED_SIZE:
            case GL_TEXTURE_GREEN_SIZE:
            case GL_TEXTURE_BLUE_SIZE:
            case GL_TEXTURE_ALPHA_SIZE:
            case GL_TEXTURE_INTENSITY_SIZE:
            case GL_TEXTURE_LUMINANCE_SIZE:
               *params = 8;  /* 8-bits */
               break;
            case GL_TEXTURE_INDEX_SIZE_EXT:
               *params = 8;
               break;
	    default:
	       gl_error( ctx, GL_INVALID_ENUM,
                         "glGetTexLevelParameter[if]v(pname)" );
	 }
	 break;
d374 3
a376 38
         if (!img) {
            if (pname == GL_TEXTURE_COMPONENTS)
               *params = 1;
            else
               *params = 0;
            return;
         }
	 switch (pname) {
	    case GL_TEXTURE_WIDTH:
	       *params = img->Width;
	       break;
	    case GL_TEXTURE_HEIGHT:
	       *params = img->Height;
	       break;
	    case GL_TEXTURE_COMPONENTS:
               /* alias for case GL_TEXTURE_INTERNAL_FORMAT */
	       *params = img->IntFormat;
	       break;
	    case GL_TEXTURE_BORDER:
	       *params = img->Border;
	       break;
            case GL_TEXTURE_RED_SIZE:
            case GL_TEXTURE_GREEN_SIZE:
            case GL_TEXTURE_BLUE_SIZE:
            case GL_TEXTURE_ALPHA_SIZE:
            case GL_TEXTURE_INTENSITY_SIZE:
            case GL_TEXTURE_LUMINANCE_SIZE:
               *params = 8;  /* 8-bits */
               break;
            case GL_TEXTURE_INDEX_SIZE_EXT:
               *params = 8;
               break;
	    default:
	       gl_error( ctx, GL_INVALID_ENUM,
                         "glGetTexLevelParameter[if]v(pname)" );
	 }
	 break;
      case GL_PROXY_TEXTURE_3D_EXT:
d378 3
a380 41
         if (!img) {
            if (pname == GL_TEXTURE_COMPONENTS)
               *params = 1;
            else
               *params = 0;
            return;
         }
	 switch (pname) {
	    case GL_TEXTURE_WIDTH:
	       *params = img->Width;
	       break;
	    case GL_TEXTURE_HEIGHT:
	       *params = img->Height;
	       break;
	    case GL_TEXTURE_DEPTH:
	       *params = img->Depth;
	       break;
	    case GL_TEXTURE_COMPONENTS:
               /* alias for case GL_TEXTURE_INTERNAL_FORMAT */
	       *params = img->IntFormat;
	       break;
	    case GL_TEXTURE_BORDER:
	       *params = img->Border;
	       break;
            case GL_TEXTURE_RED_SIZE:
            case GL_TEXTURE_GREEN_SIZE:
            case GL_TEXTURE_BLUE_SIZE:
            case GL_TEXTURE_ALPHA_SIZE:
            case GL_TEXTURE_INTENSITY_SIZE:
            case GL_TEXTURE_LUMINANCE_SIZE:
               *params = 8;  /* 8-bits */
               break;
            case GL_TEXTURE_INDEX_SIZE_EXT:
               *params = 8;
               break;
	    default:
	       gl_error( ctx, GL_INVALID_ENUM,
                         "glGetTexLevelParameter[if]v(pname)" );
	 }
	 break;
     default:
d382 64
a445 1
   }	 
@


3.35
log
@Revived previous code for texstate.c/h, get.c, enable.c, updated Win32 project files
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.33 1999/07/15 02:47:12 brianp Exp $ */
d346 2
a347 2
   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
   struct gl_texture_image *tex;
d356 6
a361 2
         tex = texUnit->CurrentD[1]->Image[level];
         if (!tex)
d363 1
d366 1
a366 1
	       *params = tex->Width;
d370 2
a371 1
	       *params = tex->IntFormat;
d374 1
a374 1
	       *params = tex->Border;
d382 1
d386 1
d395 6
a400 2
         tex = texUnit->CurrentD[2]->Image[level];
         if (!tex)
d402 1
d405 1
a405 1
	       *params = tex->Width;
d408 1
a408 1
	       *params = tex->Height;
d412 2
a413 1
	       *params = tex->IntFormat;
d416 1
a416 1
	       *params = tex->Border;
d424 1
d428 1
d436 7
a442 3
      case GL_TEXTURE_3D_EXT:
         tex = texUnit->CurrentD[3]->Image[level];
         if (!tex)
d444 1
d447 1
a447 1
               *params = tex->Width;
d450 1
a450 1
               *params = tex->Height;
d452 2
a453 2
            case GL_TEXTURE_DEPTH_EXT:
               *params = tex->Depth;
d457 2
a458 1
	       *params = tex->IntFormat;
d461 10
a470 1
               *params = tex->Border;
d481 6
a486 2
         tex = ctx->Texture.Proxy1D->Image[level];
         if (!tex)
d488 1
d491 1
a491 1
	       *params = tex->Width;
d495 1
a495 1
	       *params = tex->IntFormat;
d498 1
a498 1
	       *params = tex->Border;
d517 6
a522 2
         tex = ctx->Texture.Proxy2D->Image[level];
         if (!tex)
d524 1
d527 1
a527 1
	       *params = tex->Width;
d530 1
a530 1
	       *params = tex->Height;
d534 1
a534 1
	       *params = tex->IntFormat;
d537 1
a537 1
	       *params = tex->Border;
d556 6
a561 2
         tex = ctx->Texture.Proxy3D->Image[level];
         if (!tex)
d563 1
d566 1
a566 1
	       *params = tex->Width;
d569 1
a569 1
	       *params = tex->Height;
d571 2
a572 2
	    case GL_TEXTURE_DEPTH_EXT:
	       *params = tex->Depth;
d576 1
a576 1
	       *params = tex->IntFormat;
d579 1
a579 1
	       *params = tex->Border;
@


3.34
log
@more Win32 build cleanups
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.32 1999/07/15 01:56:45 brianp Exp $ */
d6 1
a6 1
 *
d8 1
a8 1
 *
d15 1
a15 1
 *
d18 1
a18 1
 *
d81 1
a81 1
      fprintf(stderr, "glTexEnv %s %s %.1f(%s) ...\n",
d95 1
a95 1
	    /* A small optimization for drivers */
d193 1
a193 1
      fprintf(stderr, "texPARAM %s %s %d...\n",
d553 1
a553 1
   }
d715 1
a715 1
      fprintf(stderr, "texGEN %s %s %x...\n",
a719 1

d865 1
a865 1
	    case GL_OBJECT_LINEAR:
d912 1
d989 1
d1066 1
d1145 1
a1145 1
      fprintf(stderr, "glActiveTexture %s\n",
d1243 1
a1243 1
void gl_update_texture_state( GLcontext *ctx )
@


3.33
log
@renamed gl_update_state() to gl_update_dirty_texobjs()
@
text
@d6 1
a6 1
 * 
d8 1
a8 1
 * 
d15 1
a15 1
 * 
d18 1
a18 1
 * 
d81 1
a81 1
      fprintf(stderr, "glTexEnv %s %s %.1f(%s) ...\n",  
d95 1
a95 1
	    /* A small optimization for drivers */ 
d193 1
a193 1
      fprintf(stderr, "texPARAM %s %s %d...\n", 
d553 1
a553 1
   }	 
d715 1
a715 1
      fprintf(stderr, "texGEN %s %s %x...\n", 
d720 1
d866 1
a866 1
	    case GL_OBJECT_LINEAR: 
a912 1

a988 1

a1064 1

d1143 1
a1143 1
      fprintf(stderr, "glActiveTexture %s\n", 
d1241 1
a1241 1
void gl_update_dirty_texobjs( GLcontext *ctx )
@


3.32
log
@minor clean-up
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.31 1999/07/15 01:50:49 brianp Exp $ */
d1243 1
a1243 1
void gl_update_texture_state( GLcontext *ctx )
@


3.31
log
@added more debug code to gl_put_texobj_on_dirty_list()
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.30 1999/07/12 14:58:42 brianp Exp $ */
a719 1

d912 1
d989 1
d1066 1
d1209 1
a1209 2
      printf("%p dirty but not in list!\n", t);
      assert(obj);
@


3.30
log
@silenced IRIX compiler warnings
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.29 1999/07/12 12:05:25 keithw Exp $ */
d1197 14
@


3.29
log
@merge from experimental branch upto merge-1 tag
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.28 1999/06/25 01:51:24 brianp Exp $ */
d85 1
a85 1
	      gl_lookup_enum_by_nr((GLenum) *param));
@


3.28
log
@implemented linked list for dirty texture objects
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.27 1999/06/23 22:01:32 brianp Exp $ */
d80 2
a81 2
   if (MESA_VERBOSE&VERBOSE_TEXTURE) 
      fprintf(stderr, "texENV %s %s %f...\n",  
d84 2
a85 1
	      *param);
d98 6
d105 1
d192 1
a192 1
   if (MESA_VERBOSE&VERBOSE_TEXTURE) 
d201 1
a201 1
         texObj = texUnit->Current1D;
d204 1
a204 1
         texObj = texUnit->Current2D;
d207 1
a207 1
         texObj = texUnit->Current3D;
d356 1
a356 1
         tex = texUnit->Current1D->Image[level];
d387 1
a387 1
         tex = texUnit->Current2D->Image[level];
d421 1
a421 1
         tex = texUnit->Current3D->Image[level];
d567 1
a567 1
         obj = texUnit->Current1D;
d570 1
a570 1
         obj = texUnit->Current2D;
d573 1
a573 1
         obj = texUnit->Current3D;
d634 1
a634 1
         obj = texUnit->Current1D;
d637 1
a637 1
         obj = texUnit->Current2D;
d640 1
a640 1
         obj = texUnit->Current3D;
d714 1
a714 1
   if (MESA_VERBOSE&VERBOSE_TEXTURE) 
a1134 44

/* GL_SGIS_multitexture */
void gl_SelectTextureSGIS( GLcontext *ctx, GLenum target )
{
   GLint maxUnits = ctx->Const.MaxTextureUnits;

   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, "glSelectTextureSGIS" );

   if (target >= GL_TEXTURE0_SGIS && target < GL_TEXTURE0_SGIS + maxUnits) {
      GLint texUnit = target - GL_TEXTURE0_SGIS;
      /* Select current texture env AND transformation unit! */
      ctx->Texture.CurrentUnit = texUnit;
      ctx->Texture.CurrentTransformUnit = texUnit;
      if (ctx->Driver.ActiveTexture) {
         (*ctx->Driver.ActiveTexture)( ctx, (GLuint) texUnit );
      }
   }
   else {
      gl_error(ctx, GL_INVALID_OPERATION, "glSelectTextureSGIS(target)");
   }
}


/* GL_SGIS_multitexture */
void gl_SelectTextureCoordSet( GLcontext *ctx, GLenum target )
{
   GLint maxUnits = ctx->Const.MaxTextureUnits;

   /* KW: I assume this can't be called inside begin/end???
    */
   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, "glSelectTextureCoordSetSGIS" );

   if (target >= GL_TEXTURE0_SGIS && target < GL_TEXTURE0_SGIS + maxUnits) {
      GLint texUnit = target - GL_TEXTURE0_SGIS;
      ctx->TexCoordUnit = texUnit;
      ctx->Current.TexSet = texUnit;
      ctx->input->CurrentTexSet = texUnit;
   }
   else {
      gl_error(ctx, GL_INVALID_OPERATION, "glSelectTextureCoordUnit(target)");
   }
}


d1140 5
a1144 1
   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, "glActiveTextureARB" );
a1150 2
      ctx->Current.TexSet = 0;
      ctx->input->CurrentTexSet = 0;
d1166 1
a1166 1
   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, "glClientActiveTextureARB" );
@


3.27
log
@changing texture base or max level, min or max lod must update texture state
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.26 1999/05/17 21:27:31 brianp Exp $ */
d316 2
a317 3
   texObj->Dirty = GL_TRUE;
   ctx->Texture.AnyDirty = GL_TRUE;
   
d1214 45
d1264 7
a1270 11
   struct gl_texture_object *t;

   if (ctx->Texture.AnyDirty) {
      for (t = ctx->Shared->TexObjectList; t; t = t->Next) {
         if (t->Dirty) {
            gl_test_texture_object_completeness(ctx, t);
            gl_set_texture_sampler(t);
            t->Dirty = GL_FALSE;
         }
      }
      ctx->Texture.AnyDirty = GL_FALSE;
d1272 1
@


3.26
log
@update texture state when texture wrap mode changes
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.25 1999/05/02 00:59:24 keithw Exp $ */
d285 1
d289 1
d297 1
d305 1
@


3.26.2.1
log
@Quake3 inspired optimizations
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.26 1999/05/17 21:27:31 brianp Exp $ */
d81 1
a81 1
      fprintf(stderr, "glTexEnv %s %s %.1f(%s) ...\n",  
d84 1
a84 2
	      *param,
	      gl_lookup_enum_by_nr((GLenum) *param));
a1155 6

   if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
      fprintf(stderr, "glSelectTextureCoordSetSGIS %s\n", 
	      gl_lookup_enum_by_nr(target));


a1173 4

   if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
      fprintf(stderr, "glActiveTexture %s\n", 
	      gl_lookup_enum_by_nr(target));
@


3.26.2.2
log
@q2, q3 bugfixes
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.26.2.1 1999/05/21 21:29:27 keithw Exp $ */
d80 1
a80 1
   if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE))
d185 1
a185 1
   if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE))
d704 1
a704 1
   if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE))
a1131 6

   /* quake2 seems to have a different idea about these constants -
    * off by one in fact. I can't find the spec.
    *
    */
   target++; 
@


3.26.2.3
log
@When texture.unit[0].envmode is GL_REPLACE, don't need VERT_RGBA as an input to rendering stages.

Rearranged fxfastpath.c without improving its performance.
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.26.2.2 1999/05/22 19:14:40 keithw Exp $ */
a98 1
	    ctx->NewState |= NEW_TEXTURE_ENV;
@


3.26.2.4
log
@some trial assembly, made newer code active by default
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.26.2.3 1999/06/01 00:45:21 keithw Exp $ */
a97 6

	    if (MESA_VERBOSE & (VERBOSE_STATE|VERBOSE_TEXTURE))
	       fprintf(stderr, "glTexEnv: old mode %s, new mode %s\n",
		       gl_lookup_enum_by_nr(texUnit->EnvMode),
		       gl_lookup_enum_by_nr(mode));

d195 1
a195 1
         texObj = texUnit->CurrentD[1];
d198 1
a198 1
         texObj = texUnit->CurrentD[2];
d201 1
a201 1
         texObj = texUnit->CurrentD[3];
d347 1
a347 1
         tex = texUnit->CurrentD[1]->Image[level];
d378 1
a378 1
         tex = texUnit->CurrentD[2]->Image[level];
d412 1
a412 1
         tex = texUnit->CurrentD[3]->Image[level];
d558 1
a558 1
         obj = texUnit->CurrentD[1];
d561 1
a561 1
         obj = texUnit->CurrentD[2];
d564 1
a564 1
         obj = texUnit->CurrentD[3];
d625 1
a625 1
         obj = texUnit->CurrentD[1];
d628 1
a628 1
         obj = texUnit->CurrentD[2];
d631 1
a631 1
         obj = texUnit->CurrentD[3];
@


3.26.2.5
log
@Removed SGIS multitexture, added FX/X86 assm directory
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.26.2.4 1999/06/06 22:35:55 keithw Exp $ */
d1128 56
@


3.25
log
@FX polygon offset and debugging changes
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.24 1999/03/31 20:18:40 keithw Exp $ */
d240 3
d245 1
d253 3
d258 1
d266 3
d271 1
d304 3
a306 3
		  /* (keithh@@netcomuk.co.uk) */
		  texObj->Priority = CLAMP( params[0], 0.0, 1.0 );
		  break;
@


3.24
log
@Compiled vertex arrays
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.23 1999/03/10 12:43:12 sio2 Exp $ */
d33 1
d35 1
d80 7
d184 7
d690 7
@


3.23
log
@Added GL_TEXTURE_PRIORITY to gl_TexParameterfv
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.22 1999/02/25 14:12:32 keithw Exp $ */
d129 1
a129 1
	 COPY_4V( params, texUnit->EnvColor );
a1191 46
   }

   /* The following code will have to be modified if we increase the
    * number of texture units.
    */
   ASSERT(MAX_TEXTURE_UNITS <= 2);


   /*
    * Determine which texture units are really enabled after testing
    * for texture completeness, etc.
    */
   ctx->Texture.ReallyEnabled = 0;
   /* Texture unit 0 */
   if (ctx->Texture.Enabled & TEXTURE0_3D && ctx->Texture.Unit[0].Current3D->Complete) {
      ctx->Texture.ReallyEnabled |= TEXTURE0_3D;
      ctx->Texture.Unit[0].Current = ctx->Texture.Unit[0].Current3D;
   }
   else if (ctx->Texture.Enabled & TEXTURE0_2D && ctx->Texture.Unit[0].Current2D->Complete) {
      ctx->Texture.ReallyEnabled |= TEXTURE0_2D;
      ctx->Texture.Unit[0].Current = ctx->Texture.Unit[0].Current2D;
   }
   else if (ctx->Texture.Enabled & TEXTURE0_1D && ctx->Texture.Unit[0].Current1D->Complete) {
      ctx->Texture.ReallyEnabled |= TEXTURE0_1D;
      ctx->Texture.Unit[0].Current = ctx->Texture.Unit[0].Current1D;
   }
   else {
      ctx->Texture.Unit[0].Current = NULL;
   }
   /* Texture unit 1 */
   if (ctx->Const.MaxTextureUnits > 1) {
      if (ctx->Texture.Enabled & TEXTURE1_3D && ctx->Texture.Unit[1].Current3D->Complete) {
         ctx->Texture.ReallyEnabled |= TEXTURE1_3D;
         ctx->Texture.Unit[1].Current = ctx->Texture.Unit[1].Current3D;
      }
      else if (ctx->Texture.Enabled & TEXTURE1_2D && ctx->Texture.Unit[1].Current2D->Complete) {
         ctx->Texture.ReallyEnabled |= TEXTURE1_2D;
         ctx->Texture.Unit[1].Current = ctx->Texture.Unit[1].Current2D;
      }
      else if (ctx->Texture.Enabled & TEXTURE1_1D && ctx->Texture.Unit[1].Current1D->Complete) {
         ctx->Texture.ReallyEnabled |= TEXTURE1_1D;
         ctx->Texture.Unit[1].Current = ctx->Texture.Unit[1].Current1D;
      }
      else {
         ctx->Texture.Unit[1].Current = NULL;
      }
@


3.22
log
@Merged in kw3 patch
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.21 1999/02/24 22:48:07 jens Exp $ */
d275 4
d567 1
a567 1
         *params = texUnit->Current1D->Priority;
@


3.21
log
@Added header file to get XMesa to compile standalone and inside XFree86
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.20 1999/02/14 03:46:34 brianp Exp $ */
a27 67
/*
 * $Log: texstate.c,v $
 * Revision 3.20  1999/02/14 03:46:34  brianp
 * new copyright
 *
 * Revision 3.19  1999/01/22 04:34:13  brianp
 * call new ActiveTexture() device driver function
 *
 * Revision 3.18  1998/11/27 14:13:15  brianp
 * removed some unneeded casts
 *
 * Revision 3.17  1998/11/17 01:52:47  brianp
 * implemented GL_NV_texgen_reflection extension (MJK)
 *
 * Revision 3.16  1998/11/08 22:34:07  brianp
 * renamed texture sets to texture units
 *
 * Revision 3.15  1998/11/03 01:40:37  brianp
 * implemented GL_ARB_multitexture
 *
 * Revision 3.14  1998/11/03 01:16:57  brianp
 * added Texture.ReallyEnabled to simply testing for enabled textures
 *
 * Revision 3.13  1998/10/31 17:07:46  brianp
 * variety of multi-texture changes
 *
 * Revision 3.12  1998/10/20 02:27:56  brianp
 * removed GL_EXT_multitexture extension
 *
 * Revision 3.11  1998/08/21 01:50:14  brianp
 * made max_texture_coord_sets() non-static
 *
 * Revision 3.10  1998/07/18 03:35:28  brianp
 * get of GL_TEXTURE_INTERNAL_FORMAT wasn't handled
 *
 * Revision 3.9  1998/06/17 01:21:06  brianp
 * include assert.h
 *
 * Revision 3.8  1998/06/07 22:18:52  brianp
 * implemented GL_EXT_multitexture extension
 *
 * Revision 3.7  1998/04/20 23:55:13  brianp
 * applied DavidB's changes for v0.25 of 3Dfx driver
 *
 * Revision 3.6  1998/03/27 04:17:31  brianp
 * fixed G++ warnings
 *
 * Revision 3.5  1998/03/15 17:55:03  brianp
 * fixed a typo in gl_update_texture_state()
 *
 * Revision 3.4  1998/02/20 04:53:37  brianp
 * implemented GL_SGIS_multitexture
 *
 * Revision 3.3  1998/02/04 05:00:07  brianp
 * added a few casts for Amiga StormC compiler
 *
 * Revision 3.2  1998/02/03 04:27:54  brianp
 * added texture lod clamping
 *
 * Revision 3.1  1998/02/01 19:39:09  brianp
 * added GL_CLAMP_TO_EDGE texture wrap mode
 *
 * Revision 3.0  1998/01/31 21:04:38  brianp
 * initial rev
 *
 */

d71 1
a71 4
   if (INSIDE_BEGIN_END(ctx)) {
      gl_error( ctx, GL_INVALID_OPERATION, "glTexEnv" );
      return;
   }
d669 1
a669 4
   if (INSIDE_BEGIN_END(ctx)) {
      gl_error( ctx, GL_INVALID_OPERATION, "glTexGenfv" );
      return;
   }
d675 14
a688 5
	    if (mode==GL_OBJECT_LINEAR ||
		mode==GL_EYE_LINEAR ||
                mode==GL_REFLECTION_MAP_NV ||
                mode==GL_NORMAL_MAP_NV ||
                mode==GL_SPHERE_MAP) {
d690 7
a696 2
	    }
	    else {
d723 22
a744 8
	    if (mode==GL_OBJECT_LINEAR ||
		mode==GL_EYE_LINEAR ||
                mode==GL_REFLECTION_MAP_NV ||
                mode==GL_NORMAL_MAP_NV ||
		mode==GL_SPHERE_MAP) {
	       texUnit->GenModeT = mode;
	    }
	    else {
d771 18
a788 7
	    if (mode==GL_OBJECT_LINEAR ||
                mode==GL_REFLECTION_MAP_NV ||
                mode==GL_NORMAL_MAP_NV ||
		mode==GL_EYE_LINEAR) {
	       texUnit->GenModeR = mode;
	    }
	    else {
d815 10
a824 5
	    if (mode==GL_OBJECT_LINEAR ||
		mode==GL_EYE_LINEAR) {
	       texUnit->GenModeQ = mode;
	    }
	    else {
d863 1
a863 4
   if (INSIDE_BEGIN_END(ctx)) {
      gl_error( ctx, GL_INVALID_OPERATION, "glGetTexGendv" );
      return;
   }
d939 1
a939 4
   if (INSIDE_BEGIN_END(ctx)) {
      gl_error( ctx, GL_INVALID_OPERATION, "glGetTexGenfv" );
      return;
   }
d1015 1
a1015 4
   if (INSIDE_BEGIN_END(ctx)) {
      gl_error( ctx, GL_INVALID_OPERATION, "glGetTexGeniv" );
      return;
   }
d1090 3
d1112 5
d1120 2
a1121 1
      ctx->Current.TexCoord = ctx->Current.MultiTexCoord[texUnit];
d1133 3
d1141 2
a1142 1
      ctx->Current.TexCoord = ctx->Current.MultiTexCoord[0];  /* always 0 */
d1157 3
d1194 1
@


3.20
log
@new copyright
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.19 1999/01/22 04:34:13 brianp Exp brianp $ */
d30 3
d108 3
@


3.19
log
@call new ActiveTexture() device driver function
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.18 1998/11/27 14:13:15 brianp Exp brianp $ */
d6 19
a24 15
 * Copyright (C) 1995-1999  Brian Paul
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
d30 3
@


3.18
log
@removed some unneeded casts
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.17 1998/11/17 01:52:47 brianp Exp brianp $ */
d6 1
a6 1
 * Copyright (C) 1995-1998  Brian Paul
d26 3
d1120 3
d1155 3
@


3.17
log
@implemented GL_NV_texgen_reflection extension (MJK)
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.16 1998/11/08 22:34:07 brianp Exp brianp $ */
d26 3
d1045 1
a1045 1
            COPY_4V( params, (GLint) texUnit->ObjectPlaneS );
d1048 1
a1048 1
            COPY_4V( params, (GLint) texUnit->EyePlaneS );
d1060 1
a1060 1
            COPY_4V( params, (GLint) texUnit->ObjectPlaneT );
d1063 1
a1063 1
            COPY_4V( params, (GLint) texUnit->EyePlaneT );
d1075 1
a1075 1
            COPY_4V( params, (GLint) texUnit->ObjectPlaneR );
d1078 1
a1078 1
            COPY_4V( params, (GLint) texUnit->EyePlaneR );
d1090 1
a1090 1
            COPY_4V( params, (GLint) texUnit->ObjectPlaneQ );
d1093 1
a1093 1
            COPY_4V( params, (GLint) texUnit->EyePlaneQ );
@


3.16
log
@renamed texture sets to texture units
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.15 1998/11/03 01:40:37 brianp Exp brianp $ */
d26 3
d731 3
a733 1
		mode==GL_SPHERE_MAP) {
d765 2
d798 2
@


3.15
log
@implemented GL_ARB_multitexture
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.14 1998/11/03 01:16:57 brianp Exp brianp $ */
d26 3
d114 1
a114 1
   struct gl_texture_set *texSet = &ctx->Texture.Set[ctx->Texture.CurrentSet];
d134 1
a134 1
	    if (texSet->EnvMode == mode)
d136 1
a136 1
	    texSet->EnvMode = mode;
d144 4
a147 4
      texSet->EnvColor[0] = CLAMP( param[0], 0.0, 1.0 );
      texSet->EnvColor[1] = CLAMP( param[1], 0.0, 1.0 );
      texSet->EnvColor[2] = CLAMP( param[2], 0.0, 1.0 );
      texSet->EnvColor[3] = CLAMP( param[3], 0.0, 1.0 );
d167 1
a167 1
   struct gl_texture_set *texSet = &ctx->Texture.Set[ctx->Texture.CurrentSet];
d174 1
a174 1
         *params = ENUM_TO_FLOAT(texSet->EnvMode);
d177 1
a177 1
	 COPY_4V( params, texSet->EnvColor );
d188 1
a188 1
   struct gl_texture_set *texSet = &ctx->Texture.Set[ctx->Texture.CurrentSet];
d195 1
a195 1
         *params = (GLint) texSet->EnvMode;
d198 4
a201 4
	 params[0] = FLOAT_TO_INT( texSet->EnvColor[0] );
	 params[1] = FLOAT_TO_INT( texSet->EnvColor[1] );
	 params[2] = FLOAT_TO_INT( texSet->EnvColor[2] );
	 params[3] = FLOAT_TO_INT( texSet->EnvColor[3] );
d219 1
a219 1
   struct gl_texture_set *texSet = &ctx->Texture.Set[ctx->Texture.CurrentSet];
d225 1
a225 1
         texObj = texSet->Current1D;
d228 1
a228 1
         texObj = texSet->Current2D;
d231 1
a231 1
         texObj = texSet->Current3D;
d351 1
a351 1
   struct gl_texture_set *texSet = &ctx->Texture.Set[ctx->Texture.CurrentSet];
d361 1
a361 1
         tex = texSet->Current1D->Image[level];
d392 1
a392 1
         tex = texSet->Current2D->Image[level];
d426 1
a426 1
         tex = texSet->Current3D->Image[level];
d567 1
a567 1
   struct gl_texture_set *texSet = &ctx->Texture.Set[ctx->Texture.CurrentSet];
d572 1
a572 1
         obj = texSet->Current1D;
d575 1
a575 1
         obj = texSet->Current2D;
d578 1
a578 1
         obj = texSet->Current3D;
d611 1
a611 1
         *params = texSet->Current1D->Priority;
d634 1
a634 1
   struct gl_texture_set *texSet = &ctx->Texture.Set[ctx->Texture.CurrentSet];
d639 1
a639 1
         obj = texSet->Current1D;
d642 1
a642 1
         obj = texSet->Current2D;
d645 1
a645 1
         obj = texSet->Current3D;
d715 2
a716 2
   GLuint tSet = ctx->Texture.CurrentTransformSet;
   struct gl_texture_set *texSet = &ctx->Texture.Set[tSet];
d729 1
a729 1
	       texSet->GenModeS = mode;
d737 4
a740 4
	    texSet->ObjectPlaneS[0] = params[0];
	    texSet->ObjectPlaneS[1] = params[1];
	    texSet->ObjectPlaneS[2] = params[2];
	    texSet->ObjectPlaneS[3] = params[3];
d747 1
a747 1
            gl_transform_vector( texSet->EyePlaneS, params,
d761 1
a761 1
	       texSet->GenModeT = mode;
d769 4
a772 4
	    texSet->ObjectPlaneT[0] = params[0];
	    texSet->ObjectPlaneT[1] = params[1];
	    texSet->ObjectPlaneT[2] = params[2];
	    texSet->ObjectPlaneT[3] = params[3];
d779 1
a779 1
            gl_transform_vector( texSet->EyePlaneT, params,
d792 1
a792 1
	       texSet->GenModeR = mode;
d800 4
a803 4
	    texSet->ObjectPlaneR[0] = params[0];
	    texSet->ObjectPlaneR[1] = params[1];
	    texSet->ObjectPlaneR[2] = params[2];
	    texSet->ObjectPlaneR[3] = params[3];
d810 1
a810 1
            gl_transform_vector( texSet->EyePlaneR, params,
d823 1
a823 1
	       texSet->GenModeQ = mode;
d831 4
a834 4
	    texSet->ObjectPlaneQ[0] = params[0];
	    texSet->ObjectPlaneQ[1] = params[1];
	    texSet->ObjectPlaneQ[2] = params[2];
	    texSet->ObjectPlaneQ[3] = params[3];
d841 1
a841 1
            gl_transform_vector( texSet->EyePlaneQ, params,
d862 2
a863 2
   GLuint tSet = ctx->Texture.CurrentTransformSet;
   struct gl_texture_set *texSet = &ctx->Texture.Set[tSet];
d872 1
a872 1
            params[0] = ENUM_TO_DOUBLE(texSet->GenModeS);
d875 1
a875 1
            COPY_4V( params, texSet->ObjectPlaneS );
d878 1
a878 1
            COPY_4V( params, texSet->EyePlaneS );
d887 1
a887 1
            params[0] = ENUM_TO_DOUBLE(texSet->GenModeT);
d890 1
a890 1
            COPY_4V( params, texSet->ObjectPlaneT );
d893 1
a893 1
            COPY_4V( params, texSet->EyePlaneT );
d902 1
a902 1
            params[0] = ENUM_TO_DOUBLE(texSet->GenModeR);
d905 1
a905 1
            COPY_4V( params, texSet->ObjectPlaneR );
d908 1
a908 1
            COPY_4V( params, texSet->EyePlaneR );
d917 1
a917 1
            params[0] = ENUM_TO_DOUBLE(texSet->GenModeQ);
d920 1
a920 1
            COPY_4V( params, texSet->ObjectPlaneQ );
d923 1
a923 1
            COPY_4V( params, texSet->EyePlaneQ );
d941 2
a942 2
   GLuint tSet = ctx->Texture.CurrentTransformSet;
   struct gl_texture_set *texSet = &ctx->Texture.Set[tSet];
d951 1
a951 1
            params[0] = ENUM_TO_FLOAT(texSet->GenModeS);
d954 1
a954 1
            COPY_4V( params, texSet->ObjectPlaneS );
d957 1
a957 1
            COPY_4V( params, texSet->EyePlaneS );
d966 1
a966 1
            params[0] = ENUM_TO_FLOAT(texSet->GenModeT);
d969 1
a969 1
            COPY_4V( params, texSet->ObjectPlaneT );
d972 1
a972 1
            COPY_4V( params, texSet->EyePlaneT );
d981 1
a981 1
            params[0] = ENUM_TO_FLOAT(texSet->GenModeR);
d984 1
a984 1
            COPY_4V( params, texSet->ObjectPlaneR );
d987 1
a987 1
            COPY_4V( params, texSet->EyePlaneR );
d996 1
a996 1
            params[0] = ENUM_TO_FLOAT(texSet->GenModeQ);
d999 1
a999 1
            COPY_4V( params, texSet->ObjectPlaneQ );
d1002 1
a1002 1
            COPY_4V( params, texSet->EyePlaneQ );
d1020 2
a1021 2
   GLuint tSet = ctx->Texture.CurrentTransformSet;
   struct gl_texture_set *texSet = &ctx->Texture.Set[tSet];
d1030 1
a1030 1
            params[0] = texSet->GenModeS;
d1033 1
a1033 1
            COPY_4V( params, (GLint) texSet->ObjectPlaneS );
d1036 1
a1036 1
            COPY_4V( params, (GLint) texSet->EyePlaneS );
d1045 1
a1045 1
            params[0] = texSet->GenModeT;
d1048 1
a1048 1
            COPY_4V( params, (GLint) texSet->ObjectPlaneT );
d1051 1
a1051 1
            COPY_4V( params, (GLint) texSet->EyePlaneT );
d1060 1
a1060 1
            params[0] = texSet->GenModeR;
d1063 1
a1063 1
            COPY_4V( params, (GLint) texSet->ObjectPlaneR );
d1066 1
a1066 1
            COPY_4V( params, (GLint) texSet->EyePlaneR );
d1075 1
a1075 1
            params[0] = texSet->GenModeQ;
d1078 1
a1078 1
            COPY_4V( params, (GLint) texSet->ObjectPlaneQ );
d1081 1
a1081 1
            COPY_4V( params, (GLint) texSet->EyePlaneQ );
d1099 6
a1104 7
   GLint texSet;
   GLint maxSets = ctx->Const.MaxTextureUnits;
   if (target >= GL_TEXTURE0_SGIS && target < GL_TEXTURE0_SGIS + maxSets) {
      texSet = target - GL_TEXTURE0_SGIS;
      /* Select current texture env AND transformation set! */
      ctx->Texture.CurrentSet = texSet;
      ctx->Texture.CurrentTransformSet = texSet;
a1107 1
      return;
d1115 5
a1119 4
   GLint texSet;
   GLint maxSets = ctx->Const.MaxTextureUnits;
   if (target >= GL_TEXTURE0_SGIS && target < GL_TEXTURE0_SGIS + maxSets) {
      texSet = target - GL_TEXTURE0_SGIS;
d1122 1
a1122 2
      gl_error(ctx, GL_INVALID_OPERATION, "glSelectTextureCoordSet(target)");
      return;
a1123 2
   ctx->TexCoordSet = texSet;
   ctx->Current.TexCoord = ctx->Current.MultiTexCoord[texSet];
a1129 1
   GLint texUnit;
d1132 5
a1136 1
      texUnit = target - GL_TEXTURE0_ARB;
a1139 1
      return;
a1140 4
   ctx->TexCoordSet = texUnit;
   ctx->Texture.CurrentSet = texUnit;
   ctx->Texture.CurrentTransformSet = texUnit;
   ctx->Current.TexCoord = ctx->Current.MultiTexCoord[0];  /* always 0 */
a1146 1
   GLint texUnit;
d1149 2
a1150 1
      texUnit = target - GL_TEXTURE0_ARB;
a1153 1
      return;
a1154 1
   ctx->Array.ActiveTexture = texUnit;
d1161 1
a1161 1
 * ctx->NewState is set.
d1189 1
a1189 1
   if (ctx->Texture.Enabled & TEXTURE0_3D && ctx->Texture.Set[0].Current3D->Complete) {
d1191 1
a1191 1
      ctx->Texture.Set[0].Current = ctx->Texture.Set[0].Current3D;
d1193 1
a1193 1
   else if (ctx->Texture.Enabled & TEXTURE0_2D && ctx->Texture.Set[0].Current2D->Complete) {
d1195 1
a1195 1
      ctx->Texture.Set[0].Current = ctx->Texture.Set[0].Current2D;
d1197 1
a1197 1
   else if (ctx->Texture.Enabled & TEXTURE0_1D && ctx->Texture.Set[0].Current1D->Complete) {
d1199 1
a1199 1
      ctx->Texture.Set[0].Current = ctx->Texture.Set[0].Current1D;
d1202 1
a1202 1
      ctx->Texture.Set[0].Current = NULL;
d1206 1
a1206 1
      if (ctx->Texture.Enabled & TEXTURE1_3D && ctx->Texture.Set[1].Current3D->Complete) {
d1208 1
a1208 1
         ctx->Texture.Set[1].Current = ctx->Texture.Set[1].Current3D;
d1210 1
a1210 1
      else if (ctx->Texture.Enabled & TEXTURE1_2D && ctx->Texture.Set[1].Current2D->Complete) {
d1212 1
a1212 1
         ctx->Texture.Set[1].Current = ctx->Texture.Set[1].Current2D;
d1214 1
a1214 1
      else if (ctx->Texture.Enabled & TEXTURE1_1D && ctx->Texture.Set[1].Current1D->Complete) {
d1216 1
a1216 1
         ctx->Texture.Set[1].Current = ctx->Texture.Set[1].Current1D;
d1219 1
a1219 1
         ctx->Texture.Set[1].Current = NULL;
@


3.14
log
@added Texture.ReallyEnabled to simply testing for enabled textures
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.13 1998/10/31 17:07:46 brianp Exp brianp $ */
d26 3
d1128 33
a1170 1
   GLuint texSet;
@


3.13
log
@variety of multi-texture changes
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.12 1998/10/20 02:27:56 brianp Exp brianp $ */
d26 3
a1136 12
   for (texSet=0; texSet<ctx->Const.MaxTextureUnits; texSet++) {
      GLuint setShift = texSet * 4;
      if (ctx->Texture.Enabled & (TEXTURE0_3D << setShift))
         ctx->Texture.Set[texSet].Current = ctx->Texture.Set[texSet].Current3D;
      else if (ctx->Texture.Enabled & (TEXTURE0_2D << setShift))
         ctx->Texture.Set[texSet].Current = ctx->Texture.Set[texSet].Current2D;
      else if (ctx->Texture.Enabled & (TEXTURE0_1D << setShift))
         ctx->Texture.Set[texSet].Current = ctx->Texture.Set[texSet].Current1D;
      else
         ctx->Texture.Set[texSet].Current = NULL;
   }

d1146 45
@


3.12
log
@removed GL_EXT_multitexture extension
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.11 1998/08/21 01:50:14 brianp Exp brianp $ */
d26 3
a95 16
/*
 * Return max number of simultaneous textures.
 */
GLint gl_max_texture_coord_sets( const GLcontext *ctx )
{
   if (ctx->Driver.GetParameteri) {
      GLint maxCoordSets = (*ctx->Driver.GetParameteri)(ctx, DD_MAX_TEXTURE_COORD_SETS);
      assert(maxCoordSets >= 1 && maxCoordSets <= MAX_TEX_COORD_SETS);
      return maxCoordSets;
   }
   else {
      return MAX_TEX_COORD_SETS;
   }
}


d345 1
a345 1
   if (level<0 || level>=MAX_TEXTURE_LEVELS) {
d1091 1
a1091 1
   GLint maxSets = gl_max_texture_coord_sets(ctx);
d1109 1
a1109 1
   GLint maxSets = gl_max_texture_coord_sets(ctx);
d1134 1
a1134 1
   for (texSet=0; texSet<MAX_TEX_SETS; texSet++) {
d1149 1
a1149 1
            gl_test_texture_object_completeness(t);
@


3.11
log
@made max_texture_coord_sets() non-static
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.10 1998/07/18 03:35:28 brianp Exp brianp $ */
d5 1
a5 1
 * Version:  3.0
d26 3
a152 10
   else if (pname==GL_TEXTURE_ENV_COORD_SET_EXT) {
      GLint p = (GLint) param[0] - GL_TEXTURE0_EXT;
      if (p >= 0 && p < gl_max_texture_coord_sets(ctx)) {
         texSet->TexCoordSet = p;
      }
      else {
         gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" );
         return;
      }
   }
a182 2
      case GL_TEXTURE_ENV_COORD_SET_EXT:
         params[0] = (GLfloat) (GL_TEXTURE0_EXT + texSet->TexCoordSet);
a206 2
      case GL_TEXTURE_ENV_COORD_SET_EXT:
         params[0] = GL_TEXTURE0_EXT + texSet->TexCoordSet;
d748 2
a749 2
            if (ctx->NewModelViewMatrix) {
               gl_analyze_modelview_matrix(ctx);
d752 1
a752 1
                                 ctx->ModelViewInv );
d780 2
a781 2
            if (ctx->NewModelViewMatrix) {
               gl_analyze_modelview_matrix(ctx);
d784 1
a784 1
                                 ctx->ModelViewInv );
d811 2
a812 2
            if (ctx->NewModelViewMatrix) {
               gl_analyze_modelview_matrix(ctx);
d815 1
a815 1
                                 ctx->ModelViewInv );
d842 2
a843 2
            if (ctx->NewModelViewMatrix) {
               gl_analyze_modelview_matrix(ctx);
d846 1
a846 1
                                 ctx->ModelViewInv );
d1118 1
a1118 18
/* GL_EXT_multitexture */
void gl_SelectTexture( GLcontext *ctx, GLenum target )
{
   GLint texSet;
   GLint maxSets = gl_max_texture_coord_sets(ctx);
   if (target >= GL_TEXTURE0_EXT && target < GL_TEXTURE0_EXT + maxSets) {
      texSet = target - GL_TEXTURE0_EXT;
   }
   else {
      gl_error(ctx, GL_INVALID_OPERATION, "glSelectTexture(target)");
      return;
   }
   ctx->Texture.CurrentSet = texSet;
}



/* GL_SGIS_multitexture / GL_EXT_multitexture */
a1125 3
   else if (target >= GL_TEXTURE0_EXT && target < GL_TEXTURE0_EXT + maxSets) {
      texSet = target - GL_TEXTURE0_EXT;
   }
a1133 16


/* GL_EXT_multitexture */
void gl_SelectTextureTransform( GLcontext *ctx, GLenum target )
{
   GLint texSet;
   GLint maxSets = gl_max_texture_coord_sets(ctx);
   if (target >= GL_TEXTURE0_EXT && target < GL_TEXTURE0_EXT + maxSets) {
      texSet = target - GL_TEXTURE0_EXT;
      ctx->Texture.CurrentTransformSet = texSet;
   }
   else {
      gl_error(ctx, GL_INVALID_ENUM, "glSelectTextureTransform(target)");
      return;
   }
}
@


3.10
log
@get of GL_TEXTURE_INTERNAL_FORMAT wasn't handled
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.9 1998/06/17 01:21:06 brianp Exp brianp $ */
d26 3
d93 1
a93 1
static GLint max_texture_coord_sets( const GLcontext *ctx )
d152 1
a152 1
      if (p >= 0 && p < max_texture_coord_sets(ctx)) {
d1115 1
a1115 1
   GLint maxSets = max_texture_coord_sets(ctx);
d1133 1
a1133 1
   GLint maxSets = max_texture_coord_sets(ctx);
d1150 1
a1150 1
   GLint maxSets = max_texture_coord_sets(ctx);
d1171 1
a1171 1
   GLint maxSets = max_texture_coord_sets(ctx);
@


3.9
log
@include assert.h
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.8 1998/06/07 22:18:52 brianp Exp brianp $ */
d26 3
d113 1
d137 1
a137 1
	    gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
d374 2
d381 2
a382 1
	       *params = tex->Format;
d405 2
d415 2
a416 1
	       *params = tex->Format;
d439 2
d452 2
a453 1
               *params = tex->Format;
d468 2
d475 2
a476 1
	       *params = tex->Format;
d499 2
d509 2
a510 1
	       *params = tex->Format;
d533 2
d546 2
a547 1
	       *params = tex->Format;
@


3.8
log
@implemented GL_EXT_multitexture extension
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.7 1998/04/20 23:55:13 brianp Exp brianp $ */
d26 3
d59 1
@


3.7
log
@applied DavidB's changes for v0.25 of 3Dfx driver
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.6 1998/03/27 04:17:31 brianp Exp brianp $ */
d26 3
d80 17
d139 10
d179 2
d192 1
a192 1
      gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(target)" );
d205 2
d208 1
a208 1
         gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)" );
d701 2
a702 1
   struct gl_texture_set *texSet = &ctx->Texture.Set[ctx->Texture.CurrentSet];
d848 2
a849 1
   struct gl_texture_set *texSet = &ctx->Texture.Set[ctx->Texture.CurrentSet];
d927 2
a928 1
   struct gl_texture_set *texSet = &ctx->Texture.Set[ctx->Texture.CurrentSet];
d1006 2
a1007 1
   struct gl_texture_set *texSet = &ctx->Texture.Set[ctx->Texture.CurrentSet];
d1083 18
d1104 5
a1108 1
   if (target < GL_TEXTURE0_SGIS || target > GL_TEXTURE1_SGIS) {
a1111 1
   texSet = target - GL_TEXTURE0_SGIS;
a1112 1
   /* XXX  ctx->Texture.Set = ctx->Texture.Sets[texSet];*/
d1117 1
a1117 1
/* GL_SGIS_multitexture */
d1121 8
a1128 1
   if (target < GL_TEXTURE0_SGIS || target > GL_TEXTURE1_SGIS) {
d1132 1
a1132 2
   texSet = target - GL_TEXTURE0_SGIS;
   ctx->Texture.CurrentCoordSet = texSet;
d1134 17
a1150 1
   ctx->Current.RasterTexCoord = ctx->Current.RasterMultiTexCoord[texSet];
@


3.6
log
@fixed G++ warnings
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.5 1998/03/15 17:55:03 brianp Exp brianp $ */
d26 3
d103 3
d210 4
d228 4
@


3.5
log
@fixed a typo in gl_update_texture_state()
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.4 1998/02/20 04:53:37 brianp Exp brianp $ */
d26 3
d967 1
a967 1
            COPY_4V( params, texSet->ObjectPlaneS );
d970 1
a970 1
            COPY_4V( params, texSet->EyePlaneS );
d982 1
a982 1
            COPY_4V( params, texSet->ObjectPlaneT );
d985 1
a985 1
            COPY_4V( params, texSet->EyePlaneT );
d997 1
a997 1
            COPY_4V( params, texSet->ObjectPlaneR );
d1000 1
a1000 1
            COPY_4V( params, texSet->EyePlaneR );
d1012 1
a1012 1
            COPY_4V( params, texSet->ObjectPlaneQ );
d1015 1
a1015 1
            COPY_4V( params, texSet->EyePlaneQ );
@


3.4
log
@implemented GL_SGIS_multitexture
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.3 1998/02/04 05:00:07 brianp Exp brianp $ */
d26 3
d1074 1
a1074 1
      else if (ctx->Texture.Enabled & (TEXTURE0_1D && setShift))
@


3.3
log
@added a few casts for Amiga StormC compiler
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.2 1998/02/03 04:27:54 brianp Exp brianp $ */
d26 3
d76 1
d94 1
a94 1
	    ctx->Texture.EnvMode = mode;
d102 4
a105 4
      ctx->Texture.EnvColor[0] = CLAMP( param[0], 0.0, 1.0 );
      ctx->Texture.EnvColor[1] = CLAMP( param[1], 0.0, 1.0 );
      ctx->Texture.EnvColor[2] = CLAMP( param[2], 0.0, 1.0 );
      ctx->Texture.EnvColor[3] = CLAMP( param[3], 0.0, 1.0 );
d125 1
d132 1
a132 1
         *params = ENUM_TO_FLOAT(ctx->Texture.EnvMode);
d135 1
a135 1
	 COPY_4V( params, ctx->Texture.EnvColor );
d146 1
d153 1
a153 1
         *params = (GLint) ctx->Texture.EnvMode;
d156 4
a159 4
	 params[0] = FLOAT_TO_INT( ctx->Texture.EnvColor[0] );
	 params[1] = FLOAT_TO_INT( ctx->Texture.EnvColor[1] );
	 params[2] = FLOAT_TO_INT( ctx->Texture.EnvColor[2] );
	 params[3] = FLOAT_TO_INT( ctx->Texture.EnvColor[3] );
d177 1
d183 1
a183 1
         texObj = ctx->Texture.Current1D;
d186 1
a186 1
         texObj = ctx->Texture.Current2D;
d189 1
a189 1
         texObj = ctx->Texture.Current3D;
a291 1

d301 1
d311 1
a311 1
         tex = ctx->Texture.Current1D->Image[level];
d339 1
a339 1
         tex = ctx->Texture.Current2D->Image[level];
d370 1
a370 1
         tex = ctx->Texture.Current3D->Image[level];
d499 1
d504 1
a504 1
         obj = ctx->Texture.Current1D;
d507 1
a507 1
         obj = ctx->Texture.Current2D;
d510 1
a510 1
         obj = ctx->Texture.Current3D;
d543 1
a543 1
         *params = ctx->Texture.Current1D->Priority;
d566 1
d571 1
a571 1
         obj = ctx->Texture.Current1D;
d574 1
a574 1
         obj = ctx->Texture.Current2D;
d577 1
a577 1
         obj = ctx->Texture.Current3D;
d647 1
d660 1
a660 1
	       ctx->Texture.GenModeS = mode;
d668 4
a671 4
	    ctx->Texture.ObjectPlaneS[0] = params[0];
	    ctx->Texture.ObjectPlaneS[1] = params[1];
	    ctx->Texture.ObjectPlaneS[2] = params[2];
	    ctx->Texture.ObjectPlaneS[3] = params[3];
d678 1
a678 1
            gl_transform_vector( ctx->Texture.EyePlaneS, params,
d692 1
a692 1
	       ctx->Texture.GenModeT = mode;
d700 4
a703 4
	    ctx->Texture.ObjectPlaneT[0] = params[0];
	    ctx->Texture.ObjectPlaneT[1] = params[1];
	    ctx->Texture.ObjectPlaneT[2] = params[2];
	    ctx->Texture.ObjectPlaneT[3] = params[3];
d710 1
a710 1
            gl_transform_vector( ctx->Texture.EyePlaneT, params,
d723 1
a723 1
	       ctx->Texture.GenModeR = mode;
d731 4
a734 4
	    ctx->Texture.ObjectPlaneR[0] = params[0];
	    ctx->Texture.ObjectPlaneR[1] = params[1];
	    ctx->Texture.ObjectPlaneR[2] = params[2];
	    ctx->Texture.ObjectPlaneR[3] = params[3];
d741 1
a741 1
            gl_transform_vector( ctx->Texture.EyePlaneR, params,
d754 1
a754 1
	       ctx->Texture.GenModeQ = mode;
d762 4
a765 4
	    ctx->Texture.ObjectPlaneQ[0] = params[0];
	    ctx->Texture.ObjectPlaneQ[1] = params[1];
	    ctx->Texture.ObjectPlaneQ[2] = params[2];
	    ctx->Texture.ObjectPlaneQ[3] = params[3];
d772 1
a772 1
            gl_transform_vector( ctx->Texture.EyePlaneQ, params,
d793 1
d802 1
a802 1
            params[0] = ENUM_TO_DOUBLE(ctx->Texture.GenModeS);
d805 1
a805 1
            COPY_4V( params, ctx->Texture.ObjectPlaneS );
d808 1
a808 1
            COPY_4V( params, ctx->Texture.EyePlaneS );
d817 1
a817 1
            params[0] = ENUM_TO_DOUBLE(ctx->Texture.GenModeT);
d820 1
a820 1
            COPY_4V( params, ctx->Texture.ObjectPlaneT );
d823 1
a823 1
            COPY_4V( params, ctx->Texture.EyePlaneT );
d832 1
a832 1
            params[0] = ENUM_TO_DOUBLE(ctx->Texture.GenModeR);
d835 1
a835 1
            COPY_4V( params, ctx->Texture.ObjectPlaneR );
d838 1
a838 1
            COPY_4V( params, ctx->Texture.EyePlaneR );
d847 1
a847 1
            params[0] = ENUM_TO_DOUBLE(ctx->Texture.GenModeQ);
d850 1
a850 1
            COPY_4V( params, ctx->Texture.ObjectPlaneQ );
d853 1
a853 1
            COPY_4V( params, ctx->Texture.EyePlaneQ );
d871 1
d880 1
a880 1
            params[0] = ENUM_TO_FLOAT(ctx->Texture.GenModeS);
d883 1
a883 1
            COPY_4V( params, ctx->Texture.ObjectPlaneS );
d886 1
a886 1
            COPY_4V( params, ctx->Texture.EyePlaneS );
d895 1
a895 1
            params[0] = ENUM_TO_FLOAT(ctx->Texture.GenModeT);
d898 1
a898 1
            COPY_4V( params, ctx->Texture.ObjectPlaneT );
d901 1
a901 1
            COPY_4V( params, ctx->Texture.EyePlaneT );
d910 1
a910 1
            params[0] = ENUM_TO_FLOAT(ctx->Texture.GenModeR);
d913 1
a913 1
            COPY_4V( params, ctx->Texture.ObjectPlaneR );
d916 1
a916 1
            COPY_4V( params, ctx->Texture.EyePlaneR );
d925 1
a925 1
            params[0] = ENUM_TO_FLOAT(ctx->Texture.GenModeQ);
d928 1
a928 1
            COPY_4V( params, ctx->Texture.ObjectPlaneQ );
d931 1
a931 1
            COPY_4V( params, ctx->Texture.EyePlaneQ );
d949 1
d958 1
a958 1
            params[0] = ctx->Texture.GenModeS;
d961 1
a961 1
            COPY_4V( params, ctx->Texture.ObjectPlaneS );
d964 1
a964 1
            COPY_4V( params, ctx->Texture.EyePlaneS );
d973 1
a973 1
            params[0] = ctx->Texture.GenModeT;
d976 1
a976 1
            COPY_4V( params, ctx->Texture.ObjectPlaneT );
d979 1
a979 1
            COPY_4V( params, ctx->Texture.EyePlaneT );
d988 1
a988 1
            params[0] = ctx->Texture.GenModeR;
d991 1
a991 1
            COPY_4V( params, ctx->Texture.ObjectPlaneR );
d994 1
a994 1
            COPY_4V( params, ctx->Texture.EyePlaneR );
d1003 1
a1003 1
            params[0] = ctx->Texture.GenModeQ;
d1006 1
a1006 1
            COPY_4V( params, ctx->Texture.ObjectPlaneQ );
d1009 1
a1009 1
            COPY_4V( params, ctx->Texture.EyePlaneQ );
d1024 32
d1063 1
d1065 11
a1075 8
   if (ctx->Texture.Enabled & TEXTURE_3D)
      ctx->Texture.Current = ctx->Texture.Current3D;
   else if (ctx->Texture.Enabled & TEXTURE_2D)
      ctx->Texture.Current = ctx->Texture.Current2D;
   else if (ctx->Texture.Enabled & TEXTURE_1D)
      ctx->Texture.Current = ctx->Texture.Current1D;
   else
      ctx->Texture.Current = NULL;
@


3.2
log
@added texture lod clamping
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.1 1998/02/01 19:39:09 brianp Exp brianp $ */
d26 3
d53 12
a69 1

d127 1
a127 1
         *params = (GLfloat) ctx->Texture.EnvMode;
d511 1
a511 1
	 *params = (GLfloat) obj->MagFilter;
d514 1
a514 1
         *params = (GLfloat) obj->MinFilter;
d517 1
a517 1
         *params = (GLfloat) obj->WrapS;
d520 1
a520 1
         *params = (GLfloat) obj->WrapT;
d523 1
a523 1
         *params = (GLfloat) obj->WrapR;
d532 1
a532 1
         *params = (GLfloat) GL_TRUE;
d791 1
a791 1
            params[0] = ctx->Texture.GenModeS;
d806 1
a806 1
            params[0] = ctx->Texture.GenModeT;
d821 1
a821 1
            params[0] = ctx->Texture.GenModeR;
d836 1
a836 1
            params[0] = ctx->Texture.GenModeQ;
d868 1
a868 1
            params[0] = ctx->Texture.GenModeS;
d883 1
a883 1
            params[0] = ctx->Texture.GenModeT;
d898 1
a898 1
            params[0] = ctx->Texture.GenModeR;
d913 1
a913 1
            params[0] = ctx->Texture.GenModeQ;
@


3.1
log
@added GL_CLAMP_TO_EDGE texture wrap mode
@
text
@d1 1
a1 1
/* $Id: texstate.c,v 3.0 1998/01/31 21:04:38 brianp Exp brianp $ */
d26 3
d232 20
d478 2
d482 1
a482 28
         switch (pname) {
	    case GL_TEXTURE_MAG_FILTER:
	       *params = (GLfloat) ctx->Texture.Current1D->MagFilter;
	       break;
	    case GL_TEXTURE_MIN_FILTER:
	       *params = (GLfloat) ctx->Texture.Current1D->MinFilter;
	       break;
	    case GL_TEXTURE_WRAP_S:
	       *params = (GLfloat) ctx->Texture.Current1D->WrapS;
	       break;
	    case GL_TEXTURE_WRAP_T:
	       *params = (GLfloat) ctx->Texture.Current1D->WrapT;
	       break;
	    case GL_TEXTURE_BORDER_COLOR:
               params[0] = ctx->Texture.Current1D->BorderColor[0] / 255.0f;
               params[1] = ctx->Texture.Current1D->BorderColor[1] / 255.0f;
               params[2] = ctx->Texture.Current1D->BorderColor[2] / 255.0f;
               params[3] = ctx->Texture.Current1D->BorderColor[3] / 255.0f;
	       break;
	    case GL_TEXTURE_RESIDENT:
               *params = (GLfloat) GL_TRUE;
	       break;
            case GL_TEXTURE_PRIORITY:
               *params = ctx->Texture.Current1D->Priority;
	       break;
	    default:
	       gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameterfv(pname)" );
	 }
d485 13
a497 28
         switch (pname) {
	    case GL_TEXTURE_MAG_FILTER:
	       *params = (GLfloat) ctx->Texture.Current2D->MagFilter;
	       break;
	    case GL_TEXTURE_MIN_FILTER:
	       *params = (GLfloat) ctx->Texture.Current2D->MinFilter;
	       break;
	    case GL_TEXTURE_WRAP_S:
	       *params = (GLfloat) ctx->Texture.Current2D->WrapS;
	       break;
	    case GL_TEXTURE_WRAP_T:
	       *params = (GLfloat) ctx->Texture.Current2D->WrapT;
	       break;
	    case GL_TEXTURE_BORDER_COLOR:
               params[0] = ctx->Texture.Current2D->BorderColor[0] / 255.0f;
               params[1] = ctx->Texture.Current2D->BorderColor[1] / 255.0f;
               params[2] = ctx->Texture.Current2D->BorderColor[2] / 255.0f;
               params[3] = ctx->Texture.Current2D->BorderColor[3] / 255.0f;
               break;
	    case GL_TEXTURE_RESIDENT:
               *params = (GLfloat) GL_TRUE;
	       break;
	    case GL_TEXTURE_PRIORITY:
               *params = ctx->Texture.Current2D->Priority;
	       break;
	    default:
	       gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameterfv(pname)" );
	 }
d499 35
a533 32
      case GL_TEXTURE_3D_EXT:
         switch (pname) {
            case GL_TEXTURE_MAG_FILTER:
               *params = (GLfloat) ctx->Texture.Current3D->MagFilter;
               break;
            case GL_TEXTURE_MIN_FILTER:
               *params = (GLfloat) ctx->Texture.Current3D->MinFilter;
               break;
            case GL_TEXTURE_WRAP_S:
               *params = (GLfloat) ctx->Texture.Current3D->WrapS;
               break;
            case GL_TEXTURE_WRAP_T:
               *params = (GLfloat) ctx->Texture.Current3D->WrapT;
               break;
            case GL_TEXTURE_WRAP_R_EXT:
               *params = (GLfloat) ctx->Texture.Current3D->WrapR;
               break;
            case GL_TEXTURE_BORDER_COLOR:
               params[0] = ctx->Texture.Current3D->BorderColor[0] / 255.0f;
               params[1] = ctx->Texture.Current3D->BorderColor[1] / 255.0f;
               params[2] = ctx->Texture.Current3D->BorderColor[2] / 255.0f;
               params[3] = ctx->Texture.Current3D->BorderColor[3] / 255.0f;
               break;
            case GL_TEXTURE_RESIDENT:
               *params = (GLfloat) GL_TRUE;
               break;
            case GL_TEXTURE_PRIORITY:
               *params = ctx->Texture.Current3D->Priority;
               break;
            default:
               gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameterfv(pname)" );
         }
d536 1
a536 1
         gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameterfv(target)" );
d544 2
d548 1
a548 35
         switch (pname) {
	    case GL_TEXTURE_MAG_FILTER:
	       *params = (GLint) ctx->Texture.Current1D->MagFilter;
	       break;
	    case GL_TEXTURE_MIN_FILTER:
	       *params = (GLint) ctx->Texture.Current1D->MinFilter;
	       break;
	    case GL_TEXTURE_WRAP_S:
	       *params = (GLint) ctx->Texture.Current1D->WrapS;
	       break;
	    case GL_TEXTURE_WRAP_T:
	       *params = (GLint) ctx->Texture.Current1D->WrapT;
	       break;
	    case GL_TEXTURE_BORDER_COLOR:
               {
                  GLfloat color[4];
                  color[0] = ctx->Texture.Current1D->BorderColor[0]/255.0;
                  color[1] = ctx->Texture.Current1D->BorderColor[1]/255.0;
                  color[2] = ctx->Texture.Current1D->BorderColor[2]/255.0;
                  color[3] = ctx->Texture.Current1D->BorderColor[3]/255.0;
                  params[0] = FLOAT_TO_INT( color[0] );
                  params[1] = FLOAT_TO_INT( color[1] );
                  params[2] = FLOAT_TO_INT( color[2] );
                  params[3] = FLOAT_TO_INT( color[3] );
               }
	       break;
	    case GL_TEXTURE_RESIDENT:
               *params = (GLint) GL_TRUE;
	       break;
	    case GL_TEXTURE_PRIORITY:
               *params = (GLint) ctx->Texture.Current1D->Priority;
	       break;
	    default:
	       gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameteriv(pname)" );
	 }
d551 2
a552 36
         switch (pname) {
	    case GL_TEXTURE_MAG_FILTER:
	       *params = (GLint) ctx->Texture.Current2D->MagFilter;
	       break;
	    case GL_TEXTURE_MIN_FILTER:
	       *params = (GLint) ctx->Texture.Current2D->MinFilter;
	       break;
	    case GL_TEXTURE_WRAP_S:
	       *params = (GLint) ctx->Texture.Current2D->WrapS;
	       break;
	    case GL_TEXTURE_WRAP_T:
	       *params = (GLint) ctx->Texture.Current2D->WrapT;
	       break;
	    case GL_TEXTURE_BORDER_COLOR:
               {
                  GLfloat color[4];
                  color[0] = ctx->Texture.Current2D->BorderColor[0]/255.0;
                  color[1] = ctx->Texture.Current2D->BorderColor[1]/255.0;
                  color[2] = ctx->Texture.Current2D->BorderColor[2]/255.0;
                  color[3] = ctx->Texture.Current2D->BorderColor[3]/255.0;
                  params[0] = FLOAT_TO_INT( color[0] );
                  params[1] = FLOAT_TO_INT( color[1] );
                  params[2] = FLOAT_TO_INT( color[2] );
                  params[3] = FLOAT_TO_INT( color[3] );
               }
	       break;
	    case GL_TEXTURE_RESIDENT:
               *params = (GLint) GL_TRUE;
	       break;
	    case GL_TEXTURE_PRIORITY:
               *params = (GLint) ctx->Texture.Current2D->Priority;
	       break;
	    default:
	       gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameteriv(pname)" );
	 }
	 break;
d554 53
a606 38
         switch (pname) {
            case GL_TEXTURE_MAG_FILTER:
               *params = (GLint) ctx->Texture.Current3D->MagFilter;
               break;
            case GL_TEXTURE_MIN_FILTER:
               *params = (GLint) ctx->Texture.Current3D->MinFilter;
               break;
            case GL_TEXTURE_WRAP_S:
               *params = (GLint) ctx->Texture.Current3D->WrapS;
               break;
            case GL_TEXTURE_WRAP_T:
               *params = (GLint) ctx->Texture.Current3D->WrapT;
               break;
            case GL_TEXTURE_WRAP_R_EXT:
               *params = (GLint) ctx->Texture.Current3D->WrapR;
               break;
            case GL_TEXTURE_BORDER_COLOR:
               {
                  GLfloat color[4];
                  color[0] = ctx->Texture.Current3D->BorderColor[0]/255.0;
                  color[1] = ctx->Texture.Current3D->BorderColor[1]/255.0;
                  color[2] = ctx->Texture.Current3D->BorderColor[2]/255.0;
                  color[3] = ctx->Texture.Current3D->BorderColor[3]/255.0;
                  params[0] = FLOAT_TO_INT( color[0] );
                  params[1] = FLOAT_TO_INT( color[1] );
                  params[2] = FLOAT_TO_INT( color[2] );
                  params[3] = FLOAT_TO_INT( color[3] );
               }
               break;
            case GL_TEXTURE_RESIDENT:
               *params = (GLint) GL_TRUE;
               break;
            case GL_TEXTURE_PRIORITY:
               *params = (GLint) ctx->Texture.Current3D->Priority;
               break;
            default:
               gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameteriv(pname)" );
         }
d609 1
a609 1
         gl_error( ctx, GL_INVALID_ENUM, "glGetTexParameteriv(target)" );
@


3.0
log
@initial rev
@
text
@d1 1
a1 1
/* $Id$ */
d25 4
a28 1
 * $Log$
d198 1
a198 1
         if (eparam==GL_CLAMP || eparam==GL_REPEAT) {
d207 1
a207 1
         if (eparam==GL_CLAMP || eparam==GL_REPEAT) {
d216 1
a216 1
         if (eparam==GL_CLAMP || eparam==GL_REPEAT) {
@
