Surface.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. ** Command & Conquer Generals(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. /***********************************************************************************************
  19. *** 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 ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Command & Conquer *
  23. * *
  24. * $Archive:: /Commando/Code/wwlib/surface.h $*
  25. * *
  26. * $Author:: Byon_g $*
  27. * *
  28. * $Modtime:: 11/28/00 2:40p $*
  29. * *
  30. * $Revision:: 3 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if _MSC_VER >= 1000
  36. #pragma once
  37. #endif // _MSC_VER >= 1000
  38. #ifndef SURFACE_H
  39. #define SURFACE_H
  40. #include "point.h"
  41. #include "trect.h"
  42. /*
  43. ** This is an abstract interface class for a graphic surface. Graphic operations will use this
  44. ** interface to perform their function. The philosphy behind this interface is that it represents
  45. ** a small but useful set of functions. Emphasis is placed on supporting those functions which are
  46. ** likely to have hardware assist.
  47. */
  48. class Surface
  49. {
  50. public:
  51. Surface(int width, int height) : Width(width), Height(height) {}
  52. virtual ~Surface(void) {};
  53. /*
  54. ** Copies regions from one surface to another.
  55. */
  56. virtual bool Blit_From(Rect const & dcliprect, Rect const & destrect, Surface const & source, Rect const & scliprect, Rect const & sourcerect, bool trans=false) = 0;
  57. virtual bool Blit_From(Rect const & destrect, Surface const & source, Rect const & sourcerect, bool trans=false) = 0;
  58. virtual bool Blit_From(Surface const & source, bool trans=false) = 0;
  59. /*
  60. ** Fills a region with a constant color.
  61. */
  62. virtual bool Fill_Rect(Rect const & rect, int color) = 0;
  63. virtual bool Fill_Rect(Rect const & cliprect, Rect const & fillrect, int color) = 0;
  64. virtual bool Fill(int color) = 0;
  65. /*
  66. ** Fetches and stores a pixel to the display (pixel is in surface format).
  67. */
  68. virtual bool Put_Pixel(Point2D const & point, int color) = 0;
  69. virtual int Get_Pixel(Point2D const & point) const = 0;
  70. /*
  71. ** Draws lines onto the surface.
  72. */
  73. virtual bool Draw_Line(Point2D const & startpoint, Point2D const & endpoint, int color) = 0;
  74. virtual bool Draw_Line(Rect const & cliprect, Point2D const & startpoint, Point2D const & endpoint, int color) = 0;
  75. /*
  76. ** Draws rectangle onto the surface.
  77. */
  78. virtual bool Draw_Rect(Rect const & rect, int color) = 0;
  79. virtual bool Draw_Rect(Rect const & cliprect, Rect const & rect, int color) = 0;
  80. /*
  81. ** Gets and frees a direct pointer to the video memory.
  82. */
  83. virtual void * Lock(Point2D point = Point2D(0, 0)) const = 0;
  84. virtual bool Unlock(void) const = 0;
  85. virtual bool Is_Locked(void) const = 0;
  86. /*
  87. ** Queries information about the surface.
  88. */
  89. virtual int Bytes_Per_Pixel(void) const = 0;
  90. virtual int Stride(void) const = 0;
  91. virtual Rect Get_Rect(void) const {return(Rect(0, 0, Width, Height));}
  92. virtual int Get_Width(void) const {return(Width);}
  93. virtual int Get_Height(void) const {return(Height);}
  94. /*
  95. ** Hack function to serve the purpose that RTTI was invented for, but since
  96. ** the Watcom compiler doesn't support RTTI, we must resort to using this
  97. ** alternative.
  98. */
  99. virtual bool Is_Direct_Draw(void) const {return(false);}
  100. protected:
  101. /*
  102. ** Records logical pixel dimensions of the surface.
  103. */
  104. int Width;
  105. int Height;
  106. };
  107. #endif