- 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f,
- 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f,
-
- // Padding
- 0.0f, 0.0f, 0.0f, 0.0f
- };
-
- glBindVertexArray( tile_vao );
- glBindBuffer( GL_ARRAY_BUFFER, tile_vbo );
- glBufferData
- (
- GL_ARRAY_BUFFER,
- sizeof( quad_mesh ),
- quad_mesh,
- GL_STATIC_DRAW
- );
-
- glVertexAttribPointer( 0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), (void*)0 );
- glEnableVertexAttribArray( 0 );
-
- VG_CHECK_GL();
-
- // Create map buffers
- glGenVertexArrays( 1, &map.tiles_vao );
- glGenBuffers( 1, &map.tiles_vbo );
-
- glBindVertexArray( map.tiles_vao );
- glBindBuffer( GL_ARRAY_BUFFER, map.tiles_vbo );
- glBufferData( GL_ARRAY_BUFFER,
- sizeof( quad_mesh ) +
- sizeof( float )*2 * 1024 +
- sizeof( u8 )*4 * 1024,
- NULL,
- GL_DYNAMIC_DRAW
- );
-
- glBufferSubData( GL_ARRAY_BUFFER, 0, sizeof( quad_mesh ), quad_mesh );
-
- // Base quad
- glVertexAttribPointer( 0, 2, GL_FLOAT, GL_FALSE, 2*sizeof(float), (void*)0 );
- glEnableVertexAttribArray( 0 );
-
- // Offset, data arrays (instancing)
- glVertexAttribPointer( 1, 2, GL_FLOAT, GL_FALSE, 2*sizeof(float), (void*)(sizeof(quad_mesh)) );
- glEnableVertexAttribArray( 1 );
- glVertexAttribDivisor( 1, 1 );
-
- glVertexAttribPointer( 2, 4, GL_UNSIGNED_BYTE, GL_FALSE, 4, (void*)(sizeof(quad_mesh)+sizeof(float)*2*1024) );
- glEnableVertexAttribArray( 2 );
- glVertexAttribDivisor( 2, 1 );
-
- map.tile_texture = vg_tex2d_rgba( "textures/rivertiles_flowm.tga" );
- vg_tex2d_nearest();
- vg_tex2d_repeat();
-
- map.flow_texture = vg_tex2d_rgba( "textures/rivertiles_ripple.tga" );
- vg_tex2d_nearest();
- vg_tex2d_repeat();
-
- map_load
- (
- "##-#####-##;aaa,aa\n"
- "# #;\n"
- "# #;\n"
- "# #;\n"
- "# #;\n"
- "# #;\n"
- "# #;\n"
- "##+#####+##;aa,aaa\n"
- );
-}
-
-void vg_free(void)
-{
- map_free();
-
- glDeleteVertexArrays( 1, &tile_vao );
- glDeleteVertexArrays( 1, &map.tiles_vao );
-
- glDeleteBuffers( 1, &tile_vbo );
- glDeleteBuffers( 1, &map.tiles_vbo );
-
- glDeleteTextures( 1, &map.tile_texture );
- glDeleteTextures( 1, &map.flow_texture );