src/gl/compiler.cpp

changeset 39
caac957e9834
parent 37
90443fb328ea
child 43
08dc62e03a6d
--- a/src/gl/compiler.cpp	Sat Feb 01 15:49:28 2020 +0200
+++ b/src/gl/compiler.cpp	Sat Feb 01 17:10:11 2020 +0200
@@ -143,14 +143,14 @@
 	}
 }
 
-void gl::Compiler::build(Model* model, DocumentManager* context)
+void gl::Compiler::build(Model* model, DocumentManager* context, const gl::RenderPreferences& preferences)
 {
 	this->boundingBox = {};
 	std::vector<gl::Vertex> vboData[gl::NUM_ARRAY_CLASSES];
 	const std::vector<gl::Polygon> polygons = model->getPolygons(context);
 	for (const gl::Polygon& polygon : polygons)
 	{
-		this->buildPolygon(polygon, vboData);
+		this->buildPolygon(polygon, vboData, preferences);
 	}
 	for (int arrayId = 0; arrayId < gl::NUM_ARRAY_CLASSES; arrayId += 1)
 	{
@@ -190,13 +190,16 @@
 	return {r, g, b};
 }
 
-void gl::Compiler::buildPolygon(gl::Polygon polygon, std::vector<gl::Vertex>* vboData)
+void gl::Compiler::buildPolygon(
+	gl::Polygon polygon,
+	std::vector<gl::Vertex>* vboData,
+	const gl::RenderPreferences& preferences)
 {
 	const gl::ArrayClass vboClass = classifyPolygon(polygon);
 	std::vector<gl::Vertex>& vertexBuffer = vboData[static_cast<int>(vboClass)];
 	auto vertexRing = iter::ring(polygon.vertices, polygon.numPolygonVertices());
 	reserveMore(vertexBuffer, polygon.numPolygonVertices());
-	const QColor color = this->getColorForPolygon(polygon);
+	const QColor color = this->getColorForPolygon(polygon, preferences);
 	for (unsigned int i = 0; i < polygon.numPolygonVertices(); i += 1)
 	{
 		const glm::vec3& v1 = vertexRing[i - 1];
@@ -210,13 +213,13 @@
 	}
 }
 
-QColor gl::Compiler::getColorForPolygon(const gl::Polygon& polygon)
+QColor gl::Compiler::getColorForPolygon(const gl::Polygon& polygon, const gl::RenderPreferences& preferences)
 {
 	QColor color;
 	// For normal colors, use the polygon's color.
 	if (polygon.color == ldraw::mainColor)
 	{
-		color = {255, 255, 64}; // mainColorRepresentation();
+		color = preferences.mainColor;
 	}
 	else if (polygon.color == ldraw::edgeColor)
 	{

mercurial