12#include <graphical/renderWindow.hpp>
14#include "systems/RenderConcept.hpp"
34 bool isOpen = _window.pollEvents(_rtkEventCache);
40 static_cast<rtk::Key
>(k));
44 static_cast<rtk::Key
>(k));
49 ->_rtkEventCache.isMouseButtonPressed(
50 static_cast<rtk::MouseButton
>(b));
55 ->_rtkEventCache.isMouseButtonReleased(
56 static_cast<rtk::MouseButton
>(b));
67 ->_rtkEventCache.isGamepadButtonPressed(
68 j,
static_cast<rtk::GamepadButton
>(b));
73 ->_rtkEventCache.isGamepadButtonReleased(
74 j,
static_cast<rtk::GamepadButton
>(b));
79 ->_rtkEventCache.getGamepadAxis(j,
static_cast<rtk::GamepadAxis
>(a));
83 ->_rtkEventCache.isGamepadConnected(j);
95 return _window.beginFrame(rtk::RGB{color.
r, color.
g, color.
b});
102 void draw(std::span<const rtk::ecs::concepts::SpriteData> sprites) {
103 _rtkSpritesCache.clear();
105 if (_rtkSpritesCache.capacity() < sprites.size())
106 _rtkSpritesCache.reserve(sprites.size());
108 for (
const auto &ecsSprite : sprites)
109 _rtkSpritesCache.push_back(std::bit_cast<rtk::SpriteData>(ecsSprite));
111 _window.draw(_rtkSpritesCache);
120 rtk::RenderWindow &_window;
121 rtk::Event _rtkEventCache;
123 std::vector<rtk::SpriteData> _rtkSpritesCache;
Adapts the window of the graphical library to the IsRenderWindow concept.
Definition rtkWindowAdapter.hpp:20
RtkWindowAdapter(rtk::RenderWindow &window)
Wraps a window.
Definition rtkWindowAdapter.hpp:26
bool beginFrame(rtk::ecs::concepts::ColorRGBA8 color)
Starts a frame cleared with a color.
Definition rtkWindowAdapter.hpp:94
void endFrame()
Presents the frame.
Definition rtkWindowAdapter.hpp:117
void draw(std::span< const rtk::ecs::concepts::SpriteData > sprites)
Draws a batch of sprites.
Definition rtkWindowAdapter.hpp:102
bool pollEvents(rtk::ecs::concepts::Event &engineEvent)
Polls window events and points the engine Event at them.
Definition rtkWindowAdapter.hpp:33
Input query interface filled by the window backend.
Definition RenderConcept.hpp:186
int(* _getMouseY)(void *)
Backend mouse y query.
Definition RenderConcept.hpp:201
void * userData
Backend context passed to every function.
Definition RenderConcept.hpp:189
bool(* _isMouseButtonPressed)(void *, MouseButton)
Backend mouse press query.
Definition RenderConcept.hpp:195
bool(* _isKeyReleased)(void *, Key)
Backend key release query.
Definition RenderConcept.hpp:193
bool(* _isGamepadConnected)(void *, int)
Backend gamepad presence query.
Definition RenderConcept.hpp:209
bool(* _isMouseButtonReleased)(void *, MouseButton)
Backend mouse release query.
Definition RenderConcept.hpp:197
bool(* _isGamepadButtonPressed)(void *, int, GamepadButton)
Backend gamepad press query.
Definition RenderConcept.hpp:203
bool(* _isGamepadButtonReleased)(void *, int, GamepadButton)
Backend gamepad release query.
Definition RenderConcept.hpp:205
bool(* _isKeyPressed)(void *, Key)
Backend key press query.
Definition RenderConcept.hpp:191
float(* _getGamepadAxis)(void *, int, GamepadAxis)
Backend gamepad axis query.
Definition RenderConcept.hpp:207
int(* _getMouseX)(void *)
Backend mouse x query.
Definition RenderConcept.hpp:199
GamepadAxis
Gamepad analog axes.
Definition RenderConcept.hpp:169
MouseButton
Mouse buttons.
Definition RenderConcept.hpp:130
GamepadButton
Gamepad buttons, with PlayStation style aliases.
Definition RenderConcept.hpp:140
Key
Keyboard keys, mirroring the values of the graphical library.
Definition RenderConcept.hpp:22
8-bit per channel color.
Definition RenderConcept.hpp:325
uint8_t b
Blue channel.
Definition RenderConcept.hpp:328
uint8_t g
Green channel.
Definition RenderConcept.hpp:327
uint8_t r
Red channel.
Definition RenderConcept.hpp:326