2021-03-14 08:59:16 +00:00
|
|
|
/* Python-rgbcx Texture Compression Library
|
|
|
|
Copyright (C) 2021 Andrew Cassidy <drewcassidy@me.com>
|
|
|
|
Partially derived from rgbcx.h written by Richard Geldreich <richgel99@gmail.com>
|
|
|
|
and licenced under the public domain
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <pybind11/pybind11.h>
|
|
|
|
|
|
|
|
#include <array>
|
|
|
|
#include <cstdint>
|
|
|
|
|
2021-03-28 09:36:47 +00:00
|
|
|
#include "../../Decoder.h"
|
|
|
|
#include "../../Encoder.h"
|
2021-03-14 08:59:16 +00:00
|
|
|
#include "BC5Decoder.h"
|
|
|
|
#include "BC5Encoder.h"
|
|
|
|
|
|
|
|
namespace py = pybind11;
|
|
|
|
namespace quicktex::bindings {
|
|
|
|
|
|
|
|
using namespace quicktex::s3tc;
|
2021-03-19 08:46:33 +00:00
|
|
|
using namespace quicktex::s3tc;
|
2021-03-14 08:59:16 +00:00
|
|
|
|
|
|
|
void InitBC5(py::module_ &s3tc) {
|
2021-03-21 04:19:23 +00:00
|
|
|
auto bc5 = s3tc.def_submodule("_bc5", "internal bc5 module");
|
|
|
|
py::options options;
|
|
|
|
options.disable_function_signatures();
|
2021-03-14 08:59:16 +00:00
|
|
|
|
|
|
|
// BC5Encoder
|
2021-03-28 09:36:47 +00:00
|
|
|
py::class_<BC5Encoder> bc5_encoder(bc5, "BC5Encoder", R"doc(
|
2021-03-22 03:36:26 +00:00
|
|
|
Base: :py:class:`~quicktex.BlockEncoder`
|
|
|
|
|
|
|
|
Encodes dual-channel textures to BC5.
|
|
|
|
)doc");
|
2021-03-14 08:59:16 +00:00
|
|
|
|
2021-03-21 04:19:23 +00:00
|
|
|
bc5_encoder.def(py::init<uint8_t, uint8_t>(), py::arg("chan0") = 0, py::arg("chan1") = 1, R"doc(
|
|
|
|
__init__(chan0 : int = 0, chan1 : int = 1) -> None
|
|
|
|
|
|
|
|
Create a new BC5 encoder with the specified channels
|
|
|
|
|
|
|
|
:param int chan0: the first channel that will be read from. 0 to 3 inclusive. Default: 0 (red).
|
|
|
|
:param int chan1: the second channel that will be read from. 0 to 3 inclusive. Default: 1 (green).
|
|
|
|
)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.");
|
2021-03-14 08:59:16 +00:00
|
|
|
|
|
|
|
// BC5Decoder
|
2021-03-28 09:36:47 +00:00
|
|
|
py::class_<BC5Decoder> bc5_decoder(bc5, "BC5Decoder", R"doc(
|
2021-03-22 03:36:26 +00:00
|
|
|
Base: :py:class:`~quicktex.BlockDecoder`
|
|
|
|
|
|
|
|
Decodes BC4 textures to two channels.
|
|
|
|
)doc");
|
2021-03-21 04:19:23 +00:00
|
|
|
|
|
|
|
bc5_decoder.def(py::init<uint8_t, uint8_t>(), py::arg("chan0") = 0, py::arg("chan1") = 1, R"doc(
|
|
|
|
__init__(chan0 : int = 0, chan1 : int = 1) -> None
|
|
|
|
|
|
|
|
Create a new BC5 decoder with the specified channels
|
|
|
|
|
|
|
|
:param int chan0: the first channel that will be written to. 0 to 3 inclusive. Default: 0 (red).
|
|
|
|
:param int chan1: the second channel that will be written to. 0 to 3 inclusive. Default: 1 (green).
|
|
|
|
)doc");
|
2021-03-14 08:59:16 +00:00
|
|
|
|
2021-03-21 04:19:23 +00:00
|
|
|
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.");
|
2021-03-14 08:59:16 +00:00
|
|
|
}
|
|
|
|
} // namespace quicktex::bindings
|