|
|
|
|
@ -7,6 +7,12 @@
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "tester.h"
|
|
|
|
|
#include <core/core.h>
|
|
|
|
|
#include <utils/helpers.h>
|
|
|
|
|
#include <utils/logger.h>
|
|
|
|
|
#include <graphics/igraphics.h>
|
|
|
|
|
#include <input/inputManager.h>
|
|
|
|
|
#include <assets/types/image.h>
|
|
|
|
|
|
|
|
|
|
namespace lunarium
|
|
|
|
|
{
|
|
|
|
|
@ -17,7 +23,17 @@ namespace lunarium
|
|
|
|
|
|
|
|
|
|
OpRes Tester::Initialize()
|
|
|
|
|
{
|
|
|
|
|
return OpRes::Fail("Tester::Initialize not implemented");
|
|
|
|
|
// return OpRes::Fail("Tester::Initialize not implemented");
|
|
|
|
|
|
|
|
|
|
mLogCat = Logger::RegisterCategory("TESTER");
|
|
|
|
|
|
|
|
|
|
mTextBoxWidth = 500;
|
|
|
|
|
|
|
|
|
|
// Currently the full default window size
|
|
|
|
|
mImageSize.Width = 1280;
|
|
|
|
|
mImageSize.Height = 720;
|
|
|
|
|
|
|
|
|
|
return OpRes::OK();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Tester::Shutdown()
|
|
|
|
|
@ -27,30 +43,60 @@ namespace lunarium
|
|
|
|
|
|
|
|
|
|
void Tester::OnTick(double delta)
|
|
|
|
|
{
|
|
|
|
|
// Textbox size adjustment
|
|
|
|
|
if (Core::Input().IsKeyDown(KeyCode::LEFT))
|
|
|
|
|
{
|
|
|
|
|
mTextBoxWidth -= 10;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Core::Input().IsKeyDown(KeyCode::RIGHT))
|
|
|
|
|
{
|
|
|
|
|
mTextBoxWidth += 10;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Tester::OnRender()
|
|
|
|
|
mTextBoxWidth = Math::ClampI(mTextBoxWidth, 20, 500);
|
|
|
|
|
|
|
|
|
|
// Image Size adjustment
|
|
|
|
|
if (Core::Input().IsKeyDown(KeyCode::DOWN))
|
|
|
|
|
{
|
|
|
|
|
mImageSize.Width -= 10;
|
|
|
|
|
mImageSize.Height -= 10;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Core::Input().IsKeyDown(KeyCode::UP))
|
|
|
|
|
{
|
|
|
|
|
mImageSize.Width += 10;
|
|
|
|
|
mImageSize.Height += 10;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
mImageSize.Width = Math::ClampI(mImageSize.Width, 320, 1280);
|
|
|
|
|
mImageSize.Height = Math::ClampI(mImageSize.Height, 180, 720);
|
|
|
|
|
|
|
|
|
|
// DEBUG: Graphics testing
|
|
|
|
|
// static int width = 500;
|
|
|
|
|
// if (mpInput->IsKeyDown(KeyCode::LEFT))
|
|
|
|
|
// {
|
|
|
|
|
// width -= 10;
|
|
|
|
|
// }
|
|
|
|
|
// Render to texture testing
|
|
|
|
|
OpRes result = Core::GetInstance().BeginRenderToTexture();
|
|
|
|
|
if (Failed(result))
|
|
|
|
|
{
|
|
|
|
|
Logger::Log(mLogCat, LogLevel::WARNING, "Unable to render to texture: %s", result.Description.c_str());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IGraphics& g = Core::Graphics();
|
|
|
|
|
|
|
|
|
|
g.DrawFilledEllipse(glm::vec2(600, 300), glm::vec2(100, 150), Color(1.0f, 0.0f, 1.0f, 1.0f), 100);
|
|
|
|
|
g.DrawString("This is a test of the text renderer!", Rectangle(100, 200, mTextBoxWidth, 300),
|
|
|
|
|
Color(0.0f, 1.0f, 1.0f, 1.0f), 0.5f, g.DefaultFont());
|
|
|
|
|
|
|
|
|
|
mpRenderedImage = Core::GetInstance().EndRenderToTexture();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if (mpInput->IsKeyDown(KeyCode::RIGHT))
|
|
|
|
|
// {
|
|
|
|
|
// width += 10;
|
|
|
|
|
// }
|
|
|
|
|
void Tester::OnRender(IGraphics* g)
|
|
|
|
|
{
|
|
|
|
|
g->DrawImage(*mpRenderedImage, Rectangle(0.0f, 0.0f, (float)mpRenderedImage->GetWidth(), (float)mpRenderedImage->GetHeight()),
|
|
|
|
|
Rectangle(0.0f, 0.0f, (float)mImageSize.Width, (float)mImageSize.Height), Color(1.0f, 1.0f, 1.0f, 1.0f));
|
|
|
|
|
|
|
|
|
|
g->DrawBox(Rectangle(0.0f, 0.0f, (float)mImageSize.Width, (float)mImageSize.Height), Color(0.0f, 0.0f, 0.0f, 1.0f), 1.0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// mpGraphics->DrawFilledEllipse(glm::vec2(600, 300), glm::vec2(100, 150), Color(1.0f, 0.0f, 1.0f, 1.0f), 100);
|
|
|
|
|
// mpGraphics->DrawString("This is a test of the text renderer!", Rectangle(100, 200, width, 300),
|
|
|
|
|
// Color(0.0f, 1.0f, 1.0f, 1.0f), 0.5f, mpGraphics->DefaultFont());
|
|
|
|
|
|
|
|
|
|
// mpGraphics->DrawImage(*pImage, glm::vec2(0.0f, 0.0f), Color(1.0f, 1.0f, 1.0f, 1.0f));
|