From 79ac50e11acc89b1ed87c910a1555983e84e03cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 15 Sep 2019 10:12:41 +0200 Subject: [PATCH] python: expose gl.Renderer.error. Need that for tests. --- src/python/magnum/gl.cpp | 25 ++++++++++++++++++++----- src/python/magnum/test/test_gl_gl.py | 3 +++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/python/magnum/gl.cpp b/src/python/magnum/gl.cpp index 0ee769e..b32937e 100644 --- a/src/python/magnum/gl.cpp +++ b/src/python/magnum/gl.cpp @@ -646,6 +646,19 @@ void gl(py::module& m) { { py::class_ renderer{m, "Renderer", "Global renderer configuration"}; + py::enum_{renderer, "Error", "Error status"} + .value("NO_ERROR", GL::Renderer::Error::NoError) + .value("INVALID_ENUM", GL::Renderer::Error::InvalidEnum) + .value("INVALID_VALUE", GL::Renderer::Error::InvalidValue) + .value("INVALID_OPERATION", GL::Renderer::Error::InvalidOperation) + .value("INVALID_FRAMEBUFFER_OPERATION", GL::Renderer::Error::InvalidFramebufferOperation) + .value("OUT_OF_MEMORY", GL::Renderer::Error::OutOfMemory) + #ifndef MAGNUM_TARGET_WEBGL + .value("STACK_UNDERFLOW", GL::Renderer::Error::StackUnderflow) + .value("STACK_OVERFLOW", GL::Renderer::Error::StackOverflow) + #endif + ; + py::enum_{renderer, "Feature", "Feature"} #ifndef MAGNUM_TARGET_WEBGL .value("BLEND_ADVANCED_COHERENT", GL::Renderer::Feature::BlendAdvancedCoherent) @@ -693,11 +706,13 @@ void gl(py::module& m) { .def_static("disable", GL::Renderer::disable, "Disable a feature") .def_static("set_feature", GL::Renderer::setFeature, "Enable or disable a feature") - .def_property_static("clear_color", nullptr, - [](py::object, const Color4& color) { - /** @todo why can't it be just a single param? */ - GL::Renderer::setClearColor(color); - }, "Set clear color"); + /** @todo FFS why do I have to pass the class as first argument?! */ + .def_property_static("clear_color", nullptr, [](py::object, const Color4& color) { + GL::Renderer::setClearColor(color); + }, "Set clear color") + .def_property_readonly_static("error", [](py::object) { + return GL::Renderer::error(); + }, "Error status"); } } diff --git a/src/python/magnum/test/test_gl_gl.py b/src/python/magnum/test/test_gl_gl.py index b5c4e77..660bf3c 100644 --- a/src/python/magnum/test/test_gl_gl.py +++ b/src/python/magnum/test/test_gl_gl.py @@ -210,6 +210,9 @@ class Renderer(GLTestCase): gl.Renderer.disable(gl.Renderer.Feature.FACE_CULLING) gl.Renderer.set_feature(gl.Renderer.Feature.STENCIL_TEST, True) + def test_error(self): + self.assertEqual(gl.Renderer.error, gl.Renderer.Error.NO_ERROR) + class Shader(GLTestCase): def test(self): if magnum.TARGET_GLES2: