texture.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #pragma once
  2. #include <math.h>
  3. #if defined(_WIN32) && !defined(__SYMBIAN32__)
  4. #include <windows.h>
  5. #endif
  6. #ifdef __APPLE__
  7. #include <OpenGLES/ES2/gl.h>
  8. #include <OpenGLES/ES2/glext.h>
  9. #else
  10. #include <GLES2/gl2.h>
  11. #include <GLES2/gl2ext.h>
  12. #include <EGL/egl.h>
  13. #endif
  14. #ifndef M_PI
  15. #define M_PI 3.1415926535897931f
  16. #endif
  17. GLuint loadTexture(const char *filename);
  18. struct MemoryChunk
  19. {
  20. const void *ptr;
  21. unsigned int size;
  22. #if defined(_WIN32) && !defined(__SYMBIAN32__)
  23. HANDLE fd;
  24. HANDLE mapping;
  25. #else
  26. unsigned int fd;
  27. #endif
  28. };
  29. const void *lockFile(const char *name, MemoryChunk *chunk);
  30. void unlockFile(MemoryChunk *chunk);
  31. #if 1
  32. /** from powervr sdk */
  33. #define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00
  34. #define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01
  35. #define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02
  36. #define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03
  37. struct PVR_Texture_Header
  38. {
  39. unsigned int dwHeaderSize; /*!< size of the structure */
  40. unsigned int dwHeight; /*!< height of surface to be created */
  41. unsigned int dwWidth; /*!< width of input surface */
  42. unsigned int dwMipMapCount; /*!< number of mip-map levels requested */
  43. unsigned int dwpfFlags; /*!< pixel format flags */
  44. unsigned int dwTextureDataSize; /*!< Total size in bytes */
  45. unsigned int dwBitCount; /*!< number of bits per pixel */
  46. unsigned int dwRBitMask; /*!< mask for red bit */
  47. unsigned int dwGBitMask; /*!< mask for green bits */
  48. unsigned int dwBBitMask; /*!< mask for blue bits */
  49. unsigned int dwAlphaBitMask; /*!< mask for alpha channel */
  50. unsigned int dwPVR; /*!< magic number identifying pvr file */
  51. unsigned int dwNumSurfs; /*!< the number of surfaces present in the pvr */
  52. } ;
  53. // from PVRTexLibGlobals.h
  54. const unsigned int PVRTEX_PIXELTYPE = 0xff;
  55. enum
  56. {
  57. // OpenGL version of pixel types
  58. OGL_RGBA_4444= 0x10,
  59. OGL_RGBA_5551,
  60. OGL_RGBA_8888,
  61. OGL_RGB_565,
  62. OGL_RGB_555,
  63. OGL_RGB_888,
  64. OGL_I_8,
  65. OGL_AI_88,
  66. OGL_PVRTC2,
  67. OGL_PVRTC4,
  68. };
  69. void pvrTexImage2D(const PVR_Texture_Header *pvr);
  70. #endif