2025-05-07 19:21:51 +02:00
|
|
|
/*
|
|
|
|
|
Crafter®.Graphics
|
2026-03-09 20:10:19 +01:00
|
|
|
Copyright (C) 2026 Catcrafts®
|
2025-05-07 19:21:51 +02:00
|
|
|
Catcrafts.net
|
|
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
|
version 3.0 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
License along with this library; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
*/
|
2026-01-28 23:37:12 +01:00
|
|
|
module;
|
2026-03-09 20:10:19 +01:00
|
|
|
#ifdef CRAFTER_GRAPHICS_RENDERER_VULKAN
|
2026-03-02 23:53:13 +01:00
|
|
|
#include "vulkan/vulkan.h"
|
2026-01-28 23:37:12 +01:00
|
|
|
#endif
|
2025-04-16 00:43:33 +02:00
|
|
|
export module Crafter.Graphics:Types;
|
2025-11-16 15:32:11 +01:00
|
|
|
import std;
|
2026-03-09 20:10:19 +01:00
|
|
|
import Crafter.Math;
|
2025-04-16 00:43:33 +02:00
|
|
|
|
2025-12-30 23:28:38 +01:00
|
|
|
export namespace Crafter {
|
|
|
|
|
struct MouseMoveEvent {
|
2026-03-09 20:10:19 +01:00
|
|
|
Vector<float, 2> lastMousePos;
|
|
|
|
|
Vector<float, 2> currentMousePos;
|
|
|
|
|
Vector<float, 2> mouseDelta;
|
2025-12-30 23:28:38 +01:00
|
|
|
};
|
|
|
|
|
|
2026-03-09 20:10:19 +01:00
|
|
|
struct ScaleData2D {
|
|
|
|
|
Vector<std::int32_t, 2> position;
|
|
|
|
|
Vector<std::int32_t, 2> size;
|
2025-11-22 20:58:42 +01:00
|
|
|
};
|
2025-11-26 20:15:25 +01:00
|
|
|
|
2025-12-30 23:28:38 +01:00
|
|
|
struct ClipRect {
|
|
|
|
|
std::int32_t left;
|
|
|
|
|
std::int32_t right;
|
|
|
|
|
std::int32_t top;
|
|
|
|
|
std::int32_t bottom;
|
2025-11-26 20:15:25 +01:00
|
|
|
};
|
2025-04-16 00:43:33 +02:00
|
|
|
|
2025-12-30 23:28:38 +01:00
|
|
|
struct FrameTime {
|
2025-11-24 03:38:20 +01:00
|
|
|
std::chrono::time_point<std::chrono::high_resolution_clock> now;
|
|
|
|
|
std::chrono::duration<double> delta;
|
|
|
|
|
};
|
2025-11-23 04:04:53 +01:00
|
|
|
|
2025-12-30 23:28:38 +01:00
|
|
|
enum class OpaqueType {
|
2025-12-28 00:47:27 +01:00
|
|
|
FullyOpaque, // All pixels have A of 255
|
|
|
|
|
SemiOpaque, // All pixels have A of 0 or 255 (no blending needed)
|
|
|
|
|
Transparent // Color blending is used
|
|
|
|
|
};
|
2025-11-23 04:04:53 +01:00
|
|
|
|
2025-12-30 23:28:38 +01:00
|
|
|
enum class CrafterKeys {
|
2025-12-28 00:05:03 +01:00
|
|
|
// Alphabetic keys
|
|
|
|
|
A, B, C, D, E, F, G, H, I, J, K, L, M,
|
|
|
|
|
N, O, P, Q, R, S, T, U, V, W, X, Y, Z,
|
|
|
|
|
|
|
|
|
|
// Numeric keys
|
|
|
|
|
_0, _1, _2, _3, _4, _5, _6, _7, _8, _9,
|
|
|
|
|
|
|
|
|
|
// Function keys
|
|
|
|
|
F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12,
|
|
|
|
|
|
|
|
|
|
// Control keys
|
|
|
|
|
Escape, Tab, Enter, Space, Backspace, Delete, Insert,
|
|
|
|
|
Home, End, PageUp, PageDown, CapsLock, NumLock, ScrollLock,
|
|
|
|
|
|
|
|
|
|
// Modifier keys
|
|
|
|
|
LeftShift, RightShift, LeftCtrl, RightCtrl,
|
|
|
|
|
LeftAlt, RightAlt, LeftSuper, RightSuper,
|
|
|
|
|
|
|
|
|
|
// Arrow keys
|
|
|
|
|
Up, Down, Left, Right,
|
|
|
|
|
|
|
|
|
|
// Keypad keys
|
|
|
|
|
keypad_0, keypad_1, keypad_2, keypad_3, keypad_4,
|
|
|
|
|
keypad_5, keypad_6, keypad_7, keypad_8, keypad_9,
|
|
|
|
|
keypad_enter, keypad_plus, keypad_minus, keypad_multiply,
|
|
|
|
|
keypad_divide, keypad_decimal,
|
|
|
|
|
|
|
|
|
|
// Punctuation and special keys
|
|
|
|
|
grave, minus, equal, bracket_left, bracket_right,
|
|
|
|
|
backslash, semicolon, quote, comma, period, slash,
|
|
|
|
|
print_screen, pause, menu,
|
|
|
|
|
|
|
|
|
|
// Additional keys
|
|
|
|
|
volume_up, volume_down, volume_mute,
|
|
|
|
|
media_play, media_stop, media_prev, media_next,
|
|
|
|
|
browser_back, browser_forward, browser_refresh,
|
|
|
|
|
browser_stop, browser_search, browser_home,
|
|
|
|
|
launch_mail, launch_calculator, launch_media_player,
|
|
|
|
|
|
|
|
|
|
CrafterKeysMax
|
|
|
|
|
};
|
2026-01-28 23:37:12 +01:00
|
|
|
|
2026-01-29 01:31:17 +01:00
|
|
|
template <typename T, typename T2>
|
|
|
|
|
constexpr T AlignUp(T value, T2 alignment) {
|
|
|
|
|
return (value + alignment - 1) & ~(alignment - 1);
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-22 00:46:38 +01:00
|
|
|
template <typename T>
|
|
|
|
|
constexpr T GetTanHalfFov(T fov) {
|
|
|
|
|
return std::tan(fov * std::numbers::pi / 360.0);
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-09 20:10:19 +01:00
|
|
|
#ifdef CRAFTER_GRAPHICS_RENDERER_VULKAN
|
2026-01-28 23:37:12 +01:00
|
|
|
struct DescriptorBinding {
|
|
|
|
|
VkDescriptorType type;
|
|
|
|
|
std::uint32_t slot;
|
|
|
|
|
};
|
|
|
|
|
#endif
|
2025-04-16 00:43:33 +02:00
|
|
|
}
|