Open Source Tomb Raider Engine
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

Render.h 3.8KB

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