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.

TextureManager.h 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. // These are loaded into TextureStorage::SYSTEM by initialize()!
  12. #define TEXTURE_WHITE 0
  13. #define TEXTURE_SPLASH 1
  14. /*!
  15. * \brief Texture registry
  16. */
  17. class TextureManager {
  18. public:
  19. enum class TextureStorage {
  20. GAME,
  21. SYSTEM
  22. };
  23. ~TextureManager();
  24. int initialize();
  25. int numTextures(TextureStorage s = TextureStorage::GAME);
  26. /*!
  27. * \brief Binds the texture for use in GL
  28. * \param n valid texture index
  29. * \param s Which TextureStorage should be accessed
  30. */
  31. void bindTextureId(unsigned int n, TextureStorage s = TextureStorage::GAME);
  32. /*!
  33. * \brief Loads Buffer as texture
  34. * \param image pixmap matching other params
  35. * \param width width of image
  36. * \param height height of image
  37. * \param mode mode of image
  38. * \param bpp bits per pixel of image
  39. * \param s Which TextureStorage should be accessed
  40. * \param slot slot (ID) of image
  41. * \param filter if the texture should be mipmap filtered
  42. * \returns texture ID or < 0 on error
  43. */
  44. int loadBufferSlot(unsigned char* image,
  45. unsigned int width, unsigned int height,
  46. ColorMode mode, unsigned int bpp,
  47. TextureStorage s = TextureStorage::GAME,
  48. int slot = -1, bool filter = true);
  49. int loadImage(const char* filename, TextureStorage s = TextureStorage::GAME, int slot = -1);
  50. private:
  51. std::vector<unsigned int>& getIds(TextureStorage s);
  52. int loadTGA(const char* filename, TextureStorage s, int slot);
  53. int loadPCX(const char* filename, TextureStorage s, int slot);
  54. int loadPNG(const char* filename, TextureStorage s, int slot);
  55. std::vector<unsigned int> mTextureIdsGame;
  56. std::vector<unsigned int> mTextureIdsSystem;
  57. };
  58. TextureManager& getTextureManager();
  59. #endif