Added color to rasterized polygons
This commit is contained in:
parent
bc34a2b823
commit
b86669c5a0
5 changed files with 14 additions and 6 deletions
|
@ -31,13 +31,15 @@ struct paysages::software::RenderScanlines
|
|||
int right;
|
||||
};
|
||||
|
||||
Rasterizer::Rasterizer(SoftwareRenderer* renderer, int client_id):
|
||||
Rasterizer::Rasterizer(SoftwareRenderer* renderer, int client_id, const Color &color):
|
||||
renderer(renderer), client_id(client_id)
|
||||
{
|
||||
this->color = new Color(color);
|
||||
}
|
||||
|
||||
Rasterizer::~Rasterizer()
|
||||
{
|
||||
delete color;
|
||||
}
|
||||
|
||||
void Rasterizer::pushProjectedTriangle(CanvasPortion *canvas, const Vector3 &pixel1, const Vector3 &pixel2, const Vector3 &pixel3, const Vector3 &location1, const Vector3 &location2, const Vector3 &location3)
|
||||
|
@ -329,7 +331,12 @@ void Rasterizer::renderScanLines(CanvasPortion *canvas, RenderScanlines* scanlin
|
|||
scanInterpolate(renderer->render_camera, &down, &diff, fy / dy, ¤t);
|
||||
|
||||
CanvasFragment fragment(current.pixel.z, Vector3(current.location.x, current.location.y, current.location.z), current.client);
|
||||
fragment.setColor((cury == starty || cury == endy) ? COLOR_GREY : COLOR_WHITE);
|
||||
|
||||
Color frag_color = *color;
|
||||
if (cury == starty || cury == endy)
|
||||
frag_color.mask(Color(0.0, 0.0, 0.0, 0.3));
|
||||
fragment.setColor(frag_color);
|
||||
|
||||
canvas->pushFragment(current.x, current.y, fragment);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ typedef struct RenderScanlines RenderScanlines;
|
|||
class SOFTWARESHARED_EXPORT Rasterizer
|
||||
{
|
||||
public:
|
||||
Rasterizer(SoftwareRenderer *renderer, int client_id);
|
||||
Rasterizer(SoftwareRenderer *renderer, int client_id, const Color &color);
|
||||
virtual ~Rasterizer();
|
||||
|
||||
inline SoftwareRenderer *getRenderer() const {return renderer;}
|
||||
|
@ -30,6 +30,7 @@ protected:
|
|||
void pushDisplacedTriangle(CanvasPortion *canvas, const Vector3 &v1, const Vector3 &v2, const Vector3 &v3, const Vector3 &ov1, const Vector3 &ov2, const Vector3 &ov3);
|
||||
void pushDisplacedQuad(CanvasPortion *canvas, const Vector3 &v1, const Vector3 &v2, const Vector3 &v3, const Vector3 &v4, const Vector3 &ov1, const Vector3 &ov2, const Vector3 &ov3, const Vector3 &ov4);
|
||||
|
||||
Color* color;
|
||||
SoftwareRenderer *renderer;
|
||||
int client_id;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#define SPHERE_SIZE 20000.0
|
||||
|
||||
SkyRasterizer::SkyRasterizer(SoftwareRenderer* renderer, int client_id):
|
||||
Rasterizer(renderer, client_id)
|
||||
Rasterizer(renderer, client_id, Color(0.3, 0.7, 1.0))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "CanvasPortion.h"
|
||||
|
||||
TerrainRasterizer::TerrainRasterizer(SoftwareRenderer* renderer, int client_id):
|
||||
Rasterizer(renderer, client_id)
|
||||
Rasterizer(renderer, client_id, Color(0.5, 0.3, 0.3))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "ParallelQueue.h"
|
||||
|
||||
WaterRasterizer::WaterRasterizer(SoftwareRenderer* renderer, int client_id):
|
||||
Rasterizer(renderer, client_id)
|
||||
Rasterizer(renderer, client_id, Color(0.1, 0.3, 0.6))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue