Simple game engine with complete export to scripting language
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 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //------------------------------------------------------------------------------
  2. // Author: Gero Mueller <gero.mueller@cloo.de>
  3. // Copyright: (c) 2006 Gero Mueller
  4. // License: MIT License
  5. //------------------------------------------------------------------------------
  6. #ifndef BLUECORE_TEXTURE_MANAGER_H
  7. #define BLUECORE_TEXTURE_MANAGER_H
  8. // system includes
  9. #include <map>
  10. #include <string>
  11. // project includes
  12. #include "Utilities/Referenced.h"
  13. namespace BlueCore
  14. {
  15. // forward declaration
  16. class TextureManager;
  17. class Texture : public Referenced
  18. {
  19. unsigned int _Id;
  20. unsigned int _Width, _Height;
  21. ~Texture();
  22. public:
  23. Texture( unsigned int id, unsigned int width, unsigned int height ) :
  24. _Id( id ),
  25. _Width( width ),
  26. _Height( height )
  27. {
  28. }
  29. unsigned int getWidth() const
  30. {
  31. return _Width;
  32. }
  33. unsigned int getHeight() const
  34. {
  35. return _Height;
  36. }
  37. unsigned int getId() const
  38. {
  39. return _Id;
  40. }
  41. };
  42. class TextureManager : public Referenced
  43. {
  44. private:
  45. typedef std::map<std::string, Texture *> TextureMap;
  46. TextureMap textures;
  47. float _maxAnisotopy;
  48. unsigned int _maxTextureSize;
  49. unsigned int _lodDrop;
  50. bool _textureCompression;
  51. void clearTextures();
  52. bool saveToCache ( const std::string &name, int levels );
  53. bool loadFromCache (
  54. const std::string &filename,
  55. unsigned int &max_width,
  56. unsigned int &max_height );
  57. ~TextureManager();
  58. void TextureDestroySlot(Referenced *referenced);
  59. public:
  60. TextureManager();
  61. Texture *loadTexture (
  62. const std::string &filename,
  63. int mipmapLevel = -1,
  64. int compressionLevel = 1 );
  65. };
  66. }
  67. #endif