2020-04-07 23:15:20 +00:00
|
|
|
#ifndef DUST3D_MODEL_OFFSCREEN_RENDER_H
|
|
|
|
#define DUST3D_MODEL_OFFSCREEN_RENDER_H
|
2020-04-02 10:39:57 +00:00
|
|
|
#include <QOffscreenSurface>
|
|
|
|
#include <QScreen>
|
|
|
|
#include <QOpenGLFunctions>
|
|
|
|
#include <QOpenGLContext>
|
|
|
|
#include <QImage>
|
|
|
|
#include <QThread>
|
2020-04-08 12:46:46 +00:00
|
|
|
#include <QOpenGLFramebufferObject>
|
2020-04-02 10:39:57 +00:00
|
|
|
#include "modelshaderprogram.h"
|
|
|
|
#include "modelmeshbinder.h"
|
2020-04-07 23:15:20 +00:00
|
|
|
#include "model.h"
|
2020-04-02 10:39:57 +00:00
|
|
|
|
2020-04-07 23:15:20 +00:00
|
|
|
class ModelOffscreenRender : QOffscreenSurface
|
2020-04-02 10:39:57 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-04-07 23:15:20 +00:00
|
|
|
ModelOffscreenRender(const QSurfaceFormat &format, QScreen *targetScreen = Q_NULLPTR);
|
|
|
|
~ModelOffscreenRender();
|
2020-04-02 10:39:57 +00:00
|
|
|
void setXRotation(int angle);
|
|
|
|
void setYRotation(int angle);
|
|
|
|
void setZRotation(int angle);
|
2020-04-13 13:25:04 +00:00
|
|
|
void setEyePosition(const QVector3D &eyePosition);
|
2020-04-02 10:39:57 +00:00
|
|
|
void setRenderPurpose(int purpose);
|
|
|
|
void setRenderThread(QThread *thread);
|
2020-04-07 23:15:20 +00:00
|
|
|
void updateMesh(Model *mesh);
|
2020-04-02 10:39:57 +00:00
|
|
|
void updateToonNormalAndDepthMaps(QImage *normalMap, QImage *depthMap);
|
|
|
|
void setToonShading(bool toonShading);
|
|
|
|
QImage toImage(const QSize &size);
|
|
|
|
private:
|
|
|
|
int m_xRot = 0;
|
|
|
|
int m_yRot = 0;
|
|
|
|
int m_zRot = 0;
|
2020-04-13 13:25:04 +00:00
|
|
|
QVector3D m_eyePosition;
|
2020-04-02 10:39:57 +00:00
|
|
|
int m_renderPurpose = 0;
|
|
|
|
QOpenGLContext *m_context = nullptr;
|
2020-04-08 12:46:46 +00:00
|
|
|
QOpenGLFramebufferObject *m_renderFbo = nullptr;
|
2020-04-07 23:15:20 +00:00
|
|
|
Model *m_mesh = nullptr;
|
2020-04-02 10:39:57 +00:00
|
|
|
QImage *m_normalMap = nullptr;
|
|
|
|
QImage *m_depthMap = nullptr;
|
|
|
|
bool m_toonShading = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|