mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Flow: Remove glu dependency
This commit is contained in:
parent
d9d93c6481
commit
caca3191f9
@ -3,8 +3,8 @@
|
||||
YACReader and YACReaderLibrary are build using qmake. To build and install the
|
||||
program, run:
|
||||
|
||||
> qmake-qt5 CONFIG+=[Options]
|
||||
> make
|
||||
> qmake-qt5 CONFIG+=[Options]
|
||||
> make
|
||||
> make install
|
||||
|
||||
from the source dir. For separate builds of YACReader or YACReaderLibrary,
|
||||
@ -28,7 +28,6 @@ folder. To build it, enter the folder and run the commands described above.
|
||||
- network
|
||||
- A pdf rendering backend (optional, see below)
|
||||
- qrencode (optional)
|
||||
- glu
|
||||
- (lib)unarr (see below)
|
||||
|
||||
Not all dependencies are needed at build time. For example the qml components in
|
||||
@ -81,7 +80,7 @@ can be used to install to a different location, which is usefull for packaging.
|
||||
|
||||
Default values:
|
||||
|
||||
>PREFIX=/usr
|
||||
>PREFIX=/usr
|
||||
>INSTALL_ROOT=""
|
||||
|
||||
On embedded devices that don't support desktop OpenGL, it is recommended to use
|
||||
|
@ -53,13 +53,13 @@ INCLUDEPATH += ../common \
|
||||
win32 {
|
||||
CONFIG(force_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
|
||||
#to remove any OpenGL (desktop) dependencies
|
||||
#the OpenGL stuff should be migrated to OpenGL ES
|
||||
DEFINES += FORCE_ANGLE
|
||||
} else {
|
||||
LIBS += -loleaut32 -lole32 -lshell32 -lopengl32 -lglu32 -luser32
|
||||
LIBS += -loleaut32 -lole32 -lshell32 -lopengl32 -luser32
|
||||
}
|
||||
|
||||
QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT /GL
|
||||
@ -67,10 +67,6 @@ win32 {
|
||||
CONFIG -= embed_manifest_exe
|
||||
}
|
||||
|
||||
unix:!macx:!CONFIG(no_opengl) {
|
||||
LIBS += -lGLU
|
||||
}
|
||||
|
||||
macx {
|
||||
QT += macextras gui-private
|
||||
CONFIG += objective_c
|
||||
|
@ -30,13 +30,13 @@ INCLUDEPATH += ../common/gl
|
||||
win32 {
|
||||
CONFIG(force_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
|
||||
# to remove any OpenGL (desktop) dependencies
|
||||
# the OpenGL stuff should be migrated to OpenGL ES
|
||||
DEFINES += FORCE_ANGLE
|
||||
} else {
|
||||
LIBS += -loleaut32 -lole32 -lshell32 -lopengl32 -lglu32 -luser32
|
||||
LIBS += -loleaut32 -lole32 -lshell32 -lopengl32 -luser32
|
||||
}
|
||||
|
||||
QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT /GL
|
||||
@ -62,10 +62,6 @@ CONFIG(force_angle) {
|
||||
}
|
||||
}
|
||||
|
||||
unix:!macx:!CONFIG(no_opengl) {
|
||||
LIBS += -lGLU
|
||||
}
|
||||
|
||||
macx {
|
||||
LIBS += -framework Foundation -framework ApplicationServices -framework AppKit
|
||||
CONFIG += objective_c
|
||||
|
@ -2,13 +2,7 @@
|
||||
|
||||
#include <QtGui>
|
||||
#include <QtOpenGL>
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
#include <OpenGL/glu.h>
|
||||
#else
|
||||
#include <GL/glu.h>
|
||||
#endif
|
||||
|
||||
#include <QMatrix4x4>
|
||||
#include <cmath>
|
||||
|
||||
/*** Animation Settings ***/
|
||||
@ -371,10 +365,10 @@ void YACReaderFlowGL::udpatePerspective(int width, int height)
|
||||
glViewport(0, 0, width*pixelRatio, height*pixelRatio);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
|
||||
gluPerspective(20.0, GLdouble(width) / (float)height, 1.0, 200.0);
|
||||
|
||||
QMatrix4x4 perspectiveMatrix;
|
||||
perspectiveMatrix.setToIdentity();
|
||||
perspectiveMatrix.perspective(20.0, GLdouble(width) / (float)height, 1.0, 200.0);
|
||||
glLoadMatrixf(perspectiveMatrix.constData());
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
@ -866,12 +860,10 @@ void YACReaderFlowGL::setZoom(int zoom)
|
||||
glViewport(0, 0, width, height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
//float sideX = ((float(width)/height)/2)*1.5;
|
||||
//float sideY = 0.5*1.5;
|
||||
gluPerspective(zoom, (float)width / (float)height, 1.0, 200.0);
|
||||
//glOrtho(-sideX, sideX, -sideY+0.2, +sideY+0.2, 4, 11.0);
|
||||
|
||||
QMatrix4x4 zoomMatrix;
|
||||
zoomMatrix.setToIdentity();
|
||||
zoomMatrix.perspective(zoom, (float)width / (float)height, 1.0, 200.0);
|
||||
glLoadMatrixf(zoomMatrix.constData());
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
}
|
||||
@ -1113,38 +1105,34 @@ void YACReaderFlowGL::mousePressEvent(QMouseEvent *event)
|
||||
if(event->button() == Qt::LeftButton)
|
||||
{
|
||||
float x,y;
|
||||
float pixelRatio = devicePixelRatio();
|
||||
x = event->x()*pixelRatio;
|
||||
y = event->y()*pixelRatio;
|
||||
x = event->x()*devicePixelRatio();
|
||||
y = event->y()*devicePixelRatio();
|
||||
GLint viewport[4];
|
||||
GLdouble modelview[16];
|
||||
GLdouble projection[16];
|
||||
GLfloat winX, winY, winZ;
|
||||
GLdouble posX, posY, posZ;
|
||||
QMatrix4x4 modelview;
|
||||
QMatrix4x4 projection;
|
||||
GLfloat winZ;
|
||||
|
||||
glGetDoublev( GL_MODELVIEW_MATRIX, modelview );
|
||||
glGetDoublev( GL_PROJECTION_MATRIX, projection );
|
||||
glGetIntegerv( GL_VIEWPORT, viewport );
|
||||
glGetFloatv(GL_MODELVIEW_MATRIX, modelview.data());
|
||||
glGetFloatv(GL_PROJECTION_MATRIX, projection.data());
|
||||
glGetIntegerv(GL_VIEWPORT, viewport);
|
||||
glReadPixels(x, int((float)viewport[3] - (float)y), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ );
|
||||
|
||||
winX = (float)x;
|
||||
winY = (float)viewport[3] - (float)y;
|
||||
auto clickVector = QVector3D(x, (float)viewport[3] - (float)y, winZ);
|
||||
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 );
|
||||
|
||||
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();
|
||||
}
|
||||
else if((posX <=-0.5 && !flowRightToLeft) || (posX >= 0.5 && flowRightToLeft) )
|
||||
showPrevious();
|
||||
} else
|
||||
if((clickVector.x() >= 0.5 && !flowRightToLeft) || (clickVector.x() <=-0.5 && flowRightToLeft))
|
||||
{
|
||||
showNext();
|
||||
}
|
||||
else if((clickVector.x() <=-0.5 && !flowRightToLeft) || (clickVector.x() >= 0.5 && flowRightToLeft) )
|
||||
{
|
||||
showPrevious();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QOpenGLWidget::mousePressEvent(event);
|
||||
}
|
||||
doneCurrent();
|
||||
}
|
||||
|
||||
@ -1152,26 +1140,22 @@ void YACReaderFlowGL::mouseDoubleClickEvent(QMouseEvent* event)
|
||||
{
|
||||
makeCurrent();
|
||||
float x,y;
|
||||
float pixelRatio = devicePixelRatio();
|
||||
x = event->x()*pixelRatio;
|
||||
y = event->y()*pixelRatio;
|
||||
x = event->x()*devicePixelRatio();
|
||||
y = event->y()*devicePixelRatio();
|
||||
GLint viewport[4];
|
||||
GLdouble modelview[16];
|
||||
GLdouble projection[16];
|
||||
GLfloat winX, winY, winZ;
|
||||
GLdouble posX, posY, posZ;
|
||||
QMatrix4x4 modelview;
|
||||
QMatrix4x4 projection;
|
||||
GLfloat winZ;
|
||||
|
||||
glGetDoublev( GL_MODELVIEW_MATRIX, modelview );
|
||||
glGetDoublev( GL_PROJECTION_MATRIX, projection );
|
||||
glGetIntegerv( GL_VIEWPORT, viewport );
|
||||
glGetFloatv(GL_MODELVIEW_MATRIX, modelview.data());
|
||||
glGetFloatv(GL_PROJECTION_MATRIX, projection.data());
|
||||
glGetIntegerv(GL_VIEWPORT, viewport);
|
||||
glReadPixels(x, int((float)viewport[3] - (float)y), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ );
|
||||
|
||||
winX = (float)x;
|
||||
winY = (float)viewport[3] - (float)y;
|
||||
glReadPixels( x, int(winY), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ );
|
||||
auto clickVector = QVector3D(x, (float)viewport[3] - (float)y, winZ);
|
||||
clickVector = clickVector.unproject(modelview, projection, QRect(viewport[0], viewport[1], viewport[2],viewport[3]));
|
||||
|
||||
gluUnProject( winX, winY, winZ, modelview, projection, viewport, &posX, &posY, &posZ);
|
||||
|
||||
if(posX <= 0.5 && posX >= -0.5)
|
||||
if(clickVector.x() <= 0.5 && clickVector.x() >= -0.5)
|
||||
{
|
||||
emit selected(centerIndex());
|
||||
event->accept();
|
||||
|
Loading…
Reference in New Issue
Block a user