diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-09 16:17:23 +0100 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-09 16:17:23 +0100 |
| commit | 1febb02d958fa4cf8c15e3ca18f9d644f9fc80fb (patch) | |
| tree | d9b389f6c2ff8e031bd70d503c289bcfddf2f048 /draw/wireframe.cpp | |
| parent | 09605450ecc99ad1f4d50e9c143fda6c7762e702 (diff) | |
depth buffer works!
Diffstat (limited to 'draw/wireframe.cpp')
| -rw-r--r-- | draw/wireframe.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/draw/wireframe.cpp b/draw/wireframe.cpp index 053fce7b..bf024f9e 100644 --- a/draw/wireframe.cpp +++ b/draw/wireframe.cpp @@ -27,16 +27,21 @@ GL::Texture2D mesh_base::make_constant_texture() return tex; } +struct constant_buf { + Vector2 texcoords; + float depth = 1; +}; + mesh_base::mesh_base(GL::MeshPrimitive primitive, ArrayView<const void> index_data, std::size_t num_vertices, std::size_t num_indexes) : _vertex_buffer{Containers::Array<Vector3>{ValueInit, num_vertices}, GL::BufferUsage::DynamicDraw}, - _texcoords_buffer{Containers::Array<Vector2>{ValueInit, num_vertices}}, + _constant_buffer{Containers::Array<constant_buf>{ValueInit, num_vertices}}, _index_buffer{num_indexes == 0 ? GL::Buffer{NoCreate} : GL::Buffer{index_data}} { _mesh.setCount((int)(num_indexes > 0 ? num_indexes : num_vertices)) .setPrimitive(primitive) .addVertexBuffer(_vertex_buffer, 0, tile_shader::Position{}) - .addVertexBuffer(_texcoords_buffer, 0, tile_shader::TextureCoordinates{}); + .addVertexBuffer(_constant_buffer, 0, tile_shader::TextureCoordinates{}, tile_shader::Depth{}); if (num_indexes > 0) _mesh.setIndexBuffer(_index_buffer, 0, GL::MeshIndexType::UnsignedShort); } |
