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.

Render.h 4.7KB

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