mirror of
https://github.com/drewcassidy/quicktex.git
synced 2024-09-13 06:37:34 +00:00
make Color have a constexpr constructor and add Block class
This commit is contained in:
parent
e5f60ec030
commit
c843871ac1
42
quicktex/Block.h
Normal file
42
quicktex/Block.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace quicktex {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for all compressed blocks
|
||||||
|
*
|
||||||
|
* IMPORTANT: this class cannot contain any virtual methods or the vtable would add to the derived class size,
|
||||||
|
* it is only to act as a base class for type checking reasons. As such, it has limited utility on its own.
|
||||||
|
*
|
||||||
|
* @tparam N Block width in pixels
|
||||||
|
* @tparam M Block height in pixels
|
||||||
|
*/
|
||||||
|
template <int N, int M> class Block {
|
||||||
|
static_assert(N > 0);
|
||||||
|
static_assert(M > 0);
|
||||||
|
|
||||||
|
public:
|
||||||
|
static constexpr int Width = N;
|
||||||
|
static constexpr int Height = M;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace quicktex
|
@ -26,9 +26,9 @@
|
|||||||
|
|
||||||
namespace quicktex {
|
namespace quicktex {
|
||||||
|
|
||||||
Color::Color() { SetRGBA(0, 0, 0, 0xFF); }
|
constexpr Color::Color() { SetRGBA(0, 0, 0, 0xFF); }
|
||||||
|
|
||||||
Color::Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) { SetRGBA(r, g, b, a); }
|
constexpr Color::Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) { SetRGBA(r, g, b, a); }
|
||||||
|
|
||||||
Color::Color(Vector4Int v) { SetRGBA((uint8_t)v[0], (uint8_t)v[1], (uint8_t)v[2], (uint8_t)v[3]); }
|
Color::Color(Vector4Int v) { SetRGBA((uint8_t)v[0], (uint8_t)v[1], (uint8_t)v[2], (uint8_t)v[3]); }
|
||||||
|
|
||||||
|
@ -34,9 +34,9 @@ class Color {
|
|||||||
uint8_t b;
|
uint8_t b;
|
||||||
uint8_t a;
|
uint8_t a;
|
||||||
|
|
||||||
Color();
|
constexpr Color();
|
||||||
|
|
||||||
Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 0xFF);
|
constexpr Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 0xFF);
|
||||||
|
|
||||||
Color(Vector4Int v);
|
Color(Vector4Int v);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user