Berusky3d_kofola2d.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. /* --------------------------------------------------
  2. Rozhrani k 2D grafice
  3. --------------------------------------------------
  4. */
  5. #ifndef __BERUSKY3D_KOFOLA2D_H__
  6. #define __BERUSKY3D_KOFOLA2D_H__
  7. #include "2D_graphic.h"
  8. #define DDX2_BACK_BUFFER (-1)
  9. #define NO_SURFACE (-1)
  10. typedef void (* DDX2_DEVICE_SCREEN_CALLBACK)(void);
  11. typedef struct _DDX2_SURFACE
  12. {
  13. bitmapa *p_bmp;
  14. } DDX2_SURFACE;
  15. typedef struct _DDX2_SURFACE_DEVICE_3D
  16. {
  17. int text;
  18. int filtr;
  19. int format;
  20. BODUV map[4]; // Mapovaci koordinaty v texture
  21. int back_dx, // Rozmery back-bufferu
  22. back_dy;
  23. int text_x, // Pozice a rozmery textury v Back-bufferu
  24. text_y,
  25. text_dx,
  26. text_dy,
  27. text_real_dx,
  28. text_real_dy;
  29. int scr_x, // Rozmery a pozice device na obrazovce
  30. scr_y,
  31. scr_dx,
  32. scr_dy;
  33. } DDX2_SURFACE_DEVICE_3D;
  34. typedef struct _DDX2_SURFACE_DEVICE
  35. {
  36. struct _DDX2_SURFACE_DEVICE *p_next;
  37. bitmapa *p_back_buffer;
  38. DDX2_SURFACE_DEVICE_3D hw;
  39. int rnum;
  40. RECT *p_rlist;
  41. int draw;
  42. DDX2_DEVICE_SCREEN_CALLBACK p_resize_callback;
  43. } DDX2_SURFACE_DEVICE;
  44. typedef struct _DDX2_SURFACE_LIST
  45. {
  46. int surf_num;
  47. int surf_max;
  48. DDX2_SURFACE *p_slist;
  49. dword pruhledna_barva;
  50. } DDX2_SURFACE_LIST;
  51. typedef size_ptr DeviceHandle;
  52. typedef int SurfaceHandle;
  53. //------------------------------------------------------------------------------------------------
  54. // Name: ddx2Init()
  55. // Desc: Vyrobi rezervoar na surfacy
  56. //------------------------------------------------------------------------------------------------
  57. int ddx2Init(int max_surfacu, dword pruhledna_barva);
  58. //------------------------------------------------------------------------------------------------
  59. // Name: ddx2Release()
  60. // Desc: Zrusi rezervovar na surfacy
  61. //------------------------------------------------------------------------------------------------
  62. void ddx2Release(void);
  63. //-----------------------------------------------------------------------------
  64. // Name: ddx2DeviceCreate()
  65. // Desc: Vyrobi renderovaci device a vlozi ho to seznamu devicu
  66. // filtr - TRUE - linear, FALSE - near
  67. // bpp - 16/32
  68. //-----------------------------------------------------------------------------
  69. DeviceHandle ddx2DeviceCreate(int linear_filtr, int bpp, bool cursor_device = FALSE);
  70. //-----------------------------------------------------------------------------
  71. // Name: ddx2DeviceSetActive()
  72. // Desc: Nastavi renderovaci device jako aktivni
  73. //-----------------------------------------------------------------------------
  74. DeviceHandle ddx2DeviceSetActive(DeviceHandle handle);
  75. //-----------------------------------------------------------------------------
  76. // Name: ddx2DeviceSetCursor()
  77. // Desc: Set this device as a cursor device
  78. //-----------------------------------------------------------------------------
  79. DeviceHandle ddx2DeviceSetCursor(DeviceHandle handle);
  80. //-----------------------------------------------------------------------------
  81. // Name: ddx2DeviceRemove()
  82. // Desc: Zrusi zarizeni, pokud je aktivni nastavi aktivni prvni v seznamu
  83. //-----------------------------------------------------------------------------
  84. DeviceHandle ddx2DeviceRemove(DeviceHandle handle);
  85. //-----------------------------------------------------------------------------
  86. // Name: ddx2DeviceResBackBuffer(int back_dx, int back_dy)
  87. // Desc: Nastavi rozmer back-bufferu
  88. //-----------------------------------------------------------------------------
  89. DeviceHandle ddx2DeviceSetBackBufferSize(int back_dx, int back_dy);
  90. //-----------------------------------------------------------------------------
  91. // Name: ddx2DeviceSetBackBufferRect(int text_x, int text_y, int text_dx, int text_dy)
  92. // Desc: Nastavi pozici a rozmery textury v back-bufferu
  93. //-----------------------------------------------------------------------------
  94. DeviceHandle ddx2DeviceSetBackBufferRect(int text_x, int text_y, int text_dx, int text_dy);
  95. //-----------------------------------------------------------------------------
  96. // Name: ddx2DeviceSetTextRenderRec(int vx, int vy, int v_dx, int v_dy)
  97. // Desc: Nastavi oblast textury, ktera se bude prenaset na obrazovku
  98. //-----------------------------------------------------------------------------
  99. DeviceHandle ddx2DeviceSetTextRenderRec(int vx, int vy, int v_dx, int v_dy);
  100. //-----------------------------------------------------------------------------
  101. // Name: ddx2DeviceSetScreenRec(int scr_x, int scr_y, int scr_dx, int scr_dy)
  102. // Desc: Nastavi pozici textury na obrazovce (umisteni + rozmer)
  103. //-----------------------------------------------------------------------------
  104. DeviceHandle ddx2DeviceSetScreenRec(int scr_x, int scr_y, int scr_dx = 0, int scr_dy = 0);
  105. //-----------------------------------------------------------------------------
  106. // Name: ddx2DeviceSetScreenRecCallback(DDX2DEVICESCREENRECCALLBACK p_callback)
  107. // Desc: Sets a callback for screen resize
  108. //-----------------------------------------------------------------------------
  109. void ddx2ScreenResDefaultCallback(void);
  110. DeviceHandle ddx2DeviceSetScreenRecCallback(DDX2_DEVICE_SCREEN_CALLBACK p_callback);
  111. //-----------------------------------------------------------------------------
  112. // Name: ddx2DeviceDeaktivuj()
  113. // Desc: Odmapuje aktivni zarizeni zobrazovky (smaze texturu a pod.)
  114. //-----------------------------------------------------------------------------
  115. DeviceHandle ddx2DeviceDeaktivuj(void);
  116. //-----------------------------------------------------------------------------
  117. // Name: ddx2DeviceSetRender(int draw)
  118. // Desc: Povoli/zakaze kresleni device (na zacatku je kresleni zakazano)
  119. //-----------------------------------------------------------------------------
  120. DeviceHandle ddx2DeviceSetRender(int draw);
  121. //-----------------------------------------------------------------------------
  122. // Name: ddx2DeviceGetInfo()
  123. // Desc: Cte informace o velikost obsazene pameti a poctu surfacu (vsech)
  124. //-----------------------------------------------------------------------------
  125. DeviceHandle ddx2DeviceGetInfo(int *p_surfacu, int *p_mem);
  126. //-----------------------------------------------------------------------------
  127. // Name: ddx2SetRect()
  128. // Desc: Nastavi seznam recu na kresleni, NULL = nic nekreslit
  129. //-----------------------------------------------------------------------------
  130. void ddx2SetRect(RECT * p_rlist, int rnum);
  131. //------------------------------------------------------------------------------------------------
  132. // finds first free index
  133. //------------------------------------------------------------------------------------------------
  134. SurfaceHandle ddx2FindFreeSurface(void);
  135. //------------------------------------------------------------------------------------------------
  136. // release bitmap
  137. //------------------------------------------------------------------------------------------------
  138. SurfaceHandle ddx2ReleaseBitmap(SurfaceHandle iSurface);
  139. //------------------------------------------------------------------------------------------------
  140. // load bitmap from a directory na pozici
  141. //------------------------------------------------------------------------------------------------
  142. SurfaceHandle ddx2LoadBitmapPos(SurfaceHandle handle, char *pFileName, char *pDirName);
  143. //------------------------------------------------------------------------------------------------
  144. // load bitmap from a directory
  145. //------------------------------------------------------------------------------------------------
  146. SurfaceHandle ddx2LoadBitmap(char *pFileName, char *pDirName);
  147. //------------------------------------------------------------------------------------------------
  148. // load bitmap from DISK
  149. //------------------------------------------------------------------------------------------------
  150. SurfaceHandle ddx2LoadBitmapDisk(char *pFileName);
  151. //------------------------------------------------------------------------------------------------
  152. // load bitmap from DISK na pozici
  153. //------------------------------------------------------------------------------------------------
  154. SurfaceHandle ddx2LoadBitmapPosDisk(SurfaceHandle handle, char *pFileName);
  155. //------------------------------------------------------------------------------------------------
  156. // load list of bitmaps from a directory
  157. //------------------------------------------------------------------------------------------------
  158. int ddx2LoadList(char *pFileName, char *pBmpDir, char *p_bmp_dir);
  159. //------------------------------------------------------------------------------------------------
  160. // Create Surface
  161. //------------------------------------------------------------------------------------------------
  162. SurfaceHandle ddx2CreateSurface(int x, int y, int idx);
  163. void ddx2DrawSurfaceColorKey(int iSurface, int *com, int layer, COLORREF color);
  164. void ddx2DrawDisplayColorKey(int *com, int layer, COLORREF color);
  165. void ddx2DrawSurface(int iSurface, int *com, int layer);
  166. void ddx2DrawDisplay(int *com, int layer);
  167. BOOL ddx2TransparentBlt(SurfaceHandle dst, int dx, int dy, int dsirka, int dvyska,
  168. SurfaceHandle src, int sx, int sy, dword pruhledna);
  169. BOOL ddx2TransparentBltDisplay(int dx, int dy, int dsirka, int dvyska,
  170. int dcSrcSurface,
  171. int sx, int sy, int ssirka, int svyska,
  172. UINT crTransparent);
  173. BOOL ddx2TransparentBltFull(SurfaceHandle dst, int dx, int dy,
  174. SurfaceHandle src, dword barva);
  175. BOOL ddx2BitBlt(SurfaceHandle dst, int dx, int dy, int sirka, int vyska,
  176. SurfaceHandle src, int sx, int sy);
  177. BOOL ddx2BitBltStretch(SurfaceHandle dst, int dx, int dy, int dst_width, int dst_height,
  178. SurfaceHandle src, int sx, int sy, int src_width, int src_height);
  179. BOOL ddx2BitBltDisplay(int dx, int dy, int sirka, int vyska,
  180. int dcSrcSurface, int sx, int sy);
  181. BOOL ddx2BitBltFull(SurfaceHandle dst, int dx, int dy, SurfaceHandle src);
  182. int ddx2GetWidth(SurfaceHandle src);
  183. int ddx2GetHeight(SurfaceHandle src);
  184. void ddx2CleareSurfaceColor(SurfaceHandle iSurface, COLORREF color);
  185. void ddx2FillRect(SurfaceHandle iSurface, RECT * rect, COLORREF color);
  186. void ddx2CleareSurface(SurfaceHandle iSurface);
  187. void ddx2AddRectItem(RECT_LINE * p_rl, RECT rect, int iLayer = 0);
  188. void ddx2DrawCursor(SurfaceHandle iSurface, int x, int y, int dx, int dy, dword pruhledna);
  189. void ddx2DrawCursorSetDraw(int draw);
  190. //------------------------------------------------------------------------------------------------
  191. // Povoli/zakaze rendering hry (3D modelu a pod.)
  192. //------------------------------------------------------------------------------------------------
  193. void ddx2GameRender(int render);
  194. // ----------------------------------------------------------------------------
  195. // Name: ddx2RenderDevices()
  196. // Desc: Vykresli menu pouze menu, bez mazani obrazovky a flipu
  197. // Vola se pokud se menu ma kreslit jako soucast hry (volat po renderingu
  198. // menu s listim)
  199. // ----------------------------------------------------------------------------
  200. void ddx2RenderDevices(G_KONFIG * p_ber);
  201. // ----------------------------------------------------------------------------
  202. // Name: ddx2RenderujVse()
  203. // Desc: Vykresli menu
  204. // Kresli menu vcetne vymazani obrazovky
  205. // ----------------------------------------------------------------------------
  206. void ddx2RenderujVse(G_KONFIG * p_ber);
  207. #endif