2
0

GLS.VectorTypes.pas 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. //
  2. // The graphics rendering engine GLScene http://glscene.org
  3. //
  4. unit GLS.VectorTypes;
  5. (*
  6. Defines base vector types for use in GLS.VectorGeometry.pas.
  7. The sole aim of this unit is to limit dependency between the GLS.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. PGLVector = ^TGLVector;
  259. TGLVector = TVector4f;
  260. // =========== Matrices ============
  261. TMatrix2d = record
  262. case Integer of
  263. 0 : (V: array[0..1] of TVector2d);
  264. 1 : (X,Y: TVector2d);
  265. end;
  266. TMatrix2f = record
  267. case Integer of
  268. 0 : (V: array[0..1] of TVector2f);
  269. 1 : (X,Y: TVector2f);
  270. end;
  271. TMatrix2i = record
  272. case Integer of
  273. 0 : (V: array[0..1] of TVector2i);
  274. 1 : (X,Y: TVector2i);
  275. end;
  276. TMatrix2s = record
  277. case Integer of
  278. 0 : (V: array[0..1] of TVector2s);
  279. 1 : (X,Y: TVector2s);
  280. end;
  281. TMatrix2b = record
  282. case Integer of
  283. 0 : (V: array[0..1] of TVector2b);
  284. 1 : (X,Y: TVector2b);
  285. end;
  286. TMatrix2e = record
  287. case Integer of
  288. 0 : (V: array[0..1] of TVector2e);
  289. 1 : (X,Y: TVector2e);
  290. end;
  291. TMatrix2w = record
  292. case Integer of
  293. 0 : (V: array[0..1] of TVector2w);
  294. 1 : (X,Y: TVector2w);
  295. end;
  296. TMatrix2p = record
  297. case Integer of
  298. 0 : (V: array[0..1] of TVector2p);
  299. 1 : (X,Y: TVector2p);
  300. end;
  301. TMatrix3d = record
  302. case Integer of
  303. 0 : (V: array[0..2] of TVector3d);
  304. 1 : (X,Y,Z: TVector3d);
  305. end;
  306. TMatrix3f = record
  307. case Integer of
  308. 0 : (V: array[0..2] of TVector3f);
  309. 1 : (X,Y,Z: TVector3f);
  310. end;
  311. TMatrix3i = record
  312. case Integer of
  313. 0 : (V: array[0..2] of TVector3i);
  314. 1 : (X,Y,Z: TVector3i);
  315. end;
  316. TMatrix3s = record
  317. case Integer of
  318. 0 : (V: array[0..2] of TVector3s);
  319. 1 : (X,Y,Z: TVector3s);
  320. end;
  321. TMatrix3b = record
  322. case Integer of
  323. 0 : (V: array[0..2] of TVector3b);
  324. 1 : (X,Y,Z: TVector3b);
  325. end;
  326. TMatrix3e = record
  327. case Integer of
  328. 0 : (V: array[0..2] of TVector3e);
  329. 1 : (X,Y,Z: TVector3e);
  330. end;
  331. TMatrix3w = record
  332. case Integer of
  333. 0 : (V: array[0..2] of TVector3w);
  334. 1 : (X,Y,Z: TVector3w);
  335. end;
  336. TMatrix3p = record
  337. case Integer of
  338. 0 : (V: array[0..2] of TVector3p);
  339. 1 : (X,Y,Z: TVector3p);
  340. end;
  341. TMatrix4d = record
  342. case Integer of
  343. 0 : (V: array[0..3] of TVector4d);
  344. 1 : (X,Y,Z,W: TVector4d);
  345. end;
  346. TMatrix4f = record
  347. case Integer of
  348. 0 : (V: array[0..3] of TVector4f);
  349. 1 : (X,Y,Z,W: TVector4f);
  350. end;
  351. TMatrix4i = record
  352. case Integer of
  353. 0 : (V: array[0..3] of TVector4i);
  354. 1 : (X,Y,Z,W: TVector4i);
  355. end;
  356. TMatrix4s = record
  357. case Integer of
  358. 0 : (V: array[0..3] of TVector4s);
  359. 1 : (X,Y,Z,W: TVector4s);
  360. end;
  361. TMatrix4b = record
  362. case Integer of
  363. 0 : (V: array[0..3] of TVector4b);
  364. 1 : (X,Y,Z,W: TVector4b);
  365. end;
  366. TMatrix4e = record
  367. case Integer of
  368. 0 : (V: array[0..3] of TVector4e);
  369. 1 : (X,Y,Z,W: TVector4e);
  370. end;
  371. TMatrix4w = record
  372. case Integer of
  373. 0 : (V: array[0..3] of TVector4w);
  374. 1 : (X,Y,Z,W: TVector4w);
  375. end;
  376. TMatrix4p = record
  377. case Integer of
  378. 0 : (V: array[0..3] of TVector4p);
  379. 1 : (X,Y,Z,W: TVector4p);
  380. end;
  381. TD3DVector = packed record
  382. case Integer of
  383. 0 : (X: single;
  384. Y: single;
  385. Z: single);
  386. 1 : (V: TVector3f);
  387. end;
  388. TD3DMatrix = packed record
  389. case Integer of
  390. 0 : (_11, _12, _13, _14: single;
  391. _21, _22, _23, _24: single;
  392. _31, _32, _33, _34: single;
  393. _41, _42, _43, _44: single);
  394. 1 : (M : TMatrix4f);
  395. end;
  396. PGLMatrix = ^TGLMatrix;
  397. TGLMatrix = TMatrix4f;
  398. //-----------------------------------------------
  399. implementation
  400. //-----------------------------------------------
  401. end.