r_patch.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /* Emacs style mode select -*- C++ -*-
  2. *-----------------------------------------------------------------------------
  3. *
  4. *
  5. * PrBoom: a Doom port merged with LxDoom and LSDLDoom
  6. * based on BOOM, a modified and improved DOOM engine
  7. * Copyright (C) 1999 by
  8. * id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
  9. * Copyright (C) 1999-2000 by
  10. * Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
  11. * Copyright 2005, 2006 by
  12. * Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License
  16. * as published by the Free Software Foundation; either version 2
  17. * of the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  27. * 02111-1307, USA.
  28. *
  29. *-----------------------------------------------------------------------------*/
  30. #ifndef R_PATCH_H
  31. #define R_PATCH_H
  32. // Used to specify the sloping of the top and bottom of a column post
  33. typedef enum {
  34. RDRAW_EDGESLOPE_TOP_UP = (1<<0),
  35. RDRAW_EDGESLOPE_TOP_DOWN = (1<<1),
  36. RDRAW_EDGESLOPE_BOT_UP = (1<<2),
  37. RDRAW_EDGESLOPE_BOT_DOWN = (1<<3),
  38. RDRAW_EDGESLOPE_TOP_MASK = 0x3,
  39. RDRAW_EDGESLOPE_BOT_MASK = 0xc,
  40. } edgeslope_t;
  41. typedef struct {
  42. int topdelta;
  43. int length;
  44. edgeslope_t slope;
  45. } rpost_t;
  46. typedef struct {
  47. int numPosts;
  48. rpost_t *posts;
  49. unsigned char *pixels;
  50. } rcolumn_t;
  51. typedef struct {
  52. int width;
  53. int height;
  54. unsigned widthmask;
  55. unsigned char isNotTileable;
  56. int leftoffset;
  57. int topoffset;
  58. // this is the single malloc'ed/free'd array
  59. // for this patch
  60. unsigned char *data;
  61. // these are pointers into the data array
  62. unsigned char *pixels;
  63. rcolumn_t *columns;
  64. rpost_t *posts;
  65. #ifdef TIMEDIAG
  66. int locktic;
  67. #endif
  68. unsigned int locks;
  69. } rpatch_t;
  70. const rpatch_t *R_CachePatchNum(int id);
  71. void R_UnlockPatchNum(int id);
  72. #define R_CachePatchName(name) R_CachePatchNum(W_GetNumForName(name))
  73. #define R_UnlockPatchName(name) R_UnlockPatchNum(W_GetNumForName(name))
  74. const rpatch_t *R_CacheTextureCompositePatchNum(int id);
  75. void R_UnlockTextureCompositePatchNum(int id);
  76. // Size query funcs
  77. int R_NumPatchWidth(int lump) ;
  78. int R_NumPatchHeight(int lump);
  79. #define R_NamePatchWidth(name) R_NumPatchWidth(W_GetNumForName(name))
  80. #define R_NamePatchHeight(name) R_NumPatchHeight(W_GetNumForName(name))
  81. const rcolumn_t *R_GetPatchColumnWrapped(const rpatch_t *patch, int columnIndex);
  82. const rcolumn_t *R_GetPatchColumnClamped(const rpatch_t *patch, int columnIndex);
  83. // returns R_GetPatchColumnWrapped for square, non-holed textures
  84. // and R_GetPatchColumnClamped otherwise
  85. const rcolumn_t *R_GetPatchColumn(const rpatch_t *patch, int columnIndex);
  86. void R_InitPatches();
  87. void R_FlushAllPatches();
  88. #endif