quicktex/quicktex/s3tc/bc4/_bindings.cpp

77 lines
2.7 KiB
C++
Raw Normal View History

2021-03-04 10:21: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>
2021-03-08 10:23:04 +00:00
2021-03-14 08:59:16 +00:00
#include <array>
#include <cstddef>
#include <cstdint>
#include <stdexcept>
#include <string>
2021-03-28 09:36:47 +00:00
#include "../../Decoder.h"
#include "../../Encoder.h"
2021-03-14 08:59:16 +00:00
#include "BC4Decoder.h"
#include "BC4Encoder.h"
2021-03-04 10:21:16 +00:00
namespace py = pybind11;
2021-03-13 12:14:04 +00:00
namespace quicktex::bindings {
2021-03-06 22:18:08 +00:00
2021-03-14 08:59:16 +00:00
using namespace quicktex::s3tc;
2021-03-21 04:19:23 +00:00
using namespace quicktex::s3tc;
2021-03-14 08:59:16 +00:00
void InitBC4(py::module_ &s3tc) {
2021-03-21 04:19:23 +00:00
auto bc4 = s3tc.def_submodule("_bc4", "internal bc4 module");
py::options options;
options.disable_function_signatures();
2021-03-14 08:59:16 +00:00
// BC4Encoder
2021-03-28 09:36:47 +00:00
py::class_<BC4Encoder> bc4_encoder(bc4, "BC4Encoder", R"doc(
2021-03-22 03:36:26 +00:00
Base: :py:class:`~quicktex.BlockEncoder`
Encodes single-channel textures to BC4.
)doc");
2021-03-21 04:19:23 +00:00
bc4_encoder.def(py::init<uint8_t>(), py::arg("channel") = 3, R"doc(
__init__(channel : int = 3) -> None
Create a new BC4 encoder with the specified channel
2021-03-04 10:21:16 +00:00
2021-03-21 04:19:23 +00:00
:param int channel: the channel that will be read from. 0 to 3 inclusive. Default: 3 (alpha).
)doc");
bc4_encoder.def_property_readonly("channel", &BC4Encoder::GetChannel, "The channel that will be read from. 0 to 3 inclusive. Readonly.");
2021-03-07 09:39:51 +00:00
2021-03-14 08:59:16 +00:00
// BC4Decoder
2021-03-28 09:36:47 +00:00
py::class_<BC4Decoder> bc4_decoder(bc4, "BC4Decoder", R"doc(
2021-03-22 03:36:26 +00:00
Base: :py:class:`~quicktex.BlockDecoder`
Decodes BC4 textures to a single-channel.
)doc");
2021-03-21 04:19:23 +00:00
bc4_decoder.def(py::init<uint8_t>(), py::arg("channel") = 3, R"doc(
__init__(channel : int = 3) -> None
Create a new BC4 decoder with the specified channel
2021-03-07 09:39:51 +00:00
2021-03-21 04:19:23 +00:00
:param int channel: The channel that will be written to. 0 to 3 inclusive. Default: 3 (alpha).
)doc");
bc4_decoder.def_property_readonly("channel", &BC4Decoder::GetChannel, "The channel that will be written to. 0 to 3 inclusive. Readonly.");
2021-03-06 22:18:08 +00:00
}
2021-03-13 12:14:04 +00:00
} // namespace quicktex::bindings