Pixels, Surfaces, Renderer, oh my...

This commit is contained in:
BadQuanta
2026-05-11 10:28:21 +00:00
parent 97c8847eb0
commit 28e9c4ba18
35 changed files with 4578 additions and 1210 deletions
+5 -23
View File
@@ -1,9 +1,6 @@
#pragma once
/**
* @file video.hpp
* @brief Marries the two classes together resolving what would otherwise be circular dependencies between Window and
* Renderer
*/
/// @file video.hpp
/// For complete documentation, see src/video.cpp
#include <hdk/sdl/video/Display.hpp>
#include <hdk/sdl/video/Surface.hpp>
#include <hdk/sdl/video/Window.hpp>
@@ -13,26 +10,8 @@
#include <hdk/sdl/render/Renderer.hpp>
namespace hdk::sdl {
/** @see SDL_GetRenderer
* https://wiki.libsdl.org/SDL3/SDL_GetRenderer
* @brief Get the renderer associated with a window.
* @return Renderer The renderer associated with the window. If the window is invalid or has no renderer, returns an
* invalid renderer.
*/
inline Renderer Window::GetRenderer() const { return Renderer(Renderer::get_or_view(SDL_GetRenderer(*this))); }
/** @see SDL_GetRenderWindow
* https://wiki.libsdl.org/SDL3/SDL_GetRenderWindow
*/
inline Window Renderer::GetWindow() const { return Window(Window::get_or_view(SDL_GetRenderWindow(*this))); }
/** @see SDL_CreateWindowAndRenderer
* https://wiki.libsdl.org/SDL3/SDL_CreateWindowAndRenderer
* @brief Create a window and renderer with one function call.
* @param title
* @param width
* @param height
* @param window_flags
* @return std::pair<Window, Renderer>
*/
inline std::pair<Window, Renderer> CreateWindowAndRenderer(
const char* title, int width, int height, SDL_WindowFlags window_flags) {
SDL_Window* window_ptr = nullptr;
@@ -44,4 +23,7 @@ namespace hdk::sdl {
return { Window(nullptr), Renderer(nullptr) };
}
}
inline Palette Surface::CreatePalette() const {
return Palette::get_or_cache(SDL_CreateSurfacePalette(*this), SDL_DestroyPalette);
}
}