ReactOS 0.4.15-dev-7842-g558ab78
triangle.c File Reference
#include <assert.h>
#include <math.h>
#include <stdio.h>
#include "depth.h"
#include "feedback.h"
#include "macros.h"
#include "span.h"
#include "texstate.h"
#include "triangle.h"
#include "types.h"
#include "vb.h"
#include "tritemp.h"
Include dependency graph for triangle.c:

Go to the source code of this file.

Macros

#define INTERP_Z   1
 
#define SETUP_CODE
 
#define INNER_LOOP(LEFT, RIGHT, Y)
 
#define INTERP_Z   1
 
#define INTERP_INDEX   1
 
#define INNER_LOOP(LEFT, RIGHT, Y)
 
#define INTERP_Z   1
 
#define SETUP_CODE
 
#define INNER_LOOP(LEFT, RIGHT, Y)
 
#define INTERP_Z   1
 
#define INTERP_RGB   1
 
#define INTERP_ALPHA   1
 
#define INNER_LOOP(LEFT, RIGHT, Y)
 
#define INTERP_ST   1
 
#define S_SCALE   twidth
 
#define T_SCALE   theight
 
#define SETUP_CODE
 
#define INNER_LOOP(LEFT, RIGHT, Y)
 
#define INTERP_Z   1
 
#define INTERP_ST   1
 
#define S_SCALE   twidth
 
#define T_SCALE   theight
 
#define SETUP_CODE
 
#define INNER_LOOP(LEFT, RIGHT, Y)
 
#define INTERP_Z   1
 
#define INTERP_RGB   1
 
#define INTERP_ALPHA   1
 
#define INTERP_STW   1
 
#define INTERP_UV   1
 
#define SETUP_CODE
 
#define INNER_LOOP(LEFT, RIGHT, Y)
 
#define INTERP_Z   1
 
#define INTERP_RGB   1
 
#define INTERP_ALPHA   1
 
#define INTERP_STW   1
 
#define INTERP_UV   1
 
#define SETUP_CODE
 
#define INNER_LOOP(LEFT, RIGHT, Y)
 

Functions

static void feedback_triangle (GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
 
static void select_triangle (GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
 
static void flat_ci_triangle (GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
 
static void smooth_ci_triangle (GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
 
static void flat_rgba_triangle (GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
 
static void smooth_rgba_triangle (GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
 
static void simple_textured_triangle (GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
 
static void simple_z_textured_triangle (GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
 
static void general_textured_triangle (GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
 
static GLfloat compute_lambda (GLfloat s, GLfloat t, GLfloat dsdx, GLfloat dsdy, GLfloat dtdx, GLfloat dtdy, GLfloat w, GLfloat dwdx, GLfloat dwdy, GLfloat width, GLfloat height)
 
static void lambda_textured_triangle (GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
 
static void null_triangle (GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
 
void gl_set_triangle_function (GLcontext *ctx)
 

Macro Definition Documentation

◆ INNER_LOOP [1/8]

#define INNER_LOOP (   LEFT,
  RIGHT,
  Y 
)
Value:
{ \
GLint i, n = RIGHT-LEFT; \
GLdepth zspan[MAX_WIDTH]; \
if (n>0) { \
for (i=0;i<n;i++) { \
zspan[i] = ffz; \
ffz += fdzdx; \
} \
gl_write_monoindex_span( ctx, n, LEFT, Y, \
zspan, index, GL_POLYGON ); \
} \
}
#define ffz(x)
Definition: bitops.h:109
#define Y(I)
#define MAX_WIDTH
Definition: config.h:130
GLint GLdepth
Definition: types.h:218
#define GL_POLYGON
Definition: gl.h:199
int GLint
Definition: gl.h:156
GLdouble n
Definition: glext.h:7729
GLuint index
Definition: glext.h:6031
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define LEFT
Definition: sprintf.c:26

◆ INNER_LOOP [2/8]

#define INNER_LOOP (   LEFT,
  RIGHT,
  Y 
)
Value:
{ \
GLint i, n = RIGHT-LEFT; \
GLdepth zspan[MAX_WIDTH]; \
if (n>0) { \
for (i=0;i<n;i++) { \
zspan[i] = ffz; \
index[i] = FixedToInt(ffi); \
ffz += fdzdx; \
ffi += fdidx; \
} \
gl_write_index_span( ctx, n, LEFT, Y, zspan, \
} \
}
#define FixedToInt(X)
Definition: fixed.h:47
unsigned int GLuint
Definition: gl.h:159

◆ INNER_LOOP [3/8]

#define INNER_LOOP (   LEFT,
  RIGHT,
  Y 
)
Value:
{ \
GLint i, n = RIGHT-LEFT; \
GLdepth zspan[MAX_WIDTH]; \
if (n>0) { \
for (i=0;i<n;i++) { \
zspan[i] = ffz; \
ffz += fdzdx; \
} \
gl_write_monocolor_span( ctx, n, LEFT, Y, zspan, \
VB->Color[pv][0], VB->Color[pv][1],\
VB->Color[pv][2], VB->Color[pv][3],\
} \
}
struct vertex_buffer * VB
Definition: tritemp.h:139

◆ INNER_LOOP [4/8]

#define INNER_LOOP (   LEFT,
  RIGHT,
  Y 
)
Value:
{ \
GLint i, n = RIGHT-LEFT; \
GLdepth zspan[MAX_WIDTH]; \
if (n>0) { \
for (i=0;i<n;i++) { \
zspan[i] = ffz; \
red[i] = FixedToInt(ffr); \
green[i] = FixedToInt(ffg); \
blue[i] = FixedToInt(ffb); \
alpha[i] = FixedToInt(ffa); \
ffz += fdzdx; \
ffr += fdrdx; \
ffg += fdgdx; \
ffb += fdbdx; \
ffa += fdadx; \
} \
gl_write_color_span( ctx, n, LEFT, Y, zspan, \
} \
}
unsigned char GLubyte
Definition: gl.h:157
GLclampf green
Definition: gl.h:1740
GLclampf GLclampf GLclampf alpha
Definition: gl.h:1740
GLclampf GLclampf blue
Definition: gl.h:1740
#define red
Definition: linetest.c:67

◆ INNER_LOOP [5/8]

#define INNER_LOOP (   LEFT,
  RIGHT,
  Y 
)
Value:
{ \
GLint i, n = RIGHT-LEFT; \
if (n>0) { \
for (i=0;i<n;i++) { \
GLint s = FixedToInt(ffs) & smask; \
GLint t = FixedToInt(fft) & tmask; \
GLint pos = (t << twidth_log2) + s; \
pos = pos + pos + pos; /* multiply by 3 */ \
red[i] = texture[pos]; \
green[i] = texture[pos+1]; \
blue[i] = texture[pos+2]; \
alpha[i] = 255; \
ffs += fdsdx; \
fft += fdtdx; \
} \
(*ctx->Driver.WriteColorSpan)( ctx, n, LEFT, Y, \
red, green, blue, alpha, NULL ); \
} \
}
#define NULL
Definition: types.h:112
GLdouble s
Definition: gl.h:2039
GLdouble GLdouble t
Definition: gl.h:2047
GLenum GLuint texture
Definition: glext.h:6295
#define ffs
Definition: port.h:359

◆ INNER_LOOP [6/8]

#define INNER_LOOP (   LEFT,
  RIGHT,
  Y 
)

◆ INNER_LOOP [7/8]

#define INNER_LOOP (   LEFT,
  RIGHT,
  Y 
)

◆ INNER_LOOP [8/8]

#define INNER_LOOP (   LEFT,
  RIGHT,
  Y 
)

◆ INTERP_ALPHA [1/3]

#define INTERP_ALPHA   1

◆ INTERP_ALPHA [2/3]

#define INTERP_ALPHA   1

◆ INTERP_ALPHA [3/3]

#define INTERP_ALPHA   1

◆ INTERP_INDEX

#define INTERP_INDEX   1

◆ INTERP_RGB [1/3]

#define INTERP_RGB   1

◆ INTERP_RGB [2/3]

#define INTERP_RGB   1

◆ INTERP_RGB [3/3]

#define INTERP_RGB   1

◆ INTERP_ST [1/2]

#define INTERP_ST   1

◆ INTERP_ST [2/2]

#define INTERP_ST   1

◆ INTERP_STW [1/2]

#define INTERP_STW   1

◆ INTERP_STW [2/2]

#define INTERP_STW   1

◆ INTERP_UV [1/2]

#define INTERP_UV   1

◆ INTERP_UV [2/2]

#define INTERP_UV   1

◆ INTERP_Z [1/7]

#define INTERP_Z   1

◆ INTERP_Z [2/7]

#define INTERP_Z   1

◆ INTERP_Z [3/7]

#define INTERP_Z   1

◆ INTERP_Z [4/7]

#define INTERP_Z   1

◆ INTERP_Z [5/7]

#define INTERP_Z   1

◆ INTERP_Z [6/7]

#define INTERP_Z   1

◆ INTERP_Z [7/7]

#define INTERP_Z   1

◆ S_SCALE [1/2]

#define S_SCALE   twidth

◆ S_SCALE [2/2]

#define S_SCALE   twidth

◆ SETUP_CODE [1/6]

#define SETUP_CODE
Value:
GLuint index = VB->Index[pv]; \
if (!VB->MonoColor) { \
/* set the color index */ \
(*ctx->Driver.Index)( ctx, index ); \
}

◆ SETUP_CODE [2/6]

#define SETUP_CODE
Value:
if (!VB->MonoColor) { \
/* set the color */ \
GLubyte r = VB->Color[pv][0]; \
GLubyte g = VB->Color[pv][1]; \
GLubyte b = VB->Color[pv][2]; \
GLubyte a = VB->Color[pv][3]; \
(*ctx->Driver.Color)( ctx, r, g, b, a ); \
}
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

◆ SETUP_CODE [3/6]

#define SETUP_CODE
Value:
GLfloat twidth = (GLfloat) ctx->Texture.Current2D->Image[0]->Width; \
GLfloat theight = (GLfloat) ctx->Texture.Current2D->Image[0]->Height;\
GLint twidth_log2 = ctx->Texture.Current2D->Image[0]->WidthLog2; \
GLubyte *texture = ctx->Texture.Current2D->Image[0]->Data; \
GLint smask = ctx->Texture.Current2D->Image[0]->Width - 1; \
GLint tmask = ctx->Texture.Current2D->Image[0]->Height - 1;
float GLfloat
Definition: gl.h:161

◆ SETUP_CODE [4/6]

#define SETUP_CODE
Value:
GLfloat twidth = (GLfloat) ctx->Texture.Current2D->Image[0]->Width; \
GLfloat theight = (GLfloat) ctx->Texture.Current2D->Image[0]->Height;\
GLint twidth_log2 = ctx->Texture.Current2D->Image[0]->WidthLog2; \
GLubyte *texture = ctx->Texture.Current2D->Image[0]->Data; \
GLint smask = ctx->Texture.Current2D->Image[0]->Width - 1; \
GLint tmask = ctx->Texture.Current2D->Image[0]->Height - 1;

◆ SETUP_CODE [5/6]

#define SETUP_CODE
Value:
GLboolean flat_shade = (ctx->Light.ShadeModel==GL_FLAT); \
GLint r, g, b, a; \
if (flat_shade) { \
r = VB->Color[pv][0]; \
g = VB->Color[pv][1]; \
b = VB->Color[pv][2]; \
a = VB->Color[pv][3]; \
}
#define GL_FLAT
Definition: gl.h:338
unsigned char GLboolean
Definition: gl.h:151
#define a
Definition: ke_i.h:78
#define b
Definition: ke_i.h:79

◆ SETUP_CODE [6/6]

#define SETUP_CODE
Value:
GLboolean flat_shade = (ctx->Light.ShadeModel==GL_FLAT); \
GLint r, g, b, a; \
GLfloat twidth, theight; \
if (ctx->Texture.Enabled & TEXTURE_2D) { \
twidth = (GLfloat) ctx->Texture.Current2D->Image[0]->Width; \
theight = (GLfloat) ctx->Texture.Current2D->Image[0]->Height; \
} \
else { \
twidth = (GLfloat) ctx->Texture.Current1D->Image[0]->Width; \
theight = 1.0; \
} \
if (flat_shade) { \
r = VB->Color[pv][0]; \
g = VB->Color[pv][1]; \
b = VB->Color[pv][2]; \
a = VB->Color[pv][3]; \
}
#define TEXTURE_2D
Definition: types.h:895

◆ T_SCALE [1/2]

#define T_SCALE   theight

◆ T_SCALE [2/2]

#define T_SCALE   theight

Function Documentation

◆ compute_lambda()

static GLfloat compute_lambda ( GLfloat  s,
GLfloat  t,
GLfloat  dsdx,
GLfloat  dsdy,
GLfloat  dtdx,
GLfloat  dtdy,
GLfloat  w,
GLfloat  dwdx,
GLfloat  dwdy,
GLfloat  width,
GLfloat  height 
)
static

Definition at line 553 of file triangle.c.

558{
559 /* TODO: this function can probably be optimized a bit */
560 GLfloat invw = 1.0 / w;
561 GLfloat dudx, dudy, dvdx, dvdy;
562 GLfloat r1, r2, rho2;
563
564 dudx = (dsdx - s*dwdx) * invw * width;
565 dudy = (dsdy - s*dwdy) * invw * width;
566 dvdx = (dtdx - t*dwdx) * invw * height;
567 dvdy = (dtdy - t*dwdy) * invw * height;
568
569 r1 = dudx * dudx + dudy * dudy;
570 r2 = dvdx * dvdx + dvdy * dvdy;
571
572 /* rho2 = MAX2(r1,r2); */
573 rho2 = r1 + r2;
574 if (rho2 <= 0.0F) {
575 return 0.0F;
576 }
577 else {
578 /* return log base 2 of rho */
579 return log(rho2) * 1.442695 * 0.5; /* 1.442695 = 1/log(2) */
580 }
581}
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
static DNS_RECORDW r1
Definition: record.c:37
static DNS_RECORDW r2
Definition: record.c:38
#define log(outFile, fmt,...)
Definition: util.h:15

◆ feedback_triangle()

static void feedback_triangle ( GLcontext ctx,
GLuint  v0,
GLuint  v1,
GLuint  v2,
GLuint  pv 
)
static

Definition at line 145 of file triangle.c.

147{
148 struct vertex_buffer *VB = ctx->VB;
149 GLfloat color[4];
150 GLuint i;
151 GLfloat invRedScale = ctx->Visual->InvRedScale;
152 GLfloat invGreenScale = ctx->Visual->InvGreenScale;
153 GLfloat invBlueScale = ctx->Visual->InvBlueScale;
154 GLfloat invAlphaScale = ctx->Visual->InvAlphaScale;
155
157 FEEDBACK_TOKEN( ctx, (GLfloat) 3 ); /* three vertices */
158
159 if (ctx->Light.ShadeModel==GL_FLAT) {
160 /* flat shading - same color for each vertex */
161 color[0] = (GLfloat) VB->Color[pv][0] * invRedScale;
162 color[1] = (GLfloat) VB->Color[pv][1] * invGreenScale;
163 color[2] = (GLfloat) VB->Color[pv][2] * invBlueScale;
164 color[3] = (GLfloat) VB->Color[pv][3] * invAlphaScale;
165 }
166
167 for (i=0;i<3;i++) {
168 GLfloat x, y, z, w;
169 GLfloat tc[4];
170 GLuint v;
171 GLfloat invq;
172
173 if (i==0) v = v0;
174 else if (i==1) v = v1;
175 else v = v2;
176
177 x = VB->Win[v][0];
178 y = VB->Win[v][1];
179 z = VB->Win[v][2] / DEPTH_SCALE;
180 w = VB->Clip[v][3];
181
182 if (ctx->Light.ShadeModel==GL_SMOOTH) {
183 /* smooth shading - different color for each vertex */
184 color[0] = VB->Color[v][0] * invRedScale;
185 color[1] = VB->Color[v][1] * invGreenScale;
186 color[2] = VB->Color[v][2] * invBlueScale;
187 color[3] = VB->Color[v][3] * invAlphaScale;
188 }
189
190 invq = (VB->TexCoord[v][3]==0.0) ? 1.0 : (1.0F / VB->TexCoord[v][3]);
191 tc[0] = VB->TexCoord[v][0] * invq;
192 tc[1] = VB->TexCoord[v][1] * invq;
193 tc[2] = VB->TexCoord[v][2] * invq;
194 tc[3] = VB->TexCoord[v][3];
195
196 gl_feedback_vertex( ctx, x, y, z, w, color, (GLfloat) VB->Index[v], tc );
197 }
198}
#define DEPTH_SCALE
Definition: config.h:146
void gl_feedback_vertex(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, GLfloat w, const GLfloat color[4], GLfloat index, const GLfloat texcoord[4])
Definition: feedback.c:161
#define FEEDBACK_TOKEN(CTX, T)
Definition: feedback.h:39
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
const GLdouble * v
Definition: gl.h:2040
#define GL_SMOOTH
Definition: gl.h:339
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define GL_POLYGON_TOKEN
Definition: gl.h:400
GLuint color
Definition: glext.h:6243
const GLfloat * tc
Definition: glext.h:8925
GLfloat v0
Definition: glext.h:6061
GLfloat GLfloat v1
Definition: glext.h:6062
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063
GLdouble GLdouble z
Definition: glext.h:5874

Referenced by gl_set_triangle_function().

◆ flat_ci_triangle()

static void flat_ci_triangle ( GLcontext ctx,
GLuint  v0,
GLuint  v1,
GLuint  v2,
GLuint  pv 
)
static

Definition at line 220 of file triangle.c.

222{
223#define INTERP_Z 1
224
225#define SETUP_CODE \
226 GLuint index = VB->Index[pv]; \
227 if (!VB->MonoColor) { \
228 /* set the color index */ \
229 (*ctx->Driver.Index)( ctx, index ); \
230 }
231
232#define INNER_LOOP( LEFT, RIGHT, Y ) \
233 { \
234 GLint i, n = RIGHT-LEFT; \
235 GLdepth zspan[MAX_WIDTH]; \
236 if (n>0) { \
237 for (i=0;i<n;i++) { \
238 zspan[i] = ffz; \
239 ffz += fdzdx; \
240 } \
241 gl_write_monoindex_span( ctx, n, LEFT, Y, \
242 zspan, index, GL_POLYGON ); \
243 } \
244 }
245
246#include "tritemp.h"
247}

Referenced by gl_set_triangle_function().

◆ flat_rgba_triangle()

static void flat_rgba_triangle ( GLcontext ctx,
GLuint  v0,
GLuint  v1,
GLuint  v2,
GLuint  pv 
)
static

Definition at line 285 of file triangle.c.

287{
288#define INTERP_Z 1
289
290#define SETUP_CODE \
291 if (!VB->MonoColor) { \
292 /* set the color */ \
293 GLubyte r = VB->Color[pv][0]; \
294 GLubyte g = VB->Color[pv][1]; \
295 GLubyte b = VB->Color[pv][2]; \
296 GLubyte a = VB->Color[pv][3]; \
297 (*ctx->Driver.Color)( ctx, r, g, b, a ); \
298 }
299
300#define INNER_LOOP( LEFT, RIGHT, Y ) \
301 { \
302 GLint i, n = RIGHT-LEFT; \
303 GLdepth zspan[MAX_WIDTH]; \
304 if (n>0) { \
305 for (i=0;i<n;i++) { \
306 zspan[i] = ffz; \
307 ffz += fdzdx; \
308 } \
309 gl_write_monocolor_span( ctx, n, LEFT, Y, zspan, \
310 VB->Color[pv][0], VB->Color[pv][1],\
311 VB->Color[pv][2], VB->Color[pv][3],\
312 GL_POLYGON ); \
313 } \
314 }
315
316#include "tritemp.h"
317}

Referenced by gl_set_triangle_function().

◆ general_textured_triangle()

static void general_textured_triangle ( GLcontext ctx,
GLuint  v0,
GLuint  v1,
GLuint  v2,
GLuint  pv 
)
static

Definition at line 471 of file triangle.c.

473{
474#define INTERP_Z 1
475#define INTERP_RGB 1
476#define INTERP_ALPHA 1
477#define INTERP_STW 1
478#define INTERP_UV 1
479#define SETUP_CODE \
480 GLboolean flat_shade = (ctx->Light.ShadeModel==GL_FLAT); \
481 GLint r, g, b, a; \
482 if (flat_shade) { \
483 r = VB->Color[pv][0]; \
484 g = VB->Color[pv][1]; \
485 b = VB->Color[pv][2]; \
486 a = VB->Color[pv][3]; \
487 }
488#define INNER_LOOP( LEFT, RIGHT, Y ) \
489 { \
490 GLint i, n = RIGHT-LEFT; \
491 GLdepth zspan[MAX_WIDTH]; \
492 GLubyte red[MAX_WIDTH], green[MAX_WIDTH]; \
493 GLubyte blue[MAX_WIDTH], alpha[MAX_WIDTH]; \
494 GLfloat s[MAX_WIDTH], t[MAX_WIDTH], u[MAX_WIDTH]; \
495 if (n>0) { \
496 if (flat_shade) { \
497 for (i=0;i<n;i++) { \
498 GLdouble wwvvInv = 1.0 / (ww*vv); \
499 zspan[i] = ffz; \
500 red[i] = r; \
501 green[i] = g; \
502 blue[i] = b; \
503 alpha[i] = a; \
504 s[i] = ss*wwvvInv; \
505 t[i] = tt*wwvvInv; \
506 u[i] = uu*wwvvInv; \
507 ffz += fdzdx; \
508 ss += dsdx; \
509 tt += dtdx; \
510 uu += dudx; \
511 vv += dvdx; \
512 ww += dwdx; \
513 } \
514 } \
515 else { \
516 for (i=0;i<n;i++) { \
517 GLdouble wwvvInv = 1.0 / (ww*vv); \
518 zspan[i] = ffz; \
519 red[i] = FixedToInt(ffr); \
520 green[i] = FixedToInt(ffg); \
521 blue[i] = FixedToInt(ffb); \
522 alpha[i] = FixedToInt(ffa); \
523 s[i] = ss*wwvvInv; \
524 t[i] = tt*wwvvInv; \
525 u[i] = uu*wwvvInv; \
526 ffz += fdzdx; \
527 ffr += fdrdx; \
528 ffg += fdgdx; \
529 ffb += fdbdx; \
530 ffa += fdadx; \
531 ss += dsdx; \
532 tt += dtdx; \
533 uu += dudx; \
534 ww += dwdx; \
535 vv += dvdx; \
536 } \
537 } \
538 gl_write_texture_span( ctx, n, LEFT, Y, zspan, \
539 s, t, u, NULL, \
540 red, green, blue, alpha, \
541 GL_POLYGON ); \
542 } \
543 }
544
545#include "tritemp.h"
546}

Referenced by gl_set_triangle_function().

◆ gl_set_triangle_function()

void gl_set_triangle_function ( GLcontext ctx)

Definition at line 708 of file triangle.c.

709{
710 GLboolean rgbmode = ctx->Visual->RGBAflag;
711
712 if (ctx->RenderMode==GL_RENDER) {
713 if (ctx->NoRaster) {
714 ctx->Driver.TriangleFunc = null_triangle;
715 return;
716 }
717 if (ctx->Driver.TriangleFunc) {
718 /* Device driver will draw triangles. */
719 }
720 else if (ctx->Texture.Enabled
721 && ctx->Texture.Current
722 && ctx->Texture.Current->Complete) {
723 if ( (ctx->Texture.Enabled==TEXTURE_2D)
724 && ctx->Texture.Current2D->MinFilter==GL_NEAREST
725 && ctx->Texture.Current2D->MagFilter==GL_NEAREST
726 && ctx->Texture.Current2D->WrapS==GL_REPEAT
727 && ctx->Texture.Current2D->WrapT==GL_REPEAT
728 && ctx->Texture.Current2D->Image[0]->Format==GL_RGB
729 && ctx->Texture.Current2D->Image[0]->Border==0
730 && (ctx->Texture.EnvMode==GL_DECAL
731 || ctx->Texture.EnvMode==GL_REPLACE)
732 && ctx->Hint.PerspectiveCorrection==GL_FASTEST
733 && ctx->TextureMatrixType==MATRIX_IDENTITY
734 && ((ctx->RasterMask==DEPTH_BIT
735 && ctx->Depth.Func==GL_LESS
736 && ctx->Depth.Mask==GL_TRUE)
737 || ctx->RasterMask==0)
738 && ctx->Polygon.StippleFlag==GL_FALSE
739 && ctx->Visual->EightBitColor) {
740 if (ctx->RasterMask==DEPTH_BIT) {
741 ctx->Driver.TriangleFunc = simple_z_textured_triangle;
742 }
743 else {
744 ctx->Driver.TriangleFunc = simple_textured_triangle;
745 }
746 }
747 else {
748 GLboolean needLambda = GL_TRUE;
749 /* if mag filter == min filter we're not mipmapping */
750 if (ctx->Texture.Enabled & TEXTURE_2D) {
751 if (ctx->Texture.Current2D->MinFilter==
752 ctx->Texture.Current2D->MagFilter) {
753 needLambda = GL_FALSE;
754 }
755 }
756 else if (ctx->Texture.Enabled & TEXTURE_1D) {
757 if (ctx->Texture.Current1D->MinFilter==
758 ctx->Texture.Current1D->MagFilter) {
759 needLambda = GL_FALSE;
760 }
761 }
762 if (needLambda)
763 ctx->Driver.TriangleFunc = lambda_textured_triangle;
764 else
765 ctx->Driver.TriangleFunc = general_textured_triangle;
766 }
767 }
768 else {
769 if (ctx->Light.ShadeModel==GL_SMOOTH) {
770 /* smooth shaded, no texturing, stippled or some raster ops */
771 if (rgbmode)
772 ctx->Driver.TriangleFunc = smooth_rgba_triangle;
773 else
774 ctx->Driver.TriangleFunc = smooth_ci_triangle;
775 }
776 else {
777 /* flat shaded, no texturing, stippled or some raster ops */
778 if (rgbmode)
779 ctx->Driver.TriangleFunc = flat_rgba_triangle;
780 else
781 ctx->Driver.TriangleFunc = flat_ci_triangle;
782 }
783 }
784 }
785 else if (ctx->RenderMode==GL_FEEDBACK) {
786 ctx->Driver.TriangleFunc = feedback_triangle;
787 }
788 else {
789 /* GL_SELECT mode */
790 ctx->Driver.TriangleFunc = select_triangle;
791 }
792}
#define TEXTURE_1D
Definition: types.h:894
#define DEPTH_BIT
Definition: types.h:1217
#define MATRIX_IDENTITY
Definition: types.h:1243
#define GL_RENDER
Definition: gl.h:388
#define GL_TRUE
Definition: gl.h:174
#define GL_FASTEST
Definition: gl.h:584
#define GL_LESS
Definition: gl.h:294
#define GL_FEEDBACK
Definition: gl.h:387
#define GL_RGB
Definition: gl.h:502
#define GL_NEAREST
Definition: gl.h:678
#define GL_DECAL
Definition: gl.h:676
#define GL_REPEAT
Definition: gl.h:679
#define GL_FALSE
Definition: gl.h:173
#define GL_REPLACE
Definition: gl.h:460
static void flat_rgba_triangle(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
Definition: triangle.c:285
static void smooth_rgba_triangle(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
Definition: triangle.c:324
static void simple_textured_triangle(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
Definition: triangle.c:365
static void flat_ci_triangle(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
Definition: triangle.c:220
static void feedback_triangle(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
Definition: triangle.c:145
static void simple_z_textured_triangle(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
Definition: triangle.c:412
static void null_triangle(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
Definition: triangle.c:697
static void smooth_ci_triangle(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
Definition: triangle.c:254
static void lambda_textured_triangle(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
Definition: triangle.c:592
static void select_triangle(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
Definition: triangle.c:205
static void general_textured_triangle(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
Definition: triangle.c:471

Referenced by gl_update_state().

◆ lambda_textured_triangle()

static void lambda_textured_triangle ( GLcontext ctx,
GLuint  v0,
GLuint  v1,
GLuint  v2,
GLuint  pv 
)
static

Definition at line 592 of file triangle.c.

594{
595#define INTERP_Z 1
596#define INTERP_RGB 1
597#define INTERP_ALPHA 1
598#define INTERP_STW 1
599#define INTERP_UV 1
600
601#define SETUP_CODE \
602 GLboolean flat_shade = (ctx->Light.ShadeModel==GL_FLAT); \
603 GLint r, g, b, a; \
604 GLfloat twidth, theight; \
605 if (ctx->Texture.Enabled & TEXTURE_2D) { \
606 twidth = (GLfloat) ctx->Texture.Current2D->Image[0]->Width; \
607 theight = (GLfloat) ctx->Texture.Current2D->Image[0]->Height; \
608 } \
609 else { \
610 twidth = (GLfloat) ctx->Texture.Current1D->Image[0]->Width; \
611 theight = 1.0; \
612 } \
613 if (flat_shade) { \
614 r = VB->Color[pv][0]; \
615 g = VB->Color[pv][1]; \
616 b = VB->Color[pv][2]; \
617 a = VB->Color[pv][3]; \
618 }
619
620#define INNER_LOOP( LEFT, RIGHT, Y ) \
621 { \
622 GLint i, n = RIGHT-LEFT; \
623 GLdepth zspan[MAX_WIDTH]; \
624 GLubyte red[MAX_WIDTH], green[MAX_WIDTH]; \
625 GLubyte blue[MAX_WIDTH], alpha[MAX_WIDTH]; \
626 GLfloat s[MAX_WIDTH], t[MAX_WIDTH], u[MAX_WIDTH]; \
627 DEFARRAY(GLfloat,lambda,MAX_WIDTH); \
628 if (n>0) { \
629 if (flat_shade) { \
630 for (i=0;i<n;i++) { \
631 GLdouble wwvvInv = 1.0 / (ww*vv); \
632 zspan[i] = ffz; \
633 red[i] = r; \
634 green[i] = g; \
635 blue[i] = b; \
636 alpha[i] = a; \
637 s[i] = ss*wwvvInv; \
638 t[i] = tt*wwvvInv; \
639 u[i] = uu*wwvvInv; \
640 lambda[i] = compute_lambda( s[i], t[i], \
641 dsdx, dsdy, \
642 dtdx, dtdy, ww, \
643 dwdx, dwdy, \
644 twidth, theight ); \
645 ffz += fdzdx; \
646 ss += dsdx; \
647 tt += dtdx; \
648 uu += dudx; \
649 vv += dvdx; \
650 ww += dwdx; \
651 } \
652 } \
653 else { \
654 for (i=0;i<n;i++) { \
655 GLdouble wwvvInv = 1.0 / (ww*vv); \
656 zspan[i] = ffz; \
657 red[i] = FixedToInt(ffr); \
658 green[i] = FixedToInt(ffg); \
659 blue[i] = FixedToInt(ffb); \
660 alpha[i] = FixedToInt(ffa); \
661 s[i] = ss*wwvvInv; \
662 t[i] = tt*wwvvInv; \
663 u[i] = uu*wwvvInv; \
664 lambda[i] = compute_lambda( s[i], t[i], \
665 dsdx, dsdy, \
666 dtdx, dtdy, ww, \
667 dwdx, dwdy, \
668 twidth, theight ); \
669 ffz += fdzdx; \
670 ffr += fdrdx; \
671 ffg += fdgdx; \
672 ffb += fdbdx; \
673 ffa += fdadx; \
674 ss += dsdx; \
675 tt += dtdx; \
676 uu += dudx; \
677 vv += dvdx; \
678 ww += dwdx; \
679 } \
680 } \
681 gl_write_texture_span( ctx, n, LEFT, Y, zspan, \
682 s, t, u, lambda, \
683 red, green, blue, alpha, \
684 GL_POLYGON ); \
685 } \
686 UNDEFARRAY(lambda); \
687 }
688
689#include "tritemp.h"
690}

Referenced by gl_set_triangle_function().

◆ null_triangle()

static void null_triangle ( GLcontext ctx,
GLuint  v0,
GLuint  v1,
GLuint  v2,
GLuint  pv 
)
static

Definition at line 697 of file triangle.c.

699{
700}

Referenced by gl_set_triangle_function().

◆ select_triangle()

static void select_triangle ( GLcontext ctx,
GLuint  v0,
GLuint  v1,
GLuint  v2,
GLuint  pv 
)
static

Definition at line 205 of file triangle.c.

207{
208 struct vertex_buffer *VB = ctx->VB;
209
210 gl_update_hitflag( ctx, VB->Win[v0][2] / DEPTH_SCALE );
211 gl_update_hitflag( ctx, VB->Win[v1][2] / DEPTH_SCALE );
212 gl_update_hitflag( ctx, VB->Win[v2][2] / DEPTH_SCALE );
213}
void gl_update_hitflag(GLcontext *ctx, GLfloat z)
Definition: feedback.c:240

Referenced by gl_set_triangle_function().

◆ simple_textured_triangle()

static void simple_textured_triangle ( GLcontext ctx,
GLuint  v0,
GLuint  v1,
GLuint  v2,
GLuint  pv 
)
static

Definition at line 365 of file triangle.c.

367{
368#define INTERP_ST 1
369#define S_SCALE twidth
370#define T_SCALE theight
371#define SETUP_CODE \
372 GLfloat twidth = (GLfloat) ctx->Texture.Current2D->Image[0]->Width; \
373 GLfloat theight = (GLfloat) ctx->Texture.Current2D->Image[0]->Height;\
374 GLint twidth_log2 = ctx->Texture.Current2D->Image[0]->WidthLog2; \
375 GLubyte *texture = ctx->Texture.Current2D->Image[0]->Data; \
376 GLint smask = ctx->Texture.Current2D->Image[0]->Width - 1; \
377 GLint tmask = ctx->Texture.Current2D->Image[0]->Height - 1;
378
379#define INNER_LOOP( LEFT, RIGHT, Y ) \
380 { \
381 GLint i, n = RIGHT-LEFT; \
382 GLubyte red[MAX_WIDTH], green[MAX_WIDTH]; \
383 GLubyte blue[MAX_WIDTH], alpha[MAX_WIDTH]; \
384 if (n>0) { \
385 for (i=0;i<n;i++) { \
386 GLint s = FixedToInt(ffs) & smask; \
387 GLint t = FixedToInt(fft) & tmask; \
388 GLint pos = (t << twidth_log2) + s; \
389 pos = pos + pos + pos; /* multiply by 3 */ \
390 red[i] = texture[pos]; \
391 green[i] = texture[pos+1]; \
392 blue[i] = texture[pos+2]; \
393 alpha[i] = 255; \
394 ffs += fdsdx; \
395 fft += fdtdx; \
396 } \
397 (*ctx->Driver.WriteColorSpan)( ctx, n, LEFT, Y, \
398 red, green, blue, alpha, NULL ); \
399 } \
400 }
401
402#include "tritemp.h"
403}

Referenced by gl_set_triangle_function().

◆ simple_z_textured_triangle()

static void simple_z_textured_triangle ( GLcontext ctx,
GLuint  v0,
GLuint  v1,
GLuint  v2,
GLuint  pv 
)
static

Definition at line 412 of file triangle.c.

414{
415#define INTERP_Z 1
416#define INTERP_ST 1
417#define S_SCALE twidth
418#define T_SCALE theight
419#define SETUP_CODE \
420 GLfloat twidth = (GLfloat) ctx->Texture.Current2D->Image[0]->Width; \
421 GLfloat theight = (GLfloat) ctx->Texture.Current2D->Image[0]->Height;\
422 GLint twidth_log2 = ctx->Texture.Current2D->Image[0]->WidthLog2; \
423 GLubyte *texture = ctx->Texture.Current2D->Image[0]->Data; \
424 GLint smask = ctx->Texture.Current2D->Image[0]->Width - 1; \
425 GLint tmask = ctx->Texture.Current2D->Image[0]->Height - 1;
426
427#define INNER_LOOP( LEFT, RIGHT, Y ) \
428 { \
429 GLint i, n = RIGHT-LEFT; \
430 GLubyte red[MAX_WIDTH], green[MAX_WIDTH]; \
431 GLubyte blue[MAX_WIDTH], alpha[MAX_WIDTH]; \
432 GLubyte mask[MAX_WIDTH]; \
433 if (n>0) { \
434 for (i=0;i<n;i++) { \
435 GLdepth z = ffz; \
436 if (z < zRow[i]) { \
437 GLint s = FixedToInt(ffs) & smask; \
438 GLint t = FixedToInt(fft) & tmask; \
439 GLint pos = (t << twidth_log2) + s; \
440 pos = pos + pos + pos; /* multiply by 3 */\
441 red[i] = texture[pos]; \
442 green[i] = texture[pos+1]; \
443 blue[i] = texture[pos+2]; \
444 alpha[i] = 255; \
445 zRow[i] = z; \
446 mask[i] = 1; \
447 } \
448 else { \
449 mask[i] = 0; \
450 } \
451 ffz += fdzdx; \
452 ffs += fdsdx; \
453 fft += fdtdx; \
454 } \
455 (*ctx->Driver.WriteColorSpan)( ctx, n, LEFT, Y, \
456 red, green, blue, alpha, mask ); \
457 } \
458 }
459
460#include "tritemp.h"
461}

Referenced by gl_set_triangle_function().

◆ smooth_ci_triangle()

static void smooth_ci_triangle ( GLcontext ctx,
GLuint  v0,
GLuint  v1,
GLuint  v2,
GLuint  pv 
)
static

Definition at line 254 of file triangle.c.

256{
257#define INTERP_Z 1
258#define INTERP_INDEX 1
259
260#define INNER_LOOP( LEFT, RIGHT, Y ) \
261 { \
262 GLint i, n = RIGHT-LEFT; \
263 GLdepth zspan[MAX_WIDTH]; \
264 GLuint index[MAX_WIDTH]; \
265 if (n>0) { \
266 for (i=0;i<n;i++) { \
267 zspan[i] = ffz; \
268 index[i] = FixedToInt(ffi); \
269 ffz += fdzdx; \
270 ffi += fdidx; \
271 } \
272 gl_write_index_span( ctx, n, LEFT, Y, zspan, \
273 index, GL_POLYGON ); \
274 } \
275 }
276
277#include "tritemp.h"
278}

Referenced by gl_set_triangle_function().

◆ smooth_rgba_triangle()

static void smooth_rgba_triangle ( GLcontext ctx,
GLuint  v0,
GLuint  v1,
GLuint  v2,
GLuint  pv 
)
static

Definition at line 324 of file triangle.c.

326{
327#define INTERP_Z 1
328#define INTERP_RGB 1
329#define INTERP_ALPHA 1
330
331#define INNER_LOOP( LEFT, RIGHT, Y ) \
332 { \
333 GLint i, n = RIGHT-LEFT; \
334 GLdepth zspan[MAX_WIDTH]; \
335 GLubyte red[MAX_WIDTH], green[MAX_WIDTH]; \
336 GLubyte blue[MAX_WIDTH], alpha[MAX_WIDTH]; \
337 if (n>0) { \
338 for (i=0;i<n;i++) { \
339 zspan[i] = ffz; \
340 red[i] = FixedToInt(ffr); \
341 green[i] = FixedToInt(ffg); \
342 blue[i] = FixedToInt(ffb); \
343 alpha[i] = FixedToInt(ffa); \
344 ffz += fdzdx; \
345 ffr += fdrdx; \
346 ffg += fdgdx; \
347 ffb += fdbdx; \
348 ffa += fdadx; \
349 } \
350 gl_write_color_span( ctx, n, LEFT, Y, zspan, \
351 red, green, blue, alpha, \
352 GL_POLYGON ); \
353 } \
354 }
355
356#include "tritemp.h"
357}

Referenced by gl_set_triangle_function().