#include "RendererTest.hpp"

#include "../UTest/UTest.hpp"

/*** TrooperEngine DLL Header Files ***/
#include "TrooperEngine.hpp"

using VideoEngine::cRenderer;

void RendererTest()
{
	// cRenderer
	printf("\nTesting cRenderer -----\n\n");

	UTest u("cRenderer");

	u.test("cRenderer. Setup()", cRenderer::Inst().Setup());

	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();
}

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);
}