sdl3.c3l/sdl3_surface.c3i

89 lines
7.8 KiB
Plaintext

module sdl3::sdl;
typedef SurfaceFlags = uint;
const SurfaceFlags SURFACE_PREALLOCATED @builtin = 0x00000001;
const SurfaceFlags SURFACE_LOCK_NEEDED @builtin = 0x00000002;
const SurfaceFlags SURFACE_LOCKED @builtin = 0x00000004;
const SurfaceFlags SURFACE_SIMD_ALIGNED @builtin = 0x00000008;
typedef ScaleMode = CInt;
const ScaleMode SCALEMODE_INVALID @builtin = -1;
const ScaleMode SCALEMODE_NEAREST @builtin = 0;
const ScaleMode SCALEMODE_LINEAR @builtin = 0;
enum FlipMode : inline CInt {
FLIP_NONE,
FLIP_HORIZONTAL,
FLIP_VERTICAL
}
typedef Surface = void;
extern fn Surface* create_surface(int width, int height, PixelFormat format) @extern("SDL_CreateSurface");
extern fn Surface* create_surface_from(int width, int height, PixelFormat format, void *pixels, int pitch) @extern("SDL_CreateSurfaceFrom");
extern fn void destroy_surface(Surface* surface) @extern("SDL_DestroySurface");
extern fn PropertiesID get_surface_properties(Surface* surface) @extern("SDL_GetSurfaceProperties");
const ZString PROP_SURFACE_SDR_WHITE_POINT_FLOAT @builtin = "SDL.surface.SDR_white_point";
const ZString PROP_SURFACE_HDR_HEADROOM_FLOAT @builtin = "SDL.surface.HDR_headroom";
const ZString PROP_SURFACE_TONEMAP_OPERATOR_STRING @builtin = "SDL.surface.tonemap";
const ZString PROP_SURFACE_HOTSPOT_X_NUMBER @builtin = "SDL.surface.hotspot.x";
const ZString PROP_SURFACE_HOTSPOT_Y_NUMBER @builtin = "SDL.surface.hotspot.y";
extern fn bool set_surface_colorspace(Surface* surface, Colorspace colorspace) @extern("SDL_SetSurfaceColorspace");
extern fn Colorspace get_surface_colorspace(Surface* surface) @extern("SDL_GetSurfaceColorspace");
extern fn Palette* create_surface_palette(Surface* surface) @extern("SDL_CreateSurfacePalette");
extern fn bool set_surface_palette(Surface* surface, Palette* palette) @extern("SDL_SetSurfacePalette");
extern fn Palette* get_surface_palette(Surface* surface) @extern("SDL_GetSurfacePalette");
extern fn bool add_surface_alternate_image(Surface* surface, Surface* image) @extern("SDL_AddSurfaceAlternateImage");
extern fn bool surface_has_alternate_images(Surface* surface) @extern("SDL_SurfaceHasAlternateImages");
extern fn Surface* * get_surface_images(Surface* surface, int *count) @extern("SDL_GetSurfaceImages");
extern fn void remove_surface_alternate_images(Surface* surface) @extern("SDL_RemoveSurfaceAlternateImages");
extern fn bool lock_surface(Surface* surface) @extern("SDL_LockSurface");
extern fn void unlock_surface(Surface* surface) @extern("SDL_UnlockSurface");
extern fn Surface* load_bmp_io(IOStream *src, bool closeio) @extern("SDL_LoadBMP_IO");
extern fn Surface* load_bmp(ZString file) @extern("SDL_LoadBMP");
extern fn bool save_bmp_io(Surface* surface, IOStream *dst, bool closeio) @extern("SDL_SaveBMP_IO");
extern fn bool save_bmp(Surface* surface, ZString file) @extern("SDL_SaveBMP");
extern fn bool set_surface_rle(Surface* surface, bool enabled) @extern("SDL_SetSurfaceRLE");
extern fn bool surface_has_rle(Surface* surface) @extern("SDL_SurfaceHasRLE");
extern fn bool set_surface_color_key(Surface* surface, bool enabled, uint key) @extern("SDL_SetSurfaceColorKey");
extern fn bool surface_has_color_key(Surface* surface) @extern("SDL_SurfaceHasColorKey");
extern fn bool get_surface_color_key(Surface* surface, uint *key) @extern("SDL_GetSurfaceColorKey");
extern fn bool set_surface_color_mod(Surface* surface, char r, char g, char b) @extern("SDL_SetSurfaceColorMod");
extern fn bool get_surface_color_mod(Surface* surface, char *r, char *g, char *b) @extern("SDL_GetSurfaceColorMod");
extern fn bool set_surface_alpha_mod(Surface* surface, char alpha) @extern("SDL_SetSurfaceAlphaMod");
extern fn bool get_surface_alpha_mod(Surface* surface, char *alpha) @extern("SDL_GetSurfaceAlphaMod");
extern fn bool set_surface_blend_mode(Surface* surface, BlendMode blendMode) @extern("SDL_SetSurfaceBlendMode");
extern fn bool get_surface_blend_mode(Surface* surface, BlendMode *blendMode) @extern("SDL_GetSurfaceBlendMode");
extern fn bool set_surface_clip_rect(Surface* surface, Rect* rect) @extern("SDL_SetSurfaceClipRect");
extern fn bool get_surface_clip_rect(Surface* surface, Rect* rect) @extern("SDL_GetSurfaceClipRect");
extern fn bool flip_surface(Surface* surface, FlipMode flip) @extern("SDL_FlipSurface");
extern fn Surface* duplicate_surface(Surface* surface) @extern("SDL_DuplicateSurface");
extern fn Surface* scale_surface(Surface* surface, int width, int height, ScaleMode scaleMode) @extern("SDL_ScaleSurface");
extern fn Surface* convert_surface(Surface* surface, PixelFormat format) @extern("SDL_ConvertSurface");
extern fn Surface* convert_surface_and_colorspace(Surface* surface, PixelFormat format, Palette* palette, Colorspace colorspace, PropertiesID props) @extern("SDL_ConvertSurfaceAndColorspace");
extern fn bool convert_pixels(int width, int height, PixelFormat src_format, void* src, int src_pitch, PixelFormat dst_format, void *dst, int dst_pitch) @extern("SDL_ConvertPixels");
extern fn bool convert_pixels_and_colorspace(int width, int height, PixelFormat src_format, Colorspace src_colorspace, PropertiesID src_properties, void* src, int src_pitch, PixelFormat dst_format, Colorspace dst_colorspace, PropertiesID dst_properties, void *dst, int dst_pitch) @extern("SDL_ConvertPixelsAndColorspace");
extern fn bool premultiply_alpha(int width, int height, PixelFormat src_format, void* src, int src_pitch, PixelFormat dst_format, void *dst, int dst_pitch, bool linear) @extern("SDL_PremultiplyAlpha");
extern fn bool premultiply_surface_alpha(Surface* surface, bool linear) @extern("SDL_PremultiplySurfaceAlpha");
extern fn bool clear_surface(Surface* surface, float r, float g, float b, float a) @extern("SDL_ClearSurface");
extern fn bool fill_surface_rect(Surface* dst, Rect* rect, uint color) @extern("SDL_FillSurfaceRect");
extern fn bool fill_surface_rects(Surface* dst, Rect* rects, int count, uint color) @extern("SDL_FillSurfaceRects");
extern fn bool blit_surface(Surface* src, Rect* srcrect, Surface* dst, Rect* dstrect) @extern("SDL_BlitSurface");
extern fn bool blit_surface_unchecked(Surface* src, Rect* srcrect, Surface* dst, Rect* dstrect) @extern("SDL_BlitSurfaceUnchecked");
extern fn bool blit_surface_scaled(Surface* src, Rect* srcrect, Surface* dst, Rect* dstrect, ScaleMode scaleMode) @extern("SDL_BlitSurfaceScaled");
extern fn bool blit_surface_unchecked_scaled(Surface* src, Rect* srcrect, Surface* dst, Rect* dstrect, ScaleMode scaleMode) @extern("SDL_BlitSurfaceUncheckedScaled");
extern fn bool stretch_surface(Surface* src, Rect* srcrect, Surface* dst, Rect* dstrect, ScaleMode scaleMode) @extern("SDL_StretchSurface");
extern fn bool blit_surface_tiled(Surface* src, Rect* srcrect, Surface* dst, Rect* dstrect) @extern("SDL_BlitSurfaceTiled");
extern fn bool blit_surface_tiled_with_scale(Surface* src, Rect* srcrect, float scale, ScaleMode scaleMode, Surface* dst, Rect* dstrect) @extern("SDL_BlitSurfaceTiledWithScale");
extern fn bool blit_surface9_grid(Surface* src, Rect* srcrect, int left_width, int right_width, int top_height, int bottom_height, float scale, ScaleMode scaleMode, Surface* dst, Rect* dstrect) @extern("SDL_BlitSurface9Grid");
extern fn uint map_surface_rgb(Surface* surface, char r, char g, char b) @extern("SDL_MapSurfaceRGB");
extern fn uint map_surface_rgba(Surface* surface, char r, char g, char b, char a) @extern("SDL_MapSurfaceRGBA");
extern fn bool read_surface_pixel(Surface* surface, int x, int y, char *r, char *g, char *b, char *a) @extern("SDL_ReadSurfacePixel");
extern fn bool read_surface_pixel_float(Surface* surface, int x, int y, float *r, float *g, float *b, float *a) @extern("SDL_ReadSurfacePixelFloat");
extern fn bool write_surface_pixel(Surface* surface, int x, int y, char r, char g, char b, char a) @extern("SDL_WriteSurfacePixel");
extern fn bool write_surface_pixel_float(Surface* surface, int x, int y, float r, float g, float b, float a) @extern("SDL_WriteSurfacePixelFloat");