Browse Source

python: use writeonly properties for shader uniform setters.

This practically means we depend on pybind11 2.3 now.
pull/2/head
Vladimír Vondruš 7 years ago
parent
commit
a38b14870f
  1. 32
      src/python/magnum/shaders.cpp

32
src/python/magnum/shaders.cpp

@ -54,11 +54,7 @@ template<UnsignedInt dimensions> void vertexColor(NonDestructibleBase<Shaders::V
/* Using lambdas to avoid method chaining getting into signatures */ /* Using lambdas to avoid method chaining getting into signatures */
// TODO: make writeonly once https://github.com/pybind/pybind11/pull/1144 .def_property("transformation_projection_matrix", nullptr, &Shaders::VertexColor<dimensions>::setTransformationProjectionMatrix,
// is released
.def_property("transformation_projection_matrix", [](Shaders::VertexColor<dimensions>&) {
return MatrixTypeFor<dimensions, Float>{};
}, &Shaders::VertexColor<dimensions>::setTransformationProjectionMatrix,
"Transformation and projection matrix"); "Transformation and projection matrix");
} }
@ -127,33 +123,27 @@ void shaders(py::module& m) {
}, "Flags") }, "Flags")
.def_property_readonly("light_count", &Shaders::Phong::lightCount, .def_property_readonly("light_count", &Shaders::Phong::lightCount,
"Light count") "Light count")
// TODO: make write-only once https://github.com/pybind/pybind11/pull/1144 .def_property("ambient_color", nullptr,
// is released
.def_property("ambient_color", [](Shaders::Phong&) { return Color4{}; },
&Shaders::Phong::setAmbientColor, "Ambient color") &Shaders::Phong::setAmbientColor, "Ambient color")
.def_property("diffuse_color", [](Shaders::Phong&) { return Color4{}; }, .def_property("diffuse_color", nullptr,
&Shaders::Phong::setDiffuseColor, "Diffuse color") &Shaders::Phong::setDiffuseColor, "Diffuse color")
.def_property("specular_color", [](Shaders::Phong&) { return Color4{}; }, .def_property("specular_color", nullptr,
&Shaders::Phong::setSpecularColor, "Specular color") &Shaders::Phong::setSpecularColor, "Specular color")
// TODO: textures, once exposed // TODO: textures, once exposed
.def_property("shininess", [](Shaders::Phong&) { return Float{}; }, .def_property("shininess", nullptr,
&Shaders::Phong::setShininess, "Shininess") &Shaders::Phong::setShininess, "Shininess")
.def_property("alpha_mask", [](Shaders::Phong&) { return Float{}; }, .def_property("alpha_mask", nullptr,
&Shaders::Phong::setAlphaMask, "Alpha mask") &Shaders::Phong::setAlphaMask, "Alpha mask")
.def_property("transformation_matrix", [](Shaders::Phong&) { return Matrix4{}; }, .def_property("transformation_matrix", nullptr,
&Shaders::Phong::setTransformationMatrix, "Set transformation matrix") &Shaders::Phong::setTransformationMatrix, "Set transformation matrix")
.def_property("normal_matrix", [](Shaders::Phong&) { return Matrix3x3{}; }, .def_property("normal_matrix", nullptr,
&Shaders::Phong::setNormalMatrix, "Set normal matrix") &Shaders::Phong::setNormalMatrix, "Set normal matrix")
.def_property("projection_matrix", [](Shaders::Phong&) { return Matrix4{}; }, .def_property("projection_matrix", nullptr,
&Shaders::Phong::setProjectionMatrix, "Set projection matrix") &Shaders::Phong::setProjectionMatrix, "Set projection matrix")
.def_property("light_positions", [](Shaders::Phong&) { .def_property("light_positions", nullptr, [](Shaders::Phong& self, const std::vector<Vector3>& positions) {
return std::vector<Vector3>{};
}, [](Shaders::Phong& self, const std::vector<Vector3>& positions) {
self.setLightPositions(positions); self.setLightPositions(positions);
}, "Light positions") }, "Light positions")
.def_property("light_colors", [](Shaders::Phong&) { .def_property("light_colors", nullptr, [](Shaders::Phong& self, const std::vector<Color4>& colors) {
return std::vector<Color4>{};
}, [](Shaders::Phong& self, const std::vector<Color4>& colors) {
self.setLightColors(colors); self.setLightColors(colors);
}, "Light colors"); }, "Light colors");
} }

Loading…
Cancel
Save