sdl_surface.odin 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. package sdl2
  2. import "core:c"
  3. when ODIN_OS == .Windows {
  4. @(ignore_duplicates)
  5. foreign import lib "SDL2.lib"
  6. } else {
  7. @(ignore_duplicates)
  8. foreign import lib "system:SDL2"
  9. }
  10. SWSURFACE :: 0 /**< Just here for compatibility */
  11. PREALLOC :: 0x00000001 /**< Surface uses preallocated memory */
  12. RLEACCEL :: 0x00000002 /**< Surface is RLE encoded */
  13. DONTFREE :: 0x00000004 /**< Surface is referenced internally */
  14. SIMD_ALIGNED :: 0x00000008 /**< Surface uses aligned memory */
  15. MUSTLOCK :: #force_inline proc "c" (surface: ^Surface) -> bool {
  16. return bool(surface.flags & RLEACCEL != 0)
  17. }
  18. BlitMap :: struct {}
  19. Surface :: struct {
  20. flags: u32, /**< Read-only */
  21. format: ^PixelFormat, /**< Read-only */
  22. w, h: c.int, /**< Read-only */
  23. pitch: c.int, /**< Read-only */
  24. pixels: rawptr, /**< Read-write */
  25. /** Application data associated with the surface */
  26. userdata: rawptr, /**< Read-write */
  27. /** information needed for surfaces requiring locks */
  28. locked: c.int, /**< Read-only */
  29. /** list of BlitMap that hold a reference to this surface */
  30. list_blitmap: rawptr, /**< Private */
  31. /** clipping information */
  32. clip_rect: Rect, /**< Read-only */
  33. /** info for fast blit mapping to other surfaces */
  34. blitmap: ^BlitMap, /**< Private */
  35. /** Reference count -- used when freeing surface */
  36. refcount: c.int, /**< Read-mostly */
  37. }
  38. blit :: proc "c" (src: ^Surface, srcrect: ^Rect, dst: ^Surface, dstrect: ^Rect) -> c.int
  39. YUV_CONVERSION_MODE :: enum c.int {
  40. JPEG, /**< Full range JPEG */
  41. BT601, /**< BT.601 (the default) */
  42. BT709, /**< BT.709 */
  43. AUTOMATIC, /**< BT.601 for SD content, BT.709 for HD content */
  44. }
  45. LoadBMP :: #force_inline proc "c" (file: cstring) -> ^Surface {
  46. return LoadBMP_RW(RWFromFile(file, "rb"), true)
  47. }
  48. SaveBMP :: #force_inline proc "c" (surface: ^Surface, file: cstring) -> c.int {
  49. return SaveBMP_RW(surface, RWFromFile(file, "wb"), true)
  50. }
  51. BlitSurface :: UpperBlit
  52. BlitScaled :: UpperBlitScaled
  53. @(default_calling_convention="c", link_prefix="SDL_")
  54. foreign lib {
  55. CreateRGBSurface :: proc(flags: u32, width, height, depth: c.int, Rmask, Gmask, Bmask, Amask: u32) -> ^Surface ---
  56. CreateRGBSurfaceWithFormat :: proc(flags: u32, width, height, depth: c.int, format: u32) -> ^Surface ---
  57. CreateRGBSurfaceFrom :: proc(pixels: rawptr, width, height, depth, pitch: c.int, Rmask, Gmask, Bmask, Amask: u32) -> ^Surface ---
  58. CreateRGBSurfaceWithFormatFrom :: proc(pixels: rawptr, width, height, depth, pitch: c.int, format: u32) -> ^Surface ---
  59. FreeSurface :: proc(surface: ^Surface) ---
  60. SetSurfacePalette :: proc(surface: ^Surface, palette: ^Palette) -> c.int ---
  61. LockSurface :: proc(surface: ^Surface) -> c.int ---
  62. UnlockSurface :: proc(surface: ^Surface) ---
  63. LoadBMP_RW :: proc(src: ^RWops, freesrc: bool) -> ^Surface ---
  64. SaveBMP_RW :: proc(surface: ^Surface, dst: ^RWops, freedst: bool) -> c.int ---
  65. SetSurfaceRLE :: proc(surface: ^Surface, flag: c.int) -> c.int ---
  66. HasSurfaceRLE :: proc(surface: ^Surface) -> bool ---
  67. SetColorKey :: proc(surface: ^Surface, flag: c.int, key: u32) -> c.int ---
  68. HasColorKey :: proc(surface: ^Surface) -> bool ---
  69. GetColorKey :: proc(surface: ^Surface, key: ^u32) -> c.int ---
  70. SetSurfaceColorMod :: proc(surface: ^Surface, r, g, b: u8) -> c.int ---
  71. GetSurfaceColorMod :: proc(surface: ^Surface, r, g, b: ^u8) -> c.int ---
  72. SetSurfaceAlphaMod :: proc(surface: ^Surface, alpha: u8) -> c.int ---
  73. GetSurfaceAlphaMod :: proc(surface: ^Surface, alpha: ^u8) -> c.int ---
  74. SetSurfaceBlendMode :: proc(surface: ^Surface, blendMode: BlendMode) -> c.int ---
  75. GetSurfaceBlendMode :: proc(surface: ^Surface, blendMode: ^BlendMode) -> c.int ---
  76. SetClipRect :: proc(surface: ^Surface, rect: ^Rect) -> bool ---
  77. GetClipRect :: proc(surface: ^Surface, rect: ^Rect) ---
  78. DuplicateSurface :: proc(surface: ^Surface) -> ^Surface ---
  79. ConvertSurface :: proc(src: ^Surface, fmt: ^PixelFormat, flags: u32) -> ^Surface ---
  80. ConvertSurfaceFormat :: proc(src: ^Surface, pixel_format: u32, flags: u32) -> ^Surface ---
  81. ConvertPixels :: proc(width, height: c.int, src_format: u32, src: rawptr, src_pitch: c.int, dst_format: u32, dst: rawptr, dst_pitch: c.int) -> c.int ---
  82. FillRect :: proc(dst: ^Surface, rect: ^Rect, color: u32) -> c.int ---
  83. FillRects :: proc(dst: ^Surface, rects: [^]Rect, count: c.int, color: u32) -> c.int ---
  84. UpperBlit :: proc(src: ^Surface, srcrect: ^Rect, dst: ^Surface, dstrect: ^Rect) -> c.int ---
  85. LowerBlit :: proc(src: ^Surface, srcrect: ^Rect, dst: ^Surface, dstrect: ^Rect) -> c.int ---
  86. SoftStretch :: proc(src: ^Surface, srcrect: ^Rect, dst: ^Surface, dstrect: ^Rect) -> c.int ---
  87. SoftStretchLinear :: proc(src: ^Surface, srcrect: ^Rect, dst: ^Surface, dstrect: ^Rect) -> c.int ---
  88. UpperBlitScaled :: proc(src: ^Surface, srcrect: ^Rect, dst: ^Surface, dstrect: ^Rect) -> c.int ---
  89. LowerBlitScaled :: proc(src: ^Surface, srcrect: ^Rect, dst: ^Surface, dstrect: ^Rect) -> c.int ---
  90. SetYUVConversionMode :: proc(mode: YUV_CONVERSION_MODE) ---
  91. GetYUVConversionMode :: proc() -> YUV_CONVERSION_MODE ---
  92. GetYUVConversionModeForResolution :: proc(width, height: c.int) -> YUV_CONVERSION_MODE ---
  93. }