diff --git a/quicktex/s3tc/bc1/BC1Encoder.h b/quicktex/s3tc/bc1/BC1Encoder.h index 8c4e565..4e98265 100644 --- a/quicktex/s3tc/bc1/BC1Encoder.h +++ b/quicktex/s3tc/bc1/BC1Encoder.h @@ -46,8 +46,8 @@ class BC1Encoder final : public BlockEncoder> { using OrderingPair = std::tuple; using CBlock = ColorBlock<4, 4>; - inline static constexpr unsigned min_power_iterations = 4; - inline static constexpr unsigned max_power_iterations = 10; + static constexpr unsigned min_power_iterations = 4; + static constexpr unsigned max_power_iterations = 10; enum class ColorMode { // An incomplete block with invalid selectors or endpoints diff --git a/quicktex/s3tc/bc1/_bindings.cpp b/quicktex/s3tc/bc1/_bindings.cpp index 17ac3dc..5275133 100644 --- a/quicktex/s3tc/bc1/_bindings.cpp +++ b/quicktex/s3tc/bc1/_bindings.cpp @@ -108,7 +108,7 @@ void InitBC1(py::module_ &s3tc) { "when using a BC1 texture."); bc1_encoder.def(py::init(), "level"_a = 5, "color_mode"_a = BC1Encoder::ColorMode::FourColor); - bc1_encoder.def(py::init(), "level"_a, "color_mode"_a, "interpolator"_a, R"pbdoc( + bc1_encoder.def(py::init(), "level"_a, "color_mode"_a, "interpolator"_a, R"doc( __init__(self, level: int = 5, color_mode=ColorMode.FourColor, interpolator=Interpolator()) -> None Create a new BC1 encoder with the specified preset level, color mode, and interpolator. @@ -116,16 +116,25 @@ void InitBC1(py::module_ &s3tc) { :param int level: The preset level of the resulting encoder, between 0 and 18 inclusive. See :py:meth:`set_level` for more information. Default: 5. :param ColorMode color_mode: The color mode of the resulting BC1Encoder. Default: :py:class:`~quicktex.s3tc.bc1.BC1Encoder.ColorMode.FourColor`. :param Interpolator interpolator: The interpolation mode to use for encoding. Default: :py:class:`~quicktex.s3tc.interpolator.Interpolator`. - )pbdoc"); + )doc"); + + bc1_encoder.def("encode", &BC1Encoder::Encode, "texture"_a, R"doc( + encode(self, texture: RawTexture) -> BC1Texture + + Encode a raw texture into a new BC1Texture using the encoder's current settings. - bc1_encoder.def("set_level", &BC1Encoder::SetLevel, "level"_a, R"pbdoc( + :param RawTexture texture: Input texture to encode. + :returns: A new BC1Texture with the same dimension as the input. + )doc"); + + bc1_encoder.def("set_level", &BC1Encoder::SetLevel, "level"_a, R"doc( set_level(self, level : int = 5) -> None Select a preset quality level, between 0 and 18 inclusive. Higher quality levels are slower, but produce blocks that are a closer match to input. This has no effect on the size of the resulting texture, since BC1 is a fixed-ratio compression method. For better control, see the advanced API below :param int level: The preset level of the resulting encoder, between 0 and 18 inclusive. Default: 5. - )pbdoc"); + )doc"); bc1_encoder.def_property_readonly("interpolator", &BC1Encoder::GetInterpolator, "The :py:class:`~quicktex.s3tc.interpolator.Interpolator` used by this encoder. This is a readonly property."); @@ -173,14 +182,23 @@ void InitBC1(py::module_ &s3tc) { )doc"); bc1_decoder.def(py::init(), "write_alpha"_a = false); - bc1_decoder.def(py::init(), "write_alpha"_a, "interpolator"_a, R"pbdoc( + bc1_decoder.def(py::init(), "write_alpha"_a, "interpolator"_a, R"doc( __init__(self, interpolator = Interpolator()) -> None Create a new BC1 decoder with the specificied interpolator. :param bool write_alpha: Determines if the alpha channel of the output is written to. Default: False; :param Interpolator interpolator: The interpolation mode to use for decoding. Default: :py:class:`~quicktex.s3tc.interpolator.Interpolator`. - )pbdoc"); + )doc"); + + bc1_decoder.def("decode", &BC1Decoder::Decode, "texture"_a, R"doc( + decode(self, texture: BC1Texture) -> RawTexture + + Decode a BC1 texture into a new RawTexture using the decoder's current settings. + + :param RawTexture texture: Input texture to encode. + :returns: A new RawTexture with the same dimensions as the input + )doc"); bc1_decoder.def_property_readonly("interpolator", &BC1Decoder::GetInterpolator, "The interpolator used by this decoder. This is a readonly property."); bc1_decoder.def_readwrite("write_alpha", &BC1Decoder::write_alpha, "Determines if the alpha channel of the output is written to."); diff --git a/quicktex/s3tc/bc3/_bindings.cpp b/quicktex/s3tc/bc3/_bindings.cpp index a781e48..144fa75 100644 --- a/quicktex/s3tc/bc3/_bindings.cpp +++ b/quicktex/s3tc/bc3/_bindings.cpp @@ -89,6 +89,15 @@ void InitBC3(py::module_ &s3tc) { :param Interpolator interpolator: The interpolation mode to use for encoding. Default: :py:class:`~quicktex.s3tc.interpolator.Interpolator`. )doc"); + bc3_encoder.def("encode", &BC3Encoder::Encode, "texture"_a, R"doc( + encode(self, texture: RawTexture) -> BC3Texture + + Encode a raw texture into a new BC3Texture using the encoder's current settings. + + :param RawTexture texture: Input texture to encode. + :returns: A new BC3Texture with the same dimension as the input. + )doc"); + bc3_encoder.def_property_readonly("bc1_encoder", &BC3Encoder::GetBC1Encoder, "Internal :py:class:`~quicktex.s3tc.bc1.BC1Encoder` used for RGB data. Readonly."); bc3_encoder.def_property_readonly("bc4_encoder", &BC3Encoder::GetBC4Encoder, @@ -111,6 +120,15 @@ void InitBC3(py::module_ &s3tc) { :param Interpolator interpolator: The interpolation mode to use for decoding. Default: :py:class:`~quicktex.s3tc.interpolator.Interpolator`. )doc"); + bc3_decoder.def("decode", &BC3Decoder::Decode, "texture"_a, R"doc( + decode(self, texture: BC3Texture) -> RawTexture + + Decode a BC3 texture into a new RawTexture using the decoder's current settings. + + :param RawTexture texture: Input texture to encode. + :returns: A new RawTexture with the same dimensions as the input + )doc"); + bc3_decoder.def_property_readonly("bc1_decoder", &BC3Decoder::GetBC1Decoder, "Internal :py:class:`~quicktex.s3tc.bc1.BC1Decoder` used for RGB data. Readonly."); bc3_decoder.def_property_readonly("bc4_decoder", &BC3Decoder::GetBC4Decoder, diff --git a/quicktex/s3tc/bc4/_bindings.cpp b/quicktex/s3tc/bc4/_bindings.cpp index 4bf28a7..031f2d4 100644 --- a/quicktex/s3tc/bc4/_bindings.cpp +++ b/quicktex/s3tc/bc4/_bindings.cpp @@ -94,6 +94,16 @@ void InitBC4(py::module_ &s3tc) { :param int channel: the channel that will be read from. 0 to 3 inclusive. Default: 3 (alpha). )doc"); + + bc4_encoder.def("encode", &BC4Encoder::Encode, "texture"_a, R"doc( + encode(self, texture: RawTexture) -> BC4Texture + + Encode a raw texture into a new BC4Texture using the encoder's current settings. + + :param RawTexture texture: Input texture to encode. + :returns: A new BC4Texture with the same dimension as the input. + )doc"); + bc4_encoder.def_property_readonly("channel", &BC4Encoder::GetChannel, "The channel that will be read from. 0 to 3 inclusive. Readonly."); // endregion @@ -109,6 +119,16 @@ void InitBC4(py::module_ &s3tc) { :param int channel: The channel that will be written to. 0 to 3 inclusive. Default: 3 (alpha). )doc"); + + bc4_decoder.def("decode", &BC4Decoder::Decode, "texture"_a, R"doc( + decode(self, texture: BC4Texture) -> RawTexture + + Decode a BC4 texture into a new RawTexture using the decoder's current settings. + + :param RawTexture texture: Input texture to encode. + :returns: A new RawTexture with the same dimensions as the input + )doc"); + bc4_decoder.def_property_readonly("channel", &BC4Decoder::GetChannel, "The channel that will be written to. 0 to 3 inclusive. Readonly."); // endregion } diff --git a/quicktex/s3tc/bc5/_bindings.cpp b/quicktex/s3tc/bc5/_bindings.cpp index 421425b..27d52d6 100644 --- a/quicktex/s3tc/bc5/_bindings.cpp +++ b/quicktex/s3tc/bc5/_bindings.cpp @@ -80,6 +80,15 @@ void InitBC5(py::module_ &s3tc) { :param int chan1: the second channel that will be read from. 0 to 3 inclusive. Default: 1 (green). )doc"); + bc5_encoder.def("encode", &BC5Encoder::Encode, "texture"_a, R"doc( + encode(self, texture: RawTexture) -> BC5Texture + + Encode a raw texture into a new BC5Texture using the encoder's current settings. + + :param RawTexture texture: Input texture to encode. + :returns: A new BC5Texture with the same dimension as the input. + )doc"); + bc5_encoder.def_property_readonly("channels", &BC5Encoder::GetChannels, "A 2-tuple of channels that will be read from. 0 to 3 inclusive. Readonly."); bc5_encoder.def_property_readonly("bc4_encoders", &BC5Encoder::GetBC4Encoders, "2-tuple of internal :py:class:`~quicktex.s3tc.bc4.BC4Encoder` s used for each channel. Readonly."); @@ -101,6 +110,15 @@ void InitBC5(py::module_ &s3tc) { :param int chan1: the second channel that will be written to. 0 to 3 inclusive. Default: 1 (green). )doc"); + bc5_decoder.def("decode", &BC5Decoder::Decode, "texture"_a, R"doc( + decode(self, texture: BC5Texture) -> RawTexture + + Decode a BC5 texture into a new RawTexture using the decoder's current settings. + + :param RawTexture texture: Input texture to encode. + :returns: A new RawTexture with the same dimensions as the input + )doc"); + bc5_decoder.def_property_readonly("channels", &BC5Decoder::GetChannels, "A 2-tuple of channels that will be written to. 0 to 3 inclusive. Readonly."); bc5_decoder.def_property_readonly("bc4_decoders", &BC5Decoder::GetBC4Decoders, "2-tuple of internal :py:class:`~quicktex.s3tc.bc4.BC4Decoder` s used for each channel. Readonly.");