2025-12-16 14:51:45 +05:30
|
|
|
#ifndef LIBSUICMEZ_H
|
|
|
|
|
#define LIBSUICMEZ_H
|
|
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <stdint.h>
|
2025-12-17 13:16:53 +05:30
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
2025-12-16 14:51:45 +05:30
|
|
|
|
2025-12-17 13:16:53 +05:30
|
|
|
// Raylib support
|
2025-12-16 14:51:45 +05:30
|
|
|
#include "raylib.h"
|
|
|
|
|
|
2025-12-17 13:16:53 +05:30
|
|
|
// ODE support
|
|
|
|
|
#include <ode/ode.h>
|
|
|
|
|
|
|
|
|
|
// Logging levels
|
2025-12-16 14:51:45 +05:30
|
|
|
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;
|
|
|
|
|
|
2025-12-17 13:16:53 +05:30
|
|
|
// Error handling
|
2025-12-16 14:51:45 +05:30
|
|
|
const char *suic_last_error(void);
|
|
|
|
|
void suic_clear_error(void);
|
|
|
|
|
void suic_set_log_level(suic_log_level level);
|
|
|
|
|
|
2025-12-17 13:16:53 +05:30
|
|
|
// Vec types
|
2025-12-16 14:51:45 +05:30
|
|
|
typedef struct suic_vec2 {
|
|
|
|
|
float x, y;
|
|
|
|
|
} suic_vec2;
|
|
|
|
|
|
|
|
|
|
typedef struct suic_vec3 {
|
|
|
|
|
float x, y, z;
|
|
|
|
|
} suic_vec3;
|
|
|
|
|
|
2025-12-17 13:16:53 +05:30
|
|
|
// Vector conversion helpers
|
2025-12-16 14:51:45 +05:30
|
|
|
static inline Vector2 suic_to_rl_vec2(suic_vec2 v) {
|
|
|
|
|
return (Vector2){v.x, v.y};
|
|
|
|
|
}
|
2025-12-17 13:16:53 +05:30
|
|
|
|
2025-12-16 14:51:45 +05:30
|
|
|
static inline Vector3 suic_to_rl_vec3(suic_vec3 v) {
|
|
|
|
|
return (Vector3){v.x, v.y, v.z};
|
|
|
|
|
}
|
2025-12-17 13:16:53 +05:30
|
|
|
|
2025-12-16 14:51:45 +05:30
|
|
|
static inline suic_vec2 suic_from_rl_vec2(Vector2 v) {
|
|
|
|
|
return (suic_vec2){v.x, v.y};
|
|
|
|
|
}
|
2025-12-17 13:16:53 +05:30
|
|
|
|
2025-12-16 14:51:45 +05:30
|
|
|
static inline suic_vec3 suic_from_rl_vec3(Vector3 v) {
|
|
|
|
|
return (suic_vec3){v.x, v.y, v.z};
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-17 13:16:53 +05:30
|
|
|
// Window management
|
2025-12-16 14:51:45 +05:30
|
|
|
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);
|
|
|
|
|
|
2025-12-17 13:16:53 +05:30
|
|
|
// Drawing (2D)
|
2025-12-16 14:51:45 +05:30
|
|
|
void suic_begin_drawing(void);
|
|
|
|
|
void suic_end_drawing(void);
|
2025-12-17 13:16:53 +05:30
|
|
|
void suic_clear_background(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
|
2025-12-16 14:51:45 +05:30
|
|
|
|
2025-12-17 13:16:53 +05:30
|
|
|
// 3D Camera
|
2025-12-16 14:51:45 +05:30
|
|
|
typedef struct suic_camera3d {
|
|
|
|
|
suic_vec3 position;
|
|
|
|
|
suic_vec3 target;
|
|
|
|
|
suic_vec3 up;
|
|
|
|
|
float fovy;
|
2025-12-17 13:16:53 +05:30
|
|
|
int projection; // CameraProjection
|
2025-12-16 14:51:45 +05:30
|
|
|
} suic_camera3d;
|
|
|
|
|
|
|
|
|
|
Camera3D suic_to_rl_camera3d(suic_camera3d cam);
|
2025-12-17 13:16:53 +05:30
|
|
|
void suic_begin_mode3d(float pos_x, float pos_y, float pos_z, float target_x, float target_y, float target_z, float up_x, float up_y, float up_z, float fovy, int projection);
|
2025-12-16 14:51:45 +05:30
|
|
|
void suic_end_mode3d(void);
|
|
|
|
|
|
2025-12-17 13:16:53 +05:30
|
|
|
// 3D Drawing
|
|
|
|
|
void suic_draw_cube(float x, float y, float z, float width, float height, float length, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
|
|
|
|
|
void suic_draw_cube_wires(float x, float y, float z, float width, float height, float length, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
|
|
|
|
|
|
|
|
|
|
// Input
|
2025-12-16 14:51:45 +05:30
|
|
|
bool suic_is_key_down(int key);
|
|
|
|
|
bool suic_is_mouse_button_down(int b);
|
|
|
|
|
suic_vec2 suic_get_mouse_position(void);
|
|
|
|
|
|
2025-12-17 13:16:53 +05:30
|
|
|
// Images and Textures
|
2025-12-16 14:51:45 +05:30
|
|
|
typedef struct suic_image_handle {
|
|
|
|
|
Image value;
|
|
|
|
|
bool valid;
|
|
|
|
|
} suic_image_handle;
|
2025-12-17 13:16:53 +05:30
|
|
|
|
2025-12-16 14:51:45 +05:30
|
|
|
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);
|
|
|
|
|
void suic_draw_texture(suic_texture_handle tex, int x, int y, unsigned char r,
|
|
|
|
|
unsigned char g, unsigned char b, unsigned char a);
|
|
|
|
|
|
2025-12-17 13:16:53 +05:30
|
|
|
// Audio
|
|
|
|
|
bool suic_audio_init(void);
|
|
|
|
|
void suic_audio_close(void);
|
2025-12-16 14:51:45 +05:30
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
2025-12-17 13:16:53 +05:30
|
|
|
// Raycasting
|
2025-12-16 14:51:45 +05:30
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
typedef struct suic_aabb {
|
|
|
|
|
suic_vec3 min;
|
|
|
|
|
suic_vec3 max;
|
|
|
|
|
} suic_aabb;
|
2025-12-17 13:16:53 +05:30
|
|
|
|
|
|
|
|
suic_ray suic_get_mouse_ray(suic_vec2 mouse, suic_camera3d cam);
|
2025-12-16 14:51:45 +05:30
|
|
|
suic_rayhit suic_raycast_aabb(suic_ray ray, suic_aabb box);
|
|
|
|
|
|
2025-12-17 13:16:53 +05:30
|
|
|
// GC-aware allocator (core functionality)
|
|
|
|
|
void* gc_suic_alloc(size_t size);
|
|
|
|
|
void suic_gc_free(void* ptr);
|
|
|
|
|
|
|
|
|
|
// ODE Physics Engine Support
|
|
|
|
|
// ODE types (opaque pointers)
|
|
|
|
|
typedef dWorldID suic_ode_world_id;
|
|
|
|
|
typedef dSpaceID suic_ode_space_id;
|
|
|
|
|
typedef dBodyID suic_ode_body_id;
|
|
|
|
|
typedef dGeomID suic_ode_geom_id;
|
|
|
|
|
typedef dJointID suic_ode_joint_id;
|
|
|
|
|
typedef dJointGroupID suic_ode_joint_group_id;
|
|
|
|
|
|
|
|
|
|
// Vector types for ODE (matching ODE's dReal which is double)
|
|
|
|
|
typedef struct suic_ode_vector3 {
|
|
|
|
|
dReal x, y, z;
|
|
|
|
|
} suic_ode_vector3;
|
|
|
|
|
|
|
|
|
|
typedef struct suic_ode_quaternion {
|
|
|
|
|
dReal w, x, y, z; // ODE quaternion format: w,x,y,z
|
|
|
|
|
} suic_ode_quaternion;
|
|
|
|
|
|
|
|
|
|
// Basic ODE functions
|
|
|
|
|
void suic_ode_init(void);
|
|
|
|
|
void suic_ode_close(void);
|
|
|
|
|
suic_ode_world_id suic_ode_world_create(void);
|
|
|
|
|
void suic_ode_world_destroy(suic_ode_world_id world);
|
|
|
|
|
void suic_ode_world_set_gravity(suic_ode_world_id world, dReal x, dReal y, dReal z);
|
|
|
|
|
void suic_ode_world_step(suic_ode_world_id world, dReal stepsize);
|
|
|
|
|
|
|
|
|
|
// Body management
|
|
|
|
|
suic_ode_body_id suic_ode_body_create(suic_ode_world_id world);
|
|
|
|
|
void suic_ode_body_destroy(suic_ode_body_id body);
|
|
|
|
|
void suic_ode_body_set_position(suic_ode_body_id body, dReal x, dReal y, dReal z);
|
|
|
|
|
void suic_ode_body_set_linear_vel(suic_ode_body_id body, dReal x, dReal y, dReal z);
|
|
|
|
|
void suic_ode_body_get_position(suic_ode_body_id body, float *x, float *y, float *z);
|
|
|
|
|
|
|
|
|
|
// Mass and geometry
|
|
|
|
|
void suic_ode_body_set_box_mass(suic_ode_body_id body, dReal density, dReal lx, dReal ly, dReal lz);
|
|
|
|
|
suic_ode_geom_id suic_ode_create_box_geom(suic_ode_space_id space, dReal lx, dReal ly, dReal lz);
|
|
|
|
|
suic_ode_geom_id suic_ode_create_plane_geom(suic_ode_space_id space, dReal a, dReal b, dReal c, dReal d);
|
|
|
|
|
void suic_ode_geom_set_body(suic_ode_geom_id geom, suic_ode_body_id body);
|
|
|
|
|
void suic_ode_geom_destroy(suic_ode_geom_id geom);
|
|
|
|
|
|
|
|
|
|
// Collision space
|
|
|
|
|
suic_ode_space_id suic_ode_simple_space_create(suic_ode_space_id parent);
|
|
|
|
|
void suic_ode_space_destroy(suic_ode_space_id space);
|
|
|
|
|
|
|
|
|
|
// Collision detection and contact joints
|
|
|
|
|
void suic_ode_space_collide(suic_ode_world_id world, suic_ode_space_id space, suic_ode_joint_group_id contactgroup);
|
|
|
|
|
suic_ode_joint_group_id suic_ode_joint_group_create(int max_size);
|
|
|
|
|
void suic_ode_joint_group_destroy(suic_ode_joint_group_id group);
|
|
|
|
|
void suic_ode_joint_group_empty(suic_ode_joint_group_id group);
|
|
|
|
|
|
|
|
|
|
// Additional body functions
|
|
|
|
|
void suic_ode_body_get_linear_vel(suic_ode_body_id body, float *x, float *y, float *z);
|
|
|
|
|
void suic_ode_body_get_rotation(suic_ode_body_id body, float *q_w, float *q_x, float *q_y, float *q_z);
|
|
|
|
|
void suic_ode_body_set_rotation(suic_ode_body_id body, dReal q_w, dReal q_x, dReal q_y, dReal q_z);
|
|
|
|
|
|
|
|
|
|
// Contact properties configuration
|
|
|
|
|
void suic_ode_set_contact_max_force(dReal force);
|
|
|
|
|
void suic_ode_set_contact_erp(dReal erp);
|
|
|
|
|
void suic_ode_set_contact_cfm(dReal cfm);
|
|
|
|
|
|
|
|
|
|
// Game object system - unifies physics and rendering
|
|
|
|
|
typedef struct {
|
|
|
|
|
suic_ode_body_id body;
|
|
|
|
|
suic_ode_geom_id geom;
|
|
|
|
|
float width, height, length; // For box shapes
|
|
|
|
|
unsigned char r, g, b, a; // Color for rendering
|
|
|
|
|
int shape_type; // 0=box, 1=sphere, etc.
|
|
|
|
|
} suic_game_object;
|
|
|
|
|
|
|
|
|
|
// Create and manage game objects
|
|
|
|
|
suic_game_object* suic_game_object_create_box(
|
|
|
|
|
suic_ode_world_id world,
|
|
|
|
|
suic_ode_space_id space,
|
|
|
|
|
float x, float y, float z,
|
|
|
|
|
float width, float height, float length,
|
|
|
|
|
float density,
|
|
|
|
|
unsigned char r, unsigned char g, unsigned char b, unsigned char a
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
void suic_game_object_destroy(suic_game_object* obj);
|
|
|
|
|
void suic_game_object_set_position(suic_game_object* obj, float x, float y, float z);
|
|
|
|
|
void suic_game_object_get_position(suic_game_object* obj, float *x, float *y, float *z);
|
|
|
|
|
void suic_game_object_set_velocity(suic_game_object* obj, float x, float y, float z);
|
|
|
|
|
void suic_game_object_get_velocity(suic_game_object* obj, float *x, float *y, float *z);
|
|
|
|
|
void suic_game_object_draw(suic_game_object* obj);
|
|
|
|
|
|
2025-12-16 14:51:45 +05:30
|
|
|
#endif // LIBSUICMEZ_H
|