Open Source Tomb Raider Engine
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Render.h 4.4KB

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