SURFACE.H 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. ** Command & Conquer Red Alert(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /* $Header: /CounterStrike/SURFACE.H 1 3/03/97 10:25a Joe_bostic $ */
  19. /***********************************************************************************************
  20. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Command & Conquer *
  24. * *
  25. * File Name : SURFACE.H *
  26. * *
  27. * Programmer : Joe L. Bostic *
  28. * *
  29. * Start Date : 09/08/96 *
  30. * *
  31. * Last Update : September 8, 1996 [JLB] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #ifndef SURFACE_H
  37. #define SURFACE_H
  38. #include "buff.h"
  39. #include "rect.h"
  40. /*
  41. ** This class is used to represent an arbitrary rectangle in a graphic memory space. Typically,
  42. ** this represents what could be called a graphic buffer or even a portion of a graphic buffer.
  43. ** It can also represent a piece of artwork (such as a shape image) to be used to construct a
  44. ** display image. This wide range of use is possible, because this class is a very minimal
  45. ** representation of the graphic data. It holds only the information is absolutely needs and
  46. ** has the minimum member functions possible.
  47. */
  48. class Surface
  49. {
  50. public:
  51. Surface(void) : Width(0), Height(0), Pitch(0) {}
  52. Surface(int w, int h, Buffer const * buffer=NULL, int pitch=0);
  53. Surface(Surface const & surface, int x, int y, int w, int h);
  54. virtual ~Surface(void) {}
  55. /*
  56. ** Basic manipulation routines for copying entire surfaces or
  57. ** a sub-region.
  58. */
  59. void Copy_To(Rect const & fromrect, Surface & tosurface, Rect const & torect) const;
  60. void Copy_To(Rect const & fromrect, Buffer & tobuffer) const;
  61. /*
  62. ** Convenience routines that make presumptions on what is desired so that a
  63. ** minimum of parameters can be specified. These routine ultimately map to the
  64. ** basic copy routines.
  65. */
  66. void Copy_To(Buffer & buffer, int x=0, int y=0, int w=-1, int h=-1) const;
  67. void Copy_From(Buffer const & buffer, int x=0, int y=0, int w=-1, int h=-1);
  68. /*
  69. ** Basic query functions. Support routines that will manipulate the underlying
  70. ** image data will require access to this information.
  71. */
  72. void * Get_Buffer(void) const {return(SurfaceData.Get_Buffer());}
  73. int Get_Size(void) const {return(Bytes_Per_Line() * Height);}
  74. int Get_Width(void) const {return(Width);}
  75. int Get_Height(void) const {return(Height);}
  76. int Get_Pitch(void) const {return(Pitch);}
  77. protected:
  78. int Bytes_Per_Line(void) const {return(Width+Pitch);}
  79. /*
  80. ** This is the pointer to the surface memory. Sometimes this could be allocated memory
  81. ** managed by this class but more likely, it is memory that is merely referred to by
  82. ** this class.
  83. */
  84. Buffer SurfaceData;
  85. /*
  86. ** This is the width (columns) of the surface (in pixels).
  87. */
  88. int Width;
  89. /*
  90. ** This ithe height (rows) of the surface (in pixels).
  91. */
  92. int Height;
  93. /*
  94. ** This is the modulus of the surface underlying memory 'display surface' width
  95. ** divided by this surface's width. For a surface that is full width, this value
  96. ** will be 0. This value will be non-zero if this surface is referring to a
  97. ** sub-region within another surface.
  98. */
  99. int Pitch;
  100. };
  101. #endif