Open Source Tomb Raider Engine
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

TextureManager.h 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*!
  2. * \file include/TextureManager.h
  3. * \brief Texture registry
  4. *
  5. * \author Mongoose
  6. * \author xythobuz
  7. */
  8. #ifndef _TEXTURE_MANAGER_H
  9. #define _TEXTURE_MANAGER_H
  10. #include <vector>
  11. /*!
  12. * \brief Texture registry
  13. */
  14. class TextureManager {
  15. public:
  16. enum TextureFlag {
  17. fUseMultiTexture = (1 << 0),
  18. };
  19. /*!
  20. * \brief Constructs an object of Texture
  21. */
  22. TextureManager();
  23. /*!
  24. * \brief Deconstructs an object of Texture
  25. */
  26. ~TextureManager();
  27. /*!
  28. * \brief Resets all texture data
  29. */
  30. void reset();
  31. int initialize();
  32. /*!
  33. * \brief Get number of textures in use
  34. * \returns used texture count, or -1 on error (uninitialized)
  35. */
  36. int getTextureCount();
  37. /*!
  38. * \brief Sets up multitexture rendering with passed ids
  39. * \param texture0 first texture for multitexture
  40. * \param texture1 second texture for multitexture
  41. */
  42. void bindMultiTexture(int texture0, int texture1);
  43. /*!
  44. * \brief Binds the texture for use in GL
  45. * \param n valid texture index
  46. */
  47. void bindTextureId(unsigned int n);
  48. /*!
  49. * \brief Clears an option flag
  50. * \param flag flag to clear
  51. */
  52. void clearFlag(TextureFlag flag);
  53. void disableMultiTexture();
  54. /*!
  55. * \brief Loads Buffer as texture
  56. * \param image pixmap matching other params
  57. * \param width width of image
  58. * \param height height of image
  59. * \param mode mode of image
  60. * \param bpp bits per pixel of image
  61. * \param slot slot (ID) of image
  62. * \param filter if the texture should be mipmap filtered
  63. * \returns texture ID or < 0 on error
  64. */
  65. int loadBufferSlot(unsigned char *image,
  66. unsigned int width, unsigned int height,
  67. ColorMode mode, unsigned int bpp,
  68. unsigned int slot, bool filter = true);
  69. int loadImage(const char *filename);
  70. /*!
  71. * \brief Sets an option flag
  72. * \param flag flag to set
  73. */
  74. void setFlag(TextureFlag flag);
  75. void useMultiTexture(float aU, float aV, float bU, float bV);
  76. private:
  77. int loadTGA(const char *filename);
  78. int loadPCX(const char *filename);
  79. int loadPNG(const char *filename);
  80. std::vector<unsigned int> mTextureIds;
  81. unsigned int mFlags;
  82. };
  83. TextureManager &getTextureManager();
  84. #endif