glue.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. Copyright (c) 2014-2022 Bruce A Henderson
  3. This software is provided 'as-is', without any express or implied
  4. warranty. In no event will the authors be held liable for any damages
  5. arising from the use of this software.
  6. Permission is granted to anyone to use this software for any purpose,
  7. including commercial applications, and to alter it and redistribute it
  8. freely, subject to the following restrictions:
  9. 1. The origin of this software must not be misrepresented; you must not
  10. claim that you wrote the original software. If you use this software
  11. in a product, an acknowledgment in the product documentation would be
  12. appreciated but is not required.
  13. 2. Altered source versions must be plainly marked as such, and must not be
  14. misrepresented as being the original software.
  15. 3. This notice may not be removed or altered from any source
  16. distribution.
  17. */
  18. #include "SDL_surface.h"
  19. #include "brl.mod/blitz.mod/blitz.h"
  20. SDL_PixelFormat * bmx_sdl_surface_Format(SDL_Surface * surface) {
  21. return surface->format;
  22. }
  23. int bmx_sdl_surface_Width(SDL_Surface * surface) {
  24. return surface->w;
  25. }
  26. int bmx_sdl_surface_Height(SDL_Surface * surface) {
  27. return surface->h;
  28. }
  29. int bmx_sdl_surface_Pitch(SDL_Surface * surface) {
  30. return surface->pitch;
  31. }
  32. void * bmx_sdl_surface_Pixels(SDL_Surface * surface) {
  33. return surface->pixels;
  34. }
  35. void bmx_sdl_surface_GetClipRect(SDL_Surface * surface, int * x, int * y, int * w, int * h) {
  36. SDL_Rect r;
  37. SDL_GetClipRect(surface, &r);
  38. *x = r.x;
  39. *y = r.y;
  40. *w = r.w;
  41. *h = r.h;
  42. }
  43. void bmx_sdl_surface_SetClipRect(SDL_Surface * surface, int x, int y, int w, int h) {
  44. SDL_Rect r;
  45. r.x = x;
  46. r.y = y;
  47. r.w = w;
  48. r.h = h;
  49. SDL_SetClipRect(surface, &r);
  50. }
  51. int bmx_sdl_surface_MustLock(SDL_Surface * surface) {
  52. return SDL_MUSTLOCK(surface);
  53. }
  54. int bmx_sdl_surface_FillRect(SDL_Surface * surface, int x, int y, int w, int h, Uint32 color) {
  55. SDL_Rect r;
  56. r.x = x;
  57. r.y = y;
  58. r.w = w;
  59. r.h = h;
  60. return SDL_FillRect(surface, &r, color);
  61. }
  62. int bmx_sdl_surface_Blit(SDL_Surface * surface, int sx, int sy, int sw, int sh, SDL_Surface * dest, int dx, int dy) {
  63. SDL_Rect sr;
  64. sr.x = sx;
  65. sr.y = sy;
  66. sr.w = sw;
  67. sr.h = sh;
  68. SDL_Rect dr;
  69. dr.x = dx;
  70. dr.y = dy;
  71. return SDL_BlitSurface(surface, (sw==0 && sh==0 && sx==0 && sy==0) ? NULL : &sr, dest, &dr);
  72. }
  73. int bmx_sdl_surface_BlitScaled(SDL_Surface * surface, int sx, int sy, int sw, int sh, SDL_Surface * dest, int dx, int dy) {
  74. SDL_Rect sr;
  75. sr.x = sx;
  76. sr.y = sy;
  77. sr.w = sw;
  78. sr.h = sh;
  79. SDL_Rect dr;
  80. dr.x = dx;
  81. dr.y = dy;
  82. return SDL_BlitScaled(surface, (sw==0 && sh==0 && sx==0 && sy==0) ? NULL : &sr, dest, &dr);
  83. }
  84. SDL_Surface * bmx_sdl_LoadBMP(BBString * file) {
  85. char * f = bbStringToUTF8String(file);
  86. SDL_Surface * surface = SDL_LoadBMP(f);
  87. bbMemFree(f);
  88. return surface;
  89. }