X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=fishladder.c;h=bc755e80cf915b3bedfe93fef527f92b3e1b460e;hb=684ee6fcb34db7c58a7e845d33a19d8fb0cccfd3;hp=70448bc43d718d2fcf759a07eca9e0fa45de9642;hpb=00bd0600086421b4e1a24cd7e5d44729b8ebb9f4;p=fishladder.git diff --git a/fishladder.c b/fishladder.c index 70448bc..bc755e8 100644 --- a/fishladder.c +++ b/fishladder.c @@ -6,14 +6,14 @@ SHADER_DEFINE( colour_shader, // VERTEX - "layout (location=0) in vec3 a_co;" + "layout (location=0) in vec2 a_co;" "uniform mat4 uPv;" "uniform mat4 uMdl;" "" "void main()" "{" - " vec4 vert_pos = uPv * uMdl * vec4( a_co, 1.0 );" - " gl_Position = vert_pos;" + " vec4 vert_pos = uPv * uMdl * vec4( a_co.x, 0.0, a_co.y, 1.0 );" + " gl_Position = vert_pos;" "}", // FRAGMENT @@ -22,12 +22,33 @@ SHADER_DEFINE( colour_shader, "" "void main()" "{" - " FragColor = uColour;" + " FragColor = uColour;" "}" , UNIFORMS({ "uPv", "uMdl", "uColour" }) ) +/* +SHADER_DEFINE( tilemap_shader, + + // VERTEX + "layout (location=0) in vec2 a_co;" + "uniform mat4 uPv;" + "uniform vec4 uTextureInfo;" // Cell dx,dy 1.0/mx, 1.0/my + "uniform " + "" + "uniform vec2 uPosition;" + "uniform int uCellIndex;" + "" + "out vec2 s_uv;" + "" + "void main()" + "{" + " gl_Position = uPv * vec4( uPosition.x + a_co.x, 0.0, uPosition.y + a_co.y, 0.0 );" + " s_uv = vec2( mod( uCellIndex," + "}" +*/ + mat4 m_projection; mat4 m_view; mat4 m_mdl; @@ -82,6 +103,9 @@ static struct u32 flags; } stack; + + GLuint tile_texture; + GLuint flow_texture; } map; @@ -404,12 +428,8 @@ void vg_start(void) float quad_mesh[] = { - -0.5f, 0.f, -0.5f, - -0.5f, 0.f, 0.5f, - 0.5f, 0.f, 0.5f, - -0.5f, 0.f, -0.5f, - 0.5f, 0.f, 0.5f, - 0.5f, 0.f, -0.5f + 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, + 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f }; glBindVertexArray( tile_vao ); @@ -422,11 +442,14 @@ void vg_start(void) GL_STATIC_DRAW ); - glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0 ); + glVertexAttribPointer( 0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), (void*)0 ); glEnableVertexAttribArray( 0 ); VG_CHECK_GL(); + map.tile_texture = vg_tex2d_rgba( "textures/rivertiles_flowm.tga" ); + map.flow_texture = vg_tex2d_rgba( "textures/rivertiles_ripple.tga" ); + map_load ( "#####-#####;aa\n" @@ -442,6 +465,9 @@ void vg_start(void) void vg_free(void) { map_free(); + + glDeleteTextures( 1, &map.tile_texture ); + glDeleteTextures( 1, &map.flow_texture ); } void vg_ui(void)