GLS.TextureFormat.pas 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949
  1. //
  2. // The multimedia graphics platform GLScene https://github.com/glscene
  3. //
  4. unit GLS.TextureFormat;
  5. (* Texture formats and functions *)
  6. interface
  7. uses
  8. Winapi.OpenGL,
  9. Winapi.OpenGLext,
  10. GLS.VectorTypes,
  11. GLS.OpenGLTokens,
  12. GLS.Strings;
  13. type
  14. // Texture addressing rules
  15. TGLSeparateTextureWrap = (twRepeat, twClampToEdge, twClampToBorder,
  16. twMirrorRepeat, twMirrorClampToEdge, twMirrorClampToBorder);
  17. (* Specifies the texture comparison mode for currently bound depth textures.
  18. That is, a texture whose internal format is tfDEPTH_COMPONENT* *)
  19. TGLTextureCompareMode = (tcmNone, tcmCompareRtoTexture);
  20. // Filtering quality
  21. TGLTextureFilteringQuality = (tfIsotropic, tfAnisotropic);
  22. TGLTextureTarget =
  23. (
  24. ttNoShape, ttTexture1D, ttTexture2D, ttTexture3D, ttTexture1DArray,
  25. ttTexture2DArray, ttTextureRect, ttTextureBuffer, ttTextureCube,
  26. ttTexture2DMultisample, ttTexture2DMultisampleArray, ttTextureCubeArray
  27. );
  28. TGLTextureSwizzle = (tswRed, tswGreen, tswBlue, tswAlpha, tswZero, tswOne);
  29. TSwizzleVector = array[0..3] of TGLTextureSwizzle;
  30. TGLInternalFormat = (
  31. tfALPHA4,
  32. tfALPHA8,
  33. tfALPHA12,
  34. tfALPHA16,
  35. tfDEPTH_COMPONENT16,
  36. tfDEPTH_COMPONENT24,
  37. tfDEPTH_COMPONENT32,
  38. tfLUMINANCE4,
  39. tfLUMINANCE8,
  40. tfLUMINANCE12,
  41. tfLUMINANCE16,
  42. tfLUMINANCE4_ALPHA4,
  43. tfLUMINANCE6_ALPHA2,
  44. tfLUMINANCE8_ALPHA8,
  45. tfLUMINANCE12_ALPHA4,
  46. tfLUMINANCE12_ALPHA12,
  47. tfLUMINANCE16_ALPHA16,
  48. tfINTENSITY4,
  49. tfINTENSITY8,
  50. tfINTENSITY12,
  51. tfINTENSITY16,
  52. tfR3_G3_B2,
  53. tfRGB4,
  54. tfRGB5,
  55. tfRGB8,
  56. tfRGB10,
  57. tfRGB12,
  58. tfR16G16B16,
  59. tfRGBA2,
  60. tfRGBA4,
  61. tfRGB5_A1,
  62. tfRGBA8,
  63. tfRGB10_A2,
  64. tfRGBA12,
  65. tfR16G16B16A16,
  66. tfCOMPRESSED_RGB_S3TC_DXT1,
  67. tfCOMPRESSED_RGBA_S3TC_DXT1,
  68. tfCOMPRESSED_RGBA_S3TC_DXT3,
  69. tfCOMPRESSED_RGBA_S3TC_DXT5,
  70. tfSIGNED_LUMINANCE8,
  71. tfSIGNED_LUMINANCE8_ALPHA8,
  72. tfSIGNED_RGB8,
  73. tfSIGNED_RGBA8,
  74. tfSIGNED_RGB8_UNSIGNED_ALPHA8,
  75. tfSIGNED_ALPHA8,
  76. tfSIGNED_INTENSITY8,
  77. tfHILO16,
  78. tfSIGNED_HILO16,
  79. tfDSDT8,
  80. tfDSDT8_MAG8,
  81. tfDSDT8_MAG8_INTENSITY8,
  82. tfHILO8,
  83. tfSIGNED_HILO8,
  84. tfFLOAT_R16,
  85. tfFLOAT_R32,
  86. tfFLOAT_RG16,
  87. tfFLOAT_RGB16,
  88. tfFLOAT_RGBA16,
  89. tfFLOAT_RG32,
  90. tfFLOAT_RGB32,
  91. tfFLOAT_RGBA32,
  92. tfRGBA_FLOAT32,
  93. tfRGB_FLOAT32,
  94. tfALPHA_FLOAT32,
  95. tfINTENSITY_FLOAT32,
  96. tfLUMINANCE_FLOAT32,
  97. tfLUMINANCE_ALPHA_FLOAT32,
  98. tfRGBA_FLOAT16,
  99. tfRGB_FLOAT16,
  100. tfALPHA_FLOAT16,
  101. tfINTENSITY_FLOAT16,
  102. tfLUMINANCE_FLOAT16,
  103. tfLUMINANCE_ALPHA_FLOAT16,
  104. tfDEPTH24_STENCIL8,
  105. tfDEPTH_COMPONENT32F,
  106. tfDEPTH32F_STENCIL8,
  107. tfSRGB8,
  108. tfSRGB8_ALPHA8,
  109. tfSLUMINANCE8,
  110. tfSLUMINANCE8_ALPHA8,
  111. tfCOMPRESSED_SRGB_S3TC_DXT1,
  112. tfCOMPRESSED_SRGB_ALPHA_S3TC_DXT1,
  113. tfCOMPRESSED_SRGB_ALPHA_S3TC_DXT3,
  114. tfCOMPRESSED_SRGB_ALPHA_S3TC_DXT5,
  115. tfRGB9_E5,
  116. tfR11F_G11F_B10F,
  117. tfCOMPRESSED_LUMINANCE_LATC1,
  118. tfCOMPRESSED_SIGNED_LUMINANCE_LATC1,
  119. tfCOMPRESSED_LUMINANCE_ALPHA_LATC2,
  120. tfCOMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2,
  121. tfCOMPRESSED_LUMINANCE_ALPHA_3DC,
  122. tfRGBA32UI,
  123. tfRGB32UI,
  124. tfALPHA32UI,
  125. tfINTENSITY32UI,
  126. tfLUMINANCE32UI,
  127. tfLUMINANCE_ALPHA32UI,
  128. tfRGBA16UI,
  129. tfRGB16UI,
  130. tfALPHA16UI,
  131. tfINTENSITY16UI,
  132. tfLUMINANCE16UI,
  133. tfLUMINANCE_ALPHA16UI,
  134. tfRGBA8UI,
  135. tfRGB8UI,
  136. tfALPHA8UI,
  137. tfINTENSITY8UI,
  138. tfLUMINANCE8UI,
  139. tfLUMINANCE_ALPHA8UI,
  140. tfRGBA32I,
  141. tfRGB32I,
  142. tfALPHA32I,
  143. tfINTENSITY32I,
  144. tfLUMINANCE32I,
  145. tfLUMINANCE_ALPHA32I,
  146. tfRGBA16I,
  147. tfRGB16I,
  148. tfALPHA16I,
  149. tfINTENSITY16I,
  150. tfLUMINANCE16I,
  151. tfLUMINANCE_ALPHA16I,
  152. tfRGBA8I,
  153. tfRGB8I,
  154. tfALPHA8I,
  155. tfINTENSITY8I,
  156. tfLUMINANCE8I,
  157. tfLUMINANCE_ALPHA8I,
  158. tfRG32UI,
  159. tfR32UI,
  160. tfRG16UI,
  161. tfR16UI,
  162. tfRG8UI,
  163. tfR8UI,
  164. tfRG32I,
  165. tfR32I,
  166. tfRG16I,
  167. tfR16I,
  168. tfRG8I,
  169. tfR8I,
  170. tfRG8,
  171. tfR8,
  172. tfRG16,
  173. tfR16,
  174. tfRG16F,
  175. tfR16F,
  176. tfRG32F,
  177. tfR32F,
  178. tfCOMPRESSED_RED_RGTC1,
  179. tfCOMPRESSED_SIGNED_RED_RGTC1,
  180. tfCOMPRESSED_RG_RGTC2,
  181. tfCOMPRESSED_SIGNED_RG_RGTC2,
  182. tfR8_SNORM,
  183. tfRG8_SNORM,
  184. tfRGB8_SNORM,
  185. tfRGBA8_SNORM,
  186. tfR16_SNORM,
  187. tfRG16_SNORM,
  188. tfRGB16_SNORM,
  189. tfRGBA16_SNORM
  190. );
  191. (* Texture compression option.
  192. If OpenGL supports it, this will activate a compressed texture format:
  193. tcDefault : uses global default compression option
  194. tcNone : do not use compression
  195. tcStandard : use standard compression, average quality, average rate
  196. tcHighQuality : choose a high-quality, low-speed compression
  197. tcHighSpeed : choose a high-speed, low-quality compression *)
  198. TGLInternalCompression = (tcDefault, tcNone, tcStandard, tcHighQuality,
  199. tcHighSpeed);
  200. var
  201. vDefaultTextureFormat: TGLInternalFormat = tfRGBA8;
  202. vDefaultTextureCompression: TGLInternalCompression = tcNone;
  203. const
  204. cDefaultSwizzleVector: TSwizzleVector = (tswRed, tswGreen, tswBlue, tswAlpha);
  205. // Give a openGL texture format from GLScene texture format
  206. function InternalFormatToOpenGLFormat(intFormat: TGLInternalFormat): Cardinal;
  207. // Give a GLScene texture format from openGL texture format
  208. function OpenGLFormatToInternalFormat(glFormat: Cardinal): TGLInternalFormat;
  209. // Give a pixel size in bytes from texture format or data format
  210. function GetTextureElementSize(intFormat: TGLInternalFormat): Integer; overload;
  211. function GetTextureElementSize(colorFormat: Cardinal; dataType: Cardinal):
  212. Integer; overload;
  213. // Give compatible openGL image format and data type
  214. procedure FindCompatibleDataFormat(intFormat: TGLInternalFormat; out dFormat:
  215. TGLuint; out dType: TGLUint);
  216. (* Give a compressed openGL texture format from GLScene texture format
  217. if format is have not compression than return same openGL format *)
  218. function CompressedInternalFormatToOpenGL(intFormat: TGLInternalFormat):
  219. Integer;
  220. // True if texture target supported
  221. function IsTargetSupported(glTarget: Cardinal): Boolean; overload;
  222. function IsTargetSupported(target: TGLTextureTarget): Boolean; overload;
  223. // True if texture format is supported by hardware or software
  224. function IsFormatSupported(intFormat: TGLInternalFormat): Boolean;
  225. // True if texture format is float
  226. function IsFloatFormat(intFormat: TGLInternalFormat): Boolean; overload;
  227. function IsFloatFormat(glFormat: Cardinal): Boolean; overload;
  228. // True if depth texture
  229. function IsDepthFormat(intFormat: TGLInternalFormat): boolean; overload;
  230. function IsDepthFormat(glFormat: Cardinal): Boolean; overload;
  231. // True if texture compressed
  232. function IsCompressedFormat(intFormat: TGLInternalFormat): Boolean; overload;
  233. function IsCompressedFormat(glFormat: Cardinal): Boolean; overload;
  234. // Give generic compressed OpenGL texture format
  235. function GetGenericCompressedFormat(const intFormat: TGLInternalFormat;
  236. const colorFormat: Cardinal; out internalFormat: Cardinal): Boolean;
  237. // Give uncompressed texture format and OpenGL color format
  238. function GetUncompressedFormat(const intFormat: TGLInternalFormat;
  239. out internalFormat: TGLInternalFormat; out colorFormat: Cardinal): Boolean;
  240. function DecodeTextureTarget(const TextureTarget: TGLTextureTarget): Cardinal;
  241. function EncodeGLTextureTarget(const glTarget: Cardinal): TGLTextureTarget;
  242. function IsTargetSupportMipmap(const TextureTarget: TGLTextureTarget): Boolean; overload;
  243. function IsTargetSupportMipmap(const glTarget: Cardinal): Boolean; overload;
  244. //---------------------------------------------------------------------------
  245. implementation
  246. //---------------------------------------------------------------------------
  247. uses
  248. GLS.Context;
  249. type
  250. TFormatDesc = record
  251. IntFmt: Cardinal;
  252. ClrFmt: Cardinal;
  253. DataFmt: Cardinal;
  254. RBit: Byte;
  255. GBit: Byte;
  256. BBit: Byte;
  257. ABit: Byte;
  258. LBit: Byte;
  259. DBit: Byte;
  260. Sign: Boolean;
  261. Flt: Boolean;
  262. Fix: Boolean;
  263. Comp: Boolean;
  264. end;
  265. const
  266. // InternalFormat, ColorFormat, DataType
  267. cTextureFormatToOpenGL: array[low(TGLInternalFormat)..high(TGLInternalFormat)] of TFormatDesc =
  268. (
  269. (IntFmt: GL_ALPHA4; ClrFmt: GL_ALPHA; DataFmt: GL_UNSIGNED_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 4; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  270. (IntFmt: GL_ALPHA8; ClrFmt: GL_ALPHA; DataFmt: GL_UNSIGNED_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 8; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  271. (IntFmt: GL_ALPHA12; ClrFmt: GL_ALPHA; DataFmt: GL_UNSIGNED_SHORT; RBit: 0; GBit: 0; BBit: 0; ABit: 12; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  272. (IntFmt: GL_ALPHA16; ClrFmt: GL_ALPHA; DataFmt: GL_UNSIGNED_SHORT; RBit: 0; GBit: 0; BBit: 0; ABit: 16; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  273. (IntFmt: GL_DEPTH_COMPONENT16; ClrFmt: GL_DEPTH_COMPONENT; DataFmt: GL_UNSIGNED_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 0; DBit: 16; Sign: False; Flt: False; Fix: False; Comp: False),
  274. (IntFmt: GL_DEPTH_COMPONENT24; ClrFmt: GL_DEPTH_COMPONENT; DataFmt: GL_UNSIGNED_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 0; DBit: 24; Sign: False; Flt: False; Fix: False; Comp: False),
  275. (IntFmt: GL_DEPTH_COMPONENT32; ClrFmt: GL_DEPTH_COMPONENT; DataFmt: GL_UNSIGNED_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 0; DBit: 32; Sign: False; Flt: False; Fix: False; Comp: False),
  276. (IntFmt: GL_LUMINANCE4; ClrFmt: GL_LUMINANCE; DataFmt: GL_UNSIGNED_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 4; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  277. (IntFmt: GL_LUMINANCE8; ClrFmt: GL_LUMINANCE; DataFmt: GL_UNSIGNED_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 8; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  278. (IntFmt: GL_LUMINANCE12; ClrFmt: GL_LUMINANCE; DataFmt: GL_UNSIGNED_SHORT; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 12; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  279. (IntFmt: GL_LUMINANCE16; ClrFmt: GL_LUMINANCE; DataFmt: GL_UNSIGNED_SHORT; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 16; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  280. (IntFmt: GL_LUMINANCE4_ALPHA4; ClrFmt: GL_LUMINANCE_ALPHA; DataFmt: GL_UNSIGNED_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 4; LBit: 4; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  281. (IntFmt: GL_LUMINANCE6_ALPHA2; ClrFmt: GL_LUMINANCE_ALPHA; DataFmt: GL_UNSIGNED_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 6; LBit: 2; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  282. (IntFmt: GL_LUMINANCE8_ALPHA8; ClrFmt: GL_LUMINANCE_ALPHA; DataFmt: GL_UNSIGNED_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 8; LBit: 8; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  283. (IntFmt: GL_LUMINANCE12_ALPHA4; ClrFmt: GL_LUMINANCE_ALPHA; DataFmt: GL_UNSIGNED_SHORT; RBit: 0; GBit: 0; BBit: 0; ABit: 4; LBit: 12; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  284. (IntFmt: GL_LUMINANCE12_ALPHA12; ClrFmt: GL_LUMINANCE_ALPHA; DataFmt: GL_UNSIGNED_SHORT; RBit: 0; GBit: 0; BBit: 0; ABit: 12; LBit: 12; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  285. (IntFmt: GL_LUMINANCE16_ALPHA16; ClrFmt: GL_LUMINANCE_ALPHA; DataFmt: GL_UNSIGNED_SHORT; RBit: 0; GBit: 0; BBit: 0; ABit: 16; LBit: 16; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  286. (IntFmt: GL_INTENSITY4; ClrFmt: GL_LUMINANCE; DataFmt: GL_UNSIGNED_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 4; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  287. (IntFmt: GL_INTENSITY8; ClrFmt: GL_LUMINANCE; DataFmt: GL_UNSIGNED_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 8; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  288. (IntFmt: GL_INTENSITY12; ClrFmt: GL_LUMINANCE; DataFmt: GL_UNSIGNED_SHORT; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 12; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  289. (IntFmt: GL_INTENSITY16; ClrFmt: GL_LUMINANCE; DataFmt: GL_UNSIGNED_SHORT; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 16; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  290. (IntFmt: GL_R3_G3_B2; ClrFmt: GL_RGB; DataFmt: GL_UNSIGNED_BYTE_3_3_2; RBit: 3; GBit: 3; BBit: 2; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  291. (IntFmt: GL_RGB4; ClrFmt: GL_RGB; DataFmt: GL_UNSIGNED_BYTE; RBit: 4; GBit: 4; BBit: 4; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  292. (IntFmt: GL_RGB5; ClrFmt: GL_RGB; DataFmt: GL_UNSIGNED_SHORT_5_6_5; RBit: 5; GBit: 6; BBit: 5; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  293. (IntFmt: GL_RGB8; ClrFmt: GL_RGB; DataFmt: GL_UNSIGNED_BYTE; RBit: 8; GBit: 8; BBit: 8; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  294. (IntFmt: GL_RGB10; ClrFmt: GL_RGBA; DataFmt: GL_UNSIGNED_INT_10_10_10_2; RBit: 10; GBit: 10; BBit: 10; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  295. (IntFmt: GL_RGB12; ClrFmt: GL_RGB; DataFmt: GL_UNSIGNED_BYTE; RBit: 12; GBit: 12; BBit: 12; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  296. (IntFmt: GL_RGB16; ClrFmt: GL_RGB; DataFmt: GL_UNSIGNED_SHORT; RBit: 16; GBit: 16; BBit: 16; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  297. (IntFmt: GL_RGBA2; ClrFmt: GL_RGBA; DataFmt: GL_UNSIGNED_BYTE; RBit: 2; GBit: 2; BBit: 2; ABit: 2; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  298. (IntFmt: GL_RGBA4; ClrFmt: GL_RGBA; DataFmt: GL_UNSIGNED_SHORT_4_4_4_4; RBit: 4; GBit: 4; BBit: 4; ABit: 4; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  299. (IntFmt: GL_RGB5_A1; ClrFmt: GL_RGBA; DataFmt: GL_UNSIGNED_SHORT_5_5_5_1; RBit: 5; GBit: 5; BBit: 5; ABit: 1; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  300. (IntFmt: GL_RGBA8; ClrFmt: GL_RGBA; DataFmt: GL_UNSIGNED_BYTE; RBit: 8; GBit: 8; BBit: 8; ABit: 8; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  301. (IntFmt: GL_RGB10_A2; ClrFmt: GL_RGBA; DataFmt: GL_UNSIGNED_INT_10_10_10_2; RBit: 10; GBit: 10; BBit: 10; ABit: 2; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  302. (IntFmt: GL_RGBA12; ClrFmt: GL_RGBA; DataFmt: GL_UNSIGNED_BYTE; RBit: 12; GBit: 12; BBit: 12; ABit: 12; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  303. (IntFmt: GL_RGBA16; ClrFmt: GL_RGBA; DataFmt: GL_UNSIGNED_SHORT; RBit: 16; GBit: 16; BBit: 16; ABit: 16; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  304. (IntFmt: GL_COMPRESSED_RGB_S3TC_DXT1_EXT; ClrFmt: GL_COMPRESSED_RGB_S3TC_DXT1_EXT; DataFmt: GL_COMPRESSED_RGB_S3TC_DXT1_EXT; RBit: 8; GBit: 8; BBit: 8; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: True),
  305. (IntFmt: GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; ClrFmt: GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; DataFmt: GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; RBit: 8; GBit: 8; BBit: 8; ABit: 1; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: True),
  306. (IntFmt: GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; ClrFmt: GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; DataFmt: GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; RBit: 8; GBit: 8; BBit: 8; ABit: 8; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: True),
  307. (IntFmt: GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; ClrFmt: GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; DataFmt: GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; RBit: 8; GBit: 8; BBit: 0; ABit: 8; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: True),
  308. (IntFmt: GL_SIGNED_LUMINANCE8_NV; ClrFmt: GL_LUMINANCE; DataFmt: GL_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 8; DBit: 0; Sign: True; Flt: False; Fix: False; Comp: False),
  309. (IntFmt: GL_SIGNED_LUMINANCE8_ALPHA8_NV; ClrFmt: GL_LUMINANCE_ALPHA; DataFmt: GL_SHORT; RBit: 0; GBit: 0; BBit: 0; ABit: 8; LBit: 8; DBit: 0; Sign: True; Flt: False; Fix: False; Comp: False),
  310. (IntFmt: GL_SIGNED_RGB8_NV; ClrFmt: GL_RGB; DataFmt: GL_BYTE; RBit: 8; GBit: 8; BBit: 8; ABit: 0; LBit: 0; DBit: 0; Sign: True; Flt: False; Fix: False; Comp: False),
  311. (IntFmt: GL_SIGNED_RGBA8_NV; ClrFmt: GL_RGBA; DataFmt: GL_BYTE; RBit: 8; GBit: 8; BBit: 8; ABit: 8; LBit: 0; DBit: 0; Sign: True; Flt: False; Fix: False; Comp: False),
  312. (IntFmt: GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV; ClrFmt: GL_RGBA; DataFmt: GL_BYTE; RBit: 8; GBit: 8; BBit: 8; ABit: 8; LBit: 0; DBit: 0; Sign: True; Flt: False; Fix: False; Comp: False),
  313. (IntFmt: GL_SIGNED_ALPHA8_NV; ClrFmt: GL_ALPHA; DataFmt: GL_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 8; LBit: 0; DBit: 0; Sign: True; Flt: False; Fix: False; Comp: False),
  314. (IntFmt: GL_SIGNED_INTENSITY8_NV; ClrFmt: GL_INTENSITY; DataFmt: GL_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 8; DBit: 0; Sign: True; Flt: False; Fix: False; Comp: False),
  315. (IntFmt: GL_HILO16_NV; ClrFmt: GL_RG; DataFmt: GL_UNSIGNED_SHORT; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  316. (IntFmt: GL_SIGNED_HILO16_NV; ClrFmt: GL_RG; DataFmt: GL_SHORT; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: True; Flt: False; Fix: False; Comp: False),
  317. (IntFmt: GL_DSDT8_NV; ClrFmt: GL_RED; DataFmt: GL_UNSIGNED_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  318. (IntFmt: GL_DSDT8_MAG8_NV; ClrFmt: GL_RG; DataFmt: GL_UNSIGNED_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  319. (IntFmt: GL_DSDT8_MAG8_INTENSITY8_NV; ClrFmt: GL_RGB; DataFmt: GL_UNSIGNED_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  320. (IntFmt: GL_HILO8_NV; ClrFmt: GL_RG; DataFmt: GL_UNSIGNED_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  321. (IntFmt: GL_SIGNED_HILO8_NV; ClrFmt: GL_RG; DataFmt: GL_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: True; Flt: False; Fix: False; Comp: False),
  322. (IntFmt: GL_FLOAT_R16_NV; ClrFmt: GL_RED; DataFmt: GL_HALF_FLOAT; RBit: 16; GBit: 0; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: True; Fix: False; Comp: False),
  323. (IntFmt: GL_FLOAT_R32_NV; ClrFmt: GL_RED; DataFmt: GL_FLOAT; RBit: 32; GBit: 0; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: True; Fix: False; Comp: False),
  324. (IntFmt: GL_FLOAT_RG16_NV; ClrFmt: GL_RG; DataFmt: GL_HALF_FLOAT; RBit: 16; GBit: 16; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: True; Fix: False; Comp: False),
  325. (IntFmt: GL_FLOAT_RGB16_NV; ClrFmt: GL_RGB; DataFmt: GL_HALF_FLOAT; RBit: 16; GBit: 16; BBit: 16; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: True; Fix: False; Comp: False),
  326. (IntFmt: GL_FLOAT_RGBA16_NV; ClrFmt: GL_RGBA; DataFmt: GL_HALF_FLOAT; RBit: 16; GBit: 16; BBit: 16; ABit: 16; LBit: 0; DBit: 0; Sign: False; Flt: True; Fix: False; Comp: False),
  327. (IntFmt: GL_FLOAT_RG32_NV; ClrFmt: GL_RG; DataFmt: GL_FLOAT; RBit: 32; GBit: 32; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: True; Fix: False; Comp: False),
  328. (IntFmt: GL_FLOAT_RGB32_NV; ClrFmt: GL_RGB; DataFmt: GL_FLOAT; RBit: 32; GBit: 32; BBit: 32; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: True; Fix: False; Comp: False),
  329. (IntFmt: GL_FLOAT_RGBA32_NV; ClrFmt: GL_RGBA; DataFmt: GL_FLOAT; RBit: 32; GBit: 32; BBit: 32; ABit: 32; LBit: 0; DBit: 0; Sign: False; Flt: True; Fix: False; Comp: False),
  330. (IntFmt: GL_RGBA32F_ARB; ClrFmt: GL_RGBA; DataFmt: GL_FLOAT; RBit: 32; GBit: 32; BBit: 32; ABit: 32; LBit: 0; DBit: 0; Sign: False; Flt: True; Fix: False; Comp: False),
  331. (IntFmt: GL_RGB32F_ARB; ClrFmt: GL_RGB; DataFmt: GL_FLOAT; RBit: 32; GBit: 32; BBit: 32; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: True; Fix: False; Comp: False),
  332. (IntFmt: GL_ALPHA32F_ARB; ClrFmt: GL_ALPHA; DataFmt: GL_FLOAT; RBit: 0; GBit: 0; BBit: 0; ABit: 32; LBit: 0; DBit: 0; Sign: False; Flt: True; Fix: False; Comp: False),
  333. (IntFmt: GL_INTENSITY32F_ARB; ClrFmt: GL_LUMINANCE; DataFmt: GL_FLOAT; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 32; DBit: 0; Sign: False; Flt: True; Fix: False; Comp: False),
  334. (IntFmt: GL_LUMINANCE32F_ARB; ClrFmt: GL_LUMINANCE; DataFmt: GL_FLOAT; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 32; DBit: 0; Sign: False; Flt: True; Fix: False; Comp: False),
  335. (IntFmt: GL_LUMINANCE_ALPHA32F_ARB; ClrFmt: GL_LUMINANCE_ALPHA; DataFmt: GL_FLOAT; RBit: 0; GBit: 0; BBit: 0; ABit: 32; LBit: 32; DBit: 0; Sign: False; Flt: True; Fix: False; Comp: False),
  336. (IntFmt: GL_RGBA16F_ARB; ClrFmt: GL_RGBA; DataFmt: GL_HALF_FLOAT; RBit: 16; GBit: 16; BBit: 16; ABit: 16; LBit: 0; DBit: 0; Sign: False; Flt: True; Fix: False; Comp: False),
  337. (IntFmt: GL_RGB16F_ARB; ClrFmt: GL_RGB; DataFmt: GL_HALF_FLOAT; RBit: 16; GBit: 16; BBit: 16; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: True; Fix: False; Comp: False),
  338. (IntFmt: GL_ALPHA16F_ARB; ClrFmt: GL_ALPHA; DataFmt: GL_HALF_FLOAT; RBit: 0; GBit: 0; BBit: 0; ABit: 16; LBit: 0; DBit: 0; Sign: False; Flt: True; Fix: False; Comp: False),
  339. (IntFmt: GL_INTENSITY16F_ARB; ClrFmt: GL_LUMINANCE; DataFmt: GL_HALF_FLOAT; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 16; DBit: 0; Sign: False; Flt: True; Fix: False; Comp: False),
  340. (IntFmt: GL_LUMINANCE16F_ARB; ClrFmt: GL_LUMINANCE; DataFmt: GL_HALF_FLOAT; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 16; DBit: 0; Sign: False; Flt: True; Fix: False; Comp: False),
  341. (IntFmt: GL_LUMINANCE_ALPHA16F_ARB; ClrFmt: GL_LUMINANCE_ALPHA; DataFmt: GL_HALF_FLOAT; RBit: 0; GBit: 0; BBit: 0; ABit: 16; LBit: 16; DBit: 0; Sign: False; Flt: True; Fix: False; Comp: False),
  342. (IntFmt: GL_DEPTH24_STENCIL8; ClrFmt: GL_DEPTH_STENCIL; DataFmt: GL_UNSIGNED_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 0; DBit: 24; Sign: False; Flt: False; Fix: False; Comp: False),
  343. (IntFmt: GL_DEPTH_COMPONENT32F; ClrFmt: GL_DEPTH_COMPONENT; DataFmt: GL_FLOAT; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 0; DBit: 32; Sign: False; Flt: True; Fix: False; Comp: False),
  344. (IntFmt: GL_DEPTH32F_STENCIL8; ClrFmt: GL_DEPTH_STENCIL; DataFmt: GL_FLOAT; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 0; DBit: 32; Sign: False; Flt: True; Fix: False; Comp: False),
  345. (IntFmt: GL_SRGB8; ClrFmt: GL_RGB; DataFmt: GL_UNSIGNED_BYTE; RBit: 8; GBit: 8; BBit: 8; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  346. (IntFmt: GL_SRGB8_ALPHA8; ClrFmt: GL_RGBA; DataFmt: GL_UNSIGNED_BYTE; RBit: 8; GBit: 8; BBit: 8; ABit: 8; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  347. (IntFmt: GL_SLUMINANCE8; ClrFmt: GL_LUMINANCE; DataFmt: GL_UNSIGNED_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 8; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  348. (IntFmt: GL_SLUMINANCE8_ALPHA8; ClrFmt: GL_LUMINANCE_ALPHA; DataFmt: GL_UNSIGNED_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 8; LBit: 8; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  349. (IntFmt: GL_COMPRESSED_SRGB_S3TC_DXT1_EXT; ClrFmt: GL_COMPRESSED_SRGB_S3TC_DXT1_EXT; DataFmt: GL_COMPRESSED_SRGB_S3TC_DXT1_EXT; RBit: 8; GBit: 8; BBit: 8; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: True),
  350. (IntFmt: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; ClrFmt: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; DataFmt: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; RBit: 8; GBit: 8; BBit: 8; ABit: 1; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: True),
  351. (IntFmt: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; ClrFmt: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; DataFmt: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; RBit: 8; GBit: 8; BBit: 8; ABit: 8; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: True),
  352. (IntFmt: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; ClrFmt: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; DataFmt: GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; RBit: 8; GBit: 8; BBit: 8; ABit: 8; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: True),
  353. (IntFmt: GL_RGB9_E5; ClrFmt: GL_RGBA; DataFmt: GL_FLOAT; RBit: 8; GBit: 8; BBit: 8; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  354. (IntFmt: GL_R11F_G11F_B10F; ClrFmt: GL_RGB; DataFmt: GL_FLOAT; RBit: 11; GBit: 11; BBit: 10; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: True; Fix: False; Comp: False),
  355. (IntFmt: GL_COMPRESSED_LUMINANCE_LATC1_EXT; ClrFmt: GL_COMPRESSED_LUMINANCE_LATC1_EXT; DataFmt: GL_COMPRESSED_LUMINANCE_LATC1_EXT; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 8; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: True),
  356. (IntFmt: GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT; ClrFmt: GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT; DataFmt: GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 8; DBit: 0; Sign: True; Flt: False; Fix: False; Comp: True),
  357. (IntFmt: GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT; ClrFmt: GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT; DataFmt: GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT; RBit: 0; GBit: 0; BBit: 0; ABit: 8; LBit: 8; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: True),
  358. (IntFmt: GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT; ClrFmt: GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT; DataFmt: GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT; RBit: 0; GBit: 0; BBit: 0; ABit: 8; LBit: 8; DBit: 0; Sign: True; Flt: False; Fix: False; Comp: True),
  359. (IntFmt: GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI; ClrFmt: GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI; DataFmt: GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI; RBit: 0; GBit: 0; BBit: 0; ABit: 8; LBit: 8; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: True),
  360. (IntFmt: GL_RGBA32UI; ClrFmt: GL_RGBA_INTEGER; DataFmt: GL_UNSIGNED_INT; RBit: 32; GBit: 32; BBit: 32; ABit: 32; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: True; Comp: False),
  361. (IntFmt: GL_RGB32UI; ClrFmt: GL_RGB_INTEGER; DataFmt: GL_UNSIGNED_INT; RBit: 32; GBit: 32; BBit: 32; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: True; Comp: False),
  362. (IntFmt: GL_ALPHA32UI_EXT; ClrFmt: GL_ALPHA_INTEGER; DataFmt: GL_UNSIGNED_INT; RBit: 0; GBit: 0; BBit: 0; ABit: 32; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: True; Comp: False),
  363. (IntFmt: GL_INTENSITY32UI_EXT; ClrFmt: GL_LUMINANCE_INTEGER_EXT; DataFmt: GL_UNSIGNED_INT; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 32; DBit: 0; Sign: False; Flt: False; Fix: True; Comp: False),
  364. (IntFmt: GL_LUMINANCE32UI_EXT; ClrFmt: GL_LUMINANCE_INTEGER_EXT; DataFmt: GL_UNSIGNED_INT; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 32; DBit: 0; Sign: False; Flt: False; Fix: True; Comp: False),
  365. (IntFmt: GL_LUMINANCE_ALPHA32UI_EXT; ClrFmt: GL_LUMINANCE_ALPHA_INTEGER_EXT; DataFmt: GL_UNSIGNED_INT; RBit: 0; GBit: 0; BBit: 0; ABit: 32; LBit: 32; DBit: 0; Sign: False; Flt: True; Fix: False; Comp: False),
  366. (IntFmt: GL_RGBA16UI; ClrFmt: GL_RGBA_INTEGER; DataFmt: GL_UNSIGNED_SHORT; RBit: 16; GBit: 16; BBit: 16; ABit: 16; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: True; Comp: False),
  367. (IntFmt: GL_RGB16UI; ClrFmt: GL_RGB_INTEGER; DataFmt: GL_UNSIGNED_SHORT; RBit: 16; GBit: 16; BBit: 16; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: True; Comp: False),
  368. (IntFmt: GL_ALPHA16UI_EXT; ClrFmt: GL_ALPHA_INTEGER; DataFmt: GL_UNSIGNED_SHORT; RBit: 0; GBit: 0; BBit: 0; ABit: 16; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: True; Comp: False),
  369. (IntFmt: GL_INTENSITY16UI_EXT; ClrFmt: GL_LUMINANCE_INTEGER_EXT; DataFmt: GL_UNSIGNED_SHORT; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 16; DBit: 0; Sign: False; Flt: False; Fix: True; Comp: False),
  370. (IntFmt: GL_LUMINANCE16UI_EXT; ClrFmt: GL_LUMINANCE_INTEGER_EXT; DataFmt: GL_UNSIGNED_SHORT; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 16; DBit: 0; Sign: False; Flt: False; Fix: True; Comp: False),
  371. (IntFmt: GL_LUMINANCE_ALPHA16UI_EXT; ClrFmt: GL_LUMINANCE_ALPHA_INTEGER_EXT; DataFmt: GL_UNSIGNED_SHORT; RBit: 0; GBit: 0; BBit: 0; ABit: 16; LBit: 16; DBit: 0; Sign: False; Flt: False; Fix: True; Comp: False),
  372. (IntFmt: GL_RGBA8UI; ClrFmt: GL_RGBA_INTEGER; DataFmt: GL_UNSIGNED_BYTE; RBit: 8; GBit: 8; BBit: 8; ABit: 8; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: True; Comp: False),
  373. (IntFmt: GL_RGB8UI; ClrFmt: GL_RGB_INTEGER; DataFmt: GL_UNSIGNED_BYTE; RBit: 8; GBit: 8; BBit: 8; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: True; Comp: False),
  374. (IntFmt: GL_ALPHA8UI_EXT; ClrFmt: GL_ALPHA_INTEGER; DataFmt: GL_UNSIGNED_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 8; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: True; Comp: False),
  375. (IntFmt: GL_INTENSITY8UI_EXT; ClrFmt: GL_LUMINANCE_INTEGER_EXT; DataFmt: GL_UNSIGNED_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 8; DBit: 0; Sign: False; Flt: False; Fix: True; Comp: False),
  376. (IntFmt: GL_LUMINANCE8UI_EXT; ClrFmt: GL_LUMINANCE_INTEGER_EXT; DataFmt: GL_UNSIGNED_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 8; DBit: 0; Sign: False; Flt: False; Fix: True; Comp: False),
  377. (IntFmt: GL_LUMINANCE_ALPHA8UI_EXT; ClrFmt: GL_LUMINANCE_ALPHA_INTEGER_EXT; DataFmt: GL_UNSIGNED_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 8; LBit: 8; DBit: 0; Sign: False; Flt: True; Fix: False; Comp: False),
  378. (IntFmt: GL_RGBA32I; ClrFmt: GL_RGBA_INTEGER; DataFmt: GL_INT; RBit: 32; GBit: 32; BBit: 32; ABit: 32; LBit: 0; DBit: 0; Sign: True; Flt: False; Fix: True; Comp: False),
  379. (IntFmt: GL_RGB32I; ClrFmt: GL_RGB_INTEGER; DataFmt: GL_INT; RBit: 32; GBit: 32; BBit: 32; ABit: 0; LBit: 0; DBit: 0; Sign: True; Flt: False; Fix: True; Comp: False),
  380. (IntFmt: GL_ALPHA32I_EXT; ClrFmt: GL_ALPHA_INTEGER; DataFmt: GL_INT; RBit: 0; GBit: 0; BBit: 0; ABit: 32; LBit: 0; DBit: 0; Sign: True; Flt: False; Fix: True; Comp: False),
  381. (IntFmt: GL_INTENSITY32I_EXT; ClrFmt: GL_LUMINANCE_INTEGER_EXT; DataFmt: GL_INT; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 32; DBit: 0; Sign: True; Flt: False; Fix: True; Comp: False),
  382. (IntFmt: GL_LUMINANCE32I_EXT; ClrFmt: GL_LUMINANCE_INTEGER_EXT; DataFmt: GL_INT; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 32; DBit: 0; Sign: True; Flt: False; Fix: True; Comp: False),
  383. (IntFmt: GL_LUMINANCE_ALPHA32I_EXT; ClrFmt: GL_LUMINANCE_ALPHA_INTEGER_EXT; DataFmt: GL_INT; RBit: 0; GBit: 0; BBit: 0; ABit: 32; LBit: 32; DBit: 0; Sign: True; Flt: False; Fix: True; Comp: False),
  384. (IntFmt: GL_RGBA16I; ClrFmt: GL_RGBA_INTEGER; DataFmt: GL_SHORT; RBit: 16; GBit: 16; BBit: 16; ABit: 16; LBit: 0; DBit: 0; Sign: True; Flt: False; Fix: True; Comp: False),
  385. (IntFmt: GL_RGB16I; ClrFmt: GL_RGB_INTEGER; DataFmt: GL_SHORT; RBit: 16; GBit: 16; BBit: 16; ABit: 0; LBit: 0; DBit: 0; Sign: True; Flt: False; Fix: True; Comp: False),
  386. (IntFmt: GL_ALPHA16I_EXT; ClrFmt: GL_ALPHA_INTEGER; DataFmt: GL_SHORT; RBit: 0; GBit: 0; BBit: 0; ABit: 16; LBit: 0; DBit: 0; Sign: True; Flt: False; Fix: True; Comp: False),
  387. (IntFmt: GL_INTENSITY16I_EXT; ClrFmt: GL_LUMINANCE_INTEGER_EXT; DataFmt: GL_SHORT; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 16; DBit: 0; Sign: True; Flt: False; Fix: True; Comp: False),
  388. (IntFmt: GL_LUMINANCE16I_EXT; ClrFmt: GL_LUMINANCE_INTEGER_EXT; DataFmt: GL_SHORT; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 16; DBit: 0; Sign: True; Flt: False; Fix: True; Comp: False),
  389. (IntFmt: GL_LUMINANCE_ALPHA16I_EXT; ClrFmt: GL_LUMINANCE_ALPHA_INTEGER_EXT; DataFmt: GL_SHORT; RBit: 0; GBit: 0; BBit: 0; ABit: 16; LBit: 16; DBit: 0; Sign: True; Flt: True; Fix: False; Comp: False),
  390. (IntFmt: GL_RGBA8I; ClrFmt: GL_RGBA_INTEGER; DataFmt: GL_BYTE; RBit: 8; GBit: 8; BBit: 8; ABit: 8; LBit: 0; DBit: 0; Sign: True; Flt: False; Fix: True; Comp: False),
  391. (IntFmt: GL_RGB8I; ClrFmt: GL_RGB_INTEGER; DataFmt: GL_BYTE; RBit: 8; GBit: 8; BBit: 8; ABit: 0; LBit: 0; DBit: 0; Sign: True; Flt: False; Fix: True; Comp: False),
  392. (IntFmt: GL_ALPHA8I_EXT; ClrFmt: GL_ALPHA_INTEGER; DataFmt: GL_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 8; LBit: 0; DBit: 0; Sign: True; Flt: False; Fix: True; Comp: False),
  393. (IntFmt: GL_INTENSITY8I_EXT; ClrFmt: GL_INTENSITY; DataFmt: GL_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 8; DBit: 0; Sign: True; Flt: False; Fix: True; Comp: False),
  394. (IntFmt: GL_LUMINANCE8I_EXT; ClrFmt: GL_LUMINANCE; DataFmt: GL_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 0; LBit: 8; DBit: 0; Sign: True; Flt: False; Fix: True; Comp: False),
  395. (IntFmt: GL_LUMINANCE_ALPHA8I_EXT; ClrFmt: GL_LUMINANCE_ALPHA; DataFmt: GL_BYTE; RBit: 0; GBit: 0; BBit: 0; ABit: 8; LBit: 8; DBit: 0; Sign: True; Flt: False; Fix: True; Comp: False),
  396. (IntFmt: GL_RG32UI; ClrFmt: GL_RG; DataFmt: GL_UNSIGNED_INT; RBit: 8; GBit: 8; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: True; Comp: False),
  397. (IntFmt: GL_R32UI; ClrFmt: GL_RED_INTEGER; DataFmt: GL_UNSIGNED_INT; RBit: 8; GBit: 0; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: True; Comp: False),
  398. (IntFmt: GL_RG16UI; ClrFmt: GL_RG; DataFmt: GL_UNSIGNED_SHORT; RBit: 16; GBit: 16; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: True; Comp: False),
  399. (IntFmt: GL_R16UI; ClrFmt: GL_RED_INTEGER; DataFmt: GL_UNSIGNED_SHORT; RBit: 16; GBit: 0; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: True; Comp: False),
  400. (IntFmt: GL_RG8UI; ClrFmt: GL_RG; DataFmt: GL_UNSIGNED_BYTE; RBit: 8; GBit: 8; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: True; Comp: False),
  401. (IntFmt: GL_R8UI; ClrFmt: GL_RED_INTEGER; DataFmt: GL_UNSIGNED_BYTE; RBit: 8; GBit: 0; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: True; Fix: False; Comp: False),
  402. (IntFmt: GL_RG32I; ClrFmt: GL_RG; DataFmt: GL_INT; RBit: 32; GBit: 32; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: True; Flt: False; Fix: True; Comp: False),
  403. (IntFmt: GL_R32I; ClrFmt: GL_RED_INTEGER; DataFmt: GL_INT; RBit: 16; GBit: 0; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: True; Flt: False; Fix: True; Comp: False),
  404. (IntFmt: GL_RG16I; ClrFmt: GL_RG; DataFmt: GL_SHORT; RBit: 16; GBit: 16; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: True; Flt: False; Fix: True; Comp: False),
  405. (IntFmt: GL_R16I; ClrFmt: GL_RED_INTEGER; DataFmt: GL_SHORT; RBit: 16; GBit: 0; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: True; Flt: False; Fix: True; Comp: False),
  406. (IntFmt: GL_RG8I; ClrFmt: GL_RG; DataFmt: GL_BYTE; RBit: 8; GBit: 8; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: True; Flt: False; Fix: True; Comp: False),
  407. (IntFmt: GL_R8I; ClrFmt: GL_RED_INTEGER; DataFmt: GL_BYTE; RBit: 8; GBit: 0; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: True; Flt: False; Fix: True; Comp: False),
  408. (IntFmt: GL_RG8; ClrFmt: GL_RG; DataFmt: GL_BYTE; RBit: 8; GBit: 8; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  409. (IntFmt: GL_R8; ClrFmt: GL_RED; DataFmt: GL_BYTE; RBit: 8; GBit: 0; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  410. (IntFmt: GL_RG16; ClrFmt: GL_RG; DataFmt: GL_SHORT; RBit: 16; GBit: 16; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  411. (IntFmt: GL_R16; ClrFmt: GL_RED; DataFmt: GL_SHORT; RBit: 16; GBit: 0; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  412. (IntFmt: GL_RG16F; ClrFmt: GL_RG; DataFmt: GL_HALF_FLOAT; RBit: 16; GBit: 16; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: True; Fix: False; Comp: False),
  413. (IntFmt: GL_R16F; ClrFmt: GL_RED; DataFmt: GL_HALF_FLOAT; RBit: 16; GBit: 0; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: True; Fix: False; Comp: False),
  414. (IntFmt: GL_RG32F; ClrFmt: GL_RG; DataFmt: GL_FLOAT; RBit: 32; GBit: 32; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: True; Fix: False; Comp: False),
  415. (IntFmt: GL_R32F; ClrFmt: GL_LUMINANCE; DataFmt: GL_FLOAT; RBit: 32; GBit: 0; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: True; Fix: False; Comp: False),
  416. (IntFmt: GL_COMPRESSED_RED_RGTC1; ClrFmt: GL_COMPRESSED_RED_RGTC1; DataFmt: GL_COMPRESSED_RED_RGTC1; RBit: 8; GBit: 0; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: True),
  417. (IntFmt: GL_COMPRESSED_SIGNED_RED_RGTC1; ClrFmt: GL_COMPRESSED_SIGNED_RED_RGTC1; DataFmt: GL_COMPRESSED_SIGNED_RED_RGTC1; RBit: 8; GBit: 0; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: True; Flt: False; Fix: False; Comp: True),
  418. (IntFmt: GL_COMPRESSED_RG_RGTC2; ClrFmt: GL_COMPRESSED_RG_RGTC2; DataFmt: GL_COMPRESSED_RG_RGTC2; RBit: 8; GBit: 8; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: True),
  419. (IntFmt: GL_COMPRESSED_SIGNED_RG_RGTC2; ClrFmt: GL_COMPRESSED_SIGNED_RG_RGTC2; DataFmt: GL_COMPRESSED_SIGNED_RG_RGTC2; RBit: 8; GBit: 8; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: True; Flt: False; Fix: False; Comp: True),
  420. (IntFmt: GL_R8_SNORM; ClrFmt: GL_R; DataFmt: GL_BYTE; RBit: 8; GBit: 0; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  421. (IntFmt: GL_RG8_SNORM; ClrFmt: GL_RG; DataFmt: GL_BYTE; RBit: 8; GBit: 8; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  422. (IntFmt: GL_RGB8_SNORM; ClrFmt: GL_RGB; DataFmt: GL_BYTE; RBit: 8; GBit: 8; BBit: 8; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  423. (IntFmt: GL_RGBA8_SNORM; ClrFmt: GL_RGBA; DataFmt: GL_BYTE; RBit: 8; GBit: 8; BBit: 8; ABit: 8; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  424. (IntFmt: GL_R16_SNORM; ClrFmt: GL_R; DataFmt: GL_SHORT; RBit: 16; GBit: 0; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  425. (IntFmt: GL_RG16_SNORM; ClrFmt: GL_RG; DataFmt: GL_SHORT; RBit: 16; GBit: 16; BBit: 0; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  426. (IntFmt: GL_RGB16_SNORM; ClrFmt: GL_RGB; DataFmt: GL_SHORT; RBit: 16; GBit: 16; BBit: 16; ABit: 0; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False),
  427. (IntFmt: GL_RGBA16_SNORM; ClrFmt: GL_RGBA; DataFmt: GL_SHORT; RBit: 16; GBit: 16; BBit: 16; ABit: 16; LBit: 0; DBit: 0; Sign: False; Flt: False; Fix: False; Comp: False)
  428. );
  429. function InternalFormatToOpenGLFormat(intFormat: TGLInternalFormat): Cardinal;
  430. begin
  431. Result := cTextureFormatToOpenGL[intFormat].IntFmt;
  432. end;
  433. function OpenGLFormatToInternalFormat(glFormat: Cardinal): TGLInternalFormat;
  434. var
  435. i: TGLInternalFormat;
  436. begin
  437. Result := tfRGBA8;
  438. for i := Low(cTextureFormatToOpenGL) to High(cTextureFormatToOpenGL) do
  439. if glFormat = cTextureFormatToOpenGL[i].IntFmt then
  440. begin
  441. Result := i;
  442. Exit;
  443. end;
  444. Assert(false);
  445. end;
  446. function GetTextureElementSize(intFormat: TGLInternalFormat): Integer;
  447. begin
  448. Result := GetTextureElementSize(
  449. cTextureFormatToOpenGL[intFormat].ClrFmt,
  450. cTextureFormatToOpenGL[intFormat].DataFmt);
  451. end;
  452. function GetTextureElementSize(colorFormat: Cardinal; dataType: Cardinal):
  453. Integer;
  454. var
  455. components: Byte;
  456. begin
  457. case colorFormat of
  458. GL_RGB, GL_BGR: components := 3;
  459. GL_RGBA, GL_BGRA: components := 4;
  460. GL_ALPHA: components := 1;
  461. GL_LUMINANCE: components := 1;
  462. GL_LUMINANCE_ALPHA: components := 2;
  463. GL_INTENSITY: components := 1;
  464. GL_RED: components := 1;
  465. GL_GREEN: components := 1;
  466. GL_BLUE: components := 1;
  467. GL_RG: components := 2;
  468. GL_RGB_INTEGER: components := 3;
  469. GL_RGBA_INTEGER: components := 4;
  470. GL_ALPHA_INTEGER: components := 1;
  471. GL_LUMINANCE_INTEGER_EXT: components := 1;
  472. GL_LUMINANCE_ALPHA_INTEGER_EXT: components := 2;
  473. GL_RED_INTEGER: components := 1;
  474. GL_RG_INTEGER: components := 2;
  475. else
  476. components := 1;
  477. end;
  478. case dataType of
  479. GL_BITMAP,
  480. GL_UNSIGNED_BYTE,
  481. GL_BYTE: Result := components;
  482. GL_UNSIGNED_BYTE_3_3_2,
  483. GL_UNSIGNED_BYTE_2_3_3_REV: Result := 1;
  484. GL_UNSIGNED_SHORT,
  485. GL_SHORT: Result := components * 2;
  486. GL_UNSIGNED_SHORT_4_4_4_4,
  487. GL_UNSIGNED_SHORT_4_4_4_4_REV,
  488. GL_UNSIGNED_SHORT_5_6_5,
  489. GL_UNSIGNED_SHORT_5_6_5_REV,
  490. GL_UNSIGNED_SHORT_5_5_5_1,
  491. GL_UNSIGNED_SHORT_1_5_5_5_REV: Result := 2;
  492. GL_UNSIGNED_INT,
  493. GL_INT: Result := components * 4;
  494. GL_UNSIGNED_INT_8_8_8_8,
  495. GL_UNSIGNED_INT_8_8_8_8_REV,
  496. GL_UNSIGNED_INT_10_10_10_2,
  497. GL_UNSIGNED_INT_2_10_10_10_REV: Result := 4;
  498. GL_FLOAT: Result := components * 4;
  499. GL_HALF_FLOAT: Result := components * 2;
  500. GL_COMPRESSED_RGB_S3TC_DXT1_EXT: Result := 8;
  501. GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: Result := 8;
  502. GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: Result := 16;
  503. GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: Result := 16;
  504. GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: Result := 8;
  505. GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: Result := 8;
  506. GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: Result := 16;
  507. GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: Result := 16;
  508. GL_COMPRESSED_LUMINANCE_LATC1_EXT: Result := 8;
  509. GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT: Result := 8;
  510. GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT: Result := 16;
  511. GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT: Result := 16;
  512. GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI: Result := 16;
  513. GL_COMPRESSED_RED_RGTC1: Result := 8;
  514. GL_COMPRESSED_SIGNED_RED_RGTC1: Result := 8;
  515. GL_COMPRESSED_RG_RGTC2: Result := 16;
  516. GL_COMPRESSED_SIGNED_RG_RGTC2: Result := 16;
  517. else
  518. Result := 1;
  519. end;
  520. end;
  521. function CompressedInternalFormatToOpenGL(intFormat: TGLInternalFormat):
  522. Integer;
  523. begin
  524. Result := GL_COMPRESSED_RGBA;
  525. case intFormat of
  526. tfRGB8: Result := GL_COMPRESSED_RGB;
  527. tfRGBA8: Result := GL_COMPRESSED_RGBA;
  528. tfRGB5: Result := GL_COMPRESSED_RGB;
  529. tfRGBA4: Result := GL_COMPRESSED_RGBA;
  530. tfALPHA8: Result := GL_COMPRESSED_ALPHA;
  531. tfLUMINANCE8: Result := GL_COMPRESSED_LUMINANCE;
  532. tfLUMINANCE8_ALPHA8: Result := GL_COMPRESSED_LUMINANCE_ALPHA;
  533. tfINTENSITY8: Result := GL_COMPRESSED_INTENSITY;
  534. else
  535. Assert(false);
  536. end;
  537. end;
  538. procedure FindCompatibleDataFormat(intFormat: TGLInternalFormat; out dFormat:
  539. Cardinal; out dType: Cardinal);
  540. begin
  541. dFormat := cTextureFormatToOpenGL[intFormat].ClrFmt;
  542. dType := cTextureFormatToOpenGL[intFormat].DataFmt;
  543. end;
  544. function IsTargetSupported(target: TGLTextureTarget): Boolean;
  545. begin
  546. Result := IsTargetSupported(DecodeTextureTarget(target));
  547. end;
  548. function IsTargetSupported(glTarget: Cardinal): Boolean;
  549. begin
  550. case glTarget of
  551. GL_TEXTURE_1D: Result := GL.VERSION_1_1 or GL.EXT_texture_object;
  552. GL_TEXTURE_2D: Result := GL.VERSION_1_1 or GL.EXT_texture_object;
  553. GL_TEXTURE_3D: Result := GL.EXT_texture3D;
  554. GL_TEXTURE_RECTANGLE: Result := GL.ARB_texture_rectangle;
  555. GL_TEXTURE_CUBE_MAP,
  556. GL_TEXTURE_CUBE_MAP_POSITIVE_X,
  557. GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
  558. GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
  559. GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
  560. GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
  561. GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: Result := GL.ARB_texture_cube_map;
  562. GL_TEXTURE_1D_ARRAY: Result := GL.EXT_texture_array;
  563. GL_TEXTURE_2D_ARRAY: Result := GL.EXT_texture_array;
  564. GL_TEXTURE_CUBE_MAP_ARRAY: Result := GL.ARB_texture_cube_map_array;
  565. GL_TEXTURE_BUFFER: Result := GL.ARB_texture_buffer_object;
  566. GL_TEXTURE_2D_MULTISAMPLE,
  567. GL_TEXTURE_2D_MULTISAMPLE_ARRAY: Result := GL.ARB_texture_multisample;
  568. else
  569. begin
  570. Result := false;
  571. // Assert(False, strErrorEx + strUnknownType);
  572. end;
  573. end;
  574. end;
  575. function IsFormatSupported(intFormat: TGLInternalFormat): Boolean;
  576. begin
  577. Result := false;
  578. if ((intFormat >= tfALPHA4) and (intFormat <= tfALPHA16)) or
  579. ((intFormat >= tfLUMINANCE4) and (intFormat <= tfR16G16B16A16)) then
  580. begin
  581. Result := GL.VERSION_1_1;
  582. EXIT;
  583. end;
  584. if ((intFormat >= tfDEPTH_COMPONENT16) and (intFormat <= tfDEPTH_COMPONENT32)) then
  585. begin
  586. Result := GL.ARB_depth_texture;
  587. EXIT;
  588. end;
  589. if ((intFormat >= tfCOMPRESSED_RGB_S3TC_DXT1) and (intFormat <=
  590. tfCOMPRESSED_RGBA_S3TC_DXT5)) then
  591. begin
  592. Result := GL.EXT_texture_compression_s3tc;
  593. EXIT;
  594. end;
  595. if ((intFormat >= tfSIGNED_LUMINANCE8) and (intFormat <=
  596. tfDSDT8_MAG8_INTENSITY8)) then
  597. begin
  598. Result := GL.NV_texture_shader;
  599. EXIT;
  600. end;
  601. if ((intFormat = tfHILO8) or (intFormat = tfSIGNED_HILO8)) then
  602. begin
  603. Result := GL.NV_texture_shader3;
  604. EXIT;
  605. end;
  606. if ((intFormat >= tfFLOAT_R16) and (intFormat <= tfFLOAT_RGBA32)) then
  607. begin
  608. Result := GL.NV_float_buffer;
  609. EXIT;
  610. end;
  611. if ((intFormat >= tfRGBA_FLOAT32)
  612. and (intFormat <= tfLUMINANCE_ALPHA_FLOAT16)) then
  613. begin
  614. Result := GL.ARB_texture_float or GL.ATI_texture_float;
  615. EXIT;
  616. end;
  617. if intFormat = tfDEPTH24_STENCIL8 then
  618. begin
  619. Result := GL.EXT_packed_depth_stencil;
  620. EXIT;
  621. end;
  622. if ((intFormat = tfDEPTH_COMPONENT32F) or (intFormat = tfDEPTH32F_STENCIL8)) then
  623. begin
  624. Result := GL.NV_depth_buffer_float;
  625. EXIT;
  626. end;
  627. if ((intFormat >= tfSRGB8) and (intFormat <=
  628. tfCOMPRESSED_SRGB_ALPHA_S3TC_DXT5)) then
  629. begin
  630. Result := GL.EXT_texture_sRGB;
  631. EXIT;
  632. end;
  633. if intFormat = tfRGB9_E5 then
  634. begin
  635. Result := GL.EXT_texture_shared_exponent;
  636. EXIT;
  637. end;
  638. if intFormat = tfR11F_G11F_B10F then
  639. begin
  640. Result := GL.EXT_packed_float;
  641. EXIT;
  642. end;
  643. if ((intFormat >= tfCOMPRESSED_LUMINANCE_LATC1) and (intFormat <=
  644. tfCOMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2)) then
  645. begin
  646. Result := GL.EXT_texture_compression_latc;
  647. EXIT;
  648. end;
  649. if intFormat = tfCOMPRESSED_LUMINANCE_ALPHA_3DC then
  650. begin
  651. Result := GL.ATI_texture_compression_3dc;
  652. EXIT;
  653. end;
  654. if ((intFormat >= tfRGBA32UI) and (intFormat <= tfLUMINANCE_ALPHA8I)) then
  655. begin
  656. Result := GL.EXT_texture_integer;
  657. EXIT;
  658. end;
  659. if ((intFormat >= tfRG32UI) and (intFormat <= tfR32F)) then
  660. Result := GL.ARB_texture_rg;
  661. if ((intFormat >= tfCOMPRESSED_RED_RGTC1) and (intFormat <=
  662. tfCOMPRESSED_SIGNED_RG_RGTC2)) then
  663. begin
  664. Result := GL.ARB_texture_compression_rgtc;
  665. EXIT;
  666. end;
  667. if ((intFormat >= tfR8_SNORM) and (intFormat <= tfRGBA16_SNORM)) then
  668. begin
  669. Result := GL.VERSION_3_1;
  670. EXIT;
  671. end
  672. end;
  673. function IsFloatFormat(intFormat: TGLInternalFormat): boolean;
  674. begin
  675. Result := cTextureFormatToOpenGL[intFormat].Flt;
  676. end;
  677. function IsFloatFormat(glFormat: Cardinal): boolean;
  678. begin
  679. Result := IsFloatFormat(OpenGLFormatToInternalFormat(glFormat));
  680. end;
  681. function IsDepthFormat(intFormat: TGLInternalFormat): boolean;
  682. begin
  683. Result := cTextureFormatToOpenGL[intFormat].DBit > 0;
  684. end;
  685. function IsDepthFormat(glFormat: Cardinal): boolean;
  686. begin
  687. Result := cTextureFormatToOpenGL[OpenGLFormatToInternalFormat(glFormat)].DBit > 0;
  688. end;
  689. function IsCompressedFormat(intFormat: TGLInternalFormat): boolean;
  690. begin
  691. Result := cTextureFormatToOpenGL[intFormat].Comp;
  692. end;
  693. function IsCompressedFormat(glFormat: Cardinal): boolean;
  694. begin
  695. Result := cTextureFormatToOpenGL[OpenGLFormatToInternalFormat(glFormat)].Comp;
  696. end;
  697. function GetGenericCompressedFormat(const intFormat: TGLInternalFormat;
  698. const colorFormat: Cardinal; out internalFormat: Cardinal): Boolean;
  699. begin
  700. Result := false;
  701. if IsCompressedFormat(intFormat) then
  702. Exit;
  703. if not IsFormatSupported(intFormat) then
  704. Exit;
  705. internalFormat := 0;
  706. if ((intFormat >= tfSRGB8) and (intFormat <=
  707. tfCOMPRESSED_SRGB_ALPHA_S3TC_DXT5)) then
  708. case colorFormat of
  709. GL_RGB: internalFormat := GL_COMPRESSED_SRGB;
  710. GL_RGBA: internalFormat := GL_COMPRESSED_SRGB_ALPHA;
  711. GL_LUMINANCE: internalFormat := GL_COMPRESSED_SLUMINANCE;
  712. GL_LUMINANCE_ALPHA: internalFormat := GL_COMPRESSED_SLUMINANCE_ALPHA;
  713. end
  714. else
  715. case colorFormat of
  716. GL_RGB, GL_BGR: internalFormat := GL_COMPRESSED_RGB;
  717. GL_RGBA, GL_BGRA: internalFormat := GL_COMPRESSED_RGBA;
  718. GL_ALPHA: internalFormat := GL_COMPRESSED_ALPHA;
  719. GL_LUMINANCE: internalFormat := GL_COMPRESSED_LUMINANCE;
  720. GL_LUMINANCE_ALPHA: internalFormat := GL_COMPRESSED_LUMINANCE_ALPHA;
  721. GL_INTENSITY: internalFormat := GL_COMPRESSED_INTENSITY;
  722. GL_RED: internalFormat := GL_COMPRESSED_RED;
  723. GL_RG: internalFormat := GL_COMPRESSED_RG;
  724. end;
  725. if internalFormat = 0 then
  726. Exit;
  727. Result := true;
  728. end;
  729. function GetUncompressedFormat(const intFormat: TGLInternalFormat;
  730. out internalFormat: TGLInternalFormat; out colorFormat: Cardinal): Boolean;
  731. begin
  732. Result := false;
  733. if not IsCompressedFormat(intFormat) then
  734. Exit;
  735. if not IsFormatSupported(intFormat) then
  736. Exit;
  737. colorFormat := 0;
  738. case intFormat of
  739. tfCOMPRESSED_RGB_S3TC_DXT1:
  740. begin
  741. colorFormat := GL_RGB;
  742. internalFormat := tfRGB8;
  743. end;
  744. tfCOMPRESSED_RGBA_S3TC_DXT1:
  745. begin
  746. colorFormat := GL_RGBA;
  747. internalFormat := tfRGBA8;
  748. end;
  749. tfCOMPRESSED_RGBA_S3TC_DXT3:
  750. begin
  751. colorFormat := GL_RGBA;
  752. internalFormat := tfRGBA8;
  753. end;
  754. tfCOMPRESSED_RGBA_S3TC_DXT5:
  755. begin
  756. colorFormat := GL_RGBA;
  757. internalFormat := tfRGBA8;
  758. end;
  759. tfCOMPRESSED_SRGB_S3TC_DXT1:
  760. begin
  761. colorFormat := GL_RGBA;
  762. internalFormat := tfSRGB8;
  763. end;
  764. tfCOMPRESSED_SRGB_ALPHA_S3TC_DXT1:
  765. begin
  766. colorFormat := GL_RGBA;
  767. internalFormat := tfSRGB8_ALPHA8;
  768. end;
  769. tfCOMPRESSED_SRGB_ALPHA_S3TC_DXT3:
  770. begin
  771. colorFormat := GL_RGBA;
  772. internalFormat := tfSRGB8_ALPHA8;
  773. end;
  774. tfCOMPRESSED_SRGB_ALPHA_S3TC_DXT5:
  775. begin
  776. colorFormat := GL_RGBA;
  777. internalFormat := tfSRGB8_ALPHA8;
  778. end;
  779. tfCOMPRESSED_LUMINANCE_LATC1:
  780. begin
  781. colorFormat := GL_LUMINANCE;
  782. internalFormat := tfLUMINANCE8;
  783. end;
  784. tfCOMPRESSED_SIGNED_LUMINANCE_LATC1:
  785. begin
  786. colorFormat := GL_LUMINANCE;
  787. internalFormat := tfSIGNED_LUMINANCE8;
  788. end;
  789. tfCOMPRESSED_LUMINANCE_ALPHA_LATC2:
  790. begin
  791. colorFormat := GL_LUMINANCE_ALPHA;
  792. internalFormat := tfLUMINANCE8_ALPHA8;
  793. end;
  794. tfCOMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2:
  795. begin
  796. colorFormat := GL_LUMINANCE_ALPHA;
  797. internalFormat := tfSIGNED_LUMINANCE8_ALPHA8;
  798. end;
  799. tfCOMPRESSED_LUMINANCE_ALPHA_3DC:
  800. begin
  801. colorFormat := GL_LUMINANCE_ALPHA;
  802. internalFormat := tfLUMINANCE8_ALPHA8;
  803. end;
  804. tfCOMPRESSED_RED_RGTC1:
  805. begin
  806. colorFormat := GL_RED;
  807. internalFormat := tfR8;
  808. end;
  809. tfCOMPRESSED_SIGNED_RED_RGTC1:
  810. begin
  811. colorFormat := GL_RED;
  812. internalFormat := tfR8;
  813. end;
  814. tfCOMPRESSED_RG_RGTC2:
  815. begin
  816. colorFormat := GL_RG;
  817. internalFormat := tfRG8;
  818. end;
  819. tfCOMPRESSED_SIGNED_RG_RGTC2:
  820. begin
  821. colorFormat := GL_RG;
  822. internalFormat := tfRG8;
  823. end;
  824. end;
  825. Result := colorFormat <> 0;
  826. end;
  827. function DecodeTextureTarget(const TextureTarget: TGLTextureTarget): Cardinal;
  828. const
  829. cTargetToEnum: array[TGLTextureTarget] of Cardinal =
  830. (
  831. 0,
  832. GL_TEXTURE_1D,
  833. GL_TEXTURE_2D,
  834. GL_TEXTURE_3D,
  835. GL_TEXTURE_1D_ARRAY,
  836. GL_TEXTURE_2D_ARRAY,
  837. GL_TEXTURE_RECTANGLE,
  838. GL_TEXTURE_BUFFER,
  839. GL_TEXTURE_CUBE_MAP,
  840. GL_TEXTURE_2D_MULTISAMPLE,
  841. GL_TEXTURE_2D_MULTISAMPLE_ARRAY,
  842. GL_TEXTURE_CUBE_MAP_ARRAY
  843. );
  844. begin
  845. // Assert(TextureTarget <> ttNoShape);
  846. Result := cTargetToEnum[TextureTarget];
  847. end;
  848. function EncodeGLTextureTarget(const glTarget: Cardinal): TGLTextureTarget;
  849. begin
  850. case glTarget of
  851. GL_TEXTURE_1D: Result := ttTexture1d;
  852. GL_TEXTURE_2D: Result := ttTexture2d;
  853. GL_TEXTURE_3D: Result := ttTexture3d;
  854. GL_TEXTURE_RECTANGLE: Result := ttTextureRect;
  855. GL_TEXTURE_CUBE_MAP: Result := ttTextureCube;
  856. GL_TEXTURE_1D_ARRAY: Result := ttTexture1dArray;
  857. GL_TEXTURE_2D_ARRAY: Result := ttTexture2dArray;
  858. GL_TEXTURE_CUBE_MAP_ARRAY: Result := ttTextureCubeArray;
  859. GL_TEXTURE_2D_MULTISAMPLE: Result := ttTexture2DMultisample;
  860. GL_TEXTURE_2D_MULTISAMPLE_ARRAY: Result := ttTexture2DMultisampleArray;
  861. else
  862. begin
  863. Result := ttTexture2d;
  864. Assert(False, strErrorEx + strUnknownType);
  865. end;
  866. end;
  867. end;
  868. function IsTargetSupportMipmap(const TextureTarget: TGLTextureTarget): Boolean;
  869. begin
  870. Result := (TextureTarget <> ttTextureRect)
  871. and (TextureTarget <> ttTexture2DMultisample)
  872. and (TextureTarget <> ttTexture2DMultisampleArray);
  873. end;
  874. function IsTargetSupportMipmap(const glTarget: Cardinal): Boolean;
  875. begin
  876. Result := (glTarget <> GL_TEXTURE_RECTANGLE)
  877. and (glTarget <> GL_TEXTURE_2D_MULTISAMPLE)
  878. and (glTarget <> GL_TEXTURE_2D_MULTISAMPLE_ARRAY);
  879. end;
  880. end.