void AbstractGLDisplayHelper::initRenderingContext(WorldPtr world)
{
	int height = world->getHeight();
	int width = world->getWidth();
	int depth = world->getDepth();
	int pixelResolution = world->getPixelResolution();
	_renderContext = std::make_shared<OpenGLRenderContext>(width, height, depth, pixelResolution);
}
void GL2DDisplayHelper::paintSingleSolution(WorldPtr world, PartLocationListPtr parts)
{
	for (tuple<PartOrientationPtr, Point>& partLocation : *parts)
	{
		PartOrientationPtr currentOrientation = std::get<0>(partLocation);
		Point anchorPartPoint = std::get<1>(partLocation);

		RGB_COLOR orientationColor = _colorManager->getColor(*currentOrientation);
		float r = std::get<0>(orientationColor);
		float g = std::get<1>(orientationColor);
		float b = std::get<2>(orientationColor);
		float a;
		r /= 255.0;
		g /= 255.0;
		b /= 255.0;
		a = 1.0f;

		for (Point& relativePartCoordinate : *(currentOrientation->getPointList()))
		{
			Point point = anchorPartPoint + relativePartCoordinate;

			// Paint a square for each unmasked pixel in the world
			float v1x = point.getX();
			float v1y = world->getHeight() - point.getY() - 1; // OpenGL Y axis is inverted
			float v2x = v1x + SQUARE_SIZE;
			float v2y = v1y;
			float v3x = v1x;
			float v3y = v1y + SQUARE_SIZE;
			float v4x = v1x + SQUARE_SIZE;
			float v4y = v1y + SQUARE_SIZE;

			_renderContext->write2DTriangle(v1x, v1y, v2x, v2y, v3x, v3y, r, g, b, a);
			_renderContext->write2DTriangle(v2x, v2y, v3x, v3y, v4x, v4y, r, g, b, a);

			if (currentOrientation->isContainsPointAbovePoint(relativePartCoordinate))
				_renderContext->writeLine(v1x, v1y, v2x, v2y);
			else
				_renderContext->writeBoldLine(v1x, v1y, v2x, v2y);

			if (currentOrientation->isContainsPointRightOfPoint(relativePartCoordinate))
				_renderContext->writeLine(v2x, v2y, v4x, v4y);
			else
				_renderContext->writeBoldLine(v2x, v2y, v4x, v4y);

			if (currentOrientation->isContainsPointBelowPoint(relativePartCoordinate))
				_renderContext->writeLine(v3x, v3y, v4x, v4y);
			else
				_renderContext->writeBoldLine(v3x, v3y, v4x, v4y);

			if (currentOrientation->isContainsPointLeftPoint(relativePartCoordinate))
				_renderContext->writeLine(v3x, v3y, v1x, v1y);
			else
				_renderContext->writeBoldLine(v3x, v3y, v1x, v1y);
		}
	}
}