63 lines
1.8 KiB
Plaintext
63 lines
1.8 KiB
Plaintext
#include "cGFX.hpp"
|
|
|
|
/*** SDL Header Files ***/
|
|
#include <SDL2_gfxPrimitives.h>
|
|
|
|
/*** Custom Header Files ***/
|
|
#include "../VideoEngine/cRenderer.hpp"
|
|
#include "../UtilityEngine/cUtility.hpp"
|
|
|
|
using FXEngine::cGFX;
|
|
using VideoEngine::cRenderer;
|
|
using UtilityEngine::cUtility;
|
|
|
|
/*static*/ cGFX* cGFX::sp_inst = nullptr;
|
|
|
|
//private:
|
|
cGFX::cGFX()
|
|
{}
|
|
|
|
cGFX::~cGFX()
|
|
{}
|
|
|
|
//public:
|
|
///Functions
|
|
/*static*/ cGFX& cGFX::Inst()
|
|
{
|
|
if (sp_inst == nullptr)
|
|
sp_inst = new cGFX();
|
|
return *sp_inst;
|
|
}
|
|
|
|
/*static*/ void cGFX::Delete()
|
|
{
|
|
delete sp_inst;
|
|
sp_inst = nullptr;
|
|
}
|
|
|
|
void cGFX::StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour ) const
|
|
{
|
|
if (stringRGBA(cRenderer::Inst().getRenderer(), (Sint16)pos.x, (Sint16)pos.y, text.c_str(), colour.r, colour.g, colour.b, colour.a) < 0)
|
|
cUtility::Inst().Message("Unable to render text. stringRGBA():", __AT__, cUtility::eTypeSDL::GFX);
|
|
}
|
|
|
|
void cGFX::StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour, SDL_Texture* texture ) const
|
|
{
|
|
cRenderer::Inst().SetRenderTarget(texture);
|
|
StringDefault(text, pos, colour);
|
|
cRenderer::Inst().ResetRenderTarget();
|
|
}
|
|
|
|
void cGFX::RoundedRectangle( const SDL_Rect& rect, const unsigned long int rad, const SDL_Colour& colour ) const
|
|
{
|
|
if (roundedBoxRGBA(cRenderer::Inst().getRenderer(), (Sint16)rect.x, (Sint16)rect.y, (Sint16)rect.w, (Sint16)rect.h, (Sint16)rad, colour.r, colour.g, colour.b, colour.a) < 0)
|
|
cUtility::Inst().Message("Unable to make Rounded Rectangle. roundedRectangleRGBA():", __AT__, cUtility::eTypeSDL::GFX);
|
|
}
|
|
|
|
void cGFX::RoundedRectangle( const SDL_Rect& rect, const unsigned long int rad, const SDL_Colour& colour, SDL_Texture* texture ) const
|
|
{
|
|
cRenderer::Inst().SetRenderTarget(texture);
|
|
RoundedRectangle(rect, rad, colour);
|
|
cRenderer::Inst().ResetRenderTarget();
|
|
}
|