Adding basic keyboard input
This commit is contained in:
Vendored
+1
-1
Submodule external/zlib updated: 04f42ceca4...09155eaa2f
@@ -20,14 +20,13 @@ struct LightingParameter
|
|||||||
// data passed to fragment shader
|
// data passed to fragment shader
|
||||||
struct FragmentParameter
|
struct FragmentParameter
|
||||||
{
|
{
|
||||||
// clip position has to be the first attribute for some reason????
|
|
||||||
float4 position_CS : SV_Position;
|
|
||||||
float3 position_TS;
|
float3 position_TS;
|
||||||
float3 viewDir_TS;
|
float3 viewDir_TS;
|
||||||
float3 normal_WS;
|
float3 normal_WS;
|
||||||
float3 tangent_WS;
|
float3 tangent_WS;
|
||||||
float3 biTangent_WS;
|
float3 biTangent_WS;
|
||||||
float3 position_WS;
|
float3 position_WS;
|
||||||
|
float4 position_CS;
|
||||||
float2 texCoords;
|
float2 texCoords;
|
||||||
float3 vertexColor;
|
float3 vertexColor;
|
||||||
MaterialParameter getMaterialParameter()
|
MaterialParameter getMaterialParameter()
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ struct KeyboardInput
|
|||||||
bool mouse2;
|
bool mouse2;
|
||||||
float mouseX;
|
float mouseX;
|
||||||
float mouseY;
|
float mouseY;
|
||||||
|
float deltaX;
|
||||||
|
float deltaY;
|
||||||
};
|
};
|
||||||
} // namespace Component
|
} // namespace Component
|
||||||
} // namespace Seele
|
} // namespace Seele
|
||||||
@@ -468,6 +468,13 @@ CommandPool::CommandPool(PGraphics graphics, PQueue queue)
|
|||||||
|
|
||||||
CommandPool::~CommandPool()
|
CommandPool::~CommandPool()
|
||||||
{
|
{
|
||||||
|
for (auto& command : allocatedBuffers)
|
||||||
|
{
|
||||||
|
command->waitForCommand();
|
||||||
|
}
|
||||||
|
allocatedRenderCommands.clear();
|
||||||
|
allocatedComputeCommands.clear();
|
||||||
|
allocatedBuffers.clear();
|
||||||
vkDestroyCommandPool(graphics->getDevice(), commandPool, nullptr);
|
vkDestroyCommandPool(graphics->getDevice(), commandPool, nullptr);
|
||||||
graphics = nullptr;
|
graphics = nullptr;
|
||||||
queue = nullptr;
|
queue = nullptr;
|
||||||
|
|||||||
@@ -522,8 +522,6 @@ void Graphics::createDevice(GraphicsInitializer initializer)
|
|||||||
.pNext = &descriptorIndexing,
|
.pNext = &descriptorIndexing,
|
||||||
.queueCreateInfoCount = (uint32)queueInfos.size(),
|
.queueCreateInfoCount = (uint32)queueInfos.size(),
|
||||||
.pQueueCreateInfos = queueInfos.data(),
|
.pQueueCreateInfos = queueInfos.data(),
|
||||||
.enabledLayerCount = (uint32_t)initializer.layers.size(),
|
|
||||||
.ppEnabledLayerNames = initializer.layers.data(),
|
|
||||||
.enabledExtensionCount = (uint32)initializer.deviceExtensions.size(),
|
.enabledExtensionCount = (uint32)initializer.deviceExtensions.size(),
|
||||||
.ppEnabledExtensionNames = initializer.deviceExtensions.data(),
|
.ppEnabledExtensionNames = initializer.deviceExtensions.data(),
|
||||||
.pEnabledFeatures = &features,
|
.pEnabledFeatures = &features,
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#include "Resources.h"
|
#include "Resources.h"
|
||||||
#include "Enums.h"
|
#include "Enums.h"
|
||||||
#include "Graphics.h"
|
#include "Graphics.h"
|
||||||
|
#include "Command.h"
|
||||||
|
#include "Window.h"
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
using namespace Seele::Vulkan;
|
using namespace Seele::Vulkan;
|
||||||
@@ -18,17 +20,7 @@ Semaphore::Semaphore(PGraphics graphics)
|
|||||||
|
|
||||||
Semaphore::~Semaphore()
|
Semaphore::~Semaphore()
|
||||||
{
|
{
|
||||||
uint64 value = 0;
|
graphics->getDestructionManager()->queueSemaphore(graphics->getGraphicsCommands()->getCommands(), handle);
|
||||||
VkSemaphoreWaitInfo waitInfo = {
|
|
||||||
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO,
|
|
||||||
.pNext = nullptr,
|
|
||||||
.flags = 0,
|
|
||||||
.semaphoreCount = 1,
|
|
||||||
.pSemaphores = &handle,
|
|
||||||
.pValues = &value,
|
|
||||||
};
|
|
||||||
VK_CHECK(vkWaitSemaphores(graphics->getDevice(), &waitInfo, 10000));
|
|
||||||
vkDestroySemaphore(graphics->getDevice(), handle, nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Fence::Fence(PGraphics graphics)
|
Fence::Fence(PGraphics graphics)
|
||||||
|
|||||||
@@ -41,9 +41,11 @@ TextureBase::TextureBase(PGraphics graphics, VkImageViewType viewType,
|
|||||||
, image(existingImage)
|
, image(existingImage)
|
||||||
, aspect(getAspectFromFormat(createInfo.format))
|
, aspect(getAspectFromFormat(createInfo.format))
|
||||||
, layout(Gfx::SE_IMAGE_LAYOUT_UNDEFINED)
|
, layout(Gfx::SE_IMAGE_LAYOUT_UNDEFINED)
|
||||||
|
, ownsImage(false)
|
||||||
{
|
{
|
||||||
if (existingImage == VK_NULL_HANDLE)
|
if (existingImage == VK_NULL_HANDLE)
|
||||||
{
|
{
|
||||||
|
ownsImage = true;
|
||||||
PAllocator pool = graphics->getAllocator();
|
PAllocator pool = graphics->getAllocator();
|
||||||
VkImageType type = VK_IMAGE_TYPE_MAX_ENUM;
|
VkImageType type = VK_IMAGE_TYPE_MAX_ENUM;
|
||||||
VkImageCreateFlags flags = 0;
|
VkImageCreateFlags flags = 0;
|
||||||
@@ -175,13 +177,16 @@ TextureBase::TextureBase(PGraphics graphics, VkImageViewType viewType,
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
VK_CHECK(vkCreateImageView(graphics->getDevice(), &viewInfo, nullptr, &defaultView));
|
VK_CHECK(vkCreateImageView(graphics->getDevice(), &viewInfo, nullptr, &imageView));
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureBase::~TextureBase()
|
TextureBase::~TextureBase()
|
||||||
{
|
{
|
||||||
|
if (ownsImage)
|
||||||
|
{
|
||||||
graphics->getDestructionManager()->queueImage(graphics->getQueueCommands(currentOwner)->getCommands(), image);
|
graphics->getDestructionManager()->queueImage(graphics->getQueueCommands(currentOwner)->getCommands(), image);
|
||||||
graphics->getDestructionManager()->queueImageView(graphics->getQueueCommands(currentOwner)->getCommands(), defaultView);
|
}
|
||||||
|
graphics->getDestructionManager()->queueImageView(graphics->getQueueCommands(currentOwner)->getCommands(), imageView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public:
|
|||||||
}
|
}
|
||||||
constexpr VkImageView getView() const
|
constexpr VkImageView getView() const
|
||||||
{
|
{
|
||||||
return defaultView;
|
return imageView;
|
||||||
}
|
}
|
||||||
constexpr Gfx::SeImageLayout getLayout() const
|
constexpr Gfx::SeImageLayout getLayout() const
|
||||||
{
|
{
|
||||||
@@ -72,9 +72,10 @@ protected:
|
|||||||
Gfx::SeFormat format;
|
Gfx::SeFormat format;
|
||||||
Gfx::SeImageUsageFlags usage;
|
Gfx::SeImageUsageFlags usage;
|
||||||
VkImage image;
|
VkImage image;
|
||||||
VkImageView defaultView;
|
VkImageView imageView;
|
||||||
VkImageAspectFlags aspect;
|
VkImageAspectFlags aspect;
|
||||||
Gfx::SeImageLayout layout;
|
Gfx::SeImageLayout layout;
|
||||||
|
uint8 ownsImage;
|
||||||
friend class Graphics;
|
friend class Graphics;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,11 @@ void glfwCloseCallback(GLFWwindow* handle)
|
|||||||
Window* window = (Window*)glfwGetWindowUserPointer(handle);
|
Window* window = (Window*)glfwGetWindowUserPointer(handle);
|
||||||
window->closeCallback();
|
window->closeCallback();
|
||||||
}
|
}
|
||||||
|
void glfwResizeCallback(GLFWwindow* handle, int width, int height)
|
||||||
|
{
|
||||||
|
Window* window = (Window*)glfwGetWindowUserPointer(handle);
|
||||||
|
window->resize(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
Window::Window(PGraphics graphics, const WindowCreateInfo &createInfo)
|
Window::Window(PGraphics graphics, const WindowCreateInfo &createInfo)
|
||||||
: graphics(graphics)
|
: graphics(graphics)
|
||||||
@@ -68,20 +73,11 @@ Window::Window(PGraphics graphics, const WindowCreateInfo &createInfo)
|
|||||||
glfwSetScrollCallback(handle, &glfwScrollCallback);
|
glfwSetScrollCallback(handle, &glfwScrollCallback);
|
||||||
glfwSetDropCallback(handle, &glfwFileCallback);
|
glfwSetDropCallback(handle, &glfwFileCallback);
|
||||||
glfwSetWindowCloseCallback(handle, &glfwCloseCallback);
|
glfwSetWindowCloseCallback(handle, &glfwCloseCallback);
|
||||||
|
glfwSetWindowSizeCallback(handle, &glfwResizeCallback);
|
||||||
|
|
||||||
glfwCreateWindowSurface(instance, handle, nullptr, &surface);
|
glfwCreateWindowSurface(instance, handle, nullptr, &surface);
|
||||||
|
|
||||||
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(graphics->getPhysicalDevice(), surface, &capabilities);
|
querySurface();
|
||||||
|
|
||||||
uint32 numFormats;
|
|
||||||
vkGetPhysicalDeviceSurfaceFormatsKHR(graphics->getPhysicalDevice(), surface, &numFormats, nullptr);
|
|
||||||
supportedFormats.resize(numFormats);
|
|
||||||
vkGetPhysicalDeviceSurfaceFormatsKHR(graphics->getPhysicalDevice(), surface, &numFormats, supportedFormats.data());
|
|
||||||
|
|
||||||
uint32 numPresentModes;
|
|
||||||
vkGetPhysicalDeviceSurfacePresentModesKHR(graphics->getPhysicalDevice(), surface, &numPresentModes, nullptr);
|
|
||||||
supportedPresentModes.resize(numFormats);
|
|
||||||
vkGetPhysicalDeviceSurfacePresentModesKHR(graphics->getPhysicalDevice(), surface, &numPresentModes, supportedPresentModes.data());
|
|
||||||
chooseSwapSurfaceFormat();
|
chooseSwapSurfaceFormat();
|
||||||
framebufferFormat = cast(format.format);
|
framebufferFormat = cast(format.format);
|
||||||
chooseSwapPresentMode();
|
chooseSwapPresentMode();
|
||||||
@@ -175,6 +171,33 @@ void Window::setCloseCallback(std::function<void()> callback)
|
|||||||
closeCallback = callback;
|
closeCallback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::resize(int width, int height)
|
||||||
|
{
|
||||||
|
querySurface();
|
||||||
|
chooseSwapSurfaceFormat();
|
||||||
|
framebufferFormat = cast(format.format);
|
||||||
|
chooseSwapPresentMode();
|
||||||
|
chooseSwapExtent();
|
||||||
|
framebufferWidth = extent.width;
|
||||||
|
framebufferHeight = extent.height;
|
||||||
|
createSwapChain();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Window::querySurface()
|
||||||
|
{
|
||||||
|
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(graphics->getPhysicalDevice(), surface, &capabilities);
|
||||||
|
|
||||||
|
uint32 numFormats;
|
||||||
|
vkGetPhysicalDeviceSurfaceFormatsKHR(graphics->getPhysicalDevice(), surface, &numFormats, nullptr);
|
||||||
|
supportedFormats.resize(numFormats);
|
||||||
|
vkGetPhysicalDeviceSurfaceFormatsKHR(graphics->getPhysicalDevice(), surface, &numFormats, supportedFormats.data());
|
||||||
|
|
||||||
|
uint32 numPresentModes;
|
||||||
|
vkGetPhysicalDeviceSurfacePresentModesKHR(graphics->getPhysicalDevice(), surface, &numPresentModes, nullptr);
|
||||||
|
supportedPresentModes.resize(numFormats);
|
||||||
|
vkGetPhysicalDeviceSurfacePresentModesKHR(graphics->getPhysicalDevice(), surface, &numPresentModes, supportedPresentModes.data());
|
||||||
|
}
|
||||||
|
|
||||||
void Window::chooseSwapSurfaceFormat()
|
void Window::chooseSwapSurfaceFormat()
|
||||||
{
|
{
|
||||||
for (const auto& supportedFormat : supportedFormats)
|
for (const auto& supportedFormat : supportedFormats)
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ public:
|
|||||||
virtual void setScrollCallback(std::function<void(double, double)> callback) override;
|
virtual void setScrollCallback(std::function<void(double, double)> callback) override;
|
||||||
virtual void setFileCallback(std::function<void(int, const char**)> callback) override;
|
virtual void setFileCallback(std::function<void(int, const char**)> callback) override;
|
||||||
virtual void setCloseCallback(std::function<void()> callback);
|
virtual void setCloseCallback(std::function<void()> callback);
|
||||||
|
void resize(int width, int height);
|
||||||
|
|
||||||
std::function<void(KeyCode, InputAction, KeyModifier)> keyCallback;
|
std::function<void(KeyCode, InputAction, KeyModifier)> keyCallback;
|
||||||
std::function<void(double, double)> mouseMoveCallback;
|
std::function<void(double, double)> mouseMoveCallback;
|
||||||
@@ -31,6 +32,7 @@ public:
|
|||||||
std::function<void(int, const char**)> fileCallback;
|
std::function<void(int, const char**)> fileCallback;
|
||||||
std::function<void()> closeCallback;
|
std::function<void()> closeCallback;
|
||||||
protected:
|
protected:
|
||||||
|
void querySurface();
|
||||||
void chooseSwapSurfaceFormat();
|
void chooseSwapSurfaceFormat();
|
||||||
void chooseSwapPresentMode();
|
void chooseSwapPresentMode();
|
||||||
void chooseSwapExtent();
|
void chooseSwapExtent();
|
||||||
|
|||||||
@@ -123,11 +123,11 @@ void Material::compile()
|
|||||||
// initialize variable state
|
// initialize variable state
|
||||||
for(const auto& expr :codeExpressions)
|
for(const auto& expr :codeExpressions)
|
||||||
{
|
{
|
||||||
codeStream << expr->evaluate(varState);
|
codeStream << "\t\t" << expr->evaluate(varState);
|
||||||
}
|
}
|
||||||
for(const auto& [name, exp] : brdf.variables)
|
for(const auto& [name, exp] : brdf.variables)
|
||||||
{
|
{
|
||||||
codeStream << "\t\tresult." << name << " = " << varState[exp] << ";";
|
codeStream << "\t\tresult." << name << " = " << varState[exp] << ";" << std::endl;
|
||||||
}
|
}
|
||||||
codeStream << "\t\treturn result;\n";
|
codeStream << "\t\treturn result;\n";
|
||||||
codeStream << "\t}\n";
|
codeStream << "\t}\n";
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ target_sources(Engine
|
|||||||
ComponentSystem.h
|
ComponentSystem.h
|
||||||
Executor.h
|
Executor.h
|
||||||
Executor.cpp
|
Executor.cpp
|
||||||
|
KeyboardInput.h
|
||||||
|
KeyboardInput.cpp
|
||||||
LightGather.h
|
LightGather.h
|
||||||
LightGather.cpp
|
LightGather.cpp
|
||||||
MeshUpdater.h
|
MeshUpdater.h
|
||||||
@@ -19,6 +21,7 @@ target_sources(Engine
|
|||||||
CameraUpdater.h
|
CameraUpdater.h
|
||||||
ComponentSystem.h
|
ComponentSystem.h
|
||||||
Executor.h
|
Executor.h
|
||||||
|
KeyboardInput.h
|
||||||
LightGather.h
|
LightGather.h
|
||||||
MeshUpdater.h
|
MeshUpdater.h
|
||||||
SystemBase.h
|
SystemBase.h
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
#include "KeyboardInput.h"
|
||||||
|
|
||||||
|
using namespace Seele;
|
||||||
|
using namespace Seele::System;
|
||||||
|
|
||||||
|
KeyboardInput::KeyboardInput(PScene scene)
|
||||||
|
: ComponentSystem<Component::KeyboardInput>(scene)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
KeyboardInput::~KeyboardInput()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KeyboardInput::update(Component::KeyboardInput& input)
|
||||||
|
{
|
||||||
|
std::memcpy(input.keys.data(), keys.data(), sizeof(keys));
|
||||||
|
input.deltaX = deltaX;
|
||||||
|
input.deltaY = deltaY;
|
||||||
|
input.mouseX = mouseX;
|
||||||
|
input.mouseY = mouseY;
|
||||||
|
input.mouse1 = mouse1;
|
||||||
|
input.mouse2 = mouse2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KeyboardInput::keyCallback(KeyCode code, InputAction action, KeyModifier modifier)
|
||||||
|
{
|
||||||
|
keys[code] = action != InputAction::RELEASE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KeyboardInput::mouseCallback(double x, double y)
|
||||||
|
{
|
||||||
|
mouseX = x;
|
||||||
|
mouseY = y;
|
||||||
|
deltaX = x - lastMouseX;
|
||||||
|
deltaY = y - lastMouseY;
|
||||||
|
lastMouseX = x;
|
||||||
|
lastMouseY = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KeyboardInput::mouseButtonCallback(MouseButton button, InputAction action, KeyModifier modifier)
|
||||||
|
{
|
||||||
|
if (button == MouseButton::MOUSE_BUTTON_1)
|
||||||
|
{
|
||||||
|
mouse1 = action != InputAction::RELEASE;
|
||||||
|
}
|
||||||
|
if (button == MouseButton::MOUSE_BUTTON_2)
|
||||||
|
{
|
||||||
|
mouse2 = action != InputAction::RELEASE;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "ComponentSystem.h"
|
||||||
|
#include "Component/KeyboardInput.h"
|
||||||
|
|
||||||
|
namespace Seele
|
||||||
|
{
|
||||||
|
namespace System
|
||||||
|
{
|
||||||
|
class KeyboardInput : public ComponentSystem<Component::KeyboardInput>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
KeyboardInput(PScene scene);
|
||||||
|
virtual ~KeyboardInput();
|
||||||
|
virtual void update(Component::KeyboardInput& input) override;
|
||||||
|
void keyCallback(KeyCode code, InputAction action, KeyModifier modifier);
|
||||||
|
void mouseCallback(double xPos, double yPos);
|
||||||
|
void mouseButtonCallback(MouseButton button, InputAction action, KeyModifier modifier);
|
||||||
|
private:
|
||||||
|
Seele::StaticArray<bool, (size_t)KeyCode::KEY_LAST> keys;
|
||||||
|
bool mouse1 = false;
|
||||||
|
bool mouse2 = false;
|
||||||
|
float lastMouseX = 0;
|
||||||
|
float lastMouseY = 0;
|
||||||
|
float mouseX = 0;
|
||||||
|
float mouseY = 0;
|
||||||
|
float deltaX = 0;
|
||||||
|
float deltaY = 0;
|
||||||
|
};
|
||||||
|
DEFINE_REF(KeyboardInput)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|
||||||
void SystemGraph::addSystem(System::UPSystemBase system)
|
void SystemGraph::addSystem(System::OSystemBase system)
|
||||||
{
|
{
|
||||||
systems.add(std::move(system));
|
systems.add(std::move(system));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ namespace Seele
|
|||||||
class SystemGraph
|
class SystemGraph
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void addSystem(System::UPSystemBase system);
|
void addSystem(System::OSystemBase system);
|
||||||
void run(dp::thread_pool<>& threadPool, float deltaTime);
|
void run(dp::thread_pool<>& threadPool, float deltaTime);
|
||||||
private:
|
private:
|
||||||
Array<System::UPSystemBase> systems;
|
Array<System::OSystemBase> systems;
|
||||||
};
|
};
|
||||||
DEFINE_REF(SystemGraph)
|
DEFINE_REF(SystemGraph)
|
||||||
} // namespace Seele;
|
} // namespace Seele;
|
||||||
@@ -21,7 +21,6 @@ GameView::GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreate
|
|||||||
SkyboxRenderPass(graphics, scene)
|
SkyboxRenderPass(graphics, scene)
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
camera = new CameraActor(scene);
|
|
||||||
reloadGame();
|
reloadGame();
|
||||||
renderGraph.updateViewport(viewport);
|
renderGraph.updateViewport(viewport);
|
||||||
}
|
}
|
||||||
@@ -65,7 +64,12 @@ void GameView::prepareRender()
|
|||||||
|
|
||||||
void GameView::render()
|
void GameView::render()
|
||||||
{
|
{
|
||||||
renderGraph.render(camera->accessComponent<Component::Camera>());
|
Component::Camera cam;
|
||||||
|
scene->view<Component::Camera>([&cam](Component::Camera& c) {
|
||||||
|
if (c.mainCamera)
|
||||||
|
cam = c;
|
||||||
|
});
|
||||||
|
renderGraph.render(cam);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameView::reloadGame()
|
void GameView::reloadGame()
|
||||||
@@ -74,75 +78,33 @@ void GameView::reloadGame()
|
|||||||
|
|
||||||
systemGraph = new SystemGraph();
|
systemGraph = new SystemGraph();
|
||||||
gameInterface.getGame()->setupScene(scene, systemGraph);
|
gameInterface.getGame()->setupScene(scene, systemGraph);
|
||||||
|
System::OKeyboardInput keyInput = new System::KeyboardInput(scene);
|
||||||
|
keyboardSystem = keyInput;
|
||||||
|
systemGraph->addSystem(std::move(keyInput));
|
||||||
systemGraph->addSystem(new System::LightGather(scene));
|
systemGraph->addSystem(new System::LightGather(scene));
|
||||||
systemGraph->addSystem(new System::MeshUpdater(scene));
|
systemGraph->addSystem(new System::MeshUpdater(scene));
|
||||||
systemGraph->addSystem(new System::CameraUpdater(scene));
|
systemGraph->addSystem(new System::CameraUpdater(scene));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameView::keyCallback(KeyCode code, InputAction action, KeyModifier)
|
void GameView::keyCallback(KeyCode code, InputAction action, KeyModifier modifier)
|
||||||
{
|
{
|
||||||
scene->view<Component::KeyboardInput>([=, this](Component::KeyboardInput& input)
|
keyboardSystem->keyCallback(code, action, modifier);
|
||||||
{
|
|
||||||
//if(code == KeyCode::KEY_R && action == InputAction::PRESS)
|
|
||||||
//{
|
|
||||||
// auto cubeMesh = AssetRegistry::findMesh("cube");
|
|
||||||
// PEntity cube2 = new Entity(scene);
|
|
||||||
// Component::Transform& cube2Transform = cube2->attachComponent<Component::Transform>();
|
|
||||||
// cube2Transform.setPosition(Vector(0, 20, 0));
|
|
||||||
// cube2Transform.setRotation(Quaternion(Vector(0.f, 90.f, 90.f)));
|
|
||||||
// cube2Transform.setScale(Vector(2.f, 2.f, 2.f));
|
|
||||||
// cubeMesh->physicsMesh.type = Component::ColliderType::DYNAMIC;
|
|
||||||
// cube2->attachComponent<Component::Collider>(cubeMesh->physicsMesh);
|
|
||||||
// cube2->attachComponent<Component::StaticMesh>(cubeMesh);
|
|
||||||
// Component::RigidBody& physics2 = cube2->attachComponent<Component::RigidBody>();
|
|
||||||
// physics2.linearMomentum = Vector(0, -10, 0);
|
|
||||||
// physics2.angularMomentum = Vector(0, 0, 0);
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//if(code == KeyCode::KEY_B && action == InputAction::PRESS)
|
|
||||||
//{
|
|
||||||
// showDebug = !showDebug;
|
|
||||||
// debugPassData.vertices.clear();
|
|
||||||
//}
|
|
||||||
if(code == KeyCode::KEY_R && action == InputAction::PRESS)
|
|
||||||
{
|
|
||||||
reloadGame();
|
|
||||||
}
|
|
||||||
|
|
||||||
input.keys[code] = action != InputAction::RELEASE;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameView::mouseMoveCallback(double xPos, double yPos)
|
void GameView::mouseMoveCallback(double xPos, double yPos)
|
||||||
{
|
{
|
||||||
scene->view<Component::KeyboardInput>([=](Component::KeyboardInput& input)
|
keyboardSystem->mouseCallback(xPos, yPos);
|
||||||
{
|
|
||||||
input.mouseX = static_cast<float>(xPos);
|
|
||||||
input.mouseY = static_cast<float>(yPos);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameView::mouseButtonCallback(MouseButton button, InputAction action, KeyModifier)
|
void GameView::mouseButtonCallback(MouseButton button, InputAction action, KeyModifier modifier)
|
||||||
{
|
{
|
||||||
scene->view<Component::KeyboardInput>([=](Component::KeyboardInput& input)
|
keyboardSystem->mouseButtonCallback(button, action, modifier);
|
||||||
{
|
|
||||||
if (button == MouseButton::MOUSE_BUTTON_1)
|
|
||||||
{
|
|
||||||
input.mouse1 = action != InputAction::RELEASE;
|
|
||||||
}
|
|
||||||
if (button == MouseButton::MOUSE_BUTTON_2)
|
|
||||||
{
|
|
||||||
input.mouse2 = action != InputAction::RELEASE;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameView::scrollCallback(double, double)
|
void GameView::scrollCallback(double, double)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameView::fileCallback(int, const char**)
|
void GameView::fileCallback(int, const char**)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "Graphics/RenderPass/LightCullingPass.h"
|
#include "Graphics/RenderPass/LightCullingPass.h"
|
||||||
#include "Graphics/RenderPass/BasePass.h"
|
#include "Graphics/RenderPass/BasePass.h"
|
||||||
#include "Graphics/RenderPass/SkyboxRenderPass.h"
|
#include "Graphics/RenderPass/SkyboxRenderPass.h"
|
||||||
|
#include "System/KeyboardInput.h"
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include "Platform/Windows/GameInterface.h" // TODO
|
#include "Platform/Windows/GameInterface.h" // TODO
|
||||||
#else
|
#else
|
||||||
@@ -28,7 +29,6 @@ public:
|
|||||||
void reloadGame();
|
void reloadGame();
|
||||||
private:
|
private:
|
||||||
OScene scene;
|
OScene scene;
|
||||||
OEntity camera;
|
|
||||||
GameInterface gameInterface;
|
GameInterface gameInterface;
|
||||||
RenderGraph<
|
RenderGraph<
|
||||||
DepthPrepass,
|
DepthPrepass,
|
||||||
@@ -38,6 +38,7 @@ private:
|
|||||||
> renderGraph;
|
> renderGraph;
|
||||||
|
|
||||||
PSystemGraph systemGraph;
|
PSystemGraph systemGraph;
|
||||||
|
System::PKeyboardInput keyboardSystem;
|
||||||
dp::thread_pool<> threadPool;
|
dp::thread_pool<> threadPool;
|
||||||
float updateTime = 0;
|
float updateTime = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user