-/* $Id: s_triangle.c,v 1.2 2000/11/05 18:24:41 keithw Exp $ */
+/* $Id: s_triangle.c,v 1.8 2001/01/05 02:26:49 keithw Exp $ */
/*
* Mesa 3-D graphics library
#include "s_triangle.h"
GLboolean gl_cull_triangle( GLcontext *ctx,
- SWvertex *v0,
- SWvertex *v1,
- SWvertex *v2 )
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
{
GLfloat ex = v1->win[0] - v0->win[0];
GLfloat ey = v1->win[1] - v0->win[1];
GLfloat fy = v2->win[1] - v0->win[1];
GLfloat c = ex*fy-ey*fx;
- if (c * ctx->_backface_sign > 0)
+ if (c * SWRAST_CONTEXT(ctx)->_backface_sign > 0)
return 0;
return 1;
* Render a flat-shaded color index triangle.
*/
static void flat_ci_triangle( GLcontext *ctx,
- SWvertex *v0,
- SWvertex *v1,
- SWvertex *v2 )
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
{
#define INTERP_Z 1
-#define SETUP_CODE \
- GLuint index = v0->index; \
- if (1) { \
- /* set the color index */ \
- (*ctx->Driver.Index)( ctx, index ); \
- }
#define INNER_LOOP( LEFT, RIGHT, Y ) \
{ \
fffog += fdfogdx; \
} \
gl_write_monoindex_span( ctx, n, LEFT, Y, zspan, \
- fogspan, index, GL_POLYGON ); \
+ fogspan, v0->index, GL_POLYGON ); \
} \
}
* Render a smooth-shaded color index triangle.
*/
static void smooth_ci_triangle( GLcontext *ctx,
- SWvertex *v0,
- SWvertex *v1,
- SWvertex *v2 )
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
{
#define INTERP_Z 1
#define INTERP_INDEX 1
* Render a flat-shaded RGBA triangle.
*/
static void flat_rgba_triangle( GLcontext *ctx,
- SWvertex *v0,
- SWvertex *v1,
- SWvertex *v2 )
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
{
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define SETUP_CODE \
- if (1) { \
- /* set the color */ \
- GLchan r = v0->color[0]; \
- GLchan g = v0->color[1]; \
- GLchan b = v0->color[2]; \
- GLchan a = v0->color[3]; \
- (*ctx->Driver.Color)( ctx, r, g, b, a ); \
- }
-
#define INNER_LOOP( LEFT, RIGHT, Y ) \
{ \
const GLint n = RIGHT-LEFT; \
fffog += fdfogdx; \
} \
gl_write_monocolor_span( ctx, n, LEFT, Y, zspan, \
- fogspan, \
- v0->color, \
+ fogspan, v2->color, \
GL_POLYGON ); \
} \
}
* Render a smooth-shaded RGBA triangle.
*/
static void smooth_rgba_triangle( GLcontext *ctx,
- SWvertex *v0,
- SWvertex *v1,
- SWvertex *v2 )
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
{
#define INTERP_Z 1
* No fog.
*/
static void simple_textured_triangle( GLcontext *ctx,
- SWvertex *v0,
- SWvertex *v1,
- SWvertex *v2 )
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
{
#define INTERP_INT_TEX 1
#define S_SCALE twidth
#define T_SCALE theight
#define SETUP_CODE \
- struct gl_texture_object *obj = ctx->Texture.Unit[0].CurrentD[2]; \
+ struct gl_texture_object *obj = ctx->Texture.Unit[0].Current2D; \
GLint b = obj->BaseLevel; \
GLfloat twidth = (GLfloat) obj->Image[b]->Width; \
GLfloat theight = (GLfloat) obj->Image[b]->Height; \
* No fog.
*/
static void simple_z_textured_triangle( GLcontext *ctx,
- SWvertex *v0,
- SWvertex *v1,
- SWvertex *v2 )
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
{
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define S_SCALE twidth
#define T_SCALE theight
#define SETUP_CODE \
- struct gl_texture_object *obj = ctx->Texture.Unit[0].CurrentD[2]; \
+ struct gl_texture_object *obj = ctx->Texture.Unit[0].Current2D; \
GLint b = obj->BaseLevel; \
GLfloat twidth = (GLfloat) obj->Image[b]->Width; \
GLfloat theight = (GLfloat) obj->Image[b]->Height; \
* Render an RGB/RGBA textured triangle without perspective correction.
*/
static void affine_textured_triangle( GLcontext *ctx,
- SWvertex *v0,
- SWvertex *v1,
- SWvertex *v2 )
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
{
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define T_SCALE theight
#define SETUP_CODE \
struct gl_texture_unit *unit = ctx->Texture.Unit+0; \
- struct gl_texture_object *obj = unit->CurrentD[2]; \
+ struct gl_texture_object *obj = unit->Current2D; \
GLint b = obj->BaseLevel; \
GLfloat twidth = (GLfloat) obj->Image[b]->Width; \
GLfloat theight = (GLfloat) obj->Image[b]->Height; \
* This function written by Klaus Niederkrueger <klaus@math.leidenuniv.nl>
* Send all questions and bug reports to him.
*/
+#if 0 /* XXX disabled because of texcoord interpolation errors */
static void near_persp_textured_triangle(GLcontext *ctx,
- SWvertex *v0,
- SWvertex *v1,
- SWvertex *v2 )
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
{
/* The BIAS value is used to shift negative values into positive values.
* Without this, negative texture values don't GL_REPEAT correctly at just
#define INTERP_TEX 1
#define SETUP_CODE \
struct gl_texture_unit *unit = ctx->Texture.Unit+0; \
- struct gl_texture_object *obj = unit->CurrentD[2]; \
+ struct gl_texture_object *obj = unit->Current2D; \
const GLint b = obj->BaseLevel; \
const GLfloat twidth = (GLfloat) obj->Image[b]->Width; \
const GLfloat theight = (GLfloat) obj->Image[b]->Height; \
#undef DRAW_LINE
#undef BIAS
}
-
+#endif
/*
* This function written by Klaus Niederkrueger <klaus@math.leidenuniv.nl>
* Send all questions and bug reports to him.
*/
+#if 0 /* XXX disabled because of texcoord interpolation errors */
static void lin_persp_textured_triangle( GLcontext *ctx,
- SWvertex *v0,
- SWvertex *v1,
- SWvertex *v2 )
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
{
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_TEX 1
#define SETUP_CODE \
struct gl_texture_unit *unit = ctx->Texture.Unit+0; \
- struct gl_texture_object *obj = unit->CurrentD[2]; \
+ struct gl_texture_object *obj = unit->Current2D; \
const GLint b = obj->BaseLevel; \
const GLfloat twidth = (GLfloat) obj->Image[b]->Width; \
const GLfloat theight = (GLfloat) obj->Image[b]->Height; \
} \
}
-
#include "s_tritemp.h"
#undef SPAN
}
-
+#endif
/*
* R is already used for red.
*/
static void general_textured_triangle( GLcontext *ctx,
- SWvertex *v0,
- SWvertex *v1,
- SWvertex *v2 )
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
{
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
GLboolean flat_shade = (ctx->Light.ShadeModel==GL_FLAT); \
GLint r, g, b, a; \
if (flat_shade) { \
- r = v0->color[0]; \
- g = v0->color[1]; \
- b = v0->color[2]; \
- a = v0->color[3]; \
+ r = v2->color[0]; \
+ g = v2->color[1]; \
+ b = v2->color[2]; \
+ a = v2->color[3]; \
}
#define INNER_LOOP( LEFT, RIGHT, Y ) \
{ \
* R is already used for red.
*/
static void general_textured_spec_triangle1( GLcontext *ctx,
- SWvertex *v0,
- SWvertex *v1,
- SWvertex *v2,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2,
GLdepth zspan[MAX_WIDTH],
GLfixed fogspan[MAX_WIDTH],
GLchan rgba[MAX_WIDTH][4],
GLboolean flat_shade = (ctx->Light.ShadeModel==GL_FLAT); \
GLint r, g, b, a, sr, sg, sb; \
if (flat_shade) { \
- r = v0->color[0]; \
- g = v0->color[1]; \
- b = v0->color[2]; \
- a = v0->color[3]; \
- sr = v0->specular[0]; \
- sg = v0->specular[1]; \
- sb = v0->specular[2]; \
+ r = v2->color[0]; \
+ g = v2->color[1]; \
+ b = v2->color[2]; \
+ a = v2->color[3]; \
+ sr = v2->specular[0]; \
+ sg = v2->specular[1]; \
+ sb = v2->specular[2]; \
}
#define INNER_LOOP( LEFT, RIGHT, Y ) \
{ \
* mipmaps, lambda is also used to select the texture level of detail.
*/
static void lambda_textured_triangle1( GLcontext *ctx,
- SWvertex *v0,
- SWvertex *v1,
- SWvertex *v2,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2,
GLfloat s[MAX_WIDTH],
GLfloat t[MAX_WIDTH],
GLfloat u[MAX_WIDTH] )
const GLboolean flat_shade = (ctx->Light.ShadeModel==GL_FLAT); \
GLint r, g, b, a; \
if (flat_shade) { \
- r = v0->color[0]; \
- g = v0->color[1]; \
- b = v0->color[2]; \
- a = v0->color[3]; \
+ r = v2->color[0]; \
+ g = v2->color[1]; \
+ b = v2->color[2]; \
+ a = v2->color[3]; \
}
#define INNER_LOOP( LEFT, RIGHT, Y ) \
* mipmaps, lambda is also used to select the texture level of detail.
*/
static void lambda_textured_spec_triangle1( GLcontext *ctx,
- SWvertex *v0,
- SWvertex *v1,
- SWvertex *v2,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2,
GLfloat s[MAX_WIDTH],
GLfloat t[MAX_WIDTH],
GLfloat u[MAX_WIDTH] )
const GLboolean flat_shade = (ctx->Light.ShadeModel==GL_FLAT); \
GLint r, g, b, a, sr, sg, sb; \
if (flat_shade) { \
- r = v0->color[0]; \
- g = v0->color[1]; \
- b = v0->color[2]; \
- a = v0->color[3]; \
- sr = v0->specular[0]; \
- sg = v0->specular[1]; \
- sb = v0->specular[2]; \
+ r = v2->color[0]; \
+ g = v2->color[1]; \
+ b = v2->color[2]; \
+ a = v2->color[3]; \
+ sr = v2->specular[0]; \
+ sg = v2->specular[1]; \
+ sb = v2->specular[2]; \
}
#define INNER_LOOP( LEFT, RIGHT, Y ) \
*/
static void
lambda_multitextured_triangle1( GLcontext *ctx,
- SWvertex *v0,
- SWvertex *v1,
- SWvertex *v2,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2,
GLfloat s[MAX_TEXTURE_UNITS][MAX_WIDTH],
GLfloat t[MAX_TEXTURE_UNITS][MAX_WIDTH],
GLfloat u[MAX_TEXTURE_UNITS][MAX_WIDTH])
GLfloat twidth[MAX_TEXTURE_UNITS], theight[MAX_TEXTURE_UNITS]; \
GLint r, g, b, a; \
if (flat_shade) { \
- r = v0->color[0]; \
- g = v0->color[1]; \
- b = v0->color[2]; \
- a = v0->color[3]; \
+ r = v2->color[0]; \
+ g = v2->color[1]; \
+ b = v2->color[2]; \
+ a = v2->color[3]; \
} \
{ \
GLuint unit; \
*/
static void general_textured_spec_triangle(GLcontext *ctx,
- SWvertex *v0,
- SWvertex *v1,
- SWvertex *v2 )
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
{
GLdepth zspan[MAX_WIDTH];
GLfixed fogspan[MAX_WIDTH];
}
static void lambda_textured_triangle( GLcontext *ctx,
- SWvertex *v0,
- SWvertex *v1,
- SWvertex *v2 )
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
{
GLfloat s[MAX_WIDTH], t[MAX_WIDTH], u[MAX_WIDTH];
lambda_textured_triangle1(ctx,v0,v1,v2,s,t,u);
}
static void lambda_textured_spec_triangle( GLcontext *ctx,
- SWvertex *v0,
- SWvertex *v1,
- SWvertex *v2 )
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
{
GLfloat s[MAX_WIDTH];
GLfloat t[MAX_WIDTH];
static void lambda_multitextured_triangle( GLcontext *ctx,
- SWvertex *v0,
- SWvertex *v1,
- SWvertex *v2 )
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
{
GLfloat s[MAX_TEXTURE_UNITS][MAX_WIDTH];
static void occlusion_zless_triangle( GLcontext *ctx,
- SWvertex *v0,
- SWvertex *v1,
- SWvertex *v2 )
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
{
if (ctx->OcclusionResult) {
return;
if (ctx->Texture._ReallyEnabled) {
/* Ugh, we do a _lot_ of tests to pick the best textured tri func */
GLint format, filter;
- const struct gl_texture_object *current2Dtex = ctx->Texture.Unit[0].CurrentD[2];
+ const struct gl_texture_object *current2Dtex = ctx->Texture.Unit[0].Current2D;
const struct gl_texture_image *image;
/* First see if we can used an optimized 2-D texture function */
if (ctx->Texture._ReallyEnabled==TEXTURE0_2D
}
}
else {
+#if 00 /* XXX these function have problems with texture coord interpolation */
if (filter==GL_NEAREST) {
swrast->Triangle = near_persp_textured_triangle;
dputs("near_persp_textured_triangle");
swrast->Triangle = lin_persp_textured_triangle;
dputs("lin_persp_textured_triangle");
}
+#endif
+ swrast->Triangle = general_textured_triangle;
}
}
else {
needLambda = GL_TRUE;
else
needLambda = GL_FALSE;
- if (ctx->Texture._MultiTextureEnabled) {
+ if (swrast->_MultiTextureEnabled) {
swrast->Triangle = lambda_multitextured_triangle;
dputs("lambda_multitextured_triangle");
}