Open Source Tomb Raider Engine
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

TextureManager.h 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. /*!
  26. * \brief Binds the texture for use in GL
  27. * \param n valid texture index
  28. * \param s Which TextureStorage should be accessed
  29. */
  30. void bindTextureId(unsigned int n, TextureStorage s = TextureStorage::GAME);
  31. /*!
  32. * \brief Loads Buffer as texture
  33. * \param image pixmap matching other params
  34. * \param width width of image
  35. * \param height height of image
  36. * \param mode mode of image
  37. * \param bpp bits per pixel of image
  38. * \param s Which TextureStorage should be accessed
  39. * \param slot slot (ID) of image
  40. * \param filter if the texture should be mipmap filtered
  41. * \returns texture ID or < 0 on error
  42. */
  43. int loadBufferSlot(unsigned char* image,
  44. unsigned int width, unsigned int height,
  45. ColorMode mode, unsigned int bpp,
  46. TextureStorage s = TextureStorage::GAME,
  47. int slot = -1, bool filter = true);
  48. int loadImage(const char* filename, TextureStorage s = TextureStorage::GAME, int slot = -1);
  49. private:
  50. std::vector<unsigned int>& getIds(TextureStorage s);
  51. int loadTGA(const char* filename, TextureStorage s, int slot);
  52. int loadPCX(const char* filename, TextureStorage s, int slot);
  53. int loadPNG(const char* filename, TextureStorage s, int slot);
  54. std::vector<unsigned int> mTextureIdsGame;
  55. std::vector<unsigned int> mTextureIdsSystem;
  56. };
  57. TextureManager& getTextureManager();
  58. #endif