Add MathEngineTest and Commects and clean ups
This commit is contained in:
@@ -83,7 +83,7 @@ namespace VideoEngine {
|
||||
private:
|
||||
/// Variables
|
||||
SDL_Texture* mp_texture;/// = nullptr
|
||||
SDL_Surface* mp_surface;// = nullptr
|
||||
SDL_Surface* mp_surface;/// = nullptr
|
||||
|
||||
bool m_transparent;/// = false
|
||||
|
||||
|
||||
@@ -47,7 +47,6 @@ const bool cRenderer::Setup()
|
||||
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)
|
||||
rtn = true;
|
||||
}
|
||||
@@ -169,13 +168,13 @@ SDL_Surface* cRenderer::TextureToSurface( SDL_Texture* texture )
|
||||
|
||||
SDL_Rect rec = { 0, 0, w, h };
|
||||
|
||||
SDL_Texture* tmp_texture = NewTexture(w, h, true); // Create a new texture with Software Renderer
|
||||
CopyTexture(texture, tmp_texture, true); // Copy old texture to the Software Renderer Texture renderer
|
||||
SetRenderTarget(texture);
|
||||
|
||||
if (SDL_RenderReadPixels(mp_renderer, nullptr, SDL_PIXELFORMAT_RGBA32, rtn->pixels, rtn->pitch) < 0)
|
||||
cUtility::Inst().Message("Unable to Read Texture's Pixels. SDL_RenderReadPixels():", __AT__, cUtility::eTypeSDL::SDL);
|
||||
|
||||
ResetRenderTarget();
|
||||
|
||||
Render(tmp_texture, nullptr, mp_rendererSoftware, &rec); // Render to the mp_rendererSoftware
|
||||
|
||||
SDL_RenderReadPixels(mp_rendererSoftware, nullptr, SDL_PIXELFORMAT_RGBA32, rtn->pixels, rtn->pitch);
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
@@ -266,7 +265,6 @@ const bool cRenderer::AreEqual( SDL_Surface& one, SDL_Surface& two )
|
||||
if (SDL_MUSTLOCK(&two) > 0)
|
||||
SDL_UnlockSurface(&two);
|
||||
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,11 +40,16 @@ namespace VideoEngine {
|
||||
void RenderDrawColor( const SDL_Colour& colour );
|
||||
void RenderDrawRect( const SDL_Rect& rect, SDL_Texture* dst = nullptr );
|
||||
|
||||
/* Takes a screen shot by copying the pixels from the Renderer to a new SDL_Surface and Calls SaveSurface(). */
|
||||
void ScreenShot(const cString& filename, const cString& dir = "");
|
||||
/* Saves the SDL_Surface to the given file name and directory */
|
||||
void SaveSurface( SDL_Surface* surface, const cString& fileName, const cString& dir = "" );
|
||||
/* Saves the SDL_Texture to the given file name and directory */
|
||||
void SaveTexture( SDL_Texture* texture, const cString& fileName, const cString& dir = "" );
|
||||
|
||||
/* Give it a SDL_Surface and it returns a SDL_Texture */
|
||||
SDL_Texture* SurfaceToTexture( SDL_Surface* surface );
|
||||
/* Give it a SDL_Texture and it returns and SDL_Surface */
|
||||
SDL_Surface* TextureToSurface( SDL_Texture* texture );
|
||||
|
||||
void CopyTexture( SDL_Texture* src, SDL_Texture* dst, bool software = false );
|
||||
@@ -54,6 +59,7 @@ namespace VideoEngine {
|
||||
SDL_Surface* NewSurface( long int width = -1, long int height = -1 ) 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;
|
||||
|
||||
/* Give it two SDL_Surface you wish to compare returns true if the pixels are the same. */
|
||||
const bool AreEqual( SDL_Surface& one, SDL_Surface& two );
|
||||
|
||||
void SetRenderTarget( SDL_Renderer* renderer, SDL_Texture* target = nullptr );
|
||||
@@ -67,6 +73,7 @@ namespace VideoEngine {
|
||||
SDL_Renderer* getRendererCopy();
|
||||
|
||||
private:
|
||||
/// Variables
|
||||
SDL_Renderer* mp_renderer;
|
||||
SDL_Renderer* mp_rendererSoftware;
|
||||
|
||||
|
||||
@@ -124,6 +124,17 @@ void cSprite::AddPosY( const signed long int y )
|
||||
m_position.y += Sint16(y);
|
||||
}
|
||||
|
||||
void cSprite::AddPosXPosY( const signed long int x, const signed long int y )
|
||||
{
|
||||
AddPosX(x);
|
||||
AddPosY(y);
|
||||
}
|
||||
|
||||
void VideoEngine::cSprite::AddPosXPosY( const MathEngine::iVector2& addPos /*= MathEngine::iVector2(0, 0)*/ )
|
||||
{
|
||||
AddPosXPosY(addPos.x, addPos.y);
|
||||
}
|
||||
|
||||
void cSprite::SaveImage( const cString& fileName, const cString& dir /*= ""*/ )
|
||||
{
|
||||
if (mpp_image != nullptr && *mpp_image != nullptr) {
|
||||
|
||||
@@ -44,9 +44,16 @@ namespace VideoEngine {
|
||||
/* Draws the sprite to the video buffer with out positioning it */
|
||||
void DefaltDraw();
|
||||
|
||||
/* Adds X to the position of the sprite */
|
||||
void AddPosX( const signed long int x );
|
||||
/* Adds Y to the position of the sprite */
|
||||
void AddPosY( const signed long int y );
|
||||
/* Adds X and Y to the position of the sprite */
|
||||
void AddPosXPosY( const signed long int x, const signed long int y );
|
||||
/* Adds X and Y to the Position of the sprite via iVector2 */
|
||||
void AddPosXPosY( const MathEngine::iVector2& addPos = MathEngine::iVector2(0, 0) );
|
||||
|
||||
/* Saves the Image to the given file name and directory via cRenderer's SaveTextrue()*/
|
||||
void SaveImage( const cString& fileName, const cString& dir = "" );
|
||||
|
||||
/// Sets
|
||||
|
||||
@@ -122,18 +122,18 @@ namespace VideoEngine {
|
||||
|
||||
static cVideo* sp_inst;/// = nullptr
|
||||
|
||||
/*SDL interprets each pixel as a 32-bit number, so our masks must depend
|
||||
/* SDL interprets each pixel as a 32-bit number, so our masks must depend
|
||||
on the endianness (byte order) of the machine */
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
const unsigned long int m_rmask;// = 0xff000000;
|
||||
const unsigned long int m_gmask;// = 0x00ff0000;
|
||||
const unsigned long int m_bmask;// = 0x0000ff00;
|
||||
const unsigned long int m_amask;// = 0x000000ff;
|
||||
const unsigned long int m_rmask;/// = 0xff000000;
|
||||
const unsigned long int m_gmask;/// = 0x00ff0000;
|
||||
const unsigned long int m_bmask;/// = 0x0000ff00;
|
||||
const unsigned long int m_amask;/// = 0x000000ff;
|
||||
#else
|
||||
const unsigned long int m_rmask;// = 0x000000ff;
|
||||
const unsigned long int m_gmask;// = 0x0000ff00;
|
||||
const unsigned long int m_bmask;// = 0x00ff0000;
|
||||
const unsigned long int m_amask;// = 0xff000000;
|
||||
const unsigned long int m_rmask;/// = 0x000000ff;
|
||||
const unsigned long int m_gmask;/// = 0x0000ff00;
|
||||
const unsigned long int m_bmask;/// = 0x00ff0000;
|
||||
const unsigned long int m_amask;/// = 0xff000000;
|
||||
#endif
|
||||
};/// END CLASS DEFINITION cVideo
|
||||
}/// END NAMESPACE DEFINITION VideoEngine
|
||||
|
||||
Reference in New Issue
Block a user