2023-05-26 21:41:51 +00:00
# include <logging/types.hpp>
# include <fmt/format.h>
# include <renderer/renderer.hpp>
2023-06-26 18:46:11 +00:00
# include <rwgpu.hpp>
2023-05-26 21:41:51 +00:00
# include <resources/font.hpp>
# include <string>
# include <iostream>
# include <chrono>
# include <thread>
# include <engine/engine.hpp>
2023-05-27 17:11:46 +00:00
# include <pragmautil.hpp>
# if defined(_MSC_VER) || defined(_MSC_FULL_VER)
2023-05-30 14:20:34 +00:00
WARNING ( " Please avoid using MSVC in C++ projects utilising std::chrono and std::this_thread due to unfixed frame timing issues in the MSVC C++ implementation " )
2023-05-27 17:11:46 +00:00
# endif
2023-05-26 21:41:51 +00:00
using namespace hibis ;
2023-06-26 18:46:11 +00:00
using namespace hibis : : rwgpu ;
2023-05-26 21:41:51 +00:00
void logger ( LoggingSeverity severity , std : : string message ) {
std : : string sevString ;
switch ( severity ) {
case Message :
2023-06-01 19:19:18 +00:00
sevString = " Message " ;
2023-05-26 21:41:51 +00:00
break ;
case Information :
sevString = " Information " ;
break ;
case Warning :
2023-06-01 19:19:18 +00:00
sevString = " Warning " ;
2023-05-26 21:41:51 +00:00
break ;
case Error :
2023-06-01 19:19:18 +00:00
sevString = " Error " ;
2023-05-26 21:41:51 +00:00
break ;
case Fatal :
2023-06-01 19:19:18 +00:00
sevString = " Fatal " ;
2023-05-26 21:41:51 +00:00
break ;
}
2023-05-27 17:11:46 +00:00
std : : cout < < fmt : : format ( " [{}]: {} " , sevString , message ) < < std : : endl ;
2023-05-26 21:41:51 +00:00
}
int main ( ) {
2023-06-01 19:19:18 +00:00
logger ( Information , fmt : : format ( " PWD: {} " , std : : getenv ( " PWD " ) ) ) ;
2023-06-28 20:43:01 +00:00
RWGPU renderer = RWGPU ( " test " , IntVec2 { 800 , 800 } , & logger ) ;
2023-05-26 21:41:51 +00:00
Engine engine = Engine ( & renderer , & logger ) ;
2023-06-26 18:46:11 +00:00
/*
2023-05-26 21:41:51 +00:00
# ifdef _WIN32
2023-06-01 19:19:18 +00:00
Font font = Font ( engine . mFreeTypeLibrary , " C: \\ Windows \\ Fonts \\ Arial.ttf " , 16 ) ;
2023-05-26 21:41:51 +00:00
# else
2023-06-01 17:27:14 +00:00
Font font = Font ( engine . mFreeTypeLibrary , " /usr/share/fonts/noto/NotoSans-Light.ttf " , 16 ) ;
2023-05-26 21:41:51 +00:00
# endif
2023-05-30 16:00:39 +00:00
Texture image = Texture ( ( char * ) " test.png " ) ;
2023-06-26 13:22:34 +00:00
system ( " cp ../test/test.vert ./ && cp ../test/test.frag ./ " ) ;
Shader shader = Shader ( " test.vert " , " test.frag " ) ;
2023-06-01 19:19:18 +00:00
renderer . compileShader ( & shader ) ;
2023-05-30 16:00:39 +00:00
2023-06-01 17:27:14 +00:00
uint8_t red = 0 ;
2023-05-26 21:41:51 +00:00
bool increaseRed = true ;
bool increaseSize = true ;
uint size = 16 ;
uint f = 0 ;
2023-06-28 20:43:01 +00:00
//Point2D points[3] = {{-0.5f, -0.5f}, {0.5f, -0.5f}, {0.0f, 0.5f}};
2023-06-26 18:46:11 +00:00
*/
2023-05-26 21:41:51 +00:00
logger ( Information , " Started Hibis test app! BEHOLD: Colours. " ) ;
2023-05-27 19:47:34 +00:00
while ( renderer . mKeepOpen ) {
2023-06-26 18:46:11 +00:00
/*
2023-05-26 21:41:51 +00:00
// Colour changing background!
if ( ( red = = 255 & & increaseRed ) | | ( red = = 0 & & ! increaseRed ) ) {
increaseRed = ! increaseRed ;
}
if ( increaseRed ) red + = 1 ;
else red - = 1 ;
f + + ;
if ( f = = 16 ) {
f = 0 ;
if ( ( size = = 64 & & increaseSize ) | | ( size = = 16 & & ! increaseSize ) ) {
increaseSize = ! increaseSize ;
}
if ( increaseSize ) size + = 2 ;
else size - = 2 ;
font . setFontSize ( size ) ;
}
2023-06-26 18:46:11 +00:00
*/
2023-05-26 21:41:51 +00:00
// Clear screen then sleep for ~16ms
2023-06-26 18:46:11 +00:00
//renderer.clearScreen(Color {red, 0, 0, 255});
2023-06-26 13:22:34 +00:00
//renderer.useShader(&shader, points);
2023-06-01 19:19:18 +00:00
//renderer.drawText(&font, "Testing Text", IntVec2 {0, 0}, Color {255, 255, 255, 255});
//renderer.drawTexture(&image, 1.0f, IntVec2 {10, 10});
2023-05-26 21:41:51 +00:00
renderer . renderCurrent ( ) ;
renderer . update ( ) ;
std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( 16 ) ) ;
}
return 0 ;
}