aboutsummaryrefslogtreecommitdiff
path: root/src/sdl/color.c
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2019-01-13 08:29:12 -0500
committerPaul Duncan <pabs@pablotron.org>2019-01-13 08:29:12 -0500
commitcd0f70f86d1cedffcd1bacf57d9250fdff1f7af3 (patch)
treea7be11a817a89e47700691f5042ba005e756bc4a /src/sdl/color.c
parenta3f788b6a64bbf89342fec2111eb1e1b478db13f (diff)
downloadsok-cd0f70f86d1cedffcd1bacf57d9250fdff1f7af3.tar.bz2
sok-cd0f70f86d1cedffcd1bacf57d9250fdff1f7af3.zip
refactor sok-sdl, add zoom and warp_buf support
Diffstat (limited to 'src/sdl/color.c')
-rw-r--r--src/sdl/color.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/sdl/color.c b/src/sdl/color.c
new file mode 100644
index 0000000..1e75cb6
--- /dev/null
+++ b/src/sdl/color.c
@@ -0,0 +1,25 @@
+#include <stdbool.h>
+#include "color.h"
+
+static const SDL_Color
+PALETTE[] = {
+ { .r = 0x00, .g = 0x00, .b = 0x00, .a = 0xFF }, // COLOR_BG
+ { .r = 0x00, .g = 0xFF, .b = 0x00, .a = 0xFF }, // COLOR_BG_WON
+ { .r = 0x66, .g = 0x66, .b = 0x66, .a = 0xFF }, // COLOR_WALL
+ { .r = 0x00, .g = 0xFF, .b = 0x00, .a = 0xFF }, // COLOR_GOAL
+ { .r = 0xFF, .g = 0x00, .b = 0x00, .a = 0xFF }, // COLOR_HOME
+ { .r = 0xFF, .g = 0xFF, .b = 0x00, .a = 0xFF }, // COLOR_HOME_GOAL
+ { .r = 0x00, .g = 0x00, .b = 0xFF, .a = 0xFF }, // COLOR_BOX
+ { .r = 0x00, .g = 0xFF, .b = 0xFF, .a = 0xFF }, // COLOR_BOX_GOAL
+ { 0, 0, 0, 0 }, // COLOR_LAST
+};
+
+bool
+set_color(
+ SDL_Renderer * const renderer,
+ const color_t ofs
+) {
+ // FIXME: check for error?
+ const SDL_Color c = PALETTE[ofs];
+ return SDL_SetRenderDrawColor(renderer, c.r, c.g, c.b, c.a) < 0;
+}