mirror of
https://github.com/YACReader/yacreader
synced 2026-03-03 11:20:15 -05:00
AI generated migration for a more modern OpenGL (3.3 + ES 3.0) approach that supports tinting
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
|||||||
// OpenGL Coverflow API by J.Roth
|
// OpenGL Coverflow API by J.Roth - Modernized with Shaders
|
||||||
#ifndef __YACREADER_FLOW_GL_H
|
#ifndef __YACREADER_FLOW_GL_H
|
||||||
#define __YACREADER_FLOW_GL_H
|
#define __YACREADER_FLOW_GL_H
|
||||||
|
|
||||||
@ -13,9 +13,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <QOpenGLFunctions>
|
#include <QOpenGLFunctions>
|
||||||
|
#include <QOpenGLFunctions_3_3_Core>
|
||||||
|
#include <QOpenGLShaderProgram>
|
||||||
|
#include <QOpenGLBuffer>
|
||||||
|
#include <QOpenGLVertexArrayObject>
|
||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
|
|
||||||
#include "pictureflow.h" //TODO mover los tipos de flow de sitio
|
#include "pictureflow.h"
|
||||||
#include "scroll_management.h"
|
#include "scroll_management.h"
|
||||||
|
|
||||||
class ImageLoaderGL;
|
class ImageLoaderGL;
|
||||||
@ -39,7 +43,6 @@ struct YACReader3DVector {
|
|||||||
// the image/texture info struct
|
// the image/texture info struct
|
||||||
struct YACReader3DImage {
|
struct YACReader3DImage {
|
||||||
QOpenGLTexture *texture;
|
QOpenGLTexture *texture;
|
||||||
// char name[256];
|
|
||||||
|
|
||||||
float width;
|
float width;
|
||||||
float height;
|
float height;
|
||||||
@ -105,7 +108,7 @@ extern struct Preset presetYACReaderFlowOverlappedStripeConfig;
|
|||||||
extern struct Preset pressetYACReaderFlowUpConfig;
|
extern struct Preset pressetYACReaderFlowUpConfig;
|
||||||
extern struct Preset pressetYACReaderFlowDownConfig;
|
extern struct Preset pressetYACReaderFlowDownConfig;
|
||||||
|
|
||||||
class YACReaderFlowGL : public QOpenGLWidget, public ScrollManagement
|
class YACReaderFlowGL : public QOpenGLWidget, protected QOpenGLExtraFunctions, public ScrollManagement
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
protected:
|
protected:
|
||||||
@ -118,11 +121,13 @@ protected:
|
|||||||
/*functions*/
|
/*functions*/
|
||||||
void calcPos(YACReader3DImage &image, int pos);
|
void calcPos(YACReader3DImage &image, int pos);
|
||||||
void calcVector(YACReader3DVector &vector, int pos);
|
void calcVector(YACReader3DVector &vector, int pos);
|
||||||
// returns true if the animation is finished for Current
|
|
||||||
bool animate(YACReader3DVector ¤tVector, YACReader3DVector &toVector);
|
bool animate(YACReader3DVector ¤tVector, YACReader3DVector &toVector);
|
||||||
void drawCover(const YACReader3DImage &image);
|
void drawCover(const YACReader3DImage &image);
|
||||||
|
void drawReflection(const YACReader3DImage &image);
|
||||||
|
void prepareInstanceData(const YACReader3DImage &image, bool isReflection, QVector<GLfloat> &data);
|
||||||
|
void drawMark(const YACReader3DImage &image, const QMatrix4x4 &viewProjectionMatrix);
|
||||||
|
|
||||||
void udpatePerspective(int width, int height);
|
void updatePerspective(int width, int height);
|
||||||
|
|
||||||
int updateCount;
|
int updateCount;
|
||||||
int fontSize;
|
int fontSize;
|
||||||
@ -130,11 +135,19 @@ protected:
|
|||||||
QOpenGLTexture *defaultTexture = nullptr;
|
QOpenGLTexture *defaultTexture = nullptr;
|
||||||
QOpenGLTexture *markTexture = nullptr;
|
QOpenGLTexture *markTexture = nullptr;
|
||||||
QOpenGLTexture *readingTexture = nullptr;
|
QOpenGLTexture *readingTexture = nullptr;
|
||||||
|
|
||||||
|
// Shader program and buffers
|
||||||
|
QOpenGLShaderProgram *shaderProgram = nullptr;
|
||||||
|
QOpenGLBuffer *vbo = nullptr;
|
||||||
|
QOpenGLBuffer *instanceVBO = nullptr;
|
||||||
|
QOpenGLVertexArrayObject *vao = nullptr;
|
||||||
|
|
||||||
void initializeGL();
|
void initializeGL();
|
||||||
void paintGL();
|
void paintGL();
|
||||||
void timerEvent(QTimerEvent *);
|
void timerEvent(QTimerEvent *);
|
||||||
|
void setupShaders();
|
||||||
|
void setupGeometry();
|
||||||
|
|
||||||
// number of Covers
|
|
||||||
int numObjects;
|
int numObjects;
|
||||||
int lazyPopulateObjects;
|
int lazyPopulateObjects;
|
||||||
bool showMarks;
|
bool showMarks;
|
||||||
@ -151,116 +164,81 @@ protected:
|
|||||||
/*** Animation Settings ***/
|
/*** Animation Settings ***/
|
||||||
Preset config;
|
Preset config;
|
||||||
|
|
||||||
// sets/returns the curent selected cover
|
|
||||||
int currentSelected;
|
int currentSelected;
|
||||||
|
|
||||||
// defines the position of the centered cover
|
|
||||||
YACReader3DVector centerPos;
|
YACReader3DVector centerPos;
|
||||||
|
|
||||||
/*** Style ***/
|
/*** Style ***/
|
||||||
// sets the amount of shading of the covers in the back (0-1)
|
|
||||||
float shadingTop;
|
float shadingTop;
|
||||||
float shadingBottom;
|
float shadingBottom;
|
||||||
|
|
||||||
// sets the reflection strenght (0-1)
|
|
||||||
float reflectionUp;
|
float reflectionUp;
|
||||||
float reflectionBottom;
|
float reflectionBottom;
|
||||||
|
|
||||||
|
/*** Theme Colors ***/
|
||||||
|
QColor backgroundColor;
|
||||||
|
QColor textColor;
|
||||||
|
QColor shadingColor;
|
||||||
|
|
||||||
/*** System info ***/
|
/*** System info ***/
|
||||||
float viewRotate;
|
float viewRotate;
|
||||||
|
|
||||||
// sets the updateInterval in ms
|
|
||||||
static int updateInterval;
|
static int updateInterval;
|
||||||
|
|
||||||
// sets flow direction right-to-left (manga mode)
|
|
||||||
bool flowRightToLeft;
|
bool flowRightToLeft;
|
||||||
|
|
||||||
void startAnimationTimer();
|
void startAnimationTimer();
|
||||||
void stopAnimationTimer();
|
void stopAnimationTimer();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*Constructor*/
|
|
||||||
YACReaderFlowGL(QWidget *parent = 0, struct Preset p = pressetYACReaderFlowDownConfig);
|
YACReaderFlowGL(QWidget *parent = 0, struct Preset p = pressetYACReaderFlowDownConfig);
|
||||||
virtual ~YACReaderFlowGL();
|
virtual ~YACReaderFlowGL();
|
||||||
|
|
||||||
// size;
|
|
||||||
QSize minimumSizeHint() const;
|
QSize minimumSizeHint() const;
|
||||||
// QSize sizeHint() const;
|
|
||||||
|
|
||||||
/*functions*/
|
|
||||||
|
|
||||||
// if called it moves the coverflow to the left
|
|
||||||
void showPrevious();
|
void showPrevious();
|
||||||
// if called it moves the coverflow to the right
|
|
||||||
void showNext();
|
void showNext();
|
||||||
// go to
|
|
||||||
void setCurrentIndex(int pos);
|
void setCurrentIndex(int pos);
|
||||||
// must be called whenever the coverflow animation is stopped
|
|
||||||
void cleanupAnimation();
|
void cleanupAnimation();
|
||||||
// Draws the coverflow
|
|
||||||
void draw();
|
void draw();
|
||||||
// updates the coverflow
|
|
||||||
void updatePositions();
|
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(char *name, QOpenGLTexture *texture, float x, float y, int item = -1);
|
void insert(char *name, QOpenGLTexture *texture, float x, float y, int item = -1);
|
||||||
// removes a item
|
|
||||||
virtual void remove(int item);
|
virtual void remove(int item);
|
||||||
// inserts a default texture into `item` and set is as pending to load
|
|
||||||
void add(int item);
|
void add(int item);
|
||||||
// replaces the texture of the item 'item' with Tex
|
|
||||||
void replace(char *name, QOpenGLTexture *texture, float x, float y, int item);
|
void replace(char *name, QOpenGLTexture *texture, float x, float y, int item);
|
||||||
// create n covers with the default nu
|
|
||||||
void populate(int n);
|
void populate(int n);
|
||||||
/*Info*/
|
|
||||||
// retuns the YACReader3DImage Struct of the current selected item
|
|
||||||
// to read title or textures
|
|
||||||
YACReader3DImage getCurrentSelected();
|
YACReader3DImage getCurrentSelected();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setCF_RX(int value);
|
void setCF_RX(int value);
|
||||||
// the Y Rotation of the Coverflow
|
|
||||||
void setCF_RY(int value);
|
void setCF_RY(int value);
|
||||||
// the Z Rotation of the Coverflow
|
|
||||||
void setCF_RZ(int value);
|
void setCF_RZ(int value);
|
||||||
|
|
||||||
// perspective
|
|
||||||
void setZoom(int zoom);
|
void setZoom(int zoom);
|
||||||
|
|
||||||
void setRotation(int angle);
|
void setRotation(int angle);
|
||||||
// sets the distance between the covers
|
|
||||||
void setX_Distance(int distance);
|
void setX_Distance(int distance);
|
||||||
// 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
|
|
||||||
void setZ_Distance(int distance);
|
void setZ_Distance(int distance);
|
||||||
|
|
||||||
void setCF_Y(int value);
|
void setCF_Y(int value);
|
||||||
void setCF_Z(int value);
|
void setCF_Z(int value);
|
||||||
|
|
||||||
void setY_Distance(int value);
|
void setY_Distance(int value);
|
||||||
|
|
||||||
void setFadeOutDist(int value);
|
void setFadeOutDist(int value);
|
||||||
|
|
||||||
void setLightStrenght(int value);
|
void setLightStrenght(int value);
|
||||||
|
|
||||||
void setMaxAngle(int value);
|
void setMaxAngle(int value);
|
||||||
|
|
||||||
void setPreset(const Preset &p);
|
void setPreset(const Preset &p);
|
||||||
|
|
||||||
void setPerformance(Performance performance);
|
void setPerformance(Performance performance);
|
||||||
|
|
||||||
void useVSync(bool b);
|
void useVSync(bool b);
|
||||||
|
|
||||||
void setFlowRightToLeft(bool b);
|
void setFlowRightToLeft(bool b);
|
||||||
|
|
||||||
|
// Theme color setters
|
||||||
|
void setBackgroundColor(const QColor &color);
|
||||||
|
void setTextColor(const QColor &color);
|
||||||
|
void setShadingColor(const QColor &color);
|
||||||
|
|
||||||
virtual void updateImageData() = 0;
|
virtual void updateImageData() = 0;
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
void reload();
|
void reload();
|
||||||
|
|
||||||
// interface with yacreaderlibrary, compatibility
|
|
||||||
void setShowMarks(bool value);
|
void setShowMarks(bool value);
|
||||||
void setMarks(QVector<YACReader::YACReaderComicReadStatus> marks);
|
void setMarks(QVector<YACReader::YACReaderComicReadStatus> marks);
|
||||||
void setMarkImage(QImage &image);
|
void setMarkImage(QImage &image);
|
||||||
@ -272,16 +250,15 @@ public slots:
|
|||||||
void showSlide(int index);
|
void showSlide(int index);
|
||||||
int centerIndex();
|
int centerIndex();
|
||||||
void updateMarks();
|
void updateMarks();
|
||||||
// void setFlowType(PictureFlow::FlowType flowType);
|
|
||||||
void render();
|
void render();
|
||||||
|
|
||||||
// void paintEvent(QPaintEvent *event);
|
|
||||||
QVector3D getPlaneIntersection(int x, int y, YACReader3DImage plane);
|
QVector3D getPlaneIntersection(int x, int y, YACReader3DImage plane);
|
||||||
void mouseDoubleClickEvent(QMouseEvent *event);
|
void mouseDoubleClickEvent(QMouseEvent *event);
|
||||||
void mousePressEvent(QMouseEvent *event);
|
void mousePressEvent(QMouseEvent *event);
|
||||||
void wheelEvent(QWheelEvent *event);
|
void wheelEvent(QWheelEvent *event);
|
||||||
void keyPressEvent(QKeyEvent *event);
|
void keyPressEvent(QKeyEvent *event);
|
||||||
void resizeGL(int width, int height);
|
void resizeGL(int width, int height);
|
||||||
|
|
||||||
friend class ImageLoaderGL;
|
friend class ImageLoaderGL;
|
||||||
friend class ImageLoaderByteArrayGL;
|
friend class ImageLoaderByteArrayGL;
|
||||||
|
|
||||||
@ -329,7 +306,6 @@ class ImageLoaderGL : public QThread
|
|||||||
public:
|
public:
|
||||||
ImageLoaderGL(YACReaderFlowGL *flow);
|
ImageLoaderGL(YACReaderFlowGL *flow);
|
||||||
~ImageLoaderGL();
|
~ImageLoaderGL();
|
||||||
// returns FALSE if worker is still busy and can't take the task
|
|
||||||
bool busy() const;
|
bool busy() const;
|
||||||
void generate(int index, const QString &fileName);
|
void generate(int index, const QString &fileName);
|
||||||
void reset()
|
void reset()
|
||||||
@ -365,7 +341,6 @@ class ImageLoaderByteArrayGL : public QThread
|
|||||||
public:
|
public:
|
||||||
ImageLoaderByteArrayGL(YACReaderFlowGL *flow);
|
ImageLoaderByteArrayGL(YACReaderFlowGL *flow);
|
||||||
~ImageLoaderByteArrayGL();
|
~ImageLoaderByteArrayGL();
|
||||||
// returns FALSE if worker is still busy and can't take the task
|
|
||||||
bool busy() const;
|
bool busy() const;
|
||||||
void generate(int index, const QByteArray &raw);
|
void generate(int index, const QByteArray &raw);
|
||||||
void reset()
|
void reset()
|
||||||
|
|||||||
@ -42,22 +42,28 @@ OpenGLChecker::OpenGLChecker()
|
|||||||
|
|
||||||
description = QString("%1.%2 %3").arg(majorVersion).arg(minorVersion).arg(type);
|
description = QString("%1.%2 %3").arg(majorVersion).arg(minorVersion).arg(type);
|
||||||
|
|
||||||
if (format.renderableType() != QSurfaceFormat::OpenGL) // Desktop OpenGL
|
// Check for Desktop OpenGL OR OpenGL ES 3.0+
|
||||||
compatibleOpenGLVersion = false;
|
bool isDesktopGL = (format.renderableType() == QSurfaceFormat::OpenGL);
|
||||||
|
bool isOpenGLES = (format.renderableType() == QSurfaceFormat::OpenGLES);
|
||||||
|
|
||||||
#ifdef Q_OS_WIN // TODO check Qt version, and set this values depending on the use of QOpenGLWidget or QGLWidget
|
if (isDesktopGL) {
|
||||||
static const int majorTargetVersion = 1;
|
// Desktop OpenGL requirements
|
||||||
static const int minorTargetVersion = 4;
|
#ifdef Q_OS_WIN
|
||||||
|
if (majorVersion < 1 || (majorVersion == 1 && minorVersion < 4))
|
||||||
|
compatibleOpenGLVersion = false;
|
||||||
#else
|
#else
|
||||||
static const int majorTargetVersion = 2;
|
if (majorVersion < 2)
|
||||||
static const int minorTargetVersion = 0;
|
compatibleOpenGLVersion = false;
|
||||||
#endif
|
#endif
|
||||||
|
} else if (isOpenGLES) {
|
||||||
if (majorVersion < majorTargetVersion)
|
// OpenGL ES requirements: 3.0 or higher
|
||||||
|
if (majorVersion < 3)
|
||||||
compatibleOpenGLVersion = false;
|
compatibleOpenGLVersion = false;
|
||||||
if (majorVersion == majorTargetVersion && minorVersion < minorTargetVersion)
|
} else {
|
||||||
|
// Unknown or unsupported renderable type
|
||||||
compatibleOpenGLVersion = false;
|
compatibleOpenGLVersion = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString OpenGLChecker::textVersionDescription()
|
QString OpenGLChecker::textVersionDescription()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user