summaryrefslogtreecommitdiff
path: root/src/resources/dye
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-12-21 23:18:11 +0300
committerAndrei Karas <akaras@inbox.ru>2016-12-21 23:18:11 +0300
commitdca5154e6690286b04a8cb7c7c6f2ef63e0b56df (patch)
tree6a6a0f3119f96228053f85acdbebde0fbb4fd0bc /src/resources/dye
parent6addecc3615d5e3f9caaafd39aa639c8ff49115b (diff)
downloadmanaplus-dca5154e6690286b04a8cb7c7c6f2ef63e0b56df.tar.gz
manaplus-dca5154e6690286b04a8cb7c7c6f2ef63e0b56df.tar.bz2
manaplus-dca5154e6690286b04a8cb7c7c6f2ef63e0b56df.tar.xz
manaplus-dca5154e6690286b04a8cb7c7c6f2ef63e0b56df.zip
Move buildhex macro into separate file.
Diffstat (limited to 'src/resources/dye')
-rw-r--r--src/resources/dye/dye_unittest.cc12
-rw-r--r--src/resources/dye/dyecolor.h15
2 files changed, 5 insertions, 22 deletions
diff --git a/src/resources/dye/dye_unittest.cc b/src/resources/dye/dye_unittest.cc
index e72609329..c06d0aacb 100644
--- a/src/resources/dye/dye_unittest.cc
+++ b/src/resources/dye/dye_unittest.cc
@@ -48,20 +48,8 @@
#include <SDL.h>
#endif // USE_SDL2
-#ifndef SDL_BIG_ENDIAN
-#include <SDL_endian.h>
-#endif // SDL_BYTEORDER
-
#include "debug.h"
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
-#define buildHex(a, b, c, d) \
- (d) * 16777216U + (c) * 65536U + (b) * 256U + CAST_U32(a)
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-#define buildHex(a, b, c, d) \
- (a) * 16777216U + (b) * 65536U + (c) * 256U + CAST_U32(d)
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
#ifdef USE_OPENGL
TEST_CASE("Dye replaceSOGLColor 1 1")
diff --git a/src/resources/dye/dyecolor.h b/src/resources/dye/dyecolor.h
index 11257fc22..a3558a4c3 100644
--- a/src/resources/dye/dyecolor.h
+++ b/src/resources/dye/dyecolor.h
@@ -21,21 +21,16 @@
#ifndef RESOURCES_DYE_DYECOLOR_H
#define RESOURCES_DYE_DYECOLOR_H
-#ifndef SDL_BIG_ENDIAN
-#include <SDL_endian.h>
-#endif // SDL_BYTEORDER
+#include "utils/buildhex.h"
#include "localconsts.h"
-#define buildHex(a, b, c, d) \
- (a) * 16777216U + (b) * 65536U + (c) * 256U + CAST_U32(d)
-
struct DyeColor final
{
DyeColor() noexcept2 :
valueA(buildHex(0, 0, 0, 255)),
valueS(buildHex(0, 0, 0, 0)),
- valueSOgl(buildHex(0, 0, 0, 0))
+ valueSOgl(buildHexOgl(0, 0, 0, 0))
{
value[3] = 255;
}
@@ -45,7 +40,7 @@ struct DyeColor final
const uint8_t b) noexcept2 :
valueA(buildHex(r, g, b, 255)),
valueS(buildHex(r, g, b, 0)),
- valueSOgl(buildHex(0, b, g, r))
+ valueSOgl(buildHexOgl(0, b, g, r))
{
value[0] = r;
value[1] = g;
@@ -59,7 +54,7 @@ struct DyeColor final
const uint8_t a) noexcept2 :
valueA(buildHex(r, g, b, a)),
valueS(buildHex(r, g, b, 0)),
- valueSOgl(buildHex(0, b, g, r))
+ valueSOgl(buildHexOgl(0, b, g, r))
{
value[0] = r;
value[1] = g;
@@ -71,7 +66,7 @@ struct DyeColor final
{
valueA = buildHex(value[0], value[1], value[2], value[3]);
valueS = buildHex(value[0], value[1], value[2], 0);
- valueSOgl = buildHex(0, value[2], value[1], value[0]);
+ valueSOgl = buildHexOgl(0, value[2], value[1], value[0]);
}
union