From e3de3ba5162f7ddd5005911124d4333e140fd984 Mon Sep 17 00:00:00 2001 From: navewindre Date: Thu, 27 Nov 2025 17:19:02 +0100 Subject: bunch o stuff --- src/render/gl_2d.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/render/gl_2d.cpp') diff --git a/src/render/gl_2d.cpp b/src/render/gl_2d.cpp index 1803eb5..78af1da 100644 --- a/src/render/gl_2d.cpp +++ b/src/render/gl_2d.cpp @@ -104,25 +104,33 @@ void gl_2d_textured_frect( GL_SHADER_PROGRAM* gl2d, VEC2 origin, VEC2 dim, GL_TE glBindBuffer( GL_ARRAY_BUFFER, gl2d->gl->vbuffer ); glBufferData( GL_ARRAY_BUFFER, sizeof(vertices), &vertices[0], GL_DYNAMIC_DRAW ); + I32 position = glGetAttribLocation( gl2d->id, "in_pos" ); + I32 color = glGetAttribLocation( gl2d->id, "in_col" ); + I32 texcoord = glGetAttribLocation( gl2d->id, "in_texcoord" ); + I32 sampler = glGetAttribLocation( gl2d->id, "in_sampler" ); + glEnableVertexAttribArray( position ); glVertexAttribPointer( position, 2, GL_FLOAT, 0, sizeof(VERTEX), 0 ); - I32 color = glGetAttribLocation( gl2d->id, "in_col" ); + glEnableVertexAttribArray( color ); glVertexAttribPointer( color, 4, GL_FLOAT, 0, sizeof(VERTEX), &( (VERTEX*)nullptr)->clr ); - I32 texcoord = glGetAttribLocation( gl2d->id, "in_texcoord" ); + glEnableVertexAttribArray( texcoord ); glVertexAttribPointer( texcoord, 2, GL_FLOAT, 0, sizeof(VERTEX), &( (VERTEX*)nullptr)->uv ); - I32 sampler = glGetAttribLocation( gl2d->id, "in_sampler" ); + glEnableVertexAttribArray( sampler ); glVertexAttribPointer( sampler, 1, GL_UNSIGNED_BYTE, 1, sizeof(VERTEX), &( (VERTEX*)nullptr)->sampler ); + glActiveTexture( GL_TEXTURE0 ); + glBindTexture( GL_TEXTURE_2D, texture->id ); + glBindBuffer( GL_ARRAY_BUFFER, 0 ); glActiveTexture( GL_TEXTURE0 ); glBindTexture( GL_TEXTURE_2D, texture->id ); - glUniform1f( glGetUniformLocation( gl2d->id, "in_time" ), u_time() ); + // glUniform1f( glGetUniformLocation( gl2d->id, "in_time" ), u_time() ); glDrawElements( GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_SHORT, order ); glBindTexture( GL_TEXTURE_2D, 0 ); -- cgit v1.2.3