Add material editor
This commit is contained in:
parent
291001d7e1
commit
b0fbb6764e
14 changed files with 184 additions and 31 deletions
|
@ -1 +1,5 @@
|
|||
find_package(Qt5Widgets CONFIG REQUIRED)
|
||||
|
||||
add_subdirectory(common)
|
||||
add_subdirectory(leveleditor)
|
||||
add_subdirectory(materialeditor)
|
||||
|
|
12
tools/common/CMakeLists.txt
Normal file
12
tools/common/CMakeLists.txt
Normal file
|
@ -0,0 +1,12 @@
|
|||
set(INCLUDE_FILES
|
||||
include/renderwindow.h)
|
||||
|
||||
qt5_wrap_cpp(EDITOR_SRC ${INCLUDE_FILES})
|
||||
|
||||
add_library(EditorCommon
|
||||
src/qt.cpp
|
||||
src/renderwindow.cpp
|
||||
src/editorstyle.cpp
|
||||
${EDITOR_SRC})
|
||||
target_include_directories(EditorCommon PUBLIC include)
|
||||
target_link_libraries(EditorCommon PRIVATE Engine Qt5::Widgets)
|
26
tools/common/src/qt.cpp
Normal file
26
tools/common/src/qt.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
#include <QApplication>
|
||||
#include <QVulkanInstance>
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
static std::vector<std::string> extensionList;
|
||||
|
||||
std::vector<const char*> platform::getRequiredExtensions() {
|
||||
QVulkanInstance instance;
|
||||
instance.create();
|
||||
|
||||
for(const auto& extension : instance.extensions())
|
||||
extensionList.push_back(extension.data());
|
||||
|
||||
instance.destroy();
|
||||
|
||||
std::vector<const char*> extensions;
|
||||
for(const auto& extension : extensionList)
|
||||
extensions.push_back(extension.c_str());
|
||||
|
||||
return extensions;
|
||||
}
|
||||
|
||||
uint32_t platform::getTime() {
|
||||
return 0;
|
||||
}
|
|
@ -1,17 +1,11 @@
|
|||
find_package(Qt5Widgets CONFIG REQUIRED)
|
||||
|
||||
set(INCLUDE_FILES
|
||||
include/mainwindow.h
|
||||
include/renderwindow.h
|
||||
include/editorstyle.h)
|
||||
include/mainwindow.h)
|
||||
|
||||
qt5_wrap_cpp(EDITOR_SRC ${INCLUDE_FILES})
|
||||
|
||||
add_executable(LevelEditor
|
||||
src/main.cpp
|
||||
src/mainwindow.cpp
|
||||
src/renderwindow.cpp
|
||||
src/editorstyle.cpp
|
||||
${EDITOR_SRC})
|
||||
target_include_directories(LevelEditor PRIVATE include)
|
||||
target_link_libraries(LevelEditor Qt5::Widgets Engine ToolWindowManager)
|
||||
target_link_libraries(LevelEditor Qt5::Widgets Engine ToolWindowManager EditorCommon)
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#include <QVulkanInstance>
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "platform.h"
|
||||
#include "context.h"
|
||||
#include "renderer.h"
|
||||
#include "worldmanager.h"
|
||||
|
@ -10,28 +9,6 @@
|
|||
#include "ecs.h"
|
||||
#include "editorstyle.h"
|
||||
|
||||
static std::vector<std::string> extensionList;
|
||||
|
||||
std::vector<const char*> platform::getRequiredExtensions() {
|
||||
QVulkanInstance instance;
|
||||
instance.create();
|
||||
|
||||
for(const auto& extension : instance.extensions())
|
||||
extensionList.push_back(extension.data());
|
||||
|
||||
instance.destroy();
|
||||
|
||||
std::vector<const char*> extensions;
|
||||
for(const auto& extension : extensionList)
|
||||
extensions.push_back(extension.c_str());
|
||||
|
||||
return extensions;
|
||||
}
|
||||
|
||||
uint32_t platform::getTime() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
QApplication app(argc, argv);
|
||||
app.setStyle(new EditorStyle());
|
||||
|
|
12
tools/materialeditor/CMakeLists.txt
Normal file
12
tools/materialeditor/CMakeLists.txt
Normal file
|
@ -0,0 +1,12 @@
|
|||
set(INCLUDE_FILES
|
||||
include/mainwindow.h)
|
||||
|
||||
qt5_wrap_cpp(EDITOR_SRC ${INCLUDE_FILES})
|
||||
|
||||
add_executable(MaterialEditor
|
||||
src/main.cpp
|
||||
src/mainwindow.cpp
|
||||
${EDITOR_SRC})
|
||||
target_include_directories(MaterialEditor PRIVATE include)
|
||||
target_link_libraries(MaterialEditor Qt5::Widgets Engine ToolWindowManager EditorCommon)
|
||||
|
16
tools/materialeditor/include/mainwindow.h
Normal file
16
tools/materialeditor/include/mainwindow.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QVulkanInstance>
|
||||
|
||||
struct Context;
|
||||
|
||||
class MainWindow : public QMainWindow {
|
||||
public:
|
||||
MainWindow(Context& context);
|
||||
|
||||
private:
|
||||
Context& context;
|
||||
QVulkanInstance* instance = nullptr;
|
||||
};
|
||||
|
43
tools/materialeditor/src/main.cpp
Normal file
43
tools/materialeditor/src/main.cpp
Normal file
|
@ -0,0 +1,43 @@
|
|||
#include <QApplication>
|
||||
#include <QVulkanInstance>
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "platform.h"
|
||||
#include "context.h"
|
||||
#include "renderer.h"
|
||||
#include "worldmanager.h"
|
||||
#include "assetmanager.h"
|
||||
#include "ecs.h"
|
||||
#include "editorstyle.h"
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
QApplication app(argc, argv);
|
||||
app.setStyle(new EditorStyle());
|
||||
|
||||
GraphicsConfig config;
|
||||
config.shadowResolution = 256;
|
||||
config.dofDownscale = 2;
|
||||
config.filterPCF = true;
|
||||
config.enableImgui = false;
|
||||
|
||||
Context context;
|
||||
context.renderer = new Renderer(config);
|
||||
|
||||
assetManager.setRenderer(context.renderer);
|
||||
|
||||
worldManager.loadWorld("test.world");
|
||||
worldManager.switchWorld("test.world");
|
||||
|
||||
EntityID entity = ECS::createEntity(worldManager.getCurrentWorld());
|
||||
|
||||
auto cameraTransform = ECS::addComponent<TransformComponent>(entity);
|
||||
cameraTransform->position = glm::vec3(5, 5, 5);
|
||||
|
||||
auto cameraComponent = ECS::addComponent<CameraComponent>(entity);
|
||||
cameraComponent->fov = 70.0f;
|
||||
|
||||
MainWindow window(context);
|
||||
window.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
69
tools/materialeditor/src/mainwindow.cpp
Normal file
69
tools/materialeditor/src/mainwindow.cpp
Normal file
|
@ -0,0 +1,69 @@
|
|||
#include "mainwindow.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QMenuBar>
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
#include <QVulkanWindow>
|
||||
|
||||
#include "renderwindow.h"
|
||||
#include "renderer.h"
|
||||
|
||||
MainWindow::MainWindow(Context& context) : context(context) {
|
||||
setWindowTitle("Material Editor");
|
||||
resize(1280, 720);
|
||||
|
||||
QMenuBar* mainMenuBar = new QMenuBar();
|
||||
setMenuBar(mainMenuBar);
|
||||
|
||||
QMenu* fileMenu = new QMenu("File");
|
||||
mainMenuBar->addMenu(fileMenu);
|
||||
|
||||
// file
|
||||
{
|
||||
QAction* newAction = new QAction("New");
|
||||
newAction->setIcon(QIcon::fromTheme("document-new"));
|
||||
newAction->setShortcut(QKeySequence("CTRL+N"));
|
||||
fileMenu->addAction(newAction);
|
||||
|
||||
QAction* openAction = new QAction("Open");
|
||||
openAction->setIcon(QIcon::fromTheme("document-open"));
|
||||
openAction->setShortcut(QKeySequence("CTRL+O"));
|
||||
fileMenu->addAction(openAction);
|
||||
|
||||
QAction* openRecentAction = new QAction("Open Recent...");
|
||||
openRecentAction->setIcon(QIcon::fromTheme("document-open-recent"));
|
||||
fileMenu->addAction(openRecentAction);
|
||||
|
||||
fileMenu->addSeparator();
|
||||
|
||||
QAction* saveAction = new QAction("Save");
|
||||
saveAction->setIcon(QIcon::fromTheme("document-save"));
|
||||
saveAction->setShortcut(QKeySequence("CTRL+S"));
|
||||
fileMenu->addAction(saveAction);
|
||||
|
||||
QAction* saveAsAction = new QAction("Save As...");
|
||||
saveAsAction->setIcon(QIcon::fromTheme("document-save-as"));
|
||||
saveAsAction->setShortcut(QKeySequence("CTRL+SHIFT+S"));
|
||||
fileMenu->addAction(saveAsAction);
|
||||
|
||||
fileMenu->addSeparator();
|
||||
|
||||
QAction* quitAction = new QAction("Quit");
|
||||
connect(quitAction, &QAction::triggered, QCoreApplication::quit);
|
||||
quitAction->setIcon(QIcon::fromTheme("application-exit"));
|
||||
quitAction->setShortcut(QKeySequence("CTRL+Q"));
|
||||
fileMenu->addAction(quitAction);
|
||||
}
|
||||
|
||||
instance = new QVulkanInstance();
|
||||
instance->setVkInstance(context.renderer->getInstance());
|
||||
instance->create();
|
||||
|
||||
RendererWindow* window = new RendererWindow(context);
|
||||
window->setVulkanInstance(instance);
|
||||
|
||||
QWidget* wrapper = QWidget::createWindowContainer(window);
|
||||
setCentralWidget(wrapper);
|
||||
}
|
||||
|
Reference in a new issue