You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
116 lines
3.2 KiB
C++
116 lines
3.2 KiB
C++
|
4 years ago
|
/******************************************************************************
|
||
|
|
* File - tester.cpp
|
||
|
|
* Author - Joey Pollack
|
||
|
|
* Date - 2021/09/15 (y/m/d)
|
||
|
|
* Mod Date - 2021/09/15 (y/m/d)
|
||
|
|
* Description - Run a series of tests to verify engine functionality
|
||
|
|
******************************************************************************/
|
||
|
|
|
||
|
|
#include "tester.h"
|
||
|
4 years ago
|
#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>
|
||
|
4 years ago
|
#include <LunariumConfig.h>
|
||
|
4 years ago
|
|
||
|
|
namespace lunarium
|
||
|
|
{
|
||
|
|
Tester::Tester()
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
OpRes Tester::Initialize()
|
||
|
|
{
|
||
|
4 years ago
|
// return OpRes::Fail("Tester::Initialize not implemented");
|
||
|
|
|
||
|
|
mLogCat = Logger::RegisterCategory("TESTER");
|
||
|
|
|
||
|
4 years ago
|
#if BUILD_NO_EDITOR
|
||
|
|
Logger::Log(mLogCat, LogLevel::INFO, "BUILDING NO EDITOR!");
|
||
|
|
#else
|
||
|
|
Logger::Log(mLogCat, LogLevel::INFO, "BUILDING WITH THE EDITOR!");
|
||
|
|
#endif
|
||
|
|
|
||
|
|
|
||
|
4 years ago
|
mTextBoxWidth = 500;
|
||
|
|
|
||
|
|
// Currently the full default window size
|
||
|
|
mImageSize.Width = 1280;
|
||
|
|
mImageSize.Height = 720;
|
||
|
|
|
||
|
|
return OpRes::OK();
|
||
|
4 years ago
|
}
|
||
|
|
|
||
|
|
void Tester::Shutdown()
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
void Tester::OnTick(double delta)
|
||
|
|
{
|
||
|
4 years ago
|
if (Core::Input().IsKeyDown(KeyCode::ESCAPE))
|
||
|
|
{
|
||
|
|
Core::GetInstance().SignalShutdown();
|
||
|
|
}
|
||
|
|
|
||
|
4 years ago
|
// Textbox size adjustment
|
||
|
|
if (Core::Input().IsKeyDown(KeyCode::LEFT))
|
||
|
|
{
|
||
|
|
mTextBoxWidth -= 10;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (Core::Input().IsKeyDown(KeyCode::RIGHT))
|
||
|
|
{
|
||
|
|
mTextBoxWidth += 10;
|
||
|
|
}
|
||
|
|
|
||
|
|
mTextBoxWidth = Math::ClampI(mTextBoxWidth, 20, 500);
|
||
|
|
|
||
|
|
// Image Size adjustment
|
||
|
|
if (Core::Input().IsKeyDown(KeyCode::DOWN))
|
||
|
|
{
|
||
|
|
mImageSize.Width -= 10;
|
||
|
|
mImageSize.Height -= 10;
|
||
|
|
}
|
||
|
4 years ago
|
|
||
|
4 years ago
|
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);
|
||
|
|
|
||
|
|
// 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();
|
||
|
4 years ago
|
}
|
||
|
|
|
||
|
4 years ago
|
void Tester::OnRender(IGraphics* g)
|
||
|
4 years ago
|
{
|
||
|
4 years ago
|
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));
|
||
|
4 years ago
|
|
||
|
4 years ago
|
g->DrawBox(Rectangle(0.0f, 0.0f, (float)mImageSize.Width, (float)mImageSize.Height), Color(0.0f, 0.0f, 0.0f, 1.0f), 1.0f);
|
||
|
4 years ago
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|