Open Source Tomb Raider Engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*!
  2. * \file include/Render.h
  3. * \brief OpenRaider Renderer class
  4. *
  5. * \author Mongoose
  6. * \author xythobuz
  7. */
  8. #ifndef _RENDER_H_
  9. #define _RENDER_H_
  10. #include <vector>
  11. #include "Room.h"
  12. #include "ViewVolume.h"
  13. /*!
  14. * \brief OpenRaider Renderer class
  15. */
  16. class Render {
  17. public:
  18. typedef enum {
  19. modeDisabled,
  20. modeLoadScreen,
  21. modeVertexLight,
  22. modeSolid,
  23. modeWireframe,
  24. modeTexture
  25. } RenderMode;
  26. typedef enum {
  27. fRoomAlpha = (1 << 0),
  28. fViewModel = (1 << 1),
  29. fEntityModels = (1 << 2),
  30. fFog = (1 << 3),
  31. fUsePortals = (1 << 4),
  32. fGL_Lights = (1 << 5),
  33. fOneRoom = (1 << 6),
  34. fRenderPonytail = (1 << 7),
  35. // fMultiTexture = (1 << 8), //! \todo Whats up with Multitexture stuff? Where is it needed?
  36. fUpdateRoomListPerFrame = (1 << 9),
  37. fAnimateAllModels = (1 << 10),
  38. fAllRooms = (1 << 11)
  39. } RenderFlags;
  40. /*!
  41. * \brief Constructs an object of Render
  42. */
  43. Render();
  44. /*!
  45. * \brief Deconstructs an object of Render
  46. */
  47. ~Render();
  48. /*!
  49. * \brief Makes a screenshot, writes to disk
  50. * \param filenameBase basename of file to be written
  51. */
  52. void screenShot(char *filenameBase);
  53. /*!
  54. * \brief Gets current rendering mode
  55. * \returns current RenderMode
  56. * \fixme Don't return enum as int?!
  57. */
  58. int getMode();
  59. /*!
  60. * Removes current world/entity/etc geometry
  61. */
  62. void ClearWorld();
  63. /*!
  64. * \brief Clears bitflags, changes state of renderer in some way
  65. * \param flags RenderFlags to clear (ORed)
  66. * \fixme use enum not integer as parameter?!
  67. */
  68. void clearFlags(unsigned int flags);
  69. /*!
  70. * \brief Sets bitflags, changes state of renderer in some way
  71. * \param flags RenderFlags to set (ORed)
  72. * \fixme use enum not integer as parameter?!
  73. */
  74. void setFlags(unsigned int flags);
  75. void setMode(int n);
  76. /*!
  77. * \brief Renders a single game frame
  78. */
  79. void display();
  80. void setSkyMesh(int index, bool rot);
  81. unsigned int getFlags();
  82. /*!
  83. * \brief Check if a point is in the View Volume
  84. * \param x X coordinate
  85. * \param y Y coordinate
  86. * \param z Z coordinate
  87. * \returns true if point is visible
  88. */
  89. bool isVisible(float x, float y, float z);
  90. /*!
  91. * \brief Check if a sphere is in the View Volume
  92. * \param x X coordinate of center of sphere
  93. * \param y Y coordinate of center of sphere
  94. * \param z Z coordinate of center of sphere
  95. * \param radius radius of sphere
  96. * \returns true if sphere is visible
  97. */
  98. bool isVisible(float x, float y, float z, float radius);
  99. bool isVisible(BoundingBox &box);
  100. //! \fixme should be private
  101. ViewVolume mViewVolume; //!< View Volume for frustum culling
  102. private:
  103. void drawLoadScreen();
  104. /*!
  105. * \brief Build a visible room list starting at index
  106. * \param index valid room index where to start the list
  107. */
  108. void newRoomRenderList(int index);
  109. /*!
  110. * \brief Build a visible room list starting from room and
  111. * only considers its linked rooms and their linked rooms.
  112. * \param room First room in list
  113. */
  114. void buildRoomRenderList(Room &room);
  115. /*!
  116. * \brief Renders Sky domes/boxes/etc by scaling factor.
  117. *
  118. * Texture must be initialized.
  119. * \param scale correct scale for map size
  120. */
  121. void drawSkyMesh(float scale);
  122. /*!
  123. * \brief Updates View Volume. Call once per render frame.
  124. */
  125. void updateViewVolume();
  126. std::vector<Room *> mRoomRenderList;
  127. unsigned int mFlags; //!< Rendering flags
  128. unsigned int mMode; //!< Rendering mode
  129. int mLock;
  130. int mSkyMesh; //!< Skymesh model id
  131. bool mSkyMeshRotation; //!< Should Skymesh be rotated?
  132. };
  133. Render &getRender();
  134. #endif