From 4cb109f59206d09b7bf9a6a0c562d8f52c10ef39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 6 Oct 2020 13:03:48 +0200 Subject: [PATCH] python: add remaining gl.Renderer.set_blend*() overloads and a test. --- src/python/magnum/gl.cpp | 22 +++++++++++++++++++--- src/python/magnum/test/test_gl_gl.py | 4 ++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/python/magnum/gl.cpp b/src/python/magnum/gl.cpp index 71beeb4..8d3cafd 100644 --- a/src/python/magnum/gl.cpp +++ b/src/python/magnum/gl.cpp @@ -939,9 +939,25 @@ void gl(py::module& m) { .def_static("enable", static_cast(GL::Renderer::enable), "Enable a feature") .def_static("disable", static_cast(GL::Renderer::disable), "Disable a feature") .def_static("set_feature", static_cast(GL::Renderer::setFeature), "Enable or disable a feature") - .def_static("set_blend_equation", static_cast(GL::Renderer::setBlendEquation), "Set blend equation") - .def_static("set_blend_function", static_cast(GL::Renderer::setBlendFunction), "Set blend function") - /** @todo indexed variants */ + /** @todo indexed variants of enable/disable/set_feature (needs + deprecation of the original ones and making draw_buffer first + so it's consistent with the rest) */ + .def_static("set_blend_equation", static_cast(GL::Renderer::setBlendEquation), "Set blend equation", py::arg("equation")) + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) + .def_static("set_blend_equation", static_cast(GL::Renderer::setBlendEquation), "Set blend equation for given draw buffer", py::arg("draw_buffer"), py::arg("equation")) + #endif + .def_static("set_blend_equation", static_cast(GL::Renderer::setBlendEquation), "Set blend equation separately for RGB and alpha components", py::arg("rgb"), py::arg("alpha")) + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) + .def_static("set_blend_equation", static_cast(GL::Renderer::setBlendEquation), "Set blend equation for given draw buffer separately for RGB and alpha components", py::arg("draw_buffer"), py::arg("rgb"), py::arg("alpha")) + #endif + .def_static("set_blend_function", static_cast(GL::Renderer::setBlendFunction), "Set blend function", py::arg("source"), py::arg("destination")) + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) + .def_static("set_blend_function", static_cast(GL::Renderer::setBlendFunction), "Set blend function for given draw buffer", py::arg("draw_buffer"), py::arg("source"), py::arg("destination")) + #endif + .def_static("set_blend_function", static_cast(GL::Renderer::setBlendFunction), "Set blend function separately for RGB and alpha components", py::arg("source_rgb"), py::arg("destination_rgb"), py::arg("source_alpha"), py::arg("destination_alpha")) + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) + .def_static("set_blend_function", static_cast(GL::Renderer::setBlendFunction), "Set blend function separately for RGB and alpha components", py::arg("draw_buffer"), py::arg("source_rgb"), py::arg("destination_rgb"), py::arg("source_alpha"), py::arg("destination_alpha")) + #endif /** @todo FFS why do I have to pass the class as first argument?! */ .def_property_static("clear_color", nullptr, [](py::object, const Color4& color) { diff --git a/src/python/magnum/test/test_gl_gl.py b/src/python/magnum/test/test_gl_gl.py index c9cab23..c109227 100644 --- a/src/python/magnum/test/test_gl_gl.py +++ b/src/python/magnum/test/test_gl_gl.py @@ -285,6 +285,10 @@ class Renderer(GLTestCase): def test_error(self): self.assertEqual(gl.Renderer.error, gl.Renderer.Error.NO_ERROR) + def test_blend(self): + gl.Renderer.set_blend_equation(gl.Renderer.BlendEquation.ADD) + gl.Renderer.set_blend_function(gl.Renderer.BlendFunction.SOURCE_ALPHA, gl.Renderer.BlendFunction.ONE_MINUS_SOURCE_ALPHA) + class Shader(GLTestCase): def test(self): if magnum.TARGET_GLES2: