code format
This commit is contained in:
96
qglview.cpp
96
qglview.cpp
@@ -1,51 +1,53 @@
|
||||
/*
|
||||
QGLView
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
QGLView
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include "qglview.h"
|
||||
|
||||
#include "glmesh.h"
|
||||
#include "gltexture_manager.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QKeyEvent>
|
||||
#include <QOpenGLTexture>
|
||||
#include <chunkstream.h>
|
||||
#include <qad_types.h>
|
||||
#include <QApplication>
|
||||
#include <QOpenGLTexture>
|
||||
#include <QKeyEvent>
|
||||
|
||||
using namespace QGLEngineShaders;
|
||||
|
||||
|
||||
QGLView::QGLView(): OpenGLWindow(), renderer_(this), mouse(this) {
|
||||
setIcon(QIcon(":/icons/qglview.png"));
|
||||
is_init = false;
|
||||
timer = 0;
|
||||
hoverHaloColor_ = QColor(195, 140, 255);
|
||||
is_init = false;
|
||||
timer = 0;
|
||||
hoverHaloColor_ = QColor(195, 140, 255);
|
||||
selectionHaloColor_ = QColor(175, 255, 140);
|
||||
lineWidth_ = 1.;
|
||||
max_anisotropic = 1;
|
||||
lineWidth_ = 1.;
|
||||
max_anisotropic = 1;
|
||||
max_texture_chanels = 8;
|
||||
lightEnabled_ = true;
|
||||
shaders_supported = false;
|
||||
fps_cnt = 0;
|
||||
fps_tm = fps_ = 0.;
|
||||
fogColor_ = Qt::darkGray;
|
||||
fogDensity_ = 0.;
|
||||
fogDecay_ = 10.;
|
||||
lightEnabled_ = true;
|
||||
shaders_supported = false;
|
||||
fps_cnt = 0;
|
||||
fps_tm = fps_ = 0.;
|
||||
fogColor_ = Qt::darkGray;
|
||||
fogDensity_ = 0.;
|
||||
fogDecay_ = 10.;
|
||||
hoverHaloFill_ = selectionHaloFill_ = 0.15f;
|
||||
//lmode = Simple;
|
||||
// lmode = Simple;
|
||||
setFeature(qglFXAA, false);
|
||||
setFeature(qglAnisotropicLevel, 8);
|
||||
setFeature(qglEyeAccomodationEnabled, false);
|
||||
@@ -72,16 +74,16 @@ QGLView::QGLView(): OpenGLWindow(), renderer_(this), mouse(this) {
|
||||
setFeature(qglDepthOfFieldDiaphragm, 8.);
|
||||
hoverHalo_ = selectionHalo_ = true;
|
||||
fogEnabled_ = shaders_bind = false;
|
||||
rmode = ObjectBase::Fill;
|
||||
scene_ = new Scene();
|
||||
rmode = ObjectBase::Fill;
|
||||
scene_ = new Scene();
|
||||
connect(scene_, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
|
||||
connect(scene_, SIGNAL(__destroyed()), this, SLOT(__destroyed()));
|
||||
connect(scene_, SIGNAL(__objectDeleted(ObjectBase*)), this, SLOT(__objectDeleted(ObjectBase*)));
|
||||
connect(scene_, SIGNAL(__objectDeleted(ObjectBase *)), this, SLOT(__objectDeleted(ObjectBase *)));
|
||||
default_camera = new Camera();
|
||||
default_camera->setPos(QVector3D(2, 2, 2));
|
||||
default_camera->setAim(QVector3D());
|
||||
camera_ = default_camera;
|
||||
// qDebug() << camera_->aim();
|
||||
// qDebug() << camera_->aim();
|
||||
default_camera->setName("Camera");
|
||||
emit cameraPosChanged(default_camera->pos());
|
||||
|
||||
@@ -112,27 +114,25 @@ void QGLView::start(float freq) {
|
||||
}
|
||||
|
||||
|
||||
QList<Light * > QGLView::selectedLights() const {
|
||||
QList<Light * > ret;
|
||||
QList<Light *> QGLView::selectedLights() const {
|
||||
QList<Light *> ret;
|
||||
ObjectBaseList sol = scene_->selectedObjects();
|
||||
foreach (ObjectBase * o, sol)
|
||||
if (o->type() == ObjectBase::glLight)
|
||||
ret << (Light*)o;
|
||||
foreach(ObjectBase * o, sol)
|
||||
if (o->type() == ObjectBase::glLight) ret << (Light *)o;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
QList<Camera * > QGLView::selectedCameras() const {
|
||||
QList<Camera * > ret;
|
||||
QList<Camera *> QGLView::selectedCameras() const {
|
||||
QList<Camera *> ret;
|
||||
ObjectBaseList sol = scene_->selectedObjects();
|
||||
for (ObjectBase * o : sol) {
|
||||
if (o->type() == ObjectBase::glCamera) ret << (Camera*)o;
|
||||
for (ObjectBase * o: sol) {
|
||||
if (o->type() == ObjectBase::glCamera) ret << (Camera *)o;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void QGLView::resizeEvent(QResizeEvent * e) {
|
||||
renderLater();
|
||||
mouse.resize();
|
||||
@@ -142,7 +142,7 @@ void QGLView::resizeEvent(QResizeEvent * e) {
|
||||
void QGLView::timerEvent(QTimerEvent *) {
|
||||
renderNow();
|
||||
Qt::KeyboardModifiers km = QApplication::keyboardModifiers();
|
||||
foreach (int i, keys_)
|
||||
foreach(int i, keys_)
|
||||
emit keyEvent((Qt::Key)i, km);
|
||||
}
|
||||
|
||||
@@ -157,8 +157,8 @@ void QGLView::render() {
|
||||
fps_cnt++;
|
||||
if (fps_tm < 1000.) return;
|
||||
time.restart();
|
||||
fps_ = fps_cnt / fps_tm * 1000.;
|
||||
fps_tm = 0.;
|
||||
fps_ = fps_cnt / fps_tm * 1000.;
|
||||
fps_tm = 0.;
|
||||
fps_cnt = 0;
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ void QGLView::initialize() {
|
||||
renderer_.reloadShaders();
|
||||
renderer_.init(width(), height());
|
||||
scene_->reinitAll();
|
||||
is_init = true;
|
||||
is_init = true;
|
||||
prev_size = QSize();
|
||||
emit glInitializeDone();
|
||||
}
|
||||
@@ -207,9 +207,9 @@ void QGLView::resizeGL(int width, int height) {
|
||||
if (width <= 0 || height <= 0) return;
|
||||
if (prev_size == QSize(width, height)) return;
|
||||
prev_size = QSize(width, height);
|
||||
aspect = float(width) / float(height);
|
||||
aspect = float(width) / float(height);
|
||||
renderer_.resize(width, height);
|
||||
//qDebug() << "resize" << width << height;
|
||||
// qDebug() << "resize" << width << height;
|
||||
iaspect = (aspect == 0.f) ? 0. : 1 / aspect;
|
||||
glViewport(0, 0, width, height);
|
||||
emit glResize(width, height);
|
||||
|
||||
Reference in New Issue
Block a user