Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygens_aalinetemp.h
Go to the documentation of this file.
00001 /* 00002 * Mesa 3-D graphics library 00003 * Version: 7.1 00004 * 00005 * Copyright (C) 1999-2007 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 00025 00026 /* 00027 * Antialiased line template. 00028 */ 00029 00030 00031 /* 00032 * Function to render each fragment in the AA line. 00033 * \param ix - integer fragment window X coordiante 00034 * \param iy - integer fragment window Y coordiante 00035 */ 00036 static void 00037 NAME(plot)(GLcontext *ctx, struct LineInfo *line, int ix, int iy) 00038 { 00039 const SWcontext *swrast = SWRAST_CONTEXT(ctx); 00040 const GLfloat fx = (GLfloat) ix; 00041 const GLfloat fy = (GLfloat) iy; 00042 #ifdef DO_INDEX 00043 const GLfloat coverage = compute_coveragei(line, ix, iy); 00044 #else 00045 const GLfloat coverage = compute_coveragef(line, ix, iy); 00046 #endif 00047 const GLuint i = line->span.end; 00048 00049 (void) swrast; 00050 00051 if (coverage == 0.0) 00052 return; 00053 00054 line->span.end++; 00055 line->span.array->coverage[i] = coverage; 00056 line->span.array->x[i] = ix; 00057 line->span.array->y[i] = iy; 00058 00059 /* 00060 * Compute Z, color, texture coords, fog for the fragment by 00061 * solving the plane equations at (ix,iy). 00062 */ 00063 #ifdef DO_Z 00064 line->span.array->z[i] = (GLuint) solve_plane(fx, fy, line->zPlane); 00065 #endif 00066 #ifdef DO_RGBA 00067 line->span.array->rgba[i][RCOMP] = solve_plane_chan(fx, fy, line->rPlane); 00068 line->span.array->rgba[i][GCOMP] = solve_plane_chan(fx, fy, line->gPlane); 00069 line->span.array->rgba[i][BCOMP] = solve_plane_chan(fx, fy, line->bPlane); 00070 line->span.array->rgba[i][ACOMP] = solve_plane_chan(fx, fy, line->aPlane); 00071 #endif 00072 #ifdef DO_INDEX 00073 line->span.array->index[i] = (GLint) solve_plane(fx, fy, line->iPlane); 00074 #endif 00075 #if defined(DO_ATTRIBS) 00076 ATTRIB_LOOP_BEGIN 00077 GLfloat (*attribArray)[4] = line->span.array->attribs[attr]; 00078 if (attr >= FRAG_ATTRIB_TEX0 && attr < FRAG_ATTRIB_VAR0 00079 && !ctx->FragmentProgram._Current) { 00080 /* texcoord w/ divide by Q */ 00081 const GLuint unit = attr - FRAG_ATTRIB_TEX0; 00082 const GLfloat invQ = solve_plane_recip(fx, fy, line->attrPlane[attr][3]); 00083 GLuint c; 00084 for (c = 0; c < 3; c++) { 00085 attribArray[i][c] = solve_plane(fx, fy, line->attrPlane[attr][c]) * invQ; 00086 } 00087 line->span.array->lambda[unit][i] 00088 = compute_lambda(line->attrPlane[attr][0], 00089 line->attrPlane[attr][1], invQ, 00090 line->texWidth[attr], line->texHeight[attr]); 00091 } 00092 else { 00093 /* non-texture attrib */ 00094 const GLfloat invW = solve_plane_recip(fx, fy, line->wPlane); 00095 GLuint c; 00096 for (c = 0; c < 4; c++) { 00097 attribArray[i][c] = solve_plane(fx, fy, line->attrPlane[attr][c]) * invW; 00098 } 00099 } 00100 ATTRIB_LOOP_END 00101 #endif 00102 00103 if (line->span.end == MAX_WIDTH) { 00104 #if defined(DO_RGBA) 00105 _swrast_write_rgba_span(ctx, &(line->span)); 00106 #else 00107 _swrast_write_index_span(ctx, &(line->span)); 00108 #endif 00109 line->span.end = 0; /* reset counter */ 00110 } 00111 } 00112 00113 00114 00115 /* 00116 * Line setup 00117 */ 00118 static void 00119 NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1) 00120 { 00121 SWcontext *swrast = SWRAST_CONTEXT(ctx); 00122 GLfloat tStart, tEnd; /* segment start, end along line length */ 00123 GLboolean inSegment; 00124 GLint iLen, i; 00125 00126 /* Init the LineInfo struct */ 00127 struct LineInfo line; 00128 line.x0 = v0->attrib[FRAG_ATTRIB_WPOS][0]; 00129 line.y0 = v0->attrib[FRAG_ATTRIB_WPOS][1]; 00130 line.x1 = v1->attrib[FRAG_ATTRIB_WPOS][0]; 00131 line.y1 = v1->attrib[FRAG_ATTRIB_WPOS][1]; 00132 line.dx = line.x1 - line.x0; 00133 line.dy = line.y1 - line.y0; 00134 line.len = SQRTF(line.dx * line.dx + line.dy * line.dy); 00135 line.halfWidth = 0.5F * CLAMP(ctx->Line.Width, 00136 ctx->Const.MinLineWidthAA, 00137 ctx->Const.MaxLineWidthAA); 00138 00139 if (line.len == 0.0 || IS_INF_OR_NAN(line.len)) 00140 return; 00141 00142 INIT_SPAN(line.span, GL_LINE); 00143 line.span.arrayMask = SPAN_XY | SPAN_COVERAGE; 00144 line.span.facing = swrast->PointLineFacing; 00145 line.xAdj = line.dx / line.len * line.halfWidth; 00146 line.yAdj = line.dy / line.len * line.halfWidth; 00147 00148 #ifdef DO_Z 00149 line.span.arrayMask |= SPAN_Z; 00150 compute_plane(line.x0, line.y0, line.x1, line.y1, 00151 v0->attrib[FRAG_ATTRIB_WPOS][2], v1->attrib[FRAG_ATTRIB_WPOS][2], line.zPlane); 00152 #endif 00153 #ifdef DO_RGBA 00154 line.span.arrayMask |= SPAN_RGBA; 00155 if (ctx->Light.ShadeModel == GL_SMOOTH) { 00156 compute_plane(line.x0, line.y0, line.x1, line.y1, 00157 v0->color[RCOMP], v1->color[RCOMP], line.rPlane); 00158 compute_plane(line.x0, line.y0, line.x1, line.y1, 00159 v0->color[GCOMP], v1->color[GCOMP], line.gPlane); 00160 compute_plane(line.x0, line.y0, line.x1, line.y1, 00161 v0->color[BCOMP], v1->color[BCOMP], line.bPlane); 00162 compute_plane(line.x0, line.y0, line.x1, line.y1, 00163 v0->color[ACOMP], v1->color[ACOMP], line.aPlane); 00164 } 00165 else { 00166 constant_plane(v1->color[RCOMP], line.rPlane); 00167 constant_plane(v1->color[GCOMP], line.gPlane); 00168 constant_plane(v1->color[BCOMP], line.bPlane); 00169 constant_plane(v1->color[ACOMP], line.aPlane); 00170 } 00171 #endif 00172 #ifdef DO_INDEX 00173 line.span.arrayMask |= SPAN_INDEX; 00174 if (ctx->Light.ShadeModel == GL_SMOOTH) { 00175 compute_plane(line.x0, line.y0, line.x1, line.y1, 00176 v0->attrib[FRAG_ATTRIB_CI][0], 00177 v1->attrib[FRAG_ATTRIB_CI][0], line.iPlane); 00178 } 00179 else { 00180 constant_plane(v1->attrib[FRAG_ATTRIB_CI][0], line.iPlane); 00181 } 00182 #endif 00183 #if defined(DO_ATTRIBS) 00184 { 00185 const GLfloat invW0 = v0->attrib[FRAG_ATTRIB_WPOS][3]; 00186 const GLfloat invW1 = v1->attrib[FRAG_ATTRIB_WPOS][3]; 00187 line.span.arrayMask |= SPAN_LAMBDA; 00188 compute_plane(line.x0, line.y0, line.x1, line.y1, invW0, invW1, line.wPlane); 00189 ATTRIB_LOOP_BEGIN 00190 GLuint c; 00191 if (swrast->_InterpMode[attr] == GL_FLAT) { 00192 for (c = 0; c < 4; c++) { 00193 constant_plane(v1->attrib[attr][c], line.attrPlane[attr][c]); 00194 } 00195 } 00196 else { 00197 for (c = 0; c < 4; c++) { 00198 const GLfloat a0 = v0->attrib[attr][c] * invW0; 00199 const GLfloat a1 = v1->attrib[attr][c] * invW1; 00200 compute_plane(line.x0, line.y0, line.x1, line.y1, a0, a1, 00201 line.attrPlane[attr][c]); 00202 } 00203 } 00204 line.span.arrayAttribs |= (1 << attr); 00205 if (attr >= FRAG_ATTRIB_TEX0 && attr < FRAG_ATTRIB_VAR0) { 00206 const GLuint u = attr - FRAG_ATTRIB_TEX0; 00207 const struct gl_texture_object *obj = ctx->Texture.Unit[u]._Current; 00208 const struct gl_texture_image *texImage = obj->Image[0][obj->BaseLevel]; 00209 line.texWidth[attr] = (GLfloat) texImage->Width; 00210 line.texHeight[attr] = (GLfloat) texImage->Height; 00211 } 00212 ATTRIB_LOOP_END 00213 } 00214 #endif 00215 00216 tStart = tEnd = 0.0; 00217 inSegment = GL_FALSE; 00218 iLen = (GLint) line.len; 00219 00220 if (ctx->Line.StippleFlag) { 00221 for (i = 0; i < iLen; i++) { 00222 const GLuint bit = (swrast->StippleCounter / ctx->Line.StippleFactor) & 0xf; 00223 if ((1 << bit) & ctx->Line.StipplePattern) { 00224 /* stipple bit is on */ 00225 const GLfloat t = (GLfloat) i / (GLfloat) line.len; 00226 if (!inSegment) { 00227 /* start new segment */ 00228 inSegment = GL_TRUE; 00229 tStart = t; 00230 } 00231 else { 00232 /* still in the segment, extend it */ 00233 tEnd = t; 00234 } 00235 } 00236 else { 00237 /* stipple bit is off */ 00238 if (inSegment && (tEnd > tStart)) { 00239 /* draw the segment */ 00240 segment(ctx, &line, NAME(plot), tStart, tEnd); 00241 inSegment = GL_FALSE; 00242 } 00243 else { 00244 /* still between segments, do nothing */ 00245 } 00246 } 00247 swrast->StippleCounter++; 00248 } 00249 00250 if (inSegment) { 00251 /* draw the final segment of the line */ 00252 segment(ctx, &line, NAME(plot), tStart, 1.0F); 00253 } 00254 } 00255 else { 00256 /* non-stippled */ 00257 segment(ctx, &line, NAME(plot), 0.0, 1.0); 00258 } 00259 00260 #if defined(DO_RGBA) 00261 _swrast_write_rgba_span(ctx, &(line.span)); 00262 #else 00263 _swrast_write_index_span(ctx, &(line.span)); 00264 #endif 00265 } 00266 00267 00268 00269 00270 #undef DO_Z 00271 #undef DO_RGBA 00272 #undef DO_INDEX 00273 #undef DO_ATTRIBS 00274 #undef NAME Generated on Sun May 27 2012 04:20:41 for ReactOS by
1.7.6.1
|