scummvm/graphics/tinygl/zline.cpp

71 lines
1.6 KiB
C++
Raw Normal View History

2009-05-08 07:32:33 +00:00
#include "graphics/tinygl/zbuffer.h"
namespace TinyGL {
#define ZCMP(z,zpix) ((z) >= (zpix))
void ZBuffer::plot(ZBufferPoint *p) {
unsigned int *pz;
2006-05-16 14:52:36 +00:00
PIXEL *pp;
pz = zbuf + (p->y * xsize + p->x);
pp = (PIXEL *)((char *) pbuf.getRawBuffer() + linesize * p->y + p->x * PSZB);
if (ZCMP((unsigned int)p->z, *pz)) {
*pp = RGB_TO_PIXEL(p->r, p->g, p->b);
*pz = p->z;
}
}
#define INTERP_Z
void ZBuffer::fillLineFlatZ(ZBufferPoint *p1, ZBufferPoint *p2, int color) {
2009-05-08 07:32:33 +00:00
#include "graphics/tinygl/zline.h"
}
2006-05-16 14:52:36 +00:00
// line with color interpolation
#define INTERP_Z
#define INTERP_RGB
void ZBuffer::fillLineInterpZ(ZBufferPoint *p1, ZBufferPoint *p2) {
2009-05-08 07:32:33 +00:00
#include "graphics/tinygl/zline.h"
}
2006-05-16 14:52:36 +00:00
// no Z interpolation
void ZBuffer::fillLineFlat(ZBufferPoint *p1, ZBufferPoint *p2, int color) {
2009-05-08 07:32:33 +00:00
#include "graphics/tinygl/zline.h"
}
#define INTERP_RGB
void ZBuffer::fillLineInterp(ZBufferPoint *p1, ZBufferPoint *p2) {
2009-05-08 07:32:33 +00:00
#include "graphics/tinygl/zline.h"
}
void ZBuffer::fillLineZ(ZBufferPoint *p1, ZBufferPoint *p2) {
2006-05-16 14:52:36 +00:00
int color1, color2;
2006-05-16 14:52:36 +00:00
color1 = RGB_TO_PIXEL(p1->r, p1->g, p1->b);
color2 = RGB_TO_PIXEL(p2->r, p2->g, p2->b);
// choose if the line should have its color interpolated or not
2006-05-16 14:52:36 +00:00
if (color1 == color2) {
fillLineFlatZ(p1, p2, color1);
2006-05-16 14:52:36 +00:00
} else {
fillLineInterpZ(p1, p2);
2006-05-16 14:52:36 +00:00
}
}
void ZBuffer::fillLine(ZBufferPoint *p1, ZBufferPoint *p2) {
2006-05-16 14:52:36 +00:00
int color1, color2;
2006-05-16 14:52:36 +00:00
color1 = RGB_TO_PIXEL(p1->r, p1->g, p1->b);
color2 = RGB_TO_PIXEL(p2->r, p2->g, p2->b);
2006-05-16 14:52:36 +00:00
// choose if the line should have its color interpolated or not
if (color1 == color2) {
fillLineFlat(p1, p2, color1);
2006-05-16 14:52:36 +00:00
} else {
fillLineInterp(p1, p2);
2006-05-16 14:52:36 +00:00
}
}
} // end of namespace TinyGL