texstate.h revision 01e04c3f
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 *
6401e04c3fSmrg_mesa_get_current_fixedfunc_tex_unit(struct gl_context *ctx)
6501e04c3fSmrg{
6601e04c3fSmrg   unsigned unit = ctx->Texture.CurrentUnit;
6701e04c3fSmrg
6801e04c3fSmrg   if (unit >= ARRAY_SIZE(ctx->Texture.FixedFuncUnit))
6901e04c3fSmrg      return NULL;
7001e04c3fSmrg
7101e04c3fSmrg   return &ctx->Texture.FixedFuncUnit[unit];
7201e04c3fSmrg}
7301e04c3fSmrg
7401e04c3fSmrg
7501e04c3fSmrgstatic inline GLuint
7601e04c3fSmrg_mesa_max_tex_unit(struct gl_context *ctx)
7701e04c3fSmrg{
7801e04c3fSmrg   /* See OpenGL spec for glActiveTexture: */
7901e04c3fSmrg   return MAX2(ctx->Const.MaxCombinedTextureImageUnits,
8001e04c3fSmrg               ctx->Const.MaxTextureCoordUnits);
814a49301eSmrg}
824a49301eSmrg
834a49301eSmrg
847117f1b4Smrgextern void
853464ebd5Sriastradh_mesa_copy_texture_state( const struct gl_context *src, struct gl_context *dst );
867117f1b4Smrg
877117f1b4Smrgextern void
883464ebd5Sriastradh_mesa_print_texunit_state( struct gl_context *ctx, GLuint unit );
897117f1b4Smrg
907117f1b4Smrg
91c1f859d4Smrg
927117f1b4Smrg/**
937117f1b4Smrg * \name Called from API
947117f1b4Smrg */
957117f1b4Smrg/*@{*/
967117f1b4Smrg
9701e04c3fSmrgextern void GLAPIENTRY
9801e04c3fSmrg_mesa_ActiveTexture_no_error( GLenum target );
9901e04c3fSmrg
1007117f1b4Smrgextern void GLAPIENTRY
101af69d88dSmrg_mesa_ActiveTexture( GLenum target );
1027117f1b4Smrg
1037117f1b4Smrgextern void GLAPIENTRY
104af69d88dSmrg_mesa_ClientActiveTexture( GLenum target );
1057117f1b4Smrg
1064a49301eSmrg/*@}*/
1074a49301eSmrg
1087117f1b4Smrg
1097117f1b4Smrg/**
1107117f1b4Smrg * \name Initialization, state maintenance
1117117f1b4Smrg */
1127117f1b4Smrg/*@{*/
1137117f1b4Smrg
11401e04c3fSmrgextern void
11501e04c3fSmrg_mesa_update_texture_matrices(struct gl_context *ctx);
11601e04c3fSmrg
11701e04c3fSmrgextern void
11801e04c3fSmrg_mesa_update_texture_state(struct gl_context *ctx);
1197117f1b4Smrg
1207117f1b4Smrgextern GLboolean
1213464ebd5Sriastradh_mesa_init_texture( struct gl_context *ctx );
1227117f1b4Smrg
1237117f1b4Smrgextern void
1243464ebd5Sriastradh_mesa_free_texture_data( struct gl_context *ctx );
1257117f1b4Smrg
126c1f859d4Smrgextern void
1273464ebd5Sriastradh_mesa_update_default_objects_texture(struct gl_context *ctx);
128c1f859d4Smrg
1297117f1b4Smrg/*@}*/
1307117f1b4Smrg
1317117f1b4Smrg#endif
132