diff --git a/CMakeLists.txt b/CMakeLists.txt index d834797..f050970 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,9 @@ if (POLICY CMP0054) cmake_policy(SET CMP0054 NEW) endif() project(QGLEngine) +if (NOT DEFINED SHSTKPROJECT) + include(SHSTKQtMacros) +endif() find_package(QAD REQUIRED) shstk_qt_founded(QtVersions) set(_qgl_ok 0) @@ -19,9 +22,8 @@ endif() if (NOT _qgl_ok) message(WARNING "Building ${PROJECT_NAME} available only on Qt5/6!") else() - qad_find_qt(Core Gui OpenGL OpenGLWidgets Xml) - find_package(OpenGL REQUIRED) include(SHSTKQtMacros) + include_directories("c:/sdk/MinGW/x32/lib/gcc/i686-w64-mingw32/8.1.0/include") set(QGLEngine_MAJOR 1) set(QGLEngine_MINOR 0) @@ -35,45 +37,11 @@ else() endif() shstk_begin_project(QGLEngine) + set(_qglengine_root_build "${CMAKE_CURRENT_BINARY_DIR}") - qad_sources(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) + add_subdirectory(src) 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") install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules) diff --git a/core/glprimitives.h b/core/glprimitives.h deleted file mode 100644 index 9e88f9d..0000000 --- a/core/glprimitives.h +++ /dev/null @@ -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 . -*/ - -#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 diff --git a/qglview.qrc b/qglview.qrc deleted file mode 100644 index e67f617..0000000 --- a/qglview.qrc +++ /dev/null @@ -1,46 +0,0 @@ - - - coeffs_brdf.png - icons/add-type-camera.png - icons/add-type-geo.png - icons/add-type-light.png - icons/add-type-empty.png - icons/collapse.png - icons/expand.png - icons/edit-rename.png - icons/alpha.png - icons/application-exit.png - icons/configure.png - icons/dialog-close.png - icons/document-edit.png - icons/document-import.png - icons/document-new.png - icons/document-open.png - icons/document-save.png - icons/document-save-all.png - icons/edit-clear.png - icons/edit-clear-locationbar-rtl.png - icons/edit-copy.png - icons/edit-delete.png - icons/edit-find.png - icons/edit-paste.png - icons/go-jump.png - icons/go-top.png - icons/layer-visible-on.png - icons/layer-visible-off.png - icons/light-+.png - icons/list-add.png - icons/object-flip-horizontal.png - icons/object-flip-vertical.png - icons/picker.png - icons/qglview.png - icons/transform-move.png - icons/transform-rotate.png - icons/transform-scale.png - icons/type-camera.png - icons/type-geo.png - icons/type-light.png - icons/type-empty.png - icons/view-refresh.png - - diff --git a/shaders.qrc b/shaders.qrc deleted file mode 100644 index 97e4492..0000000 --- a/shaders.qrc +++ /dev/null @@ -1,19 +0,0 @@ - - - shaders/ds_final.glsl - shaders/ds_geom.glsl - shaders/ds_light.glsl - shaders/ds_tonemap.glsl - shaders/fxaa.frag - shaders/fxaa.vert - shaders/fxaa_v3.h - shaders/selection.glsl - shaders/selection_apply.glsl - shaders/selection_frame.glsl - shaders/selection_halo.glsl - shaders/service_fill.glsl - shaders/service_frame.glsl - shaders/service_line.glsl - shaders/sum.glsl - - diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..979f0b9 --- /dev/null +++ b/src/CMakeLists.txt @@ -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() diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt new file mode 100644 index 0000000..fabb74e --- /dev/null +++ b/src/core/CMakeLists.txt @@ -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") diff --git a/coeffs_brdf.png b/src/core/coeffs_brdf.png similarity index 100% rename from coeffs_brdf.png rename to src/core/coeffs_brdf.png diff --git a/core/glbuffer.cpp b/src/core/core/glbuffer.cpp similarity index 100% rename from core/glbuffer.cpp rename to src/core/core/glbuffer.cpp diff --git a/core/glbuffer.h b/src/core/core/glbuffer.h similarity index 97% rename from core/glbuffer.h rename to src/core/core/glbuffer.h index 986ce43..2b54951 100644 --- a/core/glbuffer.h +++ b/src/core/core/glbuffer.h @@ -22,7 +22,7 @@ #include "gltypes.h" -class Buffer { +class QGLENGINE_CORE_EXPORT Buffer { friend class ObjectBase; public: diff --git a/core/glcubemap.cpp b/src/core/core/glcubemap.cpp similarity index 100% rename from core/glcubemap.cpp rename to src/core/core/glcubemap.cpp diff --git a/core/glcubemap.h b/src/core/core/glcubemap.h similarity index 91% rename from core/glcubemap.h rename to src/core/core/glcubemap.h index 744a844..54b052d 100644 --- a/core/glcubemap.h +++ b/src/core/core/glcubemap.h @@ -22,9 +22,9 @@ #include "chunkstream.h" #include "glshaders_types.h" -QVector loadFileHDR(const QString & path, QSize * size = 0); +QVector QGLENGINE_CORE_EXPORT loadFileHDR(const QString & path, QSize * size = 0); -class CubeTexture { +class QGLENGINE_CORE_EXPORT CubeTexture { public: CubeTexture(QOpenGLExtraFunctions * f_, int _size, const GLenum & _format = GL_RGB16F); bool init(); diff --git a/core/glframebuffer.cpp b/src/core/core/glframebuffer.cpp similarity index 100% rename from core/glframebuffer.cpp rename to src/core/core/glframebuffer.cpp diff --git a/core/glframebuffer.h b/src/core/core/glframebuffer.h similarity index 98% rename from core/glframebuffer.h rename to src/core/core/glframebuffer.h index 242a73f..955f155 100644 --- a/core/glframebuffer.h +++ b/src/core/core/glframebuffer.h @@ -22,7 +22,7 @@ #include "glbuffer.h" -class Framebuffer { +class QGLENGINE_CORE_EXPORT Framebuffer { friend class FramebufferMipmap; public: diff --git a/core/glframebuffer_mipmap.cpp b/src/core/core/glframebuffer_mipmap.cpp similarity index 100% rename from core/glframebuffer_mipmap.cpp rename to src/core/core/glframebuffer_mipmap.cpp diff --git a/core/glframebuffer_mipmap.h b/src/core/core/glframebuffer_mipmap.h similarity index 97% rename from core/glframebuffer_mipmap.h rename to src/core/core/glframebuffer_mipmap.h index 29a5164..8a5c809 100644 --- a/core/glframebuffer_mipmap.h +++ b/src/core/core/glframebuffer_mipmap.h @@ -22,7 +22,7 @@ #include "glframebuffer.h" -class FramebufferMipmap { +class QGLENGINE_CORE_EXPORT FramebufferMipmap { public: FramebufferMipmap(const Framebuffer & fb, int index_from_, int levels = 2); virtual ~FramebufferMipmap(); diff --git a/src/core/core/glframebuffereffectbase.cpp b/src/core/core/glframebuffereffectbase.cpp new file mode 100644 index 0000000..4742dee --- /dev/null +++ b/src/core/core/glframebuffereffectbase.cpp @@ -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 . +*/ + +#include "glframebuffereffectbase.h" + +#include "renderer.h" + +#include + + +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 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; +} diff --git a/src/core/core/glframebuffereffectbase.h b/src/core/core/glframebuffereffectbase.h new file mode 100644 index 0000000..fe3174f --- /dev/null +++ b/src/core/core/glframebuffereffectbase.h @@ -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 . +*/ + +#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 getFreePlanes(int count); + int previousOutputPlane() const; + static void deleteShader(QOpenGLShaderProgram *& s); + +private: + bool is_loaded = false; + Renderer * r = nullptr; + GLint wid, hei; +}; + +#endif diff --git a/core/glmaterial.cpp b/src/core/core/glmaterial.cpp similarity index 100% rename from core/glmaterial.cpp rename to src/core/core/glmaterial.cpp diff --git a/core/glmaterial.h b/src/core/core/glmaterial.h similarity index 97% rename from core/glmaterial.h rename to src/core/core/glmaterial.h index c0ffa06..dd7f80a 100644 --- a/core/glmaterial.h +++ b/src/core/core/glmaterial.h @@ -23,7 +23,7 @@ #include "glshaders_types.h" -class Map { +class QGLENGINE_CORE_EXPORT Map { public: Map(); void setBitmapPath(const QString & p); @@ -43,7 +43,7 @@ public: int _type, _layer; }; -class Material { +class QGLENGINE_CORE_EXPORT Material { public: Material(const QString _name = QString()); uint hash(); diff --git a/core/glmesh.cpp b/src/core/core/glmesh.cpp similarity index 100% rename from core/glmesh.cpp rename to src/core/core/glmesh.cpp diff --git a/core/glmesh.h b/src/core/core/glmesh.h similarity index 95% rename from core/glmesh.h rename to src/core/core/glmesh.h index dfe205c..6683990 100644 --- a/core/glmesh.h +++ b/src/core/core/glmesh.h @@ -24,7 +24,7 @@ #include -class Mesh { +class QGLENGINE_CORE_EXPORT Mesh { friend QDataStream & operator<<(QDataStream & s, const Mesh * m); friend QDataStream & operator>>(QDataStream & s, Mesh *& m); @@ -117,7 +117,7 @@ private: }; -QDataStream & operator<<(QDataStream & s, const Mesh * m); -QDataStream & operator>>(QDataStream & s, Mesh *& m); +QGLENGINE_CORE_EXPORT QDataStream & operator<<(QDataStream & s, const Mesh * m); +QGLENGINE_CORE_EXPORT QDataStream & operator>>(QDataStream & s, Mesh *& m); #endif // GLMESH_H diff --git a/core/glprimitives.cpp b/src/core/core/glprimitives.cpp similarity index 100% rename from core/glprimitives.cpp rename to src/core/core/glprimitives.cpp diff --git a/src/core/core/glprimitives.h b/src/core/core/glprimitives.h new file mode 100644 index 0000000..176cf7d --- /dev/null +++ b/src/core/core/glprimitives.h @@ -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 . +*/ + +#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 diff --git a/core/glshaders.cpp b/src/core/core/glshaders.cpp similarity index 99% rename from core/glshaders.cpp rename to src/core/core/glshaders.cpp index 3b414d1..d870a63 100644 --- a/core/glshaders.cpp +++ b/src/core/core/glshaders.cpp @@ -67,6 +67,7 @@ QString prepareDefines(const QStringList & defines) { bool QGLEngineShaders::loadShadersMulti(QOpenGLShaderProgram *& prog, const QString & file, bool add_qgl, const QStringList & defines) { if (!prog) prog = new QOpenGLShaderProgram(); + prog->removeAllShaders(); QFile f(file); if (!f.open(QIODevice::ReadOnly)) { qDebug() << "[QGLEngine] Shader" << file << "Error: can`t open file!"; diff --git a/core/glshaders.h b/src/core/core/glshaders.h similarity index 73% rename from core/glshaders.h rename to src/core/core/glshaders.h index f513cd5..ce94acd 100644 --- a/core/glshaders.h +++ b/src/core/core/glshaders.h @@ -23,8 +23,10 @@ namespace QGLEngineShaders { -bool loadShadersMulti(QOpenGLShaderProgram *& prog, const QString & file, bool add_qgl = true, const QStringList & defines = QStringList()); -bool loadShaders(QOpenGLShaderProgram *& prog, const QStringList & files, bool add_qgl = true, const QStringList & defines = QStringList()); +QGLENGINE_CORE_EXPORT bool +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 diff --git a/core/glshaders_headers.h b/src/core/core/glshaders_headers.h similarity index 99% rename from core/glshaders_headers.h rename to src/core/core/glshaders_headers.h index bcdada9..c225070 100644 --- a/core/glshaders_headers.h +++ b/src/core/core/glshaders_headers.h @@ -50,6 +50,7 @@ const char qgl_fragment_head[] = "in vec2 qgl_FragTexture;\n" "flat in uint qgl_MaterialIndex;\n" "out vec4 qgl_FragData[gl_MaxDrawBuffers];\n" + "uniform vec2 qgl_ViewSize;\n" "vec4 qgl_materialTexture(uint type, vec2 coord, vec4 tex_shift) {\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" diff --git a/core/glshaders_types.cpp b/src/core/core/glshaders_types.cpp similarity index 100% rename from core/glshaders_types.cpp rename to src/core/core/glshaders_types.cpp diff --git a/core/glshaders_types.h b/src/core/core/glshaders_types.h similarity index 100% rename from core/glshaders_types.h rename to src/core/core/glshaders_types.h diff --git a/core/gltexturearray.cpp b/src/core/core/gltexturearray.cpp similarity index 100% rename from core/gltexturearray.cpp rename to src/core/core/gltexturearray.cpp diff --git a/core/gltexturearray.h b/src/core/core/gltexturearray.h similarity index 97% rename from core/gltexturearray.h rename to src/core/core/gltexturearray.h index 7609f13..2121561 100644 --- a/core/gltexturearray.h +++ b/src/core/core/gltexturearray.h @@ -22,7 +22,7 @@ #include "gltypes.h" -class Texture2DArray { +class QGLENGINE_CORE_EXPORT Texture2DArray { public: Texture2DArray(bool filter); ~Texture2DArray(); diff --git a/core/gltransform.cpp b/src/core/core/gltransform.cpp similarity index 100% rename from core/gltransform.cpp rename to src/core/core/gltransform.cpp diff --git a/core/gltransform.h b/src/core/core/gltransform.h similarity index 97% rename from core/gltransform.h rename to src/core/core/gltransform.h index a6ab882..f0b45b1 100644 --- a/core/gltransform.h +++ b/src/core/core/gltransform.h @@ -19,13 +19,15 @@ #ifndef GLTRANSFORM_H #define GLTRANSFORM_H +#include "qglengine_core_export.h" + #include #include #include #include -class Transform { +class QGLENGINE_CORE_EXPORT Transform { friend QDataStream & operator>>(QDataStream & s, Transform & v); public: diff --git a/core/gltypes.cpp b/src/core/core/gltypes.cpp similarity index 100% rename from core/gltypes.cpp rename to src/core/core/gltypes.cpp diff --git a/core/gltypes.h b/src/core/core/gltypes.h similarity index 85% rename from core/gltypes.h rename to src/core/core/gltypes.h index 51d83f7..5c52cc4 100644 --- a/core/gltypes.h +++ b/src/core/core/gltypes.h @@ -179,8 +179,8 @@ inline float urand(const float & scale = 1.) { inline float uprand(const float & scale = 1.) { return ((float)rand() / RAND_MAX) * scale; } -QString readCharsUntilNull(QDataStream & s); -QString findFile(const QString & file, const QStringList & pathes); +QGLENGINE_CORE_EXPORT QString readCharsUntilNull(QDataStream & s); +QGLENGINE_CORE_EXPORT QString findFile(const QString & file, const QStringList & pathes); inline QColor operator*(const QColor & c, float v) { return QColor(piClamp(c.red() * v, 0, 255), piClamp(c.green() * v, 0, 255), @@ -216,29 +216,29 @@ inline void deleteGLTexture(QOpenGLExtraFunctions * f, GLuint & tex) { if (tex != 0) f->glDeleteTextures(1, &tex); tex = 0; } -void glEnableDepth(); -void glDisableDepth(); -void glClearFramebuffer(const QColor & color = Qt::black, bool depth = true); -void glDrawQuad(QOpenGLShaderProgram * prog = nullptr, - QVector4D * corner_dirs = nullptr, - GLfloat x = -1.f, - GLfloat y = -1.f, - GLfloat w = 2.f, - GLfloat h = 2.f); -void createGLTexture(QOpenGLExtraFunctions * f, - GLuint & tex, - int width, - int height, - const GLenum & format = GL_RGBA, - const GLenum & target = GL_TEXTURE_2D); -void createGLTexture(QOpenGLExtraFunctions * f, - GLuint & tex, - const QImage & image, - const GLenum & format = GL_RGBA, - const GLenum & target = GL_TEXTURE_2D); -QMatrix4x4 glMatrixPerspective(float angle, float aspect, float near_); -QImage rotateQImageLeft(const QImage & im); -QImage rotateQImageRight(const QImage & im); +QGLENGINE_CORE_EXPORT void glEnableDepth(); +QGLENGINE_CORE_EXPORT void glDisableDepth(); +QGLENGINE_CORE_EXPORT void glClearFramebuffer(const QColor & color = Qt::black, bool depth = true); +QGLENGINE_CORE_EXPORT void glDrawQuad(QOpenGLShaderProgram * prog = nullptr, + QVector4D * corner_dirs = nullptr, + GLfloat x = -1.f, + GLfloat y = -1.f, + GLfloat w = 2.f, + GLfloat h = 2.f); +QGLENGINE_CORE_EXPORT void createGLTexture(QOpenGLExtraFunctions * f, + GLuint & tex, + int width, + int height, + const GLenum & format = GL_RGBA, + const GLenum & target = GL_TEXTURE_2D); +QGLENGINE_CORE_EXPORT void createGLTexture(QOpenGLExtraFunctions * f, + GLuint & tex, + const QImage & image, + const GLenum & format = GL_RGBA, + const GLenum & target = GL_TEXTURE_2D); +QGLENGINE_CORE_EXPORT QMatrix4x4 glMatrixPerspective(float angle, float aspect, float near_); +QGLENGINE_CORE_EXPORT QImage rotateQImageLeft(const QImage & im); +QGLENGINE_CORE_EXPORT QImage rotateQImageRight(const QImage & im); inline QImage rotateQImage180(const QImage & im) { return im.mirrored(true, true); } @@ -257,6 +257,7 @@ class TextureManager; class Texture2DArray; class Framebuffer; class FramebufferMipmap; +class FramebufferEffectBase; class VertexObject; class Mesh; class Scene; @@ -273,7 +274,7 @@ enum RenderPass { typedef QList ObjectBaseList; -struct Box3D { +struct QGLENGINE_CORE_EXPORT Box3D { GLfloat x; GLfloat y; GLfloat z; @@ -352,7 +353,7 @@ inline QDebug operator<<(QDebug d, const Box3D & v) { #pragma pack(push, 1) -struct Vector2i { +struct QGLENGINE_CORE_EXPORT Vector2i { Vector2i(int p0_ = 0, int p1_ = 0) { p0 = p0_; p1 = p1_; @@ -401,7 +402,7 @@ inline QDataStream & operator>>(QDataStream & s, Vector2i & v) { #pragma pack(push, 1) -struct Vector3i { +struct QGLENGINE_CORE_EXPORT Vector3i { Vector3i(int p0_ = 0, int p1_ = 0, int p2_ = 0) { p0 = p0_; p1 = p1_; @@ -453,8 +454,8 @@ inline QDataStream & operator>>(QDataStream & s, Vector3i & v) { } -QVector3D vectorFromString(const QString & str); -QColor colorFromString(const QString & str); +QGLENGINE_CORE_EXPORT QVector3D vectorFromString(const QString & str); +QGLENGINE_CORE_EXPORT QColor colorFromString(const QString & str); inline QVector4D QColor2QVector(const QColor & c) { 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) { return to.normalized() * v.length() * cosABV(v, to); } -QVector3D orthToVector(const QVector3D & v, const float & scale = 1.); -QVector3D rotateVector(const QVector3D & v, const QVector3D & a); -void setVectorLength(QVector3D & v, const float & l); -void lengthenVector(QVector3D & v, const float & l); +QGLENGINE_CORE_EXPORT QVector3D orthToVector(const QVector3D & v, const float & scale = 1.); +QGLENGINE_CORE_EXPORT QVector3D rotateVector(const QVector3D & v, const QVector3D & a); +QGLENGINE_CORE_EXPORT void setVectorLength(QVector3D & v, const float & l); +QGLENGINE_CORE_EXPORT void lengthenVector(QVector3D & v, const float & l); 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()) + (to.z() - from.z()) * (to.z() - from.z()); diff --git a/core/glvertexobject.cpp b/src/core/core/glvertexobject.cpp similarity index 100% rename from core/glvertexobject.cpp rename to src/core/core/glvertexobject.cpp diff --git a/core/glvertexobject.h b/src/core/core/glvertexobject.h similarity index 97% rename from core/glvertexobject.h rename to src/core/core/glvertexobject.h index 9e88ab4..5ef048d 100644 --- a/core/glvertexobject.h +++ b/src/core/core/glvertexobject.h @@ -23,7 +23,7 @@ #include "glshaders_types.h" -class VertexObject { +class QGLENGINE_CORE_EXPORT VertexObject { public: VertexObject(); ~VertexObject(); diff --git a/core/hdr.cpp b/src/core/core/hdr.cpp similarity index 100% rename from core/hdr.cpp rename to src/core/core/hdr.cpp diff --git a/core/hdr_p.h b/src/core/core/hdr_p.h similarity index 100% rename from core/hdr_p.h rename to src/core/core/hdr_p.h diff --git a/formats/loader_assimp.cpp b/src/core/formats/loader_assimp.cpp similarity index 100% rename from formats/loader_assimp.cpp rename to src/core/formats/loader_assimp.cpp diff --git a/formats/loader_assimp.h b/src/core/formats/loader_assimp.h similarity index 87% rename from formats/loader_assimp.h rename to src/core/formats/loader_assimp.h index 086d25b..89ed9a1 100644 --- a/formats/loader_assimp.h +++ b/src/core/formats/loader_assimp.h @@ -21,7 +21,7 @@ #include "gltypes.h" -Scene * loadScene(const QString & filepath); -QStringList supportedFormats(); +QGLENGINE_CORE_EXPORT Scene * loadScene(const QString & filepath); +QGLENGINE_CORE_EXPORT QStringList supportedFormats(); #endif // LOADER_ASSIMP_H diff --git a/formats/loader_qgl.cpp b/src/core/formats/loader_qgl.cpp similarity index 100% rename from formats/loader_qgl.cpp rename to src/core/formats/loader_qgl.cpp diff --git a/formats/loader_qgl.h b/src/core/formats/loader_qgl.h similarity index 83% rename from formats/loader_qgl.h rename to src/core/formats/loader_qgl.h index 42060f9..6c0b447 100644 --- a/formats/loader_qgl.h +++ b/src/core/formats/loader_qgl.h @@ -23,7 +23,7 @@ #include -Scene * loadFromQGLFile(const QString & filepath); -bool saveToQGLFile(const QString & filepath, const Scene * scene); +QGLENGINE_CORE_EXPORT Scene * loadFromQGLFile(const QString & filepath); +QGLENGINE_CORE_EXPORT bool saveToQGLFile(const QString & filepath, const Scene * scene); #endif // LOADER_QGL_H diff --git a/glwidget.cpp b/src/core/glwidget.cpp similarity index 100% rename from glwidget.cpp rename to src/core/glwidget.cpp diff --git a/glwidget.h b/src/core/glwidget.h similarity index 97% rename from glwidget.h rename to src/core/glwidget.h index 81faae6..4fb7e52 100644 --- a/glwidget.h +++ b/src/core/glwidget.h @@ -19,6 +19,8 @@ #ifndef GLWIDGET_H #define GLWIDGET_H +#include "qglengine_core_export.h" + #include @@ -26,7 +28,7 @@ class QGLView; class ObjectBase; class Scene; -class GLWidget: public QWidget { +class QGLENGINE_CORE_EXPORT GLWidget: public QWidget { Q_OBJECT Q_PROPERTY(qreal lineWidth READ lineWidth WRITE setLineWidth) Q_PROPERTY(qreal FOV READ FOV WRITE setFOV) diff --git a/mouse_controller.cpp b/src/core/mouse_controller.cpp similarity index 100% rename from mouse_controller.cpp rename to src/core/mouse_controller.cpp diff --git a/mouse_controller.h b/src/core/mouse_controller.h similarity index 97% rename from mouse_controller.h rename to src/core/mouse_controller.h index 8e9fd82..448afd0 100644 --- a/mouse_controller.h +++ b/src/core/mouse_controller.h @@ -27,7 +27,7 @@ #include -class MouseController: public QObject { +class QGLENGINE_CORE_EXPORT MouseController: public QObject { friend class QGLView; friend class RendererSelection; Q_OBJECT diff --git a/openglwindow.cpp b/src/core/openglwindow.cpp similarity index 100% rename from openglwindow.cpp rename to src/core/openglwindow.cpp diff --git a/openglwindow.h b/src/core/openglwindow.h similarity index 91% rename from openglwindow.h rename to src/core/openglwindow.h index 7a124f9..3e469e7 100644 --- a/openglwindow.h +++ b/src/core/openglwindow.h @@ -1,3 +1,5 @@ +#include "qglengine_core_export.h" + #include #include @@ -6,7 +8,7 @@ class QOpenGLContext; class QOpenGLPaintDevice; -class OpenGLWindow +class QGLENGINE_CORE_EXPORT OpenGLWindow : public QWindow , public QOpenGLExtraFunctions { Q_OBJECT diff --git a/src/core/qglengine_core.qrc b/src/core/qglengine_core.qrc new file mode 100644 index 0000000..52a6abf --- /dev/null +++ b/src/core/qglengine_core.qrc @@ -0,0 +1,46 @@ + + + coeffs_brdf.png + ../icons/add-type-camera.png + ../icons/add-type-geo.png + ../icons/add-type-light.png + ../icons/add-type-empty.png + ../icons/collapse.png + ../icons/expand.png + ../icons/edit-rename.png + ../icons/alpha.png + ../icons/application-exit.png + ../icons/configure.png + ../icons/dialog-close.png + ../icons/document-edit.png + ../icons/document-import.png + ../icons/document-new.png + ../icons/document-open.png + ../icons/document-save.png + ../icons/document-save-all.png + ../icons/edit-clear.png + ../icons/edit-clear-locationbar-rtl.png + ../icons/edit-copy.png + ../icons/edit-delete.png + ../icons/edit-find.png + ../icons/edit-paste.png + ../icons/go-jump.png + ../icons/go-top.png + ../icons/layer-visible-on.png + ../icons/layer-visible-off.png + ../icons/light-+.png + ../icons/list-add.png + ../icons/object-flip-horizontal.png + ../icons/object-flip-vertical.png + ../icons/picker.png + ../icons/qglview.png + ../icons/transform-move.png + ../icons/transform-rotate.png + ../icons/transform-scale.png + ../icons/type-camera.png + ../icons/type-geo.png + ../icons/type-light.png + ../icons/type-empty.png + ../icons/view-refresh.png + + diff --git a/qglview.cpp b/src/core/qglview.cpp similarity index 100% rename from qglview.cpp rename to src/core/qglview.cpp diff --git a/qglview.h b/src/core/qglview.h similarity index 99% rename from qglview.h rename to src/core/qglview.h index eba1263..a9c9833 100644 --- a/qglview.h +++ b/src/core/qglview.h @@ -25,13 +25,13 @@ #include "glscene.h" #include "mouse_controller.h" #include "openglwindow.h" +#include "qglengine_core_export.h" #include "renderer.h" #include #include - -class QGLView: public OpenGLWindow { +class QGLENGINE_CORE_EXPORT QGLView: public OpenGLWindow { friend class RendererSelection; Q_OBJECT Q_PROPERTY(float lineWidth READ lineWidth WRITE setLineWidth) diff --git a/gltexture_manager.cpp b/src/core/render/gltexture_manager.cpp similarity index 100% rename from gltexture_manager.cpp rename to src/core/render/gltexture_manager.cpp diff --git a/gltexture_manager.h b/src/core/render/gltexture_manager.h similarity index 96% rename from gltexture_manager.h rename to src/core/render/gltexture_manager.h index f77c1e4..bfc0e08 100644 --- a/gltexture_manager.h +++ b/src/core/render/gltexture_manager.h @@ -19,6 +19,8 @@ #ifndef GLTEXTUREMANAGER_H #define GLTEXTUREMANAGER_H +#include "qglengine_core_export.h" + #include #include #include @@ -26,7 +28,7 @@ #include -class TextureManager { +class QGLENGINE_CORE_EXPORT TextureManager { public: TextureManager(QOpenGLExtraFunctions * f_): f(f_) {} virtual ~TextureManager() {} diff --git a/renderer.cpp b/src/core/render/renderer.cpp similarity index 86% rename from renderer.cpp rename to src/core/render/renderer.cpp index 6c4bda1..4e2ee12 100644 --- a/renderer.cpp +++ b/src/core/render/renderer.cpp @@ -33,7 +33,7 @@ using namespace QGLEngineShaders; Renderer::Renderer(QGLView * view_) : RendererBase(view_) - , fbo_ds(view_, QVector() << GL_RGBA16F << GL_RGBA32F << GL_RGBA16F << GL_RGBA16F << GL_RGBA16F) + , fbo_ds(view_, QVector() << GL_RGBA16F << GL_RGBA32F << GL_RGBA16F << GL_RGBA16F << GL_RGBA16F << GL_RGBA32F << GL_RGBA16F) , fbo_out(view_, obrBuffersCount, false, GL_RGBA16F) , rend_mat(this) , rend_service(this) @@ -127,6 +127,10 @@ void Renderer::reloadShaders() { << "FXAA_GLSL_130 1" << "FXAA_QUALITY__PRESET 15"; 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; view->scene()->setLightsChanged(); view->scene()->setTreeStructChanged(); @@ -193,6 +197,27 @@ void Renderer::releaseShader() { } +QVector Renderer::getFreePlanes(int count) { + prev_write_plane = cur_write_plane; + QVector 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) { cur_objects_.resize(ol.size()); for (int i = 0; i < ol.size(); ++i) { @@ -328,6 +353,8 @@ void Renderer::renderScene() { textures_maps.bind(f, tarMaps); 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(); /// lighting passes @@ -336,7 +363,9 @@ void Renderer::renderScene() { /// transparent geometry pass fbo_ds.bind(); glEnableDepth(); + fbo_ds.setWriteBuffers({0, 1, 2, 3, 4}); glClearFramebuffer(Qt::black, false); + fbo_ds.setWriteBuffers(); if (bindShader(srGeometryPass, &prog)) { renderObjects(scene, rpTransparent); } @@ -351,30 +380,50 @@ void Renderer::renderScene() { fbo_out.bindColorTexture(obrSolidSpot, 2); fbo_out.bindColorTexture(obrTransparentOmni, 3); fbo_out.bindColorTexture(obrTransparentSpot, 4); - fbo_out.setWriteBuffer(obrSum); + fbo_out.setWriteBuffer(obrGeneral0); renderQuad(prog, quad); } + cur_write_plane = obrGeneral0; + /// tonemapping tone_proc.process(); + auto free = getFreePlanes(0); if (bindShader(srTonemapPass, &prog)) { fbo_out.bind(); prog->setUniformValue("gamma", gamma_); prog->setUniformValue("frame_max", tone_proc.frameMax()); - fbo_out.bindColorTexture(obrSum, 0); - fbo_out.setWriteBuffer(obrTonemap); + fbo_out.bindColorTexture(prev_write_plane, 0); renderQuad(prog, quad); - fbo_out.release(); } 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 if (edit_mode) { - rend_selection.drawSelection(fbo_out, obrTonemap); + rend_selection.drawSelection(fbo_out, cur_write_plane); rend_service.renderService(); } 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) { fbo_out.queryImage(0); @@ -393,3 +442,9 @@ void Renderer::setGrabImage(bool on) { is_grabbing = on; // fbo_out.enablePixelBuffer(); } + + +void Renderer::addFramebufferEffect(FramebufferEffectBase * e) { + e->r = this; + fb_effects << e; +} diff --git a/renderer.h b/src/core/render/renderer.h similarity index 86% rename from renderer.h rename to src/core/render/renderer.h index 604e1af..2b76175 100644 --- a/renderer.h +++ b/src/core/render/renderer.h @@ -20,6 +20,7 @@ #define RENDERER_H #include "glcubemap.h" +#include "glframebuffereffectbase.h" #include "renderer_base.h" #include "renderer_material.h" #include "renderer_selection.h" @@ -29,12 +30,13 @@ #include -class Renderer: public RendererBase { +class QGLENGINE_CORE_EXPORT Renderer: public RendererBase { friend class QGLView; friend class MouseController; friend class RendererMaterial; friend class RendererService; friend class RendererSelection; + friend class FramebufferEffectBase; friend class TonemappingProc; enum ShaderRole { // Selection @@ -55,23 +57,17 @@ class Renderer: public RendererBase { srFinalPass, srTonemapPass, }; - enum DeferredBufferRole { - dbrDiffuse, - dbrNormalZ, - dbrSpecularReflect, - dbrEmissionRough, - dbrSpeedBitangXY, - - dbrBuffersCount, - }; enum OutBufferRole { - obrTonemap, - obrSum, obrSolidOmni, obrSolidSpot, obrTransparentOmni, obrTransparentSpot, + obrGeneral0, + obrGeneral1, + obrGeneral2, + obrGeneral3, + obrBuffersCount, }; @@ -79,6 +75,19 @@ public: Renderer(QGLView * view_); virtual ~Renderer(); + enum DeferredBufferRole { + dbrDiffuse, + dbrNormalZ, + dbrSpecularReflect, + dbrEmissionRough, + dbrSpeedBitangXY, + + dbrNormalZSolid, + dbrSpecularReflectSolid, + + dbrBuffersCount, + }; + void init(int width, int height); void resize(int width, int height); void reloadShaders(); @@ -88,6 +97,8 @@ public: void setGrabImage(bool on); bool isGrabImage() const { return is_grabbing; } QImage getImage() const { return last_img; } + void addFramebufferEffect(FramebufferEffectBase * e); + void clearFramebufferEffects() { fb_effects.clear(); } QImage materialThumbnail(Material * m) { return rend_mat.materialThumbnail(m); } void recreateMaterialThumbnails(bool force_all = false) { rend_mat.recreateMaterialThumbnails(force_all); } @@ -103,9 +114,11 @@ protected: void initShaders(); void releaseShader(); + QVector getFreePlanes(int count); + private: 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; Framebuffer fbo_ds, fbo_out; QMap shader_files; @@ -129,6 +142,7 @@ private: QVector4D corner_dirs[4]; QVector hcontent; QMap> cur_lights; + QVector fb_effects; QImage last_img; bool is_grabbing = false; }; diff --git a/renderer_base.cpp b/src/core/render/renderer_base.cpp similarity index 99% rename from renderer_base.cpp rename to src/core/render/renderer_base.cpp index 3e34869..3aa8700 100644 --- a/renderer_base.cpp +++ b/src/core/render/renderer_base.cpp @@ -103,6 +103,7 @@ void RendererBase::setUniformCamera(QOpenGLShaderProgram * prog, Camera * cam, b prog->setUniformValue("z_near", cam->depthStart()); } prog->setUniformValue("dt", QVector2D(1. / w, 1. / h)); + prog->setUniformValue("qgl_ViewSize", QVector2D(w, h)); prog->setUniformValue("qgl_ViewMatrix", mat_view); prog->setUniformValue("qgl_ViewProjMatrix", mat_proj * mat_view); } diff --git a/renderer_base.h b/src/core/render/renderer_base.h similarity index 98% rename from renderer_base.h rename to src/core/render/renderer_base.h index 75d4acb..8813af0 100644 --- a/renderer_base.h +++ b/src/core/render/renderer_base.h @@ -24,7 +24,7 @@ #include "gltexturearray.h" -class RendererBase { +class QGLENGINE_CORE_EXPORT RendererBase { public: RendererBase(QGLView * view_); ~RendererBase(); diff --git a/renderer_material.cpp b/src/core/render/renderer_material.cpp similarity index 100% rename from renderer_material.cpp rename to src/core/render/renderer_material.cpp diff --git a/renderer_material.h b/src/core/render/renderer_material.h similarity index 96% rename from renderer_material.h rename to src/core/render/renderer_material.h index d93e586..b62843a 100644 --- a/renderer_material.h +++ b/src/core/render/renderer_material.h @@ -24,7 +24,7 @@ #include -class RendererMaterial { +class QGLENGINE_CORE_EXPORT RendererMaterial { friend class QGLView; public: diff --git a/renderer_selection.cpp b/src/core/render/renderer_selection.cpp similarity index 100% rename from renderer_selection.cpp rename to src/core/render/renderer_selection.cpp diff --git a/renderer_selection.h b/src/core/render/renderer_selection.h similarity index 97% rename from renderer_selection.h rename to src/core/render/renderer_selection.h index 1967bdf..e839edf 100644 --- a/renderer_selection.h +++ b/src/core/render/renderer_selection.h @@ -24,7 +24,7 @@ #include -class RendererSelection { +class QGLENGINE_CORE_EXPORT RendererSelection { friend class QGLView; friend class MouseController; friend class Renderer; diff --git a/renderer_service.cpp b/src/core/render/renderer_service.cpp similarity index 100% rename from renderer_service.cpp rename to src/core/render/renderer_service.cpp diff --git a/renderer_service.h b/src/core/render/renderer_service.h similarity index 98% rename from renderer_service.h rename to src/core/render/renderer_service.h index bef6b06..81ad619 100644 --- a/renderer_service.h +++ b/src/core/render/renderer_service.h @@ -25,7 +25,7 @@ #include -class RendererService { +class QGLENGINE_CORE_EXPORT RendererService { friend class QGLView; friend class MouseController; friend class Renderer; diff --git a/tonemapping_proc.cpp b/src/core/render/tonemapping_proc.cpp similarity index 99% rename from tonemapping_proc.cpp rename to src/core/render/tonemapping_proc.cpp index d72960e..3cf21de 100644 --- a/tonemapping_proc.cpp +++ b/src/core/render/tonemapping_proc.cpp @@ -31,7 +31,7 @@ TonemappingProc::TonemappingProc(Renderer * rend) : QThread() , r(rend) , 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) { shader_sum = 0; timer_delim = 0; diff --git a/tonemapping_proc.h b/src/core/render/tonemapping_proc.h similarity index 96% rename from tonemapping_proc.h rename to src/core/render/tonemapping_proc.h index 46caf30..86bd9c5 100644 --- a/tonemapping_proc.h +++ b/src/core/render/tonemapping_proc.h @@ -24,7 +24,7 @@ #include -class TonemappingProc: public QThread { +class QGLENGINE_CORE_EXPORT TonemappingProc: public QThread { friend class Renderer; friend class QGLView; diff --git a/glcamera.cpp b/src/core/scene/glcamera.cpp similarity index 100% rename from glcamera.cpp rename to src/core/scene/glcamera.cpp diff --git a/glcamera.h b/src/core/scene/glcamera.h similarity index 89% rename from glcamera.h rename to src/core/scene/glcamera.h index b54aa22..455010e 100644 --- a/glcamera.h +++ b/src/core/scene/glcamera.h @@ -22,9 +22,9 @@ #include "globject.h" -class Camera: public AimedObject { - friend QDataStream & operator<<(QDataStream & s, const ObjectBase * p); - friend QDataStream & operator>>(QDataStream & s, ObjectBase *& p); +class QGLENGINE_CORE_EXPORT Camera: public AimedObject { + friend QGLENGINE_CORE_EXPORT QDataStream & operator<<(QDataStream & s, const ObjectBase * p); + friend QGLENGINE_CORE_EXPORT QDataStream & operator>>(QDataStream & s, ObjectBase *& p); public: Camera(); diff --git a/globject.cpp b/src/core/scene/globject.cpp similarity index 100% rename from globject.cpp rename to src/core/scene/globject.cpp diff --git a/globject.h b/src/core/scene/globject.h similarity index 95% rename from globject.h rename to src/core/scene/globject.h index 23c42ad..68ec99b 100644 --- a/globject.h +++ b/src/core/scene/globject.h @@ -25,12 +25,12 @@ #include "gltypes.h" -class ObjectBase { +class QGLENGINE_CORE_EXPORT ObjectBase { friend class Scene; friend class RendererSelection; - friend QDataStream & operator<<(QDataStream & s, const ObjectBase * p); - friend QDataStream & operator>>(QDataStream & s, ObjectBase *& p); - friend QDataStream & operator>>(QDataStream & s, Scene *& p); + friend QGLENGINE_CORE_EXPORT QDataStream & operator<<(QDataStream & s, const ObjectBase * p); + friend QGLENGINE_CORE_EXPORT QDataStream & operator>>(QDataStream & s, ObjectBase *& p); + friend QGLENGINE_CORE_EXPORT QDataStream & operator>>(QDataStream & s, Scene *& p); public: 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 GLRendererBase; friend class Light; @@ -390,7 +390,7 @@ protected: }; -class Light: public AimedObject { +class QGLENGINE_CORE_EXPORT Light: public AimedObject { friend class QGLView; friend class RendererBase; @@ -434,8 +434,8 @@ inline T globject_cast(const ObjectBase * object) { } -QDataStream & operator<<(QDataStream & s, const ObjectBase * p); -QDataStream & operator>>(QDataStream & s, ObjectBase *& p); +QGLENGINE_CORE_EXPORT QDataStream & operator<<(QDataStream & s, const ObjectBase * p); +QGLENGINE_CORE_EXPORT QDataStream & operator>>(QDataStream & s, ObjectBase *& p); inline ObjectBaseList lights2objectList(const QList & v) { ObjectBaseList ret; diff --git a/glscene.cpp b/src/core/scene/glscene.cpp similarity index 100% rename from glscene.cpp rename to src/core/scene/glscene.cpp diff --git a/glscene.h b/src/core/scene/glscene.h similarity index 91% rename from glscene.h rename to src/core/scene/glscene.h index 839c480..b0365d8 100644 --- a/glscene.h +++ b/src/core/scene/glscene.h @@ -22,7 +22,7 @@ #include "gltypes.h" -class Scene: public QObject { +class QGLENGINE_CORE_EXPORT Scene: public QObject { Q_OBJECT friend class RendererBase; friend class Renderer; @@ -31,8 +31,8 @@ class Scene: public QObject { friend class RendererSelection; friend class ObjectBase; friend class Light; - friend QDataStream & operator<<(QDataStream & s, const Scene * p); - friend QDataStream & operator>>(QDataStream & s, Scene *& p); + friend QGLENGINE_CORE_EXPORT QDataStream & operator<<(QDataStream & s, const Scene * p); + friend QGLENGINE_CORE_EXPORT QDataStream & operator>>(QDataStream & s, Scene *& p); public: explicit Scene(); @@ -138,7 +138,7 @@ signals: }; -QDataStream & operator<<(QDataStream & s, const Scene * p); -QDataStream & operator>>(QDataStream & s, Scene *& p); +QGLENGINE_CORE_EXPORT QDataStream & operator<<(QDataStream & s, const Scene * p); +QGLENGINE_CORE_EXPORT QDataStream & operator>>(QDataStream & s, Scene *& p); #endif // GLSCENE_H diff --git a/src/core/shaders.qrc b/src/core/shaders.qrc new file mode 100644 index 0000000..71555c7 --- /dev/null +++ b/src/core/shaders.qrc @@ -0,0 +1,19 @@ + + + ../../shaders/ds_final.glsl + ../../shaders/ds_geom.glsl + ../../shaders/ds_light.glsl + ../../shaders/ds_tonemap.glsl + ../../shaders/fxaa.frag + ../../shaders/fxaa.vert + ../../shaders/fxaa_v3.h + ../../shaders/selection.glsl + ../../shaders/selection_apply.glsl + ../../shaders/selection_frame.glsl + ../../shaders/selection_halo.glsl + ../../shaders/service_fill.glsl + ../../shaders/service_frame.glsl + ../../shaders/service_line.glsl + ../../shaders/sum.glsl + + diff --git a/icons/add-type-camera.png b/src/icons/add-type-camera.png similarity index 100% rename from icons/add-type-camera.png rename to src/icons/add-type-camera.png diff --git a/icons/add-type-empty.png b/src/icons/add-type-empty.png similarity index 100% rename from icons/add-type-empty.png rename to src/icons/add-type-empty.png diff --git a/icons/add-type-geo.png b/src/icons/add-type-geo.png similarity index 100% rename from icons/add-type-geo.png rename to src/icons/add-type-geo.png diff --git a/icons/add-type-light.png b/src/icons/add-type-light.png similarity index 100% rename from icons/add-type-light.png rename to src/icons/add-type-light.png diff --git a/icons/alpha.png b/src/icons/alpha.png similarity index 100% rename from icons/alpha.png rename to src/icons/alpha.png diff --git a/icons/application-exit.png b/src/icons/application-exit.png similarity index 100% rename from icons/application-exit.png rename to src/icons/application-exit.png diff --git a/icons/collapse.png b/src/icons/collapse.png similarity index 100% rename from icons/collapse.png rename to src/icons/collapse.png diff --git a/icons/configure.png b/src/icons/configure.png similarity index 100% rename from icons/configure.png rename to src/icons/configure.png diff --git a/icons/dialog-cancel.png b/src/icons/dialog-cancel.png similarity index 100% rename from icons/dialog-cancel.png rename to src/icons/dialog-cancel.png diff --git a/icons/dialog-close.png b/src/icons/dialog-close.png similarity index 100% rename from icons/dialog-close.png rename to src/icons/dialog-close.png diff --git a/icons/document-edit.png b/src/icons/document-edit.png similarity index 100% rename from icons/document-edit.png rename to src/icons/document-edit.png diff --git a/icons/document-import.png b/src/icons/document-import.png similarity index 100% rename from icons/document-import.png rename to src/icons/document-import.png diff --git a/icons/document-new.png b/src/icons/document-new.png similarity index 100% rename from icons/document-new.png rename to src/icons/document-new.png diff --git a/icons/document-open.png b/src/icons/document-open.png similarity index 100% rename from icons/document-open.png rename to src/icons/document-open.png diff --git a/icons/document-save-all.png b/src/icons/document-save-all.png similarity index 100% rename from icons/document-save-all.png rename to src/icons/document-save-all.png diff --git a/icons/document-save.png b/src/icons/document-save.png similarity index 100% rename from icons/document-save.png rename to src/icons/document-save.png diff --git a/icons/edit-clear-locationbar-rtl.png b/src/icons/edit-clear-locationbar-rtl.png similarity index 100% rename from icons/edit-clear-locationbar-rtl.png rename to src/icons/edit-clear-locationbar-rtl.png diff --git a/icons/edit-clear.png b/src/icons/edit-clear.png similarity index 100% rename from icons/edit-clear.png rename to src/icons/edit-clear.png diff --git a/icons/edit-copy.png b/src/icons/edit-copy.png similarity index 100% rename from icons/edit-copy.png rename to src/icons/edit-copy.png diff --git a/icons/edit-delete.png b/src/icons/edit-delete.png similarity index 100% rename from icons/edit-delete.png rename to src/icons/edit-delete.png diff --git a/icons/edit-find.png b/src/icons/edit-find.png similarity index 100% rename from icons/edit-find.png rename to src/icons/edit-find.png diff --git a/icons/edit-paste.png b/src/icons/edit-paste.png similarity index 100% rename from icons/edit-paste.png rename to src/icons/edit-paste.png diff --git a/icons/edit-rename.png b/src/icons/edit-rename.png similarity index 100% rename from icons/edit-rename.png rename to src/icons/edit-rename.png diff --git a/icons/expand.png b/src/icons/expand.png similarity index 100% rename from icons/expand.png rename to src/icons/expand.png diff --git a/icons/format-fill-color.png b/src/icons/format-fill-color.png similarity index 100% rename from icons/format-fill-color.png rename to src/icons/format-fill-color.png diff --git a/icons/go-jump.png b/src/icons/go-jump.png similarity index 100% rename from icons/go-jump.png rename to src/icons/go-jump.png diff --git a/icons/go-top.png b/src/icons/go-top.png similarity index 100% rename from icons/go-top.png rename to src/icons/go-top.png diff --git a/icons/group.png b/src/icons/group.png similarity index 100% rename from icons/group.png rename to src/icons/group.png diff --git a/icons/layer-visible-off.png b/src/icons/layer-visible-off.png similarity index 100% rename from icons/layer-visible-off.png rename to src/icons/layer-visible-off.png diff --git a/icons/layer-visible-on.png b/src/icons/layer-visible-on.png similarity index 100% rename from icons/layer-visible-on.png rename to src/icons/layer-visible-on.png diff --git a/icons/light-+.png b/src/icons/light-+.png similarity index 100% rename from icons/light-+.png rename to src/icons/light-+.png diff --git a/icons/list-add.png b/src/icons/list-add.png similarity index 100% rename from icons/list-add.png rename to src/icons/list-add.png diff --git a/icons/object-flip-horizontal.png b/src/icons/object-flip-horizontal.png similarity index 100% rename from icons/object-flip-horizontal.png rename to src/icons/object-flip-horizontal.png diff --git a/icons/object-flip-vertical.png b/src/icons/object-flip-vertical.png similarity index 100% rename from icons/object-flip-vertical.png rename to src/icons/object-flip-vertical.png diff --git a/icons/picker.png b/src/icons/picker.png similarity index 100% rename from icons/picker.png rename to src/icons/picker.png diff --git a/icons/qglview.png b/src/icons/qglview.png similarity index 100% rename from icons/qglview.png rename to src/icons/qglview.png diff --git a/icons/qglview.xcf b/src/icons/qglview.xcf similarity index 100% rename from icons/qglview.xcf rename to src/icons/qglview.xcf diff --git a/icons/transform-move.png b/src/icons/transform-move.png similarity index 100% rename from icons/transform-move.png rename to src/icons/transform-move.png diff --git a/icons/transform-rotate.png b/src/icons/transform-rotate.png similarity index 100% rename from icons/transform-rotate.png rename to src/icons/transform-rotate.png diff --git a/icons/transform-scale.png b/src/icons/transform-scale.png similarity index 100% rename from icons/transform-scale.png rename to src/icons/transform-scale.png diff --git a/icons/type-camera.png b/src/icons/type-camera.png similarity index 100% rename from icons/type-camera.png rename to src/icons/type-camera.png diff --git a/icons/type-empty.png b/src/icons/type-empty.png similarity index 100% rename from icons/type-empty.png rename to src/icons/type-empty.png diff --git a/icons/type-geo.png b/src/icons/type-geo.png similarity index 100% rename from icons/type-geo.png rename to src/icons/type-geo.png diff --git a/icons/type-light.png b/src/icons/type-light.png similarity index 100% rename from icons/type-light.png rename to src/icons/type-light.png diff --git a/icons/view-refresh.png b/src/icons/view-refresh.png similarity index 100% rename from icons/view-refresh.png rename to src/icons/view-refresh.png diff --git a/plugin/CMakeLists.txt b/src/plugin/CMakeLists.txt similarity index 100% rename from plugin/CMakeLists.txt rename to src/plugin/CMakeLists.txt diff --git a/plugin/qglview_designerplugin.cpp b/src/plugin/qglview_designerplugin.cpp similarity index 100% rename from plugin/qglview_designerplugin.cpp rename to src/plugin/qglview_designerplugin.cpp diff --git a/plugin/qglview_designerplugin.h b/src/plugin/qglview_designerplugin.h similarity index 100% rename from plugin/qglview_designerplugin.h rename to src/plugin/qglview_designerplugin.h diff --git a/plugin/qglviewplugin.cpp b/src/plugin/qglviewplugin.cpp similarity index 100% rename from plugin/qglviewplugin.cpp rename to src/plugin/qglviewplugin.cpp diff --git a/plugin/qglviewplugin.h b/src/plugin/qglviewplugin.h similarity index 100% rename from plugin/qglviewplugin.h rename to src/plugin/qglviewplugin.h diff --git a/src/qglview_test/CMakeLists.txt b/src/qglview_test/CMakeLists.txt new file mode 100644 index 0000000..ddff38b --- /dev/null +++ b/src/qglview_test/CMakeLists.txt @@ -0,0 +1,6 @@ +project(qglengine_test) +qad_sources(SRC) +qad_wrap(${SRC} CPPS test_CPP) +qad_add_executable(${PROJECT_NAME} test_CPP) +qad_target_link_libraries(${PROJECT_NAME} qglengine_core qglengine_widgets) +#qad_target_include_directories(${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/core" "${CMAKE_CURRENT_SOURCE_DIR}/widgets") diff --git a/qglview_test/main.cpp b/src/qglview_test/main.cpp similarity index 100% rename from qglview_test/main.cpp rename to src/qglview_test/main.cpp diff --git a/qglview_test/qglview_window.cpp b/src/qglview_test/qglview_window.cpp similarity index 93% rename from qglview_test/qglview_window.cpp rename to src/qglview_test/qglview_window.cpp index 804af9f..2eab5d1 100644 --- a/qglview_test/qglview_window.cpp +++ b/src/qglview_test/qglview_window.cpp @@ -18,6 +18,7 @@ #include "qglview_window.h" +#include "glshaders.h" #include "gltexture_manager.h" #include "glwidget.h" #include "qad_types.h" @@ -28,6 +29,27 @@ #include +class Effect1: public FramebufferEffectBase { +public: + void reloadShaders() { QGLEngineShaders::loadShadersMulti(mys, "test1.glsl"); } + void draw() { + auto planes = getFreePlanes(1); + bindPreviousOutput(0); + // bindDeferredBuffer(Renderer::dbrNormalZSolid, 1); + mys->bind(); + mys->setUniformValue("tex_in", 0); + mys->setUniformValue("step", QVector2D(1, 0)); + drawScreen(mys); + + setOutputPlane(planes[0]); + bindPreviousOutput(0); + mys->setUniformValue("step", QVector2D(0, 1)); + drawScreen(mys); + } + QOpenGLShaderProgram * mys = nullptr; +}; + + QGLViewWindow::QGLViewWindow(QWidget * parent): QMainWindow(parent), Ui::QGLViewWindow() { setupUi(this); session.setFile("session_qglview_test.conf"); @@ -46,6 +68,7 @@ QGLViewWindow::QGLViewWindow(QWidget * parent): QMainWindow(parent), Ui::QGLView view->view()->setHoverHaloEnabled(true); view->view()->setDepthStart(0.1); view->view()->setSelectionMode(Scene::smMultiSelection); + view->view()->renderer_.addFramebufferEffect(new Effect1()); groupShadows->setChecked(view->view()->isFeatureEnabled(QGLView::qglShadowsEnabled)); @@ -84,6 +107,7 @@ QGLViewWindow::QGLViewWindow(QWidget * parent): QMainWindow(parent), Ui::QGLView session.load(); + // loadFile("axis.DAE.qgl"); // matEditor->setMaterial(const_cast(view->view()->scene()->rootObject()->child(0))->material()); /*Scene * sc = loadScene("truck.obj"); diff --git a/qglview_test/qglview_window.h b/src/qglview_test/qglview_window.h similarity index 100% rename from qglview_test/qglview_window.h rename to src/qglview_test/qglview_window.h diff --git a/qglview_test/qglview_window.ui b/src/qglview_test/qglview_window.ui similarity index 97% rename from qglview_test/qglview_window.ui rename to src/qglview_test/qglview_window.ui index 5f45201..cb41efd 100644 --- a/qglview_test/qglview_window.ui +++ b/src/qglview_test/qglview_window.ui @@ -80,8 +80,8 @@ 0 0 - 907 - 943 + 904 + 840 @@ -751,7 +751,7 @@ 0 0 1107 - 30 + 31 @@ -799,7 +799,7 @@ - + :/icons/application-exit.png:/icons/application-exit.png @@ -808,7 +808,7 @@ - + :/icons/document-import.png:/icons/document-import.png @@ -820,7 +820,7 @@ - + :/icons/document-open.png:/icons/document-open.png @@ -832,7 +832,7 @@ - + :/icons/document-save-all.png:/icons/document-save-all.png @@ -844,7 +844,7 @@ - + :/icons/document-new.png:/icons/document-new.png @@ -856,7 +856,7 @@ - + :/icons/document-save.png:/icons/document-save.png @@ -888,7 +888,7 @@ true - + :/icons/transform-move.png:/icons/transform-move.png @@ -903,7 +903,7 @@ true - + :/icons/transform-rotate.png:/icons/transform-rotate.png @@ -918,7 +918,7 @@ true - + :/icons/transform-scale.png:/icons/transform-scale.png @@ -944,7 +944,7 @@ ObjectEditor QWidget -
widgets/object_editor.h
+
object_editor.h
1
@@ -956,7 +956,7 @@ MaterialsEditor QWidget -
widgets/materials_editor.h
+
materials_editor.h
1
@@ -973,9 +973,7 @@ - - - + diff --git a/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt similarity index 89% rename from widgets/CMakeLists.txt rename to src/widgets/CMakeLists.txt index d9a46c3..31e7ddc 100644 --- a/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -19,7 +19,7 @@ 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_link_libraries(${PROJECT_NAME} QAD::Widgets qglengine_core) -#qad_target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../core") +qad_target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}" "${_qglengine_root_build}") list(APPEND QT_MULTILIB_LIST ${PROJECT_NAME}) shstk_copy_to_parent() #message(STATUS "Building ${PROJECT_NAME}") diff --git a/widgets/material_editor.cpp b/src/widgets/material_editor.cpp similarity index 100% rename from widgets/material_editor.cpp rename to src/widgets/material_editor.cpp diff --git a/widgets/material_editor.h b/src/widgets/material_editor.h similarity index 100% rename from widgets/material_editor.h rename to src/widgets/material_editor.h diff --git a/widgets/material_editor.ui b/src/widgets/material_editor.ui similarity index 100% rename from widgets/material_editor.ui rename to src/widgets/material_editor.ui diff --git a/widgets/material_map_editor.cpp b/src/widgets/material_map_editor.cpp similarity index 100% rename from widgets/material_map_editor.cpp rename to src/widgets/material_map_editor.cpp diff --git a/widgets/material_map_editor.h b/src/widgets/material_map_editor.h similarity index 100% rename from widgets/material_map_editor.h rename to src/widgets/material_map_editor.h diff --git a/widgets/material_map_editor.ui b/src/widgets/material_map_editor.ui similarity index 100% rename from widgets/material_map_editor.ui rename to src/widgets/material_map_editor.ui diff --git a/widgets/materials_editor.cpp b/src/widgets/materials_editor.cpp similarity index 100% rename from widgets/materials_editor.cpp rename to src/widgets/materials_editor.cpp diff --git a/widgets/materials_editor.h b/src/widgets/materials_editor.h similarity index 100% rename from widgets/materials_editor.h rename to src/widgets/materials_editor.h diff --git a/widgets/materials_editor.ui b/src/widgets/materials_editor.ui similarity index 100% rename from widgets/materials_editor.ui rename to src/widgets/materials_editor.ui diff --git a/widgets/object_editor.cpp b/src/widgets/object_editor.cpp similarity index 100% rename from widgets/object_editor.cpp rename to src/widgets/object_editor.cpp diff --git a/widgets/object_editor.h b/src/widgets/object_editor.h similarity index 100% rename from widgets/object_editor.h rename to src/widgets/object_editor.h diff --git a/widgets/object_editor.ui b/src/widgets/object_editor.ui similarity index 100% rename from widgets/object_editor.ui rename to src/widgets/object_editor.ui diff --git a/widgets/primitiveeditor.cpp b/src/widgets/primitiveeditor.cpp similarity index 100% rename from widgets/primitiveeditor.cpp rename to src/widgets/primitiveeditor.cpp diff --git a/widgets/primitiveeditor.h b/src/widgets/primitiveeditor.h similarity index 100% rename from widgets/primitiveeditor.h rename to src/widgets/primitiveeditor.h diff --git a/widgets/primitiveeditor.ui b/src/widgets/primitiveeditor.ui similarity index 100% rename from widgets/primitiveeditor.ui rename to src/widgets/primitiveeditor.ui diff --git a/widgets/propertyeditor.cpp b/src/widgets/propertyeditor.cpp similarity index 100% rename from widgets/propertyeditor.cpp rename to src/widgets/propertyeditor.cpp diff --git a/widgets/propertyeditor.h b/src/widgets/propertyeditor.h similarity index 100% rename from widgets/propertyeditor.h rename to src/widgets/propertyeditor.h diff --git a/widgets/scene_tree.cpp b/src/widgets/scene_tree.cpp similarity index 100% rename from widgets/scene_tree.cpp rename to src/widgets/scene_tree.cpp diff --git a/widgets/scene_tree.h b/src/widgets/scene_tree.h similarity index 100% rename from widgets/scene_tree.h rename to src/widgets/scene_tree.h diff --git a/widgets/scene_tree.ui b/src/widgets/scene_tree.ui similarity index 100% rename from widgets/scene_tree.ui rename to src/widgets/scene_tree.ui diff --git a/widgets/treewidget_p.h b/src/widgets/treewidget_p.h similarity index 100% rename from widgets/treewidget_p.h rename to src/widgets/treewidget_p.h diff --git a/widgets/view_editor.cpp b/src/widgets/view_editor.cpp similarity index 100% rename from widgets/view_editor.cpp rename to src/widgets/view_editor.cpp diff --git a/widgets/view_editor.h b/src/widgets/view_editor.h similarity index 100% rename from widgets/view_editor.h rename to src/widgets/view_editor.h diff --git a/widgets/view_editor.ui b/src/widgets/view_editor.ui similarity index 100% rename from widgets/view_editor.ui rename to src/widgets/view_editor.ui diff --git a/widgets/widgets.qrc b/src/widgets/widgets.qrc similarity index 100% rename from widgets/widgets.qrc rename to src/widgets/widgets.qrc