Advertisement
TerusTheBird

masker: sdl_gen.h

Jan 7th, 2025
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.67 KB | Source Code | 0 0
  1. #ifndef __sdl_gen_h
  2. #define __sdl_gen_h
  3.  
  4. #include <stdlib.h>
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include <SDL/SDL.h>
  8.  
  9.  
  10. #define True (1)
  11. #define False (0)
  12.  
  13. typedef char s8;
  14. typedef unsigned char u8;
  15. typedef short s16;
  16. typedef unsigned short u16;
  17. typedef int s32;
  18. typedef unsigned int u32;
  19. typedef long long s64;
  20. typedef unsigned long long u64;
  21.  
  22. #define S8(n) ((s8)(n))
  23. #define U8(n) ((u8)(n))
  24. #define S16(n) ((s16)(n))
  25. #define U16(n) ((u16)(n))
  26. #define S32(n) ((s32)(n))
  27. #define U32(n) ((u32)(n))
  28. #define S64(n) ((s64)(n))
  29. #define U64(n) ((u64)(n))
  30.  
  31. typedef u32 color_t;
  32.  
  33. color_t color_new( u8 r, u8 g, u8 b, u8 a );
  34.  
  35. // The 8 digital colors
  36. #define c_black  0x000000FF
  37. #define c_blue   0x0000FFFF
  38. #define c_green  0x00FF00FF
  39. #define c_cyan   0x00FFFFFF
  40. #define c_red    0xFF0000FF
  41. #define c_pink   0xFF00FFFF
  42. #define c_yellow 0xFFFF00FF
  43. #define c_white  0xFFFFFFFF
  44.  
  45. // various shades of gray
  46. #define c_gray   0xAAAAAAFF
  47. #define c_gray50 0x808080FF
  48. #define c_gray25 0x404040FF
  49.  
  50. // an ugly color for transparent pixels
  51. #define c_trans  0xFF00FEFF
  52.  
  53. size_t fsize( FILE* fp );
  54.  
  55. u32 color_to_surf( SDL_Surface* surf, color_t color );
  56.  
  57. u32 surf_to_color( SDL_Surface* surf, u32 color_sdl );
  58.  
  59. void SDL_Clear( SDL_Surface* surf, color_t color );
  60.  
  61. void SDL_Clear_rect_easy( SDL_Surface* surf, int x, int y, int w, int h, color_t color );
  62.  
  63. void SDL_PutPixel( SDL_Surface* surf, long x, long y, color_t color );
  64.  
  65. color_t SDL_GetPixel( SDL_Surface* surf, long x, long y ); // this could be broken
  66.  
  67. void SDL_Line( SDL_Surface* surf, int x1, int y1, int x2, int y2, color_t color );
  68.  
  69. void SDL_Line_Straight( SDL_Surface* surf, int x, int y, int dx, int dy, int length, color_t color );
  70.  
  71. void SDL_Circle( SDL_Surface* surf, int x, int y, int radius, color_t color );
  72.  
  73. SDL_Surface* surf_new( int w, int h );
  74.  
  75. // out=target_surface  - modify target_surface in place
  76. // out=NULL            - return new surface
  77. SDL_Surface* scale_surface( SDL_Surface* in, SDL_Surface* out, int new_w, int new_h );
  78.  
  79. int save_to_tga( SDL_Surface* surf, char* path );
  80.  
  81. typedef struct rgb96_t rgb96_t;
  82. struct rgb96_t {
  83.     u32 r;
  84.     u32 g;
  85.     u32 b;
  86. };
  87.  
  88. #define RGB96_BLACK ((rgb96_t){.r=0,.g=0,.b=0})
  89.  
  90. u32 pixel_high_gray( rgb96_t c );
  91.  
  92. rgb96_t pixel_high_get( SDL_Surface* surf, long x, long y );
  93. int     pixel_high_put( SDL_Surface* surf, long x, long y, rgb96_t c );
  94.  
  95. rgb96_t pixel_high_add( rgb96_t c1, rgb96_t c2 );
  96. rgb96_t pixel_high_div_n( rgb96_t c1, u32 n );
  97.  
  98. //_Bool pixel_high_LT( rgb96_t c1, rgb96_t c2 );
  99. //_Bool pixel_high_LTE( rgb96_t c1, rgb96_t c2 );
  100. //_Bool pixel_high_GT( rgb96_t c1, rgb96_t c2 );
  101. //_Bool pixel_high_GTE( rgb96_t c1, rgb96_t c2 );
  102.  
  103. #endif
  104.  
  105.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement