fix m2 boxes rendering on os x@

This commit is contained in:
Skarn
2020-10-09 22:27:50 +03:00
parent d4ca960e1c
commit 1589217700
36 changed files with 3350 additions and 5 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1 +1 @@
b65ee248a3646506898c35a0046e7452922b0007827d5e87f11c462b97c234a3
9cc1f248d245595dc0553c7d587584e78e017f9df8c2d94d5790305d8dfad898

View File

@@ -2,4 +2,4 @@
#pragma once
#define STRPRODUCTVER "3.4b8b34b3+"
#define STRPRODUCTVER "3.d4ca960+"

View File

@@ -1525,7 +1525,6 @@ void Model::draw_ribbons( opengl::scoped::use_program& ribbons_shader
void Model::draw_box (opengl::scoped::use_program& m2_box_shader, std::size_t box_count)
{
static std::vector<uint16_t> const indices ({5, 7, 3, 2, 0, 1, 3, 1, 5, 4, 0, 4, 6, 2, 6, 7});
opengl::scoped::vao_binder const _ (_box_vao);
@@ -1539,7 +1538,9 @@ void Model::draw_box (opengl::scoped::use_program& m2_box_shader, std::size_t bo
m2_box_shader.attrib("position", 3, GL_FLOAT, GL_FALSE, 0, 0);
}
gl.drawElementsInstanced (GL_LINE_STRIP, indices.size(), GL_UNSIGNED_SHORT, indices.data(), box_count);
opengl::scoped::buffer_binder<GL_ELEMENT_ARRAY_BUFFER> indices_binder(_box_indices_buffer);
gl.drawElementsInstanced (GL_LINE_STRIP, _box_indices.size(), GL_UNSIGNED_SHORT, nullptr, box_count);
}
@@ -1628,6 +1629,9 @@ void Model::upload()
opengl::scoped::buffer_binder<GL_ELEMENT_ARRAY_BUFFER> indices_binder(_indices_buffer);
gl.bufferData (GL_ELEMENT_ARRAY_BUFFER, _indices.size() * sizeof(uint16_t), _indices.data(), GL_STATIC_DRAW);
opengl::scoped::buffer_binder<GL_ELEMENT_ARRAY_BUFFER> box_indices_binder(_box_indices_buffer);
gl.bufferData (GL_ELEMENT_ARRAY_BUFFER, _box_indices.size() * sizeof(uint16_t), _box_indices.data(), GL_STATIC_DRAW);
_finished_upload = true;
}

View File

@@ -318,13 +318,16 @@ private:
std::vector<math::vector_3d> _vertex_box_points;
// buffers;
opengl::scoped::deferred_upload_buffers<4> _buffers;
opengl::scoped::deferred_upload_buffers<5> _buffers;
opengl::scoped::deferred_upload_vertex_arrays<2> _vertex_arrays;
std::vector<uint16_t> const _box_indices = {5, 7, 3, 2, 0, 1, 3, 1, 5, 4, 0, 4, 6, 2, 6, 7};
GLuint const& _vao = _vertex_arrays[0];
GLuint const& _transform_buffer = _buffers[0];
GLuint const& _vertices_buffer = _buffers[1];
GLuint const& _indices_buffer = _buffers[3];
GLuint const& _box_indices_buffer = _buffers[4];
GLuint const& _box_vao = _vertex_arrays[1];
GLuint const& _box_vbo = _buffers[2];