medfall

A super great game engine
Log | Files | Refs

commit ed9bb5b63711e2fe74449c41c3884d7fb40aed7d
parent fcbe68c1337ee1d775e40d0f9f071141b16c01e8
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sat Jul 22 10:27:25 +0300

draw_text takes integer coordinates

Diffstat:
hm.cc | 2+-
text_renderer.cc | 7+++++--
text_renderer.h | 2+-
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/hm.cc b/hm.cc @@ -408,6 +408,6 @@ GAME_FRAME( game_frame ) { const str< 128 > status( "Frame time: {.1}ms FPS: {.1} {} {.1}", dt * 1000.0f, 1.0f / dt, connected ? "connected!" : "connecting", game->pos ); - draw_text( status.c_str(), 2.0f, 2.0f, 16.0f ); + draw_text( status.c_str(), 2, 2, 16.0f ); } } diff --git a/text_renderer.cc b/text_renderer.cc @@ -61,7 +61,7 @@ void text_renderer_init() { ub_window = renderer_new_ub(); } -void draw_text( const char * str, float x, float y, float pixel_size ) { +void draw_text( const char * str, int x, int y, float pixel_size ) { const v4 white( 1, 1, 1, 1 ); ImmediateContext imm; @@ -80,9 +80,12 @@ void draw_text( const char * str, float x, float y, float pixel_size ) { float left = x; float top = y + ascent; + float fx = float( x ); + float fy = float( y ); + while( *str != '\0' ) { stbtt_aligned_quad q; - stbtt_GetBakedQuad( sizes[ size_idx ].baked_chars, 512, 256, *str - ' ', &x, &y, &q, 1 ); + stbtt_GetBakedQuad( sizes[ size_idx ].baked_chars, 512, 256, *str - ' ', &fx, &fy, &q, 1 ); ImmediateVertex tl = { v3( left + scale * ( q.x0 - left ), top + scale * ( q.y0 - y ), 0 ), diff --git a/text_renderer.h b/text_renderer.h @@ -1,5 +1,5 @@ #pragma once void text_renderer_init(); -void draw_text( const char * str, float x, float y, float pixel_size ); +void draw_text( const char * str, int x, int y, float pixel_size ); void text_renderer_term();