sdl_surface.odin 5.8 KB

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