Simple dx render example.
This commit is contained in:
parent
36515556b8
commit
e0cad34d55
22 changed files with 339 additions and 60 deletions
|
@ -1,11 +1,16 @@
|
|||
#include "TestCase.h"
|
||||
#include "TestCaseRunner.h"
|
||||
|
||||
#include "MainApplication.h"
|
||||
#include "GuiApplication.h"
|
||||
#include "TestUiApplication.h"
|
||||
|
||||
#include "TestFramework.h"
|
||||
|
||||
#include "DesktopManager.h"
|
||||
#include "MeshPrimitives.h"
|
||||
#include "MeshNode.h"
|
||||
#include "Scene.h"
|
||||
#include "Widget.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
@ -14,5 +19,16 @@ TEST_CASE(TestDirectXRendering, "graphics")
|
|||
{
|
||||
auto gui_app = TestCaseRunner::getInstance().getTestApplication();
|
||||
|
||||
auto drawing_context = gui_app->getDesktopManager()->getWindowManager()->getMainWindow();
|
||||
|
||||
auto scene = drawing_context->getScene();
|
||||
|
||||
auto mesh = MeshPrimitives::buildRectangleAsTriMesh();
|
||||
auto mesh_node = std::make_unique<MeshNode>(DiscretePoint(0, 0));
|
||||
|
||||
mesh_node->setMesh(mesh.get());
|
||||
|
||||
scene->addNode(mesh_node.get());
|
||||
scene->update(nullptr);
|
||||
gui_app->run();
|
||||
};
|
|
@ -4,10 +4,12 @@ add_library(test_utils STATIC
|
|||
TestCaseRunner.h
|
||||
TestFramework.h
|
||||
TestCaseRunner.cpp
|
||||
TestUiApplication.h
|
||||
TestUiApplication.cpp
|
||||
)
|
||||
|
||||
target_include_directories(test_utils PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_link_libraries(test_utils core)
|
||||
target_link_libraries(test_utils core client)
|
||||
set_property(TARGET test_utils PROPERTY FOLDER test)
|
||||
|
||||
configure_file(TestDataLocations.h.in TestDataLocations.h)
|
|
@ -1,6 +1,7 @@
|
|||
#include "TestCaseRunner.h"
|
||||
|
||||
#include "FileLogger.h"
|
||||
#include "TestUiApplication.h"
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
@ -18,12 +19,12 @@ TestCaseRunner::~TestCaseRunner()
|
|||
|
||||
}
|
||||
|
||||
GuiApplication* TestCaseRunner::getTestApplication()
|
||||
TestUiApplication* TestCaseRunner::getTestApplication()
|
||||
{
|
||||
return mTestApplication;
|
||||
}
|
||||
|
||||
void TestCaseRunner::setTestApplication(GuiApplication* app)
|
||||
void TestCaseRunner::setTestApplication(TestUiApplication* app)
|
||||
{
|
||||
mTestApplication = app;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
class GuiApplication;
|
||||
class TestUiApplication;
|
||||
|
||||
class TestCaseRunner
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ public:
|
|||
|
||||
~TestCaseRunner();
|
||||
|
||||
GuiApplication* getTestApplication();
|
||||
TestUiApplication* getTestApplication();
|
||||
|
||||
void addTestCase(const std::string& label, const std::string& tag, TestCase::TestCaseFunction func);
|
||||
|
||||
|
@ -24,10 +24,10 @@ public:
|
|||
|
||||
bool run(const std::vector<std::string>& args);
|
||||
|
||||
void setTestApplication(GuiApplication* app);
|
||||
void setTestApplication(TestUiApplication* app);
|
||||
private:
|
||||
|
||||
GuiApplication* mTestApplication{ nullptr };
|
||||
TestUiApplication* mTestApplication{ nullptr };
|
||||
std::vector<std::string> mFailingTests;
|
||||
static bool sLastTestFailed;
|
||||
static std::string sFailureLine;
|
||||
|
|
14
test/test_utils/TestUiApplication.cpp
Normal file
14
test/test_utils/TestUiApplication.cpp
Normal file
|
@ -0,0 +1,14 @@
|
|||
#include "TestUiApplication.h"
|
||||
|
||||
#include "MainApplication.h"
|
||||
|
||||
TestUiApplication::TestUiApplication(std::unique_ptr<CommandLineArgs> args, std::unique_ptr<MainApplication> mainApp)
|
||||
: GuiApplication(std::move(args), std::move(mainApp))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DesktopManager* TestUiApplication::getDesktopManager() const
|
||||
{
|
||||
return mDesktopManager.get();
|
||||
}
|
13
test/test_utils/TestUiApplication.h
Normal file
13
test/test_utils/TestUiApplication.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include "GuiApplication.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class TestUiApplication : public GuiApplication
|
||||
{
|
||||
public:
|
||||
TestUiApplication(std::unique_ptr<CommandLineArgs> args = nullptr, std::unique_ptr<MainApplication> mainApp = nullptr);
|
||||
|
||||
DesktopManager* getDesktopManager() const;
|
||||
};
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "CommandLineArgs.h"
|
||||
#include "MainApplication.h"
|
||||
#include "GuiApplication.h"
|
||||
#include "TestUiApplication.h"
|
||||
#include "Widget.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -12,16 +12,6 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
class TestApp : public GuiApplication
|
||||
{
|
||||
public:
|
||||
TestApp(std::unique_ptr<CommandLineArgs> args = nullptr, std::unique_ptr<MainApplication> mainApp = nullptr)
|
||||
: GuiApplication(std::move(args), std::move(mainApp))
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef _WIN32
|
||||
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
|
||||
{
|
||||
|
@ -41,7 +31,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
|
|||
|
||||
main_app->initialize(std::move(args), std::move(applicationContext));
|
||||
|
||||
auto gui_app = std::make_unique<TestApp>(nullptr, std::move(main_app));
|
||||
auto gui_app = std::make_unique<TestUiApplication>(nullptr, std::move(main_app));
|
||||
|
||||
#else
|
||||
int main(int argc, char *argv[])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue