TinyGL 0.4.1 for MinGW
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Macros | Functions
ztriangle.c File Reference
#include <stdlib.h>
#include "zbuffer.h"
#include "ztriangle.h"

Go to the source code of this file.

Macros

#define ZCMP(z, zpix)   ((z) >= (zpix))
 
#define INTERP_Z
 
#define DRAW_INIT()
 
#define PUT_PIXEL(_a)
 
#define INTERP_Z
 
#define INTERP_RGB
 
#define SAR_RND_TO_ZERO(v, n)   (v / (1<<n))
 
#define DRAW_INIT()
 
#define PUT_PIXEL(_a)
 
#define DRAW_LINE()
 
#define INTERP_Z
 
#define INTERP_ST
 
#define DRAW_INIT()
 
#define PUT_PIXEL(_a)
 
#define INTERP_Z
 
#define INTERP_STZ
 
#define NB_INTERP   8
 
#define DRAW_INIT()
 
#define PUT_PIXEL(_a)
 
#define DRAW_LINE()
 

Functions

void ZB_fillTriangleFlat (ZBuffer *zb, ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2)
 
void ZB_fillTriangleSmooth (ZBuffer *zb, ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2)
 
void ZB_setTexture (ZBuffer *zb, PIXEL *texture)
 
void ZB_fillTriangleMapping (ZBuffer *zb, ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2)
 
void ZB_fillTriangleMappingPerspective (ZBuffer *zb, ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2)
 

Macro Definition Documentation

◆ DRAW_INIT [1/4]

#define DRAW_INIT ( )
Value:
{ \
color=RGB_TO_PIXEL(p2->r,p2->g,p2->b); \
}
#define RGB_TO_PIXEL(r, g, b)
Definition: zbuffer.h:46

◆ DRAW_INIT [2/4]

#define DRAW_INIT ( )
Value:
{ \
_drgbdx=(SAR_RND_TO_ZERO(drdx,6) << 22) & 0xFFC00000; \
_drgbdx|=SAR_RND_TO_ZERO(dgdx,5) & 0x000007FF; \
_drgbdx|=(SAR_RND_TO_ZERO(dbdx,7) << 12) & 0x001FF000; \
}
#define SAR_RND_TO_ZERO(v, n)

◆ DRAW_INIT [3/4]

#define DRAW_INIT ( )
Value:
{ \
texture=zb->current_texture; \
}

◆ DRAW_INIT [4/4]

#define DRAW_INIT ( )
Value:
{ \
texture=zb->current_texture;\
fdzdx=(float)dzdx;\
fndzdx=NB_INTERP * fdzdx;\
ndszdx=NB_INTERP * dszdx;\
ndtzdx=NB_INTERP * dtzdx;\
}
#define NB_INTERP

◆ DRAW_LINE [1/2]

#define DRAW_LINE ( )
Value:
{ \
register unsigned short *pz; \
register PIXEL *pp; \
register unsigned int tmp,z,zz,rgb,drgbdx; \
register int n; \
n=(x2 >> 16) - x1; \
pp=pp1+x1; \
pz=pz1+x1; \
z=z1; \
rgb=(r1 << 16) & 0xFFC00000; \
rgb|=(g1 >> 5) & 0x000007FF; \
rgb|=(b1 << 5) & 0x001FF000; \
drgbdx=_drgbdx; \
while (n>=3) { \
PUT_PIXEL(0); \
PUT_PIXEL(1); \
PUT_PIXEL(2); \
PUT_PIXEL(3); \
pz+=4; \
pp+=4; \
n-=4; \
} \
while (n>=0) { \
PUT_PIXEL(0); \
pz+=1; \
pp+=1; \
n-=1; \
} \
}
unsigned short PIXEL
Definition: zbuffer.h:48
register PIXEL * pp
Definition: zline.h:4
int tmp
Definition: ztriangle.h:12
unsigned short * pz1
Definition: ztriangle.h:8
int x1
Definition: ztriangle.h:15
int x2
Definition: ztriangle.h:17
PIXEL * pp1
Definition: ztriangle.h:9

◆ DRAW_LINE [2/2]

#define DRAW_LINE ( )

◆ INTERP_RGB

#define INTERP_RGB

◆ INTERP_ST

#define INTERP_ST

◆ INTERP_STZ

#define INTERP_STZ

◆ INTERP_Z [1/4]

#define INTERP_Z

◆ INTERP_Z [2/4]

#define INTERP_Z

◆ INTERP_Z [3/4]

#define INTERP_Z

◆ INTERP_Z [4/4]

#define INTERP_Z

◆ NB_INTERP

#define NB_INTERP   8

◆ PUT_PIXEL [1/4]

#define PUT_PIXEL (   _a)
Value:
{ \
if (ZCMP(zz,pz[_a])) { \
pp[_a]=color; \
pz[_a]=zz; \
} \
z+=dzdx; \
}
#define ZB_POINT_Z_FRAC_BITS
Definition: zbuffer.h:12
#define ZCMP(z, zpix)
Definition: ztriangle.c:4

◆ PUT_PIXEL [2/4]

#define PUT_PIXEL (   _a)
Value:
{ \
if (ZCMP(zz,pz[_a])) { \
tmp=rgb & 0xF81F07E0; \
pp[_a]=tmp | (tmp >> 16); \
pz[_a]=zz; \
} \
z+=dzdx; \
rgb=(rgb+drgbdx) & ( ~ 0x00200800); \
}

◆ PUT_PIXEL [3/4]

#define PUT_PIXEL (   _a)
Value:
{ \
if (ZCMP(zz,pz[_a])) { \
pp[_a]=texture[((t & 0x3FC00000) | s) >> 14]; \
pz[_a]=zz; \
} \
z+=dzdx; \
s+=dsdx; \
t+=dtdx; \
}

◆ PUT_PIXEL [4/4]

#define PUT_PIXEL (   _a)
Value:
{ \
if (ZCMP(zz,pz[_a])) { \
pp[_a]=*(PIXEL *)((char *)texture+ \
(((t & 0x3FC00000) | (s & 0x003FC000)) >> (17 - PSZSH)));\
pz[_a]=zz; \
} \
z+=dzdx; \
s+=dsdx; \
t+=dtdx; \
}
#define PSZSH
Definition: zbuffer.h:50

◆ SAR_RND_TO_ZERO

#define SAR_RND_TO_ZERO (   v,
 
)    (v / (1<<n))

◆ ZCMP

#define ZCMP (   z,
  zpix 
)    ((z) >= (zpix))

Definition at line 4 of file ztriangle.c.

Function Documentation

◆ ZB_fillTriangleFlat()

void ZB_fillTriangleFlat ( ZBuffer zb,
ZBufferPoint p0,
ZBufferPoint p1,
ZBufferPoint p2 
)

Definition at line 6 of file ztriangle.c.

◆ ZB_fillTriangleMapping()

void ZB_fillTriangleMapping ( ZBuffer zb,
ZBufferPoint p0,
ZBufferPoint p1,
ZBufferPoint p2 
)

Definition at line 179 of file ztriangle.c.

◆ ZB_fillTriangleMappingPerspective()

void ZB_fillTriangleMappingPerspective ( ZBuffer zb,
ZBufferPoint p0,
ZBufferPoint p1,
ZBufferPoint p2 
)

Definition at line 236 of file ztriangle.c.

◆ ZB_fillTriangleSmooth()

void ZB_fillTriangleSmooth ( ZBuffer zb,
ZBufferPoint p0,
ZBufferPoint p1,
ZBufferPoint p2 
)

Definition at line 64 of file ztriangle.c.

◆ ZB_setTexture()

void ZB_setTexture ( ZBuffer zb,
PIXEL texture 
)

Definition at line 174 of file ztriangle.c.