textures/loading
[fishladder.git] / fishladder.c
index 70448bc43d718d2fcf759a07eca9e0fa45de9642..bc755e80cf915b3bedfe93fef527f92b3e1b460e 100644 (file)
@@ -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)