Flow: Remove glu dependency

This commit is contained in:
Felix Kauselmann 2019-05-05 17:49:57 +02:00
parent d9d93c6481
commit caca3191f9
4 changed files with 51 additions and 76 deletions

View File

@ -28,7 +28,6 @@ folder. To build it, enter the folder and run the commands described above.
- network - network
- A pdf rendering backend (optional, see below) - A pdf rendering backend (optional, see below)
- qrencode (optional) - qrencode (optional)
- glu
- (lib)unarr (see below) - (lib)unarr (see below)
Not all dependencies are needed at build time. For example the qml components in Not all dependencies are needed at build time. For example the qml components in

View File

@ -53,13 +53,13 @@ INCLUDEPATH += ../common \
win32 { win32 {
CONFIG(force_angle) { CONFIG(force_angle) {
message("using ANGLE") message("using ANGLE")
LIBS += -loleaut32 -lole32 -lshell32 -lopengl32 -lglu32 -luser32 LIBS += -loleaut32 -lole32 -lshell32 -lopengl32 -luser32
#linking extra libs are necesary for a successful compilation, a better approach should be #linking extra libs are necesary for a successful compilation, a better approach should be
#to remove any OpenGL (desktop) dependencies #to remove any OpenGL (desktop) dependencies
#the OpenGL stuff should be migrated to OpenGL ES #the OpenGL stuff should be migrated to OpenGL ES
DEFINES += FORCE_ANGLE DEFINES += FORCE_ANGLE
} else { } else {
LIBS += -loleaut32 -lole32 -lshell32 -lopengl32 -lglu32 -luser32 LIBS += -loleaut32 -lole32 -lshell32 -lopengl32 -luser32
} }
QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT /GL QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT /GL
@ -67,10 +67,6 @@ win32 {
CONFIG -= embed_manifest_exe CONFIG -= embed_manifest_exe
} }
unix:!macx:!CONFIG(no_opengl) {
LIBS += -lGLU
}
macx { macx {
QT += macextras gui-private QT += macextras gui-private
CONFIG += objective_c CONFIG += objective_c

View File

@ -30,13 +30,13 @@ INCLUDEPATH += ../common/gl
win32 { win32 {
CONFIG(force_angle) { CONFIG(force_angle) {
message("using ANGLE") message("using ANGLE")
LIBS += -loleaut32 -lole32 -lshell32 -lopengl32 -lglu32 -luser32 LIBS += -loleaut32 -lole32 -lshell32 -lopengl32 -luser32
# linking extra libs are necesary for a successful compilation, a better approach should be # linking extra libs are necesary for a successful compilation, a better approach should be
# to remove any OpenGL (desktop) dependencies # to remove any OpenGL (desktop) dependencies
# the OpenGL stuff should be migrated to OpenGL ES # the OpenGL stuff should be migrated to OpenGL ES
DEFINES += FORCE_ANGLE DEFINES += FORCE_ANGLE
} else { } else {
LIBS += -loleaut32 -lole32 -lshell32 -lopengl32 -lglu32 -luser32 LIBS += -loleaut32 -lole32 -lshell32 -lopengl32 -luser32
} }
QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT /GL QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT /GL
@ -62,10 +62,6 @@ CONFIG(force_angle) {
} }
} }
unix:!macx:!CONFIG(no_opengl) {
LIBS += -lGLU
}
macx { macx {
LIBS += -framework Foundation -framework ApplicationServices -framework AppKit LIBS += -framework Foundation -framework ApplicationServices -framework AppKit
CONFIG += objective_c CONFIG += objective_c

View File

@ -2,13 +2,7 @@
#include <QtGui> #include <QtGui>
#include <QtOpenGL> #include <QtOpenGL>
#include <QMatrix4x4>
#ifdef Q_OS_MAC
#include <OpenGL/glu.h>
#else
#include <GL/glu.h>
#endif
#include <cmath> #include <cmath>
/*** Animation Settings ***/ /*** Animation Settings ***/
@ -371,10 +365,10 @@ void YACReaderFlowGL::udpatePerspective(int width, int height)
glViewport(0, 0, width*pixelRatio, height*pixelRatio); glViewport(0, 0, width*pixelRatio, height*pixelRatio);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); QMatrix4x4 perspectiveMatrix;
perspectiveMatrix.setToIdentity();
gluPerspective(20.0, GLdouble(width) / (float)height, 1.0, 200.0); perspectiveMatrix.perspective(20.0, GLdouble(width) / (float)height, 1.0, 200.0);
glLoadMatrixf(perspectiveMatrix.constData());
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
} }
@ -866,12 +860,10 @@ void YACReaderFlowGL::setZoom(int zoom)
glViewport(0, 0, width, height); glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); QMatrix4x4 zoomMatrix;
//float sideX = ((float(width)/height)/2)*1.5; zoomMatrix.setToIdentity();
//float sideY = 0.5*1.5; zoomMatrix.perspective(zoom, (float)width / (float)height, 1.0, 200.0);
gluPerspective(zoom, (float)width / (float)height, 1.0, 200.0); glLoadMatrixf(zoomMatrix.constData());
//glOrtho(-sideX, sideX, -sideY+0.2, +sideY+0.2, 4, 11.0);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
} }
@ -1113,38 +1105,34 @@ void YACReaderFlowGL::mousePressEvent(QMouseEvent *event)
if(event->button() == Qt::LeftButton) if(event->button() == Qt::LeftButton)
{ {
float x,y; float x,y;
float pixelRatio = devicePixelRatio(); x = event->x()*devicePixelRatio();
x = event->x()*pixelRatio; y = event->y()*devicePixelRatio();
y = event->y()*pixelRatio;
GLint viewport[4]; GLint viewport[4];
GLdouble modelview[16]; QMatrix4x4 modelview;
GLdouble projection[16]; QMatrix4x4 projection;
GLfloat winX, winY, winZ; GLfloat winZ;
GLdouble posX, posY, posZ;
glGetDoublev( GL_MODELVIEW_MATRIX, modelview ); glGetFloatv(GL_MODELVIEW_MATRIX, modelview.data());
glGetDoublev( GL_PROJECTION_MATRIX, projection ); glGetFloatv(GL_PROJECTION_MATRIX, projection.data());
glGetIntegerv( GL_VIEWPORT, viewport ); glGetIntegerv(GL_VIEWPORT, viewport);
glReadPixels(x, int((float)viewport[3] - (float)y), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ );
winX = (float)x; auto clickVector = QVector3D(x, (float)viewport[3] - (float)y, winZ);
winY = (float)viewport[3] - (float)y; clickVector = clickVector.unproject(modelview, projection, QRect(viewport[0], viewport[1], viewport[2],viewport[3]));
glReadPixels(winX, int(winY), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ ); if((clickVector.x() >= 0.5 && !flowRightToLeft) || (clickVector.x() <=-0.5 && flowRightToLeft))
gluUnProject(winX, winY, winZ, modelview, projection, viewport, &posX, &posY, &posZ);
if((posX >= 0.5 && !flowRightToLeft) || (posX <=-0.5 && flowRightToLeft))
{ {
//int index = currentSelected+1;
//while((cfImages[index].current.x-cfImages[index].width/(2.0*config.rotation)) < posX)
// index++;
//setCurrentIndex(index-1);
showNext(); showNext();
} }
else if((posX <=-0.5 && !flowRightToLeft) || (posX >= 0.5 && flowRightToLeft) ) else if((clickVector.x() <=-0.5 && !flowRightToLeft) || (clickVector.x() >= 0.5 && flowRightToLeft) )
{
showPrevious(); showPrevious();
} else }
}
else
{
QOpenGLWidget::mousePressEvent(event); QOpenGLWidget::mousePressEvent(event);
}
doneCurrent(); doneCurrent();
} }
@ -1152,26 +1140,22 @@ void YACReaderFlowGL::mouseDoubleClickEvent(QMouseEvent* event)
{ {
makeCurrent(); makeCurrent();
float x,y; float x,y;
float pixelRatio = devicePixelRatio(); x = event->x()*devicePixelRatio();
x = event->x()*pixelRatio; y = event->y()*devicePixelRatio();
y = event->y()*pixelRatio;
GLint viewport[4]; GLint viewport[4];
GLdouble modelview[16]; QMatrix4x4 modelview;
GLdouble projection[16]; QMatrix4x4 projection;
GLfloat winX, winY, winZ; GLfloat winZ;
GLdouble posX, posY, posZ;
glGetDoublev( GL_MODELVIEW_MATRIX, modelview ); glGetFloatv(GL_MODELVIEW_MATRIX, modelview.data());
glGetDoublev( GL_PROJECTION_MATRIX, projection ); glGetFloatv(GL_PROJECTION_MATRIX, projection.data());
glGetIntegerv( GL_VIEWPORT, viewport ); glGetIntegerv(GL_VIEWPORT, viewport);
glReadPixels(x, int((float)viewport[3] - (float)y), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ );
winX = (float)x; auto clickVector = QVector3D(x, (float)viewport[3] - (float)y, winZ);
winY = (float)viewport[3] - (float)y; clickVector = clickVector.unproject(modelview, projection, QRect(viewport[0], viewport[1], viewport[2],viewport[3]));
glReadPixels( x, int(winY), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ );
gluUnProject( winX, winY, winZ, modelview, projection, viewport, &posX, &posY, &posZ); if(clickVector.x() <= 0.5 && clickVector.x() >= -0.5)
if(posX <= 0.5 && posX >= -0.5)
{ {
emit selected(centerIndex()); emit selected(centerIndex());
event->accept(); event->accept();