6#include "flint/core/config.h"
7#include "flint/core/log.h"
8#include "flint/graphics/gpu/gpu-context.h"
11#include <SDL3/SDL_gpu.h>
12#include <SDL3/SDL_render.h>
39 void setTitle(
const std::string &name)
override {
40 SDL_SetWindowTitle(m_window, name.c_str());
51 SDL_GetWindowSizeInPixels(m_window, &width, &height);
52 return {width, height};
58 SDL_GetMouseState(&x, &y);
59 return {x * SDL_GetWindowPixelDensity(m_window), y * SDL_GetWindowPixelDensity(m_window)};
64 return {
static_cast<float>(pixel.x * SDL_GetWindowPixelDensity(m_window)),
65 static_cast<float>(pixel.y * SDL_GetWindowPixelDensity(m_window))};
72 return static_cast<void *
>(m_window);
87 return m_commandBuffer;
97 SDL_WindowFlags flags = SDL_GetWindowFlags(m_window);
98 return (flags & SDL_WINDOW_FULLSCREEN) != 0;
107 SDL_SetWindowFullscreen(m_window, fullscreen ? SDL_WINDOW_FULLSCREEN : 0);
111 SDL_Window *m_window =
nullptr;
112 SDL_Renderer *m_renderer =
nullptr;
113 SDL_GPUDevice *m_gpuDevice =
nullptr;
114 SDL_GPUCommandBuffer *m_commandBuffer =
nullptr;
115 SDL_GPURenderPass *m_renderPass =
nullptr;
116 bool m_running =
true;
118 std::vector<std::function<void(
const AppEvent &)>> m_globalEventListeners;
Interface that exposes low-level SDL GPU objects from a window implementation.
Abstract interface for a platform window.
Flint::Vec2i getSize() const override
Return the current window size in pixels.
SdlWindow(const ApplicationConfig &config, GRAPHICS_BACKEND backend)
Create and show an SDL window.
bool hasFocus() const override
Return true if the window currently has input focus.
Flint::Vec2f getMousePosition() const override
Return the current mouse cursor position in window-space pixels.
void setGPUDevice(SDL_GPUDevice *device) override
Store the SDL GPU device created by the renderer (IGPUContext).
void close() override
Signal that the window should close at the end of the current frame.
void setTitle(const std::string &name) override
Set the window title.
SDL_GPUDevice * getGPUDevice() override
Return the SDL GPU device (IGPUContext).
SDL_GPUCommandBuffer * getCommandBuffer() override
Return the current frame's command buffer (IGPUContext).
void * getNativeHandle() const override
Return the platform-native window handle (e.g. HWND, SDL_Window*).
void setMouseCursor(CursorType type) override
Set the mouse cursor shape.
Flint::Vec2f mapPixelToCoords(Flint::Vec2f pixel) const override
Pass-through pixel-to-coord mapping (no scaling applied).
bool isFullscreen() const override
Return true if the window is in fullscreen mode.
bool isOpen() const override
Return true if the window is open and the application should keep running.
void setFullscreen(bool fullscreen) override
Enter or exit fullscreen mode.
void display() override
Present the current frame to the screen.
SDL_GPURenderPass * getRenderPass() override
Return the current frame's render pass (IGPUContext).
void addGlobalEventListener(std::function< void(const AppEvent &)> callback) override
Register a global event listener that receives every polled event.
void pollEvents(const std::function< void(const AppEvent &)> &handler) override
Poll all pending OS events and dispatch them to handler.
SDL3 window implementation that also exposes the SDL GPU context.
A tagged union representing a single application input or window event.
User-facing metadata and window defaults for a Flint-powered application.
Generic 2-D vector with arithmetic operators.