Browse Source

python: expose buffer objects owned by gl.Mesh.

Makes testing much easier.
pull/2/head
Vladimír Vondruš 7 years ago
parent
commit
d5379c10eb
  1. 4
      src/python/magnum/gl.cpp
  2. 2
      src/python/magnum/test/test_gl_gl.py

4
src/python/magnum/gl.cpp

@ -24,6 +24,7 @@
*/
#include <pybind11/pybind11.h>
#include <pybind11/stl.h> /* for Mesh.buffers */
#include <Corrade/Containers/ArrayView.h>
#include <Corrade/Utility/FormatStl.h>
#include <Magnum/GL/AbstractShaderProgram.h>
@ -247,7 +248,8 @@ void gl(py::module& m) {
self.draw(shader);
}, "Draw the mesh")
/** @todo more */
;
.def_readonly("buffers", &PyMesh::buffers, "Buffer objects referenced by the mesh");
/* Renderer */
{

2
src/python/magnum/test/test_gl_gl.py

@ -96,6 +96,8 @@ class Mesh(GLTestCase):
# Adding a buffer to the mesh should increase its ref count
mesh = gl.Mesh()
mesh.add_vertex_buffer(buffer, 0, 8, gl.Attribute(gl.Attribute.Kind.GENERIC, 2, gl.Attribute.Components.TWO, gl.Attribute.DataType.FLOAT))
self.assertEqual(len(mesh.buffers), 1)
self.assertIs(mesh.buffers[0], buffer)
self.assertEqual(sys.getrefcount(buffer), buffer_refcount + 1)
# Deleting the mesh should decrease it again

Loading…
Cancel
Save