diff --git a/tests/test1.cpp b/tests/test1.cpp new file mode 100644 index 0000000..331f8bd --- /dev/null +++ b/tests/test1.cpp @@ -0,0 +1,48 @@ +#include +#include +#include +#include "MiniEngine.h" +#include "MiniEngine_Event.h" +using namespace MiniEngine; + +int main() +{ + try + { + /// Initialize SDL2, SDL2_image, SDL2_mixer, SDL2_ttf with default flags. + SDLSystem sys; + /// Create window + Window wnd("Window Title",1024,768); + /// Create renderer + Renderer rnd(wnd); + /// Load texture + Texture t=rnd.loadTexture("test.png"); + /// Create a event loop + Looper lp; + /// Add event handling functions. + lp.add(SDL_QUIT,[](Looper& lp){lp.stop();}); + /// Set Updater + lp.updater=[&]() + { + /// Clear screen + rnd.clear(); + /// Copy the texture to full-fill the screen. + rnd.copyFullFill(t); + /// Update screen + rnd.update(); + }; + /// Start Looper + lp.run(); + + /// Texture will be freed. + /// Renderer will be destroyed. + /// Window will be destroyed. + + /// All SDL system will be shut down. + } + catch (const ErrorViewer& e) + { + printf("Exception: %s\n",e.what()); + } + return 0; +}