17117f1b4Smrg/**
27117f1b4Smrg * \file texstate.h
37117f1b4Smrg * Texture state management.
47117f1b4Smrg */
57117f1b4Smrg
67117f1b4Smrg/*
77117f1b4Smrg * Mesa 3-D graphics library
87117f1b4Smrg *
9c1f859d4Smrg * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
107117f1b4Smrg *
117117f1b4Smrg * Permission is hereby granted, free of charge, to any person obtaining a
127117f1b4Smrg * copy of this software and associated documentation files (the "Software"),
137117f1b4Smrg * to deal in the Software without restriction, including without limitation
147117f1b4Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
157117f1b4Smrg * and/or sell copies of the Software, and to permit persons to whom the
167117f1b4Smrg * Software is furnished to do so, subject to the following conditions:
177117f1b4Smrg *
187117f1b4Smrg * The above copyright notice and this permission notice shall be included
197117f1b4Smrg * in all copies or substantial portions of the Software.
207117f1b4Smrg *
217117f1b4Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
227117f1b4Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
237117f1b4Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
24af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25af69d88dSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26af69d88dSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27af69d88dSmrg * OTHER DEALINGS IN THE SOFTWARE.
287117f1b4Smrg */
297117f1b4Smrg
307117f1b4Smrg
317117f1b4Smrg#ifndef TEXSTATE_H
327117f1b4Smrg#define TEXSTATE_H
337117f1b4Smrg
347117f1b4Smrg
3501e04c3fSmrg#include "enums.h"
3601e04c3fSmrg#include "macros.h"
377117f1b4Smrg#include "mtypes.h"
387117f1b4Smrg
397117f1b4Smrg
4001e04c3fSmrgstatic inline struct gl_texture_unit *
4101e04c3fSmrg_mesa_get_tex_unit(struct gl_context *ctx, GLuint unit)
4201e04c3fSmrg{
4301e04c3fSmrg   assert(unit < ARRAY_SIZE(ctx->Texture.Unit));
4401e04c3fSmrg   return &(ctx->Texture.Unit[unit]);
4501e04c3fSmrg}
4601e04c3fSmrg
474a49301eSmrg/**
484a49301eSmrg * Return pointer to current texture unit.
494a49301eSmrg * This the texture unit set by glActiveTexture(), not glClientActiveTexture().
504a49301eSmrg */
51af69d88dSmrgstatic inline struct gl_texture_unit *
523464ebd5Sriastradh_mesa_get_current_tex_unit(struct gl_context *ctx)
534a49301eSmrg{
5401e04c3fSmrg   return _mesa_get_tex_unit(ctx, ctx->Texture.CurrentUnit);
5501e04c3fSmrg}
5601e04c3fSmrg
5701e04c3fSmrg
5801e04c3fSmrg/**
5901e04c3fSmrg * Return pointer to current fixed-func texture unit.
6001e04c3fSmrg * This the texture unit set by glActiveTexture(), not glClientActiveTexture().
6101e04c3fSmrg * \return NULL if the current unit is not a fixed-func texture unit
6201e04c3fSmrg */
6301e04c3fSmrgstatic inline struct gl_fixedfunc_texture_unit *
647ec681f3Smrg_mesa_get_fixedfunc_tex_unit(struct gl_context *ctx, GLuint unit)
6501e04c3fSmrg{
6601e04c3fSmrg   if (unit >= ARRAY_SIZE(ctx->Texture.FixedFuncUnit))
6701e04c3fSmrg      return NULL;
6801e04c3fSmrg
6901e04c3fSmrg   return &ctx->Texture.FixedFuncUnit[unit];
7001e04c3fSmrg}
7101e04c3fSmrg
7201e04c3fSmrg
7301e04c3fSmrgstatic inline GLuint
7401e04c3fSmrg_mesa_max_tex_unit(struct gl_context *ctx)
7501e04c3fSmrg{
7601e04c3fSmrg   /* See OpenGL spec for glActiveTexture: */
7701e04c3fSmrg   return MAX2(ctx->Const.MaxCombinedTextureImageUnits,
7801e04c3fSmrg               ctx->Const.MaxTextureCoordUnits);
794a49301eSmrg}
804a49301eSmrg
814a49301eSmrg
827117f1b4Smrgextern void
833464ebd5Sriastradh_mesa_copy_texture_state( const struct gl_context *src, struct gl_context *dst );
847117f1b4Smrg
857117f1b4Smrgextern void
863464ebd5Sriastradh_mesa_print_texunit_state( struct gl_context *ctx, GLuint unit );
877117f1b4Smrg
887117f1b4Smrg
89c1f859d4Smrg
907117f1b4Smrg/**
917117f1b4Smrg * \name Called from API
927117f1b4Smrg */
937117f1b4Smrg/*@{*/
947117f1b4Smrg
9501e04c3fSmrgextern void GLAPIENTRY
9601e04c3fSmrg_mesa_ActiveTexture_no_error( GLenum target );
9701e04c3fSmrg
987117f1b4Smrgextern void GLAPIENTRY
99af69d88dSmrg_mesa_ActiveTexture( GLenum target );
1007117f1b4Smrg
1017117f1b4Smrgextern void GLAPIENTRY
102af69d88dSmrg_mesa_ClientActiveTexture( GLenum target );
1037117f1b4Smrg
1044a49301eSmrg/*@}*/
1054a49301eSmrg
1067117f1b4Smrg
1077117f1b4Smrg/**
1087117f1b4Smrg * \name Initialization, state maintenance
1097117f1b4Smrg */
1107117f1b4Smrg/*@{*/
1117117f1b4Smrg
1127ec681f3Smrgextern GLbitfield
11301e04c3fSmrg_mesa_update_texture_matrices(struct gl_context *ctx);
11401e04c3fSmrg
1157ec681f3Smrgextern GLbitfield
11601e04c3fSmrg_mesa_update_texture_state(struct gl_context *ctx);
1177117f1b4Smrg
1187117f1b4Smrgextern GLboolean
1193464ebd5Sriastradh_mesa_init_texture( struct gl_context *ctx );
1207117f1b4Smrg
1217117f1b4Smrgextern void
1223464ebd5Sriastradh_mesa_free_texture_data( struct gl_context *ctx );
1237117f1b4Smrg
124c1f859d4Smrgextern void
1253464ebd5Sriastradh_mesa_update_default_objects_texture(struct gl_context *ctx);
126c1f859d4Smrg
1277117f1b4Smrg/*@}*/
1287117f1b4Smrg
1297117f1b4Smrg#endif
130