bwrender.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 : ww3d2 *
  23. * *
  24. * $Archive:: /Commando/Code/ww3d2/bwrender.h $*
  25. * *
  26. * Original Author:: Jani Penttinen *
  27. * *
  28. * $Author:: Greg_h $*
  29. * *
  30. * $Modtime:: 4/04/01 10:36a $*
  31. * *
  32. * $Revision:: 2 $*
  33. * *
  34. *---------------------------------------------------------------------------------------------*
  35. * Functions: *
  36. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  37. #if defined(_MSC_VER)
  38. #pragma once
  39. #endif
  40. #ifndef BWRENDER_H
  41. #define BWRENDER_H
  42. #include "always.h"
  43. #include "vector2.h"
  44. #include "vector3.h"
  45. #include "vector3i.h"
  46. /**
  47. ** BWRenderClass
  48. ** This class implements a simple black-and-white triangle rasterizer which
  49. ** can be used to generate shadow textures. It is faster than a general purpose
  50. ** software renderer due to the fact that no z-buffering or sorting is needed and
  51. ** texturing isn't supported.
  52. ** (gth) 04/02/2001 - I'm going to add render-to-texture code to Renegade so this
  53. ** class may be obsolete.
  54. */
  55. class BWRenderClass
  56. {
  57. // Internal pixel buffer used by the triangle renderer
  58. // The buffer is not allocated or freed by this class.
  59. class Buffer
  60. {
  61. unsigned char* buffer;
  62. int scale;
  63. int minv;
  64. int maxv;
  65. public:
  66. Buffer(unsigned char* buffer, int scale);
  67. ~Buffer();
  68. void Set_H_Line(int start_x, int end_x, int y);
  69. void Fill(unsigned char c);
  70. inline int Scale() const { return scale; }
  71. } pixel_buffer;
  72. Vector2* vertices;
  73. void Render_Preprocessed_Triangle(Vector3& xcf,Vector3i& yci);
  74. public:
  75. BWRenderClass(unsigned char* buffer, int scale);
  76. ~BWRenderClass();
  77. void Fill(unsigned char c);
  78. void Set_Vertex_Locations(Vector2* vertices,int count); // Warning! Contents are modified!
  79. void Render_Triangles(const unsigned long* indices,int index_count);
  80. void Render_Triangle_Strip(const unsigned long* indices,int index_count);
  81. };
  82. #endif //BWRENDER_H