Flint Engine
Modular C++20 2D game engine powered by SDL3
Loading...
Searching...
No Matches
Flint::Texture Class Reference

Owns an SDL_Texture loaded from memory or created as a render target. More...

#include <flint/graphics/texture.h>

+ Collaboration diagram for Flint::Texture:

Public Member Functions

 Texture (const Texture &)=delete
 
Texture & operator= (const Texture &)=delete
 
FLINT_API Texture (Texture &&other) noexcept
 Move constructor; transfers SDL_Texture ownership from the other.
 
FLINT_API Texture & operator= (Texture &&other) noexcept
 Move-assignment; releases current texture then steals from the other.
 
FLINT_API bool loadFromMemory (SDL_Renderer *renderer, const void *data, size_t size)
 Load a texture from an in-memory image file.
 
FLINT_API void free ()
 
FLINT_API SDL_Texture * getSDLTexture () const
 Return the underlying SDL_Texture handle.
 
FLINT_API int getWidth () const
 Return the texture width in pixels.
 
FLINT_API int getHeight () const
 Return the texture height in pixels.
 
FLINT_API bool createRenderTarget (SDL_Renderer *renderer, int width, int height)
 Create a render-target texture of the given dimensions.
 

Static Public Member Functions

static FLINT_API Texture fromRenderer (SDL_Renderer *renderer, int width, int height)
 

Detailed Description

Owns an SDL_Texture loaded from memory or created as a render target.

Definition at line 13 of file texture.h.

Constructor & Destructor Documentation

◆ ~Texture()

virtual Flint::Texture::~Texture ( )
inlinevirtual

Definition at line 17 of file texture.h.

Member Function Documentation

◆ createRenderTarget()

FLINT_API bool Flint::Texture::createRenderTarget ( SDL_Renderer * renderer,
int width,
int height )

Create a render-target texture of the given dimensions.

Any existing texture is freed before the new one is created.

Parameters
rendererSDL renderer.
widthTarget width in pixels.
heightTarget height in pixels.
Returns
true on success.

◆ loadFromMemory()

FLINT_API bool Flint::Texture::loadFromMemory ( SDL_Renderer * renderer,
const void * data,
size_t size )

Load a texture from an in-memory image file.

Decodes the image with SDL_image, creates an SDL_Texture from the resulting surface, and applies nearest-neighbor scaling.

Parameters
rendererSDL renderer to create the texture on.
dataPointer to raw image file bytes.
sizeNumber of bytes in data.
Returns
true on success.

The documentation for this class was generated from the following file: