#ifndef RAY_H_ #define RAY_H_ #ifndef PSP # include "ruby.h" #else # include #endif #if defined(HAVE_SDL_H) # include #else # include #endif #ifdef PSP # include # include # include #endif #if defined(HAVE_SDL_IMAGE_H) # if !defined(HAVE_SDL_IMAGE) # define HAVE_SDL_IMAGE # endif # include #else # if defined(HAVE_SDL_SDL_IMAGE_H) # if !defined(HAVE_SDL_IMAGE) # define HAVE_SDL_IMAGE # endif # include # endif #endif #if defined(HAVE_SDL_ROTOZOOM_H) # if !defined(HAVE_SDL_GFX) # define HAVE_SDL_GFX # endif # include # include # include #else # if defined(HAVE_SDL_SDL_ROTOZOOM_H) # if !defined(HAVE_SDL_GFX) # define HAVE_SDL_GFX # endif # include # include # include # endif #endif #if defined(HAVE_SDL_TTF_H) # if !defined(HAVE_SDL_TTF) # define HAVE_SDL_TTF # endif # include #else # if defined(HAVE_SDL_SDL_TTF_H) # if !defined(HAVE_SDL_TTF) # define HAVE_SDL_TTF # endif # include # endif #endif #if defined(HAVE_SDL_MIXER_H) # if !defined(HAVE_SDL_MIXER) # define HAVE_SDL_MIXER # endif # include #else # if defined(HAVE_SDL_SDL_MIXER_H) # if !defined(HAVE_SDL_MIXER) # define HAVE_SDL_MIXER # endif # include # endif #endif #ifdef __cplusplus extern "C" { #if 0 } #endif #endif /* Classes and modules */ extern VALUE ray_mRay; extern VALUE ray_cImage; extern VALUE ray_cColor; extern VALUE ray_cRect; extern VALUE ray_cEvent; #ifdef HAVE_SDL_TTF extern VALUE ray_cFont; #endif #ifdef HAVE_SDL_MIXER extern VALUE ray_mAudio; extern VALUE ray_cSound; extern VALUE ray_cMusic; #endif #ifdef PSP extern VALUE ray_eTimeoutError; extern VALUE ray_mWlan; #endif /* Macros for Ruby's C API */ #define RAY_IS_A(obj, klass) (RTEST(rb_obj_is_kind_of(obj, klass))) #define RAY_OBJ_CLASSNAME(obj) (rb_class2name(rb_class_of(obj))) #define RAY_SYM(string) (ID2SYM(rb_intern(string))) #define RAY_METH(string) (rb_intern(string)) /* Data types */ typedef struct { int width; int height; int bpp; uint32_t flags; } ray_video_mode; typedef struct { SDL_Surface *surface; int must_free; /* Should we call SDL_FreeSurface? */ } ray_image; typedef struct { uint8_t r, g, b, a; } ray_color; typedef SDL_Rect ray_rect; typedef struct { SDL_Joystick *joystick; } ray_joystick; #ifdef HAVE_SDL_TTF typedef struct { TTF_Font *font; } ray_font; #endif #ifdef HAVE_SDL_MIXER typedef struct { Mix_Chunk *sound; } ray_sound; typedef struct { Mix_Music *music; } ray_music; #endif /* Convertion functions */ /** Converts a surface into a ruby object (won't free it) */ VALUE ray_create_image(SDL_Surface *surface); /** Converts a surface into a ruby object (will free it) */ VALUE ray_create_gc_image(SDL_Surface *surface); /** Converts a color into a ruby object */ VALUE ray_col2rb(ray_color color); /** Converts a rect into a ruby object */ VALUE ray_rect2rb(ray_rect rect); /** Converts a ruby object into a color */ ray_color ray_rb2col(VALUE object); /** Parses a hash to create a video mode */ ray_video_mode ray_parse_video_mode(VALUE hash); /** Converts a ruby object into an image*/ ray_image *ray_rb2image(VALUE object); /** Converts a ruby object into a color */ SDL_Surface *ray_rb2surface(VALUE object); /** Converts a ruby object into a rect */ ray_rect ray_rb2rect(VALUE object); /** Converts a ruby object into a rect even if it's not an intance of Ray::Rect. */ ray_rect ray_convert_to_rect(VALUE obj); /** Converts a ruby object into an event */ SDL_Event *ray_rb2event(VALUE object); /** Converts a ruby object into a joystick */ SDL_Joystick *ray_rb2joystick(VALUE object); #ifdef HAVE_SDL_TTF /** Converts a ruby object into a font */ TTF_Font *ray_rb2font(VALUE object); #endif #ifdef HAVE_SDL_MIXER /** Converts a ruby object into a sound chunk */ Mix_Chunk *ray_rb2chunk(VALUE object); /** Converts a ruby object into a music */ Mix_Music *ray_rb2music(VALUE object); #endif /* Initializers */ void Init_ray_ext(); void Init_ray_image(); void Init_ray_color(); void Init_ray_rect(); void Init_ray_event(); void Init_ray_joystick(); #ifdef HAVE_SDL_TTF void Init_ray_font(); #endif #ifdef HAVE_SDL_MIXER void Init_ray_audio(); #endif #ifdef PSP void Init_ray_psp(); #endif #ifdef __cplusplus #if 0 { #endif } #endif #endif