Clean Up
This commit is contained in:
@@ -5,8 +5,8 @@
|
|||||||
Date Started: August 24, 2009
|
Date Started: August 24, 2009
|
||||||
Date End:
|
Date End:
|
||||||
Webpage: http://www.richardallenonline.com
|
Webpage: http://www.richardallenonline.com
|
||||||
IDE: Visual Studio 2010
|
IDE: Visual Studio 2017
|
||||||
Compiler: C\C++ 2010
|
Compiler: C\C++ 2017
|
||||||
Langage: C++
|
Langage: C++
|
||||||
License: GNU GENERAL PUBLIC LICENSE Version 2
|
License: GNU GENERAL PUBLIC LICENSE Version 2
|
||||||
see license.txt for details
|
see license.txt for details
|
||||||
|
|||||||
@@ -98,12 +98,12 @@ void cSound::setLoops( const long int loops /*= -1*/ )
|
|||||||
}
|
}
|
||||||
|
|
||||||
///Gets
|
///Gets
|
||||||
const cString cSound::getDir() const
|
const cString& cSound::getDir() const
|
||||||
{
|
{
|
||||||
return m_dir;
|
return m_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
const cString cSound::getFileName() const
|
const cString& cSound::getFileName() const
|
||||||
{
|
{
|
||||||
return m_fileName;
|
return m_fileName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,9 +53,9 @@ namespace AudioEngine {
|
|||||||
|
|
||||||
///Gets
|
///Gets
|
||||||
/* Gets the directory of the sound */
|
/* Gets the directory of the sound */
|
||||||
const cString getDir() const;
|
const cString& getDir() const;
|
||||||
/* Gets the file name of the sound */
|
/* Gets the file name of the sound */
|
||||||
const cString getFileName() const;
|
const cString& getFileName() const;
|
||||||
/* Gets the Volume of the sound */
|
/* Gets the Volume of the sound */
|
||||||
const unsigned char getVolume() const;
|
const unsigned char getVolume() const;
|
||||||
/* Gets the Distance of the sound */
|
/* Gets the Distance of the sound */
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
using namespace GUIHelpers;
|
using namespace GUIHelpers;
|
||||||
|
|
||||||
const RGBA GUIHelpers::StringtoRGBA( const cString& colour )
|
const RGBA& GUIHelpers::StringtoRGBA( const cString& colour )
|
||||||
{
|
{
|
||||||
RGBA rtn = DEFAULT;
|
RGBA rtn = DEFAULT;
|
||||||
cString check = colour.upper();
|
cString check = colour.upper();
|
||||||
|
|||||||
@@ -39,9 +39,7 @@ namespace GUIHelpers {
|
|||||||
static const RGBA ROSE = { 255, 0, 128, 255 };
|
static const RGBA ROSE = { 255, 0, 128, 255 };
|
||||||
|
|
||||||
|
|
||||||
const RGBA StringtoRGBA(const cString& colour);
|
const RGBA& StringtoRGBA(const cString& colour);
|
||||||
|
|
||||||
|
|
||||||
}/// END NAMESPACE DEFINITION GUIHelpers
|
}/// END NAMESPACE DEFINITION GUIHelpers
|
||||||
#endif/// END IFNDEF _GUIUTILITY_HPP_
|
#endif/// END IFNDEF _GUIUTILITY_HPP_
|
||||||
|
|
||||||
|
|||||||
@@ -83,9 +83,9 @@ void cXMLoader::GetElement( tinyxml2::XMLElement& element, GUIEngine::cWindow* p
|
|||||||
tmp->Resize();
|
tmp->Resize();
|
||||||
}
|
}
|
||||||
|
|
||||||
const cString cXMLoader::GetAttribute( const tinyxml2::XMLElement& element, const cString& attribute ) const
|
const cString& cXMLoader::GetAttribute( const tinyxml2::XMLElement& element, const cString& attribute ) const
|
||||||
{
|
{
|
||||||
cString rtn = "";
|
cString rtn;
|
||||||
const char* str = element.Attribute(attribute.c_str());
|
const char* str = element.Attribute(attribute.c_str());
|
||||||
if ((str == nullptr) && (m_debugXML == true))
|
if ((str == nullptr) && (m_debugXML == true))
|
||||||
cUtility::Inst().Message("Error no attribute: " + attribute + " found in tag <" + element.Value() + ">");
|
cUtility::Inst().Message("Error no attribute: " + attribute + " found in tag <" + element.Value() + ">");
|
||||||
@@ -211,18 +211,17 @@ GUIEngine::cBoxSizer* cXMLoader::BoxSizerBuild(const tinyxml2::XMLElement& eleme
|
|||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
const cString cXMLoader::getDir(const tinyxml2::XMLElement& element) const
|
const cString& cXMLoader::getDir(const tinyxml2::XMLElement& element) const
|
||||||
{
|
{
|
||||||
cString rtn = GetAttribute(element, "dir");
|
return GetAttribute(element, "dir");
|
||||||
return rtn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const cString cXMLoader::getFileName(const tinyxml2::XMLElement& element) const
|
const cString& cXMLoader::getFileName(const tinyxml2::XMLElement& element) const
|
||||||
{
|
{
|
||||||
cString rtn = GetAttribute(element, "filename");
|
return GetAttribute(element, "filename");
|
||||||
return rtn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const unsigned long int cXMLoader::getDebug( const tinyxml2::XMLElement& element ) const
|
const unsigned long int cXMLoader::getDebug( const tinyxml2::XMLElement& element ) const
|
||||||
{
|
{
|
||||||
unsigned long int rtn = 99;
|
unsigned long int rtn = 99;
|
||||||
@@ -316,7 +315,7 @@ const GUIHelpers::eLayout cXMLoader::getLayout( const tinyxml2::XMLElement& elem
|
|||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
const GUIHelpers::Position cXMLoader::getPosition( const tinyxml2::XMLElement& element ) const
|
const GUIHelpers::Position& cXMLoader::getPosition( const tinyxml2::XMLElement& element ) const
|
||||||
{
|
{
|
||||||
GUIHelpers::Position rtn = { -1, -1 };
|
GUIHelpers::Position rtn = { -1, -1 };
|
||||||
|
|
||||||
@@ -338,7 +337,7 @@ const GUIHelpers::Position cXMLoader::getPosition( const tinyxml2::XMLElement& e
|
|||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
const GUIHelpers::Size cXMLoader::getSize( const tinyxml2::XMLElement& element ) const
|
const GUIHelpers::Size& cXMLoader::getSize( const tinyxml2::XMLElement& element ) const
|
||||||
{
|
{
|
||||||
GUIHelpers::Size rtn = { -1, -1 };
|
GUIHelpers::Size rtn = { -1, -1 };
|
||||||
|
|
||||||
@@ -360,7 +359,7 @@ const GUIHelpers::Size cXMLoader::getSize( const tinyxml2::XMLElement& element )
|
|||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
const GUIHelpers::Padding cXMLoader::getPadding( const tinyxml2::XMLElement& element ) const
|
const GUIHelpers::Padding& cXMLoader::getPadding( const tinyxml2::XMLElement& element ) const
|
||||||
{
|
{
|
||||||
GUIHelpers::Padding rtn = { -1, -1, -1, -1 };
|
GUIHelpers::Padding rtn = { -1, -1, -1, -1 };
|
||||||
|
|
||||||
@@ -386,12 +385,12 @@ const GUIHelpers::Padding cXMLoader::getPadding( const tinyxml2::XMLElement& ele
|
|||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
const cString cXMLoader::getText( const tinyxml2::XMLElement& element ) const
|
const cString& cXMLoader::getText( const tinyxml2::XMLElement& element ) const
|
||||||
{
|
{
|
||||||
return GetAttribute(element, "text");
|
return GetAttribute(element, "text");
|
||||||
}
|
}
|
||||||
|
|
||||||
const GUIHelpers::RGBA cXMLoader::getColour( const tinyxml2::XMLElement& element ) const
|
const GUIHelpers::RGBA& cXMLoader::getColour( const tinyxml2::XMLElement& element ) const
|
||||||
{
|
{
|
||||||
GUIHelpers::RGBA rtn = GUIHelpers::DEFAULT;
|
GUIHelpers::RGBA rtn = GUIHelpers::DEFAULT;
|
||||||
cString str = GetAttribute(element, "colour");
|
cString str = GetAttribute(element, "colour");
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace GUIHelpers {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void GetElement( tinyxml2::XMLElement& element, GUIEngine::cWindow* parent = nullptr ) const;
|
void GetElement( tinyxml2::XMLElement& element, GUIEngine::cWindow* parent = nullptr ) const;
|
||||||
const cString GetAttribute( const tinyxml2::XMLElement& element, const cString& attribute ) const;
|
const cString& GetAttribute( const tinyxml2::XMLElement& element, const cString& attribute ) const;
|
||||||
|
|
||||||
void Include( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const;
|
void Include( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const;
|
||||||
void GUISetup( const tinyxml2::XMLElement& element ) const;
|
void GUISetup( const tinyxml2::XMLElement& element ) const;
|
||||||
@@ -43,20 +43,20 @@ namespace GUIHelpers {
|
|||||||
GUIEngine::cLabel* LabelBuild( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const;
|
GUIEngine::cLabel* LabelBuild( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const;
|
||||||
GUIEngine::cBoxSizer* BoxSizerBuild( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const;
|
GUIEngine::cBoxSizer* BoxSizerBuild( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const;
|
||||||
|
|
||||||
const cString getDir( const tinyxml2::XMLElement& element ) const;
|
const cString& getDir( const tinyxml2::XMLElement& element ) const;
|
||||||
const cString getFileName( const tinyxml2::XMLElement& element ) const;
|
const cString& getFileName( const tinyxml2::XMLElement& element ) const;
|
||||||
const unsigned long int getDebug( const tinyxml2::XMLElement& element ) const;
|
const unsigned long int getDebug( const tinyxml2::XMLElement& element ) const;
|
||||||
const bool cXMLoader::getDebugXML(const tinyxml2::XMLElement& element) const;
|
const bool cXMLoader::getDebugXML(const tinyxml2::XMLElement& element) const;
|
||||||
const signed long int getID( const tinyxml2::XMLElement& element ) const;
|
const signed long int getID( const tinyxml2::XMLElement& element ) const;
|
||||||
const GUIHelpers::eOrientation getOrientation( const tinyxml2::XMLElement& element ) const;
|
const GUIHelpers::eOrientation getOrientation( const tinyxml2::XMLElement& element ) const;
|
||||||
const GUIHelpers::eAlign getAlign( const tinyxml2::XMLElement& element ) const;
|
const GUIHelpers::eAlign getAlign( const tinyxml2::XMLElement& element ) const;
|
||||||
const GUIHelpers::eLayout getLayout( const tinyxml2::XMLElement& element ) const;
|
const GUIHelpers::eLayout getLayout( const tinyxml2::XMLElement& element ) const;
|
||||||
const GUIHelpers::Position getPosition( const tinyxml2::XMLElement& element ) const;
|
const GUIHelpers::Position& getPosition( const tinyxml2::XMLElement& element ) const;
|
||||||
const GUIHelpers::Size getSize( const tinyxml2::XMLElement& element ) const;
|
const GUIHelpers::Size& getSize( const tinyxml2::XMLElement& element ) const;
|
||||||
const GUIHelpers::Padding getPadding( const tinyxml2::XMLElement& element ) const;
|
const GUIHelpers::Padding& getPadding( const tinyxml2::XMLElement& element ) const;
|
||||||
const cString getText( const tinyxml2::XMLElement& element ) const;
|
const cString& getText( const tinyxml2::XMLElement& element ) const;
|
||||||
|
|
||||||
const GUIHelpers::RGBA getColour( const tinyxml2::XMLElement& element ) const;
|
const GUIHelpers::RGBA& getColour( const tinyxml2::XMLElement& element ) const;
|
||||||
const signed long int getFontSize( const tinyxml2::XMLElement& element ) const;
|
const signed long int getFontSize( const tinyxml2::XMLElement& element ) const;
|
||||||
|
|
||||||
void LoadDefault() const;
|
void LoadDefault() const;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ void cBoxSizer::Create( cWindow* parent, const signed int id, const GUIHelpers::
|
|||||||
return GUIHelpers::eType::CBOXSIZER;
|
return GUIHelpers::eType::CBOXSIZER;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*virtual*/ const GUIHelpers::RGBA cBoxSizer::getDebugColour() const
|
/*virtual*/ const GUIHelpers::RGBA& cBoxSizer::getDebugColour() const
|
||||||
{
|
{
|
||||||
return GUIHelpers::CYAN;
|
return GUIHelpers::CYAN;
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@ namespace GUIEngine {
|
|||||||
const cString& name = sNAME );
|
const cString& name = sNAME );
|
||||||
|
|
||||||
virtual const GUIHelpers::eType getType() const;
|
virtual const GUIHelpers::eType getType() const;
|
||||||
virtual const GUIHelpers::RGBA getDebugColour() const;
|
virtual const GUIHelpers::RGBA& getDebugColour() const;
|
||||||
private:
|
private:
|
||||||
private:
|
private:
|
||||||
};/// END CLASS DEFINITION cBoxSizer
|
};/// END CLASS DEFINITION cBoxSizer
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ const cString& cLabel::getText() const
|
|||||||
return GUIHelpers::eType::CLABEL;
|
return GUIHelpers::eType::CLABEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*virtual*/ const GUIHelpers::RGBA cLabel::getDebugColour() const
|
/*virtual*/ const GUIHelpers::RGBA& cLabel::getDebugColour() const
|
||||||
{
|
{
|
||||||
return GUIHelpers::GREEN;
|
return GUIHelpers::GREEN;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace GUIEngine {
|
|||||||
const TextTypeEngine::cFont* getFont() const;
|
const TextTypeEngine::cFont* getFont() const;
|
||||||
const cString& getText() const;
|
const cString& getText() const;
|
||||||
virtual const GUIHelpers::eType getType() const;
|
virtual const GUIHelpers::eType getType() const;
|
||||||
virtual const GUIHelpers::RGBA getDebugColour() const;
|
virtual const GUIHelpers::RGBA& getDebugColour() const;
|
||||||
|
|
||||||
|
|
||||||
//virtual void Resize();
|
//virtual void Resize();
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ cLayout::cLayout(cWindow* parent, const signed int id, const GUIHelpers::eOrient
|
|||||||
return GUIHelpers::eType::CLAYOUT;
|
return GUIHelpers::eType::CLAYOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*virtual*/ const GUIHelpers::RGBA cLayout::getDebugColour() const
|
/*virtual*/ const GUIHelpers::RGBA& cLayout::getDebugColour() const
|
||||||
{
|
{
|
||||||
return GUIHelpers::BLUE;
|
return GUIHelpers::BLUE;
|
||||||
}
|
}
|
||||||
@@ -40,10 +40,9 @@ namespace GUIEngine {
|
|||||||
///Set
|
///Set
|
||||||
|
|
||||||
///Get
|
///Get
|
||||||
|
|
||||||
virtual const GUIHelpers::eType getType() const;
|
virtual const GUIHelpers::eType getType() const;
|
||||||
|
|
||||||
virtual const GUIHelpers::RGBA getDebugColour() const;
|
virtual const GUIHelpers::RGBA& getDebugColour() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GUIHelpers::eOrientation m_orientation;
|
GUIHelpers::eOrientation m_orientation;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ cPanel::cPanel( cWindow* parent /*= nullptr*/, const signed int id /*= -1*/, con
|
|||||||
return GUIHelpers::eType::CPANEL;
|
return GUIHelpers::eType::CPANEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*virtual*/ const GUIHelpers::RGBA cPanel::getDebugColour() const
|
/*virtual*/ const GUIHelpers::RGBA& cPanel::getDebugColour() const
|
||||||
{
|
{
|
||||||
return GUIHelpers::RED;
|
return GUIHelpers::RED;
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,7 @@ namespace GUIEngine {
|
|||||||
|
|
||||||
virtual const GUIHelpers::eType getType() const;
|
virtual const GUIHelpers::eType getType() const;
|
||||||
|
|
||||||
virtual const GUIHelpers::RGBA getDebugColour() const;
|
virtual const GUIHelpers::RGBA& getDebugColour() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};/// END CLASS DEFINITION cPanel
|
};/// END CLASS DEFINITION cPanel
|
||||||
|
|||||||
@@ -41,12 +41,12 @@ void cTextButton::setTextSize(const unsigned long int size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
///Gets
|
///Gets
|
||||||
const cString cTextButton::getText() const
|
const cString& cTextButton::getText() const
|
||||||
{
|
{
|
||||||
return m_label.getText();
|
return m_label.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
const GUIHelpers::RGBA cTextButton::getTextColour()
|
const GUIHelpers::RGBA& cTextButton::getTextColour()
|
||||||
{
|
{
|
||||||
return m_label.getFontColour();
|
return m_label.getFontColour();
|
||||||
}
|
}
|
||||||
@@ -61,6 +61,7 @@ const unsigned long int cTextButton::getTextSize()
|
|||||||
return GUIHelpers::eType::CTEXTBUTTON;
|
return GUIHelpers::eType::CTEXTBUTTON;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Private
|
||||||
void CreateLabel()
|
void CreateLabel()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ namespace GUIEngine {
|
|||||||
void setTextSize( const unsigned long int size );
|
void setTextSize( const unsigned long int size );
|
||||||
|
|
||||||
///Gets
|
///Gets
|
||||||
const cString getText() const;
|
const cString& getText() const;
|
||||||
const GUIHelpers::RGBA getTextColour();
|
const GUIHelpers::RGBA& getTextColour();
|
||||||
const unsigned long int getTextSize();
|
const unsigned long int getTextSize();
|
||||||
|
|
||||||
virtual const GUIHelpers::eType getType() const;
|
virtual const GUIHelpers::eType getType() const;
|
||||||
|
|||||||
@@ -449,7 +449,7 @@ cWindow* cWindow::getParent()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*virtual*/ const GUIHelpers::RGBA cWindow::getDebugColour() const
|
/*virtual*/ const GUIHelpers::RGBA& cWindow::getDebugColour() const
|
||||||
{
|
{
|
||||||
return GUIHelpers::WHITE;
|
return GUIHelpers::WHITE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ namespace GUIEngine {
|
|||||||
virtual void RePos();
|
virtual void RePos();
|
||||||
virtual void RebuildPos();
|
virtual void RebuildPos();
|
||||||
|
|
||||||
virtual const GUIHelpers::RGBA getDebugColour() const;
|
virtual const GUIHelpers::RGBA& getDebugColour() const;
|
||||||
|
|
||||||
/*protected:*/
|
/*protected:*/
|
||||||
std::vector<cWindow*>& getChildren();
|
std::vector<cWindow*>& getChildren();
|
||||||
|
|||||||
@@ -7,35 +7,28 @@
|
|||||||
using VideoEngine::cImage;
|
using VideoEngine::cImage;
|
||||||
using UtilityEngine::cUtility;
|
using UtilityEngine::cUtility;
|
||||||
|
|
||||||
cImage::cImage( const cString& filename, const cString& dir /*= ""*/, const bool transparent /*= false*/,
|
cImage::cImage( const bool transparent /*= false*/, const unsigned char red /*= 0*/, const unsigned char blue /*= 0*/, const unsigned char green /*= 255*/,
|
||||||
const unsigned char red /*= 0*/, const unsigned char blue /*= 0*/, const unsigned char green /*= 255*/,
|
|
||||||
const unsigned char translevel /*= 255*/, const bool isSurface /*= false*/ )
|
const unsigned char translevel /*= 255*/, const bool isSurface /*= false*/ )
|
||||||
: mp_texture(nullptr), mp_surface(nullptr), m_dir(dir), m_fileName(filename), m_transparent(transparent),
|
: mp_texture(nullptr), mp_surface(nullptr), m_transparent(transparent),
|
||||||
m_transRed(red), m_transBlue(blue), m_transGreen(green), m_transLevel(translevel), m_isSurface(isSurface)
|
m_transRed(red), m_transBlue(blue), m_transGreen(green), m_transLevel(translevel), m_isSurface(isSurface)
|
||||||
{
|
{}
|
||||||
if (m_fileName != (char*)"")
|
|
||||||
LoadImage();
|
|
||||||
if (mp_texture != nullptr)
|
|
||||||
TransparentSetup();
|
|
||||||
}
|
|
||||||
|
|
||||||
cImage::cImage( SDL_Surface* surface )
|
cImage::cImage( SDL_Surface* surface )
|
||||||
: mp_texture(nullptr), mp_surface(nullptr), m_dir(""), m_fileName(""), m_transparent(false),
|
: mp_texture(nullptr), mp_surface(nullptr), m_transparent(false),
|
||||||
m_transRed(0), m_transBlue(0), m_transGreen(255), m_transLevel(255)
|
m_transRed(0), m_transBlue(0), m_transGreen(255), m_transLevel(255)
|
||||||
{
|
{
|
||||||
setImage(surface);
|
setImage(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
cImage::cImage( SDL_Texture* texture )
|
cImage::cImage( SDL_Texture* texture )
|
||||||
: mp_texture(nullptr), mp_surface(nullptr), m_dir(""), m_fileName(""), m_transparent(false),
|
: mp_texture(nullptr), mp_surface(nullptr), m_transparent(false),
|
||||||
m_transRed(0), m_transBlue(0), m_transGreen(255), m_transLevel(255)
|
m_transRed(0), m_transBlue(0), m_transGreen(255), m_transLevel(255)
|
||||||
{
|
{
|
||||||
setImage(texture);
|
setImage(texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
cImage::cImage( const cImage& copy, const bool surfaceCopy /*= true*/)
|
cImage::cImage( const cImage& copy, const bool surfaceCopy /*= true*/)
|
||||||
: mp_texture(nullptr), mp_surface(nullptr), m_dir(copy.getDir()),
|
: mp_texture(nullptr), mp_surface(nullptr), m_transparent(copy.getTransparent()), m_transRed(copy.getRedTrans()),
|
||||||
m_fileName(copy.getFileName()), m_transparent(copy.getTransparent()), m_transRed(copy.getRedTrans()),
|
|
||||||
m_transBlue(copy.getBlueTrans()), m_transGreen(copy.getGreenTrans()), m_transLevel(copy.getLevelTrans())
|
m_transBlue(copy.getBlueTrans()), m_transGreen(copy.getGreenTrans()), m_transLevel(copy.getLevelTrans())
|
||||||
{
|
{
|
||||||
if (surfaceCopy == true)
|
if (surfaceCopy == true)
|
||||||
@@ -78,23 +71,6 @@ const cImage* cImage::NewImage( SDL_Rect& area ) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
///Sets
|
///Sets
|
||||||
void cImage::setDir( const cString& dir )
|
|
||||||
{
|
|
||||||
m_dir = dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cImage::setFileName( const cString& filename )
|
|
||||||
{
|
|
||||||
m_fileName = filename;
|
|
||||||
LoadImage();
|
|
||||||
}
|
|
||||||
|
|
||||||
void cImage::setFileNameandDir( const cString& filename, const cString& dir /*= ""*/ )
|
|
||||||
{
|
|
||||||
setDir(dir);
|
|
||||||
setFileName(filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cImage::setTransparent( const bool transparent /*= true*/ )
|
void cImage::setTransparent( const bool transparent /*= true*/ )
|
||||||
{
|
{
|
||||||
m_transparent = transparent;
|
m_transparent = transparent;
|
||||||
@@ -117,8 +93,17 @@ void cImage::setLevelTrans( const unsigned char translevel /*= 255*/ )
|
|||||||
///Gets
|
///Gets
|
||||||
SDL_Surface* cImage::getSurface() const
|
SDL_Surface* cImage::getSurface() const
|
||||||
{
|
{
|
||||||
return mp_surface;
|
SDL_Surface* rtn = nullptr;
|
||||||
//return cRenderer::Inst().TextureToSurface(mp_texture);
|
if (m_isSurface == false)
|
||||||
|
rtn = cRenderer::Inst().TextureToSurface(mp_texture);
|
||||||
|
else
|
||||||
|
rtn = mp_surface;
|
||||||
|
return rtn;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_Texture* cImage::getTexture() const
|
||||||
|
{
|
||||||
|
return mp_texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Texture* cImage::getImage() const
|
SDL_Texture* cImage::getImage() const
|
||||||
@@ -165,16 +150,6 @@ void cImage::getWH( unsigned long int& w, unsigned long int& h ) const
|
|||||||
h = height;
|
h = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
const cString cImage::getDir() const
|
|
||||||
{
|
|
||||||
return m_dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
const cString cImage::getFileName() const
|
|
||||||
{
|
|
||||||
return m_fileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
const bool cImage::getTransparent() const
|
const bool cImage::getTransparent() const
|
||||||
{
|
{
|
||||||
return m_transparent;
|
return m_transparent;
|
||||||
@@ -217,9 +192,12 @@ void cImage::setImage( SDL_Surface* surface )
|
|||||||
{
|
{
|
||||||
UnloadImage();
|
UnloadImage();
|
||||||
|
|
||||||
mp_texture = cRenderer::Inst().SurfaceToTexture(surface);
|
if (m_isSurface == false) {
|
||||||
|
mp_texture = cRenderer::Inst().SurfaceToTexture(surface);
|
||||||
SDL_FreeSurface(surface);
|
SDL_FreeSurface(surface);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mp_surface = surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cImage::setImage( SDL_Texture* texture )
|
void cImage::setImage( SDL_Texture* texture )
|
||||||
@@ -232,46 +210,26 @@ void cImage::setImage( SDL_Texture* texture )
|
|||||||
///Functions
|
///Functions
|
||||||
void cImage::TransparentSetup()
|
void cImage::TransparentSetup()
|
||||||
{
|
{
|
||||||
if( (m_transparent == true) && (mp_texture != nullptr) ) {
|
if (m_transparent == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( mp_texture != nullptr ) {
|
||||||
if ((SDL_SetTextureColorMod(mp_texture, m_transRed, m_transGreen, m_transBlue) | SDL_SetTextureAlphaMod(mp_texture, m_transLevel)) < 0)
|
if ((SDL_SetTextureColorMod(mp_texture, m_transRed, m_transGreen, m_transBlue) | SDL_SetTextureAlphaMod(mp_texture, m_transLevel)) < 0)
|
||||||
cUtility::Inst().Message("Unable to set Transparent. SDL_SetTextureColorMod:", __AT__, cUtility::eTypeSDL::SDL);
|
cUtility::Inst().Message("Unable to set Transparent. SDL_SetTextureColorMod:", __AT__, cUtility::eTypeSDL::SDL);
|
||||||
}
|
}
|
||||||
//LoadImage();
|
if ((m_isSurface == true) && (mp_surface != nullptr)) {
|
||||||
}
|
if ((SDL_SetSurfaceColorMod(mp_surface, m_transRed, m_transGreen, m_transBlue) | SDL_SetSurfaceAlphaMod(mp_surface, m_transLevel)) < 0)
|
||||||
|
cUtility::Inst().Message("Unable to set Transparent. SDL_SetSurfaceColorMod:", __AT__, cUtility::eTypeSDL::SDL);
|
||||||
void cImage::LoadImage()
|
|
||||||
{
|
|
||||||
UnloadImage();
|
|
||||||
|
|
||||||
SDL_Texture* tempText = nullptr;
|
|
||||||
SDL_Surface* tempSurface = nullptr;
|
|
||||||
|
|
||||||
if (m_fileName != "")
|
|
||||||
{
|
|
||||||
cString temp = m_dir + m_fileName;
|
|
||||||
|
|
||||||
if (m_isSurface == false) {
|
|
||||||
if ((tempText = IMG_LoadTexture(cRenderer::Inst().getRenderer(), temp.c_str())) == nullptr)
|
|
||||||
cUtility::Inst().Message("Unable to load necessary image file. " + temp + " IMG_LoadTexture():", __AT__, cUtility::eTypeSDL::IMAGE);
|
|
||||||
else
|
|
||||||
mp_texture = tempText;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if ((tempSurface = IMG_Load(temp.c_str())) == nullptr)
|
|
||||||
cUtility::Inst().Message("Unable to load necessary image file. " + temp + " IMG_Load():", __AT__, cUtility::eTypeSDL::IMAGE);
|
|
||||||
else
|
|
||||||
mp_surface = tempSurface;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cImage::UnloadImage()
|
void cImage::UnloadImage()
|
||||||
{
|
{
|
||||||
if (mp_texture != nullptr)
|
if (mp_texture != nullptr)
|
||||||
{
|
|
||||||
SDL_DestroyTexture(mp_texture);
|
SDL_DestroyTexture(mp_texture);
|
||||||
mp_texture = nullptr;
|
if (mp_surface != nullptr)
|
||||||
}
|
SDL_FreeSurface(mp_surface);
|
||||||
|
|
||||||
|
mp_texture = nullptr;
|
||||||
|
mp_surface = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,7 @@ namespace VideoEngine {
|
|||||||
class EXPORT_FROM_MYDLL cImage
|
class EXPORT_FROM_MYDLL cImage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cImage( const cString& filename = "", const cString& dir = "", const bool transparent = false,
|
cImage( const bool transparent = false, const unsigned char red = 0, const unsigned char blue = 0, const unsigned char green = 255,
|
||||||
const unsigned char red = 0, const unsigned char blue = 0, const unsigned char green = 255,
|
|
||||||
const unsigned char translevel = 255, const bool isSurface = false );
|
const unsigned char translevel = 255, const bool isSurface = false );
|
||||||
cImage( SDL_Surface* surface );
|
cImage( SDL_Surface* surface );
|
||||||
cImage( SDL_Texture* texture );
|
cImage( SDL_Texture* texture );
|
||||||
@@ -32,13 +31,6 @@ namespace VideoEngine {
|
|||||||
const cImage* NewImage( SDL_Rect& area ) const;
|
const cImage* NewImage( SDL_Rect& area ) const;
|
||||||
|
|
||||||
///Sets
|
///Sets
|
||||||
/* Sets the Directory of the image */
|
|
||||||
void setDir( const cString& dir );
|
|
||||||
/* Sets the File Name of the image */
|
|
||||||
void setFileName( const cString& filename );
|
|
||||||
/* Sets the File Name and the Directory of the image */
|
|
||||||
void setFileNameandDir( const cString& filename, const cString& dir = "" );
|
|
||||||
|
|
||||||
/* Sets Transparent on if set to true */
|
/* Sets Transparent on if set to true */
|
||||||
void setTransparent( const bool transparent = true );
|
void setTransparent( const bool transparent = true );
|
||||||
/* Sets the colour to be made transparent */
|
/* Sets the colour to be made transparent */
|
||||||
@@ -50,6 +42,8 @@ namespace VideoEngine {
|
|||||||
/* Gets a pointer to the SDL_Surface */
|
/* Gets a pointer to the SDL_Surface */
|
||||||
SDL_Surface* getSurface() const;
|
SDL_Surface* getSurface() const;
|
||||||
/* Gets a pointer to the SDL_Texture */
|
/* Gets a pointer to the SDL_Texture */
|
||||||
|
SDL_Texture* getTexture() const;
|
||||||
|
/* Gets a pointer to the SDL_Texture */
|
||||||
SDL_Texture* getImage() const;
|
SDL_Texture* getImage() const;
|
||||||
/* Gets the width of the image */
|
/* Gets the width of the image */
|
||||||
const unsigned long int getWidth() const;
|
const unsigned long int getWidth() const;
|
||||||
@@ -60,11 +54,6 @@ namespace VideoEngine {
|
|||||||
/* Gets the Width and Height of the image */
|
/* Gets the Width and Height of the image */
|
||||||
void getWH( unsigned long int& w, unsigned long int& h ) const;
|
void getWH( unsigned long int& w, unsigned long int& h ) const;
|
||||||
|
|
||||||
/* Gets the Directory of the image */
|
|
||||||
const cString getDir() const;
|
|
||||||
/* Gets the File Name of the image */
|
|
||||||
const cString getFileName() const;
|
|
||||||
|
|
||||||
/* Gets return true if transparent on false if off */
|
/* Gets return true if transparent on false if off */
|
||||||
const bool getTransparent() const;
|
const bool getTransparent() const;
|
||||||
/* Gets return the colour to be made transparent */
|
/* Gets return the colour to be made transparent */
|
||||||
@@ -89,7 +78,6 @@ namespace VideoEngine {
|
|||||||
private:
|
private:
|
||||||
///Functions
|
///Functions
|
||||||
void TransparentSetup();
|
void TransparentSetup();
|
||||||
virtual void LoadImage(); //cFont over rides this
|
|
||||||
void UnloadImage();
|
void UnloadImage();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -97,12 +85,6 @@ namespace VideoEngine {
|
|||||||
SDL_Texture* mp_texture;// = nullptr
|
SDL_Texture* mp_texture;// = nullptr
|
||||||
SDL_Surface* mp_surface;// = nullptr
|
SDL_Surface* mp_surface;// = nullptr
|
||||||
|
|
||||||
cString m_dir;// = ""
|
|
||||||
cString m_fileName;// = ""
|
|
||||||
|
|
||||||
//char m_dir[255];
|
|
||||||
//char m_fileName[255];
|
|
||||||
|
|
||||||
bool m_transparent;// = false
|
bool m_transparent;// = false
|
||||||
|
|
||||||
unsigned char m_transRed;// = 0
|
unsigned char m_transRed;// = 0
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
#include "cImageFile.hpp"
|
||||||
|
|
||||||
|
/*** Custom Header Files ***/
|
||||||
|
#include "cRenderer.hpp"
|
||||||
|
#include "../UtilityEngine/cUtility.hpp"
|
||||||
|
|
||||||
|
using VideoEngine::cImageFile;
|
||||||
|
using UtilityEngine::cUtility;
|
||||||
|
|
||||||
|
cImageFile::cImageFile(const cString& filename, const cString& dir /*= ""*/, const bool transparent /*= false*/,
|
||||||
|
const unsigned char red /*= 0*/, const unsigned char blue /*= 0*/, const unsigned char green /*= 255*/,
|
||||||
|
const unsigned char translevel /*= 255*/, const bool isSurface /*= false*/)
|
||||||
|
: cImage(transparent, red, blue, green, translevel, isSurface), m_dir(dir), m_fileName(filename)
|
||||||
|
{
|
||||||
|
if (m_fileName != (char*)"")
|
||||||
|
LoadImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
cImageFile::cImageFile(const cImageFile& copy, const bool surfaceCopy /*= true*/)
|
||||||
|
: cImage(copy)
|
||||||
|
{}
|
||||||
|
|
||||||
|
cImageFile::~cImageFile()
|
||||||
|
{}
|
||||||
|
|
||||||
|
///Sets
|
||||||
|
void cImageFile::setDir(const cString& dir)
|
||||||
|
{
|
||||||
|
m_dir = dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cImageFile::setFileName(const cString& filename)
|
||||||
|
{
|
||||||
|
m_fileName = filename;
|
||||||
|
LoadImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
void cImageFile::setFileNameandDir(const cString& filename, const cString& dir /*= ""*/)
|
||||||
|
{
|
||||||
|
setDir(dir);
|
||||||
|
setFileName(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
const cString& cImageFile::getDir() const
|
||||||
|
{
|
||||||
|
return m_dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
const cString& cImageFile::getFileName() const
|
||||||
|
{
|
||||||
|
return m_fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
///private
|
||||||
|
///Functions
|
||||||
|
void cImageFile::LoadImage()
|
||||||
|
{
|
||||||
|
SDL_Texture* tempText = nullptr;
|
||||||
|
SDL_Surface* tempSurface = nullptr;
|
||||||
|
|
||||||
|
if (m_fileName != "")
|
||||||
|
{
|
||||||
|
cString temp = m_dir + m_fileName;
|
||||||
|
|
||||||
|
if (this->getIsSurface() == false) {
|
||||||
|
if ((tempText = IMG_LoadTexture(cRenderer::Inst().getRenderer(), temp.c_str())) == nullptr)
|
||||||
|
cUtility::Inst().Message("Unable to load necessary image file. " + temp + " IMG_LoadTexture():", __AT__, cUtility::eTypeSDL::IMAGE);
|
||||||
|
else
|
||||||
|
this->setImage(tempText);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ((tempSurface = IMG_Load(temp.c_str())) == nullptr)
|
||||||
|
cUtility::Inst().Message("Unable to load necessary image file. " + temp + " IMG_Load():", __AT__, cUtility::eTypeSDL::IMAGE);
|
||||||
|
else
|
||||||
|
this->setImage(tempSurface);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
#ifndef _CIMAGEFILE_HPP_
|
||||||
|
#define _CIMAGEFILE_HPP_
|
||||||
|
|
||||||
|
/*** SDL Header Files ***/
|
||||||
|
#include <SDL.h>
|
||||||
|
#include <SDL_image.h>
|
||||||
|
|
||||||
|
/*** DLL Header File ***/
|
||||||
|
#include "dllExport.h"
|
||||||
|
|
||||||
|
/*** Custom Header Files ***/
|
||||||
|
#include "cImage.hpp"
|
||||||
|
#include "../UtilityEngine/cString.hpp"
|
||||||
|
|
||||||
|
using UtilityEngine::cString;
|
||||||
|
|
||||||
|
namespace VideoEngine {
|
||||||
|
class EXPORT_FROM_MYDLL cImageFile : public cImage
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cImageFile(const cString& filename = "", const cString& dir = "", const bool transparent = false,
|
||||||
|
const unsigned char red = 0, const unsigned char blue = 0, const unsigned char green = 255,
|
||||||
|
const unsigned char translevel = 255, const bool isSurface = false);
|
||||||
|
/* Copy constructor */
|
||||||
|
cImageFile(const cImageFile& copy, const bool surfaceCopy = true);
|
||||||
|
~cImageFile();
|
||||||
|
|
||||||
|
///Sets
|
||||||
|
/* Sets the Directory of the image */
|
||||||
|
void setDir(const cString& dir);
|
||||||
|
/* Sets the File Name of the image */
|
||||||
|
void setFileName(const cString& filename);
|
||||||
|
/* Sets the File Name and the Directory of the image */
|
||||||
|
void setFileNameandDir(const cString& filename, const cString& dir = "");
|
||||||
|
|
||||||
|
///Gets
|
||||||
|
/* Gets the Directory of the image */
|
||||||
|
const cString& getDir() const;
|
||||||
|
/* Gets the File Name of the image */
|
||||||
|
const cString& getFileName() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
///Functions
|
||||||
|
void LoadImage();
|
||||||
|
|
||||||
|
private:
|
||||||
|
///Variables
|
||||||
|
cString m_dir;// = ""
|
||||||
|
cString m_fileName;// = ""
|
||||||
|
};/// END CLASS DEFINITION cImageFile
|
||||||
|
}/// END NAMESPACE DEFINITION VideoEngine
|
||||||
|
#endif/// END IFNDEF _CIMAGEFILE_HPP_
|
||||||
@@ -12,6 +12,7 @@ using UtilityEngine::cUtility;
|
|||||||
|
|
||||||
//private:
|
//private:
|
||||||
cRenderer::cRenderer()
|
cRenderer::cRenderer()
|
||||||
|
: mp_renderer(nullptr), mp_rendererSoftware(nullptr)
|
||||||
{
|
{
|
||||||
Setup();
|
Setup();
|
||||||
}
|
}
|
||||||
@@ -42,7 +43,11 @@ const bool cRenderer::Setup()
|
|||||||
if (cVideo::Inst().IsInit() == false)
|
if (cVideo::Inst().IsInit() == false)
|
||||||
cUtility::Inst().Message("Unable to setup until SDL_Video is initialized.");
|
cUtility::Inst().Message("Unable to setup until SDL_Video is initialized.");
|
||||||
else {
|
else {
|
||||||
|
CleanUp();
|
||||||
mp_renderer = cVideo::Inst().CreateRender();
|
mp_renderer = cVideo::Inst().CreateRender();
|
||||||
|
SDL_Surface* surface = SDL_GetWindowSurface(cVideo::Inst().getWindow());
|
||||||
|
mp_rendererSoftware = SDL_CreateSoftwareRenderer(surface);
|
||||||
|
//mp_rendererCopy = cVideo::Inst().CreateRender();
|
||||||
if (mp_renderer != nullptr)
|
if (mp_renderer != nullptr)
|
||||||
rtn = true;
|
rtn = true;
|
||||||
}
|
}
|
||||||
@@ -51,8 +56,13 @@ const bool cRenderer::Setup()
|
|||||||
|
|
||||||
void cRenderer::CleanUp()
|
void cRenderer::CleanUp()
|
||||||
{
|
{
|
||||||
SDL_DestroyRenderer(mp_renderer);
|
if (mp_renderer != nullptr)
|
||||||
|
SDL_DestroyRenderer(mp_renderer);
|
||||||
|
if (mp_rendererSoftware != nullptr)
|
||||||
|
SDL_DestroyRenderer(mp_rendererSoftware);
|
||||||
|
|
||||||
mp_renderer = nullptr;
|
mp_renderer = nullptr;
|
||||||
|
mp_rendererSoftware = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cRenderer::Render( SDL_Texture* texture, SDL_Rect* srcrect, SDL_Rect* dstrect )
|
void cRenderer::Render( SDL_Texture* texture, SDL_Rect* srcrect, SDL_Rect* dstrect )
|
||||||
@@ -111,24 +121,12 @@ void cRenderer::RenderDrawRect( const SDL_Rect& rect, SDL_Texture* dst /*= nullp
|
|||||||
|
|
||||||
void cRenderer::ScreenShot( const cString& filename, const cString& dir /*= ""*/ )
|
void cRenderer::ScreenShot( const cString& filename, const cString& dir /*= ""*/ )
|
||||||
{
|
{
|
||||||
SDL_Surface* infoSurface = SDL_GetWindowSurface(VideoEngine::cVideo::Inst().getWindow());
|
SDL_Surface *sshot = NewSurface();
|
||||||
SDL_Surface* saveSurface = NewSurface();
|
SDL_RenderReadPixels(getRenderer(), nullptr, SDL_PIXELFORMAT_RGBA32, sshot->pixels, sshot->pitch);
|
||||||
|
SaveSurface(sshot, filename, dir);
|
||||||
if (infoSurface == nullptr) {
|
SDL_FreeSurface(sshot);
|
||||||
cUtility::Inst().Message("Failed to create info surface from window.\n", __AT__, cUtility::eTypeSDL::SDL);
|
|
||||||
} else {
|
|
||||||
if (SDL_RenderReadPixels(mp_renderer, &infoSurface->clip_rect, infoSurface->format->format, saveSurface->pixels, infoSurface->w * infoSurface->format->BytesPerPixel) != 0)
|
|
||||||
cUtility::Inst().Message("Failed to read pixel data from SDL_Renderer object.\n", __AT__, cUtility::eTypeSDL::SDL);
|
|
||||||
else
|
|
||||||
SaveSurface(saveSurface, filename, dir);
|
|
||||||
SDL_FreeSurface(infoSurface);
|
|
||||||
infoSurface = nullptr;
|
|
||||||
}
|
|
||||||
SDL_FreeSurface(saveSurface);
|
|
||||||
saveSurface = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void cRenderer::SaveSurface( SDL_Surface* surface, const cString& fileName, const cString& dir /*= ""*/ )
|
void cRenderer::SaveSurface( SDL_Surface* surface, const cString& fileName, const cString& dir /*= ""*/ )
|
||||||
{
|
{
|
||||||
cString temp = dir + fileName;
|
cString temp = dir + fileName;
|
||||||
@@ -169,57 +167,27 @@ SDL_Surface* cRenderer::TextureToSurface( SDL_Texture* texture )
|
|||||||
|
|
||||||
rtn = NewSurface(w, h);
|
rtn = NewSurface(w, h);
|
||||||
|
|
||||||
void* srcPixels = nullptr;
|
SDL_Rect rec = { 0, 0, w, h };
|
||||||
int srcPitch = 0;
|
|
||||||
|
|
||||||
//Lock texture for manipulation
|
SDL_Texture* tmp_texture = NewTexture(w, h, true); // Create a new texture with Software Renderer
|
||||||
if (SDL_LockTexture( texture, nullptr, &srcPixels, &srcPitch ) < 0)
|
CopyTexture(texture, tmp_texture, true); // Copy old texture to the Software Renderer Texture renderer
|
||||||
cUtility::Inst().Message("Unable to lock texture. SDL_LockTexture():", __AT__, cUtility::eTypeSDL::SDL);
|
|
||||||
|
|
||||||
if (SDL_LockSurface(rtn))
|
Render(tmp_texture, nullptr, mp_rendererSoftware, &rec); // Render to the mp_rendererSoftware
|
||||||
cUtility::Inst().Message("Unable to lock surface rtn. SDL_LockSurface():", __AT__, cUtility::eTypeSDL::SDL);
|
|
||||||
|
|
||||||
//Copy loaded/formatted surface pixels
|
SDL_RenderReadPixels(mp_rendererSoftware, nullptr, SDL_PIXELFORMAT_RGBA32, rtn->pixels, rtn->pitch);
|
||||||
memcpy( rtn->pixels, srcPixels, srcPitch * h );
|
|
||||||
|
|
||||||
//Unlock texture to update
|
|
||||||
SDL_UnlockSurface(rtn);
|
|
||||||
SDL_UnlockTexture( texture );
|
|
||||||
|
|
||||||
srcPixels = nullptr;
|
|
||||||
|
|
||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cRenderer::CopyTexture( SDL_Texture* src, SDL_Texture* dst )
|
void cRenderer::CopyTexture( SDL_Texture* src, SDL_Texture* dst, bool software /*= false*/ )
|
||||||
{
|
{
|
||||||
void* srcPixels = nullptr;
|
SDL_Renderer* render = mp_renderer;
|
||||||
int srcPitch = 0;
|
if (software == true)
|
||||||
|
render = mp_rendererSoftware;
|
||||||
void* dstPixels = nullptr;
|
if (SDL_SetRenderTarget(render, dst) < 0)
|
||||||
int dstPitch = 0;
|
cUtility::Inst().Message("Unable to set render target to dst. SDL_SetRenderTarget():", __AT__, cUtility::eTypeSDL::SDL);
|
||||||
|
Render(src, nullptr, render, nullptr);
|
||||||
int height = 0;
|
ResetRenderTarget();
|
||||||
|
|
||||||
if (SDL_QueryTexture( src, nullptr, nullptr, nullptr, &height ) < 0)
|
|
||||||
cUtility::Inst().Message("Unable to query texture. SDL_QueryTexture():", __AT__, cUtility::eTypeSDL::SDL);
|
|
||||||
|
|
||||||
//Lock texture for manipulation
|
|
||||||
if (SDL_LockTexture( src, nullptr, &srcPixels, &srcPitch ) < 0)
|
|
||||||
cUtility::Inst().Message("Unable to lock texture src. SDL_LockTexture():", __AT__, cUtility::eTypeSDL::SDL);
|
|
||||||
|
|
||||||
if (SDL_LockTexture( dst, nullptr, &dstPixels, &dstPitch ) < 0)
|
|
||||||
cUtility::Inst().Message("Unable to lock texture dst. SDL_LockTexture():", __AT__, cUtility::eTypeSDL::SDL);
|
|
||||||
|
|
||||||
//Copy loaded/formatted surface pixels
|
|
||||||
memcpy( dstPixels, srcPixels, srcPitch * height );
|
|
||||||
|
|
||||||
//Unlock texture to update
|
|
||||||
SDL_UnlockTexture( dst );
|
|
||||||
SDL_UnlockTexture( src );
|
|
||||||
srcPixels = nullptr;
|
|
||||||
dstPixels = nullptr;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Surface* cRenderer::CopySurface( SDL_Surface* src )
|
SDL_Surface* cRenderer::CopySurface( SDL_Surface* src )
|
||||||
@@ -242,19 +210,72 @@ SDL_Surface* cRenderer::NewSurface( long int width /*= -1*/, long int height /*=
|
|||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Texture* cRenderer::NewTexture( long int width, long int height, const unsigned long int access /*= SDL_TEXTUREACCESS_TARGET*/ ) const
|
SDL_Texture* cRenderer::NewTexture( long int width, long int height, const bool copyRenderer /*= false*/, const unsigned long int access /*= SDL_TEXTUREACCESS_TARGET*/ ) const
|
||||||
{
|
{
|
||||||
if (width < 0)
|
if (width < 0)
|
||||||
width = cVideo::Inst().getWidth();
|
width = cVideo::Inst().getWidth();
|
||||||
if (height < 0)
|
if (height < 0)
|
||||||
height = cVideo::Inst().getHeight();
|
height = cVideo::Inst().getHeight();
|
||||||
|
|
||||||
SDL_Texture* rtn = SDL_CreateTexture(mp_renderer, SDL_PIXELFORMAT_ABGR8888, access, width, height);
|
SDL_Renderer* renderer = nullptr;
|
||||||
|
if (copyRenderer == false)
|
||||||
|
renderer = mp_renderer;
|
||||||
|
else
|
||||||
|
renderer = mp_rendererSoftware;
|
||||||
|
|
||||||
|
SDL_Texture* rtn = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ABGR8888, access, width, height);
|
||||||
if (rtn == nullptr)
|
if (rtn == nullptr)
|
||||||
cUtility::Inst().Message("Unable to create texture. SDL_CreateTexture:", __AT__, cUtility::eTypeSDL::SDL);
|
cUtility::Inst().Message("Unable to create texture. SDL_CreateTexture:", __AT__, cUtility::eTypeSDL::SDL);
|
||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bool cRenderer::AreEqual(SDL_Surface& one, SDL_Surface& two)
|
||||||
|
{
|
||||||
|
bool rtn = false;
|
||||||
|
|
||||||
|
int x = 0;
|
||||||
|
int y = 0;
|
||||||
|
|
||||||
|
if (SDL_MUSTLOCK(&one) > 0)
|
||||||
|
SDL_LockSurface(&one);
|
||||||
|
|
||||||
|
if (SDL_MUSTLOCK(&two) > 0)
|
||||||
|
SDL_LockSurface(&two);
|
||||||
|
|
||||||
|
if ((one.pitch == two.pitch) && (one.h == two.h)) {
|
||||||
|
unsigned char *one_pixels = (unsigned char *)one.pixels;
|
||||||
|
unsigned char *two_pixels = (unsigned char *)two.pixels;
|
||||||
|
|
||||||
|
rtn = true; // we are equal so far....
|
||||||
|
|
||||||
|
for (x = 0; x < one.pitch; x++) {
|
||||||
|
for (y = 0; y < one.h; y++) {
|
||||||
|
if (one_pixels[y + x] != two_pixels[y + x]) {
|
||||||
|
rtn = false;
|
||||||
|
x = one.pitch + two.pitch + 1; // break out of the top for loop
|
||||||
|
y = one.h + two.h + 1;
|
||||||
|
break; // we found a pixel that is not equal no need to continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SDL_MUSTLOCK(&one) > 0)
|
||||||
|
SDL_UnlockSurface(&one);
|
||||||
|
|
||||||
|
if (SDL_MUSTLOCK(&two) > 0)
|
||||||
|
SDL_UnlockSurface(&two);
|
||||||
|
|
||||||
|
|
||||||
|
return rtn;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cRenderer::SetRenderTarget(SDL_Renderer* renderer, SDL_Texture* target /*= nullptr*/)
|
||||||
|
{
|
||||||
|
if (SDL_SetRenderTarget(renderer, target) < 0)
|
||||||
|
cUtility::Inst().Message("Unable to set render target to dst. SDL_SetRenderTarget():", __AT__, cUtility::eTypeSDL::SDL);
|
||||||
|
}
|
||||||
|
|
||||||
void cRenderer::SetRenderTarget( SDL_Texture* target /*= nullptr*/ )
|
void cRenderer::SetRenderTarget( SDL_Texture* target /*= nullptr*/ )
|
||||||
{
|
{
|
||||||
if (SDL_SetRenderTarget(mp_renderer, target) < 0)
|
if (SDL_SetRenderTarget(mp_renderer, target) < 0)
|
||||||
@@ -271,3 +292,8 @@ SDL_Renderer* cRenderer::getRenderer()
|
|||||||
{
|
{
|
||||||
return mp_renderer;
|
return mp_renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_Renderer* cRenderer::getRendererCopy()
|
||||||
|
{
|
||||||
|
return mp_rendererSoftware;
|
||||||
|
}
|
||||||
@@ -47,23 +47,28 @@ namespace VideoEngine {
|
|||||||
SDL_Texture* SurfaceToTexture( SDL_Surface* surface );
|
SDL_Texture* SurfaceToTexture( SDL_Surface* surface );
|
||||||
SDL_Surface* TextureToSurface( SDL_Texture* texture );
|
SDL_Surface* TextureToSurface( SDL_Texture* texture );
|
||||||
|
|
||||||
void CopyTexture( SDL_Texture* src, SDL_Texture* dst );
|
void CopyTexture( SDL_Texture* src, SDL_Texture* dst, bool software = false);
|
||||||
|
|
||||||
SDL_Surface* CopySurface( SDL_Surface* src );
|
SDL_Surface* CopySurface( SDL_Surface* src );
|
||||||
|
|
||||||
SDL_Surface* NewSurface( long int width = -1, long int height = -1 ) const;
|
SDL_Surface* NewSurface( long int width = -1, long int height = -1 ) const;
|
||||||
SDL_Texture* NewTexture( long int width = -1, long int height = -1, const unsigned long int access = SDL_TEXTUREACCESS_TARGET ) const;
|
SDL_Texture* NewTexture( long int width = -1, long int height = -1, const bool copyRenderer = false, const unsigned long int access = SDL_TEXTUREACCESS_TARGET ) const;
|
||||||
|
|
||||||
void SetRenderTarget( SDL_Texture* target = nullptr );
|
const bool AreEqual(SDL_Surface& one, SDL_Surface& two);
|
||||||
|
|
||||||
|
void SetRenderTarget(SDL_Renderer* renderer, SDL_Texture* target = nullptr);
|
||||||
|
void SetRenderTarget(SDL_Texture* target = nullptr);
|
||||||
void ResetRenderTarget();
|
void ResetRenderTarget();
|
||||||
|
|
||||||
///Sets
|
///Sets
|
||||||
|
|
||||||
///Gets
|
///Gets
|
||||||
SDL_Renderer* getRenderer();
|
SDL_Renderer* getRenderer();
|
||||||
|
SDL_Renderer* getRendererCopy();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SDL_Renderer* mp_renderer;
|
SDL_Renderer* mp_renderer;
|
||||||
|
SDL_Renderer* mp_rendererSoftware;
|
||||||
|
|
||||||
static cRenderer* sp_inst;// = nullptr
|
static cRenderer* sp_inst;// = nullptr
|
||||||
};/// END CLASS DEFINITION cRenderer
|
};/// END CLASS DEFINITION cRenderer
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ const bool cVideo::Setup()
|
|||||||
CleanUp();
|
CleanUp();
|
||||||
VideoSettings();
|
VideoSettings();
|
||||||
|
|
||||||
mp_window = SDL_CreateWindow("Hello World!", 100, 100, m_width, m_height, SDL_WINDOW_SHOWN);
|
mp_window = SDL_CreateWindow("Hello World!", m_xPos, m_yPos, m_width, m_height, SDL_WINDOW_SHOWN);
|
||||||
if (mp_window == nullptr)
|
if (mp_window == nullptr)
|
||||||
cUtility::Inst().Message("Unable to set Window. SDL_CreateWindow():", __AT__, cUtility::eTypeSDL::SDL);
|
cUtility::Inst().Message("Unable to set Window. SDL_CreateWindow():", __AT__, cUtility::eTypeSDL::SDL);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -162,6 +162,7 @@
|
|||||||
<ClInclude Include="TrooperEngine\VideoEngine\cAnimatedSprite.hpp" />
|
<ClInclude Include="TrooperEngine\VideoEngine\cAnimatedSprite.hpp" />
|
||||||
<ClInclude Include="TrooperEngine\VideoEngine\cCamera.hpp" />
|
<ClInclude Include="TrooperEngine\VideoEngine\cCamera.hpp" />
|
||||||
<ClInclude Include="TrooperEngine\VideoEngine\cImage.hpp" />
|
<ClInclude Include="TrooperEngine\VideoEngine\cImage.hpp" />
|
||||||
|
<ClInclude Include="TrooperEngine\VideoEngine\cImageFile.hpp" />
|
||||||
<ClInclude Include="TrooperEngine\VideoEngine\cRenderer.hpp" />
|
<ClInclude Include="TrooperEngine\VideoEngine\cRenderer.hpp" />
|
||||||
<ClInclude Include="TrooperEngine\VideoEngine\cSprite.hpp" />
|
<ClInclude Include="TrooperEngine\VideoEngine\cSprite.hpp" />
|
||||||
<ClInclude Include="TrooperEngine\VideoEngine\cVideo.hpp" />
|
<ClInclude Include="TrooperEngine\VideoEngine\cVideo.hpp" />
|
||||||
@@ -212,6 +213,7 @@
|
|||||||
<ClCompile Include="TrooperEngine\VideoEngine\cAnimatedSprite.cpp" />
|
<ClCompile Include="TrooperEngine\VideoEngine\cAnimatedSprite.cpp" />
|
||||||
<ClCompile Include="TrooperEngine\VideoEngine\cCamera.cpp" />
|
<ClCompile Include="TrooperEngine\VideoEngine\cCamera.cpp" />
|
||||||
<ClCompile Include="TrooperEngine\VideoEngine\cImage.cpp" />
|
<ClCompile Include="TrooperEngine\VideoEngine\cImage.cpp" />
|
||||||
|
<ClCompile Include="TrooperEngine\VideoEngine\cImageFile.cpp" />
|
||||||
<ClCompile Include="TrooperEngine\VideoEngine\cRenderer.cpp" />
|
<ClCompile Include="TrooperEngine\VideoEngine\cRenderer.cpp" />
|
||||||
<ClCompile Include="TrooperEngine\VideoEngine\cSprite.cpp" />
|
<ClCompile Include="TrooperEngine\VideoEngine\cSprite.cpp" />
|
||||||
<ClCompile Include="TrooperEngine\VideoEngine\cVideo.cpp" />
|
<ClCompile Include="TrooperEngine\VideoEngine\cVideo.cpp" />
|
||||||
|
|||||||
@@ -55,6 +55,9 @@
|
|||||||
<Filter Include="TrooperEngine\UtilityEngine\MSUNIX">
|
<Filter Include="TrooperEngine\UtilityEngine\MSUNIX">
|
||||||
<UniqueIdentifier>{f6fc613b-8e1a-4df1-aee7-f37382d38981}</UniqueIdentifier>
|
<UniqueIdentifier>{f6fc613b-8e1a-4df1-aee7-f37382d38981}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="TrooperEngine\TextTypeEngine\TextTypeHelpers">
|
||||||
|
<UniqueIdentifier>{b13cf78d-bfda-4467-9cdc-79dcb63fd8a9}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="dllExportFiles\dllExport.h">
|
<ClInclude Include="dllExportFiles\dllExport.h">
|
||||||
@@ -180,9 +183,6 @@
|
|||||||
<ClInclude Include="TrooperEngine\VideoEngine\cRenderer.hpp">
|
<ClInclude Include="TrooperEngine\VideoEngine\cRenderer.hpp">
|
||||||
<Filter>TrooperEngine\VideoEngine</Filter>
|
<Filter>TrooperEngine\VideoEngine</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="TrooperEngine\TextTypeEngine\TextTypeHelpers\cFontHolder.hpp">
|
|
||||||
<Filter>TrooperEngine\TextTypeEngine</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="TrooperEngine\UtilityEngine\cString.hpp">
|
<ClInclude Include="TrooperEngine\UtilityEngine\cString.hpp">
|
||||||
<Filter>TrooperEngine\UtilityEngine</Filter>
|
<Filter>TrooperEngine\UtilityEngine</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@@ -213,6 +213,12 @@
|
|||||||
<ClInclude Include="TrooperEngine\EventEngine\cEventControl.hpp">
|
<ClInclude Include="TrooperEngine\EventEngine\cEventControl.hpp">
|
||||||
<Filter>TrooperEngine\EventEngine</Filter>
|
<Filter>TrooperEngine\EventEngine</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="TrooperEngine\VideoEngine\cImageFile.hpp">
|
||||||
|
<Filter>TrooperEngine\VideoEngine</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="TrooperEngine\TextTypeEngine\TextTypeHelpers\cFontHolder.hpp">
|
||||||
|
<Filter>TrooperEngine\TextTypeEngine\TextTypeHelpers</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="TrooperEngine\AudioEngine\cAudio.cpp">
|
<ClCompile Include="TrooperEngine\AudioEngine\cAudio.cpp">
|
||||||
@@ -320,9 +326,6 @@
|
|||||||
<ClCompile Include="TrooperEngine\VideoEngine\cRenderer.cpp">
|
<ClCompile Include="TrooperEngine\VideoEngine\cRenderer.cpp">
|
||||||
<Filter>TrooperEngine\VideoEngine</Filter>
|
<Filter>TrooperEngine\VideoEngine</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="TrooperEngine\TextTypeEngine\TextTypeHelpers\cFontHolder.cpp">
|
|
||||||
<Filter>TrooperEngine\TextTypeEngine</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="TrooperEngine\GUIEngine\GUIHelpers\GUIUtility.cpp">
|
<ClCompile Include="TrooperEngine\GUIEngine\GUIHelpers\GUIUtility.cpp">
|
||||||
<Filter>TrooperEngine\GUIEngine\GUIHelpers</Filter>
|
<Filter>TrooperEngine\GUIEngine\GUIHelpers</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@@ -359,5 +362,11 @@
|
|||||||
<ClCompile Include="TrooperEngine\EventEngine\cEventControl.cpp">
|
<ClCompile Include="TrooperEngine\EventEngine\cEventControl.cpp">
|
||||||
<Filter>TrooperEngine\EventEngine</Filter>
|
<Filter>TrooperEngine\EventEngine</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="TrooperEngine\VideoEngine\cImageFile.cpp">
|
||||||
|
<Filter>TrooperEngine\VideoEngine</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="TrooperEngine\TextTypeEngine\TextTypeHelpers\cFontHolder.cpp">
|
||||||
|
<Filter>TrooperEngine\TextTypeEngine\TextTypeHelpers</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
#include "../TrooperEngine/VideoEngine/cSprite.hpp"
|
#include "../TrooperEngine/VideoEngine/cSprite.hpp"
|
||||||
#include "../TrooperEngine/VideoEngine/cAnimatedSprite.hpp"
|
#include "../TrooperEngine/VideoEngine/cAnimatedSprite.hpp"
|
||||||
#include "../TrooperEngine/VideoEngine/cImage.hpp"
|
#include "../TrooperEngine/VideoEngine/cImage.hpp"
|
||||||
|
#include "../TrooperEngine/VideoEngine/cImageFile.hpp"
|
||||||
#include "../TrooperEngine/VideoEngine/cCamera.hpp"
|
#include "../TrooperEngine/VideoEngine/cCamera.hpp"
|
||||||
|
|
||||||
/*** AudioEngine Folder ***/
|
/*** AudioEngine Folder ***/
|
||||||
@@ -55,6 +56,9 @@
|
|||||||
#include "../TrooperEngine/TextTypeEngine/cFont.hpp"
|
#include "../TrooperEngine/TextTypeEngine/cFont.hpp"
|
||||||
#include "../TrooperEngine/TextTypeEngine/cText.hpp"
|
#include "../TrooperEngine/TextTypeEngine/cText.hpp"
|
||||||
|
|
||||||
|
/*** TextTypeHelpers ***/
|
||||||
|
#include "../TrooperEngine/TextTypeEngine/TextTypeHelpers/cFontHolder.hpp"
|
||||||
|
|
||||||
/*** EventEngine ***/
|
/*** EventEngine ***/
|
||||||
#include "../TrooperEngine/EventEngine/cEventControl.hpp"
|
#include "../TrooperEngine/EventEngine/cEventControl.hpp"
|
||||||
#include "../TrooperEngine/EventEngine/cEvent.hpp"
|
#include "../TrooperEngine/EventEngine/cEvent.hpp"
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 600 KiB |
@@ -150,8 +150,9 @@
|
|||||||
<ClCompile Include="main.cpp" />
|
<ClCompile Include="main.cpp" />
|
||||||
<ClCompile Include="UTest\UTest.cpp" />
|
<ClCompile Include="UTest\UTest.cpp" />
|
||||||
<ClCompile Include="UtilityEngineTest\StringTest.cpp" />
|
<ClCompile Include="UtilityEngineTest\StringTest.cpp" />
|
||||||
<ClCompile Include="VideoEngineTest\ImageTest.cpp" />
|
<ClCompile Include="VideoEngineTest\ImageFileTest.cpp" />
|
||||||
<ClCompile Include="VideoEngineTest\RendererTest.cpp" />
|
<ClCompile Include="VideoEngineTest\RendererTest.cpp" />
|
||||||
|
<ClCompile Include="VideoEngineTest\VideoEngineTest.cpp" />
|
||||||
<ClCompile Include="VideoEngineTest\VideoTest.cpp" />
|
<ClCompile Include="VideoEngineTest\VideoTest.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -159,8 +160,9 @@
|
|||||||
<ClInclude Include="GUIEngineTest\GUIXMLTest.hpp" />
|
<ClInclude Include="GUIEngineTest\GUIXMLTest.hpp" />
|
||||||
<ClInclude Include="UTest\UTest.hpp" />
|
<ClInclude Include="UTest\UTest.hpp" />
|
||||||
<ClInclude Include="UtilityEngineTest\StringTest.hpp" />
|
<ClInclude Include="UtilityEngineTest\StringTest.hpp" />
|
||||||
<ClInclude Include="VideoEngineTest\ImageTest.hpp" />
|
<ClInclude Include="VideoEngineTest\ImageFileTest.hpp" />
|
||||||
<ClInclude Include="VideoEngineTest\RendererTest.hpp" />
|
<ClInclude Include="VideoEngineTest\RendererTest.hpp" />
|
||||||
|
<ClInclude Include="VideoEngineTest\VideoEngineTest.hpp" />
|
||||||
<ClInclude Include="VideoEngineTest\VideoTest.hpp" />
|
<ClInclude Include="VideoEngineTest\VideoTest.hpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -39,7 +39,10 @@
|
|||||||
<ClInclude Include="VideoEngineTest\VideoTest.hpp">
|
<ClInclude Include="VideoEngineTest\VideoTest.hpp">
|
||||||
<Filter>VideoEngineTest</Filter>
|
<Filter>VideoEngineTest</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="VideoEngineTest\ImageTest.hpp">
|
<ClInclude Include="VideoEngineTest\ImageFileTest.hpp">
|
||||||
|
<Filter>VideoEngineTest</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="VideoEngineTest\VideoEngineTest.hpp">
|
||||||
<Filter>VideoEngineTest</Filter>
|
<Filter>VideoEngineTest</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -63,7 +66,10 @@
|
|||||||
<ClCompile Include="VideoEngineTest\VideoTest.cpp">
|
<ClCompile Include="VideoEngineTest\VideoTest.cpp">
|
||||||
<Filter>VideoEngineTest</Filter>
|
<Filter>VideoEngineTest</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="VideoEngineTest\ImageTest.cpp">
|
<ClCompile Include="VideoEngineTest\ImageFileTest.cpp">
|
||||||
|
<Filter>VideoEngineTest</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="VideoEngineTest\VideoEngineTest.cpp">
|
||||||
<Filter>VideoEngineTest</Filter>
|
<Filter>VideoEngineTest</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -1,21 +1,27 @@
|
|||||||
#include "UTest.hpp"
|
#include "UTest.hpp"
|
||||||
|
|
||||||
const /*static*/ char * UTest::sp_pstr = "pass";
|
#include <stdio.h>
|
||||||
const /*static*/ char * UTest::sp_fstr = "fail";
|
|
||||||
|
/*static*/ const char* UTest::sp_pstr = "pass";
|
||||||
|
/*static*/ const char* UTest::sp_fstr = "fail";
|
||||||
|
|
||||||
/*static*/ unsigned long int UTest::s_pass = 0;
|
/*static*/ unsigned long int UTest::s_pass = 0;
|
||||||
/*static*/ unsigned long int UTest::s_fail = 0;
|
/*static*/ unsigned long int UTest::s_fail = 0;
|
||||||
|
|
||||||
UTest::UTest( const char * tstr ) {
|
UTest::UTest( const char* tstr )
|
||||||
|
: m_pass(0), m_fail(0)
|
||||||
|
{
|
||||||
init(tstr);
|
init(tstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UTest::init( const char * tstr ) {
|
void UTest::init( const char* tstr )
|
||||||
|
{
|
||||||
mp_tstr = tstr;
|
mp_tstr = tstr;
|
||||||
m_pass = m_fail = 0;
|
m_pass = m_fail = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UTest::test( const char * description, const int flag ) {
|
void UTest::test( const char* description, const int flag )
|
||||||
|
{
|
||||||
const char * pf = nullptr;
|
const char * pf = nullptr;
|
||||||
if (flag) {
|
if (flag) {
|
||||||
pf = sp_pstr;
|
pf = sp_pstr;
|
||||||
@@ -29,7 +35,8 @@ void UTest::test( const char * description, const int flag ) {
|
|||||||
printf("%s: %s -> %s\n", mp_tstr, description, pf);
|
printf("%s: %s -> %s\n", mp_tstr, description, pf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UTest::report() const {
|
void UTest::report() const
|
||||||
|
{
|
||||||
printf("%s: pass: %ld, fail: %ld\n", mp_tstr, m_pass, m_fail);
|
printf("%s: pass: %ld, fail: %ld\n", mp_tstr, m_pass, m_fail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
#ifndef __UTEST__
|
#ifndef __UTEST__
|
||||||
#define __UTEST__
|
#define __UTEST__
|
||||||
|
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
#define __UTest_VERSION "1.0.0"
|
#define __UTest_VERSION "1.0.0"
|
||||||
|
|
||||||
class UTest {
|
class UTest {
|
||||||
@@ -11,11 +9,11 @@ private:
|
|||||||
UTest operator = ( UTest & ); // no assignment operator
|
UTest operator = ( UTest & ); // no assignment operator
|
||||||
UTest(){}
|
UTest(){}
|
||||||
public:
|
public:
|
||||||
static const char * version() { return __UTest_VERSION; }
|
static const char* version() { return __UTest_VERSION; }
|
||||||
|
|
||||||
UTest( const char * );
|
UTest( const char* tstr );
|
||||||
void init( const char * );
|
void init( const char* tstr );
|
||||||
void test( const char * description, const int flag );
|
void test( const char* description, const int flag );
|
||||||
void report() const;
|
void report() const;
|
||||||
|
|
||||||
static void OverAllReport();
|
static void OverAllReport();
|
||||||
@@ -24,13 +22,13 @@ private:
|
|||||||
unsigned long int m_pass = 0;
|
unsigned long int m_pass = 0;
|
||||||
unsigned long int m_fail = 0;
|
unsigned long int m_fail = 0;
|
||||||
|
|
||||||
const char * mp_tstr = nullptr;
|
const char* mp_tstr = nullptr;
|
||||||
|
|
||||||
const static char * sp_pstr; /*= "pass";*/
|
static const char* sp_pstr; /*= "pass";*/
|
||||||
const static char * sp_fstr; /*= "fail";*/
|
static const char* sp_fstr; /*= "fail";*/
|
||||||
|
|
||||||
static unsigned long int s_pass;
|
static unsigned long int s_pass; //= 0
|
||||||
static unsigned long int s_fail;
|
static unsigned long int s_fail; //= 0
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __UTEST__
|
#endif // __UTEST__
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
#include "ImageFileTest.hpp"
|
||||||
|
|
||||||
|
#include "../UTest/UTest.hpp"
|
||||||
|
|
||||||
|
/*** TrooperEngine DLL Header Files ***/
|
||||||
|
#include "TrooperEngine.hpp"
|
||||||
|
|
||||||
|
using VideoEngine::cImageFile;
|
||||||
|
|
||||||
|
using VideoEngine::cSprite;
|
||||||
|
|
||||||
|
void ImageFileTest()
|
||||||
|
{
|
||||||
|
// cImageFile
|
||||||
|
printf("\nTesting cImageFile -----\n\n");
|
||||||
|
|
||||||
|
UTest u("cImageFile");
|
||||||
|
|
||||||
|
cImageFile* image = new cImageFile("ImageTest.bmp");
|
||||||
|
|
||||||
|
//u.test()
|
||||||
|
|
||||||
|
//image->SaveImage("ImageTestSaved.bmp");
|
||||||
|
|
||||||
|
//cSprite* sprite = new cSprite(&image);
|
||||||
|
|
||||||
|
//sprite->Draw();
|
||||||
|
|
||||||
|
|
||||||
|
u.report();
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#ifndef __IMAGEFILETEST__
|
||||||
|
#define __IMAGEFILETEST__
|
||||||
|
|
||||||
|
void ImageFileTest();
|
||||||
|
|
||||||
|
#endif // __IMAGEFILETEST__
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
#include "ImageTest.hpp"
|
|
||||||
|
|
||||||
#include "../UTest/UTest.hpp"
|
|
||||||
|
|
||||||
/*** TrooperEngine DLL Header Files ***/
|
|
||||||
#include "TrooperEngine.hpp"
|
|
||||||
|
|
||||||
using VideoEngine::cImage;
|
|
||||||
|
|
||||||
using VideoEngine::cSprite;
|
|
||||||
|
|
||||||
void ImageTest()
|
|
||||||
{
|
|
||||||
// cRenderer
|
|
||||||
printf("\nTesting cImage -----\n\n");
|
|
||||||
|
|
||||||
UTest u("cImage");
|
|
||||||
|
|
||||||
cImage* image = new cImage("ImageTest.bmp", "", false, 0, 0, 255, 255, true);
|
|
||||||
|
|
||||||
image->SaveImage("ImageTestSaved.bmp");
|
|
||||||
|
|
||||||
cSprite* sprite = new cSprite(&image);
|
|
||||||
|
|
||||||
sprite->Draw();
|
|
||||||
|
|
||||||
|
|
||||||
u.report();
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
#ifndef __IMAGETEST__
|
|
||||||
#define __IMAGETEST__
|
|
||||||
|
|
||||||
void ImageTest();
|
|
||||||
|
|
||||||
#endif // __IMAGETEST__
|
|
||||||
@@ -14,8 +14,50 @@ void RendererTest()
|
|||||||
|
|
||||||
UTest u("cRenderer");
|
UTest u("cRenderer");
|
||||||
|
|
||||||
SDL_Surface* sur = nullptr;
|
u.test("cRenderer. Setup()", cRenderer::Inst().Setup());
|
||||||
//cRenderer::Inst()->TextureToSurface();
|
|
||||||
|
u.test("Are Surface Equal. AreEqual()", RendererAreaEqual());
|
||||||
|
u.test("Are Surface Equal Not Equal. AreEqual()", RendererAreaEqualNotEqual());
|
||||||
|
|
||||||
|
u.test("Texture To Surface. TextureToSurface()", RendererTextureToSurface());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//u.test("Screen Shot", RendererTextureToSurface());
|
||||||
|
|
||||||
|
|
||||||
u.report();
|
u.report();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bool RendererAreaEqual()
|
||||||
|
{
|
||||||
|
SDL_Surface* one = SDL_LoadBMP("ImageTest.bmp");
|
||||||
|
SDL_Surface* two = SDL_LoadBMP("ImageTest.bmp");
|
||||||
|
|
||||||
|
return cRenderer::Inst().AreEqual(*one, *two);
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool RendererAreaEqualNotEqual()
|
||||||
|
{
|
||||||
|
SDL_Surface* one = SDL_LoadBMP("ImageTest.bmp");
|
||||||
|
SDL_Surface* two = SDL_LoadBMP("ImageTest.bmp");
|
||||||
|
|
||||||
|
one = SDL_ConvertSurfaceFormat(one, SDL_PIXELFORMAT_RGBA32, 0);
|
||||||
|
|
||||||
|
bool rtn = false;
|
||||||
|
if (cRenderer::Inst().AreEqual(*one, *two) == false)
|
||||||
|
rtn = true;
|
||||||
|
return rtn;
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool RendererTextureToSurface()
|
||||||
|
{
|
||||||
|
SDL_Texture* text = IMG_LoadTexture(cRenderer::Inst().getRendererCopy(), "ImageTest.bmp");
|
||||||
|
|
||||||
|
SDL_Surface* one = SDL_LoadBMP("ImageTest.bmp");
|
||||||
|
one = SDL_ConvertSurfaceFormat(one, SDL_PIXELFORMAT_RGBA32, 0);
|
||||||
|
|
||||||
|
SDL_Surface* sur = cRenderer::Inst().TextureToSurface(text);
|
||||||
|
|
||||||
|
return cRenderer::Inst().AreEqual(*one, *sur);
|
||||||
|
}
|
||||||
@@ -3,4 +3,10 @@
|
|||||||
|
|
||||||
void RendererTest();
|
void RendererTest();
|
||||||
|
|
||||||
|
const bool RendererAreaEqual();
|
||||||
|
|
||||||
|
const bool RendererAreaEqualNotEqual();
|
||||||
|
|
||||||
|
const bool RendererTextureToSurface();
|
||||||
|
|
||||||
#endif // __RENDERERTEST__
|
#endif // __RENDERERTEST__
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#include "VideoEngineTest.hpp"
|
||||||
|
|
||||||
|
#include "VideoTest.hpp"
|
||||||
|
#include "RendererTest.hpp"
|
||||||
|
#include "ImageFileTest.hpp"
|
||||||
|
|
||||||
|
void VideoEngineTest()
|
||||||
|
{
|
||||||
|
VideoTest();
|
||||||
|
|
||||||
|
RendererTest();
|
||||||
|
|
||||||
|
ImageFileTest();
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#ifndef __VIDEOENGINETEST__
|
||||||
|
#define __VIDEOENGINETEST__
|
||||||
|
|
||||||
|
void VideoEngineTest();
|
||||||
|
|
||||||
|
#endif // __VIDEOENGINETEST__
|
||||||
@@ -18,16 +18,26 @@ void VideoTest()
|
|||||||
VideoEngine::cVideo& video = VideoEngine::cVideo::Inst();
|
VideoEngine::cVideo& video = VideoEngine::cVideo::Inst();
|
||||||
video.Initialize();
|
video.Initialize();
|
||||||
|
|
||||||
u.test("Video Initialize", video.IsInit());
|
u.test("Video Initialize. IsInit()", video.IsInit());
|
||||||
|
|
||||||
u.test("Video Setup", video.Setup());
|
u.test("Video Setup. Setup()", video.Setup());
|
||||||
|
|
||||||
// CaptionTest
|
// CaptionTest
|
||||||
cString cap_set = "Hello World";
|
u.test("setCaption() and getCaption()", CaptionTest());
|
||||||
cVideo::Inst().setCaption(cap_set);
|
|
||||||
cString cap_get = cVideo::Inst().getCaption();
|
|
||||||
u.test("setCaption() and getCaption()", (cap_get == cap_set));
|
|
||||||
|
|
||||||
|
|
||||||
u.report();
|
u.report();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bool CaptionTest()
|
||||||
|
{
|
||||||
|
bool rtn = false;
|
||||||
|
|
||||||
|
cString cap_set = "Caption Test";
|
||||||
|
cVideo::Inst().setCaption(cap_set);
|
||||||
|
cString cap_get = cVideo::Inst().getCaption();
|
||||||
|
|
||||||
|
if (cap_get == cap_set)
|
||||||
|
rtn = true;
|
||||||
|
|
||||||
|
return rtn;
|
||||||
|
}
|
||||||
@@ -3,4 +3,6 @@
|
|||||||
|
|
||||||
void VideoTest();
|
void VideoTest();
|
||||||
|
|
||||||
|
const bool CaptionTest();
|
||||||
|
|
||||||
#endif // __VIDEOTEST__
|
#endif // __VIDEOTEST__
|
||||||
+11
-10
@@ -1,12 +1,12 @@
|
|||||||
/* Copyright (C) 2016 Richard W. Allen
|
/* Copyright (C) 2016 Richard W. Allen
|
||||||
Program Name: SDL Pong C++
|
Program Name: TrooperEngineTest
|
||||||
Author: Richard W. Allen
|
Author: Richard W. Allen
|
||||||
Version: V1.0
|
Version: V1.0
|
||||||
Date Started: August 24, 2016
|
Date Started: August 24, 2016
|
||||||
Date End:
|
Date End:
|
||||||
Webpage: http://www.richardallenonline.com
|
Webpage: http://www.richardallenonline.com
|
||||||
IDE: Visual Studio 2015
|
IDE: Visual Studio 2017
|
||||||
Compiler: C\C++ 2014
|
Compiler: C\C++ 2017
|
||||||
Langage: C++
|
Langage: C++
|
||||||
License: GNU GENERAL PUBLIC LICENSE Version 2
|
License: GNU GENERAL PUBLIC LICENSE Version 2
|
||||||
see license.txt for details
|
see license.txt for details
|
||||||
@@ -19,11 +19,11 @@ see license.txt for details
|
|||||||
/*** SDL Header Files ***/
|
/*** SDL Header Files ***/
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
|
|
||||||
|
/*** Unit Testing ***/
|
||||||
#include "UTest/UTest.hpp"
|
#include "UTest/UTest.hpp"
|
||||||
|
|
||||||
/*** Video Engine Test ***/
|
/*** Video Engine Test ***/
|
||||||
#include "VideoEngineTest/VideoTest.hpp"
|
#include "VideoEngineTest/VideoEngineTest.hpp"
|
||||||
#include "VideoEngineTest/ImageTest.hpp"
|
|
||||||
|
|
||||||
/*** Utility Engine Test ***/
|
/*** Utility Engine Test ***/
|
||||||
#include "UtilityEngineTest/StringTest.hpp"
|
#include "UtilityEngineTest/StringTest.hpp"
|
||||||
@@ -45,15 +45,16 @@ int main(int argc, char *argv[])
|
|||||||
printf(cString("TrooperEngine V") + TrooperEngineCore::cTrooperEngineCore::Version() + "\n");
|
printf(cString("TrooperEngine V") + TrooperEngineCore::cTrooperEngineCore::Version() + "\n");
|
||||||
|
|
||||||
|
|
||||||
VideoTest();
|
VideoEngineTest();
|
||||||
|
|
||||||
|
//UtilityEngineTest();
|
||||||
|
|
||||||
|
|
||||||
|
//StringTest();
|
||||||
|
|
||||||
StringTest();
|
//GUIXMLTest();
|
||||||
|
|
||||||
GUIXMLTest();
|
//ImageTest();
|
||||||
|
|
||||||
ImageTest();
|
|
||||||
|
|
||||||
|
|
||||||
UTest::OverAllReport();
|
UTest::OverAllReport();
|
||||||
|
|||||||
Reference in New Issue
Block a user