|
@@ -1,29 +1,39 @@
|
|
|
#ifndef INCLUDE_GRAPHICS_H
|
|
#ifndef INCLUDE_GRAPHICS_H
|
|
|
#define INCLUDE_GRAPHICS_H
|
|
#define INCLUDE_GRAPHICS_H
|
|
|
|
|
|
|
|
-namespace WalrusRPG{ namespace Graphics {
|
|
|
|
|
|
|
+#include <cstdint>
|
|
|
|
|
|
|
|
|
|
+namespace WalrusRPG{ namespace Graphics {
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
|
* Pixel structure
|
|
* Pixel structure
|
|
|
* TODO?: Convert this into a class to hide value?
|
|
* TODO?: Convert this into a class to hide value?
|
|
|
*/
|
|
*/
|
|
|
union Pixel {
|
|
union Pixel {
|
|
|
- ::uint16_t value;
|
|
|
|
|
|
|
+ std::uint16_t value;
|
|
|
struct {
|
|
struct {
|
|
|
unsigned r : 5;
|
|
unsigned r : 5;
|
|
|
unsigned g : 6;
|
|
unsigned g : 6;
|
|
|
unsigned b : 5;
|
|
unsigned b : 5;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- Pixel(::uint8_t red, ::uint8_t green, ::uint8_t blue) : r(red>>3), g(green>>2), b(blue>>3) {
|
|
|
|
|
|
|
+ Pixel(std::uint16_t color) : value(color) {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Pixel(Pixel &pix) : value(pix.value) {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Pixel(std::uint8_t red, std::uint8_t green, std::uint8_t blue) : r(red>>3), g(green>>2), b(blue>>3) {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Overloading (unsigned) typecast
|
|
// Overloading (unsigned) typecast
|
|
|
- operator ::uint16_t() {
|
|
|
|
|
|
|
+ operator std::uint16_t() {
|
|
|
return value;
|
|
return value;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
Pixel& operator=(unsigned value) {
|
|
Pixel& operator=(unsigned value) {
|
|
|
this->value = value;
|
|
this->value = value;
|
|
|
return *this;
|
|
return *this;
|