source-tree refactoring
@@ -7,6 +7,9 @@ if (POLICY CMP0054)
|
|||||||
cmake_policy(SET CMP0054 NEW)
|
cmake_policy(SET CMP0054 NEW)
|
||||||
endif()
|
endif()
|
||||||
project(QGLEngine)
|
project(QGLEngine)
|
||||||
|
if (NOT DEFINED SHSTKPROJECT)
|
||||||
|
include(SHSTKQtMacros)
|
||||||
|
endif()
|
||||||
find_package(QAD REQUIRED)
|
find_package(QAD REQUIRED)
|
||||||
shstk_qt_founded(QtVersions)
|
shstk_qt_founded(QtVersions)
|
||||||
set(_qgl_ok 0)
|
set(_qgl_ok 0)
|
||||||
@@ -19,9 +22,8 @@ endif()
|
|||||||
if (NOT _qgl_ok)
|
if (NOT _qgl_ok)
|
||||||
message(WARNING "Building ${PROJECT_NAME} available only on Qt5/6!")
|
message(WARNING "Building ${PROJECT_NAME} available only on Qt5/6!")
|
||||||
else()
|
else()
|
||||||
qad_find_qt(Core Gui OpenGL OpenGLWidgets Xml)
|
|
||||||
find_package(OpenGL REQUIRED)
|
|
||||||
include(SHSTKQtMacros)
|
include(SHSTKQtMacros)
|
||||||
|
include_directories("c:/sdk/MinGW/x32/lib/gcc/i686-w64-mingw32/8.1.0/include")
|
||||||
|
|
||||||
set(QGLEngine_MAJOR 1)
|
set(QGLEngine_MAJOR 1)
|
||||||
set(QGLEngine_MINOR 0)
|
set(QGLEngine_MINOR 0)
|
||||||
@@ -35,44 +37,10 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
shstk_begin_project(QGLEngine)
|
shstk_begin_project(QGLEngine)
|
||||||
|
set(_qglengine_root_build "${CMAKE_CURRENT_BINARY_DIR}")
|
||||||
|
|
||||||
qad_sources(SRC)
|
add_subdirectory(src)
|
||||||
qad_sources(FSRC DIR "formats")
|
|
||||||
list(APPEND SRC ${FSRC})
|
|
||||||
qad_sources(FSRC DIR "core")
|
|
||||||
list(APPEND SRC ${FSRC})
|
|
||||||
qad_wrap(${SRC} HDRS out_HDR CPPS out_CPP QMS out_QM)
|
|
||||||
file(GLOB PHS "*_p.h" "formats/*_p.h" "core/*_p.h")
|
|
||||||
list(REMOVE_ITEM out_HDR "${PHS}")
|
|
||||||
import_version(qglengine_core QGLEngine)
|
|
||||||
set_deploy_property(qglengine_core ${QGLEngine_LIB_TYPE}
|
|
||||||
LABEL "QGLEngine core library"
|
|
||||||
FULLNAME "${QGLEngine_DOMAIN}.qglengine_core"
|
|
||||||
COMPANY "${QGLEngine_COMPANY}"
|
|
||||||
INFO "QGLEngine core library")
|
|
||||||
make_rc(qglengine_core _RC)
|
|
||||||
qad_add_library(qglengine_core ${QGLEngine_LIB_TYPE} out_CPP ${_RC})
|
|
||||||
qad_generate_export_header(qglengine_core)
|
|
||||||
list(APPEND out_HDR "${CMAKE_CURRENT_BINARY_DIR}/qglengine_core_export.h")
|
|
||||||
list(APPEND out_HDR "${QGLEngine_VERSION_FILE}")
|
|
||||||
qad_target_include_directories(qglengine_core PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/core")
|
|
||||||
qad_target_link_libraries(qglengine_core QAD::Widgets assimp ${OPENGL_LIBRARIES})
|
|
||||||
message(STATUS "Building QGLEngine version ${QGLEngine_VERSION} (${QGLEngine_LIB_TYPE_MSG}) for ${QtVersions}")
|
|
||||||
list(APPEND QT_MULTILIB_LIST qglengine_core)
|
|
||||||
add_subdirectory(widgets)
|
|
||||||
shstk_copy_to_parent()
|
shstk_copy_to_parent()
|
||||||
shstk_qad_install("qglengine" FALSE "qglengine_core" "${out_HDR}" "out_QM")
|
|
||||||
if (NOT DEFINED ANDROID_PLATFORM)
|
|
||||||
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/plugin")
|
|
||||||
#add_subdirectory(plugin)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
qad_sources(test_SRC DIR "qglview_test")
|
|
||||||
qad_wrap(${test_SRC} CPPS test_CPP)
|
|
||||||
qad_add_executable(qglengine_test test_CPP)
|
|
||||||
qad_target_link_libraries(qglengine_test qglengine_core qglengine_widgets)
|
|
||||||
qad_target_include_directories(qglengine_test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/core" "${CMAKE_CURRENT_SOURCE_DIR}/widgets")
|
|
||||||
|
|
||||||
file(GLOB CMAKES "cmake/*.cmake" "cmake/*.in")
|
file(GLOB CMAKES "cmake/*.cmake" "cmake/*.in")
|
||||||
install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules)
|
install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules)
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
QGL Primitives
|
|
||||||
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 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GLPRIMITIVE_CUBE_H
|
|
||||||
#define GLPRIMITIVE_CUBE_H
|
|
||||||
|
|
||||||
#include "gltypes.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace Primitive {
|
|
||||||
|
|
||||||
|
|
||||||
Mesh * plane(float width = 1., float length = 1.);
|
|
||||||
|
|
||||||
Mesh * cube(float width = 1., float length = 1., float height = 1.);
|
|
||||||
|
|
||||||
Mesh * ellipsoid(int segments_wl, int segments_h, float radius = 1., float end_angle = 360.);
|
|
||||||
|
|
||||||
Mesh * disc(int segments, float radius = 1., float end_angle = 360.);
|
|
||||||
|
|
||||||
Mesh * cone(int segments, float radius = 1., float height = 1.);
|
|
||||||
|
|
||||||
Mesh * cylinder(int segments, float radius = 1., float height = 1., float end_angle = 360.);
|
|
||||||
|
|
||||||
Mesh * arrow(int segments = 16, float thick = 0.04, float angle = 30.); // length = 1
|
|
||||||
|
|
||||||
Mesh * torus(int segments_main = 30, int segments_second = 16, float radius_main = 2.5, float radius_second = 0.5, float end_angle = 360.);
|
|
||||||
|
|
||||||
|
|
||||||
Mesh * lineFrame(QVector3D p0, QVector3D p1);
|
|
||||||
|
|
||||||
Mesh * cubeFrame(float width = 1., float length = 1., float height = 1.);
|
|
||||||
|
|
||||||
Mesh * ellipsoidFrame(int segments_wl, int segments_h, float radius = 1.);
|
|
||||||
|
|
||||||
Mesh * coneFrame(int segments, float radius = 1., float height = 1.);
|
|
||||||
|
|
||||||
} // namespace Primitive
|
|
||||||
|
|
||||||
#endif // GLPRIMITIVE_CUBE_H
|
|
||||||
46
qglview.qrc
@@ -1,46 +0,0 @@
|
|||||||
<RCC>
|
|
||||||
<qresource prefix="/">
|
|
||||||
<file>coeffs_brdf.png</file>
|
|
||||||
<file>icons/add-type-camera.png</file>
|
|
||||||
<file>icons/add-type-geo.png</file>
|
|
||||||
<file>icons/add-type-light.png</file>
|
|
||||||
<file>icons/add-type-empty.png</file>
|
|
||||||
<file>icons/collapse.png</file>
|
|
||||||
<file>icons/expand.png</file>
|
|
||||||
<file>icons/edit-rename.png</file>
|
|
||||||
<file>icons/alpha.png</file>
|
|
||||||
<file>icons/application-exit.png</file>
|
|
||||||
<file>icons/configure.png</file>
|
|
||||||
<file>icons/dialog-close.png</file>
|
|
||||||
<file>icons/document-edit.png</file>
|
|
||||||
<file>icons/document-import.png</file>
|
|
||||||
<file>icons/document-new.png</file>
|
|
||||||
<file>icons/document-open.png</file>
|
|
||||||
<file>icons/document-save.png</file>
|
|
||||||
<file>icons/document-save-all.png</file>
|
|
||||||
<file>icons/edit-clear.png</file>
|
|
||||||
<file>icons/edit-clear-locationbar-rtl.png</file>
|
|
||||||
<file>icons/edit-copy.png</file>
|
|
||||||
<file>icons/edit-delete.png</file>
|
|
||||||
<file>icons/edit-find.png</file>
|
|
||||||
<file>icons/edit-paste.png</file>
|
|
||||||
<file>icons/go-jump.png</file>
|
|
||||||
<file>icons/go-top.png</file>
|
|
||||||
<file>icons/layer-visible-on.png</file>
|
|
||||||
<file>icons/layer-visible-off.png</file>
|
|
||||||
<file>icons/light-+.png</file>
|
|
||||||
<file>icons/list-add.png</file>
|
|
||||||
<file>icons/object-flip-horizontal.png</file>
|
|
||||||
<file>icons/object-flip-vertical.png</file>
|
|
||||||
<file>icons/picker.png</file>
|
|
||||||
<file>icons/qglview.png</file>
|
|
||||||
<file>icons/transform-move.png</file>
|
|
||||||
<file>icons/transform-rotate.png</file>
|
|
||||||
<file>icons/transform-scale.png</file>
|
|
||||||
<file>icons/type-camera.png</file>
|
|
||||||
<file>icons/type-geo.png</file>
|
|
||||||
<file>icons/type-light.png</file>
|
|
||||||
<file>icons/type-empty.png</file>
|
|
||||||
<file>icons/view-refresh.png</file>
|
|
||||||
</qresource>
|
|
||||||
</RCC>
|
|
||||||
19
shaders.qrc
@@ -1,19 +0,0 @@
|
|||||||
<RCC>
|
|
||||||
<qresource prefix="/">
|
|
||||||
<file>shaders/ds_final.glsl</file>
|
|
||||||
<file>shaders/ds_geom.glsl</file>
|
|
||||||
<file>shaders/ds_light.glsl</file>
|
|
||||||
<file>shaders/ds_tonemap.glsl</file>
|
|
||||||
<file>shaders/fxaa.frag</file>
|
|
||||||
<file>shaders/fxaa.vert</file>
|
|
||||||
<file>shaders/fxaa_v3.h</file>
|
|
||||||
<file>shaders/selection.glsl</file>
|
|
||||||
<file>shaders/selection_apply.glsl</file>
|
|
||||||
<file>shaders/selection_frame.glsl</file>
|
|
||||||
<file>shaders/selection_halo.glsl</file>
|
|
||||||
<file>shaders/service_fill.glsl</file>
|
|
||||||
<file>shaders/service_frame.glsl</file>
|
|
||||||
<file>shaders/service_line.glsl</file>
|
|
||||||
<file>shaders/sum.glsl</file>
|
|
||||||
</qresource>
|
|
||||||
</RCC>
|
|
||||||
9
src/CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#if (NOT DEFINED ANDROID_PLATFORM)
|
||||||
|
# if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/plugin")
|
||||||
|
# #add_subdirectory(plugin)
|
||||||
|
# endif()
|
||||||
|
#endif()
|
||||||
|
foreach (_d "core" "widgets" "qglview_test") # "plugin")
|
||||||
|
add_subdirectory("${_d}")
|
||||||
|
endforeach()
|
||||||
|
shstk_copy_to_parent()
|
||||||
35
src/core/CMakeLists.txt
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.0)
|
||||||
|
project(qglengine_core)
|
||||||
|
if (POLICY CMP0017)
|
||||||
|
cmake_policy(SET CMP0017 NEW)
|
||||||
|
endif()
|
||||||
|
qad_find_qt(Core Gui OpenGL OpenGLWidgets Xml)
|
||||||
|
find_package(OpenGL REQUIRED)
|
||||||
|
qad_sources(SRC)
|
||||||
|
set(_includes "${_qglengine_root_build}")
|
||||||
|
foreach (_d "formats" "core" "scene" "render")
|
||||||
|
qad_sources(FSRC DIR "${_d}")
|
||||||
|
list(APPEND SRC ${FSRC})
|
||||||
|
list(APPEND _includes "${CMAKE_CURRENT_SOURCE_DIR}/${_d}")
|
||||||
|
endforeach()
|
||||||
|
qad_wrap(${SRC} HDRS out_HDR CPPS out_CPP QMS out_QM)
|
||||||
|
file(GLOB PHS "*_p.h")
|
||||||
|
list(REMOVE_ITEM out_HDR "${PHS}")
|
||||||
|
import_version(${PROJECT_NAME} QGLEngine)
|
||||||
|
set_deploy_property(${PROJECT_NAME} ${QGLEngine_LIB_TYPE}
|
||||||
|
LABEL "QGLEngine core library"
|
||||||
|
FULLNAME "${QGLEngine_DOMAIN}.qglengine_core"
|
||||||
|
COMPANY "${QGLEngine_COMPANY}"
|
||||||
|
INFO "QGLEngine core library")
|
||||||
|
make_rc(${PROJECT_NAME} _RC)
|
||||||
|
qad_add_library(${PROJECT_NAME} ${QGLEngine_LIB_TYPE} out_CPP ${_RC})
|
||||||
|
qad_generate_export_header(${PROJECT_NAME})
|
||||||
|
list(APPEND out_HDR "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_export.h")
|
||||||
|
qad_target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}" ${_includes})
|
||||||
|
qad_target_link_libraries(${PROJECT_NAME} QAD::Widgets assimp ${OPENGL_LIBRARIES})
|
||||||
|
message(STATUS "Building QGLEngine version ${QGLEngine_VERSION} (${QGLEngine_LIB_TYPE_MSG}) for ${QtVersions}")
|
||||||
|
|
||||||
|
list(APPEND QT_MULTILIB_LIST ${PROJECT_NAME})
|
||||||
|
shstk_copy_to_parent()
|
||||||
|
#message(STATUS "Building ${PROJECT_NAME}")
|
||||||
|
shstk_qad_install("qglengine" FALSE "${PROJECT_NAME}" "${out_HDR}" "out_QM")
|
||||||
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
@@ -22,7 +22,7 @@
|
|||||||
#include "gltypes.h"
|
#include "gltypes.h"
|
||||||
|
|
||||||
|
|
||||||
class Buffer {
|
class QGLENGINE_CORE_EXPORT Buffer {
|
||||||
friend class ObjectBase;
|
friend class ObjectBase;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -22,9 +22,9 @@
|
|||||||
#include "chunkstream.h"
|
#include "chunkstream.h"
|
||||||
#include "glshaders_types.h"
|
#include "glshaders_types.h"
|
||||||
|
|
||||||
QVector<QVector3D> loadFileHDR(const QString & path, QSize * size = 0);
|
QVector<QVector3D> QGLENGINE_CORE_EXPORT loadFileHDR(const QString & path, QSize * size = 0);
|
||||||
|
|
||||||
class CubeTexture {
|
class QGLENGINE_CORE_EXPORT CubeTexture {
|
||||||
public:
|
public:
|
||||||
CubeTexture(QOpenGLExtraFunctions * f_, int _size, const GLenum & _format = GL_RGB16F);
|
CubeTexture(QOpenGLExtraFunctions * f_, int _size, const GLenum & _format = GL_RGB16F);
|
||||||
bool init();
|
bool init();
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
#include "glbuffer.h"
|
#include "glbuffer.h"
|
||||||
|
|
||||||
|
|
||||||
class Framebuffer {
|
class QGLENGINE_CORE_EXPORT Framebuffer {
|
||||||
friend class FramebufferMipmap;
|
friend class FramebufferMipmap;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
#include "glframebuffer.h"
|
#include "glframebuffer.h"
|
||||||
|
|
||||||
|
|
||||||
class FramebufferMipmap {
|
class QGLENGINE_CORE_EXPORT FramebufferMipmap {
|
||||||
public:
|
public:
|
||||||
FramebufferMipmap(const Framebuffer & fb, int index_from_, int levels = 2);
|
FramebufferMipmap(const Framebuffer & fb, int index_from_, int levels = 2);
|
||||||
virtual ~FramebufferMipmap();
|
virtual ~FramebufferMipmap();
|
||||||
145
src/core/core/glframebuffereffectbase.cpp
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
/*
|
||||||
|
QGL Framebuffer effect basic
|
||||||
|
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 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "glframebuffereffectbase.h"
|
||||||
|
|
||||||
|
#include "renderer.h"
|
||||||
|
|
||||||
|
#include <QTime>
|
||||||
|
|
||||||
|
|
||||||
|
FramebufferEffectBase::FramebufferEffectBase() {}
|
||||||
|
|
||||||
|
|
||||||
|
FramebufferEffectBase::~FramebufferEffectBase() {
|
||||||
|
/*if (fbo > 0) deleteGLFramebuffer(fbo);
|
||||||
|
deleteGLRenderbuffer(drbo);
|
||||||
|
for (int i = 0; i < colors.size(); ++i)
|
||||||
|
deleteGLTexture(f, colors[i]);
|
||||||
|
deleteGLTexture(f, tex_d);*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FramebufferEffectBase::resize(int width, int height, bool force) {
|
||||||
|
/*if (fbo > 0) {
|
||||||
|
if ((wid == width) && (hei == height) && !force) return;
|
||||||
|
}
|
||||||
|
wid = width;
|
||||||
|
hei = height;
|
||||||
|
if (fbo > 0) deleteGLFramebuffer(fbo);
|
||||||
|
f->glGenFramebuffers(1, &fbo);
|
||||||
|
f->glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||||
|
// qDebug() << "resize" << f << wid << hei << fbo;
|
||||||
|
for (int i = 0; i < colors.size(); ++i) {
|
||||||
|
deleteGLTexture(f, colors[i]);
|
||||||
|
createGLTexture(f, colors[i], width, height, color_formats[i], target_);
|
||||||
|
f->glTexParameteri(target_, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
f->glTexParameteri(target_, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
f->glTexParameteri(target_, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
f->glTexParameteri(target_, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
f->glTexParameteri(target_, GL_TEXTURE_MAX_LEVEL, 4);
|
||||||
|
f->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, target_, colors[i], 0);
|
||||||
|
}
|
||||||
|
if (is_depth) {
|
||||||
|
deleteGLTexture(f, tex_d);
|
||||||
|
if (drbo > 0) deleteGLRenderbuffer(drbo);
|
||||||
|
f->glGenRenderbuffers(1, &drbo);
|
||||||
|
f->glBindRenderbuffer(GL_RENDERBUFFER, drbo);
|
||||||
|
f->glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width, height);
|
||||||
|
f->glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, drbo);
|
||||||
|
createGLTexture(f, tex_d, width, height, GL_DEPTH_COMPONENT);
|
||||||
|
f->glTexParameteri(target_, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
|
f->glTexParameteri(target_, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
|
f->glTexParameteri(target_, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
f->glTexParameteri(target_, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
f->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, target_, tex_d, 0);
|
||||||
|
}
|
||||||
|
f->glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
|
if (pbo.isInit()) {
|
||||||
|
enablePixelBuffer();
|
||||||
|
}
|
||||||
|
is_changed = false;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FramebufferEffectBase::reinit() {
|
||||||
|
/*pbo.reinit();
|
||||||
|
colors.fill(0);
|
||||||
|
fbo = drbo = 0;
|
||||||
|
tex_d = 0;
|
||||||
|
pbo_queried = 0;
|
||||||
|
is_changed = true;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FramebufferEffectBase::bindDeferredBuffer(int role, int channel) {
|
||||||
|
r->fbo_ds.bindColorTexture(role, channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FramebufferEffectBase::bindDepthBuffer(int channel) {
|
||||||
|
r->fbo_ds.bindDepthTexture(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FramebufferEffectBase::bindPreviousOutput(int channel) {
|
||||||
|
r->fbo_out.bindColorTexture(r->prev_write_plane, channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FramebufferEffectBase::setOutputPlane(int channel) {
|
||||||
|
r->fbo_out.setWriteBuffer(channel);
|
||||||
|
r->prev_write_plane = r->cur_write_plane;
|
||||||
|
r->cur_write_plane = channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FramebufferEffectBase::drawScreen(QOpenGLShaderProgram * prog) {
|
||||||
|
r->renderQuad(prog, r->quad, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FramebufferEffectBase::drawInternal() {
|
||||||
|
if (!r) return;
|
||||||
|
draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FramebufferEffectBase::reloadShadersInternal() {
|
||||||
|
if (!r) return;
|
||||||
|
if (is_loaded) return;
|
||||||
|
reloadShaders();
|
||||||
|
is_loaded = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVector<int> FramebufferEffectBase::getFreePlanes(int count) {
|
||||||
|
return r->getFreePlanes(count);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int FramebufferEffectBase::previousOutputPlane() const {
|
||||||
|
return r->prev_write_plane;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FramebufferEffectBase::deleteShader(QOpenGLShaderProgram *& s) {
|
||||||
|
if (!s) return;
|
||||||
|
delete s;
|
||||||
|
s = nullptr;
|
||||||
|
}
|
||||||
59
src/core/core/glframebuffereffectbase.h
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
QGL Framebuffer effect basic
|
||||||
|
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 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef glframebuffereffectbase_H
|
||||||
|
#define glframebuffereffectbase_H
|
||||||
|
|
||||||
|
#include "glframebuffer.h"
|
||||||
|
|
||||||
|
|
||||||
|
class QGLENGINE_CORE_EXPORT FramebufferEffectBase {
|
||||||
|
friend class FramebufferMipmap;
|
||||||
|
friend class Renderer;
|
||||||
|
|
||||||
|
public:
|
||||||
|
FramebufferEffectBase();
|
||||||
|
virtual ~FramebufferEffectBase();
|
||||||
|
|
||||||
|
virtual void draw() = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void resize(int width, int height, bool force = false);
|
||||||
|
void reinit();
|
||||||
|
|
||||||
|
virtual int maxPlanesUsed() const { return 1; }
|
||||||
|
virtual void reloadShaders() {}
|
||||||
|
|
||||||
|
void bindDeferredBuffer(int role, int channel);
|
||||||
|
void bindDepthBuffer(int channel);
|
||||||
|
void bindPreviousOutput(int channel);
|
||||||
|
void setOutputPlane(int channel);
|
||||||
|
void drawScreen(QOpenGLShaderProgram * prog);
|
||||||
|
void drawInternal();
|
||||||
|
void reloadShadersInternal();
|
||||||
|
QVector<int> getFreePlanes(int count);
|
||||||
|
int previousOutputPlane() const;
|
||||||
|
static void deleteShader(QOpenGLShaderProgram *& s);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool is_loaded = false;
|
||||||
|
Renderer * r = nullptr;
|
||||||
|
GLint wid, hei;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
#include "glshaders_types.h"
|
#include "glshaders_types.h"
|
||||||
|
|
||||||
|
|
||||||
class Map {
|
class QGLENGINE_CORE_EXPORT Map {
|
||||||
public:
|
public:
|
||||||
Map();
|
Map();
|
||||||
void setBitmapPath(const QString & p);
|
void setBitmapPath(const QString & p);
|
||||||
@@ -43,7 +43,7 @@ public:
|
|||||||
int _type, _layer;
|
int _type, _layer;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Material {
|
class QGLENGINE_CORE_EXPORT Material {
|
||||||
public:
|
public:
|
||||||
Material(const QString _name = QString());
|
Material(const QString _name = QString());
|
||||||
uint hash();
|
uint hash();
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
#include <chunkstream.h>
|
#include <chunkstream.h>
|
||||||
|
|
||||||
|
|
||||||
class Mesh {
|
class QGLENGINE_CORE_EXPORT Mesh {
|
||||||
friend QDataStream & operator<<(QDataStream & s, const Mesh * m);
|
friend QDataStream & operator<<(QDataStream & s, const Mesh * m);
|
||||||
friend QDataStream & operator>>(QDataStream & s, Mesh *& m);
|
friend QDataStream & operator>>(QDataStream & s, Mesh *& m);
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
QDataStream & operator<<(QDataStream & s, const Mesh * m);
|
QGLENGINE_CORE_EXPORT QDataStream & operator<<(QDataStream & s, const Mesh * m);
|
||||||
QDataStream & operator>>(QDataStream & s, Mesh *& m);
|
QGLENGINE_CORE_EXPORT QDataStream & operator>>(QDataStream & s, Mesh *& m);
|
||||||
|
|
||||||
#endif // GLMESH_H
|
#endif // GLMESH_H
|
||||||
56
src/core/core/glprimitives.h
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
QGL Primitives
|
||||||
|
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 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GLPRIMITIVE_CUBE_H
|
||||||
|
#define GLPRIMITIVE_CUBE_H
|
||||||
|
|
||||||
|
#include "gltypes.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace Primitive {
|
||||||
|
|
||||||
|
|
||||||
|
QGLENGINE_CORE_EXPORT Mesh * plane(float width = 1., float length = 1.);
|
||||||
|
|
||||||
|
QGLENGINE_CORE_EXPORT Mesh * cube(float width = 1., float length = 1., float height = 1.);
|
||||||
|
|
||||||
|
QGLENGINE_CORE_EXPORT Mesh * ellipsoid(int segments_wl, int segments_h, float radius = 1., float end_angle = 360.);
|
||||||
|
|
||||||
|
QGLENGINE_CORE_EXPORT Mesh * disc(int segments, float radius = 1., float end_angle = 360.);
|
||||||
|
|
||||||
|
QGLENGINE_CORE_EXPORT Mesh * cone(int segments, float radius = 1., float height = 1.);
|
||||||
|
|
||||||
|
QGLENGINE_CORE_EXPORT Mesh * cylinder(int segments, float radius = 1., float height = 1., float end_angle = 360.);
|
||||||
|
|
||||||
|
QGLENGINE_CORE_EXPORT Mesh * arrow(int segments = 16, float thick = 0.04, float angle = 30.); // length = 1
|
||||||
|
|
||||||
|
QGLENGINE_CORE_EXPORT Mesh *
|
||||||
|
torus(int segments_main = 30, int segments_second = 16, float radius_main = 2.5, float radius_second = 0.5, float end_angle = 360.);
|
||||||
|
|
||||||
|
|
||||||
|
QGLENGINE_CORE_EXPORT Mesh * lineFrame(QVector3D p0, QVector3D p1);
|
||||||
|
|
||||||
|
QGLENGINE_CORE_EXPORT Mesh * cubeFrame(float width = 1., float length = 1., float height = 1.);
|
||||||
|
|
||||||
|
QGLENGINE_CORE_EXPORT Mesh * ellipsoidFrame(int segments_wl, int segments_h, float radius = 1.);
|
||||||
|
|
||||||
|
QGLENGINE_CORE_EXPORT Mesh * coneFrame(int segments, float radius = 1., float height = 1.);
|
||||||
|
|
||||||
|
} // namespace Primitive
|
||||||
|
|
||||||
|
#endif // GLPRIMITIVE_CUBE_H
|
||||||
@@ -67,6 +67,7 @@ QString prepareDefines(const QStringList & defines) {
|
|||||||
|
|
||||||
bool QGLEngineShaders::loadShadersMulti(QOpenGLShaderProgram *& prog, const QString & file, bool add_qgl, const QStringList & defines) {
|
bool QGLEngineShaders::loadShadersMulti(QOpenGLShaderProgram *& prog, const QString & file, bool add_qgl, const QStringList & defines) {
|
||||||
if (!prog) prog = new QOpenGLShaderProgram();
|
if (!prog) prog = new QOpenGLShaderProgram();
|
||||||
|
prog->removeAllShaders();
|
||||||
QFile f(file);
|
QFile f(file);
|
||||||
if (!f.open(QIODevice::ReadOnly)) {
|
if (!f.open(QIODevice::ReadOnly)) {
|
||||||
qDebug() << "[QGLEngine] Shader" << file << "Error: can`t open file!";
|
qDebug() << "[QGLEngine] Shader" << file << "Error: can`t open file!";
|
||||||
@@ -23,8 +23,10 @@
|
|||||||
|
|
||||||
namespace QGLEngineShaders {
|
namespace QGLEngineShaders {
|
||||||
|
|
||||||
bool loadShadersMulti(QOpenGLShaderProgram *& prog, const QString & file, bool add_qgl = true, const QStringList & defines = QStringList());
|
QGLENGINE_CORE_EXPORT bool
|
||||||
bool loadShaders(QOpenGLShaderProgram *& prog, const QStringList & files, bool add_qgl = true, const QStringList & defines = QStringList());
|
loadShadersMulti(QOpenGLShaderProgram *& prog, const QString & file, bool add_qgl = true, const QStringList & defines = QStringList());
|
||||||
|
QGLENGINE_CORE_EXPORT bool
|
||||||
|
loadShaders(QOpenGLShaderProgram *& prog, const QStringList & files, bool add_qgl = true, const QStringList & defines = QStringList());
|
||||||
|
|
||||||
} // namespace QGLEngineShaders
|
} // namespace QGLEngineShaders
|
||||||
|
|
||||||
@@ -50,6 +50,7 @@ const char qgl_fragment_head[] =
|
|||||||
"in vec2 qgl_FragTexture;\n"
|
"in vec2 qgl_FragTexture;\n"
|
||||||
"flat in uint qgl_MaterialIndex;\n"
|
"flat in uint qgl_MaterialIndex;\n"
|
||||||
"out vec4 qgl_FragData[gl_MaxDrawBuffers];\n"
|
"out vec4 qgl_FragData[gl_MaxDrawBuffers];\n"
|
||||||
|
"uniform vec2 qgl_ViewSize;\n"
|
||||||
"vec4 qgl_materialTexture(uint type, vec2 coord, vec4 tex_shift) {\n"
|
"vec4 qgl_materialTexture(uint type, vec2 coord, vec4 tex_shift) {\n"
|
||||||
" coord *= qgl_material[qgl_MaterialIndex].map[type].scale;\n"
|
" coord *= qgl_material[qgl_MaterialIndex].map[type].scale;\n"
|
||||||
" vec4 t = texture(qgl_texture_array[qgl_material[qgl_MaterialIndex].map[type].array_index],\n"
|
" vec4 t = texture(qgl_texture_array[qgl_material[qgl_MaterialIndex].map[type].array_index],\n"
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
#include "gltypes.h"
|
#include "gltypes.h"
|
||||||
|
|
||||||
|
|
||||||
class Texture2DArray {
|
class QGLENGINE_CORE_EXPORT Texture2DArray {
|
||||||
public:
|
public:
|
||||||
Texture2DArray(bool filter);
|
Texture2DArray(bool filter);
|
||||||
~Texture2DArray();
|
~Texture2DArray();
|
||||||
@@ -19,13 +19,15 @@
|
|||||||
#ifndef GLTRANSFORM_H
|
#ifndef GLTRANSFORM_H
|
||||||
#define GLTRANSFORM_H
|
#define GLTRANSFORM_H
|
||||||
|
|
||||||
|
#include "qglengine_core_export.h"
|
||||||
|
|
||||||
#include <QMatrix4x4>
|
#include <QMatrix4x4>
|
||||||
#include <QQuaternion>
|
#include <QQuaternion>
|
||||||
#include <QVector3D>
|
#include <QVector3D>
|
||||||
#include <chunkstream.h>
|
#include <chunkstream.h>
|
||||||
|
|
||||||
|
|
||||||
class Transform {
|
class QGLENGINE_CORE_EXPORT Transform {
|
||||||
friend QDataStream & operator>>(QDataStream & s, Transform & v);
|
friend QDataStream & operator>>(QDataStream & s, Transform & v);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -179,8 +179,8 @@ inline float urand(const float & scale = 1.) {
|
|||||||
inline float uprand(const float & scale = 1.) {
|
inline float uprand(const float & scale = 1.) {
|
||||||
return ((float)rand() / RAND_MAX) * scale;
|
return ((float)rand() / RAND_MAX) * scale;
|
||||||
}
|
}
|
||||||
QString readCharsUntilNull(QDataStream & s);
|
QGLENGINE_CORE_EXPORT QString readCharsUntilNull(QDataStream & s);
|
||||||
QString findFile(const QString & file, const QStringList & pathes);
|
QGLENGINE_CORE_EXPORT QString findFile(const QString & file, const QStringList & pathes);
|
||||||
inline QColor operator*(const QColor & c, float v) {
|
inline QColor operator*(const QColor & c, float v) {
|
||||||
return QColor(piClamp<int>(c.red() * v, 0, 255),
|
return QColor(piClamp<int>(c.red() * v, 0, 255),
|
||||||
piClamp<int>(c.green() * v, 0, 255),
|
piClamp<int>(c.green() * v, 0, 255),
|
||||||
@@ -216,29 +216,29 @@ inline void deleteGLTexture(QOpenGLExtraFunctions * f, GLuint & tex) {
|
|||||||
if (tex != 0) f->glDeleteTextures(1, &tex);
|
if (tex != 0) f->glDeleteTextures(1, &tex);
|
||||||
tex = 0;
|
tex = 0;
|
||||||
}
|
}
|
||||||
void glEnableDepth();
|
QGLENGINE_CORE_EXPORT void glEnableDepth();
|
||||||
void glDisableDepth();
|
QGLENGINE_CORE_EXPORT void glDisableDepth();
|
||||||
void glClearFramebuffer(const QColor & color = Qt::black, bool depth = true);
|
QGLENGINE_CORE_EXPORT void glClearFramebuffer(const QColor & color = Qt::black, bool depth = true);
|
||||||
void glDrawQuad(QOpenGLShaderProgram * prog = nullptr,
|
QGLENGINE_CORE_EXPORT void glDrawQuad(QOpenGLShaderProgram * prog = nullptr,
|
||||||
QVector4D * corner_dirs = nullptr,
|
QVector4D * corner_dirs = nullptr,
|
||||||
GLfloat x = -1.f,
|
GLfloat x = -1.f,
|
||||||
GLfloat y = -1.f,
|
GLfloat y = -1.f,
|
||||||
GLfloat w = 2.f,
|
GLfloat w = 2.f,
|
||||||
GLfloat h = 2.f);
|
GLfloat h = 2.f);
|
||||||
void createGLTexture(QOpenGLExtraFunctions * f,
|
QGLENGINE_CORE_EXPORT void createGLTexture(QOpenGLExtraFunctions * f,
|
||||||
GLuint & tex,
|
GLuint & tex,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
const GLenum & format = GL_RGBA,
|
const GLenum & format = GL_RGBA,
|
||||||
const GLenum & target = GL_TEXTURE_2D);
|
const GLenum & target = GL_TEXTURE_2D);
|
||||||
void createGLTexture(QOpenGLExtraFunctions * f,
|
QGLENGINE_CORE_EXPORT void createGLTexture(QOpenGLExtraFunctions * f,
|
||||||
GLuint & tex,
|
GLuint & tex,
|
||||||
const QImage & image,
|
const QImage & image,
|
||||||
const GLenum & format = GL_RGBA,
|
const GLenum & format = GL_RGBA,
|
||||||
const GLenum & target = GL_TEXTURE_2D);
|
const GLenum & target = GL_TEXTURE_2D);
|
||||||
QMatrix4x4 glMatrixPerspective(float angle, float aspect, float near_);
|
QGLENGINE_CORE_EXPORT QMatrix4x4 glMatrixPerspective(float angle, float aspect, float near_);
|
||||||
QImage rotateQImageLeft(const QImage & im);
|
QGLENGINE_CORE_EXPORT QImage rotateQImageLeft(const QImage & im);
|
||||||
QImage rotateQImageRight(const QImage & im);
|
QGLENGINE_CORE_EXPORT QImage rotateQImageRight(const QImage & im);
|
||||||
inline QImage rotateQImage180(const QImage & im) {
|
inline QImage rotateQImage180(const QImage & im) {
|
||||||
return im.mirrored(true, true);
|
return im.mirrored(true, true);
|
||||||
}
|
}
|
||||||
@@ -257,6 +257,7 @@ class TextureManager;
|
|||||||
class Texture2DArray;
|
class Texture2DArray;
|
||||||
class Framebuffer;
|
class Framebuffer;
|
||||||
class FramebufferMipmap;
|
class FramebufferMipmap;
|
||||||
|
class FramebufferEffectBase;
|
||||||
class VertexObject;
|
class VertexObject;
|
||||||
class Mesh;
|
class Mesh;
|
||||||
class Scene;
|
class Scene;
|
||||||
@@ -273,7 +274,7 @@ enum RenderPass {
|
|||||||
|
|
||||||
typedef QList<ObjectBase *> ObjectBaseList;
|
typedef QList<ObjectBase *> ObjectBaseList;
|
||||||
|
|
||||||
struct Box3D {
|
struct QGLENGINE_CORE_EXPORT Box3D {
|
||||||
GLfloat x;
|
GLfloat x;
|
||||||
GLfloat y;
|
GLfloat y;
|
||||||
GLfloat z;
|
GLfloat z;
|
||||||
@@ -352,7 +353,7 @@ inline QDebug operator<<(QDebug d, const Box3D & v) {
|
|||||||
|
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
struct Vector2i {
|
struct QGLENGINE_CORE_EXPORT Vector2i {
|
||||||
Vector2i(int p0_ = 0, int p1_ = 0) {
|
Vector2i(int p0_ = 0, int p1_ = 0) {
|
||||||
p0 = p0_;
|
p0 = p0_;
|
||||||
p1 = p1_;
|
p1 = p1_;
|
||||||
@@ -401,7 +402,7 @@ inline QDataStream & operator>>(QDataStream & s, Vector2i & v) {
|
|||||||
|
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
struct Vector3i {
|
struct QGLENGINE_CORE_EXPORT Vector3i {
|
||||||
Vector3i(int p0_ = 0, int p1_ = 0, int p2_ = 0) {
|
Vector3i(int p0_ = 0, int p1_ = 0, int p2_ = 0) {
|
||||||
p0 = p0_;
|
p0 = p0_;
|
||||||
p1 = p1_;
|
p1 = p1_;
|
||||||
@@ -453,8 +454,8 @@ inline QDataStream & operator>>(QDataStream & s, Vector3i & v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QVector3D vectorFromString(const QString & str);
|
QGLENGINE_CORE_EXPORT QVector3D vectorFromString(const QString & str);
|
||||||
QColor colorFromString(const QString & str);
|
QGLENGINE_CORE_EXPORT QColor colorFromString(const QString & str);
|
||||||
inline QVector4D QColor2QVector(const QColor & c) {
|
inline QVector4D QColor2QVector(const QColor & c) {
|
||||||
return QVector4D(c.redF(), c.greenF(), c.blueF(), c.alphaF());
|
return QVector4D(c.redF(), c.greenF(), c.blueF(), c.alphaF());
|
||||||
}
|
}
|
||||||
@@ -478,10 +479,10 @@ inline void normalizeAngleDeg360(float & a) {
|
|||||||
inline QVector3D projection(const QVector3D & v, const QVector3D & to) {
|
inline QVector3D projection(const QVector3D & v, const QVector3D & to) {
|
||||||
return to.normalized() * v.length() * cosABV(v, to);
|
return to.normalized() * v.length() * cosABV(v, to);
|
||||||
}
|
}
|
||||||
QVector3D orthToVector(const QVector3D & v, const float & scale = 1.);
|
QGLENGINE_CORE_EXPORT QVector3D orthToVector(const QVector3D & v, const float & scale = 1.);
|
||||||
QVector3D rotateVector(const QVector3D & v, const QVector3D & a);
|
QGLENGINE_CORE_EXPORT QVector3D rotateVector(const QVector3D & v, const QVector3D & a);
|
||||||
void setVectorLength(QVector3D & v, const float & l);
|
QGLENGINE_CORE_EXPORT void setVectorLength(QVector3D & v, const float & l);
|
||||||
void lengthenVector(QVector3D & v, const float & l);
|
QGLENGINE_CORE_EXPORT void lengthenVector(QVector3D & v, const float & l);
|
||||||
inline float squareLength(const QVector3D & from, const QVector3D & to) {
|
inline float squareLength(const QVector3D & from, const QVector3D & to) {
|
||||||
return (to.x() - from.x()) * (to.x() - from.x()) + (to.y() - from.y()) * (to.y() - from.y()) +
|
return (to.x() - from.x()) * (to.x() - from.x()) + (to.y() - from.y()) * (to.y() - from.y()) +
|
||||||
(to.z() - from.z()) * (to.z() - from.z());
|
(to.z() - from.z()) * (to.z() - from.z());
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
#include "glshaders_types.h"
|
#include "glshaders_types.h"
|
||||||
|
|
||||||
|
|
||||||
class VertexObject {
|
class QGLENGINE_CORE_EXPORT VertexObject {
|
||||||
public:
|
public:
|
||||||
VertexObject();
|
VertexObject();
|
||||||
~VertexObject();
|
~VertexObject();
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include "gltypes.h"
|
#include "gltypes.h"
|
||||||
|
|
||||||
Scene * loadScene(const QString & filepath);
|
QGLENGINE_CORE_EXPORT Scene * loadScene(const QString & filepath);
|
||||||
QStringList supportedFormats();
|
QGLENGINE_CORE_EXPORT QStringList supportedFormats();
|
||||||
|
|
||||||
#endif // LOADER_ASSIMP_H
|
#endif // LOADER_ASSIMP_H
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
|
||||||
Scene * loadFromQGLFile(const QString & filepath);
|
QGLENGINE_CORE_EXPORT Scene * loadFromQGLFile(const QString & filepath);
|
||||||
bool saveToQGLFile(const QString & filepath, const Scene * scene);
|
QGLENGINE_CORE_EXPORT bool saveToQGLFile(const QString & filepath, const Scene * scene);
|
||||||
|
|
||||||
#endif // LOADER_QGL_H
|
#endif // LOADER_QGL_H
|
||||||
@@ -19,6 +19,8 @@
|
|||||||
#ifndef GLWIDGET_H
|
#ifndef GLWIDGET_H
|
||||||
#define GLWIDGET_H
|
#define GLWIDGET_H
|
||||||
|
|
||||||
|
#include "qglengine_core_export.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
|
||||||
@@ -26,7 +28,7 @@ class QGLView;
|
|||||||
class ObjectBase;
|
class ObjectBase;
|
||||||
class Scene;
|
class Scene;
|
||||||
|
|
||||||
class GLWidget: public QWidget {
|
class QGLENGINE_CORE_EXPORT GLWidget: public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(qreal lineWidth READ lineWidth WRITE setLineWidth)
|
Q_PROPERTY(qreal lineWidth READ lineWidth WRITE setLineWidth)
|
||||||
Q_PROPERTY(qreal FOV READ FOV WRITE setFOV)
|
Q_PROPERTY(qreal FOV READ FOV WRITE setFOV)
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
#include <QTime>
|
#include <QTime>
|
||||||
|
|
||||||
|
|
||||||
class MouseController: public QObject {
|
class QGLENGINE_CORE_EXPORT MouseController: public QObject {
|
||||||
friend class QGLView;
|
friend class QGLView;
|
||||||
friend class RendererSelection;
|
friend class RendererSelection;
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#include "qglengine_core_export.h"
|
||||||
|
|
||||||
#include <QOpenGLExtraFunctions>
|
#include <QOpenGLExtraFunctions>
|
||||||
#include <QWindow>
|
#include <QWindow>
|
||||||
|
|
||||||
@@ -6,7 +8,7 @@ class QOpenGLContext;
|
|||||||
class QOpenGLPaintDevice;
|
class QOpenGLPaintDevice;
|
||||||
|
|
||||||
|
|
||||||
class OpenGLWindow
|
class QGLENGINE_CORE_EXPORT OpenGLWindow
|
||||||
: public QWindow
|
: public QWindow
|
||||||
, public QOpenGLExtraFunctions {
|
, public QOpenGLExtraFunctions {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
46
src/core/qglengine_core.qrc
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/">
|
||||||
|
<file>coeffs_brdf.png</file>
|
||||||
|
<file>../icons/add-type-camera.png</file>
|
||||||
|
<file>../icons/add-type-geo.png</file>
|
||||||
|
<file>../icons/add-type-light.png</file>
|
||||||
|
<file>../icons/add-type-empty.png</file>
|
||||||
|
<file>../icons/collapse.png</file>
|
||||||
|
<file>../icons/expand.png</file>
|
||||||
|
<file>../icons/edit-rename.png</file>
|
||||||
|
<file>../icons/alpha.png</file>
|
||||||
|
<file>../icons/application-exit.png</file>
|
||||||
|
<file>../icons/configure.png</file>
|
||||||
|
<file>../icons/dialog-close.png</file>
|
||||||
|
<file>../icons/document-edit.png</file>
|
||||||
|
<file>../icons/document-import.png</file>
|
||||||
|
<file>../icons/document-new.png</file>
|
||||||
|
<file>../icons/document-open.png</file>
|
||||||
|
<file>../icons/document-save.png</file>
|
||||||
|
<file>../icons/document-save-all.png</file>
|
||||||
|
<file>../icons/edit-clear.png</file>
|
||||||
|
<file>../icons/edit-clear-locationbar-rtl.png</file>
|
||||||
|
<file>../icons/edit-copy.png</file>
|
||||||
|
<file>../icons/edit-delete.png</file>
|
||||||
|
<file>../icons/edit-find.png</file>
|
||||||
|
<file>../icons/edit-paste.png</file>
|
||||||
|
<file>../icons/go-jump.png</file>
|
||||||
|
<file>../icons/go-top.png</file>
|
||||||
|
<file>../icons/layer-visible-on.png</file>
|
||||||
|
<file>../icons/layer-visible-off.png</file>
|
||||||
|
<file>../icons/light-+.png</file>
|
||||||
|
<file>../icons/list-add.png</file>
|
||||||
|
<file>../icons/object-flip-horizontal.png</file>
|
||||||
|
<file>../icons/object-flip-vertical.png</file>
|
||||||
|
<file>../icons/picker.png</file>
|
||||||
|
<file>../icons/qglview.png</file>
|
||||||
|
<file>../icons/transform-move.png</file>
|
||||||
|
<file>../icons/transform-rotate.png</file>
|
||||||
|
<file>../icons/transform-scale.png</file>
|
||||||
|
<file>../icons/type-camera.png</file>
|
||||||
|
<file>../icons/type-geo.png</file>
|
||||||
|
<file>../icons/type-light.png</file>
|
||||||
|
<file>../icons/type-empty.png</file>
|
||||||
|
<file>../icons/view-refresh.png</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
||||||
@@ -25,13 +25,13 @@
|
|||||||
#include "glscene.h"
|
#include "glscene.h"
|
||||||
#include "mouse_controller.h"
|
#include "mouse_controller.h"
|
||||||
#include "openglwindow.h"
|
#include "openglwindow.h"
|
||||||
|
#include "qglengine_core_export.h"
|
||||||
#include "renderer.h"
|
#include "renderer.h"
|
||||||
|
|
||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
|
class QGLENGINE_CORE_EXPORT QGLView: public OpenGLWindow {
|
||||||
class QGLView: public OpenGLWindow {
|
|
||||||
friend class RendererSelection;
|
friend class RendererSelection;
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(float lineWidth READ lineWidth WRITE setLineWidth)
|
Q_PROPERTY(float lineWidth READ lineWidth WRITE setLineWidth)
|
||||||
@@ -19,6 +19,8 @@
|
|||||||
#ifndef GLTEXTUREMANAGER_H
|
#ifndef GLTEXTUREMANAGER_H
|
||||||
#define GLTEXTUREMANAGER_H
|
#define GLTEXTUREMANAGER_H
|
||||||
|
|
||||||
|
#include "qglengine_core_export.h"
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
@@ -26,7 +28,7 @@
|
|||||||
#include <QOpenGLExtraFunctions>
|
#include <QOpenGLExtraFunctions>
|
||||||
|
|
||||||
|
|
||||||
class TextureManager {
|
class QGLENGINE_CORE_EXPORT TextureManager {
|
||||||
public:
|
public:
|
||||||
TextureManager(QOpenGLExtraFunctions * f_): f(f_) {}
|
TextureManager(QOpenGLExtraFunctions * f_): f(f_) {}
|
||||||
virtual ~TextureManager() {}
|
virtual ~TextureManager() {}
|
||||||
@@ -33,7 +33,7 @@ using namespace QGLEngineShaders;
|
|||||||
|
|
||||||
Renderer::Renderer(QGLView * view_)
|
Renderer::Renderer(QGLView * view_)
|
||||||
: RendererBase(view_)
|
: RendererBase(view_)
|
||||||
, fbo_ds(view_, QVector<GLenum>() << GL_RGBA16F << GL_RGBA32F << GL_RGBA16F << GL_RGBA16F << GL_RGBA16F)
|
, fbo_ds(view_, QVector<GLenum>() << GL_RGBA16F << GL_RGBA32F << GL_RGBA16F << GL_RGBA16F << GL_RGBA16F << GL_RGBA32F << GL_RGBA16F)
|
||||||
, fbo_out(view_, obrBuffersCount, false, GL_RGBA16F)
|
, fbo_out(view_, obrBuffersCount, false, GL_RGBA16F)
|
||||||
, rend_mat(this)
|
, rend_mat(this)
|
||||||
, rend_service(this)
|
, rend_service(this)
|
||||||
@@ -127,6 +127,10 @@ void Renderer::reloadShaders() {
|
|||||||
<< "FXAA_GLSL_130 1"
|
<< "FXAA_GLSL_130 1"
|
||||||
<< "FXAA_QUALITY__PRESET 15";
|
<< "FXAA_QUALITY__PRESET 15";
|
||||||
loadShaders(shader_fxaa, QStringList() << (dir + "fxaa.vert") << (dir + "fxaa.frag"), true, fxaa_defs);
|
loadShaders(shader_fxaa, QStringList() << (dir + "fxaa.vert") << (dir + "fxaa.frag"), true, fxaa_defs);
|
||||||
|
for (auto * e: fb_effects) {
|
||||||
|
e->reloadShaders();
|
||||||
|
e->is_loaded = true;
|
||||||
|
}
|
||||||
need_init_shaders = true;
|
need_init_shaders = true;
|
||||||
view->scene()->setLightsChanged();
|
view->scene()->setLightsChanged();
|
||||||
view->scene()->setTreeStructChanged();
|
view->scene()->setTreeStructChanged();
|
||||||
@@ -193,6 +197,27 @@ void Renderer::releaseShader() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVector<int> Renderer::getFreePlanes(int count) {
|
||||||
|
prev_write_plane = cur_write_plane;
|
||||||
|
QVector<int> ret;
|
||||||
|
bool output_done = false;
|
||||||
|
const int total_count = 4;
|
||||||
|
for (int i = 0; i < total_count; ++i) {
|
||||||
|
int plane = obrGeneral0 + i;
|
||||||
|
if (prev_write_plane == plane) continue;
|
||||||
|
if (!output_done) {
|
||||||
|
fbo_out.setWriteBuffer(plane);
|
||||||
|
cur_write_plane = plane;
|
||||||
|
output_done = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ret << plane;
|
||||||
|
if (ret.size() == count) break;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Renderer::fillObjectsBuffer(const ObjectBaseList & ol, RenderPass pass) {
|
void Renderer::fillObjectsBuffer(const ObjectBaseList & ol, RenderPass pass) {
|
||||||
cur_objects_.resize(ol.size());
|
cur_objects_.resize(ol.size());
|
||||||
for (int i = 0; i < ol.size(); ++i) {
|
for (int i = 0; i < ol.size(); ++i) {
|
||||||
@@ -328,6 +353,8 @@ void Renderer::renderScene() {
|
|||||||
textures_maps.bind(f, tarMaps);
|
textures_maps.bind(f, tarMaps);
|
||||||
renderObjects(scene, rpSolid);
|
renderObjects(scene, rpSolid);
|
||||||
}
|
}
|
||||||
|
fbo_ds.blit(dbrNormalZ, fbo_ds.id(), dbrNormalZSolid, fbo_ds.rect(), fbo_ds.rect());
|
||||||
|
fbo_ds.blit(dbrSpecularReflect, fbo_ds.id(), dbrSpecularReflectSolid, fbo_ds.rect(), fbo_ds.rect());
|
||||||
fbo_ds.release();
|
fbo_ds.release();
|
||||||
|
|
||||||
/// lighting passes
|
/// lighting passes
|
||||||
@@ -336,7 +363,9 @@ void Renderer::renderScene() {
|
|||||||
/// transparent geometry pass
|
/// transparent geometry pass
|
||||||
fbo_ds.bind();
|
fbo_ds.bind();
|
||||||
glEnableDepth();
|
glEnableDepth();
|
||||||
|
fbo_ds.setWriteBuffers({0, 1, 2, 3, 4});
|
||||||
glClearFramebuffer(Qt::black, false);
|
glClearFramebuffer(Qt::black, false);
|
||||||
|
fbo_ds.setWriteBuffers();
|
||||||
if (bindShader(srGeometryPass, &prog)) {
|
if (bindShader(srGeometryPass, &prog)) {
|
||||||
renderObjects(scene, rpTransparent);
|
renderObjects(scene, rpTransparent);
|
||||||
}
|
}
|
||||||
@@ -351,30 +380,50 @@ void Renderer::renderScene() {
|
|||||||
fbo_out.bindColorTexture(obrSolidSpot, 2);
|
fbo_out.bindColorTexture(obrSolidSpot, 2);
|
||||||
fbo_out.bindColorTexture(obrTransparentOmni, 3);
|
fbo_out.bindColorTexture(obrTransparentOmni, 3);
|
||||||
fbo_out.bindColorTexture(obrTransparentSpot, 4);
|
fbo_out.bindColorTexture(obrTransparentSpot, 4);
|
||||||
fbo_out.setWriteBuffer(obrSum);
|
fbo_out.setWriteBuffer(obrGeneral0);
|
||||||
renderQuad(prog, quad);
|
renderQuad(prog, quad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_write_plane = obrGeneral0;
|
||||||
|
|
||||||
/// tonemapping
|
/// tonemapping
|
||||||
tone_proc.process();
|
tone_proc.process();
|
||||||
|
auto free = getFreePlanes(0);
|
||||||
if (bindShader(srTonemapPass, &prog)) {
|
if (bindShader(srTonemapPass, &prog)) {
|
||||||
fbo_out.bind();
|
fbo_out.bind();
|
||||||
prog->setUniformValue("gamma", gamma_);
|
prog->setUniformValue("gamma", gamma_);
|
||||||
prog->setUniformValue("frame_max", tone_proc.frameMax());
|
prog->setUniformValue("frame_max", tone_proc.frameMax());
|
||||||
fbo_out.bindColorTexture(obrSum, 0);
|
fbo_out.bindColorTexture(prev_write_plane, 0);
|
||||||
fbo_out.setWriteBuffer(obrTonemap);
|
|
||||||
renderQuad(prog, quad);
|
renderQuad(prog, quad);
|
||||||
fbo_out.release();
|
|
||||||
} else {
|
} else {
|
||||||
fbo_out.blit(obrSum, fbo_out.id(), obrTonemap, fbo_out.rect(), fbo_out.rect());
|
fbo_out.blit(prev_write_plane, fbo_out.id(), cur_write_plane, fbo_out.rect(), fbo_out.rect());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// FXAA
|
||||||
|
if (view->isFeatureEnabled(QGLView::qglFXAA)) {
|
||||||
|
prog = shader_fxaa;
|
||||||
|
if (bindShader(prog)) {
|
||||||
|
auto free = getFreePlanes(0);
|
||||||
|
setUniformCamera(prog, 0, true, fbo_out.size());
|
||||||
|
fbo_out.bindColorTexture(prev_write_plane);
|
||||||
|
renderQuad(prog, quad, 0, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// custom effects
|
||||||
|
for (auto * e: fb_effects) {
|
||||||
|
e->reloadShadersInternal();
|
||||||
|
e->drawInternal();
|
||||||
|
}
|
||||||
|
|
||||||
|
fbo_out.release();
|
||||||
|
|
||||||
/// apply hovers and selection frame
|
/// apply hovers and selection frame
|
||||||
if (edit_mode) {
|
if (edit_mode) {
|
||||||
rend_selection.drawSelection(fbo_out, obrTonemap);
|
rend_selection.drawSelection(fbo_out, cur_write_plane);
|
||||||
rend_service.renderService();
|
rend_service.renderService();
|
||||||
} else {
|
} else {
|
||||||
fbo_out.blit(obrTonemap, 0, 0, fbo_out.rect(), QRect(QPoint(), view->size()));
|
fbo_out.blit(cur_write_plane, 0, 0, fbo_out.rect(), QRect(QPoint(), view->size()));
|
||||||
}
|
}
|
||||||
if (is_grabbing) {
|
if (is_grabbing) {
|
||||||
fbo_out.queryImage(0);
|
fbo_out.queryImage(0);
|
||||||
@@ -393,3 +442,9 @@ void Renderer::setGrabImage(bool on) {
|
|||||||
is_grabbing = on;
|
is_grabbing = on;
|
||||||
// fbo_out.enablePixelBuffer();
|
// fbo_out.enablePixelBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Renderer::addFramebufferEffect(FramebufferEffectBase * e) {
|
||||||
|
e->r = this;
|
||||||
|
fb_effects << e;
|
||||||
|
}
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
#define RENDERER_H
|
#define RENDERER_H
|
||||||
|
|
||||||
#include "glcubemap.h"
|
#include "glcubemap.h"
|
||||||
|
#include "glframebuffereffectbase.h"
|
||||||
#include "renderer_base.h"
|
#include "renderer_base.h"
|
||||||
#include "renderer_material.h"
|
#include "renderer_material.h"
|
||||||
#include "renderer_selection.h"
|
#include "renderer_selection.h"
|
||||||
@@ -29,12 +30,13 @@
|
|||||||
#include <QQueue>
|
#include <QQueue>
|
||||||
|
|
||||||
|
|
||||||
class Renderer: public RendererBase {
|
class QGLENGINE_CORE_EXPORT Renderer: public RendererBase {
|
||||||
friend class QGLView;
|
friend class QGLView;
|
||||||
friend class MouseController;
|
friend class MouseController;
|
||||||
friend class RendererMaterial;
|
friend class RendererMaterial;
|
||||||
friend class RendererService;
|
friend class RendererService;
|
||||||
friend class RendererSelection;
|
friend class RendererSelection;
|
||||||
|
friend class FramebufferEffectBase;
|
||||||
friend class TonemappingProc;
|
friend class TonemappingProc;
|
||||||
enum ShaderRole {
|
enum ShaderRole {
|
||||||
// Selection
|
// Selection
|
||||||
@@ -55,23 +57,17 @@ class Renderer: public RendererBase {
|
|||||||
srFinalPass,
|
srFinalPass,
|
||||||
srTonemapPass,
|
srTonemapPass,
|
||||||
};
|
};
|
||||||
enum DeferredBufferRole {
|
|
||||||
dbrDiffuse,
|
|
||||||
dbrNormalZ,
|
|
||||||
dbrSpecularReflect,
|
|
||||||
dbrEmissionRough,
|
|
||||||
dbrSpeedBitangXY,
|
|
||||||
|
|
||||||
dbrBuffersCount,
|
|
||||||
};
|
|
||||||
enum OutBufferRole {
|
enum OutBufferRole {
|
||||||
obrTonemap,
|
|
||||||
obrSum,
|
|
||||||
obrSolidOmni,
|
obrSolidOmni,
|
||||||
obrSolidSpot,
|
obrSolidSpot,
|
||||||
obrTransparentOmni,
|
obrTransparentOmni,
|
||||||
obrTransparentSpot,
|
obrTransparentSpot,
|
||||||
|
|
||||||
|
obrGeneral0,
|
||||||
|
obrGeneral1,
|
||||||
|
obrGeneral2,
|
||||||
|
obrGeneral3,
|
||||||
|
|
||||||
obrBuffersCount,
|
obrBuffersCount,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -79,6 +75,19 @@ public:
|
|||||||
Renderer(QGLView * view_);
|
Renderer(QGLView * view_);
|
||||||
virtual ~Renderer();
|
virtual ~Renderer();
|
||||||
|
|
||||||
|
enum DeferredBufferRole {
|
||||||
|
dbrDiffuse,
|
||||||
|
dbrNormalZ,
|
||||||
|
dbrSpecularReflect,
|
||||||
|
dbrEmissionRough,
|
||||||
|
dbrSpeedBitangXY,
|
||||||
|
|
||||||
|
dbrNormalZSolid,
|
||||||
|
dbrSpecularReflectSolid,
|
||||||
|
|
||||||
|
dbrBuffersCount,
|
||||||
|
};
|
||||||
|
|
||||||
void init(int width, int height);
|
void init(int width, int height);
|
||||||
void resize(int width, int height);
|
void resize(int width, int height);
|
||||||
void reloadShaders();
|
void reloadShaders();
|
||||||
@@ -88,6 +97,8 @@ public:
|
|||||||
void setGrabImage(bool on);
|
void setGrabImage(bool on);
|
||||||
bool isGrabImage() const { return is_grabbing; }
|
bool isGrabImage() const { return is_grabbing; }
|
||||||
QImage getImage() const { return last_img; }
|
QImage getImage() const { return last_img; }
|
||||||
|
void addFramebufferEffect(FramebufferEffectBase * e);
|
||||||
|
void clearFramebufferEffects() { fb_effects.clear(); }
|
||||||
|
|
||||||
QImage materialThumbnail(Material * m) { return rend_mat.materialThumbnail(m); }
|
QImage materialThumbnail(Material * m) { return rend_mat.materialThumbnail(m); }
|
||||||
void recreateMaterialThumbnails(bool force_all = false) { rend_mat.recreateMaterialThumbnails(force_all); }
|
void recreateMaterialThumbnails(bool force_all = false) { rend_mat.recreateMaterialThumbnails(force_all); }
|
||||||
@@ -103,9 +114,11 @@ protected:
|
|||||||
void initShaders();
|
void initShaders();
|
||||||
void releaseShader();
|
void releaseShader();
|
||||||
|
|
||||||
|
QVector<int> getFreePlanes(int count);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float gamma_ = 1.f;
|
float gamma_ = 1.f;
|
||||||
int camera_light_mode;
|
int camera_light_mode, cur_write_plane = 0, prev_write_plane = 0;
|
||||||
bool edit_mode, need_init_shaders, need_render_sum;
|
bool edit_mode, need_init_shaders, need_render_sum;
|
||||||
Framebuffer fbo_ds, fbo_out;
|
Framebuffer fbo_ds, fbo_out;
|
||||||
QMap<ShaderRole, QString> shader_files;
|
QMap<ShaderRole, QString> shader_files;
|
||||||
@@ -129,6 +142,7 @@ private:
|
|||||||
QVector4D corner_dirs[4];
|
QVector4D corner_dirs[4];
|
||||||
QVector<QVector3D> hcontent;
|
QVector<QVector3D> hcontent;
|
||||||
QMap<int, QList<Light *>> cur_lights;
|
QMap<int, QList<Light *>> cur_lights;
|
||||||
|
QVector<FramebufferEffectBase *> fb_effects;
|
||||||
QImage last_img;
|
QImage last_img;
|
||||||
bool is_grabbing = false;
|
bool is_grabbing = false;
|
||||||
};
|
};
|
||||||
@@ -103,6 +103,7 @@ void RendererBase::setUniformCamera(QOpenGLShaderProgram * prog, Camera * cam, b
|
|||||||
prog->setUniformValue("z_near", cam->depthStart());
|
prog->setUniformValue("z_near", cam->depthStart());
|
||||||
}
|
}
|
||||||
prog->setUniformValue("dt", QVector2D(1. / w, 1. / h));
|
prog->setUniformValue("dt", QVector2D(1. / w, 1. / h));
|
||||||
|
prog->setUniformValue("qgl_ViewSize", QVector2D(w, h));
|
||||||
prog->setUniformValue("qgl_ViewMatrix", mat_view);
|
prog->setUniformValue("qgl_ViewMatrix", mat_view);
|
||||||
prog->setUniformValue("qgl_ViewProjMatrix", mat_proj * mat_view);
|
prog->setUniformValue("qgl_ViewProjMatrix", mat_proj * mat_view);
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
#include "gltexturearray.h"
|
#include "gltexturearray.h"
|
||||||
|
|
||||||
|
|
||||||
class RendererBase {
|
class QGLENGINE_CORE_EXPORT RendererBase {
|
||||||
public:
|
public:
|
||||||
RendererBase(QGLView * view_);
|
RendererBase(QGLView * view_);
|
||||||
~RendererBase();
|
~RendererBase();
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
#include <QQueue>
|
#include <QQueue>
|
||||||
|
|
||||||
|
|
||||||
class RendererMaterial {
|
class QGLENGINE_CORE_EXPORT RendererMaterial {
|
||||||
friend class QGLView;
|
friend class QGLView;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
|
||||||
|
|
||||||
class RendererSelection {
|
class QGLENGINE_CORE_EXPORT RendererSelection {
|
||||||
friend class QGLView;
|
friend class QGLView;
|
||||||
friend class MouseController;
|
friend class MouseController;
|
||||||
friend class Renderer;
|
friend class Renderer;
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
#include <QQueue>
|
#include <QQueue>
|
||||||
|
|
||||||
|
|
||||||
class RendererService {
|
class QGLENGINE_CORE_EXPORT RendererService {
|
||||||
friend class QGLView;
|
friend class QGLView;
|
||||||
friend class MouseController;
|
friend class MouseController;
|
||||||
friend class Renderer;
|
friend class Renderer;
|
||||||
@@ -31,7 +31,7 @@ TonemappingProc::TonemappingProc(Renderer * rend)
|
|||||||
: QThread()
|
: QThread()
|
||||||
, r(rend)
|
, r(rend)
|
||||||
, fbo_1x1(r->view, 1, false, GL_RGB32F)
|
, fbo_1x1(r->view, 1, false, GL_RGB32F)
|
||||||
, fbomm(r->fbo_out, Renderer::obrSum, 3)
|
, fbomm(r->fbo_out, Renderer::obrGeneral1, 3)
|
||||||
, buffer_vbo(GL_ARRAY_BUFFER, GL_DYNAMIC_DRAW) {
|
, buffer_vbo(GL_ARRAY_BUFFER, GL_DYNAMIC_DRAW) {
|
||||||
shader_sum = 0;
|
shader_sum = 0;
|
||||||
timer_delim = 0;
|
timer_delim = 0;
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
|
|
||||||
class TonemappingProc: public QThread {
|
class QGLENGINE_CORE_EXPORT TonemappingProc: public QThread {
|
||||||
friend class Renderer;
|
friend class Renderer;
|
||||||
friend class QGLView;
|
friend class QGLView;
|
||||||
|
|
||||||
@@ -22,9 +22,9 @@
|
|||||||
#include "globject.h"
|
#include "globject.h"
|
||||||
|
|
||||||
|
|
||||||
class Camera: public AimedObject {
|
class QGLENGINE_CORE_EXPORT Camera: public AimedObject {
|
||||||
friend QDataStream & operator<<(QDataStream & s, const ObjectBase * p);
|
friend QGLENGINE_CORE_EXPORT QDataStream & operator<<(QDataStream & s, const ObjectBase * p);
|
||||||
friend QDataStream & operator>>(QDataStream & s, ObjectBase *& p);
|
friend QGLENGINE_CORE_EXPORT QDataStream & operator>>(QDataStream & s, ObjectBase *& p);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Camera();
|
Camera();
|
||||||
@@ -25,12 +25,12 @@
|
|||||||
#include "gltypes.h"
|
#include "gltypes.h"
|
||||||
|
|
||||||
|
|
||||||
class ObjectBase {
|
class QGLENGINE_CORE_EXPORT ObjectBase {
|
||||||
friend class Scene;
|
friend class Scene;
|
||||||
friend class RendererSelection;
|
friend class RendererSelection;
|
||||||
friend QDataStream & operator<<(QDataStream & s, const ObjectBase * p);
|
friend QGLENGINE_CORE_EXPORT QDataStream & operator<<(QDataStream & s, const ObjectBase * p);
|
||||||
friend QDataStream & operator>>(QDataStream & s, ObjectBase *& p);
|
friend QGLENGINE_CORE_EXPORT QDataStream & operator>>(QDataStream & s, ObjectBase *& p);
|
||||||
friend QDataStream & operator>>(QDataStream & s, Scene *& p);
|
friend QGLENGINE_CORE_EXPORT QDataStream & operator>>(QDataStream & s, Scene *& p);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Type {
|
enum Type {
|
||||||
@@ -350,7 +350,7 @@ inline bool operator<(const ObjectBase & f, const ObjectBase & s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class AimedObject: public ObjectBase {
|
class QGLENGINE_CORE_EXPORT AimedObject: public ObjectBase {
|
||||||
friend class QGLView;
|
friend class QGLView;
|
||||||
friend class GLRendererBase;
|
friend class GLRendererBase;
|
||||||
friend class Light;
|
friend class Light;
|
||||||
@@ -390,7 +390,7 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Light: public AimedObject {
|
class QGLENGINE_CORE_EXPORT Light: public AimedObject {
|
||||||
friend class QGLView;
|
friend class QGLView;
|
||||||
friend class RendererBase;
|
friend class RendererBase;
|
||||||
|
|
||||||
@@ -434,8 +434,8 @@ inline T globject_cast(const ObjectBase * object) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QDataStream & operator<<(QDataStream & s, const ObjectBase * p);
|
QGLENGINE_CORE_EXPORT QDataStream & operator<<(QDataStream & s, const ObjectBase * p);
|
||||||
QDataStream & operator>>(QDataStream & s, ObjectBase *& p);
|
QGLENGINE_CORE_EXPORT QDataStream & operator>>(QDataStream & s, ObjectBase *& p);
|
||||||
|
|
||||||
inline ObjectBaseList lights2objectList(const QList<Light *> & v) {
|
inline ObjectBaseList lights2objectList(const QList<Light *> & v) {
|
||||||
ObjectBaseList ret;
|
ObjectBaseList ret;
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
#include "gltypes.h"
|
#include "gltypes.h"
|
||||||
|
|
||||||
|
|
||||||
class Scene: public QObject {
|
class QGLENGINE_CORE_EXPORT Scene: public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
friend class RendererBase;
|
friend class RendererBase;
|
||||||
friend class Renderer;
|
friend class Renderer;
|
||||||
@@ -31,8 +31,8 @@ class Scene: public QObject {
|
|||||||
friend class RendererSelection;
|
friend class RendererSelection;
|
||||||
friend class ObjectBase;
|
friend class ObjectBase;
|
||||||
friend class Light;
|
friend class Light;
|
||||||
friend QDataStream & operator<<(QDataStream & s, const Scene * p);
|
friend QGLENGINE_CORE_EXPORT QDataStream & operator<<(QDataStream & s, const Scene * p);
|
||||||
friend QDataStream & operator>>(QDataStream & s, Scene *& p);
|
friend QGLENGINE_CORE_EXPORT QDataStream & operator>>(QDataStream & s, Scene *& p);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Scene();
|
explicit Scene();
|
||||||
@@ -138,7 +138,7 @@ signals:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
QDataStream & operator<<(QDataStream & s, const Scene * p);
|
QGLENGINE_CORE_EXPORT QDataStream & operator<<(QDataStream & s, const Scene * p);
|
||||||
QDataStream & operator>>(QDataStream & s, Scene *& p);
|
QGLENGINE_CORE_EXPORT QDataStream & operator>>(QDataStream & s, Scene *& p);
|
||||||
|
|
||||||
#endif // GLSCENE_H
|
#endif // GLSCENE_H
|
||||||
19
src/core/shaders.qrc
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/">
|
||||||
|
<file>../../shaders/ds_final.glsl</file>
|
||||||
|
<file>../../shaders/ds_geom.glsl</file>
|
||||||
|
<file>../../shaders/ds_light.glsl</file>
|
||||||
|
<file>../../shaders/ds_tonemap.glsl</file>
|
||||||
|
<file>../../shaders/fxaa.frag</file>
|
||||||
|
<file>../../shaders/fxaa.vert</file>
|
||||||
|
<file>../../shaders/fxaa_v3.h</file>
|
||||||
|
<file>../../shaders/selection.glsl</file>
|
||||||
|
<file>../../shaders/selection_apply.glsl</file>
|
||||||
|
<file>../../shaders/selection_frame.glsl</file>
|
||||||
|
<file>../../shaders/selection_halo.glsl</file>
|
||||||
|
<file>../../shaders/service_fill.glsl</file>
|
||||||
|
<file>../../shaders/service_frame.glsl</file>
|
||||||
|
<file>../../shaders/service_line.glsl</file>
|
||||||
|
<file>../../shaders/sum.glsl</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
||||||
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 158 B After Width: | Height: | Size: 158 B |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 8.4 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |