重新组织了项目结构

dev-VirtualTexture
wuyize 2022-10-20 22:48:27 +08:00
parent 6555e4db72
commit d7329e78e6
42 changed files with 404 additions and 184 deletions

View File

@ -95,27 +95,28 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="BvhTree.cpp" /> <ClCompile Include="src\Editor\EditorWidget.cpp" />
<ClCompile Include="Camera.cpp" /> <ClCompile Include="src\main.cpp" />
<ClCompile Include="CubicBezier.cpp" /> <ClCompile Include="src\MainWindow.cpp" />
<ClCompile Include="Light.cpp" /> <ClCompile Include="src\Renderer\BvhTree.cpp" />
<ClCompile Include="Line.cpp" /> <ClCompile Include="src\Renderer\Camera.cpp" />
<ClCompile Include="Mesh.cpp" /> <ClCompile Include="src\Renderer\CubicBezier.cpp" />
<ClCompile Include="Model.cpp" /> <ClCompile Include="src\Renderer\CubicMonotonization.cpp" />
<ClCompile Include="PaintingHelper.cpp" /> <ClCompile Include="src\Renderer\Light.cpp" />
<ClCompile Include="PaintingMesh.cpp" /> <ClCompile Include="src\Renderer\Line.cpp" />
<ClCompile Include="RendererWidget.cpp" /> <ClCompile Include="src\Renderer\Mesh.cpp" />
<ClCompile Include="ShortCutTree.cpp" /> <ClCompile Include="src\Renderer\Model.cpp" />
<ClCompile Include="StraightLine.cpp" /> <ClCompile Include="src\Renderer\PaintingHelper.cpp" />
<ClCompile Include="SvgParser.cpp" /> <ClCompile Include="src\Renderer\PaintingMesh.cpp" />
<ClCompile Include="src\Renderer\RendererGLWidget.cpp" />
<ClCompile Include="src\Renderer\RendererWidget.cpp" />
<ClCompile Include="src\Renderer\ShortCutTree.cpp" />
<ClCompile Include="src\Renderer\StraightLine.cpp" />
<ClCompile Include="src\SvgParser.cpp" />
<QtRcc Include="MainWindow.qrc" /> <QtRcc Include="MainWindow.qrc" />
<QtUic Include="EditorWidget.ui" />
<QtUic Include="MainWindow.ui" /> <QtUic Include="MainWindow.ui" />
<QtMoc Include="MainWindow.h" /> <QtUic Include="RendererWidget.ui" />
<ClCompile Include="MainWindow.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<QtMoc Include="RendererWidget.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Shaders\depth_init.comp" /> <None Include="Shaders\depth_init.comp" />
@ -136,19 +137,24 @@
<None Include="Shaders\ssgi.comp" /> <None Include="Shaders\ssgi.comp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="BvhTree.h" /> <QtMoc Include="src\Renderer\RendererWidget.h" />
<ClInclude Include="Camera.h" /> <ClInclude Include="src\SvgParser.h" />
<ClInclude Include="CubicBezier.h" /> <QtMoc Include="src\MainWindow.h" />
<ClInclude Include="Drawable.h" /> <QtMoc Include="src\Editor\EditorWidget.h" />
<ClInclude Include="Light.h" /> <ClInclude Include="src\Renderer\BvhTree.h" />
<ClInclude Include="Line.h" /> <ClInclude Include="src\Renderer\Camera.h" />
<ClInclude Include="Mesh.h" /> <ClInclude Include="src\Renderer\CubicBezier.h" />
<ClInclude Include="Model.h" /> <ClInclude Include="src\Renderer\CubicMonotonization.h" />
<ClInclude Include="PaintingHelper.h" /> <ClInclude Include="src\Renderer\Drawable.h" />
<ClInclude Include="PaintingMesh.h" /> <ClInclude Include="src\Renderer\Light.h" />
<ClInclude Include="ShortCutTree.h" /> <ClInclude Include="src\Renderer\Line.h" />
<ClInclude Include="StraightLine.h" /> <ClInclude Include="src\Renderer\Mesh.h" />
<ClInclude Include="SvgParser.h" /> <ClInclude Include="src\Renderer\Model.h" />
<ClInclude Include="src\Renderer\PaintingHelper.h" />
<ClInclude Include="src\Renderer\PaintingMesh.h" />
<ClInclude Include="src\Renderer\ShortCutTree.h" />
<ClInclude Include="src\Renderer\StraightLine.h" />
<QtMoc Include="src\Renderer\RendererGLWidget.h" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.targets')"> <ImportGroup Condition="Exists('$(QtMsBuild)\qt.targets')">

View File

@ -24,6 +24,18 @@
<Filter Include="Resource Files\Shaders"> <Filter Include="Resource Files\Shaders">
<UniqueIdentifier>{60515177-3da7-420f-8f5b-27c16bb2b77b}</UniqueIdentifier> <UniqueIdentifier>{60515177-3da7-420f-8f5b-27c16bb2b77b}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Source Files\Editor">
<UniqueIdentifier>{bd91d673-6674-478d-a43d-54ac6c09d77f}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Editor">
<UniqueIdentifier>{f21af5cf-2eba-4e89-a7ca-faebd689025d}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Renderer">
<UniqueIdentifier>{f1a582fa-33b1-46fe-b969-e1b2de56bf7e}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Renderer">
<UniqueIdentifier>{f52671e3-3263-45e6-8d6c-976d19dc7e24}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<QtRcc Include="MainWindow.qrc"> <QtRcc Include="MainWindow.qrc">
@ -32,60 +44,75 @@
<QtUic Include="MainWindow.ui"> <QtUic Include="MainWindow.ui">
<Filter>Form Files</Filter> <Filter>Form Files</Filter>
</QtUic> </QtUic>
<QtMoc Include="MainWindow.h"> </ItemGroup>
<Filter>Header Files</Filter> <ItemGroup>
<ClCompile Include="src\Editor\EditorWidget.cpp">
<Filter>Source Files\Editor</Filter>
</ClCompile>
<ClCompile Include="src\Renderer\BvhTree.cpp">
<Filter>Source Files\Renderer</Filter>
</ClCompile>
<ClCompile Include="src\Renderer\Camera.cpp">
<Filter>Source Files\Renderer</Filter>
</ClCompile>
<ClCompile Include="src\Renderer\CubicBezier.cpp">
<Filter>Source Files\Renderer</Filter>
</ClCompile>
<ClCompile Include="src\Renderer\CubicMonotonization.cpp">
<Filter>Source Files\Renderer</Filter>
</ClCompile>
<ClCompile Include="src\Renderer\Light.cpp">
<Filter>Source Files\Renderer</Filter>
</ClCompile>
<ClCompile Include="src\Renderer\Line.cpp">
<Filter>Source Files\Renderer</Filter>
</ClCompile>
<ClCompile Include="src\Renderer\Mesh.cpp">
<Filter>Source Files\Renderer</Filter>
</ClCompile>
<ClCompile Include="src\Renderer\Model.cpp">
<Filter>Source Files\Renderer</Filter>
</ClCompile>
<ClCompile Include="src\Renderer\PaintingHelper.cpp">
<Filter>Source Files\Renderer</Filter>
</ClCompile>
<ClCompile Include="src\Renderer\PaintingMesh.cpp">
<Filter>Source Files\Renderer</Filter>
</ClCompile>
<ClCompile Include="src\Renderer\RendererGLWidget.cpp">
<Filter>Source Files\Renderer</Filter>
</ClCompile>
<ClCompile Include="src\Renderer\ShortCutTree.cpp">
<Filter>Source Files\Renderer</Filter>
</ClCompile>
<ClCompile Include="src\Renderer\StraightLine.cpp">
<Filter>Source Files\Renderer</Filter>
</ClCompile>
<ClCompile Include="src\main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\MainWindow.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\SvgParser.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\Renderer\RendererWidget.cpp">
<Filter>Source Files\Renderer</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<QtMoc Include="src\Renderer\RendererGLWidget.h">
<Filter>Header Files\Renderer</Filter>
</QtMoc> </QtMoc>
<ClCompile Include="MainWindow.cpp"> <QtMoc Include="src\Editor\EditorWidget.h">
<Filter>Header Files\Editor</Filter>
</QtMoc>
<QtMoc Include="src\MainWindow.h">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </QtMoc>
</ItemGroup> <QtMoc Include="src\Renderer\RendererWidget.h">
<ItemGroup> <Filter>Header Files\Renderer</Filter>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="RendererWidget.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Camera.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Mesh.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Model.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PaintingMesh.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="BvhTree.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PaintingHelper.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Light.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ShortCutTree.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Line.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="CubicBezier.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="StraightLine.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SvgParser.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<QtMoc Include="RendererWidget.h">
<Filter>Header Files</Filter>
</QtMoc> </QtMoc>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -139,44 +166,55 @@
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="Camera.h"> <QtUic Include="EditorWidget.ui">
<Filter>Header Files</Filter> <Filter>Form Files</Filter>
</QtUic>
<QtUic Include="RendererWidget.ui">
<Filter>Form Files</Filter>
</QtUic>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\Renderer\BvhTree.h">
<Filter>Header Files\Renderer</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Mesh.h"> <ClInclude Include="src\Renderer\Camera.h">
<Filter>Header Files</Filter> <Filter>Header Files\Renderer</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Model.h"> <ClInclude Include="src\Renderer\CubicBezier.h">
<Filter>Header Files</Filter> <Filter>Header Files\Renderer</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="PaintingMesh.h"> <ClInclude Include="src\Renderer\CubicMonotonization.h">
<Filter>Header Files</Filter> <Filter>Header Files\Renderer</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Drawable.h"> <ClInclude Include="src\Renderer\Drawable.h">
<Filter>Header Files</Filter> <Filter>Header Files\Renderer</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="BvhTree.h"> <ClInclude Include="src\Renderer\Light.h">
<Filter>Header Files</Filter> <Filter>Header Files\Renderer</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="PaintingHelper.h"> <ClInclude Include="src\Renderer\Line.h">
<Filter>Header Files</Filter> <Filter>Header Files\Renderer</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Light.h"> <ClInclude Include="src\Renderer\Mesh.h">
<Filter>Header Files</Filter> <Filter>Header Files\Renderer</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="ShortCutTree.h"> <ClInclude Include="src\Renderer\Model.h">
<Filter>Header Files</Filter> <Filter>Header Files\Renderer</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Line.h"> <ClInclude Include="src\Renderer\PaintingHelper.h">
<Filter>Header Files</Filter> <Filter>Header Files\Renderer</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="CubicBezier.h"> <ClInclude Include="src\Renderer\PaintingMesh.h">
<Filter>Header Files</Filter> <Filter>Header Files\Renderer</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="StraightLine.h"> <ClInclude Include="src\Renderer\ShortCutTree.h">
<Filter>Header Files</Filter> <Filter>Header Files\Renderer</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="SvgParser.h"> <ClInclude Include="src\Renderer\StraightLine.h">
<Filter>Header Files</Filter> <Filter>Header Files\Renderer</Filter>
</ClInclude>
<ClInclude Include="src\SvgParser.h">
<Filter>Source Files</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>EditorWidgetClass</class>
<widget class="QWidget" name="EditorWidgetClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1124</width>
<height>695</height>
</rect>
</property>
<property name="windowTitle">
<string>RendererWidget</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>纹理编辑</string>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

View File

@ -1,16 +0,0 @@
#include "MainWindow.h"
#include "RendererWidget.h"
#include "qslider.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
QObject::connect(ui.horizontalSlider, &QSlider::valueChanged,
ui.openGLWidget, &RendererWidget::setMainLightPitch);
QObject::connect(ui.horizontalSlider_2, &QSlider::valueChanged,
ui.openGLWidget, &RendererWidget::setMainLightYaw);
}
MainWindow::~MainWindow()
{}

View File

@ -34,61 +34,55 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0"> <layout class="QVBoxLayout" name="verticalLayout_4" stretch="0">
<property name="sizeConstraint"> <property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum> <enum>QLayout::SetDefaultConstraint</enum>
</property> </property>
<item> <item>
<widget class="RendererWidget" name="openGLWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="sizePolicy"> <property name="font">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding"> <font>
<horstretch>0</horstretch> <family>Microsoft YaHei UI</family>
<verstretch>0</verstretch> <pointsize>13</pointsize>
</sizepolicy> </font>
</property> </property>
<property name="tabPosition">
<enum>QTabWidget::North</enum>
</property>
<property name="tabShape">
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<widget class="EditorWidget" name="editorWidget">
<attribute name="title">
<string>纹理编辑</string>
</attribute>
</widget> </widget>
</item> <widget class="RendererWidget" name="rendererWidget">
<item> <attribute name="title">
<layout class="QVBoxLayout" name="verticalLayout_3"> <string>场景渲染</string>
<item> </attribute>
<widget class="QSlider" name="horizontalSlider">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>180</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget> </widget>
</item>
<item>
<widget class="QSlider" name="horizontalSlider_2">
<property name="maximum">
<number>360</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
</layout> </layout>
</item>
</layout>
</widget> </widget>
</widget> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
<customwidgets> <customwidgets>
<customwidget> <customwidget>
<class>RendererWidget</class> <class>RendererWidget</class>
<extends>QOpenGLWidget</extends> <extends>QWidget</extends>
<header>RendererWidget.h</header> <header>Renderer/RendererWidget.h</header>
</customwidget>
<customwidget>
<class>EditorWidget</class>
<extends>QWidget</extends>
<header>Editor/EditorWidget.h</header>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources> <resources>

View File

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RendererWidgetClass</class>
<widget class="QWidget" name="RendererWidgetClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1124</width>
<height>695</height>
</rect>
</property>
<property name="windowTitle">
<string>RendererWidget</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="RendererGLWidget" name="openGLWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QSlider" name="horizontalSlider">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>180</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="horizontalSlider_2">
<property name="maximum">
<number>360</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>RendererGLWidget</class>
<extends>QOpenGLWidget</extends>
<header>RendererGLWidget.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,10 @@
#include "EditorWidget.h"
EditorWidget::EditorWidget(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
}
EditorWidget::~EditorWidget()
{}

View File

@ -0,0 +1,16 @@
#pragma once
#include <QWidget>
#include "ui_EditorWidget.h"
class EditorWidget : public QWidget
{
Q_OBJECT
public:
EditorWidget(QWidget *parent = nullptr);
~EditorWidget();
private:
Ui::EditorWidgetClass ui;
};

View File

@ -0,0 +1,12 @@
#include "MainWindow.h"
#include "Renderer/RendererGLWidget.h"
#include "qslider.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
}
MainWindow::~MainWindow()
{}

View File

@ -8,7 +8,7 @@
#include <QtMath> #include <QtMath>
#include "BvhTree.h" #include "BvhTree.h"
#include "ShortCutTree.h" #include "ShortCutTree.h"
#include "SvgParser.h" #include "../SvgParser.h"
Model::Model(QString path, QOpenGLContext* context, QOpenGLShaderProgram* shaderProgram) Model::Model(QString path, QOpenGLContext* context, QOpenGLShaderProgram* shaderProgram)
: context(context) : context(context)

View File

@ -1,4 +1,4 @@
#include "RendererWidget.h" #include "RendererGLWidget.h"
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <fstream> #include <fstream>
@ -12,7 +12,7 @@ QVector3D lightColors[] = { 20 * QVector3D(0.7529,0.7450,0.6784).normalized(), Q
static float sunPitch = 105, sunYaw = 80; static float sunPitch = 105, sunYaw = 80;
static int sunSpeed = 10; static int sunSpeed = 10;
RendererWidget::RendererWidget(QWidget* parent) RendererGLWidget::RendererGLWidget(QWidget* parent)
: QOpenGLWidget(parent) : QOpenGLWidget(parent)
, camera(QVector3D(0.0f, 100.0f, 0.0f)) , camera(QVector3D(0.0f, 100.0f, 0.0f))
, light(&camera) , light(&camera)
@ -26,7 +26,7 @@ RendererWidget::RendererWidget(QWidget* parent)
setFormat(format); setFormat(format);
} }
RendererWidget::~RendererWidget() RendererGLWidget::~RendererGLWidget()
{ {
if (modelProgramPtr != nullptr) if (modelProgramPtr != nullptr)
{ {
@ -51,19 +51,19 @@ RendererWidget::~RendererWidget()
} }
} }
void RendererWidget::setMainLightPitch(float pitch) void RendererGLWidget::setMainLightPitch(float pitch)
{ {
//qDebug() << "pitch" << pitch; //qDebug() << "pitch" << pitch;
sunPitch = pitch; sunPitch = pitch;
} }
void RendererWidget::setMainLightYaw(float yaw) void RendererGLWidget::setMainLightYaw(float yaw)
{ {
//qDebug() << "yaw" << yaw; //qDebug() << "yaw" << yaw;
sunYaw = yaw; sunYaw = yaw;
} }
QOpenGLTexture randomMap(QOpenGLTexture::Target2D); QOpenGLTexture randomMap(QOpenGLTexture::Target2D);
void RendererWidget::initializeGL() void RendererGLWidget::initializeGL()
{ {
initializeOpenGLFunctions(); initializeOpenGLFunctions();
qDebug() << "GL_VERSION" << (char*)glGetString(GL_VERSION); qDebug() << "GL_VERSION" << (char*)glGetString(GL_VERSION);
@ -243,7 +243,7 @@ void RendererWidget::initializeGL()
} }
void RendererWidget::paintGL() void RendererGLWidget::paintGL()
{ {
light.lightDirection.setX(cos(qDegreesToRadians(sunPitch)) * cos(qDegreesToRadians(sunYaw))); light.lightDirection.setX(cos(qDegreesToRadians(sunPitch)) * cos(qDegreesToRadians(sunYaw)));
light.lightDirection.setY(sin(qDegreesToRadians(sunPitch))); light.lightDirection.setY(sin(qDegreesToRadians(sunPitch)));
@ -391,7 +391,7 @@ void RendererWidget::paintGL()
finalProgramPtr->release(); finalProgramPtr->release();
} }
void RendererWidget::resizeGL(int width, int height) void RendererGLWidget::resizeGL(int width, int height)
{ {
frameWidth = ceil( devicePixelRatioF() * width); frameWidth = ceil( devicePixelRatioF() * width);
frameHeight = ceil(devicePixelRatioF() * height); frameHeight = ceil(devicePixelRatioF() * height);
@ -531,7 +531,7 @@ void RendererWidget::resizeGL(int width, int height)
std::cout << "\033[?25l"; std::cout << "\033[?25l";
} }
void RendererWidget::timerEvent(QTimerEvent* event) void RendererGLWidget::timerEvent(QTimerEvent* event)
{ {
clock_t currentFrame = std::clock(); clock_t currentFrame = std::clock();
deltaTime = (float)(currentFrame - lastFrame) / CLOCKS_PER_SEC; deltaTime = (float)(currentFrame - lastFrame) / CLOCKS_PER_SEC;
@ -589,7 +589,7 @@ void RendererWidget::timerEvent(QTimerEvent* event)
repaint(); repaint();
} }
void RendererWidget::keyPressEvent(QKeyEvent* event) void RendererGLWidget::keyPressEvent(QKeyEvent* event)
{ {
if (event->key() == Qt::Key_Escape) if (event->key() == Qt::Key_Escape)
clearFocus(); clearFocus();
@ -598,25 +598,25 @@ void RendererWidget::keyPressEvent(QKeyEvent* event)
QOpenGLWidget::keyPressEvent(event); QOpenGLWidget::keyPressEvent(event);
} }
void RendererWidget::keyReleaseEvent(QKeyEvent* event) void RendererGLWidget::keyReleaseEvent(QKeyEvent* event)
{ {
if (!event->isAutoRepeat()) if (!event->isAutoRepeat())
pressedKeys.remove(event->key()); pressedKeys.remove(event->key());
QOpenGLWidget::keyReleaseEvent(event); QOpenGLWidget::keyReleaseEvent(event);
} }
void RendererWidget::wheelEvent(QWheelEvent* event) void RendererGLWidget::wheelEvent(QWheelEvent* event)
{ {
camera.ProcessMouseScroll(event->delta() / 15.); camera.ProcessMouseScroll(event->delta() / 15.);
} }
void RendererWidget::focusInEvent(QFocusEvent* event) void RendererGLWidget::focusInEvent(QFocusEvent* event)
{ {
setCursor(Qt::BlankCursor); setCursor(Qt::BlankCursor);
cursor().setPos(mapToGlobal(geometry().center())); cursor().setPos(mapToGlobal(geometry().center()));
} }
void RendererWidget::focusOutEvent(QFocusEvent* event) void RendererGLWidget::focusOutEvent(QFocusEvent* event)
{ {
setCursor(Qt::ArrowCursor); setCursor(Qt::ArrowCursor);
} }

View File

@ -12,12 +12,12 @@
#include "Model.h" #include "Model.h"
#include "PaintingHelper.h" #include "PaintingHelper.h"
class RendererWidget : public QOpenGLWidget, protected QOpenGLFunctions_4_5_Compatibility class RendererGLWidget : public QOpenGLWidget, protected QOpenGLFunctions_4_5_Compatibility
{ {
Q_OBJECT Q_OBJECT
public: public:
RendererWidget(QWidget* parent = nullptr); RendererGLWidget(QWidget* parent = nullptr);
~RendererWidget(); ~RendererGLWidget();
public slots: public slots:
void setMainLightPitch(float pitch); void setMainLightPitch(float pitch);

View File

@ -0,0 +1,15 @@
#include "RendererWidget.h"
#include "RendererGLWidget.h"
RendererWidget::RendererWidget(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
QObject::connect(ui.horizontalSlider, &QSlider::valueChanged,
ui.openGLWidget, &RendererGLWidget::setMainLightPitch);
QObject::connect(ui.horizontalSlider_2, &QSlider::valueChanged,
ui.openGLWidget, &RendererGLWidget::setMainLightYaw);
}
RendererWidget::~RendererWidget()
{}

View File

@ -0,0 +1,16 @@
#pragma once
#include <QWidget>
#include "ui_RendererWidget.h"
class RendererWidget : public QWidget
{
Q_OBJECT
public:
RendererWidget(QWidget *parent = nullptr);
~RendererWidget();
private:
Ui::RendererWidgetClass ui;
};

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "Line.h" #include "Renderer/Line.h"
#include <cmath> #include <cmath>
#include <string> #include <string>
using namespace std; using namespace std;