[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    =?utf-8?q?=5Bkstars=5D_kstars=3A_Use_matrix_manipultion_from_Ope?=
From:       Khudyakov Alexey <alexey.skladnoy () gmail ! com>
Date:       2011-05-05 12:20:30
Message-ID: 20110505122030.9E71AA60C6 () git ! kde ! org
[Download RAW message or body]

Git commit 40fc8a23328aed608cef71cdc0efd5002890797e by Khudyakov Alexey.
Committed on 03/05/2011 at 23:36.
Pushed by khudyakov into branch 'master'.

Use matrix manipultion from OpenGL to place image of planet on screen.
It makes it easy to separate drawing of textured rectangle into separate
function.

Same code is used by planet and deepskyes

M  +17   -15   kstars/skyglpainter.cpp     

http://commits.kde.org/kstars/40fc8a23328aed608cef71cdc0efd5002890797e

diff --git a/kstars/skyglpainter.cpp b/kstars/skyglpainter.cpp
index f4c5358..928f968 100644
--- a/kstars/skyglpainter.cpp
+++ b/kstars/skyglpainter.cpp
@@ -191,31 +191,33 @@ bool SkyGLPainter::drawPlanet(KSPlanetBase* planet)
             size *= 2.5;
 
         float s = size/2.;
-        Rotation2Df rot( m_proj->findPA(planet, pos.x(), pos.y()) * (M_PI/180.0) );
-        Vector2f vec;
 
         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
         glEnable(GL_TEXTURE_2D);
-
         TextureManager::bindFromImage( planet->image(), m_widget );
+
+        // Change modelview matrix
+        glPushMatrix();
+        glTranslatef( pos.x(), pos.y(), 0 );
+        glRotatef( m_proj->findPA(planet, pos.x(), pos.y()), 0, 0, 1 );
+        glScalef( s, s, 1 );
+
         glBegin(GL_QUADS);
-            vec = pos + rot*Vector2f(-s,-s);
-            glTexCoord2f(0.,0.);
-            glVertex2fv(vec.data());
+            glTexCoord2f( 0,  0);
+            glVertex2f(  -1, -1);
             
-            vec = pos + rot*Vector2f( s,-s);
-            glTexCoord2f(1.,0.);
-            glVertex2fv(vec.data());
+            glTexCoord2f( 1,  0);
+            glVertex2f(   1, -1);
             
-            vec = pos + rot*Vector2f( s, s);
-            glTexCoord2f(1.,1.);
-            glVertex2fv(vec.data());
+            glTexCoord2f( 1,  1);
+            glVertex2f(   1,  1);
             
-            vec = pos + rot*Vector2f(-s, s);
-            glTexCoord2f(0.,1.);
-            glVertex2fv(vec.data());
+            glTexCoord2f( 0,  1);
+            glVertex2f(  -1,  1);
         glEnd();
+
+        glPopMatrix();
         return true;
     }
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic