core | glapi | vbo | math | shader | swrast | swrast_setup | tnl | tnl_dd

s_triangle.c File Reference

#include "main/glheader.h"
#include "main/context.h"
#include "main/colormac.h"
#include "main/imports.h"
#include "main/macros.h"
#include "main/texformat.h"
#include "shader/prog_instruction.h"
#include "s_aatriangle.h"
#include "s_context.h"
#include "s_feedback.h"
#include "s_span.h"
#include "s_triangle.h"
#include "s_tritemp.h"

Defines

#define NAME   ci_triangle
#define INTERP_Z   1
#define INTERP_ATTRIBS   1
#define INTERP_INDEX   1
#define RENDER_SPAN(span)   _swrast_write_index_span(ctx, &span);
#define NAME   flat_rgba_triangle
#define INTERP_Z   1
#define SETUP_CODE
#define RENDER_SPAN(span)   _swrast_write_rgba_span(ctx, &span);
#define NAME   smooth_rgba_triangle
#define INTERP_Z   1
#define INTERP_RGB   1
#define INTERP_ALPHA   1
#define SETUP_CODE
#define RENDER_SPAN(span)   _swrast_write_rgba_span(ctx, &span);
#define NAME   simple_textured_triangle
#define INTERP_INT_TEX   1
#define S_SCALE   twidth
#define T_SCALE   theight
#define SETUP_CODE
#define RENDER_SPAN(span)
#define NAME   simple_z_textured_triangle
#define INTERP_Z   1
#define DEPTH_TYPE   DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_INT_TEX   1
#define S_SCALE   twidth
#define T_SCALE   theight
#define SETUP_CODE
#define RENDER_SPAN(span)
#define NAME   general_triangle
#define INTERP_Z   1
#define INTERP_RGB   1
#define INTERP_ALPHA   1
#define INTERP_ATTRIBS   1
#define RENDER_SPAN(span)   _swrast_write_rgba_span(ctx, &span);
#define NAME   occlusion_zless_triangle
#define INTERP_Z   1
#define SETUP_CODE
#define RENDER_SPAN(span)
#define USE(triFunc)   swrast->Triangle = triFunc;

Functions

GLboolean _swrast_culltriangle (GLcontext *ctx, const SWvertex *v0, const SWvertex *v1, const SWvertex *v2)
 Test if a triangle should be culled.
static void nodraw_triangle (GLcontext *ctx, const SWvertex *v0, const SWvertex *v1, const SWvertex *v2)
void _swrast_add_spec_terms_triangle (GLcontext *ctx, const SWvertex *v0, const SWvertex *v1, const SWvertex *v2)
void _swrast_choose_triangle (GLcontext *ctx)


Define Documentation

#define DEPTH_TYPE   DEFAULT_SOFTWARE_DEPTH_TYPE

#define INTERP_ALPHA   1

#define INTERP_ALPHA   1

#define INTERP_ATTRIBS   1

#define INTERP_ATTRIBS   1

#define INTERP_INDEX   1

#define INTERP_INT_TEX   1

#define INTERP_INT_TEX   1

#define INTERP_RGB   1

#define INTERP_RGB   1

#define INTERP_Z   1

#define INTERP_Z   1

#define INTERP_Z   1

#define INTERP_Z   1

#define INTERP_Z   1

#define INTERP_Z   1

#define NAME   occlusion_zless_triangle

#define NAME   general_triangle

#define NAME   simple_z_textured_triangle

#define NAME   simple_textured_triangle

#define NAME   smooth_rgba_triangle

#define NAME   flat_rgba_triangle

#define NAME   ci_triangle

#define RENDER_SPAN ( span   ) 

Value:

if (rb->DepthBits <= 16) {                                              \
      GLuint i;                                                         \
      const GLushort *zRow = (const GLushort *)                         \
         rb->GetPointer(ctx, rb, span.x, span.y);                       \
      for (i = 0; i < span.end; i++) {                                  \
         GLuint z = FixedToDepth(span.z);                               \
         if (z < zRow[i]) {                                             \
            q->Result++;                                                \
         }                                                              \
         span.z += span.zStep;                                          \
      }                                                                 \
   }                                                                    \
   else {                                                               \
      GLuint i;                                                         \
      const GLuint *zRow = (const GLuint *)                             \
         rb->GetPointer(ctx, rb, span.x, span.y);                       \
      for (i = 0; i < span.end; i++) {                                  \
         if ((GLuint)span.z < zRow[i]) {                                \
            q->Result++;                                                \
         }                                                              \
         span.z += span.zStep;                                          \
      }                                                                 \
   }

#define RENDER_SPAN ( span   )     _swrast_write_rgba_span(ctx, &span);

#define RENDER_SPAN ( span   ) 

Value:

GLuint i;                                                               \
   GLchan rgb[MAX_WIDTH][3];                                            \
   span.intTex[0] -= FIXED_HALF; /* off-by-one error? */                \
   span.intTex[1] -= FIXED_HALF;                                        \
   for (i = 0; i < span.end; i++) {                                     \
      const GLuint z = FixedToDepth(span.z);                            \
      if (z < zRow[i]) {                                                \
         GLint s = FixedToInt(span.intTex[0]) & smask;                  \
         GLint t = FixedToInt(span.intTex[1]) & tmask;                  \
         GLint pos = (t << twidth_log2) + s;                            \
         pos = pos + pos + pos;  /* multiply by 3 */                    \
         rgb[i][RCOMP] = texture[pos];                                  \
         rgb[i][GCOMP] = texture[pos+1];                                \
         rgb[i][BCOMP] = texture[pos+2];                                \
         zRow[i] = z;                                                   \
         span.array->mask[i] = 1;                                       \
      }                                                                 \
      else {                                                            \
         span.array->mask[i] = 0;                                       \
      }                                                                 \
      span.intTex[0] += span.intTexStep[0];                             \
      span.intTex[1] += span.intTexStep[1];                             \
      span.z += span.zStep;                                             \
   }                                                                    \
   rb->PutRowRGB(ctx, rb, span.end, span.x, span.y, rgb, span.array->mask);

#define RENDER_SPAN ( span   ) 

Value:

GLuint i;                                                               \
   GLchan rgb[MAX_WIDTH][3];                                            \
   span.intTex[0] -= FIXED_HALF; /* off-by-one error? */                \
   span.intTex[1] -= FIXED_HALF;                                        \
   for (i = 0; i < span.end; i++) {                                     \
      GLint s = FixedToInt(span.intTex[0]) & smask;                     \
      GLint t = FixedToInt(span.intTex[1]) & tmask;                     \
      GLint pos = (t << twidth_log2) + s;                               \
      pos = pos + pos + pos;  /* multiply by 3 */                       \
      rgb[i][RCOMP] = texture[pos];                                     \
      rgb[i][GCOMP] = texture[pos+1];                                   \
      rgb[i][BCOMP] = texture[pos+2];                                   \
      span.intTex[0] += span.intTexStep[0];                             \
      span.intTex[1] += span.intTexStep[1];                             \
   }                                                                    \
   rb->PutRowRGB(ctx, rb, span.end, span.x, span.y, rgb, NULL);

#define RENDER_SPAN ( span   )     _swrast_write_rgba_span(ctx, &span);

#define RENDER_SPAN ( span   )     _swrast_write_rgba_span(ctx, &span);

#define RENDER_SPAN ( span   )     _swrast_write_index_span(ctx, &span);

#define S_SCALE   twidth

#define S_SCALE   twidth

#define SETUP_CODE

Value:

struct gl_renderbuffer *rb = ctx->DrawBuffer->_DepthBuffer;             \
   struct gl_query_object *q = ctx->Query.CurrentOcclusionObject;       \
   ASSERT(ctx->Depth.Test);                                             \
   ASSERT(!ctx->Depth.Mask);                                            \
   ASSERT(ctx->Depth.Func == GL_LESS);                                  \
   if (!q) {                                                            \
      return;                                                           \
   }

#define SETUP_CODE

Value:

struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];     \
   struct gl_texture_object *obj =                                      \
      ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX];                \
   const GLint b = obj->BaseLevel;                                      \
   const GLfloat twidth = (GLfloat) obj->Image[0][b]->Width;            \
   const GLfloat theight = (GLfloat) obj->Image[0][b]->Height;          \
   const GLint twidth_log2 = obj->Image[0][b]->WidthLog2;               \
   const GLchan *texture = (const GLchan *) obj->Image[0][b]->Data;     \
   const GLint smask = obj->Image[0][b]->Width - 1;                     \
   const GLint tmask = obj->Image[0][b]->Height - 1;                    \
   if (!rb || !texture) {                                               \
      return;                                                           \
   }

#define SETUP_CODE

Value:

struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];     \
   struct gl_texture_object *obj =                                      \
      ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX];                \
   const GLint b = obj->BaseLevel;                                      \
   const GLfloat twidth = (GLfloat) obj->Image[0][b]->Width;            \
   const GLfloat theight = (GLfloat) obj->Image[0][b]->Height;          \
   const GLint twidth_log2 = obj->Image[0][b]->WidthLog2;               \
   const GLchan *texture = (const GLchan *) obj->Image[0][b]->Data;     \
   const GLint smask = obj->Image[0][b]->Width - 1;                     \
   const GLint tmask = obj->Image[0][b]->Height - 1;                    \
   if (!rb || !texture) {                                               \
      return;                                                           \
   }

#define SETUP_CODE

Value:

{                                               \
      /* texturing must be off */               \
      ASSERT(ctx->Texture._EnabledCoordUnits == 0);     \
      ASSERT(ctx->Light.ShadeModel==GL_SMOOTH); \
   }

#define SETUP_CODE

Value:

ASSERT(ctx->Texture._EnabledCoordUnits == 0);\
   ASSERT(ctx->Light.ShadeModel==GL_FLAT);      \
   span.interpMask |= SPAN_RGBA;                \
   span.red = ChanToFixed(v2->color[0]);        \
   span.green = ChanToFixed(v2->color[1]);      \
   span.blue = ChanToFixed(v2->color[2]);       \
   span.alpha = ChanToFixed(v2->color[3]);      \
   span.redStep = 0;                            \
   span.greenStep = 0;                          \
   span.blueStep = 0;                           \
   span.alphaStep = 0;

#define T_SCALE   theight

#define T_SCALE   theight

#define USE ( triFunc   )     swrast->Triangle = triFunc;


Function Documentation

void _swrast_add_spec_terms_triangle ( GLcontext ctx,
const SWvertex v0,
const SWvertex v1,
const SWvertex v2 
)

void _swrast_choose_triangle ( GLcontext ctx  ) 

GLboolean _swrast_culltriangle ( GLcontext ctx,
const SWvertex v0,
const SWvertex v1,
const SWvertex v2 
)

Test if a triangle should be culled.

Used for feedback and selection mode.

Returns:
GL_TRUE if the triangle is to be culled, GL_FALSE otherwise.

static void nodraw_triangle ( GLcontext ctx,
const SWvertex v0,
const SWvertex v1,
const SWvertex v2 
) [static]


Generated on Sun Sep 27 06:48:05 2009 for Mesa Software Rasterization (swrast) by  doxygen 1.5.4