add QTVulkan example
This commit is contained in:
parent
d6ec92a86a
commit
da0fba1760
@ -1 +1 @@
|
||||
Subproject commit 7d35df757f12b204fd4556669d10b131cc373e3d
|
||||
Subproject commit 2b3b225659aa182b69a53b887815aa915dd8723e
|
@ -1 +1 @@
|
||||
Subproject commit 9b1975a8a5c74dfc5189b4d7f23d155b6e15cca8
|
||||
Subproject commit 165e95c0d54e4ba978bcba50a0f7b43200648309
|
@ -19,6 +19,8 @@ use_cm_module(Platform)
|
||||
use_cm_module(AssetsManage)
|
||||
use_cm_module(SceneGraph)
|
||||
|
||||
OPTION(SUPPORT_QT_VULKAN OFF)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
include_directories(${ULRE_3RDPTY_ROOT_PATH}/jsoncpp/include)
|
||||
add_subdirectory(3rdpty/jsoncpp)
|
||||
@ -49,3 +51,8 @@ SET(ULRE_RUNTIME_PATH ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
add_subdirectory(src)
|
||||
|
||||
add_subdirectory(example)
|
||||
|
||||
IF(SUPPORT_QT_VULKAN)
|
||||
fix_project_version(1,1)
|
||||
add_project_meta(META_FILES_TO_INCLUDE)
|
||||
ENDIF(SUPPORT_QT_VULKAN)
|
@ -9,6 +9,20 @@
|
||||
set_property(TARGET ${name} PROPERTY FOLDER "ULRE/Example/Vulkan")
|
||||
endmacro()
|
||||
|
||||
macro(CreateQtProject name)
|
||||
add_executable(${name} ${ARGN} VulkanAppFramework.h)
|
||||
|
||||
set(IDENTIFIER "com.hyzgame.texconv")
|
||||
|
||||
target_link_libraries(${name} ${ULRE} Qt5::Core Qt5::Gui Qt5::Widgets)
|
||||
|
||||
IF(WIN32)
|
||||
set_target_properties(${name} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ${ULRE_RUNTIME_PATH})
|
||||
ENDIF()
|
||||
|
||||
set_property(TARGET ${name} PROPERTY FOLDER "ULRE/Example/Vulkan")
|
||||
endmacro()
|
||||
|
||||
CreateProject(00.triangle first_triangle.cpp)
|
||||
CreateProject(01.FragCoord FragCoordTest.cpp)
|
||||
CreateProject(02.indices_rect indices_rect.cpp)
|
||||
@ -23,6 +37,15 @@ CreateProject(10.InlineGeometryScene InlineGeometryScene.cpp)
|
||||
CreateProject(11.Atomsphere Atomsphere.cpp)
|
||||
CreateProject(12.DrawText DrawText.cpp)
|
||||
|
||||
IF(SUPPORT_QT_VULKAN)
|
||||
include(QtCommon)
|
||||
CreateQtProject(13.VulkanQT VulkanQtApp.cpp
|
||||
QtVulkanWindow.cpp
|
||||
QtVulkanWindow.h
|
||||
QtVulkanMainWindow.h
|
||||
QtVulkanMainWindow.cpp)
|
||||
ENDIF(SUPPORT_QT_VULKAN)
|
||||
|
||||
#CreateProject(12.PBRBasic PBRBasic.cpp)
|
||||
#CreateProject(12.Deferred Deferred.cpp)
|
||||
#CreateProject(13.DeferredModel DeferredModel.cpp)
|
||||
|
21
example/Vulkan/QtVulkanMainWindow.cpp
Normal file
21
example/Vulkan/QtVulkanMainWindow.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include"QtVulkanMainWindow.h"
|
||||
|
||||
MainWindow::MainWindow(QtVulkanWindow *w):m_window(w)
|
||||
{
|
||||
this->setWindowTitle(QString("Vulkan and QT"));
|
||||
|
||||
QWidget *wrapper = QWidget::createWindowContainer(w);
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
|
||||
m_info=new QPlainTextEdit;
|
||||
m_info->setReadOnly(true);
|
||||
|
||||
layout->addWidget(m_info,1);
|
||||
layout->addWidget(wrapper,5);
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
void MainWindow::onVulkanInfoReceived(const QString &text)
|
||||
{
|
||||
m_info->setPlainText(text);
|
||||
}
|
24
example/Vulkan/QtVulkanMainWindow.h
Normal file
24
example/Vulkan/QtVulkanMainWindow.h
Normal file
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include<QWidget>
|
||||
#include<QPlainTextEdit>
|
||||
#include<QVBoxLayout>
|
||||
#include"QtVulkanWindow.h"
|
||||
|
||||
class MainWindow:public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
|
||||
QtVulkanWindow *m_window;
|
||||
QPlainTextEdit *m_info;
|
||||
|
||||
public slots:
|
||||
|
||||
void onVulkanInfoReceived(const QString &text);
|
||||
|
||||
public:
|
||||
|
||||
MainWindow(QtVulkanWindow *w);
|
||||
virtual ~MainWindow()=default;
|
||||
};//
|
25
example/Vulkan/QtVulkanWindow.cpp
Normal file
25
example/Vulkan/QtVulkanWindow.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include"QtVulkanWindow.h"
|
||||
|
||||
void VulkanRenderer::initResources()
|
||||
{
|
||||
m_devFuncs=m_window->vulkanInstance()->deviceFunctions(m_window->device());
|
||||
|
||||
}
|
||||
|
||||
void VulkanRenderer::initSwapChainResources()
|
||||
{
|
||||
}
|
||||
|
||||
void VulkanRenderer::releaseSwapChainResources()
|
||||
{
|
||||
}
|
||||
|
||||
void VulkanRenderer::releaseResources()
|
||||
{
|
||||
}
|
||||
|
||||
void VulkanRenderer::startNextFrame()
|
||||
{
|
||||
m_window->frameReady();
|
||||
m_window->requestUpdate(); // render continuously, throttled by the presentation rate
|
||||
}
|
40
example/Vulkan/QtVulkanWindow.h
Normal file
40
example/Vulkan/QtVulkanWindow.h
Normal file
@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
#include<QVulkanWindow>
|
||||
|
||||
class VulkanRenderer:public QVulkanWindowRenderer
|
||||
{
|
||||
private:
|
||||
|
||||
QVulkanWindow *m_window;
|
||||
QVulkanDeviceFunctions *m_devFuncs;
|
||||
|
||||
public:
|
||||
|
||||
VulkanRenderer(QVulkanWindow *w):m_window(w){}
|
||||
virtual ~VulkanRenderer()=default;
|
||||
|
||||
void initResources() override;
|
||||
void initSwapChainResources() override;
|
||||
void releaseSwapChainResources() override;
|
||||
void releaseResources() override;
|
||||
void startNextFrame() override;
|
||||
};//class VulkanRenderer:public QVulkanWindowRenderer
|
||||
|
||||
class QtVulkanWindow:public QVulkanWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
signals:
|
||||
|
||||
void vulkanInfoReceived(const QString &text);
|
||||
|
||||
public:
|
||||
|
||||
using QVulkanWindow::QVulkanWindow;
|
||||
virtual ~QtVulkanWindow()=default;
|
||||
|
||||
QVulkanWindowRenderer *createRenderer() override
|
||||
{
|
||||
return(new VulkanRenderer(this));
|
||||
}
|
||||
};
|
55
example/Vulkan/VulkanQtApp.cpp
Normal file
55
example/Vulkan/VulkanQtApp.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
#include<hgl/QT.h>
|
||||
#include<QObject>
|
||||
#include<QApplication>
|
||||
#include<QVulkanInstance>
|
||||
#include"QtVulkanMainWindow.h"
|
||||
#include<hgl/graph/vulkan/VKDevice.h>
|
||||
|
||||
using namespace hgl;
|
||||
using namespace hgl::graph;
|
||||
|
||||
//vulkan::Device *CreateRenderDevice(QVulkanWindow *qvw)
|
||||
//{
|
||||
// VkDevice vk_device=qvw->device();
|
||||
// VkPhysicalDevice vk_pdevice=qvw->physicalDevice();
|
||||
//
|
||||
//
|
||||
//
|
||||
//}
|
||||
|
||||
//class VulkanQtAppFramework
|
||||
//{
|
||||
// QVulkanInstance qv_inst;
|
||||
// QtVulkanWindow *qv_win;
|
||||
//
|
||||
//public:
|
||||
//
|
||||
// VulkanQtAppFramework()
|
||||
// {
|
||||
// }
|
||||
//
|
||||
//};//
|
||||
|
||||
int main(int argc,char **argv)
|
||||
{
|
||||
QApplication qt_app(argc,argv);
|
||||
|
||||
QVulkanInstance qv_inst;
|
||||
|
||||
if(!qv_inst.create())
|
||||
return -1;
|
||||
|
||||
QtVulkanWindow *qv_win=new QtVulkanWindow;
|
||||
qv_win->setVulkanInstance(&qv_inst);
|
||||
|
||||
MainWindow win(qv_win);
|
||||
|
||||
QObject::connect(qv_win,&QtVulkanWindow::vulkanInfoReceived,&win,&MainWindow::onVulkanInfoReceived);
|
||||
|
||||
win.resize(1280,720);
|
||||
win.show();
|
||||
|
||||
qt_app.exec();
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user