git-svn-id: svn://db.shs.com.ru/libs@626 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
123
qglengine/renderer.h
Normal file
123
qglengine/renderer.h
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
QGLView
|
||||
Copyright (C) 2019 Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef RENDERER_H
|
||||
#define RENDERER_H
|
||||
|
||||
#include "renderer_base.h"
|
||||
#include "renderer_material.h"
|
||||
#include "renderer_service.h"
|
||||
#include <QQueue>
|
||||
|
||||
|
||||
class Renderer: public RendererBase {
|
||||
friend class QGLView;
|
||||
friend class RendererMaterial;
|
||||
friend class RendererService;
|
||||
enum RenderPass {
|
||||
rpSolid,
|
||||
rpTransparent,
|
||||
rpSelection,
|
||||
rpShadow,
|
||||
rpNoProc,
|
||||
};
|
||||
enum ShaderRole {
|
||||
// Selection
|
||||
srSelectionFill,
|
||||
srSelectionHalo,
|
||||
srSelectionApply,
|
||||
srSelectionFrame,
|
||||
|
||||
// Service
|
||||
srService,
|
||||
|
||||
// Deferred shading
|
||||
srGeometryPass,
|
||||
srLightingPass,
|
||||
srFinalPass,
|
||||
};
|
||||
enum DeferredBufferRole {
|
||||
dbrDiffuseRough,
|
||||
dbrNormalReflect,
|
||||
dbrSpecularHeight,
|
||||
dbrEmissionBitangX,
|
||||
dbrSpeedBitangXY,
|
||||
};
|
||||
enum SelectionBufferRole {
|
||||
sbrSrcHover,
|
||||
sbrSrcSelect,
|
||||
sbrHovered,
|
||||
sbrSelected
|
||||
};
|
||||
|
||||
public:
|
||||
Renderer(QGLView * view_);
|
||||
virtual ~Renderer();
|
||||
|
||||
void init(int width, int height);
|
||||
void resize(int width, int height);
|
||||
void reloadShaders();
|
||||
void renderScene();
|
||||
void setCameraLightOn(bool on);
|
||||
bool isCameraLightOn() const {return is_camera_light;}
|
||||
|
||||
QImage materialThumbnail(Material * m) {return rend_mat.materialThumbnail(m);}
|
||||
void recreateMaterialThumbnails(bool force_all = false) {rend_mat.recreateMaterialThumbnails(force_all);}
|
||||
|
||||
protected:
|
||||
void generateObjectsID(Scene & scene);
|
||||
void fillSelectionsBuffer(const QList<ObjectBase *> & ol);
|
||||
void fillObjectsBuffer(const QList<ObjectBase*> & ol, RenderPass pass);
|
||||
void reloadObjects();
|
||||
void renderObjects(Scene & scene, RenderPass pass);
|
||||
void renderSelection(Scene & scene);
|
||||
void renderSelectionFrame();
|
||||
|
||||
bool bindShader(ShaderRole role, QOpenGLShaderProgram ** ret = 0);
|
||||
void initShaders();
|
||||
void releaseShader();
|
||||
|
||||
private:
|
||||
float exposure_, line_thick_;
|
||||
bool edit_mode, proc_sel_pbo, need_init_shaders, is_camera_light;
|
||||
Framebuffer fbo_selection, fbo_ds, fbo_out, fbo_hsmall;
|
||||
/*QOpenGLShaderProgram * shader_fxaa, * shader_ds_0, * shader_ds_1, * shader_hdr, * shader_small;
|
||||
QOpenGLShaderProgram * shader_bloom_0, * shader_bloom_1, * shader_motion_blur, * shader_fbo_add;
|
||||
QOpenGLShaderProgram * shader_shadow, * shader_ssr, * shader_ssr_blur, * shader_ssr_merge;
|
||||
QOpenGLShaderProgram * shader_ssao_blur, * shader_ssao_merge, * shader_dof;*/
|
||||
QMap<ShaderRole, QString> shader_files;
|
||||
QMap<ShaderRole, QOpenGLShaderProgram*> shaders;
|
||||
|
||||
RendererMaterial rend_mat;
|
||||
RendererService rend_service;
|
||||
|
||||
Mesh * quad, * sel_frame;
|
||||
Light * cam_light;
|
||||
|
||||
QHash<uint, ObjectBase * > ids;
|
||||
uint id_hover;
|
||||
QPoint mouse_pos;
|
||||
QRect mouse_rect;
|
||||
QMatrix4x4 prev_view, prev_proj;
|
||||
QMatrix3x3 nm;
|
||||
QVector4D corner_dirs[4];
|
||||
QVector<QVector3D> hcontent;
|
||||
|
||||
};
|
||||
|
||||
#endif // RENDERER_H
|
||||
Reference in New Issue
Block a user