Mana
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Graphics Class Referenceabstract

A central point of control for graphics. More...

#include <graphics.h>

Inheritance diagram for Graphics:
SDLGraphics

Public Member Functions

 Graphics ()=default
 
virtual void setVSync (bool sync)=0
 Sets whether vertical refresh syncing is enabled.
 
virtual void updateSize (int width, int height, float scale)
 Called when the window size or scale has changed.
 
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 drawRescaledImage (const Image *image, int srcX, int srcY, int dstX, int dstY, int width, int height, int desiredWidth, int desiredHeight, bool useColor=false)=0
 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.
 
virtual 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)=0
 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)
 
virtual void updateScreen ()=0
 Updates the screen.
 
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.
 
virtual void windowToLogical (int windowX, int windowY, float &logicalX, float &logicalY) const =0
 Converts a window coordinate to a logical coordinate.
 
void _beginDraw () override
 
void _endDraw () override
 
virtual SDL_Surface * getScreenshot ()=0
 Takes a screenshot and returns it as SDL surface.
 
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 ()
 

Protected Member Functions

virtual void updateClipRect ()=0
 

Protected Attributes

int mWidth = 0
 
int mHeight = 0
 
float mScale = 1.0f
 
gcn::Color mColor
 
std::stack< gcn::Rectangle > mClipRects
 

Detailed Description

A central point of control for graphics.

Definition at line 77 of file graphics.h.

Constructor & Destructor Documentation

◆ Graphics()

Graphics::Graphics ( )
default

Member Function Documentation

◆ _beginDraw()

void Graphics::_beginDraw ( )
override

Definition at line 242 of file graphics.cpp.

◆ _endDraw()

void Graphics::_endDraw ( )
override

Definition at line 247 of file graphics.cpp.

◆ drawImage() [1/3]

void Graphics::drawImage ( const gcn::Image *  image,
int  srcX,
int  srcY,
int  dstX,
int  dstY,
int  width,
int  height 
)
inlineoverride

Definition at line 250 of file graphics.h.

◆ drawImage() [2/3]

bool Graphics::drawImage ( const Image image,
int  srcX,
int  srcY,
int  dstX,
int  dstY,
int  width,
int  height,
bool  useColor = false 
)
virtual

Blits an image onto the screen.

Returns
true if the image was blitted properly false otherwise.

Definition at line 77 of file graphics.cpp.

◆ drawImage() [3/3]

bool Graphics::drawImage ( const Image image,
int  x,
int  y 
)

Blits an image onto the screen.

Returns
true if the image was blitted properly false otherwise.

Definition at line 36 of file graphics.cpp.

◆ drawImageF() [1/2]

bool Graphics::drawImageF ( const Image image,
float  x,
float  y 
)

Blits an image onto the screen.

Returns
true if the image was blitted properly false otherwise.

Definition at line 44 of file graphics.cpp.

◆ drawImageF() [2/2]

bool Graphics::drawImageF ( const Image image,
int  srcX,
int  srcY,
float  dstX,
float  dstY,
int  width,
int  height,
bool  useColor = false 
)
virtual

Blits an image onto the screen.

Returns
true if the image was blitted properly false otherwise.

Definition at line 90 of file graphics.cpp.

◆ drawImagePattern()

void Graphics::drawImagePattern ( const Image image,
int  x,
int  y,
int  w,
int  h 
)
virtual

Definition at line 99 of file graphics.cpp.

◆ drawImageRect() [1/2]

void Graphics::drawImageRect ( const ImageRect imgRect,
const gcn::Rectangle &  area 
)
inline

Definition at line 188 of file graphics.h.

◆ drawImageRect() [2/2]

void Graphics::drawImageRect ( const ImageRect imgRect,
int  x,
int  y,
int  w,
int  h 
)

Draws a rectangle using images.

4 corner images, 4 side images and 1 image for the inside.

Definition at line 123 of file graphics.cpp.

◆ drawRescaledImage() [1/2]

virtual bool Graphics::drawRescaledImage ( const Image image,
int  srcX,
int  srcY,
int  dstX,
int  dstY,
int  width,
int  height,
int  desiredWidth,
int  desiredHeight,
bool  useColor = false 
)
pure virtual

Draws a rescaled version of the image.

Implemented in SDLGraphics.

◆ drawRescaledImage() [2/2]

bool Graphics::drawRescaledImage ( const Image image,
int  x,
int  y,
int  width,
int  height 
)

Draws a rescaled version of the image.

Definition at line 52 of file graphics.cpp.

◆ drawRescaledImageF()

bool Graphics::drawRescaledImageF ( const Image image,
int  srcX,
int  srcY,
float  dstX,
float  dstY,
int  width,
int  height,
float  desiredWidth,
float  desiredHeight,
bool  useColor = false 
)
virtual

Draws a rescaled version of the image.

Definition at line 60 of file graphics.cpp.

◆ drawRescaledImagePattern() [1/2]

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

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

Implemented in SDLGraphics.

◆ drawRescaledImagePattern() [2/2]

void Graphics::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.

Definition at line 108 of file graphics.cpp.

◆ drawText() [1/2]

void Graphics::drawText ( const std::string &  text,
int  x,
int  y,
gcn::Graphics::Alignment  align,
gcn::Font *  font,
const TextFormat format 
)

Definition at line 223 of file graphics.cpp.

◆ drawText() [2/2]

void Graphics::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 = {} 
)

Definition at line 176 of file graphics.cpp.

◆ getColor()

const gcn::Color & Graphics::getColor ( ) const
inlinefinal

Definition at line 260 of file graphics.h.

◆ getFont()

gcn::Font * Graphics::getFont ( ) const
inline

Definition at line 248 of file graphics.h.

◆ getHeight()

int Graphics::getHeight ( ) const
inline

Returns the logical height of the screen.

Definition at line 226 of file graphics.h.

◆ getScale()

float Graphics::getScale ( ) const
inline

Returns the graphics scale.

Definition at line 231 of file graphics.h.

◆ getScreenshot()

virtual SDL_Surface * Graphics::getScreenshot ( )
pure virtual

Takes a screenshot and returns it as SDL surface.

Implemented in SDLGraphics.

◆ getWidth()

int Graphics::getWidth ( ) const
inline

Returns the logical width of the screen.

Definition at line 221 of file graphics.h.

◆ popClipRect()

void Graphics::popClipRect ( )

Definition at line 263 of file graphics.cpp.

◆ pushClipRect()

void Graphics::pushClipRect ( const gcn::Rectangle &  rect)

Definition at line 252 of file graphics.cpp.

◆ setColor()

void Graphics::setColor ( const gcn::Color &  color)
inlineoverride

Definition at line 255 of file graphics.h.

◆ setVSync()

virtual void Graphics::setVSync ( bool  sync)
pure virtual

Sets whether vertical refresh syncing is enabled.

Implemented in SDLGraphics.

◆ updateClipRect()

virtual void Graphics::updateClipRect ( )
protectedpure virtual

Implemented in SDLGraphics.

◆ updateScreen()

virtual void Graphics::updateScreen ( )
pure virtual

Updates the screen.

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

Implemented in SDLGraphics.

◆ updateSize()

void Graphics::updateSize ( int  width,
int  height,
float  scale 
)
virtual

Called when the window size or scale has changed.

Reimplemented in SDLGraphics.

Definition at line 30 of file graphics.cpp.

◆ windowToLogical()

virtual void Graphics::windowToLogical ( int  windowX,
int  windowY,
float &  logicalX,
float &  logicalY 
) const
pure virtual

Converts a window coordinate to a logical coordinate.

Used for converting mouse coordinates.

Implemented in SDLGraphics.

Member Data Documentation

◆ mClipRects

std::stack<gcn::Rectangle> Graphics::mClipRects
protected

Definition at line 277 of file graphics.h.

◆ mColor

gcn::Color Graphics::mColor
protected

Definition at line 274 of file graphics.h.

◆ mHeight

int Graphics::mHeight = 0
protected

Definition at line 272 of file graphics.h.

◆ mScale

float Graphics::mScale = 1.0f
protected

Definition at line 273 of file graphics.h.

◆ mWidth

int Graphics::mWidth = 0
protected

Definition at line 271 of file graphics.h.


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