[update] Improved the text rendering engine.
This commit is contained in:
parent
6f6b08c06b
commit
3c441d5a5d
@ -41,17 +41,17 @@ class ResultScene : SceneInterface {
|
||||
enum CubeInterval = 0.005;
|
||||
|
||||
///
|
||||
enum DescTextScale = vec3(-0.002, 0.002, 0.002);
|
||||
enum DescTextScale = vec3(-0.1, 0.1, 0.1);
|
||||
///
|
||||
enum DescTextTranslation = vec3(0, -0.3, 0);
|
||||
///
|
||||
enum DescTextColor = vec4(0.2, 0.2, 0.2, 1);
|
||||
///
|
||||
enum RankTextScale = vec3(-0.002, 0.002, 0.002);
|
||||
enum RankTextScale = vec3(-0.1, 0.1, 0.1);
|
||||
///
|
||||
enum RankTextTranslation = vec3(0, -0.5, 0);
|
||||
///
|
||||
enum ScoreTextScale = vec3(-0.002, 0.002, 0.002);
|
||||
enum ScoreTextScale = vec3(-0.1, 0.1, 0.1);
|
||||
///
|
||||
enum ScoreTextTranslation = vec3(0, -0.55, 0);
|
||||
|
||||
|
@ -28,11 +28,11 @@ import sj.FontSet,
|
||||
class SelectScene : SceneInterface {
|
||||
public:
|
||||
///
|
||||
enum DescTextScale = vec3(-0.002, 0.002, 0.002);
|
||||
enum DescTextScale = vec3(-0.1, 0.1, 0.1);
|
||||
///
|
||||
enum DescTextTranslation = vec3(0, -0.3, 0);
|
||||
///
|
||||
enum DescTextColor = vec4(0.02, 0.02, 0.02, 1);
|
||||
enum DescTextColor = vec4(0.2, 0.2, 0.2, 1);
|
||||
|
||||
///
|
||||
this(LobbyWorld lobby, ProgramSet program, FontSet fonts, Music[] music_list) {
|
||||
@ -140,7 +140,7 @@ private abstract class AbstractSceneState {
|
||||
enum LoadingCubeInterval = 0.06;
|
||||
|
||||
enum TitleTextSize = 40;
|
||||
enum TitleTextScale = vec3(-0.002, 0.002, 0.002);
|
||||
enum TitleTextScale = vec3(-0.1, 0.1, 0.1);
|
||||
enum TitleTextTranslation = vec3(0, -0.4, 0);
|
||||
|
||||
enum TitleTextRandomTranslationRange = 0.02;
|
||||
@ -293,12 +293,6 @@ private class MusicWaitState : AbstractSceneState {
|
||||
void Initialize(size_t music_index) {
|
||||
music_index_ = music_index;
|
||||
music.PlayForPreview();
|
||||
|
||||
with (owner.title_text_) {
|
||||
matrix.scale = TitleTextScale;
|
||||
matrix.translation =
|
||||
TitleTextTranslation + vec3(-modelWidth/2*matrix.scale.x, 0, 0);
|
||||
}
|
||||
}
|
||||
override UpdateResult Update(KeyInput input) {
|
||||
owner.lobby_.cube_matrix.rotation += CubeRotationSpeed;
|
||||
|
@ -47,31 +47,37 @@ class Text {
|
||||
int bmp_width;
|
||||
size_t glyph_count;
|
||||
foreach (c; text) {
|
||||
if (c == ' ') continue;
|
||||
|
||||
with (gloader) {
|
||||
character = c;
|
||||
Load(face).enforce;
|
||||
}
|
||||
|
||||
const m = &face.glyph.metrics;
|
||||
const mwidth = m.width *1f / face.max_advance_width;
|
||||
const mheight = m.height *1f / face.max_advance_width;
|
||||
const advance = m.horiAdvance *1f / face.max_advance_width;
|
||||
const bear_x = m.horiBearingX*1f / face.max_advance_width;
|
||||
const bear_y = m.horiBearingY*1f / face.max_advance_width;
|
||||
|
||||
if (mwidth == 0 || mheight == 0) {
|
||||
model_width_ += advance;
|
||||
continue;
|
||||
}
|
||||
|
||||
const bitmap = face.EnforceGlyphBitmap();
|
||||
const srcsz = vec2i(bitmap.width, bitmap.rows);
|
||||
CopyRawPixels(bitmap.buffer, srcsz, pixels.ptr, texsz, vec2i(bmp_width, 0));
|
||||
|
||||
const m = &face.glyph.metrics;
|
||||
const bearing_x = m.horiBearingX*1f / m.width * srcsz.x;
|
||||
const bearing_y = m.horiBearingY*1f / m.height * srcsz.y;
|
||||
const advance = m.horiAdvance *1f / m.width * srcsz.x;
|
||||
|
||||
const posleft = model_width_ + bearing_x;
|
||||
const posright = posleft + srcsz.x;
|
||||
const postop = bearing_y;
|
||||
const posbottom = postop - srcsz.y;
|
||||
|
||||
const uvleft = bmp_width*1f / texsz.x;
|
||||
const uvright = (bmp_width + srcsz.x)*1f / texsz.x;
|
||||
const uvtop = 0f;
|
||||
const uvbottom = srcsz.y*1f / texsz.y;
|
||||
|
||||
const posleft = model_width_ + bear_x;
|
||||
const posright = posleft + mwidth;
|
||||
const postop = bear_y;
|
||||
const posbottom = postop - mheight;
|
||||
|
||||
*vertices_ptr++ = posleft;
|
||||
*vertices_ptr++ = postop;
|
||||
*vertices_ptr++ = 0;
|
||||
|
Reference in New Issue
Block a user