From 0965f3958d18c76b9500c8aa8a80ea870110f924 Mon Sep 17 00:00:00 2001 From: drewcassidy Date: Mon, 29 Mar 2021 19:58:46 -0700 Subject: [PATCH] enable buffer protocol --- quicktex/_bindings.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quicktex/_bindings.cpp b/quicktex/_bindings.cpp index 7a446b6..c10a638 100644 --- a/quicktex/_bindings.cpp +++ b/quicktex/_bindings.cpp @@ -88,14 +88,14 @@ PYBIND11_MODULE(_quicktex, m) { py::options options; - py::class_ texture(m, "Texture"); + py::class_ texture(m, "Texture", py::buffer_protocol()); texture.def_property_readonly("size", &Texture::Size); texture.def_property_readonly("dimensions", &Texture::Dimensions); texture.def_property_readonly("width", &Texture::Width); texture.def_property_readonly("height", &Texture::Height); -// texture.def_buffer([](Texture &t) { return py::buffer_info(t.Data(), t.Size()); }); + texture.def_buffer([](Texture &t) { return py::buffer_info(t.Data(), t.Size()); }); texture.def("to_bytes", [](const Texture &t) { return py::bytes(reinterpret_cast(t.Data()), t.Size()); }); py::class_ raw_texture(m, "RawTexture", texture);