ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

t_vb_texmat.c
Go to the documentation of this file.
00001 /*
00002  * Mesa 3-D graphics library
00003  * Version:  6.5
00004  *
00005  * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
00006  *
00007  * Permission is hereby granted, free of charge, to any person obtaining a
00008  * copy of this software and associated documentation files (the "Software"),
00009  * to deal in the Software without restriction, including without limitation
00010  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00011  * and/or sell copies of the Software, and to permit persons to whom the
00012  * Software is furnished to do so, subject to the following conditions:
00013  *
00014  * The above copyright notice and this permission notice shall be included
00015  * in all copies or substantial portions of the Software.
00016  *
00017  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00018  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
00020  * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00021  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00022  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00023  *
00024  * Authors:
00025  *    Keith Whitwell <keith@tungstengraphics.com>
00026  */
00027 
00028 
00029 #include "main/glheader.h"
00030 #include "main/colormac.h"
00031 #include "main/context.h"
00032 #include "main/macros.h"
00033 #include "main/imports.h"
00034 #include "main/mtypes.h"
00035 
00036 #include "math/m_xform.h"
00037 
00038 #include "t_context.h"
00039 #include "t_pipeline.h"
00040 
00041 /* Is there any real benefit seperating texmat from texgen?  It means
00042  * we need two lots of intermediate storage.  Any changes to
00043  * _NEW_TEXTURE will invalidate both sets -- it's only on changes to
00044  * *only* _NEW_TEXTURE_MATRIX that texgen survives but texmat doesn't.
00045  *
00046  * However, the seperation of this code from the complex texgen stuff
00047  * is very appealing.
00048  */
00049 struct texmat_stage_data {
00050    GLvector4f texcoord[MAX_TEXTURE_COORD_UNITS];
00051 };
00052 
00053 #define TEXMAT_STAGE_DATA(stage) ((struct texmat_stage_data *)stage->privatePtr)
00054 
00055 
00056 
00057 static GLboolean run_texmat_stage( GLcontext *ctx,
00058                    struct tnl_pipeline_stage *stage )
00059 {
00060    struct texmat_stage_data *store = TEXMAT_STAGE_DATA(stage);
00061    struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
00062    GLuint i;
00063 
00064    if (!ctx->Texture._TexMatEnabled || ctx->VertexProgram._Current) 
00065       return GL_TRUE;
00066 
00067    /* ENABLE_TEXMAT implies that the texture matrix is not the
00068     * identity, so we don't have to check that here.
00069     */
00070    for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) {
00071       if (ctx->Texture._TexMatEnabled & ENABLE_TEXMAT(i)) {
00072      (void) TransformRaw( &store->texcoord[i],
00073                   ctx->TextureMatrixStack[i].Top,
00074                   VB->AttribPtr[_TNL_ATTRIB_TEX0 + i]);
00075 
00076          VB->TexCoordPtr[i] = 
00077      VB->AttribPtr[VERT_ATTRIB_TEX0+i] = &store->texcoord[i];
00078       }
00079    }
00080 
00081    return GL_TRUE;
00082 }
00083 
00084 
00085 /* Called the first time stage->run() is invoked.
00086  */
00087 static GLboolean alloc_texmat_data( GLcontext *ctx,
00088                     struct tnl_pipeline_stage *stage )
00089 {
00090    struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
00091    struct texmat_stage_data *store;
00092    GLuint i;
00093 
00094    stage->privatePtr = CALLOC(sizeof(*store));
00095    store = TEXMAT_STAGE_DATA(stage);
00096    if (!store)
00097       return GL_FALSE;
00098 
00099    for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++)
00100       _mesa_vector4f_alloc( &store->texcoord[i], 0, VB->Size, 32 );
00101 
00102    return GL_TRUE;
00103 }
00104 
00105 
00106 static void free_texmat_data( struct tnl_pipeline_stage *stage )
00107 {
00108    struct texmat_stage_data *store = TEXMAT_STAGE_DATA(stage);
00109    GLuint i;
00110 
00111    if (store) {
00112       for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++)
00113      if (store->texcoord[i].data)
00114         _mesa_vector4f_free( &store->texcoord[i] );
00115       FREE( store );
00116       stage->privatePtr = NULL;
00117    }
00118 }
00119 
00120 
00121 
00122 const struct tnl_pipeline_stage _tnl_texture_transform_stage =
00123 {
00124    "texture transform",         /* name */
00125    NULL,                /* private data */
00126    alloc_texmat_data,
00127    free_texmat_data,            /* destructor */
00128    NULL,
00129    run_texmat_stage,
00130 };

Generated on Sun May 27 2012 04:20:46 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.