GLVectorTypes.pas 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. //
  2. // This unit is part of the GLScene Engine, http://glscene.org
  3. //
  4. unit GLVectorTypes;
  5. (*
  6. Defines base vector types for use in GLVectorGeometry.pas.
  7. The sole aim of this unit is to limit dependency between the GLVectorGeometry
  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. 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. TVector4f = record
  140. case Integer of
  141. 0 : (V: array[0..3] of Single);
  142. 1 : (X,Y,Z,W: Single);
  143. end;
  144. TVector4h = record
  145. case Integer of
  146. 0 : (V: array[0..3] of Word);
  147. 1 : (X,Y,Z,W: Word);
  148. end;
  149. TVector4i = record
  150. case Integer of
  151. 0 : (V: array[0..3] of LongInt);
  152. 1 : (X,Y,Z,W: Longint);
  153. end;
  154. TVector4ui = record
  155. case Integer of
  156. 0 : (V: array[0..3] of LongWord);
  157. 1 : (X,Y,Z,W: LongWord);
  158. end;
  159. TVector4s = record
  160. case Integer of
  161. 0 : (V: array[0..3] of SmallInt);
  162. 1 : (X,Y,Z,W: SmallInt);
  163. end;
  164. TVector4b = record
  165. case Integer of
  166. 0 : (V: array[0..3] of Byte);
  167. 1 : (X,Y,Z,W: Byte);
  168. end;
  169. TVector4sb = record
  170. case Integer of
  171. 0 : (V: array[0..3] of ShortInt);
  172. 1 : (X,Y,Z,W: ShortInt);
  173. end;
  174. TVector4e = record
  175. case Integer of
  176. 0 : (V: array[0..3] of Extended);
  177. 1 : (X,Y,Z,W: Extended);
  178. end;
  179. TVector4w = record
  180. case Integer of
  181. 0 : (V: array[0..3] of Word);
  182. 1 : (X,Y,Z,W: Word);
  183. end;
  184. TVector4p = record
  185. case Integer of
  186. 0 : (V: array[0..3] of Pointer);
  187. 1 : (X,Y,Z,W: Pointer);
  188. end;
  189. TMatrix2d = record
  190. case Integer of
  191. 0 : (V: array[0..1] of TVector2d);
  192. 1 : (X,Y: TVector2d);
  193. end;
  194. TMatrix2f = record
  195. case Integer of
  196. 0 : (V: array[0..1] of TVector2f);
  197. 1 : (X,Y: TVector2f);
  198. end;
  199. TMatrix2i = record
  200. case Integer of
  201. 0 : (V: array[0..1] of TVector2i);
  202. 1 : (X,Y: TVector2i);
  203. end;
  204. TMatrix2s = record
  205. case Integer of
  206. 0 : (V: array[0..1] of TVector2s);
  207. 1 : (X,Y: TVector2s);
  208. end;
  209. TMatrix2b = record
  210. case Integer of
  211. 0 : (V: array[0..1] of TVector2b);
  212. 1 : (X,Y: TVector2b);
  213. end;
  214. TMatrix2e = record
  215. case Integer of
  216. 0 : (V: array[0..1] of TVector2e);
  217. 1 : (X,Y: TVector2e);
  218. end;
  219. TMatrix2w = record
  220. case Integer of
  221. 0 : (V: array[0..1] of TVector2w);
  222. 1 : (X,Y: TVector2w);
  223. end;
  224. TMatrix2p = record
  225. case Integer of
  226. 0 : (V: array[0..1] of TVector2p);
  227. 1 : (X,Y: TVector2p);
  228. end;
  229. TMatrix3d = record
  230. case Integer of
  231. 0 : (V: array[0..2] of TVector3d);
  232. 1 : (X,Y,Z: TVector3d);
  233. end;
  234. TMatrix3f = record
  235. case Integer of
  236. 0 : (V: array[0..2] of TVector3f);
  237. 1 : (X,Y,Z: TVector3f);
  238. end;
  239. TMatrix3i = record
  240. case Integer of
  241. 0 : (V: array[0..2] of TVector3i);
  242. 1 : (X,Y,Z: TVector3i);
  243. end;
  244. TMatrix3s = record
  245. case Integer of
  246. 0 : (V: array[0..2] of TVector3s);
  247. 1 : (X,Y,Z: TVector3s);
  248. end;
  249. TMatrix3b = record
  250. case Integer of
  251. 0 : (V: array[0..2] of TVector3b);
  252. 1 : (X,Y,Z: TVector3b);
  253. end;
  254. TMatrix3e = record
  255. case Integer of
  256. 0 : (V: array[0..2] of TVector3e);
  257. 1 : (X,Y,Z: TVector3e);
  258. end;
  259. TMatrix3w = record
  260. case Integer of
  261. 0 : (V: array[0..2] of TVector3w);
  262. 1 : (X,Y,Z: TVector3w);
  263. end;
  264. TMatrix3p = record
  265. case Integer of
  266. 0 : (V: array[0..2] of TVector3p);
  267. 1 : (X,Y,Z: TVector3p);
  268. end;
  269. TMatrix4d = record
  270. case Integer of
  271. 0 : (V: array[0..3] of TVector4d);
  272. 1 : (X,Y,Z,W: TVector4d);
  273. end;
  274. TMatrix4f = record
  275. case Integer of
  276. 0 : (V: array[0..3] of TVector4f);
  277. 1 : (X,Y,Z,W: TVector4f);
  278. end;
  279. TMatrix4i = record
  280. case Integer of
  281. 0 : (V: array[0..3] of TVector4i);
  282. 1 : (X,Y,Z,W: TVector4i);
  283. end;
  284. TMatrix4s = record
  285. case Integer of
  286. 0 : (V: array[0..3] of TVector4s);
  287. 1 : (X,Y,Z,W: TVector4s);
  288. end;
  289. TMatrix4b = record
  290. case Integer of
  291. 0 : (V: array[0..3] of TVector4b);
  292. 1 : (X,Y,Z,W: TVector4b);
  293. end;
  294. TMatrix4e = record
  295. case Integer of
  296. 0 : (V: array[0..3] of TVector4e);
  297. 1 : (X,Y,Z,W: TVector4e);
  298. end;
  299. TMatrix4w = record
  300. case Integer of
  301. 0 : (V: array[0..3] of TVector4w);
  302. 1 : (X,Y,Z,W: TVector4w);
  303. end;
  304. TMatrix4p = record
  305. case Integer of
  306. 0 : (V: array[0..3] of TVector4p);
  307. 1 : (X,Y,Z,W: TVector4p);
  308. end;
  309. TD3DVector = packed record
  310. case Integer of
  311. 0 : (X: single;
  312. Y: single;
  313. Z: single);
  314. 1 : (V: TVector3f);
  315. end;
  316. TD3DMatrix = packed record
  317. case Integer of
  318. 0 : (_11, _12, _13, _14: single;
  319. _21, _22, _23, _24: single;
  320. _31, _32, _33, _34: single;
  321. _41, _42, _43, _44: single);
  322. 1 : (M : TMatrix4f);
  323. end;
  324. //-----------------------------------------------
  325. implementation
  326. //-----------------------------------------------
  327. end.