Small OpenGL based c++ rendering library
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.

gltexture.h 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifndef __GLTEXTUR_H
  2. #define __GLTEXTUR_H
  3. #include <iostream>
  4. #include <string>
  5. #include <vector>
  6. #include <SDL.h>
  7. #include <SDL_image.h>
  8. #include <SDL_opengl.h>
  9. #include "sdlfuncs.h"
  10. namespace segl {
  11. class GLTexture {
  12. private:
  13. GLuint texint;
  14. SDL_Surface *tex;
  15. int width, height;
  16. std::string filename; // wenn von datei geladen
  17. // Parameter
  18. GLint minfilter;
  19. GLint magfilter;
  20. GLint wraps;
  21. GLint wrapt;
  22. bool loaded;
  23. bool texconverted;
  24. bool keepsurface;
  25. bool donotreload;
  26. void init();
  27. bool loadLocalSurface();
  28. void convertLocalSurface();
  29. static std::vector<GLTexture*> alltextures;
  30. protected:
  31. GLTexture(SDL_Surface*);
  32. bool loadSurface(SDL_Surface*, bool = false);
  33. public:
  34. static void reloadAll();
  35. GLTexture();
  36. GLTexture(std::string, GLint=GL_LINEAR, GLint=GL_LINEAR, GLint=GL_REPEAT, GLint=GL_REPEAT);
  37. ~GLTexture();
  38. //load
  39. bool loadImage(std::string);
  40. bool selectTexture();
  41. void unloadTexture();
  42. bool setParameter(GLint=0, GLint=0, GLint=0, GLint=0);
  43. inline bool select() { return selectTexture(); }
  44. int getW();
  45. int getH();
  46. bool isLoaded();
  47. };
  48. } // namespace segl
  49. #endif