TinyGPU
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
DisplayDriverSDL< RGB_T > Class Template Reference

Display class for rendering a Surface<RGB565> using the SDL2 library. This class can be used to display the contents of a TinyGPU Surface<RGB565> on a desktop environment for testing and debugging purposes. More...

#include <DisplayDriverSDL.h>

Inheritance diagram for DisplayDriverSDL< RGB_T >:
Inheritance graph
[legend]
Collaboration diagram for DisplayDriverSDL< RGB_T >:
Collaboration graph
[legend]

Public Member Functions

 DisplayDriverSDL (size_t width, size_t height)
 
 DisplayDriverSDL (const ISurface< RGB_T > &surface)
 
size_t width () const override
 
size_t height () const override
 
bool begin () override
 
bool writeData (ISurface< RGB_T > &surface) override
 
bool writeData (ISurface< RGB_T > &surface, size_t x, size_t y) override
 
void end () override
 
- Public Member Functions inherited from DisplayDriver< RGB_T >
virtual ~DisplayDriver ()=default
 
virtual bool begin ()=0
 
virtual void end ()
 
virtual bool writeData (ISurface< RGB_T > &surface)=0
 
virtual bool writeData (ISurface< RGB_T > &surface, size_t x, size_t y)=0
 
virtual void setRotation (DisplayRotation rotation)
 
virtual size_t width () const =0
 
virtual size_t height () const =0
 
void writeColor (size_t width, size_t height, RGB_T color)
 

Protected Member Functions

bool setAddressWindow (size_t x, size_t y, size_t w, size_t h) override
 
virtual bool setAddressWindow (size_t x, size_t y, size_t w, size_t h)=0
 

Protected Attributes

size_t w_ = 0
 
size_t h_ = 0
 
SDL_Window * window_ = nullptr
 
SDL_Renderer * renderer_ = nullptr
 
SDL_Texture * texture_ = nullptr
 
std::vector< uint8_t > scratch_
 
- Protected Attributes inherited from DisplayDriver< RGB_T >
Font5x7< RGB_T > defaultFont
 

Detailed Description

template<typename RGB_T = RGB565>
class tinygpu::DisplayDriverSDL< RGB_T >

Display class for rendering a Surface<RGB565> using the SDL2 library. This class can be used to display the contents of a TinyGPU Surface<RGB565> on a desktop environment for testing and debugging purposes.

writeData() drains the SDL event queue on every call and exits the process on SDL_QUIT (i.e. the window's close button), since sketches that never touch a TouchDriverSDL - the only other place that pumps events - would otherwise leave the window unresponsive to being closed: with no one calling SDL_PollEvent, the window manager's close request just piles up in SDL's queue and the OS reports the window as hung.

Constructor & Destructor Documentation

◆ DisplayDriverSDL() [1/2]

DisplayDriverSDL ( size_t  width,
size_t  height 
)
inline

◆ DisplayDriverSDL() [2/2]

DisplayDriverSDL ( const ISurface< RGB_T > &  surface)
inline

Member Function Documentation

◆ begin()

bool begin ( )
inlineoverridevirtual

◆ end()

void end ( )
inlineoverridevirtual

Reimplemented from DisplayDriver< RGB_T >.

◆ height()

size_t height ( ) const
inlineoverridevirtual

◆ setAddressWindow()

bool setAddressWindow ( size_t  x,
size_t  y,
size_t  w,
size_t  h 
)
inlineoverrideprotectedvirtual

◆ width()

size_t width ( ) const
inlineoverridevirtual

Current addressable panel width/height in pixels - for a driver that supports setRotation(), these reflect the current rotation (landscape vs portrait swaps them; see isLandscapeFamily()), not necessarily the panel's native/physical orientation. Callers that need to lay out content (e.g. OutputTinyGPU's scale_to_fit target, or clearScreen()'s band loop) should read these fresh rather than caching their own copy, so a setRotation() call is picked up automatically without needing separate bookkeeping.

Implements DisplayDriver< RGB_T >.

◆ writeData() [1/2]

bool writeData ( ISurface< RGB_T > &  surface)
inlineoverridevirtual

◆ writeData() [2/2]

bool writeData ( ISurface< RGB_T > &  surface,
size_t  x,
size_t  y 
)
inlineoverridevirtual

Member Data Documentation

◆ h_

size_t h_ = 0
protected

◆ renderer_

SDL_Renderer* renderer_ = nullptr
protected

◆ scratch_

std::vector<uint8_t> scratch_
protected

◆ texture_

SDL_Texture* texture_ = nullptr
protected

◆ w_

size_t w_ = 0
protected

◆ window_

SDL_Window* window_ = nullptr
protected

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