Compare commits

..

3 Commits
master ... dev

  1. 14
      src/python/CMakeLists.txt
  2. 47
      src/python/magnum/gl.cpp
  3. 15
      src/python/magnum/scenegraph.cpp

14
src/python/CMakeLists.txt

@ -35,16 +35,10 @@ elseif(NOT pybind11_VERSION)
set(pybind11_VERSION ${PYBIND11_VERSION_MAJOR}.${PYBIND11_VERSION_MINOR}.${PYBIND11_VERSION_PATCH}) set(pybind11_VERSION ${PYBIND11_VERSION_MAJOR}.${PYBIND11_VERSION_MINOR}.${PYBIND11_VERSION_PATCH})
endif() endif()
# In pybind11 2.2.4 and below, pybind11_add_module() added the include # Newer pybind11 versions route pybind11_add_module() through FindPython and no
# directories as non-system. That, combined with Corrade's warning level, added # longer accept SYSTEM as a positional compatibility argument. Keep this empty
# an insane amount of warnings to the build. Since 2.3 it was possible to # in the Oasis superproject build.
# override that by passing SYSTEM to pybind11_add_module(), HOWEVER since 2.6 set(pybind11_add_module_SYSTEM)
# doing so causes an ANNOYING warning because they made that a default. That
# all in a span of barely two years. Can't things just stay stable for a little
# moment?!
if(pybind11_VERSION VERSION_LESS 2.6)
set(pybind11_add_module_SYSTEM SYSTEM)
endif()
# UGH FFS # UGH FFS
get_property(CMAKE_GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) get_property(CMAKE_GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)

47
src/python/magnum/gl.cpp

@ -35,6 +35,8 @@
#include <Magnum/GL/AbstractShaderProgram.h> #include <Magnum/GL/AbstractShaderProgram.h>
#include <Magnum/GL/Attribute.h> #include <Magnum/GL/Attribute.h>
#include <Magnum/GL/Buffer.h> #include <Magnum/GL/Buffer.h>
#include <Magnum/GL/BufferTexture.h>
#include <Magnum/GL/BufferTextureFormat.h>
#include <Magnum/GL/Context.h> #include <Magnum/GL/Context.h>
#include <Magnum/GL/DefaultFramebuffer.h> #include <Magnum/GL/DefaultFramebuffer.h>
#include <Magnum/GL/Framebuffer.h> #include <Magnum/GL/Framebuffer.h>
@ -792,6 +794,43 @@ void gl(py::module_& m) {
}, "Set buffer data", py::arg("data"), py::arg("usage") = GL::BufferUsage::StaticDraw) }, "Set buffer data", py::arg("data"), py::arg("usage") = GL::BufferUsage::StaticDraw)
/** @todo more */; /** @todo more */;
py::enum_<GL::BufferTextureFormat>{m, "BufferTextureFormat", "Buffer texture internal format"}
.value("R8", GL::BufferTextureFormat::R8)
.value("RG8", GL::BufferTextureFormat::RG8)
.value("RGBA8", GL::BufferTextureFormat::RGBA8)
#ifndef MAGNUM_TARGET_GLES
.value("R16", GL::BufferTextureFormat::R16)
.value("RG16", GL::BufferTextureFormat::RG16)
.value("RGBA16", GL::BufferTextureFormat::RGBA16)
#endif
.value("R8UI", GL::BufferTextureFormat::R8UI)
.value("RG8UI", GL::BufferTextureFormat::RG8UI)
.value("RGBA8UI", GL::BufferTextureFormat::RGBA8UI)
.value("R8I", GL::BufferTextureFormat::R8I)
.value("RG8I", GL::BufferTextureFormat::RG8I)
.value("RGBA8I", GL::BufferTextureFormat::RGBA8I)
.value("R16UI", GL::BufferTextureFormat::R16UI)
.value("RG16UI", GL::BufferTextureFormat::RG16UI)
.value("RGBA16UI", GL::BufferTextureFormat::RGBA16UI)
.value("R16I", GL::BufferTextureFormat::R16I)
.value("RG16I", GL::BufferTextureFormat::RG16I)
.value("RGBA16I", GL::BufferTextureFormat::RGBA16I)
.value("R32UI", GL::BufferTextureFormat::R32UI)
.value("RG32UI", GL::BufferTextureFormat::RG32UI)
.value("RGB32UI", GL::BufferTextureFormat::RGB32UI)
.value("RGBA32UI", GL::BufferTextureFormat::RGBA32UI)
.value("R32I", GL::BufferTextureFormat::R32I)
.value("RG32I", GL::BufferTextureFormat::RG32I)
.value("RGB32I", GL::BufferTextureFormat::RGB32I)
.value("RGBA32I", GL::BufferTextureFormat::RGBA32I)
.value("R16F", GL::BufferTextureFormat::R16F)
.value("RG16F", GL::BufferTextureFormat::RG16F)
.value("RGBA16F", GL::BufferTextureFormat::RGBA16F)
.value("R32F", GL::BufferTextureFormat::R32F)
.value("RG32F", GL::BufferTextureFormat::RG32F)
.value("RGB32F", GL::BufferTextureFormat::RGB32F)
.value("RGBA32F", GL::BufferTextureFormat::RGBA32F);
/* Renderbuffer */ /* Renderbuffer */
py::enum_<GL::RenderbufferFormat>{m, "RenderbufferFormat", "Internal renderbuffer format"} py::enum_<GL::RenderbufferFormat>{m, "RenderbufferFormat", "Internal renderbuffer format"}
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
@ -1383,6 +1422,14 @@ void gl(py::module_& m) {
texture(texture3D); texture(texture3D);
#endif #endif
py::class_<GL::BufferTexture, GL::AbstractTexture> bufferTexture{m, "BufferTexture", "Buffer texture"};
bufferTexture
.def(py::init(), "Constructor")
.def("set_buffer", [](GL::BufferTexture& self, GL::BufferTextureFormat internal_format, GL::Buffer& buffer) {
self.setBuffer(internal_format, buffer);
}, "Set buffer texture data", py::arg("internal_format"), py::arg("buffer"))
.def("reset_buffer", &GL::BufferTexture::resetBuffer, "Reset buffer texture data");
/* Framebuffer, needs to be after textures due to attach_texture() */ /* Framebuffer, needs to be after textures due to attach_texture() */
py::class_<GL::Framebuffer, GL::AbstractFramebuffer, GL::PyFramebufferHolder<GL::Framebuffer>> framebuffer{m, py::class_<GL::Framebuffer, GL::AbstractFramebuffer, GL::PyFramebufferHolder<GL::Framebuffer>> framebuffer{m,
"Framebuffer", "Framebuffer"}; "Framebuffer", "Framebuffer"};

15
src/python/magnum/scenegraph.cpp

@ -39,14 +39,13 @@ template<UnsignedInt dimensions, class T> struct PyDrawable: SceneGraph::PyFeatu
explicit PyDrawable(SceneGraph::AbstractObject<dimensions, T>& object, SceneGraph::DrawableGroup<dimensions, T>* drawables): SceneGraph::PyFeature<SceneGraph::Drawable<dimensions, T>>{object, drawables} {} explicit PyDrawable(SceneGraph::AbstractObject<dimensions, T>& object, SceneGraph::DrawableGroup<dimensions, T>* drawables): SceneGraph::PyFeature<SceneGraph::Drawable<dimensions, T>>{object, drawables} {}
void draw(const MatrixTypeFor<dimensions, T>& transformationMatrix, SceneGraph::Camera<dimensions, T>& camera) override { void draw(const MatrixTypeFor<dimensions, T>& transformationMatrix, SceneGraph::Camera<dimensions, T>& camera) override {
PYBIND11_OVERLOAD_PURE_NAME( py::gil_scoped_acquire gil;
void, py::function override = py::get_override(static_cast<const PyDrawable*>(this), "draw");
PyDrawable, if(!override) {
"draw", py::pybind11_fail("Tried to call pure virtual function \"PyDrawable::draw\"");
draw, }
transformationMatrix, override(transformationMatrix,
camera py::cast(&camera, py::return_value_policy::reference));
);
} }
}; };

Loading…
Cancel
Save