Some documentation and cleanup in GLRenderer...

Tue, 14 Feb 2017 08:26:39 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Tue, 14 Feb 2017 08:26:39 +0200
changeset 1133
47f6db5ea24d
parent 1132
825dd975588d
child 1134
daa9808d626e

Some documentation and cleanup in GLRenderer...

src/glRenderer.cpp file | annotate | diff | comparison | revisions
src/glRenderer.h file | annotate | diff | comparison | revisions
--- a/src/glRenderer.cpp	Tue Feb 14 08:15:58 2017 +0200
+++ b/src/glRenderer.cpp	Tue Feb 14 08:26:39 2017 +0200
@@ -37,8 +37,9 @@
 
 const QPen GLRenderer::thinBorderPen {QColor {0, 0, 0, 208}, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin};
 
-// =============================================================================
-//
+/*
+ * Constructs a GL renderer.
+ */
 GLRenderer::GLRenderer(const Model* model, QWidget* parent) :
     QGLWidget {parent},
     HierarchyElement {parent},
@@ -80,20 +81,18 @@
 	calcCameraIcons();
 }
 
-// =============================================================================
-//
+/*
+ * Cleans up the axes VBOs when the renderer is destroyed.
+ */
 GLRenderer::~GLRenderer()
 {
-	m_compiler->setRenderer (nullptr);
-	delete m_compiler;
-	glDeleteBuffers (1, &m_axesVbo);
-	glDeleteBuffers (1, &m_axesColorVbo);
+	glDeleteBuffers(1, &m_axesVbo);
+	glDeleteBuffers(1, &m_axesColorVbo);
 }
 
-// =============================================================================
-// Calculates the "hitboxes" of the camera icons so that we can tell when the
-// cursor is pointing at the camera icon.
-//
+/*
+ * Calculates the camera icon locations.
+ */
 void GLRenderer::calcCameraIcons()
 {
 	int i = 0;
@@ -105,6 +104,7 @@
 		int row = i / columns;
 		int column = i % columns;
 
+		// Do right-justifying on the last row.
 		if (i >= firstAtLastRow)
 			column += columns - (countof(m_cameras) % columns);
 
@@ -124,18 +124,25 @@
 	}
 }
 
+/*
+ * Returns the camera currently in use.
+ */
 GLCamera& GLRenderer::currentCamera()
 {
 	return m_cameras[static_cast<int>(camera())];
 }
 
+/*
+ * Returns the camera currently in use.
+ */
 const GLCamera& GLRenderer::currentCamera() const
 {
 	return m_cameras[static_cast<int>(camera())];
 }
 
-// =============================================================================
-//
+/*
+ * Prepares the GL context for rendering.
+ */
 void GLRenderer::initGLData()
 {
 	glEnable (GL_BLEND);
@@ -160,21 +167,9 @@
 	}
 }
 
-bool GLRenderer::isDrawOnly() const
-{
-	return m_isDrawOnly;
-}
-
-void GLRenderer::setDrawOnly (bool value)
-{
-	m_isDrawOnly = value;
-}
-
-GLCompiler* GLRenderer::compiler() const
-{
-	return m_compiler;
-}
-
+/*
+ * Returns the object currently highlighted by the cursor.
+ */
 LDObject* GLRenderer::objectAtCursor() const
 {
 	return m_objectAtCursor;
@@ -232,7 +227,7 @@
 	setAutoFillBackground (false);
 	setMouseTracking (true);
 	setFocusPolicy (Qt::WheelFocus);
-	compiler()->initialize();
+	m_compiler->initialize();
 	initializeAxes();
 	initializeLighting();
 	m_initialized = true;
--- a/src/glRenderer.h	Tue Feb 14 08:15:58 2017 +0200
+++ b/src/glRenderer.h	Tue Feb 14 08:26:39 2017 +0200
@@ -87,7 +87,6 @@
 	void forgetObject(LDObject* obj);
 	void highlightCursorObject();
 	void initGLData();
-	bool isDrawOnly() const;
 	bool isPicking() const;
 	Qt::KeyboardModifiers keyboardModifiers() const;
 	const Model* model() const;
@@ -103,7 +102,6 @@
 	void resetAngles();
 	void setBackground();
 	void setCamera(Camera cam);
-	void setDrawOnly(bool value);
 	void setPicking(bool a);
 	QPen textPen() const;
 
@@ -152,7 +150,6 @@
 	bool m_takingScreenCapture = false;
 	bool m_panning = false;
 	bool m_initialized = false;
-	bool m_isDrawOnly = false;
 	bool m_isDrawingSelectionScene = false;
 	bool m_isCameraMoving = false;
 	bool m_needZoomToFit = true;

mercurial