25 lines
577 B
C++
25 lines
577 B
C++
#include "dvr_triangle.h"
|
|
#include "rasterizer/dvc_rasterizer_triangle.h"
|
|
|
|
void Triangle::build(const davinci::fVector3& _pixelColor, int32_t canvasWidth, int32_t canvasHeight, bool debug)
|
|
{
|
|
pixelColor = _pixelColor;
|
|
pixels.clear();
|
|
|
|
//make sure it's cw
|
|
bool ccw = false;
|
|
if ((p2 - p1).crossProduct(p0 - p2).z > 0) {
|
|
ccw = true;
|
|
}
|
|
|
|
//build pixel data
|
|
davinci::Rasterizer::drawTriangleLarrabee(canvasWidth, canvasHeight,
|
|
p0.xy(), p1.xy(), p2.xy(),
|
|
[this](std::pair<int32_t, int32_t> pos, const davinci::fVector3& t)
|
|
{
|
|
pixels.push_back(pos);
|
|
},
|
|
ccw
|
|
);
|
|
}
|