Added initial implementation of the SDL Pixels category.

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
BadQuanta
2026-04-26 17:45:26 +00:00
parent 85dbe33a77
commit 97c8847eb0
8 changed files with 239 additions and 11 deletions
+35 -2
View File
@@ -1,11 +1,44 @@
#pragma once
/**
* @file Renderer_Texture.hpp
* @file render.hpp
* @brief HDK sdl Renderer subsystem. Glues together Texture & Renderer which have circular dependencies
*/
#include <hdk/sdl/render/Renderer.hpp>
#include <hdk/sdl/render/Texture.hpp>
namespace hdk::sdl {
/** @see https://wiki.libsdl.org/SDL3/SDL_GetRendererFromTexture
* @return Renderer The renderer associated with the texture
*/
inline Renderer Texture::GetRenderer() const {
/** we may not have created the renderer we get back, if not we will not own it. */
return Renderer(Renderer::get_or_view(SDL_GetRendererFromTexture(*this)));
}
/** @see https://wiki.libsdl.org/SDL3/SDL_CreateTexture
* @brief Create a texture for a rendering context.
* @param format The pixel format of the texture
* @param access The access pattern for the texture
* @param w The width of the texture in pixels
* @param h The height of the texture in pixels
* @return Texture The created texture. If the creation fails, returns an invalid texture.
*/
inline Texture Renderer::CreateTexture(SDL_PixelFormat format, SDL_TextureAccess access, int w, int h) const {
return Texture(Texture::get_or_cache(SDL_CreateTexture(*this, format, access, w, h), SDL_DestroyTexture));
}
/** @see https://wiki.libsdl.org/SDL3/SDL_CreateTextureFromSurface
* @brief Create a texture from an existing surface.
* @param surface The surface to create the texture from.
* @return Texture The created texture. If the creation fails, returns an invalid texture.
*/
inline Texture Renderer::CreateTextureFromSurface(SDL_Surface* surface) const {
return Texture(Texture::get_or_cache(SDL_CreateTextureFromSurface(*this, surface), SDL_DestroyTexture));
}
/** @see https://wiki.libsdl.org/SDL3/SDL_CreateTextureWithProperties
* @brief Create a texture for a rendering context with specific properties.
* @param properties The properties to create the texture with.
* @return Texture The created texture. If the creation fails, returns an invalid texture.
*/
inline Texture Renderer::CreateTextureWithProperties(SDL_PropertiesID properties) const {
return Texture(Texture::get_or_cache(SDL_CreateTextureWithProperties(*this, properties), SDL_DestroyTexture));
}
}