src/gldraw.cpp

changeset 230
43d722c255d3
parent 223
4f95d7f2e9ef
child 240
bdc9d429cdc2
--- a/src/gldraw.cpp	Sun May 19 15:36:01 2013 +0300
+++ b/src/gldraw.cpp	Tue May 21 14:02:18 2013 +0300
@@ -154,6 +154,20 @@
 	}
 }
 
+void GLRenderer::initGLData () {
+	glEnable (GL_BLEND);
+	glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+	glEnable (GL_POLYGON_OFFSET_FILL);
+	glPolygonOffset (1.0f, 1.0f);
+	
+	glEnable (GL_DEPTH_TEST);
+	glShadeModel (GL_SMOOTH);
+	glEnable (GL_MULTISAMPLE);
+	
+	glEnable (GL_LINE_SMOOTH);
+	glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
+}
+
 // =============================================================================
 void GLRenderer::resetAngles () {
 	m_rotX = 30.0f;
@@ -175,6 +189,10 @@
 	
 	glLineWidth (gl_linethickness);
 	
+#ifdef NO_OVERPAINTING
+	initGLData ();
+#endif // NO_OVERPAINTING
+	
 	setAutoFillBackground (false);
 	setMouseTracking (true);
 	setFocusPolicy (Qt::WheelFocus);
@@ -461,31 +479,22 @@
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
+#ifndef NO_OVERPAINTING
+
 void GLRenderer::paintEvent (QPaintEvent* ev) {
 	Q_UNUSED (ev)
 	m_virtWidth = m_zoom;
 	m_virtHeight = (m_height * m_virtWidth) / m_width;
 	
-	glEnable (GL_BLEND);
-	glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-	glEnable (GL_POLYGON_OFFSET_FILL);
-	glPolygonOffset (1.0f, 1.0f);
+	initGLData ();
+	drawGLScene ();
 	
-	glEnable (GL_DEPTH_TEST);
-	glShadeModel (GL_SMOOTH);
-	glEnable (GL_MULTISAMPLE);
-	
-	glEnable (GL_LINE_SMOOTH);
-	glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
-	
-	drawGLScene ();
+	m_hoverpos = g_origin;
 	
 	QPainter paint (this);
 	QFontMetrics metrics = QFontMetrics (QFont ());
 	paint.setRenderHint (QPainter::HighQualityAntialiasing);
 	
-	m_hoverpos = g_origin;
-	
 	if (m_camera != Free) {
 		// Paint the overlay image if we have one
 		const overlayMeta& overlay = g_overlays[m_camera];
@@ -656,6 +665,23 @@
 	}
 }
 
+#else
+
+void GLRenderer::paintGL () {
+	m_virtWidth = m_zoom;
+	m_virtHeight = (m_height * m_virtWidth) / m_width;
+	drawGLScene ();
+	
+	m_hoverpos = g_origin;
+	if (m_camera != Free)
+		m_hoverpos = coordconv2_3 (m_pos, true);
+	
+	g_win->setStatusBarText (fmt ("%s camera: X: %f, Y: %f, Z: %f",
+		g_CameraNames[camera ()], m_hoverpos[X], m_hoverpos[Y], m_hoverpos[Z]));
+}
+
+#endif // NO_OVERPAINTING
+
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================

mercurial