From f59e10fccd98a6b59b30fd475434d58b92698035 Mon Sep 17 00:00:00 2001
From: Oliver Bock <oliver.bock@aei.mpg.de>
Date: Sun, 11 Sep 2011 18:47:15 +0200
Subject: [PATCH] Draw background first (correct z-order)

---
 src/pulsaranimationwidget.cpp | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/src/pulsaranimationwidget.cpp b/src/pulsaranimationwidget.cpp
index aac209f..c718c76 100644
--- a/src/pulsaranimationwidget.cpp
+++ b/src/pulsaranimationwidget.cpp
@@ -229,6 +229,30 @@ void PulsarAnimationWidget::paintGL()
               0.0, 0.0, 0.0,
               0.0, 1.0, 0.0);
 
+    // save current state (the following is using parallel projection)
+    glMatrixMode(GL_PROJECTION);
+    glPushMatrix();
+    {
+        glLoadIdentity();
+        glOrtho(0, width(), 0, height(), 0.1, 501.0);
+        glMatrixMode(GL_MODELVIEW);
+        glPushMatrix();
+        {
+            glLoadIdentity();
+
+            // draw backdrop (independent parallel projection)
+            glColor3f(0.5, 0.5, 0.5f);
+            glTranslatef(0.0, 0.0, -501.0);
+            drawTexture(QPointF(0.0, 0.0), m_backgroundTexture);
+
+            // restore original state
+            glMatrixMode(GL_PROJECTION);
+        }
+        glPopMatrix();
+        glMatrixMode(GL_MODELVIEW);
+    }
+    glPopMatrix();
+
     // TODO: should be located elsewhere
     static GLfloat no_mat[] = {0.0, 0.0, 0.0, 1.0};
     static GLfloat mat_diffuse[] = {0.5, 0.5, 0.5, 1.0};
-- 
GitLab