Jump to content

  • Log In with Google      Sign In   
  • Create Account


Instanced font rendering lib


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 Yours3!f   Members   -  Reputation: 1300

Like
1Likes
Like

Posted 14 December 2013 - 09:42 AM

Hi,

 

I made a font rendering library originally based on Shikoba.

 

It uses one texture, one vao, 5 vbos, and one draw call to draw text.
A screen full of text performs around 1ms on my PC (A8-4500m apu, 64 bit Xubuntu 12.04, composition disabled). Same performance on Win7 64 bit.

 

get it here (MIT licence):

https://github.com/Yours3lf/instanced_font_rendering

 

easy usage:
 

//load in the shaders with your method, get_shader() gives you a ref to the shader program
load_shader( font::get().get_shader(), GL_VERTEX_SHADER, "../shaders/font/font.vs" );
load_shader( font::get().get_shader(), GL_FRAGMENT_SHADER, "../shaders/font/font.ps" );

uvec2 screen = uvec2( 1280, 720 );

font_inst instance; //this holds your font type and the corresponding sizes
font::get().resize( screen ); //set screen size
font::get().load_font( "../resources/font.ttf", //where your font is
                       instance, //font will load your font into this instance
                       22 ); //the font size

vec3 color = vec3( 0.5, 0.8, 0.5 ); //rgb [0...1]
uvec2 pos = uvec2( 10, 20 ); //in pixels

std::wstring text = L"hello world\n"; //what to display

rendering:
while(true) //your ordinary rendering loop
{
clear_screen();
...
//optionally bind fbo here to render to texture
...
font::get().add_to_text( instance, text + L"_" ); //feed the font
font::get().render( instance, color, pos );
...
swap_buffers();
}

zsO7sST.png


Edited by Yours3!f, 14 December 2013 - 02:06 PM.


Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS