GLS.VectorTypes.pas 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. //
  2. // The multimedia graphics platform GLScene https://github.com/glscene
  3. //
  4. unit GLS.VectorTypes;
  5. (*
  6. Defines base vector types for use in VectorGeometry unit
  7. The sole aim of this unit is to limit dependency between the VectorGeometry
  8. and OpenGL units by introducing the base compatibility types
  9. (and only the *base* types).
  10. Conventions:
  11. d is used for Double precision floating points values (64 bits)
  12. f is used for Single precision floating points values (32 bits)
  13. i is used for 32 bits signed integers (longint)
  14. s is uses for 16 bits signed integers (smallint)
  15. Note : D3D types untested.
  16. *)
  17. interface
  18. {$I GLScene.inc}
  19. uses
  20. Winapi.Windows;
  21. type
  22. // =========== OpenGL types ============
  23. TGLboolean = BYTEBOOL;
  24. PGLboolean = ^TGLboolean;
  25. TGLbitfield = UINT;
  26. PGLbitfield = ^TGLbitfield;
  27. TGLbyte = ShortInt;
  28. PGLbyte = ^TGLbyte;
  29. TGLshort = SmallInt;
  30. PGLshort = ^TGLshort;
  31. TGLint = Integer;
  32. PGLint = System.PInteger;
  33. TGLsizei = Integer;
  34. PGLsizei = System.PInteger;
  35. TGLint64 = Int64;
  36. PGLint64 = System.PInt64;
  37. TGLint64EXT = Int64;
  38. PGLint64EXT = System.PInt64;
  39. TGLuint64 = UInt64;
  40. PGLuint64 = System.PUInt64;
  41. TGLuint64EXT = UInt64;
  42. PGLuint64EXT = System.PUInt64;
  43. TGLubyte = Byte;
  44. PGLubyte = System.PByte;
  45. TGLushort = Word;
  46. PGLushort = System.PWord;
  47. TGLenum = Cardinal;
  48. PGLenum = ^TGLenum;
  49. TGLuint = Cardinal;
  50. PGLuint = System.PCardinal;
  51. TGLfloat = Single;
  52. TGLdouble = Double;
  53. PGLdouble = System.PDouble;
  54. PGLclampf = System.PSingle;
  55. TGLclampd = Double;
  56. PGLclampd = System.PDouble;
  57. PGLPCharArray = ^PAnsiChar;
  58. PGLvoid = Pointer;
  59. PGLPointer = ^PGLvoid;
  60. TGLhandleARB = Cardinal;
  61. PGLhandleARB = ^TGLhandleARB;
  62. // the size of these depend on platform (32bit or 64bit)
  63. TGLintptr = NativeInt;
  64. PGLintptr = ^TGLintptr;
  65. TGLsizeiptr = NativeInt;
  66. PGLsizeiptr = ^TGLsizeiptr;
  67. TGLsync = NativeInt;
  68. PGLsync = ^TGLsync;
  69. TGLchar = Byte;
  70. PGLchar = MarshaledAString;
  71. TGLhalf = WORD;
  72. PGLhalf = ^TGLhalf;
  73. // ========= Windows types ==============
  74. PWGLswap = ^TWGLswap;
  75. _WGLSWAP = packed record
  76. hdc: HDC;
  77. uiFlags: UINT;
  78. end;
  79. TWGLswap = _WGLSWAP;
  80. WGLSWAP = _WGLSWAP;
  81. HPBUFFERARB = Integer;
  82. (* These OpenCL's types are compatible with cl_context and cl_event *)
  83. T_cl_context = record end;
  84. P_cl_context = ^T_cl_context;
  85. T_cl_event = record end;
  86. P_cl_event = ^T_cl_event;
  87. type
  88. // =========== Vectors ============
  89. //2
  90. TVector2d = record
  91. case Integer of
  92. 0 : (V: array[0..1] of Double);
  93. 1 : (X: Double;
  94. Y: Double);
  95. end;
  96. TVector2f = record
  97. case Integer of
  98. 0 : (V: array[0..1] of Single);
  99. 1 : (X,Y: Single);
  100. end;
  101. TVector2h = record
  102. case Integer of
  103. 0 : (V: array[0..1] of Word);
  104. 1 : (X,Y: Word);
  105. end;
  106. TVector2i = record
  107. case Integer of
  108. 0 : (V: array[0..1] of Longint);
  109. 1 : (X,Y: Longint);
  110. end;
  111. TVector2ui = record
  112. case Integer of
  113. 0 : (V: array[0..1] of Longword);
  114. 1 : (X,Y: Longword);
  115. end;
  116. TVector2s = record
  117. case Integer of
  118. 0 : (V: array[0..1] of Smallint);
  119. 1 : (X,Y: Smallint);
  120. end;
  121. TVector2b = record
  122. case Integer of
  123. 0 : (V: array[0..1] of Byte);
  124. 1 : (X,Y: Byte);
  125. end;
  126. TVector2sb = record
  127. case Integer of
  128. 0 : (V: array[0..1] of ShortInt);
  129. 1 : (X,Y: ShortInt);
  130. end;
  131. TVector2e = record
  132. case Integer of
  133. 0 : (V: array[0..1] of Extended);
  134. 1 : (X,Y: Extended);
  135. end;
  136. TVector2w = record
  137. case Integer of
  138. 0 : (V: array[0..1] of Word);
  139. 1 : (X,Y: Word);
  140. end;
  141. TVector2p = record
  142. case Integer of
  143. 0 : (V: array[0..1] of Pointer);
  144. 1 : (X,Y: Pointer);
  145. end;
  146. //3
  147. TVector3d = record
  148. case Integer of
  149. 0 : (V: array[0..2] of Double);
  150. 1 : (X,Y,Z: Double);
  151. end;
  152. TVector3f = record
  153. case Integer of
  154. 0 : (V: array[0..2] of Single);
  155. 1 : (X,Y,Z: Single);
  156. end;
  157. TVector3h = record
  158. case Integer of
  159. 0 : (V: array[0..2] of Word);
  160. 1 : (X,Y,Z: Word);
  161. end;
  162. TVector3i = record
  163. case Integer of
  164. 0 : (V: array[0..2] of Longint);
  165. 1 : (X,Y,Z: Longint);
  166. end;
  167. TVector3ui = record
  168. case Integer of
  169. 0 : (V: array[0..2] of Longword);
  170. 1 : (X,Y,Z: Longword);
  171. end;
  172. TVector3s = record
  173. case Integer of
  174. 0 : (V: array[0..2] of Smallint);
  175. 1 : (X,Y,Z: Smallint);
  176. end;
  177. TVector3b = record
  178. case Integer of
  179. 0 : (V: array[0..2] of Byte);
  180. 1 : (X,Y,Z: Byte);
  181. end;
  182. TVector3sb = record
  183. case Integer of
  184. 0 : (V: array[0..2] of ShortInt);
  185. 1 : (X,Y,Z: ShortInt);
  186. end;
  187. TVector3e = record
  188. case Integer of
  189. 0 : (V: array[0..2] of Extended);
  190. 1 : (X,Y,Z: Extended);
  191. end;
  192. TVector3w = record
  193. case Integer of
  194. 0 : (V: array[0..2] of Word);
  195. 1 : (X,Y,Z: Word);
  196. end;
  197. TVector3p = record
  198. case Integer of
  199. 0 : (V: array[0..2] of Pointer);
  200. 1 : (X,Y,Z: Pointer);
  201. end;
  202. //4
  203. TVector4d = record
  204. case Integer of
  205. 0 : (V: array[0..3] of Double);
  206. 1 : (X,Y,Z,W: Double);
  207. end;
  208. TVector4f = record
  209. case Integer of
  210. 0 : (V: array[0..3] of Single);
  211. 1 : (X,Y,Z,W: Single);
  212. end;
  213. TVector4h = record
  214. case Integer of
  215. 0 : (V: array[0..3] of Word);
  216. 1 : (X,Y,Z,W: Word);
  217. end;
  218. TVector4i = record
  219. case Integer of
  220. 0 : (V: array[0..3] of LongInt);
  221. 1 : (X,Y,Z,W: Longint);
  222. end;
  223. TVector4ui = record
  224. case Integer of
  225. 0 : (V: array[0..3] of LongWord);
  226. 1 : (X,Y,Z,W: LongWord);
  227. end;
  228. TVector4s = record
  229. case Integer of
  230. 0 : (V: array[0..3] of SmallInt);
  231. 1 : (X,Y,Z,W: SmallInt);
  232. end;
  233. TVector4b = record
  234. case Integer of
  235. 0 : (V: array[0..3] of Byte);
  236. 1 : (X,Y,Z,W: Byte);
  237. end;
  238. TVector4sb = record
  239. case Integer of
  240. 0 : (V: array[0..3] of ShortInt);
  241. 1 : (X,Y,Z,W: ShortInt);
  242. end;
  243. TVector4e = record
  244. case Integer of
  245. 0 : (V: array[0..3] of Extended);
  246. 1 : (X,Y,Z,W: Extended);
  247. end;
  248. TVector4w = record
  249. case Integer of
  250. 0 : (V: array[0..3] of Word);
  251. 1 : (X,Y,Z,W: Word);
  252. end;
  253. TVector4p = record
  254. case Integer of
  255. 0 : (V: array[0..3] of Pointer);
  256. 1 : (X,Y,Z,W: Pointer);
  257. end;
  258. // The vector by default
  259. PGLVector = ^TGLVector;
  260. TGLVector = TVector4f;
  261. // =========== Matrices ============
  262. TMatrix2d = record
  263. case Integer of
  264. 0 : (V: array[0..1] of TVector2d);
  265. 1 : (X,Y: TVector2d);
  266. end;
  267. TMatrix2f = record
  268. case Integer of
  269. 0 : (V: array[0..1] of TVector2f);
  270. 1 : (X,Y: TVector2f);
  271. end;
  272. TMatrix2i = record
  273. case Integer of
  274. 0 : (V: array[0..1] of TVector2i);
  275. 1 : (X,Y: TVector2i);
  276. end;
  277. TMatrix2s = record
  278. case Integer of
  279. 0 : (V: array[0..1] of TVector2s);
  280. 1 : (X,Y: TVector2s);
  281. end;
  282. TMatrix2b = record
  283. case Integer of
  284. 0 : (V: array[0..1] of TVector2b);
  285. 1 : (X,Y: TVector2b);
  286. end;
  287. TMatrix2e = record
  288. case Integer of
  289. 0 : (V: array[0..1] of TVector2e);
  290. 1 : (X,Y: TVector2e);
  291. end;
  292. TMatrix2w = record
  293. case Integer of
  294. 0 : (V: array[0..1] of TVector2w);
  295. 1 : (X,Y: TVector2w);
  296. end;
  297. TMatrix2p = record
  298. case Integer of
  299. 0 : (V: array[0..1] of TVector2p);
  300. 1 : (X,Y: TVector2p);
  301. end;
  302. TMatrix3d = record
  303. case Integer of
  304. 0 : (V: array[0..2] of TVector3d);
  305. 1 : (X,Y,Z: TVector3d);
  306. end;
  307. TMatrix3f = record
  308. case Integer of
  309. 0 : (V: array[0..2] of TVector3f);
  310. 1 : (X,Y,Z: TVector3f);
  311. end;
  312. TMatrix3i = record
  313. case Integer of
  314. 0 : (V: array[0..2] of TVector3i);
  315. 1 : (X,Y,Z: TVector3i);
  316. end;
  317. TMatrix3s = record
  318. case Integer of
  319. 0 : (V: array[0..2] of TVector3s);
  320. 1 : (X,Y,Z: TVector3s);
  321. end;
  322. TMatrix3b = record
  323. case Integer of
  324. 0 : (V: array[0..2] of TVector3b);
  325. 1 : (X,Y,Z: TVector3b);
  326. end;
  327. TMatrix3e = record
  328. case Integer of
  329. 0 : (V: array[0..2] of TVector3e);
  330. 1 : (X,Y,Z: TVector3e);
  331. end;
  332. TMatrix3w = record
  333. case Integer of
  334. 0 : (V: array[0..2] of TVector3w);
  335. 1 : (X,Y,Z: TVector3w);
  336. end;
  337. TMatrix3p = record
  338. case Integer of
  339. 0 : (V: array[0..2] of TVector3p);
  340. 1 : (X,Y,Z: TVector3p);
  341. end;
  342. TMatrix4d = record
  343. case Integer of
  344. 0 : (V: array[0..3] of TVector4d);
  345. 1 : (X,Y,Z,W: TVector4d);
  346. end;
  347. TMatrix4f = record
  348. case Integer of
  349. 0 : (V: array[0..3] of TVector4f);
  350. 1 : (X,Y,Z,W: TVector4f);
  351. end;
  352. TMatrix4i = record
  353. case Integer of
  354. 0 : (V: array[0..3] of TVector4i);
  355. 1 : (X,Y,Z,W: TVector4i);
  356. end;
  357. TMatrix4s = record
  358. case Integer of
  359. 0 : (V: array[0..3] of TVector4s);
  360. 1 : (X,Y,Z,W: TVector4s);
  361. end;
  362. TMatrix4b = record
  363. case Integer of
  364. 0 : (V: array[0..3] of TVector4b);
  365. 1 : (X,Y,Z,W: TVector4b);
  366. end;
  367. TMatrix4e = record
  368. case Integer of
  369. 0 : (V: array[0..3] of TVector4e);
  370. 1 : (X,Y,Z,W: TVector4e);
  371. end;
  372. TMatrix4w = record
  373. case Integer of
  374. 0 : (V: array[0..3] of TVector4w);
  375. 1 : (X,Y,Z,W: TVector4w);
  376. end;
  377. TMatrix4p = record
  378. case Integer of
  379. 0 : (V: array[0..3] of TVector4p);
  380. 1 : (X,Y,Z,W: TVector4p);
  381. end;
  382. TD3DVector = packed record
  383. case Integer of
  384. 0 : (X: single;
  385. Y: single;
  386. Z: single);
  387. 1 : (V: TVector3f);
  388. end;
  389. TD3DMatrix = packed record
  390. case Integer of
  391. 0 : (_11, _12, _13, _14: single;
  392. _21, _22, _23, _24: single;
  393. _31, _32, _33, _34: single;
  394. _41, _42, _43, _44: single);
  395. 1 : (M : TMatrix4f);
  396. end;
  397. // the matrix by default
  398. PGLMatrix = ^TGLMatrix;
  399. TGLMatrix = TMatrix4f;
  400. //-----------------------------------------------
  401. implementation
  402. //-----------------------------------------------
  403. end.