Add MathEngineTest and Commects and clean ups

This commit is contained in:
2018-08-18 20:50:06 -04:00
parent bd3c111fa1
commit a815367c9d
52 changed files with 386 additions and 144 deletions
@@ -41,6 +41,13 @@ void cGFX::StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Co
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_Surface* surface ) const
{
//cRenderer::Inst().SetRenderTarget(texture);
//StringDefault(text, pos, colour);
//cRenderer::Inst().ResetRenderTarget();
}
void cGFX::StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour, SDL_Texture* texture ) const
{
cRenderer::Inst().SetRenderTarget(texture);
@@ -48,6 +55,17 @@ void cGFX::StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Co
cRenderer::Inst().ResetRenderTarget();
}
SDL_Texture* cGFX::StringTexture( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour ) const
{
SDL_Texture* rtn = cRenderer::Inst().NewTexture(8 * text.length(), 8, false, SDL_TEXTUREACCESS_TARGET);
if (rtn != nullptr)
cGFX::Inst().StringDefault(text, pos, colour, rtn);
else
cUtility::Inst().Message("Unable to create NewTexture in StringTexture. cRenderer::NewTexture():", __AT__);
return rtn;
}
void cGFX::Box( const SDL_Rect& rect, const SDL_Colour& colour ) const
{
if (boxRGBA(cRenderer::Inst().getRenderer(), (Sint16)rect.x, (Sint16)rect.y, (Sint16)rect.w, (Sint16)rect.h, colour.r, colour.g, colour.b, colour.a) < 0)
@@ -100,17 +118,28 @@ void cGFX::Rectangle( const SDL_Rect& rect, const SDL_Colour& colour, SDL_Textur
cRenderer::Inst().ResetRenderTarget();
}
void cGFX::ZoomIn( SDL_Texture* texture, const double zoomx, const double zoomy, const unsigned long int smooth /*= SMOOTHING_ON*/ ) const
SDL_Surface* cGFX::ZoomIn( SDL_Surface* surface, const double zoomx, const double zoomy, const unsigned long int smooth /*= SMOOTHING_ON*/ ) const
{
SDL_Surface* rtn = nullptr;
rtn = zoomSurface(surface, zoomx, zoomy, smooth);
return rtn;
}
SDL_Texture* cGFX::ZoomIn( SDL_Texture* texture, const double zoomx, const double zoomy, const unsigned long int smooth /*= SMOOTHING_ON*/ ) const
{
SDL_Surface* surface = cRenderer::Inst().TextureToSurface(texture);
SDL_DestroyTexture(texture);
texture = nullptr;
SDL_Surface* zoom_sur = zoomSurface(surface, zoomx, zoomy, smooth);
zoomSurface(surface, zoomx, zoomy, smooth);
texture = cRenderer::Inst().SurfaceToTexture(surface);
SDL_FreeSurface(surface);
surface = nullptr;
SDL_Texture* rtn = cRenderer::Inst().SurfaceToTexture(zoom_sur);
SDL_FreeSurface(zoom_sur);
zoom_sur = nullptr;
return rtn;
}
@@ -25,24 +25,42 @@ namespace FXEngine {
static cGFX& Inst();
static void Delete();
/* Render to the renderer with stringRGBA() from SDL2_gfx */
void StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour ) const;
void StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour, SDL_Surface* surface ) const;
/* Sets texture to renderer and calls StringDefault(text, pos, colour) */
void StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour, SDL_Texture* texture ) const;
/* Creates a Texture for use and calls StringDefault(text, pos, colour, texture) */
SDL_Texture* StringTexture( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour ) const;
/* Render to the renderer with boxRGBA() from SDL2_gfx */
void Box( const SDL_Rect& rect, const SDL_Colour& colour ) const;
/* Sets texture to renderer and calls Box(rect, colour) */
void Box( const SDL_Rect& rect, const SDL_Colour& colour, SDL_Texture* texture ) const;
/* Render to the renderer with roundedBoxRGBA() from SDL2_gfx */
void RoundedBox( const SDL_Rect& rect, const unsigned long int rad, const SDL_Colour& colour ) const;
/* Sets texture to renderer and calls RoundedBox(rect, rad, colour) */
void RoundedBox( const SDL_Rect& rect, const unsigned long int rad, const SDL_Colour& colour, SDL_Texture* texture ) const;
/* Render to the renderer with pixelRGBA() from SDL2_gfx */
void Pixel( const unsigned long int x, const unsigned long int y, const SDL_Colour& colour ) const;
/* Sets texture to renderer and calls Pixel(x, y, colour) */
void Pixel( const unsigned long int x, const unsigned long int y, const SDL_Colour& colour, SDL_Texture* texture ) const;
/* Render to the renderer with rectangleRGBA() from SDL2_gfx */
void Rectangle( const SDL_Rect& rect, const SDL_Colour& colour ) const;
/* Sets texture to renderer and calls Rectangle(rect, colour) */
void Rectangle( const SDL_Rect& rect, const SDL_Colour& colour, SDL_Texture* texture ) const;
void ZoomIn( SDL_Texture* texture, const double zoomx, const double zoomy, const unsigned long int smooth = SMOOTHING_ON ) const;
/* Zooms in or out to stretch or shrink the surface and returns a new surface with zoomSurface() from SDL2_gfx */
SDL_Surface* ZoomIn( SDL_Surface* surface, const double zoomx, const double zoomy, const unsigned long int smooth = SMOOTHING_ON ) const;
/* Zooms in or out to stretch or shrink the texture and returns a new texture with zoomSurface() from SDL2_gfx */
SDL_Texture* ZoomIn( SDL_Texture* texture, const double zoomx, const double zoomy, const unsigned long int smooth = SMOOTHING_ON ) const;
private:
/// Variables
static cGFX* sp_inst;/// = nullptr
};/// END CLASS DEFINITION cGFX
}/// END NAMESPACE DEFINITION FXEngine