mirror of
https://github.com/YACReader/yacreader
synced 2026-04-12 15:49:53 -04:00
Merge pull request #53 from selmf/light_gl_flow_refactoring
Light gl flow refactoring
This commit is contained in:
@ -3,8 +3,8 @@
|
|||||||
YACReader and YACReaderLibrary are build using qmake. To build and install the
|
YACReader and YACReaderLibrary are build using qmake. To build and install the
|
||||||
program, run:
|
program, run:
|
||||||
|
|
||||||
> qmake-qt5 CONFIG+=[Options]
|
> qmake-qt5 CONFIG+=[Options]
|
||||||
> make
|
> make
|
||||||
> make install
|
> make install
|
||||||
|
|
||||||
from the source dir. For separate builds of YACReader or YACReaderLibrary,
|
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
|
- 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
|
||||||
@ -81,7 +80,7 @@ can be used to install to a different location, which is usefull for packaging.
|
|||||||
|
|
||||||
Default values:
|
Default values:
|
||||||
|
|
||||||
>PREFIX=/usr
|
>PREFIX=/usr
|
||||||
>INSTALL_ROOT=""
|
>INSTALL_ROOT=""
|
||||||
|
|
||||||
On embedded devices that don't support desktop OpenGL, it is recommended to use
|
On embedded devices that don't support desktop OpenGL, it is recommended to use
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -2,18 +2,9 @@
|
|||||||
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include <QtOpenGL>
|
#include <QtOpenGL>
|
||||||
//#include <math.h>
|
#include <QMatrix4x4>
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
|
||||||
#include <OpenGL/glu.h>
|
|
||||||
#else
|
|
||||||
#include <GL/glu.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <QGLContext>
|
|
||||||
#include <QGLPixelBuffer>
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
|
||||||
/*** Animation Settings ***/
|
/*** Animation Settings ***/
|
||||||
|
|
||||||
/*** Position Configuration ***/
|
/*** Position Configuration ***/
|
||||||
@ -24,15 +15,15 @@ struct Preset defaultYACReaderFlowConfig = {
|
|||||||
0.08f, //Animation_step sets the speed of the animation
|
0.08f, //Animation_step sets the speed of the animation
|
||||||
1.5f, //Animation_speedup sets the acceleration of the animation
|
1.5f, //Animation_speedup sets the acceleration of the animation
|
||||||
0.1f, //Animation_step_max sets the maximum speed of the animation
|
0.1f, //Animation_step_max sets the maximum speed of the animation
|
||||||
3.f, //Animation_Fade_out_dis sets the distance of view
|
3.f, //Animation_Fade_out_dis sets the distance of view
|
||||||
|
|
||||||
1.5f, //pre_rotation sets the rotation increasion
|
1.5f, //pre_rotation sets the rotation increasion
|
||||||
3.f, //View_rotate_light_strenght sets the light strenght on rotation
|
3.f, //View_rotate_light_strenght sets the light strenght on rotation
|
||||||
0.01f, //View_rotate_add sets the speed of the rotation
|
0.01f, //View_rotate_add sets the speed of the rotation
|
||||||
0.02f, //View_rotate_sub sets the speed of reversing the rotation
|
0.02f, //View_rotate_sub sets the speed of reversing the rotation
|
||||||
20.f, //View_angle sets the maximum view angle
|
20.f, //View_angle sets the maximum view angle
|
||||||
|
|
||||||
0.f, //CF_X the X Position of the Coverflow
|
0.f, //CF_X the X Position of the Coverflow
|
||||||
0.f, //CF_Y the Y Position of the Coverflow
|
0.f, //CF_Y the Y Position of the Coverflow
|
||||||
-8.f, //CF_Z the Z Position of the Coverflow
|
-8.f, //CF_Z the Z Position of the Coverflow
|
||||||
|
|
||||||
@ -43,7 +34,7 @@ struct Preset defaultYACReaderFlowConfig = {
|
|||||||
-50.f, //Rotation sets the rotation of each cover
|
-50.f, //Rotation sets the rotation of each cover
|
||||||
0.18f, //X_Distance sets the distance between the covers
|
0.18f, //X_Distance sets the distance between the covers
|
||||||
1.f, //Center_Distance sets the distance between the centered and the non centered covers
|
1.f, //Center_Distance sets the distance between the centered and the non centered covers
|
||||||
0.1f, //Z_Distance sets the pushback amount
|
0.1f, //Z_Distance sets the pushback amount
|
||||||
0.0f, //Y_Distance sets the elevation amount
|
0.0f, //Y_Distance sets the elevation amount
|
||||||
|
|
||||||
30.f //zoom level
|
30.f //zoom level
|
||||||
@ -54,15 +45,15 @@ struct Preset presetYACReaderFlowClassicConfig = {
|
|||||||
0.08f, //Animation_step sets the speed of the animation
|
0.08f, //Animation_step sets the speed of the animation
|
||||||
1.5f, //Animation_speedup sets the acceleration of the animation
|
1.5f, //Animation_speedup sets the acceleration of the animation
|
||||||
0.1f, //Animation_step_max sets the maximum speed of the animation
|
0.1f, //Animation_step_max sets the maximum speed of the animation
|
||||||
2.f, //Animation_Fade_out_dis sets the distance of view
|
2.f, //Animation_Fade_out_dis sets the distance of view
|
||||||
|
|
||||||
1.5f, //pre_rotation sets the rotation increasion
|
1.5f, //pre_rotation sets the rotation increasion
|
||||||
3.f, //View_rotate_light_strenght sets the light strenght on rotation
|
3.f, //View_rotate_light_strenght sets the light strenght on rotation
|
||||||
0.08f, //View_rotate_add sets the speed of the rotation
|
0.08f, //View_rotate_add sets the speed of the rotation
|
||||||
0.08f, //View_rotate_sub sets the speed of reversing the rotation
|
0.08f, //View_rotate_sub sets the speed of reversing the rotation
|
||||||
30.f, //View_angle sets the maximum view angle
|
30.f, //View_angle sets the maximum view angle
|
||||||
|
|
||||||
0.f, //CF_X the X Position of the Coverflow
|
0.f, //CF_X the X Position of the Coverflow
|
||||||
-0.2f, //CF_Y the Y Position of the Coverflow
|
-0.2f, //CF_Y the Y Position of the Coverflow
|
||||||
-7.f, //CF_Z the Z Position of the Coverflow
|
-7.f, //CF_Z the Z Position of the Coverflow
|
||||||
|
|
||||||
@ -73,9 +64,9 @@ struct Preset presetYACReaderFlowClassicConfig = {
|
|||||||
-40.f, //Rotation sets the rotation of each cover
|
-40.f, //Rotation sets the rotation of each cover
|
||||||
0.18f, //X_Distance sets the distance between the covers
|
0.18f, //X_Distance sets the distance between the covers
|
||||||
1.f, //Center_Distance sets the distance between the centered and the non centered covers
|
1.f, //Center_Distance sets the distance between the centered and the non centered covers
|
||||||
0.1f, //Z_Distance sets the pushback amount
|
0.1f, //Z_Distance sets the pushback amount
|
||||||
0.0f, //Y_Distance sets the elevation amount
|
0.0f, //Y_Distance sets the elevation amount
|
||||||
|
|
||||||
22.f //zoom level
|
22.f //zoom level
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -84,15 +75,15 @@ struct Preset presetYACReaderFlowStripeConfig = {
|
|||||||
0.08f, //Animation_step sets the speed of the animation
|
0.08f, //Animation_step sets the speed of the animation
|
||||||
1.5f, //Animation_speedup sets the acceleration of the animation
|
1.5f, //Animation_speedup sets the acceleration of the animation
|
||||||
0.1f, //Animation_step_max sets the maximum speed of the animation
|
0.1f, //Animation_step_max sets the maximum speed of the animation
|
||||||
6.f, //Animation_Fade_out_dis sets the distance of view
|
6.f, //Animation_Fade_out_dis sets the distance of view
|
||||||
|
|
||||||
1.5f, //pre_rotation sets the rotation increasion
|
1.5f, //pre_rotation sets the rotation increasion
|
||||||
4.f, //View_rotate_light_strenght sets the light strenght on rotation
|
4.f, //View_rotate_light_strenght sets the light strenght on rotation
|
||||||
0.08f, //View_rotate_add sets the speed of the rotation
|
0.08f, //View_rotate_add sets the speed of the rotation
|
||||||
0.08f, //View_rotate_sub sets the speed of reversing the rotation
|
0.08f, //View_rotate_sub sets the speed of reversing the rotation
|
||||||
30.f, //View_angle sets the maximum view angle
|
30.f, //View_angle sets the maximum view angle
|
||||||
|
|
||||||
0.f, //CF_X the X Position of the Coverflow
|
0.f, //CF_X the X Position of the Coverflow
|
||||||
-0.2f, //CF_Y the Y Position of the Coverflow
|
-0.2f, //CF_Y the Y Position of the Coverflow
|
||||||
-7.f, //CF_Z the Z Position of the Coverflow
|
-7.f, //CF_Z the Z Position of the Coverflow
|
||||||
|
|
||||||
@ -103,7 +94,7 @@ struct Preset presetYACReaderFlowStripeConfig = {
|
|||||||
0.f, //Rotation sets the rotation of each cover
|
0.f, //Rotation sets the rotation of each cover
|
||||||
1.1f, //X_Distance sets the distance between the covers
|
1.1f, //X_Distance sets the distance between the covers
|
||||||
0.2f, //Center_Distance sets the distance between the centered and the non centered covers
|
0.2f, //Center_Distance sets the distance between the centered and the non centered covers
|
||||||
0.01f, //Z_Distance sets the pushback amount
|
0.01f, //Z_Distance sets the pushback amount
|
||||||
0.0f, //Y_Distance sets the elevation amount
|
0.0f, //Y_Distance sets the elevation amount
|
||||||
|
|
||||||
22.f //zoom level
|
22.f //zoom level
|
||||||
@ -114,15 +105,15 @@ struct Preset presetYACReaderFlowOverlappedStripeConfig = {
|
|||||||
0.08f, //Animation_step sets the speed of the animation
|
0.08f, //Animation_step sets the speed of the animation
|
||||||
1.5f, //Animation_speedup sets the acceleration of the animation
|
1.5f, //Animation_speedup sets the acceleration of the animation
|
||||||
0.1f, //Animation_step_max sets the maximum speed of the animation
|
0.1f, //Animation_step_max sets the maximum speed of the animation
|
||||||
2.f, //Animation_Fade_out_dis sets the distance of view
|
2.f, //Animation_Fade_out_dis sets the distance of view
|
||||||
|
|
||||||
1.5f, //pre_rotation sets the rotation increasion
|
1.5f, //pre_rotation sets the rotation increasion
|
||||||
3.f, //View_rotate_light_strenght sets the light strenght on rotation
|
3.f, //View_rotate_light_strenght sets the light strenght on rotation
|
||||||
0.08f, //View_rotate_add sets the speed of the rotation
|
0.08f, //View_rotate_add sets the speed of the rotation
|
||||||
0.08f, //View_rotate_sub sets the speed of reversing the rotation
|
0.08f, //View_rotate_sub sets the speed of reversing the rotation
|
||||||
30.f, //View_angle sets the maximum view angle
|
30.f, //View_angle sets the maximum view angle
|
||||||
|
|
||||||
0.f, //CF_X the X Position of the Coverflow
|
0.f, //CF_X the X Position of the Coverflow
|
||||||
-0.2f, //CF_Y the Y Position of the Coverflow
|
-0.2f, //CF_Y the Y Position of the Coverflow
|
||||||
-7.f, //CF_Z the Z Position of the Coverflow
|
-7.f, //CF_Z the Z Position of the Coverflow
|
||||||
|
|
||||||
@ -133,7 +124,7 @@ struct Preset presetYACReaderFlowOverlappedStripeConfig = {
|
|||||||
0.f, //Rotation sets the rotation of each cover
|
0.f, //Rotation sets the rotation of each cover
|
||||||
0.18f, //X_Distance sets the distance between the covers
|
0.18f, //X_Distance sets the distance between the covers
|
||||||
1.f, //Center_Distance sets the distance between the centered and the non centered covers
|
1.f, //Center_Distance sets the distance between the centered and the non centered covers
|
||||||
0.1f, //Z_Distance sets the pushback amount
|
0.1f, //Z_Distance sets the pushback amount
|
||||||
0.0f, //Y_Distance sets the elevation amount
|
0.0f, //Y_Distance sets the elevation amount
|
||||||
|
|
||||||
22.f //zoom level
|
22.f //zoom level
|
||||||
@ -144,15 +135,15 @@ struct Preset pressetYACReaderFlowUpConfig = {
|
|||||||
0.08f, //Animation_step sets the speed of the animation
|
0.08f, //Animation_step sets the speed of the animation
|
||||||
1.5f, //Animation_speedup sets the acceleration of the animation
|
1.5f, //Animation_speedup sets the acceleration of the animation
|
||||||
0.1f, //Animation_step_max sets the maximum speed of the animation
|
0.1f, //Animation_step_max sets the maximum speed of the animation
|
||||||
2.5f, //Animation_Fade_out_dis sets the distance of view
|
2.5f, //Animation_Fade_out_dis sets the distance of view
|
||||||
|
|
||||||
1.5f, //pre_rotation sets the rotation increasion
|
1.5f, //pre_rotation sets the rotation increasion
|
||||||
3.f, //View_rotate_light_strenght sets the light strenght on rotation
|
3.f, //View_rotate_light_strenght sets the light strenght on rotation
|
||||||
0.08f, //View_rotate_add sets the speed of the rotation
|
0.08f, //View_rotate_add sets the speed of the rotation
|
||||||
0.08f, //View_rotate_sub sets the speed of reversing the rotation
|
0.08f, //View_rotate_sub sets the speed of reversing the rotation
|
||||||
5.f, //View_angle sets the maximum view angle
|
5.f, //View_angle sets the maximum view angle
|
||||||
|
|
||||||
0.f, //CF_X the X Position of the Coverflow
|
0.f, //CF_X the X Position of the Coverflow
|
||||||
-0.2f, //CF_Y the Y Position of the Coverflow
|
-0.2f, //CF_Y the Y Position of the Coverflow
|
||||||
-7.f, //CF_Z the Z Position of the Coverflow
|
-7.f, //CF_Z the Z Position of the Coverflow
|
||||||
|
|
||||||
@ -163,7 +154,7 @@ struct Preset pressetYACReaderFlowUpConfig = {
|
|||||||
-50.f, //Rotation sets the rotation of each cover
|
-50.f, //Rotation sets the rotation of each cover
|
||||||
0.18f, //X_Distance sets the distance between the covers
|
0.18f, //X_Distance sets the distance between the covers
|
||||||
1.f, //Center_Distance sets the distance between the centered and the non centered covers
|
1.f, //Center_Distance sets the distance between the centered and the non centered covers
|
||||||
0.1f, //Z_Distance sets the pushback amount
|
0.1f, //Z_Distance sets the pushback amount
|
||||||
-0.1f, //Y_Distance sets the elevation amount
|
-0.1f, //Y_Distance sets the elevation amount
|
||||||
|
|
||||||
22.f //zoom level
|
22.f //zoom level
|
||||||
@ -174,15 +165,15 @@ struct Preset pressetYACReaderFlowDownConfig = {
|
|||||||
0.08f, //Animation_step sets the speed of the animation
|
0.08f, //Animation_step sets the speed of the animation
|
||||||
1.5f, //Animation_speedup sets the acceleration of the animation
|
1.5f, //Animation_speedup sets the acceleration of the animation
|
||||||
0.1f, //Animation_step_max sets the maximum speed of the animation
|
0.1f, //Animation_step_max sets the maximum speed of the animation
|
||||||
2.5f, //Animation_Fade_out_dis sets the distance of view
|
2.5f, //Animation_Fade_out_dis sets the distance of view
|
||||||
|
|
||||||
1.5f, //pre_rotation sets the rotation increasion
|
1.5f, //pre_rotation sets the rotation increasion
|
||||||
3.f, //View_rotate_light_strenght sets the light strenght on rotation
|
3.f, //View_rotate_light_strenght sets the light strenght on rotation
|
||||||
0.08f, //View_rotate_add sets the speed of the rotation
|
0.08f, //View_rotate_add sets the speed of the rotation
|
||||||
0.08f, //View_rotate_sub sets the speed of reversing the rotation
|
0.08f, //View_rotate_sub sets the speed of reversing the rotation
|
||||||
5.f, //View_angle sets the maximum view angle
|
5.f, //View_angle sets the maximum view angle
|
||||||
|
|
||||||
0.f, //CF_X the X Position of the Coverflow
|
0.f, //CF_X the X Position of the Coverflow
|
||||||
-0.2f, //CF_Y the Y Position of the Coverflow
|
-0.2f, //CF_Y the Y Position of the Coverflow
|
||||||
-7.f, //CF_Z the Z Position of the Coverflow
|
-7.f, //CF_Z the Z Position of the Coverflow
|
||||||
|
|
||||||
@ -193,7 +184,7 @@ struct Preset pressetYACReaderFlowDownConfig = {
|
|||||||
-50.f, //Rotation sets the rotation of each cover
|
-50.f, //Rotation sets the rotation of each cover
|
||||||
0.18f, //X_Distance sets the distance between the covers
|
0.18f, //X_Distance sets the distance between the covers
|
||||||
1.f, //Center_Distance sets the distance between the centered and the non centered covers
|
1.f, //Center_Distance sets the distance between the centered and the non centered covers
|
||||||
0.1f, //Z_Distance sets the pushback amount
|
0.1f, //Z_Distance sets the pushback amount
|
||||||
0.1f, //Y_Distance sets the elevation amount
|
0.1f, //Y_Distance sets the elevation amount
|
||||||
|
|
||||||
22.f //zoom level
|
22.f //zoom level
|
||||||
@ -253,7 +244,7 @@ void YACReaderFlowGL::timerEvent(QTimerEvent * event)
|
|||||||
{
|
{
|
||||||
if(timerId == event->timerId())
|
if(timerId == event->timerId())
|
||||||
update();
|
update();
|
||||||
|
|
||||||
//if(!worker->isRunning())
|
//if(!worker->isRunning())
|
||||||
//worker->start();
|
//worker->start();
|
||||||
}
|
}
|
||||||
@ -374,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -449,7 +440,7 @@ void YACReaderFlowGL::drawCover(const YACReader3DImage & image)
|
|||||||
float w = image.width;
|
float w = image.width;
|
||||||
float h = image.height;
|
float h = image.height;
|
||||||
|
|
||||||
//fadeout
|
//fadeout
|
||||||
float opacity = 1-1/(config.animationFadeOutDist+config.viewRotateLightStrenght*fabs(viewRotate))*fabs(0-image.current.x);
|
float opacity = 1-1/(config.animationFadeOutDist+config.viewRotateLightStrenght*fabs(viewRotate))*fabs(0-image.current.x);
|
||||||
|
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
@ -527,7 +518,7 @@ void YACReaderFlowGL::drawCover(const YACReader3DImage & image)
|
|||||||
|
|
||||||
glEnd();
|
glEnd();
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
if(showMarks && loaded[image.index] && marks[image.index] != Unread)
|
if(showMarks && loaded[image.index] && marks[image.index] != Unread)
|
||||||
{
|
{
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
@ -561,7 +552,7 @@ void YACReaderFlowGL::drawCover(const YACReader3DImage & image)
|
|||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -618,7 +609,7 @@ void YACReaderFlowGL::showPrevious()
|
|||||||
|
|
||||||
viewRotateActive = 1;
|
viewRotateActive = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void YACReaderFlowGL::showNext()
|
void YACReaderFlowGL::showNext()
|
||||||
@ -708,7 +699,7 @@ void YACReaderFlowGL::insert(char *name, QOpenGLTexture * texture, float x, floa
|
|||||||
startAnimationTimer();
|
startAnimationTimer();
|
||||||
|
|
||||||
Q_UNUSED(name)
|
Q_UNUSED(name)
|
||||||
//set a new entry
|
//set a new entry
|
||||||
if(item == -1){
|
if(item == -1){
|
||||||
images.push_back(YACReader3DImage());
|
images.push_back(YACReader3DImage());
|
||||||
|
|
||||||
@ -786,7 +777,7 @@ void YACReaderFlowGL::populate(int n)
|
|||||||
float x = 1;
|
float x = 1;
|
||||||
float y = 1 * (700.f/480.0f);
|
float y = 1 * (700.f/480.0f);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0;i<n;i++){
|
for(i = 0;i<n;i++){
|
||||||
QString s = "cover";
|
QString s = "cover";
|
||||||
insert(s.toLocal8Bit().data(), defaultTexture, x, y);
|
insert(s.toLocal8Bit().data(), defaultTexture, x, y);
|
||||||
@ -803,7 +794,7 @@ void YACReaderFlowGL::populate(int n)
|
|||||||
loaded = QVector<bool>(n,false);
|
loaded = QVector<bool>(n,false);
|
||||||
//marks = QVector<bool>(n,false);
|
//marks = QVector<bool>(n,false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//worker->start();
|
//worker->start();
|
||||||
}
|
}
|
||||||
@ -824,7 +815,7 @@ void YACReaderFlowGL::reset()
|
|||||||
|
|
||||||
numObjects = 0;
|
numObjects = 0;
|
||||||
images.clear();
|
images.clear();
|
||||||
|
|
||||||
if(!hasBeenInitialized)
|
if(!hasBeenInitialized)
|
||||||
lazyPopulateObjects = -1;
|
lazyPopulateObjects = -1;
|
||||||
|
|
||||||
@ -869,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);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -899,7 +888,7 @@ void YACReaderFlowGL::setCenter_Distance(int distance)
|
|||||||
|
|
||||||
config.centerDistance = distance/100.0;
|
config.centerDistance = distance/100.0;
|
||||||
}
|
}
|
||||||
//sets the pushback amount
|
//sets the pushback amount
|
||||||
void YACReaderFlowGL::setZ_Distance(int distance)
|
void YACReaderFlowGL::setZ_Distance(int distance)
|
||||||
{
|
{
|
||||||
startAnimationTimer();
|
startAnimationTimer();
|
||||||
@ -1116,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);
|
showNext();
|
||||||
|
}
|
||||||
if((posX >= 0.5 && !flowRightToLeft) || (posX <=-0.5 && flowRightToLeft))
|
else if((clickVector.x() <=-0.5 && !flowRightToLeft) || (clickVector.x() >= 0.5 && flowRightToLeft) )
|
||||||
{
|
{
|
||||||
//int index = currentSelected+1;
|
showPrevious();
|
||||||
//while((cfImages[index].current.x-cfImages[index].width/(2.0*config.rotation)) < posX)
|
}
|
||||||
// index++;
|
}
|
||||||
//setCurrentIndex(index-1);
|
else
|
||||||
showNext();
|
{
|
||||||
}
|
|
||||||
else if((posX <=-0.5 && !flowRightToLeft) || (posX >= 0.5 && flowRightToLeft) )
|
|
||||||
showPrevious();
|
|
||||||
} else
|
|
||||||
QOpenGLWidget::mousePressEvent(event);
|
QOpenGLWidget::mousePressEvent(event);
|
||||||
|
}
|
||||||
doneCurrent();
|
doneCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1155,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();
|
||||||
@ -1240,7 +1221,7 @@ void YACReaderComicFlowGL::updateImageData()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// try to load only few images on the left and right side
|
// try to load only few images on the left and right side
|
||||||
// i.e. all visible ones plus some extra
|
// i.e. all visible ones plus some extra
|
||||||
int count=8;
|
int count=8;
|
||||||
switch(performance)
|
switch(performance)
|
||||||
@ -1265,7 +1246,7 @@ void YACReaderComicFlowGL::updateImageData()
|
|||||||
{
|
{
|
||||||
indexes[j*2+1] = center+j+1;
|
indexes[j*2+1] = center+j+1;
|
||||||
indexes[j*2+2] = center-j-1;
|
indexes[j*2+2] = center-j-1;
|
||||||
}
|
}
|
||||||
for(int c = 0; c < 2*count+1; c++)
|
for(int c = 0; c < 2*count+1; c++)
|
||||||
{
|
{
|
||||||
int i = indexes[c];
|
int i = indexes[c];
|
||||||
@ -1396,7 +1377,7 @@ void YACReaderPageFlowGL::updateImageData()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// try to load only few images on the left and right side
|
// try to load only few images on the left and right side
|
||||||
// i.e. all visible ones plus some extra
|
// i.e. all visible ones plus some extra
|
||||||
int count=8;
|
int count=8;
|
||||||
switch(performance)
|
switch(performance)
|
||||||
@ -1421,17 +1402,17 @@ void YACReaderPageFlowGL::updateImageData()
|
|||||||
{
|
{
|
||||||
indexes[j*2+1] = center+j+1;
|
indexes[j*2+1] = center+j+1;
|
||||||
indexes[j*2+2] = center-j-1;
|
indexes[j*2+2] = center-j-1;
|
||||||
}
|
}
|
||||||
for(int c = 0; c < 2*count+1; c++)
|
for(int c = 0; c < 2*count+1; c++)
|
||||||
{
|
{
|
||||||
int i = indexes[c];
|
int i = indexes[c];
|
||||||
if((i >= 0) && (i < numObjects))
|
if((i >= 0) && (i < numObjects))
|
||||||
if(rawImages.size()>0)
|
if(rawImages.size()>0)
|
||||||
|
|
||||||
if(!loaded[i]&&imagesReady[i])//slide(i).isNull())
|
if(!loaded[i]&&imagesReady[i])//slide(i).isNull())
|
||||||
{
|
{
|
||||||
worker->generate(i, rawImages.at(i));
|
worker->generate(i, rawImages.at(i));
|
||||||
|
|
||||||
delete[] indexes;
|
delete[] indexes;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1481,7 +1462,7 @@ QImage ImageLoaderGL::loadImage(const QString& fileName)
|
|||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageLoaderGL::ImageLoaderGL(YACReaderFlowGL * flow):
|
ImageLoaderGL::ImageLoaderGL(YACReaderFlowGL * flow):
|
||||||
QThread(),flow(flow),restart(false), working(false), idx(-1)
|
QThread(),flow(flow),restart(false), working(false), idx(-1)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -1498,7 +1479,7 @@ ImageLoaderGL::~ImageLoaderGL()
|
|||||||
bool ImageLoaderGL::busy() const
|
bool ImageLoaderGL::busy() const
|
||||||
{
|
{
|
||||||
return isRunning() ? working : false;
|
return isRunning() ? working : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageLoaderGL::generate(int index, const QString& fileName)
|
void ImageLoaderGL::generate(int index, const QString& fileName)
|
||||||
{
|
{
|
||||||
@ -1556,9 +1537,9 @@ void ImageLoaderGL::run()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage ImageLoaderGL::result()
|
QImage ImageLoaderGL::result()
|
||||||
{
|
{
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -1591,7 +1572,7 @@ QImage ImageLoaderByteArrayGL::loadImage(const QByteArray& raw)
|
|||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageLoaderByteArrayGL::ImageLoaderByteArrayGL(YACReaderFlowGL * flow):
|
ImageLoaderByteArrayGL::ImageLoaderByteArrayGL(YACReaderFlowGL * flow):
|
||||||
QThread(),flow(flow),restart(false), working(false), idx(-1)
|
QThread(),flow(flow),restart(false), working(false), idx(-1)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -1608,7 +1589,7 @@ ImageLoaderByteArrayGL::~ImageLoaderByteArrayGL()
|
|||||||
bool ImageLoaderByteArrayGL::busy() const
|
bool ImageLoaderByteArrayGL::busy() const
|
||||||
{
|
{
|
||||||
return isRunning() ? working : false;
|
return isRunning() ? working : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageLoaderByteArrayGL::generate(int index, const QByteArray& raw)
|
void ImageLoaderByteArrayGL::generate(int index, const QByteArray& raw)
|
||||||
{
|
{
|
||||||
@ -1656,7 +1637,7 @@ void ImageLoaderByteArrayGL::run()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage ImageLoaderByteArrayGL::result()
|
QImage ImageLoaderByteArrayGL::result()
|
||||||
{
|
{
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,11 +2,6 @@
|
|||||||
#ifndef __YACREADER_FLOW_GL_H
|
#ifndef __YACREADER_FLOW_GL_H
|
||||||
#define __YACREADER_FLOW_GL_H
|
#define __YACREADER_FLOW_GL_H
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
#include <QOpenGLWidget>
|
#include <QOpenGLWidget>
|
||||||
#include <QOpenGLFunctions>
|
#include <QOpenGLFunctions>
|
||||||
#include <QOpenGLTexture>
|
#include <QOpenGLTexture>
|
||||||
@ -16,8 +11,6 @@
|
|||||||
#include "scroll_management.h"
|
#include "scroll_management.h"
|
||||||
|
|
||||||
class ImageLoaderGL;
|
class ImageLoaderGL;
|
||||||
class QGLContext;
|
|
||||||
class WidgetLoader;
|
|
||||||
class ImageLoaderByteArrayGL;
|
class ImageLoaderByteArrayGL;
|
||||||
|
|
||||||
enum Performance
|
enum Performance
|
||||||
@ -58,13 +51,13 @@ struct Preset{
|
|||||||
float animationSpeedUp;
|
float animationSpeedUp;
|
||||||
//sets the maximum speed of the animation
|
//sets the maximum speed of the animation
|
||||||
float animationStepMax;
|
float animationStepMax;
|
||||||
//sets the distance of view
|
//sets the distance of view
|
||||||
float animationFadeOutDist;
|
float animationFadeOutDist;
|
||||||
//sets the rotation increasion
|
//sets the rotation increasion
|
||||||
float preRotation;
|
float preRotation;
|
||||||
//sets the light strenght on rotation
|
//sets the light strenght on rotation
|
||||||
float viewRotateLightStrenght;
|
float viewRotateLightStrenght;
|
||||||
//sets the speed of the rotation
|
//sets the speed of the rotation
|
||||||
float viewRotateAdd;
|
float viewRotateAdd;
|
||||||
//sets the speed of reversing the rotation
|
//sets the speed of reversing the rotation
|
||||||
float viewRotateSub;
|
float viewRotateSub;
|
||||||
@ -72,17 +65,17 @@ struct Preset{
|
|||||||
float viewAngle;
|
float viewAngle;
|
||||||
|
|
||||||
/*** Position Configuration ***/
|
/*** Position Configuration ***/
|
||||||
//the X Position of the Coverflow
|
//the X Position of the Coverflow
|
||||||
float cfX;
|
float cfX;
|
||||||
//the Y Position of the Coverflow
|
//the Y Position of the Coverflow
|
||||||
float cfY;
|
float cfY;
|
||||||
//the Z Position of the Coverflow
|
//the Z Position of the Coverflow
|
||||||
float cfZ;
|
float cfZ;
|
||||||
//the X Rotation of the Coverflow
|
//the X Rotation of the Coverflow
|
||||||
float cfRX;
|
float cfRX;
|
||||||
//the Y Rotation of the Coverflow
|
//the Y Rotation of the Coverflow
|
||||||
float cfRY;
|
float cfRY;
|
||||||
//the Z Rotation of the Coverflow
|
//the Z Rotation of the Coverflow
|
||||||
float cfRZ;
|
float cfRZ;
|
||||||
//sets the rotation of each cover
|
//sets the rotation of each cover
|
||||||
float rotation;
|
float rotation;
|
||||||
@ -90,7 +83,7 @@ struct Preset{
|
|||||||
float xDistance;
|
float xDistance;
|
||||||
//sets the distance between the centered and the non centered covers
|
//sets the distance between the centered and the non centered covers
|
||||||
float centerDistance;
|
float centerDistance;
|
||||||
//sets the pushback amount
|
//sets the pushback amount
|
||||||
float zDistance;
|
float zDistance;
|
||||||
//sets the elevation amount
|
//sets the elevation amount
|
||||||
float yDistance;
|
float yDistance;
|
||||||
@ -123,9 +116,8 @@ protected:
|
|||||||
void drawCover(const YACReader3DImage & image);
|
void drawCover(const YACReader3DImage & image);
|
||||||
|
|
||||||
void udpatePerspective(int width, int height);
|
void udpatePerspective(int width, int height);
|
||||||
|
|
||||||
int updateCount;
|
int updateCount;
|
||||||
WidgetLoader * loader;
|
|
||||||
int fontSize;
|
int fontSize;
|
||||||
|
|
||||||
QOpenGLTexture * defaultTexture;
|
QOpenGLTexture * defaultTexture;
|
||||||
@ -152,10 +144,10 @@ protected:
|
|||||||
/*** Animation Settings ***/
|
/*** Animation Settings ***/
|
||||||
Preset config;
|
Preset config;
|
||||||
|
|
||||||
//sets/returns the curent selected cover
|
//sets/returns the curent selected cover
|
||||||
int currentSelected;
|
int currentSelected;
|
||||||
|
|
||||||
//defines the position of the centered cover
|
//defines the position of the centered cover
|
||||||
YACReader3DVector centerPos;
|
YACReader3DVector centerPos;
|
||||||
|
|
||||||
/*** Style ***/
|
/*** Style ***/
|
||||||
@ -174,11 +166,11 @@ protected:
|
|||||||
static int updateInterval;
|
static int updateInterval;
|
||||||
|
|
||||||
// sets flow direction right-to-left (manga mode)
|
// sets flow direction right-to-left (manga mode)
|
||||||
bool flowRightToLeft;
|
bool flowRightToLeft;
|
||||||
|
|
||||||
void startAnimationTimer();
|
void startAnimationTimer();
|
||||||
void stopAnimationTimer();
|
void stopAnimationTimer();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
@ -204,7 +196,7 @@ public:
|
|||||||
void draw();
|
void draw();
|
||||||
//updates the coverflow
|
//updates the coverflow
|
||||||
void updatePositions();
|
void updatePositions();
|
||||||
//inserts a new item to the coverflow
|
//inserts a new item to the coverflow
|
||||||
//if item is set to a value > -1 it updates a already set value
|
//if item is set to a value > -1 it updates a already set value
|
||||||
//otherwise a new entry is set
|
//otherwise a new entry is set
|
||||||
void insert(char *name, QOpenGLTexture * texture, float x, float y, int item = -1);
|
void insert(char *name, QOpenGLTexture * texture, float x, float y, int item = -1);
|
||||||
@ -221,9 +213,9 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setCF_RX(int value);
|
void setCF_RX(int value);
|
||||||
//the Y Rotation of the Coverflow
|
//the Y Rotation of the Coverflow
|
||||||
void setCF_RY(int value);
|
void setCF_RY(int value);
|
||||||
//the Z Rotation of the Coverflow
|
//the Z Rotation of the Coverflow
|
||||||
void setCF_RZ(int value);
|
void setCF_RZ(int value);
|
||||||
|
|
||||||
//perspective
|
//perspective
|
||||||
@ -234,7 +226,7 @@ public:
|
|||||||
void setX_Distance(int distance);
|
void setX_Distance(int distance);
|
||||||
//sets the distance between the centered and the non centered covers
|
//sets the distance between the centered and the non centered covers
|
||||||
void setCenter_Distance(int distance);
|
void setCenter_Distance(int distance);
|
||||||
//sets the pushback amount
|
//sets the pushback amount
|
||||||
void setZ_Distance(int distance);
|
void setZ_Distance(int distance);
|
||||||
|
|
||||||
void setCF_Y(int value);
|
void setCF_Y(int value);
|
||||||
@ -344,7 +336,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
QMutex mutex;
|
QMutex mutex;
|
||||||
QWaitCondition condition;
|
QWaitCondition condition;
|
||||||
|
|
||||||
|
|
||||||
bool restart;
|
bool restart;
|
||||||
bool working;
|
bool working;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,385 +0,0 @@
|
|||||||
//OpenGL Coverflow API by J.Roth
|
|
||||||
#ifndef __YACREADER_FLOW_GL_H
|
|
||||||
#define __YACREADER_FLOW_GL_H
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
#include <QtOpenGL>
|
|
||||||
#include <QGLWidget>
|
|
||||||
#include <QtWidgets>
|
|
||||||
|
|
||||||
#include "pictureflow.h" //TODO mover los tipos de flow de sitio
|
|
||||||
#include "scroll_management.h"
|
|
||||||
|
|
||||||
class ImageLoaderGL;
|
|
||||||
class QGLContext;
|
|
||||||
class WidgetLoader;
|
|
||||||
class ImageLoaderByteArrayGL;
|
|
||||||
|
|
||||||
enum Performance
|
|
||||||
{
|
|
||||||
low=0,
|
|
||||||
medium,
|
|
||||||
high,
|
|
||||||
ultraHigh
|
|
||||||
};
|
|
||||||
|
|
||||||
//Cover Vector
|
|
||||||
struct YACReader3DVector{
|
|
||||||
float x;
|
|
||||||
float y;
|
|
||||||
float z;
|
|
||||||
float rot;
|
|
||||||
};
|
|
||||||
|
|
||||||
//the image/texture info struct
|
|
||||||
struct YACReader3DImage{
|
|
||||||
GLuint texture;
|
|
||||||
//char name[256];
|
|
||||||
|
|
||||||
float width;
|
|
||||||
float height;
|
|
||||||
|
|
||||||
int index;
|
|
||||||
|
|
||||||
YACReader3DVector current;
|
|
||||||
YACReader3DVector animEnd;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Preset{
|
|
||||||
/*** Animation Settings ***/
|
|
||||||
//sets the speed of the animation
|
|
||||||
float animationStep;
|
|
||||||
//sets the acceleration of the animation
|
|
||||||
float animationSpeedUp;
|
|
||||||
//sets the maximum speed of the animation
|
|
||||||
float animationStepMax;
|
|
||||||
//sets the distance of view
|
|
||||||
float animationFadeOutDist;
|
|
||||||
//sets the rotation increasion
|
|
||||||
float preRotation;
|
|
||||||
//sets the light strenght on rotation
|
|
||||||
float viewRotateLightStrenght;
|
|
||||||
//sets the speed of the rotation
|
|
||||||
float viewRotateAdd;
|
|
||||||
//sets the speed of reversing the rotation
|
|
||||||
float viewRotateSub;
|
|
||||||
//sets the maximum view angle
|
|
||||||
float viewAngle;
|
|
||||||
|
|
||||||
/*** Position Configuration ***/
|
|
||||||
//the X Position of the Coverflow
|
|
||||||
float cfX;
|
|
||||||
//the Y Position of the Coverflow
|
|
||||||
float cfY;
|
|
||||||
//the Z Position of the Coverflow
|
|
||||||
float cfZ;
|
|
||||||
//the X Rotation of the Coverflow
|
|
||||||
float cfRX;
|
|
||||||
//the Y Rotation of the Coverflow
|
|
||||||
float cfRY;
|
|
||||||
//the Z Rotation of the Coverflow
|
|
||||||
float cfRZ;
|
|
||||||
//sets the rotation of each cover
|
|
||||||
float rotation;
|
|
||||||
//sets the distance between the covers
|
|
||||||
float xDistance;
|
|
||||||
//sets the distance between the centered and the non centered covers
|
|
||||||
float centerDistance;
|
|
||||||
//sets the pushback amount
|
|
||||||
float zDistance;
|
|
||||||
//sets the elevation amount
|
|
||||||
float yDistance;
|
|
||||||
|
|
||||||
float zoom;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern struct Preset defaultYACReaderFlowConfig;
|
|
||||||
extern struct Preset presetYACReaderFlowClassicConfig;
|
|
||||||
extern struct Preset presetYACReaderFlowStripeConfig;
|
|
||||||
extern struct Preset presetYACReaderFlowOverlappedStripeConfig;
|
|
||||||
extern struct Preset pressetYACReaderFlowUpConfig;
|
|
||||||
extern struct Preset pressetYACReaderFlowDownConfig;
|
|
||||||
|
|
||||||
class YACReaderFlowGL : public QGLWidget, public ScrollManagement
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
protected:
|
|
||||||
int timerId;
|
|
||||||
/*** System variables ***/
|
|
||||||
YACReader3DImage dummy;
|
|
||||||
int viewRotateActive;
|
|
||||||
float stepBackup;
|
|
||||||
|
|
||||||
/*functions*/
|
|
||||||
void calcPos(YACReader3DImage & image, int pos);
|
|
||||||
void calcVector(YACReader3DVector & vector, int pos);
|
|
||||||
//returns true if the animation is finished for Current
|
|
||||||
bool animate(YACReader3DVector ¤tVector, YACReader3DVector &toVector);
|
|
||||||
void drawCover(const YACReader3DImage & image);
|
|
||||||
|
|
||||||
void udpatePerspective(int width, int height);
|
|
||||||
|
|
||||||
int updateCount;
|
|
||||||
WidgetLoader * loader;
|
|
||||||
int fontSize;
|
|
||||||
|
|
||||||
GLuint defaultTexture;
|
|
||||||
GLuint markTexture;
|
|
||||||
GLuint readingTexture;
|
|
||||||
void initializeGL();
|
|
||||||
void paintGL();
|
|
||||||
void timerEvent(QTimerEvent *);
|
|
||||||
|
|
||||||
//number of Covers
|
|
||||||
int numObjects;
|
|
||||||
int lazyPopulateObjects;
|
|
||||||
bool showMarks;
|
|
||||||
QVector<bool> loaded;
|
|
||||||
QVector<YACReaderComicReadStatus> marks;
|
|
||||||
QVector<YACReader3DImage> images;
|
|
||||||
bool hasBeenInitialized;
|
|
||||||
|
|
||||||
// sets flow direction right-to-left (manga mode)
|
|
||||||
bool flowRightToLeft;
|
|
||||||
|
|
||||||
Performance performance;
|
|
||||||
bool bUseVSync;
|
|
||||||
|
|
||||||
/*** Animation Settings ***/
|
|
||||||
Preset config;
|
|
||||||
|
|
||||||
//sets/returns the curent selected cover
|
|
||||||
int currentSelected;
|
|
||||||
|
|
||||||
//defines the position of the centered cover
|
|
||||||
YACReader3DVector centerPos;
|
|
||||||
|
|
||||||
/*** Style ***/
|
|
||||||
//sets the amount of shading of the covers in the back (0-1)
|
|
||||||
float shadingTop;
|
|
||||||
float shadingBottom;
|
|
||||||
|
|
||||||
//sets the reflection strenght (0-1)
|
|
||||||
float reflectionUp;
|
|
||||||
float reflectionBottom;
|
|
||||||
|
|
||||||
/*** System info ***/
|
|
||||||
float viewRotate;
|
|
||||||
|
|
||||||
//sets the updateInterval in ms
|
|
||||||
static int updateInterval;
|
|
||||||
|
|
||||||
void startAnimationTimer();
|
|
||||||
void stopAnimationTimer();
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
|
|
||||||
/*Constructor*/
|
|
||||||
YACReaderFlowGL(QWidget *parent = 0,struct Preset p = pressetYACReaderFlowDownConfig);
|
|
||||||
virtual ~YACReaderFlowGL();
|
|
||||||
|
|
||||||
//size;
|
|
||||||
QSize minimumSizeHint() const;
|
|
||||||
//QSize sizeHint() const;
|
|
||||||
|
|
||||||
/*functions*/
|
|
||||||
|
|
||||||
//if called it moves the coverflow to the left
|
|
||||||
void showPrevious();
|
|
||||||
//if called it moves the coverflow to the right
|
|
||||||
void showNext();
|
|
||||||
//go to
|
|
||||||
void setCurrentIndex(int pos);
|
|
||||||
//must be called whenever the coverflow animation is stopped
|
|
||||||
void cleanupAnimation();
|
|
||||||
//Draws the coverflow
|
|
||||||
void draw();
|
|
||||||
//updates the coverflow
|
|
||||||
void updatePositions();
|
|
||||||
//inserts a new item to the coverflow
|
|
||||||
//if item is set to a value > -1 it updates a already set value
|
|
||||||
//otherwise a new entry is set
|
|
||||||
void insert(const char *name, GLuint Tex, float x, float y,int item = -1);
|
|
||||||
//removes a item
|
|
||||||
virtual void remove(int item);
|
|
||||||
//replaces the texture of the item 'item' with Tex
|
|
||||||
void replace(const char *name, GLuint Tex, float x, float y,int item);
|
|
||||||
//create n covers with the default nu
|
|
||||||
void populate(int n);
|
|
||||||
/*Info*/
|
|
||||||
//retuns the YACReader3DImage Struct of the current selected item
|
|
||||||
//to read title or textures
|
|
||||||
YACReader3DImage getCurrentSelected();
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void setCF_RX(int value);
|
|
||||||
//the Y Rotation of the Coverflow
|
|
||||||
void setCF_RY(int value);
|
|
||||||
//the Z Rotation of the Coverflow
|
|
||||||
void setCF_RZ(int value);
|
|
||||||
|
|
||||||
//perspective
|
|
||||||
void setZoom(int zoom);
|
|
||||||
|
|
||||||
void setRotation(int angle);
|
|
||||||
//sets the distance between the covers
|
|
||||||
void setX_Distance(int distance);
|
|
||||||
//sets the distance between the centered and the non centered covers
|
|
||||||
void setCenter_Distance(int distance);
|
|
||||||
//sets the pushback amount
|
|
||||||
void setZ_Distance(int distance);
|
|
||||||
|
|
||||||
void setCF_Y(int value);
|
|
||||||
void setCF_Z(int value);
|
|
||||||
|
|
||||||
void setY_Distance(int value);
|
|
||||||
|
|
||||||
void setFadeOutDist(int value);
|
|
||||||
|
|
||||||
void setLightStrenght(int value);
|
|
||||||
|
|
||||||
void setMaxAngle(int value);
|
|
||||||
|
|
||||||
void setPreset(const Preset & p);
|
|
||||||
|
|
||||||
void setPerformance(Performance performance);
|
|
||||||
|
|
||||||
void useVSync(bool b);
|
|
||||||
|
|
||||||
void setFlowRightToLeft(bool b);
|
|
||||||
|
|
||||||
virtual void updateImageData() = 0;
|
|
||||||
|
|
||||||
void reset();
|
|
||||||
void reload();
|
|
||||||
|
|
||||||
//interface with yacreaderlibrary, compatibility
|
|
||||||
void setShowMarks(bool value);
|
|
||||||
void setMarks(QVector<YACReaderComicReadStatus> marks);
|
|
||||||
void setMarkImage(QImage & image);
|
|
||||||
void markSlide(int index, YACReaderComicReadStatus status);
|
|
||||||
void unmarkSlide(int index);
|
|
||||||
void setSlideSize(QSize size);
|
|
||||||
void clear();
|
|
||||||
void setCenterIndex(unsigned int index);
|
|
||||||
void showSlide(int index);
|
|
||||||
int centerIndex();
|
|
||||||
void updateMarks();
|
|
||||||
//void setFlowType(PictureFlow::FlowType flowType);
|
|
||||||
void render();
|
|
||||||
|
|
||||||
//void paintEvent(QPaintEvent *event);
|
|
||||||
void mouseDoubleClickEvent(QMouseEvent* event);
|
|
||||||
void mousePressEvent(QMouseEvent *event);
|
|
||||||
void wheelEvent(QWheelEvent * event);
|
|
||||||
void keyPressEvent(QKeyEvent *event);
|
|
||||||
void resizeGL(int width, int height);
|
|
||||||
friend class ImageLoaderGL;
|
|
||||||
friend class ImageLoaderByteArrayGL;
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void centerIndexChanged(int);
|
|
||||||
void selected(unsigned int);
|
|
||||||
};
|
|
||||||
|
|
||||||
class YACReaderComicFlowGL : public YACReaderFlowGL
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
YACReaderComicFlowGL(QWidget *parent = 0,struct Preset p = defaultYACReaderFlowConfig);
|
|
||||||
void setImagePaths(QStringList paths);
|
|
||||||
void updateImageData();
|
|
||||||
void remove(int item);
|
|
||||||
void resortCovers(QList<int> newOrder);
|
|
||||||
friend class ImageLoaderGL;
|
|
||||||
private:
|
|
||||||
ImageLoaderGL * worker;
|
|
||||||
protected:
|
|
||||||
QList<QString> paths;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
class YACReaderPageFlowGL : public YACReaderFlowGL
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
YACReaderPageFlowGL(QWidget *parent = 0,struct Preset p = defaultYACReaderFlowConfig);
|
|
||||||
~YACReaderPageFlowGL();
|
|
||||||
void updateImageData();
|
|
||||||
void populate(int n);
|
|
||||||
QVector<bool> imagesReady;
|
|
||||||
QVector<QByteArray> rawImages;
|
|
||||||
QVector<bool> imagesSetted;
|
|
||||||
friend class ImageLoaderByteArrayGL;
|
|
||||||
private:
|
|
||||||
ImageLoaderByteArrayGL * worker;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ImageLoaderGL : public QThread
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ImageLoaderGL(YACReaderFlowGL * flow);
|
|
||||||
~ImageLoaderGL();
|
|
||||||
// returns FALSE if worker is still busy and can't take the task
|
|
||||||
bool busy() const;
|
|
||||||
void generate(int index, const QString& fileName);
|
|
||||||
void reset(){idx = -1;fileName="";}
|
|
||||||
int index() const { return idx; }
|
|
||||||
void lock();
|
|
||||||
void unlock();
|
|
||||||
QImage result();
|
|
||||||
YACReaderFlowGL * flow;
|
|
||||||
GLuint resultTexture;
|
|
||||||
QImage loadImage(const QString& fileName);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void run();
|
|
||||||
|
|
||||||
private:
|
|
||||||
QMutex mutex;
|
|
||||||
QWaitCondition condition;
|
|
||||||
|
|
||||||
|
|
||||||
bool restart;
|
|
||||||
bool working;
|
|
||||||
int idx;
|
|
||||||
QString fileName;
|
|
||||||
QSize size;
|
|
||||||
QImage img;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ImageLoaderByteArrayGL : public QThread
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ImageLoaderByteArrayGL(YACReaderFlowGL * flow);
|
|
||||||
~ImageLoaderByteArrayGL();
|
|
||||||
// returns FALSE if worker is still busy and can't take the task
|
|
||||||
bool busy() const;
|
|
||||||
void generate(int index, const QByteArray& raw);
|
|
||||||
void reset(){idx = -1; rawData.clear();}
|
|
||||||
int index() const { return idx; }
|
|
||||||
QImage result();
|
|
||||||
YACReaderFlowGL * flow;
|
|
||||||
GLuint resultTexture;
|
|
||||||
QImage loadImage(const QByteArray& rawData);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void run();
|
|
||||||
|
|
||||||
private:
|
|
||||||
QMutex mutex;
|
|
||||||
QWaitCondition condition;
|
|
||||||
|
|
||||||
|
|
||||||
bool restart;
|
|
||||||
bool working;
|
|
||||||
int idx;
|
|
||||||
QByteArray rawData;
|
|
||||||
QSize size;
|
|
||||||
QImage img;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
Reference in New Issue
Block a user