code format
This commit is contained in:
@@ -1,35 +1,36 @@
|
||||
/*
|
||||
QGL RendererMaterial
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
QGL RendererMaterial
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
|
||||
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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <QOpenGLExtraFunctions>
|
||||
#include "renderer_material.h"
|
||||
#include "renderer.h"
|
||||
#include "qglview.h"
|
||||
|
||||
#include "glmesh.h"
|
||||
#include "gltexture_manager.h"
|
||||
#include "qglview.h"
|
||||
#include "renderer.h"
|
||||
|
||||
#include <QOpenGLExtraFunctions>
|
||||
#include <qad_types.h>
|
||||
|
||||
using namespace QGLEngineShaders;
|
||||
|
||||
|
||||
RendererMaterial::RendererMaterial(Renderer * r_)
|
||||
: r(r_), fbo_mat_thumb(r->view, 6, true , GL_RGBA16F) {
|
||||
RendererMaterial::RendererMaterial(Renderer * r_): r(r_), fbo_mat_thumb(r->view, 6, true, GL_RGBA16F) {
|
||||
mat_sphere = Primitive::ellipsoid(16, 16);
|
||||
mat_camera = new Camera();
|
||||
mat_camera->setPos(QVector3D(2, 2, 2));
|
||||
@@ -62,19 +63,19 @@ void RendererMaterial::resize(int width, int height) {
|
||||
|
||||
|
||||
void RendererMaterial::renderMaterial(Material * m) {
|
||||
//qDebug() << "renderMaterial" << m;
|
||||
last_thumb_material = m;
|
||||
// qDebug() << "renderMaterial" << m;
|
||||
last_thumb_material = m;
|
||||
QOpenGLShaderProgram * prog = 0;
|
||||
QOpenGLExtraFunctions * f = r->view;
|
||||
QOpenGLExtraFunctions * f = r->view;
|
||||
fbo_mat_thumb.bind();
|
||||
glEnableDepth();
|
||||
glClearFramebuffer(QColor(0,0,0,0));
|
||||
glClearFramebuffer(QColor(0, 0, 0, 0));
|
||||
if (r->bindShader(Renderer::srGeometryPass, &prog)) {
|
||||
r->setUniformMaps(prog);
|
||||
r->setUniformCamera(prog, mat_camera, true, fbo_mat_thumb.size());
|
||||
//qDebug() << mat_camera->viewMatrix();
|
||||
// qDebug() << mat_camera->viewMatrix();
|
||||
r->textures_empty.bind(f, tarEmpty);
|
||||
r->textures_maps .bind(f, tarMaps );
|
||||
r->textures_maps.bind(f, tarMaps);
|
||||
Object o;
|
||||
o.material = m->_index;
|
||||
mat_sphere->loadObject(f, o);
|
||||
@@ -91,7 +92,7 @@ void RendererMaterial::renderMaterial(Material * m) {
|
||||
prog->setUniformValue("tex_d", 5);
|
||||
prog->setUniformValue("lights_start", 0);
|
||||
prog->setUniformValue("lights_count", 1);
|
||||
QMap<int, QList<Light*>> mat_l;
|
||||
QMap<int, QList<Light *>> mat_l;
|
||||
mat_l[Light::Omni] << mat_light;
|
||||
r->reloadLightsParameters(mat_l);
|
||||
r->reloadLightsPositions(mat_camera);
|
||||
@@ -110,8 +111,7 @@ void RendererMaterial::procQueue() {
|
||||
emit r->view->materialThumbnailCreated(last_thumb_material);
|
||||
last_thumb_material = 0;
|
||||
}
|
||||
if (!mat_thumb_queue.isEmpty())
|
||||
renderMaterial(mat_thumb_queue.dequeue());
|
||||
if (!mat_thumb_queue.isEmpty()) renderMaterial(mat_thumb_queue.dequeue());
|
||||
}
|
||||
|
||||
|
||||
@@ -123,12 +123,11 @@ QImage RendererMaterial::materialThumbnail(Material * m) {
|
||||
void RendererMaterial::recreateMaterialThumbnails(bool force_all) {
|
||||
if (force_all) {
|
||||
mat_thumb_queue.clear();
|
||||
//qDebug() << "recreateMaterialThumbnails" << view->scene_->materials;
|
||||
foreach (Material * m, r->view->scene()->materials)
|
||||
// qDebug() << "recreateMaterialThumbnails" << view->scene_->materials;
|
||||
foreach(Material * m, r->view->scene()->materials)
|
||||
mat_thumb_queue.enqueue(m);
|
||||
} else {
|
||||
foreach (Material * m, r->view->scene()->changed_materials)
|
||||
if (!mat_thumb_queue.contains(m))
|
||||
mat_thumb_queue.enqueue(m);
|
||||
foreach(Material * m, r->view->scene()->changed_materials)
|
||||
if (!mat_thumb_queue.contains(m)) mat_thumb_queue.enqueue(m);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user