Add Tests

This commit is contained in:
Kirigaya Kazuto 2017-07-11 23:00:04 +08:00
parent c769c0a3db
commit 8187d5c9a6

48
tests/test1.cpp Normal file
View File

@ -0,0 +1,48 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
#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;
}