aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/05Font/main.cpp76
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