Mana
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
SDLGraphics Class Referencefinal

#include <sdlgraphics.h>

Inheritance diagram for SDLGraphics:
Graphics

Public Member Functions

 SDLGraphics (SDL_Window *window, SDL_Renderer *renderer)
 
 ~SDLGraphics () override
 
void setVSync (bool sync) override
 Sets whether vertical refresh syncing is enabled.
 
void updateSize (int windowWidth, int windowHeight, float scale) override
 Called when the window size or scale has changed.
 
bool drawRescaledImage (const Image *image, int srcX, int srcY, int dstX, int dstY, int width, int height, int desiredWidth, int desiredHeight, bool useColor) override
 Draws a rescaled version of the image.
 
void drawRescaledImagePattern (const Image *image, int srcX, int srcY, int srcW, int srcH, int dstX, int dstY, int dstW, int dstH, int scaledWidth, int scaledHeight) override
 Draw a pattern based on a rescaled version of the given image.
 
void updateScreen () override
 Updates the screen.
 
void windowToLogical (int windowX, int windowY, float &logicalX, float &logicalY) const override
 Converts a window coordinate to a logical coordinate.
 
SDL_Surface * getScreenshot () override
 Takes a screenshot and returns it as SDL surface.
 
void drawPoint (int x, int y) override
 
void drawLine (int x1, int y1, int x2, int y2) override
 
void drawRectangle (const gcn::Rectangle &rectangle) override
 
void fillRectangle (const gcn::Rectangle &rectangle) override
 
- Public Member Functions inherited from Graphics
 Graphics ()=default
 
bool drawImage (const Image *image, int x, int y)
 Blits an image onto the screen.
 
bool drawImageF (const Image *image, float x, float y)
 Blits an image onto the screen.
 
bool drawRescaledImage (const Image *image, int x, int y, int width, int height)
 Draws a rescaled version of the image.
 
virtual bool drawRescaledImageF (const Image *image, int srcX, int srcY, float dstX, float dstY, int width, int height, float desiredWidth, float desiredHeight, bool useColor=false)
 Draws a rescaled version of the image.
 
virtual bool drawImage (const Image *image, int srcX, int srcY, int dstX, int dstY, int width, int height, bool useColor=false)
 Blits an image onto the screen.
 
virtual bool drawImageF (const Image *image, int srcX, int srcY, float dstX, float dstY, int width, int height, bool useColor=false)
 Blits an image onto the screen.
 
virtual void drawImagePattern (const Image *image, int x, int y, int w, int h)
 
void drawRescaledImagePattern (const Image *image, int x, int y, int w, int h, int scaledWidth, int scaledHeight)
 Draw a pattern based on a rescaled version of the given image.
 
void drawImageRect (const ImageRect &imgRect, int x, int y, int w, int h)
 Draws a rectangle using images.
 
void drawImageRect (const ImageRect &imgRect, const gcn::Rectangle &area)
 
void drawText (const std::string &text, int x, int y, gcn::Graphics::Alignment alignment, const gcn::Color &color, gcn::Font *font, bool outline=false, bool shadow=false, const std::optional< gcn::Color > &outlineColor={}, const std::optional< gcn::Color > &shadowColor={})
 
void drawText (const std::string &text, int x, int y, gcn::Graphics::Alignment align, gcn::Font *font, const TextFormat &format)
 
int getWidth () const
 Returns the logical width of the screen.
 
int getHeight () const
 Returns the logical height of the screen.
 
float getScale () const
 Returns the graphics scale.
 
void _beginDraw () override
 
void _endDraw () override
 
gcn::Font * getFont () const
 
void drawImage (const gcn::Image *image, int srcX, int srcY, int dstX, int dstY, int width, int height) override
 
void setColor (const gcn::Color &color) override
 
const gcn::Color & getColor () const final
 
void pushClipRect (const gcn::Rectangle &rect)
 
void popClipRect ()
 

Static Public Member Functions

static std::unique_ptr< Graphicscreate (SDL_Window *window, const VideoSettings &settings)
 

Protected Member Functions

void updateClipRect () override
 

Private Member Functions

void setColorAlphaMod (const Image *image, bool useColor) const
 

Private Attributes

SDL_Window * mWindow = nullptr
 
SDL_Renderer * mRenderer = nullptr
 

Additional Inherited Members

- Protected Attributes inherited from Graphics
int mWidth = 0
 
int mHeight = 0
 
float mScale = 1.0f
 
gcn::Color mColor
 
std::stack< gcn::Rectangle > mClipRects
 

Detailed Description

Definition at line 30 of file sdlgraphics.h.

Constructor & Destructor Documentation

◆ SDLGraphics()

SDLGraphics::SDLGraphics ( SDL_Window *  window,
SDL_Renderer *  renderer 
)

Definition at line 50 of file sdlgraphics.cpp.

◆ ~SDLGraphics()

SDLGraphics::~SDLGraphics ( )
override

Definition at line 83 of file sdlgraphics.cpp.

Member Function Documentation

◆ create()

std::unique_ptr< Graphics > SDLGraphics::create ( SDL_Window *  window,
const VideoSettings settings 
)
static

Definition at line 33 of file sdlgraphics.cpp.

◆ drawLine()

void SDLGraphics::drawLine ( int  x1,
int  y1,
int  x2,
int  y2 
)
override

Definition at line 308 of file sdlgraphics.cpp.

◆ drawPoint()

void SDLGraphics::drawPoint ( int  x,
int  y 
)
override

Definition at line 285 of file sdlgraphics.cpp.

◆ drawRectangle()

void SDLGraphics::drawRectangle ( const gcn::Rectangle &  rectangle)
override

Definition at line 330 of file sdlgraphics.cpp.

◆ drawRescaledImage()

bool SDLGraphics::drawRescaledImage ( const Image image,
int  srcX,
int  srcY,
int  dstX,
int  dstY,
int  width,
int  height,
int  desiredWidth,
int  desiredHeight,
bool  useColor 
)
overridevirtual

Draws a rescaled version of the image.

Implements Graphics.

Definition at line 112 of file sdlgraphics.cpp.

◆ drawRescaledImagePattern()

void SDLGraphics::drawRescaledImagePattern ( const Image image,
int  srcX,
int  srcY,
int  srcW,
int  srcH,
int  dstX,
int  dstY,
int  dstW,
int  dstH,
int  scaledWidth,
int  scaledHeight 
)
overridevirtual

Draw a pattern based on a rescaled version of the given image.

Implements Graphics.

Definition at line 174 of file sdlgraphics.cpp.

◆ fillRectangle()

void SDLGraphics::fillRectangle ( const gcn::Rectangle &  rectangle)
override

Definition at line 353 of file sdlgraphics.cpp.

◆ getScreenshot()

SDL_Surface * SDLGraphics::getScreenshot ( )
overridevirtual

Takes a screenshot and returns it as SDL surface.

Implements Graphics.

Definition at line 234 of file sdlgraphics.cpp.

◆ setColorAlphaMod()

void SDLGraphics::setColorAlphaMod ( const Image image,
bool  useColor 
) const
private

Definition at line 385 of file sdlgraphics.cpp.

◆ setVSync()

void SDLGraphics::setVSync ( bool  sync)
overridevirtual

Sets whether vertical refresh syncing is enabled.

Implements Graphics.

Definition at line 88 of file sdlgraphics.cpp.

◆ updateClipRect()

void SDLGraphics::updateClipRect ( )
overrideprotectedvirtual

Implements Graphics.

Definition at line 266 of file sdlgraphics.cpp.

◆ updateScreen()

void SDLGraphics::updateScreen ( )
overridevirtual

Updates the screen.

This is done by either copying the buffer to the screen or swapping pages.

Implements Graphics.

Definition at line 215 of file sdlgraphics.cpp.

◆ updateSize()

void SDLGraphics::updateSize ( int  width,
int  height,
float  scale 
)
overridevirtual

Called when the window size or scale has changed.

Reimplemented from Graphics.

Definition at line 95 of file sdlgraphics.cpp.

◆ windowToLogical()

void SDLGraphics::windowToLogical ( int  windowX,
int  windowY,
float &  logicalX,
float &  logicalY 
) const
overridevirtual

Converts a window coordinate to a logical coordinate.

Used for converting mouse coordinates.

Implements Graphics.

Definition at line 220 of file sdlgraphics.cpp.

Member Data Documentation

◆ mRenderer

SDL_Renderer* SDLGraphics::mRenderer = nullptr
private

Definition at line 89 of file sdlgraphics.h.

◆ mWindow

SDL_Window* SDLGraphics::mWindow = nullptr
private

Definition at line 88 of file sdlgraphics.h.


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