libsuicmez
This commit is contained in:
parent
376152f465
commit
6d34fe05fe
1 changed files with 130 additions and 0 deletions
130
libsuicmez/libsuicmez.h
Normal file
130
libsuicmez/libsuicmez.h
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
#ifndef LIBSUICMEZ_H
|
||||
#define LIBSUICMEZ_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// Forward include raylib (or include it in the .c and keep only forward decls)
|
||||
#include "raylib.h"
|
||||
|
||||
typedef enum suic_log_level {
|
||||
SUIC_LOG_ALL = 0,
|
||||
SUIC_LOG_INFO = 1,
|
||||
SUIC_LOG_WARN = 2,
|
||||
SUIC_LOG_ERROR = 3,
|
||||
SUIC_LOG_NONE = 4
|
||||
} suic_log_level;
|
||||
|
||||
const char *suic_last_error(void);
|
||||
void suic_clear_error(void);
|
||||
|
||||
void suic_set_log_level(suic_log_level level);
|
||||
|
||||
typedef struct suic_vec2 {
|
||||
float x, y;
|
||||
} suic_vec2;
|
||||
|
||||
typedef struct suic_vec3 {
|
||||
float x, y, z;
|
||||
} suic_vec3;
|
||||
|
||||
static inline Vector2 suic_to_rl_vec2(suic_vec2 v) {
|
||||
return (Vector2){v.x, v.y};
|
||||
}
|
||||
static inline Vector3 suic_to_rl_vec3(suic_vec3 v) {
|
||||
return (Vector3){v.x, v.y, v.z};
|
||||
}
|
||||
static inline suic_vec2 suic_from_rl_vec2(Vector2 v) {
|
||||
return (suic_vec2){v.x, v.y};
|
||||
}
|
||||
static inline suic_vec3 suic_from_rl_vec3(Vector3 v) {
|
||||
return (suic_vec3){v.x, v.y, v.z};
|
||||
}
|
||||
|
||||
// Must be called before any GPU resources (textures, models) are created.
|
||||
bool suic_init_window(int width, int height, const char *title);
|
||||
void suic_close_window(void);
|
||||
|
||||
bool suic_window_should_close(void);
|
||||
void suic_set_target_fps(int fps);
|
||||
|
||||
// Frame boundaries (2D)
|
||||
void suic_begin_drawing(void);
|
||||
void suic_end_drawing(void);
|
||||
void suic_clear_background(unsigned char r, unsigned char g, unsigned char b,
|
||||
unsigned char a);
|
||||
|
||||
// 3D mode boundaries
|
||||
typedef struct suic_camera3d {
|
||||
suic_vec3 position;
|
||||
suic_vec3 target;
|
||||
suic_vec3 up;
|
||||
float fovy;
|
||||
int projection; // map to CameraProjection
|
||||
} suic_camera3d;
|
||||
|
||||
Camera3D suic_to_rl_camera3d(suic_camera3d cam);
|
||||
|
||||
void suic_begin_mode3d(suic_camera3d cam);
|
||||
void suic_end_mode3d(void);
|
||||
|
||||
bool suic_is_key_down(int key);
|
||||
bool suic_is_mouse_button_down(int b);
|
||||
suic_vec2 suic_get_mouse_position(void);
|
||||
|
||||
typedef struct suic_image_handle {
|
||||
Image value;
|
||||
bool valid;
|
||||
} suic_image_handle;
|
||||
typedef struct suic_texture_handle {
|
||||
Texture2D value;
|
||||
bool valid;
|
||||
} suic_texture_handle;
|
||||
|
||||
suic_image_handle suic_image_load(const char *path);
|
||||
void suic_image_free(suic_image_handle *img);
|
||||
|
||||
suic_texture_handle suic_texture_load(const char *path);
|
||||
suic_texture_handle suic_texture_from_image(suic_image_handle img);
|
||||
void suic_texture_free(suic_texture_handle *tex);
|
||||
|
||||
// Drawing a texture (basic)
|
||||
void suic_draw_texture(suic_texture_handle tex, int x, int y, unsigned char r,
|
||||
unsigned char g, unsigned char b, unsigned char a);
|
||||
|
||||
bool suic_audio_init(void); // wraps InitAudioDevice
|
||||
void suic_audio_close(void); // wraps CloseAudioDevice
|
||||
|
||||
typedef struct suic_sound_handle {
|
||||
Sound value;
|
||||
bool valid;
|
||||
} suic_sound_handle;
|
||||
|
||||
suic_sound_handle suic_sound_load(const char *path);
|
||||
void suic_sound_play(suic_sound_handle snd);
|
||||
void suic_sound_set_volume(suic_sound_handle snd, float volume);
|
||||
void suic_sound_free(suic_sound_handle *snd);
|
||||
|
||||
typedef struct suic_ray {
|
||||
suic_vec3 origin;
|
||||
suic_vec3 direction;
|
||||
} suic_ray;
|
||||
|
||||
typedef struct suic_rayhit {
|
||||
bool hit;
|
||||
float distance;
|
||||
suic_vec3 point;
|
||||
suic_vec3 normal;
|
||||
} suic_rayhit;
|
||||
|
||||
// Ray from camera + mouse
|
||||
suic_ray suic_get_mouse_ray(suic_vec2 mouse, suic_camera3d cam);
|
||||
|
||||
// AABB ray test (for chunk culling / picking helpers)
|
||||
typedef struct suic_aabb {
|
||||
suic_vec3 min;
|
||||
suic_vec3 max;
|
||||
} suic_aabb;
|
||||
suic_rayhit suic_raycast_aabb(suic_ray ray, suic_aabb box);
|
||||
|
||||
#endif // LIBSUICMEZ_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue