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

List:       kde-commits
Subject:    [kalgebra] src: Fix colors on graph3d
From:       Aleix Pol <aleixpol () kde ! org>
Date:       2012-01-16 16:49:49
Message-ID: 20120116164949.4E34FA60BB () git ! kde ! org
[Download RAW message or body]

Git commit 55e6fbcd78a34b051b90ef33e3af2661d5beebe8 by Aleix Pol.
Committed on 16/01/2012 at 17:47.
Pushed by apol into branch 'master'.

Fix colors on graph3d

In some occasions the colors used in 3D graphs were NaN and some
opengl implementations drew it differently than others. Find a
common place where it always works.

Patch contributed by Nikita Skovoroda.

BUG: 290979

M  +7    -5    src/graph3d.cpp

http://commits.kde.org/kalgebra/55e6fbcd78a34b051b90ef33e3af2661d5beebe8

diff --git a/src/graph3d.cpp b/src/graph3d.cpp
index 47195f0..8124d22 100644
--- a/src/graph3d.cpp
+++ b/src/graph3d.cpp
@@ -245,20 +245,22 @@ void Graph3D::paintGL()
 			glTranslatef(i*step-mida, -mida, 0);
 			glBegin(GL_TRIANGLE_STRIP);
 			
-			double red=(i*step-mida)/mida;
-			double nextRed=((i+1)*step-mida)/mida;
+			double red=fabs((i*step-mida)/mida);
+			double nextRed=fabs(((i+1)*step-mida)/mida);
 			for(uint j=0; j<bound; j++) {
 				float s=j%2 ? .0f : 1.f;
-				double green=(j*step-mida)/mida;
+				double green=fabs((j*step-mida)/mida);
 				
 				double z=points[i][j];
+				double blue=1./fabs(log10(10.+fabs(z)));
+
 				glTexCoord2f(s, 0.f);
-				glColor4d(red, green, 1./fabs(log10(5.+z)), transf);
+				glColor4d(red, green, blue, transf);
 				glVertex3d(0., j*step, z);
 				
 				z=points[i+1][j];
 				glTexCoord2f(s, 1.f);
-				glColor4d(nextRed, green, 1./fabs(log10(5.+z)), transf);
+				glColor4d(nextRed, green, blue, transf);
 				glVertex3d(step, j*step, z);
 			}
 			glEnd();
[prev in list] [next in list] [prev in thread] [next in thread] 

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