bw_render.h 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 : ww3d *
  23. * *
  24. * $Archive:: /Commando/Code/ww3d2/bw_render.h $*
  25. * *
  26. * Original Author:: Jani Penttinen *
  27. * *
  28. * $Author:: Greg_h $*
  29. * *
  30. * $Modtime:: 3/26/01 4:53p $*
  31. * *
  32. * $Revision:: 3 $*
  33. * *
  34. *---------------------------------------------------------------------------------------------*
  35. * Functions: *
  36. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  37. #if defined(_MSC_VER)
  38. #pragma once
  39. #endif
  40. #ifndef BW_RENDER_H__
  41. #define BW_RENDER_H__
  42. #include "always.h"
  43. #include "vector2.h"
  44. #include "vector3.h"
  45. #include "vector3i.h"
  46. class BW_Render
  47. {
  48. // Internal pixel buffer used by the triangle renderer
  49. // The buffer is not allocated or freed by this class.
  50. class Buffer
  51. {
  52. unsigned char* buffer;
  53. int scale;
  54. int minv;
  55. int maxv;
  56. public:
  57. Buffer(unsigned char* buffer, int scale);
  58. ~Buffer();
  59. void Set_H_Line(int start_x, int end_x, int y);
  60. void Fill(unsigned char c);
  61. inline int Scale() const { return scale; }
  62. } pixel_buffer;
  63. Vector2* vertices;
  64. void Render_Preprocessed_Triangle(Vector3& xcf,Vector3i& yci);
  65. public:
  66. BW_Render(unsigned char* buffer, int scale);
  67. ~BW_Render();
  68. void Fill(unsigned char c);
  69. void Set_Vertex_Locations(Vector2* vertices,int count); // Warning! Contents are modified!
  70. void Render_Triangles(const unsigned long* indices,int index_count);
  71. void Render_Triangle_Strip(const unsigned long* indices,int index_count);
  72. };
  73. #endif // BW_RENDER_H__