Initial scaffolding.

This commit is contained in:
BadQuanta
2026-04-20 11:00:42 +00:00
commit 6d0de7e621
7 changed files with 118 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
#pragma once
/**
* @file Window.hpp
* @brief HDK sdl video header only wrapper for SDL_Window struct & related functions
*/
#include <SDL3/SDL.h>
#include <hdk/grid/SharedPtrWrapper.hpp>
/** Windows are the primary interface for rendering and interacting with the user in SDL */
namespace hdk::sdl {
class Window : public hdk::grid::SharedPtrWrapper<SDL_Window> {
public:
/** Inherit constructors from SharedPtrWrapper */
using hdk::grid::SharedPtrWrapper<SDL_Window>::SharedPtrWrapper;
/**
* https://wiki.libsdl.org/SDL3/SDL_CreateWindow
* https://wiki.libsdl.org/SDL3/SDL_DestroyWindowSurface
*
* @param title The title of the window, in UTF-8 encoding. If the title contains UTF-8 characters, you should use SDL_CreateWindowUTF8() instead.
* @param w The width of the window in pixels.
* @param h The height of the window in pixels.
* @param flags 0, or one or more SDL_WindowFlags OR'd together.
* @return A Window instance that manages the created SDL_Window. If window creation fails, the returned Window will evaluate to false (i.e., it will be null).
*/
static Window Create(const char* title, int w, int h, SDL_WindowFlags flags)
{
return Window(get_or_cache(SDL_CreateWindow(title, w, h, flags), SDL_DestroyWindow));
}
/**
* https://wiki.libsdl.org/SDL3/SDL_GetWindowFromID
* @brief Get window for WindowID
* @param id The ID of the window.
* @return A Window instance that wraps the SDL_Window. If no window with the given ID exists, the returned Window will evaluate to false (i.e., it will be null).
*/
static Window GetFromID(SDL_WindowID id)
{
/** Because it is possible windows were created by other means, we use get_or_view to wrap the SDL_Window without taking ownership */
return Window(get_or_view(SDL_GetWindowFromID(id)));
}
};
}