add release checks

main
Brett 2024-05-15 14:09:58 -04:00
parent ae2ad8d1ab
commit c9475afb2a
4 changed files with 21 additions and 4 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.25) cmake_minimum_required(VERSION 3.25)
set(BLT_GRAPHICS_VERSION 0.13.18) set(BLT_GRAPHICS_VERSION 0.13.19)
set(BLT_GRAPHICS_TEST_VERSION 0.0.1) set(BLT_GRAPHICS_TEST_VERSION 0.0.1)
project(BLT_WITH_GRAPHICS VERSION ${BLT_GRAPHICS_VERSION}) project(BLT_WITH_GRAPHICS VERSION ${BLT_GRAPHICS_VERSION})

View File

@ -33,7 +33,9 @@ namespace blt::gfx
double scroll = 0; double scroll = 0;
bool mouse_moved = false; bool mouse_moved = false;
bool key_pressed = false; bool key_pressed = false;
bool key_released = false;
bool mouse_pressed = false; bool mouse_pressed = false;
bool mouse_released = false;
private: private:
KEY_STATE* key_state; KEY_STATE* key_state;
MOUSE_STATE* mouse_state; MOUSE_STATE* mouse_state;
@ -81,8 +83,10 @@ namespace blt::gfx
void clear() void clear()
{ {
key_pressed = false; key_pressed = false;
key_released = false;
mouse_moved = false; mouse_moved = false;
mouse_pressed = false; mouse_pressed = false;
mouse_released = false;
} }
bool isKeyPressed(std::size_t key) bool isKeyPressed(std::size_t key)

View File

@ -120,11 +120,15 @@ namespace blt::gfx
bool mousePressedLastFrame(); bool mousePressedLastFrame();
bool mouseReleaseLastFrame();
bool isKeyPressed(int key); bool isKeyPressed(int key);
// TODO: maybe make this per key? // TODO: maybe make this per key?
bool keyPressedLastFrame(); bool keyPressedLastFrame();
bool keyReleasedLastFrame();
double getFrameDeltaSeconds(); double getFrameDeltaSeconds();
double getFrameDeltaMilliseconds(); double getFrameDeltaMilliseconds();

View File

@ -74,15 +74,17 @@ namespace blt::gfx
{ {
case GLFW_PRESS: case GLFW_PRESS:
state = KEY_STATE::PRESS; state = KEY_STATE::PRESS;
window_state.inputManager.key_pressed = true;
break; break;
case GLFW_REPEAT: case GLFW_REPEAT:
state = KEY_STATE::REPEAT; state = KEY_STATE::REPEAT;
break; break;
default: default:
state = KEY_STATE::RELEASE; state = KEY_STATE::RELEASE;
window_state.inputManager.key_released = true;
break;
} }
window_state.inputManager.key(key) = state; window_state.inputManager.key(key) = state;
window_state.inputManager.key_pressed = true;
}); });
/* Setup mouse button callback */ /* Setup mouse button callback */
@ -94,13 +96,14 @@ namespace blt::gfx
{ {
case GLFW_PRESS: case GLFW_PRESS:
state = MOUSE_STATE::PRESS; state = MOUSE_STATE::PRESS;
window_state.inputManager.mouse_pressed = true;
break; break;
default: default:
state = MOUSE_STATE::RELEASE; state = MOUSE_STATE::RELEASE;
window_state.inputManager.mouse_released = true;
break; break;
} }
window_state.inputManager.mouse(button) = state; window_state.inputManager.mouse(button) = state;
window_state.inputManager.mouse_pressed = true;
}); });
/* Setup mouse cursor callback */ /* Setup mouse cursor callback */
@ -385,6 +388,12 @@ namespace blt::gfx
i32 getWindowWidth() i32 getWindowWidth()
{ return window_state.width; } { return window_state.width; }
bool keyReleasedLastFrame()
{ return window_state.inputManager.key_released; }
bool mouseReleaseLastFrame()
{ return window_state.inputManager.mouse_released; }
window_data& window_data::setWindowSize(int32_t new_width, int32_t new_height) window_data& window_data::setWindowSize(int32_t new_width, int32_t new_height)
{ {
width = new_width; width = new_width;