Add project files.

This commit is contained in:
2018-06-25 21:48:45 -04:00
parent b04a25689b
commit 3c1b7d28e8
425 changed files with 35333 additions and 0 deletions
@@ -0,0 +1,118 @@
#include "cCamera.hpp"
/*** Custom Header Files ***/
#include "cRenderer.hpp"
#include "../UtilityEngine/cUtility.hpp"
using VideoEngine::cCamera;
using UtilityEngine::cUtility;
cCamera::cCamera( const signed long int xPos /*= 0*/, const signed long int yPos /*= 0*/,
const unsigned long int reswidth /*= 640*/, const unsigned long int reshight /*= 480*/ )
: mp_texture(nullptr)
{
m_position.x = Sint16(xPos);
m_position.y = Sint16(yPos);
m_position.w = Uint16(reswidth);
m_position.h = Uint16(reshight);
CreateCamera();
}
cCamera::cCamera( const cCamera& copy )
{
m_position.x = Sint16(copy.getXPos());
m_position.y = Sint16(copy.getYPos());
m_position.w = Uint16(copy.getWidthRes());
m_position.h = Uint16(copy.getHeightRes());
setTexture(copy.getTexture());
}
cCamera::~cCamera()
{
DeleteCamera();
}
void cCamera::Draw()
{
cRenderer::Inst().Render(mp_texture, nullptr, &m_position);
}
void cCamera::SaveImage( const cString& fileName, const cString& dir /*= ""*/ )
{
cRenderer::Inst().SaveTexture(mp_texture, fileName, dir);
}
///Sets
void cCamera::setXPosandYPos( const signed long int xPos /*= 0*/, const signed long int yPos /*= 0*/ )
{
m_position.x = Sint16(xPos);
m_position.y = Sint16(yPos);
CreateCamera();
}
void cCamera::setResWidthandResHeight( const unsigned long int reswidth /*= 640*/, const unsigned long int reshight /*= 480*/ )
{
m_position.w = Uint16(reswidth);
m_position.h = Uint16(reshight);
CreateCamera();
}
void cCamera::setTexture( SDL_Texture* texture )
{
DeleteCamera();
CreateCamera();
cRenderer::Inst().CopyTexture(texture, mp_texture);
}
///Gets
const unsigned long int cCamera::getXPos() const
{
return m_position.x;
}
const unsigned long int cCamera::getYPos() const
{
return m_position.y;
}
const unsigned long int cCamera::getWidthRes() const
{
return m_position.w;
}
const unsigned long int cCamera::getHeightRes() const
{
return m_position.h;
}
SDL_Texture* cCamera::getCameraView() const
{
return mp_texture;
}
SDL_Texture* cCamera::getTexture() const
{
return mp_texture;
}
void cCamera::CreateCamera()
{
DeleteCamera();
mp_texture = cRenderer::Inst().NewTexture(m_position.w, m_position.h, SDL_TEXTUREACCESS_TARGET);
if (mp_texture == nullptr)
cUtility::Inst().Message("Unable to create camera.", __AT__);
}
void cCamera::DeleteCamera()
{
if (mp_texture != nullptr)
SDL_DestroyTexture(mp_texture);
}
@@ -0,0 +1,71 @@
#ifndef _CRENDERER_HPP_
#define _CRENDERER_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** DLL Header File ***/
#include "dllExport.h"
/*** Custom Header Files ***/
#include "../UtilityEngine/cString.hpp"
using UtilityEngine::cString;
namespace VideoEngine {
/* Singleton */
class EXPORT_FROM_MYDLL cRenderer
{
private:
cRenderer();
~cRenderer();
public:
static cRenderer& Inst();
static void Delete();
/* Creates the Renderer */
const bool Setup();
/* Uses */
void CleanUp();
void Render( SDL_Texture* texture, SDL_Rect* srcrect, SDL_Rect* dstrect );
void Render( SDL_Surface* surface, SDL_Rect* srcrect, SDL_Rect* dstrect );
void Render( SDL_Surface* src, const SDL_Rect* srcrect, SDL_Surface* dst, SDL_Rect* dstrect );
void Render( SDL_Texture* src, const SDL_Rect* srcrect, SDL_Surface* dst, SDL_Rect* dstrect );
void Render( SDL_Texture* src, const SDL_Rect* srcrect, SDL_Renderer* dst, SDL_Rect* dstrect );
void RenderToTexture( SDL_Texture* src, SDL_Rect* srcrect, SDL_Texture* dst, SDL_Rect* dstrect );
void RenderDrawColor( const SDL_Colour& colour );
void RenderDrawRect( const SDL_Rect& rect, SDL_Texture* dst = nullptr );
void ScreenShot(const cString& filename, const cString& dir = "");
void SaveSurface( SDL_Surface* surface, const cString& fileName, const cString& dir = "" );
void SaveTexture( SDL_Texture* texture, const cString& fileName, const cString& dir = "" );
SDL_Texture* SurfaceToTexture( SDL_Surface* surface );
SDL_Surface* TextureToSurface( SDL_Texture* texture );
void CopyTexture( SDL_Texture* src, SDL_Texture* dst );
SDL_Surface* CopySurface( SDL_Surface* src );
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;
void SetRenderTarget( SDL_Texture* target = nullptr );
void ResetRenderTarget();
///Sets
///Gets
SDL_Renderer* getRenderer();
private:
SDL_Renderer* mp_renderer;
static cRenderer* sp_inst;// = nullptr
};/// END CLASS DEFINITION cRenderer
}/// END NAMESPACE DEFINITION VideoEngine
#endif/// END IFNDEF _CRENDERER_HPP_