GLScene.VectorTypes.pas 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. //
  2. // The graphics engine GLScene https://github.com/glscene
  3. //
  4. unit GLScene.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. // =========== Vectors ============
  19. type
  20. //2
  21. TVector2d = record
  22. case Integer of
  23. 0 : (V: array[0..1] of Double);
  24. 1 : (X: Double;
  25. Y: Double);
  26. end;
  27. TVector2f = record
  28. case Integer of
  29. 0 : (V: array[0..1] of Single);
  30. 1 : (X,Y: Single);
  31. end;
  32. TVector2h = record
  33. case Integer of
  34. 0 : (V: array[0..1] of Word);
  35. 1 : (X,Y: Word);
  36. end;
  37. TVector2i = record
  38. case Integer of
  39. 0 : (V: array[0..1] of Longint);
  40. 1 : (X,Y: Longint);
  41. end;
  42. TVector2ui = record
  43. case Integer of
  44. 0 : (V: array[0..1] of Longword);
  45. 1 : (X,Y: Longword);
  46. end;
  47. TVector2s = record
  48. case Integer of
  49. 0 : (V: array[0..1] of Smallint);
  50. 1 : (X,Y: Smallint);
  51. end;
  52. TVector2b = record
  53. case Integer of
  54. 0 : (V: array[0..1] of Byte);
  55. 1 : (X,Y: Byte);
  56. end;
  57. TVector2sb = record
  58. case Integer of
  59. 0 : (V: array[0..1] of ShortInt);
  60. 1 : (X,Y: ShortInt);
  61. end;
  62. TVector2e = record
  63. case Integer of
  64. 0 : (V: array[0..1] of Extended);
  65. 1 : (X,Y: Extended);
  66. end;
  67. TVector2w = record
  68. case Integer of
  69. 0 : (V: array[0..1] of Word);
  70. 1 : (X,Y: Word);
  71. end;
  72. TVector2p = record
  73. case Integer of
  74. 0 : (V: array[0..1] of Pointer);
  75. 1 : (X,Y: Pointer);
  76. end;
  77. //3
  78. TVector3d = record
  79. case Integer of
  80. 0 : (V: array[0..2] of Double);
  81. 1 : (X,Y,Z: Double);
  82. end;
  83. TVector3f = record
  84. case Integer of
  85. 0 : (V: array[0..2] of Single);
  86. 1 : (X,Y,Z: Single);
  87. end;
  88. TVector3h = record
  89. case Integer of
  90. 0 : (V: array[0..2] of Word);
  91. 1 : (X,Y,Z: Word);
  92. end;
  93. TVector3i = record
  94. case Integer of
  95. 0 : (V: array[0..2] of Longint);
  96. 1 : (X,Y,Z: Longint);
  97. end;
  98. TVector3ui = record
  99. case Integer of
  100. 0 : (V: array[0..2] of Longword);
  101. 1 : (X,Y,Z: Longword);
  102. end;
  103. TVector3s = record
  104. case Integer of
  105. 0 : (V: array[0..2] of Smallint);
  106. 1 : (X,Y,Z: Smallint);
  107. end;
  108. TVector3b = record
  109. case Integer of
  110. 0 : (V: array[0..2] of Byte);
  111. 1 : (X,Y,Z: Byte);
  112. end;
  113. TVector3sb = record
  114. case Integer of
  115. 0 : (V: array[0..2] of ShortInt);
  116. 1 : (X,Y,Z: ShortInt);
  117. end;
  118. TVector3e = record
  119. case Integer of
  120. 0 : (V: array[0..2] of Extended);
  121. 1 : (X,Y,Z: Extended);
  122. end;
  123. TVector3w = record
  124. case Integer of
  125. 0 : (V: array[0..2] of Word);
  126. 1 : (X,Y,Z: Word);
  127. end;
  128. TVector3p = record
  129. case Integer of
  130. 0 : (V: array[0..2] of Pointer);
  131. 1 : (X,Y,Z: Pointer);
  132. end;
  133. //4
  134. TVector4d = record
  135. case Integer of
  136. 0 : (V: array[0..3] of Double);
  137. 1 : (X,Y,Z,W: Double);
  138. end;
  139. PVector4f = ^TVector4f;
  140. TVector4f = record
  141. case Integer of
  142. 0 : (V: array[0..3] of Single);
  143. 1 : (X,Y,Z,W: Single);
  144. end;
  145. TVector4h = record
  146. case Integer of
  147. 0 : (V: array[0..3] of Word);
  148. 1 : (X,Y,Z,W: Word);
  149. end;
  150. TVector4i = record
  151. case Integer of
  152. 0 : (V: array[0..3] of LongInt);
  153. 1 : (X,Y,Z,W: Longint);
  154. end;
  155. TVector4ui = record
  156. case Integer of
  157. 0 : (V: array[0..3] of LongWord);
  158. 1 : (X,Y,Z,W: LongWord);
  159. end;
  160. TVector4s = record
  161. case Integer of
  162. 0 : (V: array[0..3] of SmallInt);
  163. 1 : (X,Y,Z,W: SmallInt);
  164. end;
  165. TVector4b = record
  166. case Integer of
  167. 0 : (V: array[0..3] of Byte);
  168. 1 : (X,Y,Z,W: Byte);
  169. end;
  170. TVector4sb = record
  171. case Integer of
  172. 0 : (V: array[0..3] of ShortInt);
  173. 1 : (X,Y,Z,W: ShortInt);
  174. end;
  175. TVector4e = record
  176. case Integer of
  177. 0 : (V: array[0..3] of Extended);
  178. 1 : (X,Y,Z,W: Extended);
  179. end;
  180. TVector4w = record
  181. case Integer of
  182. 0 : (V: array[0..3] of Word);
  183. 1 : (X,Y,Z,W: Word);
  184. end;
  185. TVector4p = record
  186. case Integer of
  187. 0 : (V: array[0..3] of Pointer);
  188. 1 : (X,Y,Z,W: Pointer);
  189. end;
  190. // =========== Matrices ============
  191. TMatrix2d = record
  192. case Integer of
  193. 0 : (V: array[0..1] of TVector2d);
  194. 1 : (X,Y: TVector2d);
  195. end;
  196. TMatrix2f = record
  197. case Integer of
  198. 0 : (V: array[0..1] of TVector2f);
  199. 1 : (X,Y: TVector2f);
  200. end;
  201. TMatrix2i = record
  202. case Integer of
  203. 0 : (V: array[0..1] of TVector2i);
  204. 1 : (X,Y: TVector2i);
  205. end;
  206. TMatrix2s = record
  207. case Integer of
  208. 0 : (V: array[0..1] of TVector2s);
  209. 1 : (X,Y: TVector2s);
  210. end;
  211. TMatrix2b = record
  212. case Integer of
  213. 0 : (V: array[0..1] of TVector2b);
  214. 1 : (X,Y: TVector2b);
  215. end;
  216. TMatrix2e = record
  217. case Integer of
  218. 0 : (V: array[0..1] of TVector2e);
  219. 1 : (X,Y: TVector2e);
  220. end;
  221. TMatrix2w = record
  222. case Integer of
  223. 0 : (V: array[0..1] of TVector2w);
  224. 1 : (X,Y: TVector2w);
  225. end;
  226. TMatrix2p = record
  227. case Integer of
  228. 0 : (V: array[0..1] of TVector2p);
  229. 1 : (X,Y: TVector2p);
  230. end;
  231. TMatrix3d = record
  232. case Integer of
  233. 0 : (V: array[0..2] of TVector3d);
  234. 1 : (X,Y,Z: TVector3d);
  235. end;
  236. TMatrix3f = record
  237. case Integer of
  238. 0 : (V: array[0..2] of TVector3f);
  239. 1 : (X,Y,Z: TVector3f);
  240. end;
  241. TMatrix3i = record
  242. case Integer of
  243. 0 : (V: array[0..2] of TVector3i);
  244. 1 : (X,Y,Z: TVector3i);
  245. end;
  246. TMatrix3s = record
  247. case Integer of
  248. 0 : (V: array[0..2] of TVector3s);
  249. 1 : (X,Y,Z: TVector3s);
  250. end;
  251. TMatrix3b = record
  252. case Integer of
  253. 0 : (V: array[0..2] of TVector3b);
  254. 1 : (X,Y,Z: TVector3b);
  255. end;
  256. TMatrix3e = record
  257. case Integer of
  258. 0 : (V: array[0..2] of TVector3e);
  259. 1 : (X,Y,Z: TVector3e);
  260. end;
  261. TMatrix3w = record
  262. case Integer of
  263. 0 : (V: array[0..2] of TVector3w);
  264. 1 : (X,Y,Z: TVector3w);
  265. end;
  266. TMatrix3p = record
  267. case Integer of
  268. 0 : (V: array[0..2] of TVector3p);
  269. 1 : (X,Y,Z: TVector3p);
  270. end;
  271. TMatrix4d = record
  272. case Integer of
  273. 0 : (V: array[0..3] of TVector4d);
  274. 1 : (X,Y,Z,W: TVector4d);
  275. end;
  276. // the matrix by default
  277. PMatrix4f = ^TMatrix4f;
  278. TMatrix4f = record
  279. case Integer of
  280. 0 : (V: array[0..3] of TVector4f);
  281. 1 : (X,Y,Z,W: TVector4f);
  282. end;
  283. TMatrix4i = record
  284. case Integer of
  285. 0 : (V: array[0..3] of TVector4i);
  286. 1 : (X,Y,Z,W: TVector4i);
  287. end;
  288. TMatrix4s = record
  289. case Integer of
  290. 0 : (V: array[0..3] of TVector4s);
  291. 1 : (X,Y,Z,W: TVector4s);
  292. end;
  293. TMatrix4b = record
  294. case Integer of
  295. 0 : (V: array[0..3] of TVector4b);
  296. 1 : (X,Y,Z,W: TVector4b);
  297. end;
  298. TMatrix4e = record
  299. case Integer of
  300. 0 : (V: array[0..3] of TVector4e);
  301. 1 : (X,Y,Z,W: TVector4e);
  302. end;
  303. TMatrix4w = record
  304. case Integer of
  305. 0 : (V: array[0..3] of TVector4w);
  306. 1 : (X,Y,Z,W: TVector4w);
  307. end;
  308. TMatrix4p = record
  309. case Integer of
  310. 0 : (V: array[0..3] of TVector4p);
  311. 1 : (X,Y,Z,W: TVector4p);
  312. end;
  313. TD3DVector = packed record
  314. case Integer of
  315. 0 : (X: single;
  316. Y: single;
  317. Z: single);
  318. 1 : (V: TVector3f);
  319. end;
  320. TD3DMatrix = packed record
  321. case Integer of
  322. 0 : (_11, _12, _13, _14: single;
  323. _21, _22, _23, _24: single;
  324. _31, _32, _33, _34: single;
  325. _41, _42, _43, _44: single);
  326. 1 : (M : TMatrix4f);
  327. end;
  328. // The vector by default
  329. PGLVector = ^TGLVector;
  330. TGLVector = TVector4f;
  331. // The matrix by default
  332. PGLMatrix = ^TGLMatrix;
  333. TGLMatrix = TMatrix4f;
  334. implementation //--------------------------------------------------------------
  335. end.