summaryrefslogtreecommitdiff
path: root/src/render/gl_2d_font.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/render/gl_2d_font.cpp')
-rw-r--r--src/render/gl_2d_font.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/render/gl_2d_font.cpp b/src/render/gl_2d_font.cpp
index 1dc498b..10ae71a 100644
--- a/src/render/gl_2d_font.cpp
+++ b/src/render/gl_2d_font.cpp
@@ -210,22 +210,27 @@ void gl_font_draw( GL_FONT* font, GL_SHADER_PROGRAM* shader, VEC2 origin, const
glBindBuffer( GL_ARRAY_BUFFER, shader->gl->vbuffer );
glBufferData( GL_ARRAY_BUFFER, sizeof(VERTEX) * 6 * len, vertices, GL_STATIC_DRAW );
+
I32 position = glGetAttribLocation( shader->id, "in_pos" );
+ I32 color = glGetAttribLocation( shader->id, "in_clr" );
+ I32 texcoord = glGetAttribLocation( shader->id, "in_texcoord" );
+ I32 sampler = glGetAttribLocation( shader->id, "in_sampler" );
+
glEnableVertexAttribArray( position );
glVertexAttribPointer( position, 2, GL_FLOAT, 0, sizeof(VERTEX), &( (VERTEX*)nullptr)->pos );
- I32 color = glGetAttribLocation( shader->id, "in_clr" );
glEnableVertexAttribArray( color );
glVertexAttribPointer( color, 4, GL_FLOAT, 0, sizeof(VERTEX), &( (VERTEX*)nullptr)->clr );
- I32 texcoord = glGetAttribLocation( shader->id, "in_texcoord" );
glEnableVertexAttribArray( texcoord );
glVertexAttribPointer( texcoord, 2, GL_FLOAT, 0, sizeof(VERTEX), &( (VERTEX*)nullptr)->uv );
- I32 sampler = glGetAttribLocation( shader->id, "in_sampler" );
glEnableVertexAttribArray( sampler );
glVertexAttribPointer( sampler, 1, GL_UNSIGNED_BYTE, 1, sizeof(VERTEX), &( (VERTEX*)nullptr)->sampler );
+ glActiveTexture( GL_TEXTURE0 );
+ glBindTexture( GL_TEXTURE_2D, font->atlas->id );
+
glBindBuffer( GL_ARRAY_BUFFER, 0 );
glActiveTexture( GL_TEXTURE0 );
@@ -234,7 +239,7 @@ void gl_font_draw( GL_FONT* font, GL_SHADER_PROGRAM* shader, VEC2 origin, const
glDrawElements( GL_TRIANGLES, len * 6, GL_UNSIGNED_SHORT, indices );
glBindTexture( GL_TEXTURE_2D, 0 );
-
+
free( vertices );
free( indices );
free( coords );