tinyswords/lib.h

84 lines
2.3 KiB
C

#pragma once
#include <stdint.h>
#include <stddef.h>
#include "include/raylib.h"
typedef uint8_t u8;
typedef uint16_t u16;
typedef int16_t i16;
typedef int32_t i32;
typedef uint32_t u32;
typedef uint64_t u64;
typedef float f32;
typedef double f64;
typedef uintptr_t uptr;
typedef char sbyte;
typedef ptrdiff_t size;
typedef size_t usize;
typedef Vector2 Point;
typedef struct Size {
float width;
float height;
} Size;
typedef struct Rect {
Point position;
Size size;
} Rect;
typedef union {
Rect components;
Rectangle rect;
} RectU;
#define OPTION(type, typeName) \
struct { \
enum {NONE, SOME} tag; \
union { \
u8 none; \
type typeName; \
} some; \
}
typedef OPTION(Point, point) PointOption;
void D_DrawTextureRec(Texture2D texture, Rectangle source, Vector2 position, Color tint);
void D_DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, Color tint);
void D_DrawTextureV(Texture2D texture, Vector2 position, Color tint);
#ifdef ENNIX_LIB_IMPLEMENTATION
extern bool global_debug_mode;
inline void D_DrawTextureV(Texture2D texture, Vector2 position, Color tint) {
DrawTextureV(texture, position, tint);
#ifdef DEBUG_MODE_ENABLED
if (global_debug_mode) {
Rectangle debug = {position.x,position.y,texture.width,texture.height};
DrawRectangleLinesEx(debug, 1.0f, RED);
}
#endif
}
inline void D_DrawTextureRec(Texture2D texture, Rectangle source, Vector2 position, Color tint) {
DrawTextureRec(texture, source, position, tint);
#ifdef DEBUG_MODE_ENABLED
if (global_debug_mode) {
Rectangle debug = {position.x,position.y,source.width,source.height};
DrawRectangleLinesEx(debug, 1.0f, RED);
}
#endif
}
inline void D_DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, Color tint) {
DrawTexturePro(texture, source, dest, origin, rotation, tint);
#ifdef DEBUG_MODE_ENABLED
if (global_debug_mode) {
Rectangle debug = {dest.x-origin.x,dest.y-origin.y,dest.width,dest.height};
DrawRectangleLinesEx(debug, 1.0f, RED);
}
#endif
}
#endif