aboutsummaryrefslogtreecommitdiff
path: root/headers
diff options
context:
space:
mode:
authorkdx <kikoodx@paranoici.org>2023-06-28 23:20:20 +0200
committerkdx <kikoodx@paranoici.org>2023-06-28 23:20:58 +0200
commitea0485e7c4806d3407d2f86d52f4f28fed55331b (patch)
tree26b7051bdc0b9c4d180074ecf5857bdaf3ce6778 /headers
parent581a38bb7a9f1b2b0ad6edd86b8d876d63e36376 (diff)
downloadtzr-ea0485e7c4806d3407d2f86d52f4f28fed55331b.tar.gz
c++ support
Diffstat (limited to 'headers')
-rw-r--r--headers/TZR.h5
-rw-r--r--headers/TZR_render.h16
-rw-r--r--headers/TZR_sound.h5
3 files changed, 15 insertions, 11 deletions
diff --git a/headers/TZR.h b/headers/TZR.h
index a202242..3144cca 100644
--- a/headers/TZR.h
+++ b/headers/TZR.h
@@ -10,7 +10,7 @@
* Resources are exposed as ID instead of pointer, as a future proof measure in
* case TZR needs to rearrange memory at runtime in the future. */
-#define TZR_Init(...) _TZR_Init(&(const TZR_Config){ \
+#define TZR_Init(...) ({ const TZR_Config ____arg = { \
.width=256, \
.height=224, \
.scale=2, \
@@ -21,7 +21,8 @@
.show_cursor=false, \
.mixer=TZR_MIXER_ON, \
.title="TZR", \
- ._=0, __VA_ARGS__ })
+ ._=0, __VA_ARGS__ }; \
+ _TZR_Init(&____arg); })
/* Should be called only once before usage of any other function unless
* otherwise specified. On error this calls TZR_Quit and returns -1.
diff --git a/headers/TZR_render.h b/headers/TZR_render.h
index 9cd3128..8fde15a 100644
--- a/headers/TZR_render.h
+++ b/headers/TZR_render.h
@@ -17,8 +17,9 @@ int TZR_DrawBegin(void);
int TZR_DrawEnd(void);
/* Return -1 on error. */
-#define TZR_DrawSetColor(...) _TZR_DrawSetColor(&(const TZR_Color){ \
- .r=-1.0f, .g=-1.0f, .b=-1.0f, .a=-1.0f, ._=0, __VA_ARGS__ })
+#define TZR_DrawSetColor(...) ({ const TZR_Color ____arg = { \
+ .r=-1.0f, .g=-1.0f, .b=-1.0f, .a=-1.0f, ._=0, __VA_ARGS__ }; \
+ _TZR_DrawSetColor(&____arg); })
#ifdef TZR_PARANOID
#if __STDC_VERSION__ > 201710L
[[nodiscard]]
@@ -61,9 +62,9 @@ int TZR_DrawLine(int x0, int y0, int x1, int y1);
/* Return -1 on error. Draw rectangle at `x`;`y` position of size `w`x`h` in the
* framebuffer. */
-#define TZR_DrawRectangle(...) _TZR_DrawRectangle( \
- &(const TZR_DrawRectangleArgs){ \
- .x=0, .y=0, .w=0, .h=0, .fill=false, .center=false, ._=0, __VA_ARGS__ })
+#define TZR_DrawRectangle(...) ({ const TZR_DrawRectangleArgs ____arg = { \
+ .x=0, .y=0, .w=0, .h=0, .fill=false, .center=false, ._=0, __VA_ARGS__ }; \
+ _TZR_DrawRectangle(&____arg); })
#ifdef TZR_PARANOID
#if __STDC_VERSION__ > 201710L
[[nodiscard]]
@@ -73,10 +74,11 @@ int _TZR_DrawRectangle(const TZR_DrawRectangleArgs *args);
/* Return -1 on error. Draw texture ressource `id` at `x`;`y` position of
* the framebuffer. */
-#define TZR_DrawImage(...) _TZR_DrawImage(&(const TZR_DrawImageArgs){ \
+#define TZR_DrawImage(...) ({ const TZR_DrawImageArgs ____arg = { \
.x=0, .y=0, .ix=0, .iy=0, .w=INT_MIN, .h=INT_MIN, .r=0.0f, .sx=1.0f, \
.sy=1.0f, .center=false, .flip_x=false, .flip_y=false, ._=0, \
- __VA_ARGS__ })
+ __VA_ARGS__ }; \
+ _TZR_DrawImage(&____arg); })
#ifdef TZR_PARANOID
#if __STDC_VERSION__ > 201710L
[[nodiscard]]
diff --git a/headers/TZR_sound.h b/headers/TZR_sound.h
index 271995b..1e5e829 100644
--- a/headers/TZR_sound.h
+++ b/headers/TZR_sound.h
@@ -1,8 +1,9 @@
#pragma once
#include "TZR_types.h"
-#define TZR_PlaySound(...) _TZR_PlaySound(&(const TZR_PlaySoundArgs){ \
- .id=0, .loop=0, .volume=1.0f, ._=0, __VA_ARGS__ })
+#define TZR_PlaySound(...) ({ const TZR_PlaySoundArgs ____arg = { \
+ .id=0, .loop=0, .volume=1.0f, ._=0, __VA_ARGS__ }; \
+ _TZR_PlaySound(&____arg); })
#ifdef TZR_PARANOID
#if __STDC_VERSION__ > 201710L
[[nodiscard]]