Bug 321244 - compilation error on armhf: GLdouble is not the same as qreal
Summary: compilation error on armhf: GLdouble is not the same as qreal
Status: RESOLVED FIXED
Alias: None
Product: analitza
Classification: Frameworks and Libraries
Component: analitzaplot (show other bugs)
Version: unspecified
Platform: Debian unstable Linux
: NOR normal
Target Milestone: ---
Assignee: Aleix Pol
URL: https://buildd.debian.org/status/fetc...
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-16 21:13 UTC by Maximiliano Curia
Modified: 2013-10-30 22:54 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
plotter3d patch (1.42 KB, patch)
2013-06-19 12:47 UTC, Maximiliano Curia
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Maximiliano Curia 2013-06-16 21:13:46 UTC
In arm the qreal type is a single precision float which makes the constructors of QMatrix4x4 incompatible with a GLdouble* (which is a double*). This means analitza doesn't compile in armhf.

This issue (QMatrix4x4 using qreal) is referenced in different discussions over the net, probably:
http://stackoverflow.com/questions/14303126/use-qmatrix4x4-with-opengl-functions
is one of the more interesting readings.


Reproducible: Always

Steps to Reproduce:
1. Try to compile analitza in armhf.
2. See the failure. :)
Comment 1 Aleix Pol 2013-06-19 01:15:05 UTC
Do you have anything defined so that I can use ifdef?
Comment 2 Maximiliano Curia 2013-06-19 12:45:17 UTC
¡Hola Aleix!

El 2013-06-19 a las 01:15 +0000, Aleix Pol escribió:
> --- Comment #1 from Aleix Pol <aleixpol@kde.org> ---
> Do you have anything defined so that I can use ifdef?

I was thinking something more in the lines of:

diff -Naru ../analitzaplot/plotter3d.cpp analitzaplot/plotter3d.cpp
--- ../analitzaplot/plotter3d.cpp	2013-06-19 14:02:21.126969033 +0200
+++ analitzaplot/plotter3d.cpp	2013-06-19 14:24:09.042822834 +0200
@@ -142,6 +142,12 @@
     renderGL();
 }
 
+// add overloaded functions which call the underlying OpenGL function
+inline void glMultMatrix(const GLfloat  *m) { glMultMatrixf(m); }
+inline void glMultMatrix(const GLdouble *m) { glMultMatrixd(m); }
+
+inline void glMultMatrix(const QMatrix4x4 &m) { glMultMatrix(m.constData()); }
+
 void Plotter3D::drawPlots()
 {
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -152,7 +158,7 @@
 
     glMatrixMode(GL_MODELVIEW);
     glLoadIdentity();
-    glMultMatrixd(m_rot.data());
+    glMultMatrix(m_rot.data());
 
     // Object Drawing :
     glCallList(m_sceneObjects.value(Axes));
@@ -396,6 +402,14 @@
     renderGL();
 }
 
+inline QMatrix4x4 get_matrix(GLdouble *m)
+{
+    return QMatrix4x4(m[0],  m[1],  m[2],  m[3],
+                      m[4],  m[5],  m[6],  m[7],
+                      m[8],  m[9],  m[10], m[11],
+                      m[12], m[13], m[14], m[15]);
+}
+
 void Plotter3D::rotate(int dx, int dy)
 {
     GLdouble ax = -dy;
@@ -414,7 +428,7 @@
 
         glGetDoublev(GL_MODELVIEW_MATRIX, matrix);
 
-        QMatrix4x4 matrix4(matrix);
+        QMatrix4x4 matrix4(get_matrix(matrix));
         bool couldInvert;
         matrix4 = matrix4.inverted(&couldInvert); 

And let the compiler to take care of floats and doubles.
Comment 3 Maximiliano Curia 2013-06-19 12:47:26 UTC
Created attachment 80634 [details]
plotter3d patch
Comment 4 Aleix Pol 2013-06-19 12:56:29 UTC
Interesting, can you put it over http://reviewboard.kde.org? There we can work it out better.

I'm unsure we want to create a new constructor for QMatrix4x4 in case of Gldouble since it's already working, so this one should be overloaded as well.
Comment 5 Maximiliano Curia 2013-06-19 15:00:01 UTC
¡Hola Aleix!

El 2013-06-19 a las 12:56 +0000, Aleix Pol escribió:
> --- Comment #4 from Aleix Pol <aleixpol@kde.org> ---
> Interesting, can you put it over http://reviewboard.kde.org? There we can work
> it out better.
 
https://git.reviewboard.kde.org/r/111121/

> I'm unsure we want to create a new constructor for QMatrix4x4 in case of
> Gldouble since it's already working, so this one should be overloaded as well.

What do you mean?
Comment 6 Aleix Pol 2013-06-19 15:21:32 UTC
You didn't publish the request
Comment 7 Maximiliano Curia 2013-06-19 15:37:26 UTC
(In reply to comment #6)
> You didn't publish the request

Great. Done.
Comment 8 Albert Astals Cid 2013-10-30 22:54:06 UTC
Git commit 07dc31770db7a7d2e5273db0c2b32578a7e13c4e by Albert Astals Cid, on behalf of Maximiliano Curia.
Committed on 30/10/2013 at 22:53.
Pushed by aacid into branch 'master'.

Fix compile in armhf

Acked by Aleix
REVIEW: 111121

M  +16   -4    analitzaplot/plotter3d.cpp

http://commits.kde.org/analitza/07dc31770db7a7d2e5273db0c2b32578a7e13c4e