Input & Resource Managers
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@ -53,3 +53,5 @@ build-linux/
|
|||||||
build-ios/
|
build-ios/
|
||||||
build-mac/
|
build-mac/
|
||||||
build-android/
|
build-android/
|
||||||
|
|
||||||
|
imgui.ini
|
||||||
|
|||||||
6
.vscode/settings.json
vendored
6
.vscode/settings.json
vendored
@ -17,6 +17,10 @@
|
|||||||
"xlocale": "cpp",
|
"xlocale": "cpp",
|
||||||
"xlocinfo": "cpp",
|
"xlocinfo": "cpp",
|
||||||
"xstring": "cpp",
|
"xstring": "cpp",
|
||||||
"any": "cpp"
|
"any": "cpp",
|
||||||
|
"array": "cpp",
|
||||||
|
"ranges": "cpp",
|
||||||
|
"span": "cpp",
|
||||||
|
"vector": "cpp"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -25,4 +25,4 @@ target_include_directories(IAEngine PUBLIC Src/Inc)
|
|||||||
target_include_directories(IAEngine PRIVATE Src/Imp/HPP)
|
target_include_directories(IAEngine PRIVATE Src/Imp/HPP)
|
||||||
|
|
||||||
target_link_libraries(IAEngine PUBLIC IACore ImGui glm::glm)
|
target_link_libraries(IAEngine PUBLIC IACore ImGui glm::glm)
|
||||||
target_link_libraries(IAEngine PRIVATE SDL3::SDL3 SDL3_mixer::SDL3_mixer RmlUi::RmlUi)
|
target_link_libraries(IAEngine PRIVATE SDL3::SDL3 SDL3_mixer::SDL3_mixer RmlUi::RmlUi STB)
|
||||||
|
|||||||
@ -17,13 +17,33 @@
|
|||||||
#include <AudioManager.hpp>
|
#include <AudioManager.hpp>
|
||||||
#include <IAEngine/Engine.hpp>
|
#include <IAEngine/Engine.hpp>
|
||||||
|
|
||||||
|
#include <SDL3/SDL_iostream.h>
|
||||||
|
|
||||||
namespace ia::iae
|
namespace ia::iae
|
||||||
{
|
{
|
||||||
|
MIX_Mixer *AudioManager::s_mixer;
|
||||||
|
|
||||||
VOID AudioManager::Initialize()
|
VOID AudioManager::Initialize()
|
||||||
{
|
{
|
||||||
|
if (!MIX_Init())
|
||||||
|
THROW_UNKNOWN("Failed to initialize SDL Mixer: ", SDL_GetError());
|
||||||
|
|
||||||
|
if (!(s_mixer = MIX_CreateMixerDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, NULL)))
|
||||||
|
THROW_UNKNOWN(BuildString("Failed to create the SDL mixer: ", SDL_GetError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID AudioManager::Terminate()
|
VOID AudioManager::Terminate()
|
||||||
{
|
{
|
||||||
|
MIX_DestroyMixer(s_mixer);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Handle AudioManager::CreateAudio(IN PCUINT8 encodedData, IN SIZE_T encodedDataSize)
|
||||||
|
{
|
||||||
|
return (Handle) MIX_LoadAudio_IO(s_mixer, SDL_IOFromConstMem(encodedData, encodedDataSize), false, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID AudioManager::DestoryAudio(IN Handle handle)
|
||||||
|
{
|
||||||
|
MIX_DestroyAudio((MIX_Audio*)handle);
|
||||||
|
}
|
||||||
|
} // namespace ia::iae
|
||||||
@ -25,7 +25,11 @@ namespace ia::iae
|
|||||||
{
|
{
|
||||||
BOOL Engine::IsDebugMode()
|
BOOL Engine::IsDebugMode()
|
||||||
{
|
{
|
||||||
|
#if defined(__DEBUG_MODE__)
|
||||||
return true;
|
return true;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID Engine::ResizeDisplay(IN INT32 newWidth, IN INT32 newHeight)
|
VOID Engine::ResizeDisplay(IN INT32 newWidth, IN INT32 newHeight)
|
||||||
@ -33,34 +37,4 @@ namespace ia::iae
|
|||||||
Renderer::OnScreenResize(newWidth, newHeight);
|
Renderer::OnScreenResize(newWidth, newHeight);
|
||||||
g_gameFunctions.OnResize(newWidth, newHeight);
|
g_gameFunctions.OnResize(newWidth, newHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLOAT32 Engine::GetRandomFloat()
|
|
||||||
{
|
|
||||||
return 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
INT32 Engine::GetRandomInRange(IN INT32 min, IN INT32 max)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
INT64 Engine::GetTickCount()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
INT64 Engine::GetUnixSecond()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
INT64 Engine::GetUnixMillisecond()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
FLOAT32 Engine::GetFrameDeltaTime()
|
|
||||||
{
|
|
||||||
return 0.0f;
|
|
||||||
}
|
|
||||||
} // namespace ia::iae
|
} // namespace ia::iae
|
||||||
|
|||||||
@ -14,13 +14,24 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <InputManager.hpp>
|
|
||||||
#include <IAEngine/Engine.hpp>
|
#include <IAEngine/Engine.hpp>
|
||||||
|
#include <InputManager.hpp>
|
||||||
|
|
||||||
namespace ia::iae
|
namespace ia::iae
|
||||||
{
|
{
|
||||||
|
EXTERN SDL_Window *g_windowHandle;
|
||||||
|
|
||||||
|
BOOL InputManager::s_keys[256];
|
||||||
|
BOOL InputManager::s_prevKeys[256];
|
||||||
|
InputKey InputManager::s_axisInputs[4];
|
||||||
|
Vec2 InputManager::s_pointerPosition{};
|
||||||
|
Map<String, Handle> InputManager::s_actionNames;
|
||||||
|
Vector<Vector<InputKey>> InputManager::s_actions;
|
||||||
|
|
||||||
VOID InputManager::Initialize()
|
VOID InputManager::Initialize()
|
||||||
{
|
{
|
||||||
|
memset(s_keys, 0, sizeof(s_keys));
|
||||||
|
memset(s_prevKeys, 0, sizeof(s_prevKeys));
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID InputManager::Terminate()
|
VOID InputManager::Terminate()
|
||||||
@ -29,80 +40,197 @@ namespace ia::iae
|
|||||||
|
|
||||||
VOID InputManager::OnSDLEvent(IN SDL_Event *event)
|
VOID InputManager::OnSDLEvent(IN SDL_Event *event)
|
||||||
{
|
{
|
||||||
|
memcpy(s_prevKeys, s_keys, sizeof(s_prevKeys));
|
||||||
|
switch (event->type)
|
||||||
|
{
|
||||||
|
case SDL_EVENT_KEY_DOWN:
|
||||||
|
s_keys[event->key.scancode] = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDL_EVENT_KEY_UP:
|
||||||
|
s_keys[event->key.scancode] = false;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDL_EVENT_MOUSE_MOTION:
|
||||||
|
s_pointerPosition = {event->motion.x, event->motion.y};
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Vec2 InputManager::GetAxis()
|
||||||
|
{
|
||||||
|
return Vec2{
|
||||||
|
IsKeyDown(s_axisInputs[1]) + IsKeyDown(s_axisInputs[0]) * -1,
|
||||||
|
IsKeyDown(s_axisInputs[3]) + IsKeyDown(s_axisInputs[2]) * -1
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID InputManager::SwitchModeToText()
|
||||||
|
{
|
||||||
|
SDL_StartTextInput(g_windowHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID InputManager::SwitchModeToAction()
|
||||||
|
{
|
||||||
|
SDL_StopTextInput(g_windowHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vec2 InputManager::GetPointerPosition()
|
||||||
|
{
|
||||||
|
return s_pointerPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL InputManager::IsKeyDown(IN InputKey key)
|
||||||
|
{
|
||||||
|
return s_keys[(UINT8) key];
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL InputManager::WasKeyPressed(IN InputKey key)
|
||||||
|
{
|
||||||
|
return !s_prevKeys[(UINT8) key] && s_keys[(UINT8) key];
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL InputManager::WasKeyReleased(IN InputKey key)
|
||||||
|
{
|
||||||
|
return s_prevKeys[(UINT8) key] && !s_keys[(UINT8) key];
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL InputManager::IsActionDown(IN Handle action)
|
||||||
|
{
|
||||||
|
const auto& t = s_actions[action];
|
||||||
|
for(const auto& k : t)
|
||||||
|
if(IsKeyDown(k))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL InputManager::WasActionPressed(IN Handle action)
|
||||||
|
{
|
||||||
|
const auto& t = s_actions[action];
|
||||||
|
for(const auto& k : t)
|
||||||
|
if(WasKeyPressed(k))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL InputManager::WasActionReleased(IN Handle action)
|
||||||
|
{
|
||||||
|
const auto& t = s_actions[action];
|
||||||
|
for(const auto& k : t)
|
||||||
|
if(WasKeyReleased(k))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL InputManager::IsActionDown(IN CONST String& action)
|
||||||
|
{
|
||||||
|
return IsActionDown(s_actionNames[action]);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL InputManager::WasActionPressed(IN CONST String& action)
|
||||||
|
{
|
||||||
|
return WasActionPressed(s_actionNames[action]);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL InputManager::WasActionReleased(IN CONST String& action)
|
||||||
|
{
|
||||||
|
return WasActionReleased(s_actionNames[action]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Handle InputManager::BindAction(IN CONST String &name, IN InputKey key)
|
||||||
|
{
|
||||||
|
s_actions.pushBack({key});
|
||||||
|
const auto handle = s_actions.size() - 1;
|
||||||
|
s_actionNames[name] = handle;
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID InputManager::BindAxis(IN InputKey upKey, IN InputKey downKey, IN InputKey leftKey, IN InputKey rightKey)
|
||||||
|
{
|
||||||
|
s_axisInputs[0] = upKey;
|
||||||
|
s_axisInputs[1] = downKey;
|
||||||
|
s_axisInputs[2] = leftKey;
|
||||||
|
s_axisInputs[3] = rightKey;
|
||||||
|
}
|
||||||
|
} // namespace ia::iae
|
||||||
|
|
||||||
namespace ia::iae
|
namespace ia::iae
|
||||||
{
|
{
|
||||||
Vec2 Engine::GetInputAxis()
|
Vec2 Engine::GetInputAxis()
|
||||||
{
|
{
|
||||||
return {};
|
return InputManager::GetAxis();
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID Engine::SwitchInputModeToText()
|
VOID Engine::SwitchInputModeToText()
|
||||||
{
|
{
|
||||||
|
InputManager::SwitchModeToText();
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID Engine::SwitchInputModeToAction()
|
VOID Engine::SwitchInputModeToAction()
|
||||||
{
|
{
|
||||||
|
InputManager::SwitchModeToAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec2 Engine::GetInputPointerPosition()
|
Vec2 Engine::GetInputPointerPosition()
|
||||||
{
|
{
|
||||||
return {};
|
return InputManager::GetPointerPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Engine::IsInputKeyDown(IN InputKey key)
|
BOOL Engine::IsInputKeyDown(IN InputKey key)
|
||||||
{
|
{
|
||||||
return false;
|
return InputManager::IsKeyDown(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Engine::WasInputKeyPressed(IN InputKey key)
|
BOOL Engine::WasInputKeyPressed(IN InputKey key)
|
||||||
{
|
{
|
||||||
return false;
|
return InputManager::WasKeyPressed(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Engine::WasInputKeyReleased(IN InputKey key)
|
BOOL Engine::WasInputKeyReleased(IN InputKey key)
|
||||||
{
|
{
|
||||||
return false;
|
return InputManager::WasKeyReleased(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Engine::IsInputActionDown(IN Handle action)
|
BOOL Engine::IsInputActionDown(IN Handle action)
|
||||||
{
|
{
|
||||||
return false;
|
return InputManager::IsActionDown(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Engine::WasInputActionPressed(IN Handle action)
|
BOOL Engine::WasInputActionPressed(IN Handle action)
|
||||||
{
|
{
|
||||||
return false;
|
return InputManager::WasActionPressed(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Engine::WasInputActionReleased(IN Handle action)
|
BOOL Engine::WasInputActionReleased(IN Handle action)
|
||||||
{
|
{
|
||||||
return false;
|
return InputManager::WasActionReleased(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Engine::IsInputActionDown(IN PCCHAR action)
|
BOOL Engine::IsInputActionDown(IN CONST String& action)
|
||||||
{
|
{
|
||||||
return false;
|
return InputManager::IsActionDown(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Engine::WasInputActionPressed(IN PCCHAR action)
|
BOOL Engine::WasInputActionPressed(IN CONST String& action)
|
||||||
{
|
{
|
||||||
return false;
|
return InputManager::WasActionPressed(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Engine::WasInputActionReleased(IN PCCHAR action)
|
BOOL Engine::WasInputActionReleased(IN CONST String& action)
|
||||||
{
|
{
|
||||||
return false;
|
return InputManager::WasActionReleased(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle Engine::BindInputAction(IN CONST String &name, IN InputKey key)
|
Handle Engine::BindInputAction(IN CONST String &name, IN InputKey key)
|
||||||
{
|
{
|
||||||
return INVALID_HANDLE;
|
return InputManager::BindAction(name, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID Engine::BindInputAxis(IN InputKey upKey, IN InputKey downKey, IN InputKey leftKey, IN InputKey rightKey)
|
VOID Engine::BindInputAxis(IN InputKey upKey, IN InputKey downKey, IN InputKey leftKey, IN InputKey rightKey)
|
||||||
{
|
{
|
||||||
|
InputManager::BindAxis(upKey, downKey, leftKey, rightKey);
|
||||||
}
|
}
|
||||||
} // namespace ia::iae
|
} // namespace ia::iae
|
||||||
@ -103,6 +103,11 @@ namespace ia::iae
|
|||||||
EventManager::OnSDLEvent(event);
|
EventManager::OnSDLEvent(event);
|
||||||
ImGui_ImplSDL3_ProcessEvent(event);
|
ImGui_ImplSDL3_ProcessEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FLOAT32 TimePeriod::GetValue() CONST
|
||||||
|
{
|
||||||
|
return (FLOAT32) m_value + ((FLOAT32) m_value * (Random::Get() * m_randomAdjustment) / 100.0f);
|
||||||
|
}
|
||||||
} // namespace ia::iae
|
} // namespace ia::iae
|
||||||
|
|
||||||
BOOL ValidateGameFunctionTable(IN GameFunctionTable gameFunctionTable)
|
BOOL ValidateGameFunctionTable(IN GameFunctionTable gameFunctionTable)
|
||||||
|
|||||||
@ -14,16 +14,41 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <Random.hpp>
|
|
||||||
#include <IAEngine/Engine.hpp>
|
#include <IAEngine/Engine.hpp>
|
||||||
|
#include <Time.hpp>
|
||||||
|
#include <Random.hpp>
|
||||||
|
|
||||||
namespace ia::iae
|
namespace ia::iae
|
||||||
{
|
{
|
||||||
VOID Random::Initialize()
|
VOID Random::Initialize()
|
||||||
{
|
{
|
||||||
|
srand((INT32)Time::GetUnixMillisecond());
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID Random::Terminate()
|
VOID Random::Terminate()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
FLOAT32 Random::Get()
|
||||||
|
{
|
||||||
|
return ((FLOAT32) rand()) / ((FLOAT32) RAND_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
INT32 Random::GetInRange(IN INT32 min, IN INT32 max)
|
||||||
|
{
|
||||||
|
return min + (INT32)((max - min) * Get());
|
||||||
|
}
|
||||||
|
} // namespace ia::iae
|
||||||
|
|
||||||
|
namespace ia::iae
|
||||||
|
{
|
||||||
|
FLOAT32 Engine::GetRandomFloat()
|
||||||
|
{
|
||||||
|
return Random::Get();
|
||||||
|
}
|
||||||
|
|
||||||
|
INT32 Engine::GetRandomInRange(IN INT32 min, IN INT32 max)
|
||||||
|
{
|
||||||
|
return Random::GetInRange(min, max);
|
||||||
|
}
|
||||||
|
} // namespace ia::iae
|
||||||
@ -103,7 +103,7 @@ namespace ia::iae
|
|||||||
}
|
}
|
||||||
|
|
||||||
SDL_GPUBuffer *GPUResourceManager::CreateDeviceLocalBuffer(IN SDL_GPUBufferUsageFlags usage, IN PCVOID data,
|
SDL_GPUBuffer *GPUResourceManager::CreateDeviceLocalBuffer(IN SDL_GPUBufferUsageFlags usage, IN PCVOID data,
|
||||||
IN UINT32 dataSize)
|
IN UINT32 dataSize)
|
||||||
{
|
{
|
||||||
SDL_GPUBufferCreateInfo createInfo{.usage = usage, .size = dataSize};
|
SDL_GPUBufferCreateInfo createInfo{.usage = usage, .size = dataSize};
|
||||||
const auto result = SDL_CreateGPUBuffer(Renderer::GetDevice(), &createInfo);
|
const auto result = SDL_CreateGPUBuffer(Renderer::GetDevice(), &createInfo);
|
||||||
@ -112,7 +112,7 @@ namespace ia::iae
|
|||||||
THROW_UNKNOWN("Failed to create a SDL GPU Buffer: ", SDL_GetError());
|
THROW_UNKNOWN("Failed to create a SDL GPU Buffer: ", SDL_GetError());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if(dataSize && dataSize)
|
if (dataSize && dataSize)
|
||||||
{
|
{
|
||||||
SDL_GPUTransferBufferCreateInfo stagingBufferCreateInfo{.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD,
|
SDL_GPUTransferBufferCreateInfo stagingBufferCreateInfo{.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD,
|
||||||
.size = dataSize};
|
.size = dataSize};
|
||||||
@ -145,4 +145,67 @@ namespace ia::iae
|
|||||||
{
|
{
|
||||||
SDL_ReleaseGPUBuffer(Renderer::GetDevice(), handle);
|
SDL_ReleaseGPUBuffer(Renderer::GetDevice(), handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector<UINT8> GPUResourceManager::GetTexturePixelData(IN SDL_GPUTexture *texture, IN INT32 width, IN INT32 height)
|
||||||
|
{
|
||||||
|
SDL_GPUTransferBufferCreateInfo stagingBufferCreateInfo{.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD,
|
||||||
|
.size = (UINT32) width * (UINT32) height * 4};
|
||||||
|
const auto stagingBuffer = SDL_CreateGPUTransferBuffer(Renderer::GetDevice(), &stagingBufferCreateInfo);
|
||||||
|
|
||||||
|
const auto cmdBuffer = SDL_AcquireGPUCommandBuffer(Renderer::GetDevice());
|
||||||
|
const auto copyPass = SDL_BeginGPUCopyPass(cmdBuffer);
|
||||||
|
|
||||||
|
SDL_GPUTextureTransferInfo transferInfo{.transfer_buffer = stagingBuffer, .offset = 0};
|
||||||
|
SDL_GPUTextureRegion region{.texture = texture, .w = (UINT32) width, .h = (UINT32) height, .d = 1};
|
||||||
|
SDL_DownloadFromGPUTexture(copyPass, ®ion, &transferInfo);
|
||||||
|
|
||||||
|
SDL_EndGPUCopyPass(copyPass);
|
||||||
|
SDL_SubmitGPUCommandBuffer(cmdBuffer);
|
||||||
|
SDL_WaitForGPUIdle(Renderer::GetDevice());
|
||||||
|
|
||||||
|
Vector<UINT8> result;
|
||||||
|
result.resize(width * height * 4);
|
||||||
|
|
||||||
|
const auto mappedPtr = SDL_MapGPUTransferBuffer(Renderer::GetDevice(), stagingBuffer, false);
|
||||||
|
SDL_UnmapGPUTransferBuffer(Renderer::GetDevice(), stagingBuffer);
|
||||||
|
SDL_memcpy(result.data(), mappedPtr, result.size());
|
||||||
|
SDL_ReleaseGPUTransferBuffer(Renderer::GetDevice(), stagingBuffer);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_GPUTexture* GPUResourceManager::CombineTextures(IN SDL_GPUTexture** textures, IN INT32 unitWidth, IN INT32 unitHeight,
|
||||||
|
IN INT32 unitCountX, IN INT32 unitCountY)
|
||||||
|
{
|
||||||
|
SDL_GPUTextureCreateInfo createInfo{.type = SDL_GPU_TEXTURETYPE_2D,
|
||||||
|
.format = SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM,
|
||||||
|
.usage = SDL_GPU_TEXTUREUSAGE_SAMPLER,
|
||||||
|
.width = (UINT32) unitCountX * unitWidth,
|
||||||
|
.height = (UINT32) unitCountY * unitHeight,
|
||||||
|
.layer_count_or_depth = 1,
|
||||||
|
.num_levels = 1};
|
||||||
|
|
||||||
|
SDL_GPUTexture *result{};
|
||||||
|
if (!(result = SDL_CreateGPUTexture(Renderer::GetDevice(), &createInfo)))
|
||||||
|
THROW_UNKNOWN("Failed to create a SDL GPU Texture: ", SDL_GetError());
|
||||||
|
|
||||||
|
const auto cmdBuffer = SDL_AcquireGPUCommandBuffer(Renderer::GetDevice());
|
||||||
|
const auto copyPass = SDL_BeginGPUCopyPass(cmdBuffer);
|
||||||
|
|
||||||
|
for (INT32 y = 0; y < unitCountY; y++)
|
||||||
|
{
|
||||||
|
for (INT32 x = 0; x < unitCountX; x++)
|
||||||
|
{
|
||||||
|
SDL_GPUTextureLocation src{.texture = textures[x + (y * unitCountX)], .x = 0, .y = 0};
|
||||||
|
SDL_GPUTextureLocation dst{.texture = result, .x = (UINT32)(x * unitWidth), .y = (UINT32)(y * unitHeight)};
|
||||||
|
SDL_CopyGPUTextureToTexture(copyPass, &src, &dst, unitWidth, unitHeight, 1, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_EndGPUCopyPass(copyPass);
|
||||||
|
SDL_SubmitGPUCommandBuffer(cmdBuffer);
|
||||||
|
SDL_WaitForGPUIdle(Renderer::GetDevice());
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
} // namespace ia::iae
|
} // namespace ia::iae
|
||||||
@ -14,11 +14,21 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <ResourceManager.hpp>
|
|
||||||
#include <IAEngine/Engine.hpp>
|
#include <IAEngine/Engine.hpp>
|
||||||
|
#include <ResourceManager.hpp>
|
||||||
|
|
||||||
|
#include <AudioManager.hpp>
|
||||||
|
#include <Renderer/GPUResourceManager.hpp>
|
||||||
|
|
||||||
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
|
#define STB_IMAGE_RESIZE_IMPLEMENTATION
|
||||||
|
#include <stb_image.h>
|
||||||
|
#include <stb_image_resize2.h>
|
||||||
|
|
||||||
namespace ia::iae
|
namespace ia::iae
|
||||||
{
|
{
|
||||||
|
Map<Handle, UINT64> ResourceManager::s_imageExtents;
|
||||||
|
|
||||||
VOID ResourceManager::Initialize()
|
VOID ResourceManager::Initialize()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -26,40 +36,106 @@ namespace ia::iae
|
|||||||
VOID ResourceManager::Terminate()
|
VOID ResourceManager::Terminate()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Handle ResourceManager::CreateImage(IN PCUINT8 encodedData, IN SIZE_T encodedDataSize)
|
||||||
|
{
|
||||||
|
INT32 w, h, n;
|
||||||
|
const auto rgbaData = stbi_load_from_memory(encodedData, encodedDataSize, &w, &h, &n, STBI_rgb_alpha);
|
||||||
|
const auto result = CreateImage(rgbaData, w, h);
|
||||||
|
STBI_FREE(rgbaData);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Handle ResourceManager::CreateImage(IN PCUINT8 rgbaData, IN INT32 width, IN INT32 height)
|
||||||
|
{
|
||||||
|
const auto handle = (Handle) GPUResourceManager::CreateTexture(SDL_GPU_TEXTUREUSAGE_SAMPLER, width, height,
|
||||||
|
rgbaData, SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM);
|
||||||
|
s_imageExtents[handle] = (((UINT64) width) << 32) | height;
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
Handle ResourceManager::CreateSound(IN PCUINT8 encodedData, IN SIZE_T encodedDataSize)
|
||||||
|
{
|
||||||
|
return AudioManager::CreateAudio(encodedData, encodedDataSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID ResourceManager::DestroyImage(IN Handle image)
|
||||||
|
{
|
||||||
|
GPUResourceManager::DestroyTexture((SDL_GPUTexture *) image);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID ResourceManager::DestroySound(IN Handle sound)
|
||||||
|
{
|
||||||
|
AudioManager::DestoryAudio(sound);
|
||||||
|
}
|
||||||
|
|
||||||
|
IVec2 ResourceManager::GetImageExtent(IN Handle image)
|
||||||
|
{
|
||||||
|
const auto t = s_imageExtents[image];
|
||||||
|
return {(INT32) (t >> 32), (INT32) t};
|
||||||
|
}
|
||||||
|
|
||||||
|
Handle ResourceManager::RescaleImage(IN Handle image, IN INT32 newWidth, IN INT32 newHeight)
|
||||||
|
{
|
||||||
|
const auto currentExtent = GetImageExtent(image);
|
||||||
|
const auto pixelData =
|
||||||
|
GPUResourceManager::GetTexturePixelData((SDL_GPUTexture *) image, currentExtent.x, currentExtent.y);
|
||||||
|
GPUResourceManager::DestroyTexture((SDL_GPUTexture *) image);
|
||||||
|
const auto newPixelData =
|
||||||
|
stbir_resize_uint8_linear(pixelData.data(), currentExtent.x, currentExtent.y, currentExtent.x * 4, nullptr,
|
||||||
|
newWidth, newHeight, newWidth * 4, stbir_pixel_layout::STBIR_RGBA);
|
||||||
|
const auto result = CreateImage(newPixelData, newWidth, newHeight);
|
||||||
|
free(newPixelData);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Handle ResourceManager::CombineImages(IN CONST Vector<Handle> &images, IN INT32 unitWidth, IN INT32 unitHeight,
|
||||||
|
IN INT32 unitCountX, IN INT32 unitCountY)
|
||||||
|
{
|
||||||
|
return (Handle)GPUResourceManager::CombineTextures((SDL_GPUTexture**)images.data(), unitWidth, unitHeight, unitCountX, unitCountY);
|
||||||
|
}
|
||||||
|
} // namespace ia::iae
|
||||||
|
|
||||||
namespace ia::iae
|
namespace ia::iae
|
||||||
{
|
{
|
||||||
Handle Engine::CreateImage()
|
Handle Engine::CreateImage(IN PCUINT8 encodedData, IN SIZE_T encodedDataSize)
|
||||||
{
|
{
|
||||||
return INVALID_HANDLE;
|
return ResourceManager::CreateImage(encodedData, encodedDataSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle Engine::CreateSound()
|
Handle Engine::CreateImage(IN PCUINT8 rgbaData, IN INT32 width, IN INT32 height)
|
||||||
{
|
{
|
||||||
return INVALID_HANDLE;
|
return ResourceManager::CreateImage(rgbaData, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
Handle Engine::CreateSound(IN PCUINT8 encodedData, IN SIZE_T encodedDataSize)
|
||||||
|
{
|
||||||
|
return ResourceManager::CreateSound(encodedData, encodedDataSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID Engine::DestroyImage(IN Handle image)
|
VOID Engine::DestroyImage(IN Handle image)
|
||||||
{
|
{
|
||||||
|
ResourceManager::DestroyImage(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID Engine::DestroySound(IN Handle sound)
|
VOID Engine::DestroySound(IN Handle sound)
|
||||||
{
|
{
|
||||||
|
ResourceManager::DestroySound(sound);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec2 Engine::GetImageExtent(IN Handle image)
|
IVec2 Engine::GetImageExtent(IN Handle image)
|
||||||
{
|
{
|
||||||
return {};
|
return ResourceManager::GetImageExtent(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID Engine::RescaleImage(IN Handle image, IN INT32 newWidth, IN INT32 newHeight)
|
Handle Engine::RescaleImage(IN Handle image, IN INT32 newWidth, IN INT32 newHeight)
|
||||||
{
|
{
|
||||||
|
return ResourceManager::RescaleImage(image, newWidth, newHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle Engine::CombineImages(IN CONST Vector<Handle> &images, IN INT32 unitWidth, IN INT32 unitHeight,
|
Handle Engine::CombineImages(IN CONST Vector<Handle> &images, IN INT32 unitWidth, IN INT32 unitHeight,
|
||||||
IN INT32 unitCountX, IN INT32 unitCountY)
|
IN INT32 unitCountX, IN INT32 unitCountY)
|
||||||
{
|
{
|
||||||
return INVALID_HANDLE;
|
return ResourceManager::CombineImages(images, unitWidth, unitHeight, unitCountX, unitCountY);
|
||||||
}
|
}
|
||||||
} // namespace ia::iae
|
} // namespace ia::iae
|
||||||
@ -19,11 +19,84 @@
|
|||||||
|
|
||||||
namespace ia::iae
|
namespace ia::iae
|
||||||
{
|
{
|
||||||
|
FLOAT32 g_globalTimeScale = 1.0f;
|
||||||
|
|
||||||
|
FLOAT32 g_deltaTime{1 / 60.0f};
|
||||||
|
INT64 g_lastFrameTick{0};
|
||||||
|
|
||||||
|
std::chrono::time_point<std::chrono::high_resolution_clock> g_startMS;
|
||||||
|
|
||||||
VOID Time::Initialize()
|
VOID Time::Initialize()
|
||||||
{
|
{
|
||||||
|
g_startMS = std::chrono::high_resolution_clock::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID Time::Terminate()
|
VOID Time::Terminate()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID Time::NextFrame()
|
||||||
|
{
|
||||||
|
const auto t = GetTickCount();
|
||||||
|
g_deltaTime = t - g_lastFrameTick;
|
||||||
|
g_lastFrameTick = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
INT64 Time::GetTickCount()
|
||||||
|
{
|
||||||
|
return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() -
|
||||||
|
g_startMS)
|
||||||
|
.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
INT64 Time::GetCurrentSecond()
|
||||||
|
{
|
||||||
|
return std::chrono::duration_cast<std::chrono::seconds>(std::chrono::high_resolution_clock::now() - g_startMS)
|
||||||
|
.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
FLOAT32 Time::GetFrameDeltaTime()
|
||||||
|
{
|
||||||
|
return g_deltaTime * g_globalTimeScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
INT64 Time::GetUnixSecond()
|
||||||
|
{
|
||||||
|
return std::chrono::duration_cast<std::chrono::seconds>(
|
||||||
|
std::chrono::system_clock::now().time_since_epoch()).count();
|
||||||
|
}
|
||||||
|
|
||||||
|
INT64 Time::GetUnixMillisecond()
|
||||||
|
{
|
||||||
|
return std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||||
|
std::chrono::system_clock::now().time_since_epoch()).count();
|
||||||
|
}
|
||||||
|
} // namespace ia::iae
|
||||||
|
|
||||||
|
namespace ia::iae
|
||||||
|
{
|
||||||
|
VOID Engine::SetTimeScale(IN FLOAT32 scale)
|
||||||
|
{
|
||||||
|
g_globalTimeScale = scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
INT64 Engine::GetTickCount()
|
||||||
|
{
|
||||||
|
return Time::GetTickCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
INT64 Engine::GetUnixSecond()
|
||||||
|
{
|
||||||
|
return Time::GetUnixSecond();
|
||||||
|
}
|
||||||
|
|
||||||
|
INT64 Engine::GetUnixMillisecond()
|
||||||
|
{
|
||||||
|
return Time::GetUnixMillisecond();
|
||||||
|
}
|
||||||
|
|
||||||
|
FLOAT32 Engine::GetFrameDeltaTime()
|
||||||
|
{
|
||||||
|
return Time::GetFrameDeltaTime();
|
||||||
|
}
|
||||||
} // namespace ia::iae
|
} // namespace ia::iae
|
||||||
@ -33,7 +33,6 @@ namespace ia::iae
|
|||||||
|
|
||||||
VOID WorldManager::DebugDraw()
|
VOID WorldManager::DebugDraw()
|
||||||
{
|
{
|
||||||
Engine::DebugDraw_FillRect({0.0f, 0.0f}, {100.0f, 100.0f});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID WorldManager::Update()
|
VOID WorldManager::Update()
|
||||||
@ -52,11 +51,7 @@ namespace ia::iae
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID Engine::SetTimeScale(IN FLOAT32 scale)
|
Handle Engine::CreateEmptyScene()
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Handle Engine::CreateScene()
|
|
||||||
{
|
{
|
||||||
return INVALID_HANDLE;
|
return INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
@ -89,4 +84,9 @@ namespace ia::iae
|
|||||||
VOID Engine::RemoveNodeFromScene(IN Handle scene, IN CONST String &name)
|
VOID Engine::RemoveNodeFromScene(IN Handle scene, IN CONST String &name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Handle Engine::CreateScene(IN CONST String& sceneXML)
|
||||||
|
{
|
||||||
|
return INVALID_HANDLE;
|
||||||
|
}
|
||||||
} // namespace ia::iae
|
} // namespace ia::iae
|
||||||
@ -1,4 +0,0 @@
|
|||||||
[Window][Debug##Default]
|
|
||||||
Pos=60,60
|
|
||||||
Size=400,400
|
|
||||||
|
|
||||||
@ -19,13 +19,20 @@
|
|||||||
#include <IAEngine/Base.hpp>
|
#include <IAEngine/Base.hpp>
|
||||||
|
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
|
#include <SDL3_mixer/SDL_mixer.h>
|
||||||
|
|
||||||
namespace ia::iae
|
namespace ia::iae
|
||||||
{
|
{
|
||||||
class AudioManager
|
class AudioManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
STATIC VOID Initialize();
|
STATIC VOID Initialize();
|
||||||
STATIC VOID Terminate();
|
STATIC VOID Terminate();
|
||||||
|
|
||||||
|
STATIC Handle CreateAudio(IN PCUINT8 encodedData, IN SIZE_T encodedDataSize);
|
||||||
|
STATIC VOID DestoryAudio(IN Handle handle);
|
||||||
|
|
||||||
|
private:
|
||||||
|
STATIC MIX_Mixer *s_mixer;
|
||||||
};
|
};
|
||||||
}
|
} // namespace ia::iae
|
||||||
@ -24,10 +24,34 @@ namespace ia::iae
|
|||||||
{
|
{
|
||||||
class InputManager
|
class InputManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
STATIC VOID Initialize();
|
STATIC VOID Initialize();
|
||||||
STATIC VOID Terminate();
|
STATIC VOID Terminate();
|
||||||
|
|
||||||
STATIC VOID OnSDLEvent(IN SDL_Event* event);
|
STATIC VOID OnSDLEvent(IN SDL_Event *event);
|
||||||
|
|
||||||
|
STATIC Vec2 GetAxis();
|
||||||
|
STATIC VOID SwitchModeToText();
|
||||||
|
STATIC VOID SwitchModeToAction();
|
||||||
|
STATIC Vec2 GetPointerPosition();
|
||||||
|
STATIC BOOL IsKeyDown(IN InputKey key);
|
||||||
|
STATIC BOOL WasKeyPressed(IN InputKey key);
|
||||||
|
STATIC BOOL WasKeyReleased(IN InputKey key);
|
||||||
|
STATIC BOOL IsActionDown(IN Handle action);
|
||||||
|
STATIC BOOL WasActionPressed(IN Handle action);
|
||||||
|
STATIC BOOL WasActionReleased(IN Handle action);
|
||||||
|
STATIC BOOL IsActionDown(IN CONST String& action);
|
||||||
|
STATIC BOOL WasActionPressed(IN CONST String& action);
|
||||||
|
STATIC BOOL WasActionReleased(IN CONST String& action);
|
||||||
|
STATIC Handle BindAction(IN CONST String &name, IN InputKey key);
|
||||||
|
STATIC VOID BindAxis(IN InputKey upKey, IN InputKey downKey, IN InputKey leftKey, IN InputKey rightKey);
|
||||||
|
|
||||||
|
private:
|
||||||
|
STATIC BOOL s_keys[256];
|
||||||
|
STATIC BOOL s_prevKeys[256];
|
||||||
|
STATIC Vec2 s_pointerPosition;
|
||||||
|
STATIC InputKey s_axisInputs[4];
|
||||||
|
STATIC Map<String, Handle> s_actionNames;
|
||||||
|
STATIC Vector<Vector<InputKey>> s_actions;
|
||||||
};
|
};
|
||||||
}
|
} // namespace ia::iae
|
||||||
@ -27,5 +27,8 @@ namespace ia::iae
|
|||||||
public:
|
public:
|
||||||
STATIC VOID Initialize();
|
STATIC VOID Initialize();
|
||||||
STATIC VOID Terminate();
|
STATIC VOID Terminate();
|
||||||
|
|
||||||
|
STATIC FLOAT32 Get();
|
||||||
|
STATIC INT32 GetInRange(IN INT32 min, IN INT32 max);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -34,5 +34,9 @@ namespace ia::iae
|
|||||||
STATIC SDL_GPUBuffer *CreateDeviceLocalBuffer(IN SDL_GPUBufferUsageFlags usage, IN PCVOID data, IN UINT32 dataSize);
|
STATIC SDL_GPUBuffer *CreateDeviceLocalBuffer(IN SDL_GPUBufferUsageFlags usage, IN PCVOID data, IN UINT32 dataSize);
|
||||||
STATIC VOID DestroyTexture(IN SDL_GPUTexture *handle);
|
STATIC VOID DestroyTexture(IN SDL_GPUTexture *handle);
|
||||||
STATIC VOID DestroyBuffer(IN SDL_GPUBuffer *handle);
|
STATIC VOID DestroyBuffer(IN SDL_GPUBuffer *handle);
|
||||||
|
|
||||||
|
STATIC Vector<UINT8> GetTexturePixelData(IN SDL_GPUTexture* texture, IN INT32 width, IN INT32 height);
|
||||||
|
STATIC SDL_GPUTexture* CombineTextures(IN SDL_GPUTexture** textures, IN INT32 unitWidth, IN INT32 unitHeight,
|
||||||
|
IN INT32 unitCountX, IN INT32 unitCountY);
|
||||||
};
|
};
|
||||||
} // namespace ia::iae
|
} // namespace ia::iae
|
||||||
@ -24,8 +24,28 @@ namespace ia::iae
|
|||||||
{
|
{
|
||||||
class ResourceManager
|
class ResourceManager
|
||||||
{
|
{
|
||||||
public:
|
struct ImageResource
|
||||||
|
{
|
||||||
|
INT32 Width{};
|
||||||
|
INT32 Height{};
|
||||||
|
SDL_GPUTexture *Texture{};
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
STATIC VOID Initialize();
|
STATIC VOID Initialize();
|
||||||
STATIC VOID Terminate();
|
STATIC VOID Terminate();
|
||||||
|
|
||||||
|
STATIC Handle CreateImage(IN PCUINT8 encodedData, IN SIZE_T encodedDataSize);
|
||||||
|
STATIC Handle CreateImage(IN PCUINT8 rgbaData, IN INT32 width, IN INT32 height);
|
||||||
|
STATIC Handle CreateSound(IN PCUINT8 encodedData, IN SIZE_T encodedDataSize);
|
||||||
|
STATIC VOID DestroyImage(IN Handle image);
|
||||||
|
STATIC VOID DestroySound(IN Handle sound);
|
||||||
|
STATIC IVec2 GetImageExtent(IN Handle image);
|
||||||
|
STATIC Handle RescaleImage(IN Handle image, IN INT32 newWidth, IN INT32 newHeight);
|
||||||
|
STATIC Handle CombineImages(IN CONST Vector<Handle> &images, IN INT32 unitWidth, IN INT32 unitHeight,
|
||||||
|
IN INT32 unitCountX, IN INT32 unitCountY);
|
||||||
|
|
||||||
|
private:
|
||||||
|
STATIC Map<Handle, UINT64> s_imageExtents;
|
||||||
};
|
};
|
||||||
}
|
} // namespace ia::iae
|
||||||
@ -27,5 +27,14 @@ namespace ia::iae
|
|||||||
public:
|
public:
|
||||||
STATIC VOID Initialize();
|
STATIC VOID Initialize();
|
||||||
STATIC VOID Terminate();
|
STATIC VOID Terminate();
|
||||||
|
|
||||||
|
STATIC VOID NextFrame();
|
||||||
|
|
||||||
|
STATIC INT64 GetTickCount();
|
||||||
|
STATIC INT64 GetCurrentSecond();
|
||||||
|
STATIC FLOAT32 GetFrameDeltaTime();
|
||||||
|
|
||||||
|
STATIC INT64 GetUnixSecond();
|
||||||
|
STATIC INT64 GetUnixMillisecond();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -16,11 +16,12 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <IACore/Exception.hpp>
|
#include <IACore/Map.hpp>
|
||||||
#include <IACore/Logger.hpp>
|
#include <IACore/Logger.hpp>
|
||||||
#include <IACore/Memory.hpp>
|
#include <IACore/Memory.hpp>
|
||||||
#include <IACore/String.hpp>
|
#include <IACore/String.hpp>
|
||||||
#include <IACore/Vector.hpp>
|
#include <IACore/Vector.hpp>
|
||||||
|
#include <IACore/Exception.hpp>
|
||||||
|
|
||||||
#include <glm/ext/matrix_clip_space.hpp>
|
#include <glm/ext/matrix_clip_space.hpp>
|
||||||
#include <glm/ext/matrix_transform.hpp>
|
#include <glm/ext/matrix_transform.hpp>
|
||||||
@ -30,6 +31,8 @@
|
|||||||
#include <glm/vec3.hpp>
|
#include <glm/vec3.hpp>
|
||||||
#include <glm/vec4.hpp>
|
#include <glm/vec4.hpp>
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
#define IAE_LOG_TAG "IAE"
|
#define IAE_LOG_TAG "IAE"
|
||||||
|
|
||||||
#define IAE_LOG_INFO(...) ia::Logger::Info(IAE_LOG_TAG, __VA_ARGS__)
|
#define IAE_LOG_INFO(...) ia::Logger::Info(IAE_LOG_TAG, __VA_ARGS__)
|
||||||
@ -52,6 +55,31 @@ namespace ia::iae
|
|||||||
|
|
||||||
struct TimePeriod
|
struct TimePeriod
|
||||||
{
|
{
|
||||||
|
TimePeriod()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
TimePeriod(IN INT32 value, IN INT32 randomAdjustment)
|
||||||
|
{
|
||||||
|
SetValue(value);
|
||||||
|
SetRandomAdjustment(randomAdjustment);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID SetValue(IN INT32 value)
|
||||||
|
{
|
||||||
|
m_value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID SetRandomAdjustment(IN INT32 adjustment)
|
||||||
|
{
|
||||||
|
m_randomAdjustment = adjustment;
|
||||||
|
}
|
||||||
|
|
||||||
|
FLOAT32 GetValue() CONST;
|
||||||
|
|
||||||
|
private:
|
||||||
|
INT32 m_value{};
|
||||||
|
INT32 m_randomAdjustment{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ImageView
|
struct ImageView
|
||||||
|
|||||||
@ -61,12 +61,13 @@ namespace ia::iae
|
|||||||
STATIC VOID DebugDraw_StrokeRect(IN Vec2 position, IN Vec2 size);
|
STATIC VOID DebugDraw_StrokeRect(IN Vec2 position, IN Vec2 size);
|
||||||
|
|
||||||
// Resource Functions
|
// Resource Functions
|
||||||
STATIC Handle CreateImage();
|
STATIC Handle CreateImage(IN PCUINT8 encodedData, IN SIZE_T encodedDataSize);
|
||||||
STATIC Handle CreateSound();
|
STATIC Handle CreateImage(IN PCUINT8 rgbaData, IN INT32 width, IN INT32 height);
|
||||||
|
STATIC Handle CreateSound(IN PCUINT8 encodedData, IN SIZE_T encodedDataSize);
|
||||||
STATIC VOID DestroyImage(IN Handle image);
|
STATIC VOID DestroyImage(IN Handle image);
|
||||||
STATIC VOID DestroySound(IN Handle sound);
|
STATIC VOID DestroySound(IN Handle sound);
|
||||||
STATIC Vec2 GetImageExtent(IN Handle image);
|
STATIC IVec2 GetImageExtent(IN Handle image);
|
||||||
STATIC VOID RescaleImage(IN Handle image, IN INT32 newWidth, IN INT32 newHeight);
|
STATIC Handle RescaleImage(IN Handle image, IN INT32 newWidth, IN INT32 newHeight);
|
||||||
STATIC Handle CombineImages(IN CONST Vector<Handle>& images, IN INT32 unitWidth, IN INT32 unitHeight, IN INT32 unitCountX, IN INT32 unitCountY);
|
STATIC Handle CombineImages(IN CONST Vector<Handle>& images, IN INT32 unitWidth, IN INT32 unitHeight, IN INT32 unitCountX, IN INT32 unitCountY);
|
||||||
|
|
||||||
// Game Functions
|
// Game Functions
|
||||||
@ -74,7 +75,8 @@ namespace ia::iae
|
|||||||
STATIC VOID SetActiveCamera(IN ICameraComponent* cameraComponent);
|
STATIC VOID SetActiveCamera(IN ICameraComponent* cameraComponent);
|
||||||
|
|
||||||
// Scene Functions
|
// Scene Functions
|
||||||
STATIC Handle CreateScene();
|
STATIC Handle CreateScene(IN CONST String& sceneXML);
|
||||||
|
STATIC Handle CreateEmptyScene();
|
||||||
STATIC VOID DestroyScene(IN Handle handle);
|
STATIC VOID DestroyScene(IN Handle handle);
|
||||||
STATIC VOID ChangeActiveScene(IN Handle scene);
|
STATIC VOID ChangeActiveScene(IN Handle scene);
|
||||||
STATIC VOID AddNodeToActiveScene(IN RefPtr<INode> node);
|
STATIC VOID AddNodeToActiveScene(IN RefPtr<INode> node);
|
||||||
@ -94,9 +96,9 @@ namespace ia::iae
|
|||||||
STATIC BOOL IsInputActionDown(IN Handle action);
|
STATIC BOOL IsInputActionDown(IN Handle action);
|
||||||
STATIC BOOL WasInputActionPressed(IN Handle action);
|
STATIC BOOL WasInputActionPressed(IN Handle action);
|
||||||
STATIC BOOL WasInputActionReleased(IN Handle action);
|
STATIC BOOL WasInputActionReleased(IN Handle action);
|
||||||
STATIC BOOL IsInputActionDown(IN PCCHAR action);
|
STATIC BOOL IsInputActionDown(IN CONST String& action);
|
||||||
STATIC BOOL WasInputActionPressed(IN PCCHAR action);
|
STATIC BOOL WasInputActionPressed(IN CONST String& action);
|
||||||
STATIC BOOL WasInputActionReleased(IN PCCHAR action);
|
STATIC BOOL WasInputActionReleased(IN CONST String& action);
|
||||||
STATIC Handle BindInputAction(IN CONST String& name, IN InputKey key);
|
STATIC Handle BindInputAction(IN CONST String& name, IN InputKey key);
|
||||||
STATIC VOID BindInputAxis(IN InputKey upKey, IN InputKey downKey, IN InputKey leftKey, IN InputKey rightKey);
|
STATIC VOID BindInputAxis(IN InputKey upKey, IN InputKey downKey, IN InputKey leftKey, IN InputKey rightKey);
|
||||||
|
|
||||||
|
|||||||
6
Vendor/CMakeLists.txt
vendored
6
Vendor/CMakeLists.txt
vendored
@ -78,6 +78,12 @@ add_subdirectory(pugixml/)
|
|||||||
# -----------------------------------------------
|
# -----------------------------------------------
|
||||||
add_subdirectory(json/)
|
add_subdirectory(json/)
|
||||||
|
|
||||||
|
# -----------------------------------------------
|
||||||
|
# STB
|
||||||
|
# -----------------------------------------------
|
||||||
|
add_library(STB INTERFACE)
|
||||||
|
target_include_directories(STB INTERFACE stb/)
|
||||||
|
|
||||||
# -----------------------------------------------
|
# -----------------------------------------------
|
||||||
# NativeFileDialog
|
# NativeFileDialog
|
||||||
# -----------------------------------------------
|
# -----------------------------------------------
|
||||||
|
|||||||
2
Vendor/IACore
vendored
2
Vendor/IACore
vendored
Submodule Vendor/IACore updated: a73cc7e69c...af084e0b94
7988
Vendor/stb/stb_image.h
vendored
Normal file
7988
Vendor/stb/stb_image.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
10630
Vendor/stb/stb_image_resize2.h
vendored
Normal file
10630
Vendor/stb/stb_image_resize2.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1724
Vendor/stb/stb_image_write.h
vendored
Normal file
1724
Vendor/stb/stb_image_write.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user