Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygent_context.c
Go to the documentation of this file.
00001 /* 00002 * Mesa 3-D graphics library 00003 * Version: 7.2 00004 * 00005 * Copyright (C) 1999-2008 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/imports.h" 00031 #include "main/context.h" 00032 #include "main/macros.h" 00033 #include "main/mtypes.h" 00034 #include "main/light.h" 00035 00036 #include "tnl.h" 00037 #include "t_context.h" 00038 #include "t_pipeline.h" 00039 #include "t_vp_build.h" 00040 00041 #include "vbo/vbo.h" 00042 00043 GLboolean 00044 _tnl_CreateContext( GLcontext *ctx ) 00045 { 00046 TNLcontext *tnl; 00047 00048 /* Create the TNLcontext structure 00049 */ 00050 ctx->swtnl_context = tnl = (TNLcontext *) CALLOC( sizeof(TNLcontext) ); 00051 00052 if (!tnl) { 00053 return GL_FALSE; 00054 } 00055 00056 /* Initialize the VB. 00057 */ 00058 tnl->vb.Size = ctx->Const.MaxArrayLockSize + MAX_CLIPPED_VERTICES; 00059 00060 00061 /* Initialize tnl state. 00062 */ 00063 if (ctx->VertexProgram._MaintainTnlProgram) { 00064 _tnl_install_pipeline( ctx, _tnl_vp_pipeline ); 00065 } else { 00066 _tnl_install_pipeline( ctx, _tnl_default_pipeline ); 00067 } 00068 00069 tnl->NeedNdcCoords = GL_TRUE; 00070 tnl->AllowVertexFog = GL_TRUE; 00071 tnl->AllowPixelFog = GL_TRUE; 00072 00073 /* Set a few default values in the driver struct. 00074 */ 00075 tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; 00076 tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; 00077 tnl->Driver.NotifyMaterialChange = _mesa_validate_all_lighting_tables; 00078 00079 tnl->nr_blocks = 0; 00080 00081 return GL_TRUE; 00082 } 00083 00084 00085 void 00086 _tnl_DestroyContext( GLcontext *ctx ) 00087 { 00088 TNLcontext *tnl = TNL_CONTEXT(ctx); 00089 00090 _tnl_destroy_pipeline( ctx ); 00091 00092 FREE(tnl); 00093 ctx->swtnl_context = NULL; 00094 } 00095 00096 00097 void 00098 _tnl_InvalidateState( GLcontext *ctx, GLuint new_state ) 00099 { 00100 TNLcontext *tnl = TNL_CONTEXT(ctx); 00101 const struct gl_vertex_program *vp = ctx->VertexProgram._Current; 00102 const struct gl_fragment_program *fp = ctx->FragmentProgram._Current; 00103 00104 if (new_state & (_NEW_HINT | _NEW_PROGRAM)) { 00105 ASSERT(tnl->AllowVertexFog || tnl->AllowPixelFog); 00106 tnl->_DoVertexFog = ((tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST)) 00107 || !tnl->AllowPixelFog) && !fp; 00108 } 00109 00110 tnl->pipeline.new_state |= new_state; 00111 00112 /* Calculate tnl->render_inputs. This bitmask indicates which vertex 00113 * attributes need to be emitted to the rasterizer. 00114 */ 00115 if (ctx->Visual.rgbMode) { 00116 GLuint i; 00117 00118 RENDERINPUTS_ZERO( tnl->render_inputs_bitset ); 00119 RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_POS ); 00120 00121 if (!fp || (fp->Base.InputsRead & FRAG_BIT_COL0)) { 00122 RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_COLOR0 ); 00123 } 00124 00125 if (NEED_SECONDARY_COLOR(ctx)) 00126 RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_COLOR1 ); 00127 00128 for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { 00129 if (ctx->Texture._EnabledCoordUnits & (1 << i) || 00130 (fp && fp->Base.InputsRead & FRAG_BIT_TEX(i))) { 00131 RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_TEX(i) ); 00132 } 00133 } 00134 } 00135 else { 00136 RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_POS ); 00137 RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_COLOR_INDEX ); 00138 } 00139 00140 if (ctx->Fog.Enabled) { 00141 /* fixed-function fog */ 00142 RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_FOG ); 00143 } 00144 else if (ctx->FragmentProgram._Current) { 00145 struct gl_fragment_program *fp = ctx->FragmentProgram._Current; 00146 if (fp) { 00147 if (fp->FogOption != GL_NONE || (fp->Base.InputsRead & FRAG_BIT_FOGC)) { 00148 /* fragment program needs fog coord */ 00149 RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_FOG ); 00150 } 00151 } 00152 } 00153 00154 if (ctx->Polygon.FrontMode != GL_FILL || 00155 ctx->Polygon.BackMode != GL_FILL) 00156 RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_EDGEFLAG ); 00157 00158 if (ctx->RenderMode == GL_FEEDBACK) 00159 RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_TEX0 ); 00160 00161 if (ctx->Point._Attenuated || 00162 (ctx->VertexProgram._Enabled && ctx->VertexProgram.PointSizeEnabled)) 00163 RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_POINTSIZE ); 00164 00165 /* check for varying vars which are written by the vertex program */ 00166 if (vp) { 00167 GLuint i; 00168 for (i = 0; i < MAX_VARYING; i++) { 00169 if (vp->Base.OutputsWritten & (1 << (VERT_RESULT_VAR0 + i))) { 00170 RENDERINPUTS_SET(tnl->render_inputs_bitset, 00171 _TNL_ATTRIB_GENERIC(i)); 00172 } 00173 } 00174 } 00175 } 00176 00177 00178 void 00179 _tnl_wakeup( GLcontext *ctx ) 00180 { 00181 /* Assume we haven't been getting state updates either: 00182 */ 00183 _tnl_InvalidateState( ctx, ~0 ); 00184 00185 #if 0 00186 if (ctx->Light.ColorMaterialEnabled) { 00187 _mesa_update_color_material( ctx, 00188 ctx->Current.Attrib[VERT_ATTRIB_COLOR0] ); 00189 } 00190 #endif 00191 } 00192 00193 00194 00195 00201 void 00202 _tnl_need_projected_coords( GLcontext *ctx, GLboolean mode ) 00203 { 00204 TNLcontext *tnl = TNL_CONTEXT(ctx); 00205 tnl->NeedNdcCoords = mode; 00206 } 00207 00208 void 00209 _tnl_allow_vertex_fog( GLcontext *ctx, GLboolean value ) 00210 { 00211 TNLcontext *tnl = TNL_CONTEXT(ctx); 00212 tnl->AllowVertexFog = value; 00213 tnl->_DoVertexFog = ((tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST)) 00214 || !tnl->AllowPixelFog) && !ctx->FragmentProgram._Current; 00215 00216 } 00217 00218 void 00219 _tnl_allow_pixel_fog( GLcontext *ctx, GLboolean value ) 00220 { 00221 TNLcontext *tnl = TNL_CONTEXT(ctx); 00222 tnl->AllowPixelFog = value; 00223 tnl->_DoVertexFog = ((tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST)) 00224 || !tnl->AllowPixelFog) && !ctx->FragmentProgram._Current; 00225 } 00226 Generated on Sun May 27 2012 04:20:45 for ReactOS by
1.7.6.1
|