1bf215546Sopenharmony_ci/** 2bf215546Sopenharmony_ci * \file texstate.h 3bf215546Sopenharmony_ci * Texture state management. 4bf215546Sopenharmony_ci */ 5bf215546Sopenharmony_ci 6bf215546Sopenharmony_ci/* 7bf215546Sopenharmony_ci * Mesa 3-D graphics library 8bf215546Sopenharmony_ci * 9bf215546Sopenharmony_ci * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 12bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 13bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 14bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 15bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 16bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 17bf215546Sopenharmony_ci * 18bf215546Sopenharmony_ci * The above copyright notice and this permission notice shall be included 19bf215546Sopenharmony_ci * in all copies or substantial portions of the Software. 20bf215546Sopenharmony_ci * 21bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 22bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 24bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 25bf215546Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 26bf215546Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27bf215546Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 28bf215546Sopenharmony_ci */ 29bf215546Sopenharmony_ci 30bf215546Sopenharmony_ci 31bf215546Sopenharmony_ci#ifndef TEXSTATE_H 32bf215546Sopenharmony_ci#define TEXSTATE_H 33bf215546Sopenharmony_ci 34bf215546Sopenharmony_ci 35bf215546Sopenharmony_ci#include "enums.h" 36bf215546Sopenharmony_ci#include "macros.h" 37bf215546Sopenharmony_ci#include "mtypes.h" 38bf215546Sopenharmony_ci 39bf215546Sopenharmony_ci 40bf215546Sopenharmony_cistatic inline struct gl_texture_unit * 41bf215546Sopenharmony_ci_mesa_get_tex_unit(struct gl_context *ctx, GLuint unit) 42bf215546Sopenharmony_ci{ 43bf215546Sopenharmony_ci assert(unit < ARRAY_SIZE(ctx->Texture.Unit)); 44bf215546Sopenharmony_ci return &(ctx->Texture.Unit[unit]); 45bf215546Sopenharmony_ci} 46bf215546Sopenharmony_ci 47bf215546Sopenharmony_ci/** 48bf215546Sopenharmony_ci * Return pointer to current texture unit. 49bf215546Sopenharmony_ci * This the texture unit set by glActiveTexture(), not glClientActiveTexture(). 50bf215546Sopenharmony_ci */ 51bf215546Sopenharmony_cistatic inline struct gl_texture_unit * 52bf215546Sopenharmony_ci_mesa_get_current_tex_unit(struct gl_context *ctx) 53bf215546Sopenharmony_ci{ 54bf215546Sopenharmony_ci return _mesa_get_tex_unit(ctx, ctx->Texture.CurrentUnit); 55bf215546Sopenharmony_ci} 56bf215546Sopenharmony_ci 57bf215546Sopenharmony_ci 58bf215546Sopenharmony_ci/** 59bf215546Sopenharmony_ci * Return pointer to current fixed-func texture unit. 60bf215546Sopenharmony_ci * This the texture unit set by glActiveTexture(), not glClientActiveTexture(). 61bf215546Sopenharmony_ci * \return NULL if the current unit is not a fixed-func texture unit 62bf215546Sopenharmony_ci */ 63bf215546Sopenharmony_cistatic inline struct gl_fixedfunc_texture_unit * 64bf215546Sopenharmony_ci_mesa_get_fixedfunc_tex_unit(struct gl_context *ctx, GLuint unit) 65bf215546Sopenharmony_ci{ 66bf215546Sopenharmony_ci if (unit >= ARRAY_SIZE(ctx->Texture.FixedFuncUnit)) 67bf215546Sopenharmony_ci return NULL; 68bf215546Sopenharmony_ci 69bf215546Sopenharmony_ci return &ctx->Texture.FixedFuncUnit[unit]; 70bf215546Sopenharmony_ci} 71bf215546Sopenharmony_ci 72bf215546Sopenharmony_ci 73bf215546Sopenharmony_cistatic inline GLuint 74bf215546Sopenharmony_ci_mesa_max_tex_unit(struct gl_context *ctx) 75bf215546Sopenharmony_ci{ 76bf215546Sopenharmony_ci /* See OpenGL spec for glActiveTexture: */ 77bf215546Sopenharmony_ci return MAX2(ctx->Const.MaxCombinedTextureImageUnits, 78bf215546Sopenharmony_ci ctx->Const.MaxTextureCoordUnits); 79bf215546Sopenharmony_ci} 80bf215546Sopenharmony_ci 81bf215546Sopenharmony_ci 82bf215546Sopenharmony_ciextern void 83bf215546Sopenharmony_ci_mesa_copy_texture_state( const struct gl_context *src, struct gl_context *dst ); 84bf215546Sopenharmony_ci 85bf215546Sopenharmony_ciextern void 86bf215546Sopenharmony_ci_mesa_print_texunit_state( struct gl_context *ctx, GLuint unit ); 87bf215546Sopenharmony_ci 88bf215546Sopenharmony_ci 89bf215546Sopenharmony_ci/** 90bf215546Sopenharmony_ci * \name Initialization, state maintenance 91bf215546Sopenharmony_ci */ 92bf215546Sopenharmony_ci/*@{*/ 93bf215546Sopenharmony_ci 94bf215546Sopenharmony_ciextern GLbitfield 95bf215546Sopenharmony_ci_mesa_update_texture_matrices(struct gl_context *ctx); 96bf215546Sopenharmony_ci 97bf215546Sopenharmony_ciextern GLbitfield 98bf215546Sopenharmony_ci_mesa_update_texture_state(struct gl_context *ctx); 99bf215546Sopenharmony_ci 100bf215546Sopenharmony_ciextern GLboolean 101bf215546Sopenharmony_ci_mesa_init_texture( struct gl_context *ctx ); 102bf215546Sopenharmony_ci 103bf215546Sopenharmony_ciextern void 104bf215546Sopenharmony_ci_mesa_free_texture_data( struct gl_context *ctx ); 105bf215546Sopenharmony_ci 106bf215546Sopenharmony_ciextern void 107bf215546Sopenharmony_ci_mesa_update_default_objects_texture(struct gl_context *ctx); 108bf215546Sopenharmony_ci 109bf215546Sopenharmony_ci/*@}*/ 110bf215546Sopenharmony_ci 111bf215546Sopenharmony_ci#endif 112