diff options
author | chai <chaifix@163.com> | 2018-09-17 08:09:12 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-09-17 08:09:12 +0800 |
commit | 67aeffc5fd6573074a450826fe0c000ca2177451 (patch) | |
tree | 18d72d43e46e668e48a34b494656b7891964961b /test/05Font/main.cpp | |
parent | 8a2970103ed4facafee30a7653ee3b6cb6df902a (diff) |
*update
Diffstat (limited to 'test/05Font/main.cpp')
-rw-r--r-- | test/05Font/main.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/test/05Font/main.cpp b/test/05Font/main.cpp new file mode 100644 index 0000000..30b0e3d --- /dev/null +++ b/test/05Font/main.cpp @@ -0,0 +1,76 @@ +#include <iostream> +#include "jin.h" + +using namespace jin::core; +using namespace jin::graphics; +using namespace jin::input; +using namespace jin::audio; +using namespace jin::filesystem; +Font* font = nullptr; +Canvas* canvas; +FontData* data = nullptr; +void onLoad() +{ + Filesystem* fs = Filesystem::get(); + fs->mount("D:/Documents/VisualStudio2017/Projects/Jin/libjin/min/build/Debug"); + Buffer buffer; + fs->read("SIMYOU.TTF", &buffer); + data = FontData::createFontData((const unsigned char*)buffer.data, buffer.size); + font = Font::createFont(data, 15); + //canvas = Canvas::createCanvas(100, 100); +} + +void onEvent(jin::input::Event* e) +{ + static Game* game = Game::get(); + if (e->type == EventType::QUIT) + game->stop(); +} + +void onUpdate(int ms) +{ + +} + +void onDraw() +{ + glColor4f(32 / 255.f, 32 / 255.f, 32 / 255.f, 1); + rect(FILL, 0, 0, 500, 500); + glColor4f(1, 1, 1, 1); + //Canvas::bind(canvas); + if (font != nullptr) + { + font->print(u8"hello, worldjqp", 0, 0); + } + //Canvas::unbind(); + //canvas->draw(0, 0, 2, 2, 0); +} + +int main(int argc, char* argv[]) +{ + Game* game = Game::get(); + Game::Setting setting; + setting.loader = onLoad; + setting.eventHandler = onEvent; + setting.updater = onUpdate; + setting.drawer = onDraw; + game->init(&setting); + + Window* wnd = Window::get(); + Window::Setting wndSetting; + wndSetting.width = 600; + wndSetting.height = 512; + wndSetting.title = "test"; + wndSetting.fps = 60; + wndSetting.vsync = false; + wndSetting.fullscreen = false; + wndSetting.resizable = false; + wnd->init(&wndSetting); + + game->run(); + + game->quit(); + wnd->quit(); + + return 0; +}
\ No newline at end of file |