aboutsummaryrefslogtreecommitdiff
path: root/test/05Font/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/05Font/main.cpp')
-rw-r--r--test/05Font/main.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/test/05Font/main.cpp b/test/05Font/main.cpp
index 1b0ae0a..1388537 100644
--- a/test/05Font/main.cpp
+++ b/test/05Font/main.cpp
@@ -1,4 +1,4 @@
-#include <iostream>
+#include <iostream>
#include "jin.h"
using namespace jin::core;
@@ -17,18 +17,19 @@ void onLoad()
uniform float dt;
Color effect(Color col, Texture tex, vec2 uv, vec2 screen)
{
- float d = 150;
- float f = abs((screen.x - d * sin(dt))/20);
- return vec4(col.rgb*(1-f), Texel(tex, uv).a);
+ float d = 130;
+ float f = clamp(abs((screen.x - d * sin(dt))/75), 0, 1);
+ return vec4(col.r*(f), col.g*(1-f + 0.5), 0,Texel(tex, uv).a);
+ //return Texel(tex, uv);
}
)";
shader = JSLProgram::createJSLProgram(program);
Filesystem* fs = Filesystem::get();
fs->mount("../Debug");
Buffer buffer;
- fs->read("SIMYOU.TTF", &buffer);
+ fs->read("font.ttf", &buffer);
data = FontData::createFontData((const unsigned char*)buffer.data, buffer.size);
- font = Font::createFont(data, 14);
+ font = Font::createFont(data, 17);
//canvas = Canvas::createCanvas(100, 100);
}
@@ -49,17 +50,19 @@ void onDraw()
glColor4f(32 / 255.f, 32 / 255.f, 32 / 255.f, 1);
rect(FILL, 0, 0, 500, 500);
glColor4f(1, 1, 1, 1);
- //shader->use();
- //shader->sendFloat("dt", dt);
+ shader->use();
+ shader->sendFloat("dt", dt);
//Canvas::bind(canvas);
if (font != nullptr)
{
glColor4f(1, 1, 1, 1);
- //font->print(u8"ԴZ󤸤Τ", 0, 0);
- font->print(u8"hello, worldԴZ󤸤", 0, 0);
+ font->print(u8"Hello, world!", 10, 10);
+ font->print(u8"Привет мир!", 10, 10 + 15 * 1);
+ font->print(u8"こんにちは世界!", 10, 10 + 15 * 2);
+ font->print(u8"你好世界!", 10, 10 + 15*3);
glColor4f(1, 1, 1, 1);
}
- //shader->unuse();
+ shader->unuse();
//Canvas::unbind();
//canvas->draw(0, 0, 2, 2, 0);
}
@@ -78,7 +81,7 @@ int main(int argc, char* argv[])
Window::Setting wndSetting;
wndSetting.width = 600;
wndSetting.height = 512;
- wndSetting.title = "test";
+ wndSetting.title = "Jin v0.1.1";
wndSetting.fps = 60;
wndSetting.vsync = false;
wndSetting.fullscreen = false;