diff options
Diffstat (limited to 'lib')
56 files changed, 48884 insertions, 0 deletions
diff --git a/lib/base/devel/FGInt.pas b/lib/base/devel/FGInt.pas new file mode 100644 index 000000000..7cb5a8516 --- /dev/null +++ b/lib/base/devel/FGInt.pas @@ -0,0 +1,2199 @@ +{License, info, etc + ------------------ + +This implementation is made by me, Walied Othman, to contact me +mail to Walied.Othman@belgacom.net or Triade@ulyssis.org, +always mention wether it 's about the FGInt for Delphi or for +FreePascal, or wether it 's about the 6xs, preferably in the subject line. +If you 're going to use these implementations, at least mention my +name or something and notify me so I may even put a link on my page. +This implementation is freeware and according to the coderpunks' +manifesto it should remain so, so don 't use these implementations +in commercial software. Encryption, as a tool to ensure privacy +should be free and accessible for anyone. If you plan to use these +implementations in a commercial application, contact me before +doing so, that way you can license the software to use it in commercial +Software. If any algorithm is patented in your country, you should +acquire a license before using this software. Modified versions of this +software must contain an acknowledgement of the original author (=me). +This implementation is available at +http://triade.studentenweb.org + +copyright 2000, Walied Othman +This header may not be removed. +} + +Unit FGInt; + +{$H+} + +Interface + +Uses SysUtils, Math; + +Type + TCompare = (Lt, St, Eq, Er); + TSign = (negative, positive); + TFGInt = Record + Sign : TSign; + Number : Array Of LongWord; + End; + +Procedure zeronetochar8(Var g : char; Const x : String); +Procedure zeronetochar6(Var g : integer; Const x : String); +Procedure initialize8(Var trans : Array Of String); +Procedure initialize6(Var trans : Array Of String); +Procedure initialize6PGP(Var trans : Array Of String); +Procedure ConvertBase256to64(Const str256 : String; Var str64 : String); +Procedure ConvertBase64to256(Const str64 : String; Var str256 : String); +Procedure ConvertBase256to2(Const str256 : String; Var str2 : String); +Procedure ConvertBase64to2(Const str64 : String; Var str2 : String); +Procedure ConvertBase2to256(str2 : String; Var str256 : String); +Procedure ConvertBase2to64(str2 : String; Var str64 : String); +Procedure ConvertBase256StringToHexString(Str256 : String; Var HexStr : String); +Procedure ConvertHexStringToBase256String(HexStr : String; Var Str256 : String); +Procedure PGPConvertBase256to64(Var str256, str64 : String); +Procedure PGPConvertBase64to256(str64 : String; Var str256 : String); +Procedure PGPConvertBase64to2(str64 : String; Var str2 : String); +Procedure FGIntToBase2String(Const FGInt : TFGInt; Var S : String); +Procedure Base2StringToFGInt(S : String; Var FGInt : TFGInt); +Procedure FGIntToBase256String(Const FGInt : TFGInt; Var str256 : String); +Procedure Base256StringToFGInt(str256 : String; Var FGInt : TFGInt); +Procedure PGPMPIToFGInt(PGPMPI : String; Var FGInt : TFGInt); +Procedure FGIntToPGPMPI(FGInt : TFGInt; Var PGPMPI : String); +Procedure Base10StringToFGInt(Base10 : String; Var FGInt : TFGInt); +Procedure FGIntToBase10String(Const FGInt : TFGInt; Var Base10 : String); +Procedure FGIntDestroy(Var FGInt : TFGInt); +Function FGIntCompareAbs(Const FGInt1, FGInt2 : TFGInt) : TCompare; +Procedure FGIntAdd(Const FGInt1, FGInt2 : TFGInt; Var Sum : TFGInt); +Procedure FGIntChangeSign(Var FGInt : TFGInt); +Procedure FGIntSub(Var FGInt1, FGInt2, dif : TFGInt); +Procedure FGIntMulByInt(Const FGInt : TFGInt; Var res : TFGInt; by : LongWord); +Procedure FGIntMulByIntbis(Var FGInt : TFGInt; by : LongWord); +Procedure FGIntDivByInt(Const FGInt : TFGInt; Var res : TFGInt; by : LongWord; Var modres : LongWord); +Procedure FGIntDivByIntBis(Var FGInt : TFGInt; by : LongWord; Var modres : LongWord); +Procedure FGIntModByInt(Const FGInt : TFGInt; by : LongWord; Var modres : LongWord); +Procedure FGIntAbs(Var FGInt : TFGInt); +Procedure FGIntCopy(Const FGInt1 : TFGInt; Var FGInt2 : TFGInt); +Procedure FGIntShiftLeft(Var FGInt : TFGInt); +Procedure FGIntShiftRight(Var FGInt : TFGInt); +Procedure FGIntShiftRightBy31(Var FGInt : TFGInt); +Procedure FGIntAddBis(Var FGInt1 : TFGInt; Const FGInt2 : TFGInt); +Procedure FGIntSubBis(Var FGInt1 : TFGInt; Const FGInt2 : TFGInt); +Procedure FGIntMul(Const FGInt1, FGInt2 : TFGInt; Var Prod : TFGInt); +Procedure FGIntSquare(Const FGInt : TFGInt; Var Square : TFGInt); +Procedure FGIntExp(Const FGInt, exp : TFGInt; Var res : TFGInt); +Procedure FGIntFac(Const FGInt : TFGInt; Var res : TFGInt); +Procedure FGIntShiftLeftBy31(Var FGInt : TFGInt); +Procedure FGIntDivMod(Var FGInt1, FGInt2, QFGInt, MFGInt : TFGInt); +Procedure FGIntDiv(Var FGInt1, FGInt2, QFGInt : TFGInt); +Procedure FGIntMod(Var FGInt1, FGInt2, MFGInt : TFGInt); +Procedure FGIntSquareMod(Var FGInt, Modb, FGIntSM : TFGInt); +Procedure FGIntAddMod(Var FGInt1, FGInt2, base, FGIntres : TFGInt); +Procedure FGIntMulMod(Var FGInt1, FGInt2, base, FGIntres : TFGInt); +Procedure FGIntModExp(Var FGInt, exp, modb, res : TFGInt); +Procedure FGIntModBis(Const FGInt : TFGInt; Var FGIntOut : TFGInt; b, head : LongWord); +Procedure FGIntMulModBis(Const FGInt1, FGInt2 : TFGInt; Var Prod : TFGInt; b, head : LongWord); +Procedure FGIntMontgomeryMod(Const GInt, base, baseInv : TFGInt; Var MGInt : TFGInt; b : Longword; head : LongWord); +Procedure FGIntMontgomeryModExp(Var FGInt, exp, modb, res : TFGInt); +Procedure FGIntGCD(Const FGInt1, FGInt2 : TFGInt; Var GCD : TFGInt); +Procedure FGIntLCM(Const FGInt1, FGInt2 : TFGInt; Var LCM : TFGInt); +Procedure FGIntTrialDiv9999(Const FGInt : TFGInt; Var ok : boolean); +Procedure FGIntRandom1(Var Seed, RandomFGInt : TFGInt); +Procedure FGIntRabinMiller(Var FGIntp : TFGInt; nrtest : Longword; Var ok : boolean); +Procedure FGIntBezoutBachet(Var FGInt1, FGInt2, a, b : TFGInt); +Procedure FGIntModInv(Const FGInt1, base : TFGInt; Var Inverse : TFGInt); +Procedure FGIntPrimetest(Var FGIntp : TFGInt; nrRMtests : integer; Var ok : boolean); +Procedure FGIntLegendreSymbol(Var a, p : TFGInt; Var L : integer); +Procedure FGIntSquareRootModP(Square, Prime : TFGInt; Var SquareRoot : TFGInt); + + + +Implementation + +Var + primes : Array[1..1228] Of integer = + (3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, + 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, + 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, + 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, + 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, + 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, + 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, + 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, + 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, + 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, + 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, + 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, + 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, + 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, + 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, + 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, + 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, + 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, + 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, + 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, + 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, + 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, + 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, + 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, + 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, + 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, + 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, + 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, + 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, + 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, + 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, + 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, + 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, + 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, + 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, + 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, + 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, + 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, + 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, + 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, + 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, + 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, + 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, + 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, + 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, + 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, + 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, + 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, + 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, + 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, + 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, + 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, + 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, + 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, + 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, + 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, + 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, + 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, + 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, + 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, + 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, + 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, + 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973); + chr64 : Array[1..64] Of char = ('a', 'A', 'b', 'B', 'c', 'C', 'd', 'D', 'e', 'E', 'f', 'F', + 'g', 'G', 'h', 'H', 'i', 'I', 'j', 'J', 'k', 'K', 'l', 'L', 'm', 'M', 'n', 'N', 'o', 'O', 'p', + 'P', 'q', 'Q', 'r', 'R', 's', 'S', 't', 'T', 'u', 'U', 'v', 'V', 'w', 'W', 'x', 'X', 'y', 'Y', + 'z', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '='); + PGPchr64 : Array[1..64] Of char = ('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', + 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', + 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'); + + + +Procedure zeronetochar8(Var g : char; Const x : String); +Var + i : Integer; + b : byte; +Begin + b := 0; + For i := 1 To 8 Do + Begin + If copy(x, i, 1) = '1' Then + b := b Or (1 Shl (8 - I)); + End; + g := chr(b); +End; + + +Procedure zeronetochar6(Var g : integer; Const x : String); +Var + I : Integer; +Begin + G := 0; + For I := 1 To Length(X) Do + Begin + If I > 6 Then + Break; + If X[I] <> '0' Then + G := G Or (1 Shl (6 - I)); + End; + Inc(G); +End; + + +Procedure initialize8(Var trans : Array Of String); +Var + c1, c2, c3, c4, c5, c6, c7, c8 : integer; + x : String; + g : char; +Begin + For c1 := 0 To 1 Do + For c2 := 0 To 1 Do + For c3 := 0 To 1 Do + For c4 := 0 To 1 Do + For c5 := 0 To 1 Do + For c6 := 0 To 1 Do + For c7 := 0 To 1 Do + For c8 := 0 To 1 Do + Begin + x := chr(48+c1) + chr(48+c2) + chr(48+c3) + chr(48+c4) + chr(48+c5) + chr(48+c6) + chr(48+c7) + chr(48+c8); + zeronetochar8(g, x); + trans[ord(g)] := x; + End; +End; + + +Procedure initialize6(Var trans : Array Of String); +Var + c1, c2, c3, c4, c5, c6 : integer; + x : String; + g : integer; +Begin + For c1 := 0 To 1 Do + For c2 := 0 To 1 Do + For c3 := 0 To 1 Do + For c4 := 0 To 1 Do + For c5 := 0 To 1 Do + For c6 := 0 To 1 Do + Begin + x := chr(48+c1) + chr(48+c2) + chr(48+c3) + chr(48+c4) + chr(48+c5) + chr(48+c6); + zeronetochar6(g, x); + trans[ord(chr64[g])] := x; + End; +End; + +Procedure initialize6PGP(Var trans : Array Of String); +Var + c1, c2, c3, c4, c5, c6 : integer; + x : String; + g : integer; +Begin + For c1 := 0 To 1 Do + For c2 := 0 To 1 Do + For c3 := 0 To 1 Do + For c4 := 0 To 1 Do + For c5 := 0 To 1 Do + For c6 := 0 To 1 Do + Begin + x := chr(48+c1) + chr(48+c2) + chr(48+c3) + chr(48+c4) + chr(48+c5) + chr(48+c6); + zeronetochar6(g, x); + trans[ord(PGPchr64[g])] := x; + End; +End; + + +// Convert base 8 strings to base 6 strings and visa versa + +Procedure ConvertBase256to64(Const str256 : String; Var str64 : String); +Var + temp : String; + trans : Array[0..255] Of String; + i, len6 : longint; + g : integer; +Begin + initialize8(trans); + temp := ''; + For i := 1 To length(str256) Do temp := temp + trans[ord(str256[i])]; + While (length(temp) Mod 6) <> 0 Do temp := temp + '0'; + len6 := length(temp) Div 6; + str64 := ''; + For i := 1 To len6 Do + Begin + zeronetochar6(g, copy(temp, 1, 6)); + str64 := str64 + chr64[g]; + delete(temp, 1, 6); + End; +End; + + +Procedure ConvertBase64to256(Const str64 : String; Var str256 : String); +Var + temp : String; + trans : Array[0..255] Of String; + i, len8 : longint; + g : char; +Begin + initialize6(trans); + temp := ''; + For i := 1 To length(str64) Do temp := temp + trans[ord(str64[i])]; + str256 := ''; + len8 := length(temp) Div 8; + For i := 1 To len8 Do + Begin + zeronetochar8(g, copy(temp, 1, 8)); + str256 := str256 + g; + delete(temp, 1, 8); + End; +End; + + +// Convert base 8 & 6 bit strings to base 2 strings and visa versa + +Procedure ConvertBase256to2(Const str256 : String; Var str2 : String); +Var + trans : Array[0..255] Of String; + i : longint; +Begin + str2 := ''; + initialize8(trans); + For i := 1 To length(str256) Do str2 := str2 + trans[ord(str256[i])]; +End; + + +Procedure ConvertBase64to2(Const str64 : String; Var str2 : String); +Var + trans : Array[0..255] Of String; + i : longint; +Begin + str2 := ''; + initialize6(trans); + For i := 1 To length(str64) Do str2 := str2 + trans[ord(str64[i])]; +End; + + +Procedure ConvertBase2to256(str2 : String; Var str256 : String); +Var + i, len8 : longint; + g : char; +Begin + str256 := ''; + While (length(str2) Mod 8) <> 0 Do str2 := '0' + str2; + len8 := length(str2) Div 8; + For i := 1 To len8 Do + Begin + zeronetochar8(g, copy(str2, 1, 8)); + str256 := str256 + g; + delete(str2, 1, 8); + End; +End; + + +Procedure ConvertBase2to64(str2 : String; Var str64 : String); +Var + i, len6 : longint; + g : integer; +Begin + str64 := ''; + While (length(str2) Mod 6) <> 0 Do str2 := '0' + str2; + len6 := length(str2) Div 6; + For i := 1 To len6 Do + Begin + zeronetochar6(g, copy(str2, 1, 6)); + str64 := str64 + chr64[g]; + delete(str2, 1, 6); + End; +End; + + +// Convert base 256 strings to base 16 (HexaDecimal) strings and visa versa + +Procedure ConvertBase256StringToHexString(Str256 : String; Var HexStr : String); +Var + i : longint; + b : byte; +Begin + HexStr := ''; + For i := 1 To length(str256) Do + Begin + b := ord(str256[i]); + If (b Shr 4) < 10 Then HexStr := HexStr + chr(48 + (b Shr 4)) + Else HexStr := HexStr + chr(55 + (b Shr 4)); + If (b And 15) < 10 Then HexStr := HexStr + chr(48 + (b And 15)) + Else HexStr := HexStr + chr(55 + (b And 15)); + End; +End; + + +Procedure ConvertHexStringToBase256String(HexStr : String; Var Str256 : String); +Var + i : longint; + b, h1, h2 : byte; + temp : string; +Begin + Str256 := ''; + If (length(Hexstr) mod 2) = 1 Then temp := '0' + HexStr Else temp := HexStr; + For i := 1 To (length(temp) Div 2) Do + Begin + h2 := ord(temp[2 * i]); + h1 := ord(temp[2 * i - 1]); + If h1 < 58 Then + b := ((h1 - 48) Shl 4) + Else + b := ((h1 - 55) Shl 4); + If h2 < 58 Then + b := (b Or (h2 - 48)) + Else + b := (b Or ((h2 - 55) and 15)); + Str256 := Str256 + chr(b); + End; +End; + + +// Convert base 256 strings to base 64 strings and visa versa, PGP style + +Procedure PGPConvertBase256to64(Var str256, str64 : String); +Var + temp, x, a : String; + i, len6 : longint; + g : integer; + trans : Array[0..255] Of String; +Begin + initialize8(trans); + temp := ''; + For i := 1 To length(str256) Do temp := temp + trans[ord(str256[i])]; + If (length(temp) Mod 6) = 0 Then a := '' Else + If (length(temp) Mod 6) = 4 Then + Begin + temp := temp + '00'; + a := '=' + End + Else + Begin + temp := temp + '0000'; + a := '==' + End; + str64 := ''; + len6 := length(temp) Div 6; + For i := 1 To len6 Do + Begin + x := copy(temp, 1, 6); + zeronetochar6(g, x); + str64 := str64 + PGPchr64[g]; + delete(temp, 1, 6); + End; + str64 := str64 + a; +End; + + +Procedure PGPConvertBase64to256(str64 : String; Var str256 : String); +Var + temp, x : String; + i, j, len8 : longint; + g : char; + trans : Array[0..255] Of String; +Begin + initialize6PGP(trans); + temp := ''; + str256 := ''; + If str64[length(str64) - 1] = '=' Then j := 2 Else + If str64[length(str64)] = '=' Then j := 1 Else j := 0; + For i := 1 To (length(str64) - j) Do temp := temp + trans[ord(str64[i])]; + If j <> 0 Then delete(temp, length(temp) - 2 * j + 1, 2 * j); + len8 := length(temp) Div 8; + For i := 1 To len8 Do + Begin + x := copy(temp, 1, 8); + zeronetochar8(g, x); + str256 := str256 + g; + delete(temp, 1, 8); + End; +End; + +// Convert base 64 strings to base 2 strings, PGP style + + +Procedure PGPConvertBase64to2(str64 : String; Var str2 : String); +Var + i, j : longint; + trans : Array[0..255] Of String; +Begin + str2 := ''; + initialize6(trans); + If str64[length(str64) - 1] = '=' Then j := 2 Else + If str64[length(str64)] = '=' Then j := 1 Else j := 0; + For i := 1 To (length(str64) - j) Do str2 := str2 + trans[ord(str64[i])]; + delete(str2, length(str2) - 2 * j + 1, 2 * j); +End; + + +// Convert a FGInt to a binary string (base 2) & visa versa + +Procedure FGIntToBase2String(Const FGInt : TFGInt; Var S : String); +Var + i : LongWord; + j : integer; +Begin + S := ''; + For i := 1 To FGInt.Number[0] Do + Begin + For j := 0 To 30 Do + If (1 And (FGInt.Number[i] Shr j)) = 1 Then + S := '1' + S + Else + S := '0' + S; + End; + While (length(S) > 1) And (S[1] = '0') Do + delete(S, 1, 1); + If S = '' Then S := '0'; +End; + + +Procedure Base2StringToFGInt(S : String; Var FGInt : TFGInt); +Var + i, j, size : LongWord; +Begin + While (S[1] = '0') And (length(S) > 1) Do + delete(S, 1, 1); + size := length(S) Div 31; + If (length(S) Mod 31) <> 0 Then size := size + 1; + SetLength(FGInt.Number, (size + 1)); + FGInt.Number[0] := size; + j := 1; + FGInt.Number[j] := 0; + i := 0; + While length(S) > 0 Do + Begin + If S[length(S)] = '1' Then + FGInt.Number[j] := FGInt.Number[j] Or (1 Shl i); + i := i + 1; + If i = 31 Then + Begin + i := 0; + j := j + 1; + If j <= size Then FGInt.Number[j] := 0; + End; + delete(S, length(S), 1); + End; + FGInt.Sign := positive; +End; + + +// Convert a FGInt to an base 256 string & visa versa + +Procedure FGIntToBase256String(Const FGInt : TFGInt; Var str256 : String); +Var + temp1 : String; + i, len8 : LongWord; + g : char; +Begin + FGIntToBase2String(FGInt, temp1); + While (length(temp1) Mod 8) <> 0 Do temp1 := '0' + temp1; + len8 := length(temp1) Div 8; + str256 := ''; + For i := 1 To len8 Do + Begin + zeronetochar8(g, copy(temp1, 1, 8)); + str256 := str256 + g; + delete(temp1, 1, 8); + End; +End; + + +Procedure Base256StringToFGInt(str256 : String; Var FGInt : TFGInt); +Var + temp1 : String; + i : longint; + trans : Array[0..255] Of String; +Begin + temp1 := ''; + initialize8(trans); + For i := 1 To length(str256) Do temp1 := temp1 + trans[ord(str256[i])]; + While (temp1[1] = '0') And (temp1 <> '0') Do delete(temp1, 1, 1); + Base2StringToFGInt(temp1, FGInt); +End; + +// Convert an MPI (Multiple Precision Integer, PGP style) to an FGInt & +// visa versa + +Procedure PGPMPIToFGInt(PGPMPI : String; Var FGInt : TFGInt); +Var + temp : String; +Begin + temp := PGPMPI; + delete(temp, 1, 2); + Base256StringToFGInt(temp, FGInt); +End; + + +Procedure FGIntToPGPMPI(FGInt : TFGInt; Var PGPMPI : String); +Var + len, i : word; + c : char; + b : byte; +Begin + FGIntToBase256String(FGInt, PGPMPI); + len := length(PGPMPI) * 8; + c := PGPMPI[1]; + For i := 7 Downto 0 Do If (ord(c) Shr i) = 0 Then len := len - 1 Else break; + b := len Mod 256; + PGPMPI := chr(b) + PGPMPI; + b := len Div 256; + PGPMPI := chr(b) + PGPMPI; +End; + + +// Convert a base 10 string to a FGInt +// NESTED +Procedure GIntDivByIntBis1(Var GInt : TFGInt; by : LongWord; Var modres : word); +Var + i, size, rest, temp : LongWord; +Begin + size := GInt.Number[0]; + temp := 0; + For i := size Downto 1 Do + Begin + temp := temp * 10000; + rest := temp + GInt.Number[i]; + GInt.Number[i] := rest Div by; + temp := rest Mod by; + End; + modres := temp; + While (GInt.Number[size] = 0) And (size > 1) Do + size := size - 1; + If size <> GInt.Number[0] Then + Begin + SetLength(GInt.Number, size + 1); + GInt.Number[0] := size; + End; +End; + +Procedure Base10StringToFGInt(Base10 : String; Var FGInt : TFGInt); +Var + i, size : LongWord; + j : word; + S, x : String; + sign : TSign; + + +Begin + While (Not (Base10[1] In ['-', '0'..'9'])) And (length(Base10) > 1) Do + delete(Base10, 1, 1); + If copy(Base10, 1, 1) = '-' Then + Begin + Sign := negative; + delete(Base10, 1, 1); + End + Else + Sign := positive; + While (length(Base10) > 1) And (copy(Base10, 1, 1) = '0') Do + delete(Base10, 1, 1); + size := length(Base10) Div 4; + If (length(Base10) Mod 4) <> 0 Then size := size + 1; + SetLength(FGInt.Number, size + 1); + FGInt.Number[0] := size; + For i := 1 To (size - 1) Do + Begin + x := copy(Base10, length(Base10) - 3, 4); + FGInt.Number[i] := StrToInt(x); + delete(Base10, length(Base10) - 3, 4); + End; + FGInt.Number[size] := StrToInt(Base10); + + S := ''; + While (FGInt.Number[0] <> 1) Or (FGInt.Number[1] <> 0) Do + Begin + GIntDivByIntBis1(FGInt, 2, j); + S := inttostr(j) + S; + End; + If S = '' Then S := '0'; + FGIntDestroy(FGInt); + Base2StringToFGInt(S, FGInt); + FGInt.Sign := sign; +End; + + +// Convert a FGInt to a base 10 string + +Procedure FGIntToBase10String(Const FGInt : TFGInt; Var Base10 : String); +Var + S : String; + j : LongWord; + temp : TFGInt; +Begin + FGIntCopy(FGInt, temp); + Base10 := ''; + While (temp.Number[0] > 1) Or (temp.Number[1] > 0) Do + Begin + FGIntDivByIntBis(temp, 10000, j); + S := IntToStr(j); + While Length(S) < 4 Do + S := '0' + S; + Base10 := S + Base10; + End; + Base10 := '0' + Base10; + While (length(Base10) > 1) And (Base10[1] = '0') Do + delete(Base10, 1, 1); + If FGInt.Sign = negative Then Base10 := '-' + Base10; +End; + + +// Destroy a FGInt to free memory + +Procedure FGIntDestroy(Var FGInt : TFGInt); +Begin + FGInt.Number := Nil; +End; + + +// Compare 2 FGInts in absolute value, returns +// Lt if FGInt1 > FGInt2, St if FGInt1 < FGInt2, Eq if FGInt1 = FGInt2, +// Er otherwise + +Function FGIntCompareAbs(Const FGInt1, FGInt2 : TFGInt) : TCompare; +Var + size1, size2, i : LongWord; +Begin + FGIntCompareAbs := Er; + size1 := FGInt1.Number[0]; + size2 := FGInt2.Number[0]; + If size1 > size2 Then FGIntCompareAbs := Lt Else + If size1 < size2 Then FGIntCompareAbs := St Else + Begin + i := size2; + While (FGInt1.Number[i] = FGInt2.Number[i]) And (i > 1) Do i := i - 1; + If FGInt1.Number[i] = FGInt2.Number[i] Then FGIntCompareAbs := Eq Else + If FGInt1.Number[i] < FGInt2.Number[i] Then FGIntCompareAbs := St Else + If FGInt1.Number[i] > FGInt2.Number[i] Then FGIntCompareAbs := Lt; + End; +End; + + +// Add 2 FGInts, FGInt1 + FGInt2 = Sum + +Procedure FGIntAdd(Const FGInt1, FGInt2 : TFGInt; Var Sum : TFGInt); +Var + i, size1, size2, size, rest, Trest : LongWord; +Begin + size1 := FGInt1.Number[0]; + size2 := FGInt2.Number[0]; + If size1 < size2 Then + FGIntAdd(FGInt2, FGInt1, Sum) + Else + Begin + If FGInt1.Sign = FGInt2.Sign Then + Begin + Sum.Sign := FGInt1.Sign; + setlength(Sum.Number, (size1 + 2)); + rest := 0; + For i := 1 To size2 Do + Begin + Trest := FGInt1.Number[i]; + Trest := Trest + FGInt2.Number[i]; + Trest := Trest + rest; + Sum.Number[i] := Trest And 2147483647; + rest := Trest Shr 31; + End; + For i := (size2 + 1) To size1 Do + Begin + Trest := FGInt1.Number[i] + rest; + Sum.Number[i] := Trest And 2147483647; + rest := Trest Shr 31; + End; + size := size1 + 1; + Sum.Number[0] := size; + Sum.Number[size] := rest; + While (Sum.Number[size] = 0) And (size > 1) Do + size := size - 1; + If Sum.Number[0] <> size Then SetLength(Sum.Number, size + 1); + Sum.Number[0] := size; + End + Else + Begin + If FGIntCompareAbs(FGInt2, FGInt1) = Lt Then + FGIntAdd(FGInt2, FGInt1, Sum) + Else + Begin + SetLength(Sum.Number, (size1 + 1)); + rest := 0; + For i := 1 To size2 Do + Begin + Trest := $80000000; // 2147483648; + TRest := Trest + FGInt1.Number[i]; + TRest := Trest - FGInt2.Number[i]; + TRest := Trest - rest; + Sum.Number[i] := Trest And 2147483647; + If (Trest > 2147483647) Then + rest := 0 + Else + rest := 1; + End; + For i := (size2 + 1) To size1 Do + Begin + Trest := $80000000; + TRest := Trest + FGInt1.Number[i]; + TRest := Trest - rest; + Sum.Number[i] := Trest And 2147483647; + If (Trest > 2147483647) Then + rest := 0 + Else + rest := 1; + End; + size := size1; + While (Sum.Number[size] = 0) And (size > 1) Do + size := size - 1; + If size <> size1 Then SetLength(Sum.Number, size + 1); + Sum.Number[0] := size; + Sum.Sign := FGInt1.Sign; + End; + End; + End; +End; + + + +Procedure FGIntChangeSign(Var FGInt : TFGInt); +Begin + If FGInt.Sign = negative Then FGInt.Sign := positive Else FGInt.Sign := negative; +End; + + +// Substract 2 FGInts, FGInt1 - FGInt2 = dif + +Procedure FGIntSub(Var FGInt1, FGInt2, dif : TFGInt); +Begin + FGIntChangeSign(FGInt2); + FGIntAdd(FGInt1, FGInt2, dif); + FGIntChangeSign(FGInt2); +End; + + +// multiply a FGInt by an integer, FGInt * by = res, by < 2147483648 + +Procedure FGIntMulByInt(Const FGInt : TFGInt; Var res : TFGInt; by : LongWord); +Var + i, size, rest : LongWord; + Trest : int64; +Begin + size := FGInt.Number[0]; + setlength(res.Number, (size + 2)); + rest := 0; + For i := 1 To size Do + Begin + Trest := FGInt.Number[i]; + TRest := Trest * by; + TRest := Trest + rest; + res.Number[i] := Trest And 2147483647; + rest := Trest Shr 31; + End; + If rest <> 0 Then + Begin + size := size + 1; + Res.Number[size] := rest; + End + Else + SetLength(Res.Number, size + 1); + Res.Number[0] := size; + Res.Sign := FGInt.Sign; +End; + + +// multiply a FGInt by an integer, FGInt * by = res, by < 1000000000 + +Procedure FGIntMulByIntbis(Var FGInt : TFGInt; by : LongWord); +Var + i, size, rest : LongWord; + Trest : int64; +Begin + size := FGInt.Number[0]; + Setlength(FGInt.Number, size + 2); + rest := 0; + For i := 1 To size Do + Begin + Trest := FGInt.Number[i]; + TRest := Trest * by; + TRest := Trest + rest; + FGInt.Number[i] := Trest And 2147483647; + rest := Trest Shr 31; + End; + If rest <> 0 Then + Begin + size := size + 1; + FGInt.Number[size] := rest; + End + Else + SetLength(FGInt.Number, size + 1); + FGInt.Number[0] := size; +End; + + +// divide a FGInt by an integer, FGInt = res * by + modres + +Procedure FGIntDivByInt(Const FGInt : TFGInt; Var res : TFGInt; by : LongWord; Var modres : LongWord); +Var + i, size : LongWord; + rest : int64; +Begin + size := FGInt.Number[0]; + setlength(res.Number, (size + 1)); + modres := 0; + For i := size Downto 1 Do + Begin + rest := modres; + rest := rest Shl 31; + rest := rest Or FGInt.Number[i]; + res.Number[i] := rest Div by; + modres := rest Mod by; + End; + While (res.Number[size] = 0) And (size > 1) Do + size := size - 1; + If size <> FGInt.Number[0] Then SetLength(res.Number, size + 1); + res.Number[0] := size; + Res.Sign := FGInt.Sign; + If FGInt.sign = negative Then modres := by - modres; +End; + + +// divide a FGInt by an integer, FGInt = FGInt * by + modres + +Procedure FGIntDivByIntBis(Var FGInt : TFGInt; by : LongWord; Var modres : LongWord); +Var + i, size : LongWord; + temp, rest : int64; +Begin + size := FGInt.Number[0]; + temp := 0; + For i := size Downto 1 Do + Begin + temp := temp Shl 31; + rest := temp Or FGInt.Number[i]; + FGInt.Number[i] := rest Div by; + temp := rest Mod by; + End; + modres := temp; + While (FGInt.Number[size] = 0) And (size > 1) Do + size := size - 1; + If size <> FGInt.Number[0] Then + Begin + SetLength(FGInt.Number, size + 1); + FGInt.Number[0] := size; + End; +End; + + +// Reduce a FGInt modulo by (=an integer), FGInt mod by = modres + +Procedure FGIntModByInt(Const FGInt : TFGInt; by : LongWord; Var modres : LongWord); +Var + i, size : LongWord; + temp, rest : int64; +Begin + size := FGInt.Number[0]; + temp := 0; + For i := size Downto 1 Do + Begin + temp := temp Shl 31; + rest := temp Or FGInt.Number[i]; + temp := rest Mod by; + End; + modres := temp; + If FGInt.sign = negative Then modres := by - modres; +End; + + +// Returns the FGInt in absolute value + +Procedure FGIntAbs(Var FGInt : TFGInt); +Begin + FGInt.Sign := positive; +End; + + +// Copy a FGInt1 into FGInt2 + +Procedure FGIntCopy(Const FGInt1 : TFGInt; Var FGInt2 : TFGInt); +Begin + FGInt2.Sign := FGInt1.Sign; + FGInt2.Number := Nil; + FGInt2.Number := Copy(FGInt1.Number, 0, FGInt1.Number[0] + 1); +End; + + +// Shift the FGInt to the left in base 2 notation, ie FGInt = FGInt * 2 + +Procedure FGIntShiftLeft(Var FGInt : TFGInt); +Var + l, m, i, size : LongWord; +Begin + size := FGInt.Number[0]; + l := 0; + For i := 1 To Size Do + Begin + m := FGInt.Number[i] Shr 30; + FGInt.Number[i] := ((FGInt.Number[i] Shl 1) Or l) And 2147483647; + l := m; + End; + If l <> 0 Then + Begin + setlength(FGInt.Number, size + 2); + FGInt.Number[size + 1] := l; + FGInt.Number[0] := size + 1; + End; +End; + + +// Shift the FGInt to the right in base 2 notation, ie FGInt = FGInt div 2 + +Procedure FGIntShiftRight(Var FGInt : TFGInt); +Var + l, m, i, size : LongWord; +Begin + size := FGInt.Number[0]; + l := 0; + For i := size Downto 1 Do + Begin + m := FGInt.Number[i] And 1; + FGInt.Number[i] := (FGInt.Number[i] Shr 1) Or l; + l := m Shl 30; + End; + If (FGInt.Number[size] = 0) And (size > 1) Then + Begin + setlength(FGInt.Number, size); + FGInt.Number[0] := size - 1; + End; +End; + + +// FGInt = FGInt / 2147483648 + +Procedure FGIntShiftRightBy31(Var FGInt : TFGInt); +Var + size, i : LongWord; +Begin + size := FGInt.Number[0]; + If size > 1 Then + Begin + For i := 1 To size - 1 Do + Begin + FGInt.Number[i] := FGInt.Number[i + 1]; + End; + SetLength(FGInt.Number, Size); + FGInt.Number[0] := size - 1; + End + Else + FGInt.Number[1] := 0; +End; + + +// FGInt1 = FGInt1 + FGInt2, FGInt1 > FGInt2 + +Procedure FGIntAddBis(Var FGInt1 : TFGInt; Const FGInt2 : TFGInt); +Var + i, size1, size2, Trest, rest : LongWord; +Begin + size1 := FGInt1.Number[0]; + size2 := FGInt2.Number[0]; + rest := 0; + For i := 1 To size2 Do + Begin + Trest := FGInt1.Number[i] + FGInt2.Number[i] + rest; + rest := Trest Shr 31; + FGInt1.Number[i] := Trest And 2147483647; + End; + For i := size2 + 1 To size1 Do + Begin + Trest := FGInt1.Number[i] + rest; + rest := Trest Shr 31; + FGInt1.Number[i] := Trest And 2147483647; + End; + If rest <> 0 Then + Begin + SetLength(FGInt1.Number, size1 + 2); + FGInt1.Number[0] := size1 + 1; + FGInt1.Number[size1 + 1] := rest; + End; +End; + + +// FGInt1 = FGInt1 - FGInt2, use only when 0 < FGInt2 < FGInt1 + +Procedure FGIntSubBis(Var FGInt1 : TFGInt; Const FGInt2 : TFGInt); +Var + i, size1, size2, rest, Trest : LongWord; +Begin + size1 := FGInt1.Number[0]; + size2 := FGInt2.Number[0]; + rest := 0; + For i := 1 To size2 Do + Begin + Trest := ($80000000 Or FGInt1.Number[i]) - FGInt2.Number[i] - rest; + If (Trest > 2147483647) Then + rest := 0 + Else + rest := 1; + FGInt1.Number[i] := Trest And 2147483647; + End; + For i := size2 + 1 To size1 Do + Begin + Trest := ($80000000 Or FGInt1.Number[i]) - rest; + If (Trest > 2147483647) Then + rest := 0 + Else + rest := 1; + FGInt1.Number[i] := Trest And 2147483647; + End; + i := size1; + While (FGInt1.Number[i] = 0) And (i > 1) Do + i := i - 1; + If i <> size1 Then + Begin + SetLength(FGInt1.Number, i + 1); + FGInt1.Number[0] := i; + End; +End; + + +// Multiply 2 FGInts, FGInt1 * FGInt2 = Prod + +Procedure FGIntMul(Const FGInt1, FGInt2 : TFGInt; Var Prod : TFGInt); +Var + i, j, size, size1, size2, rest : LongWord; + Trest : int64; +Begin + size1 := FGInt1.Number[0]; + size2 := FGInt2.Number[0]; + size := size1 + size2; + SetLength(Prod.Number, (size + 1)); + For i := 1 To size Do + Prod.Number[i] := 0; + + For i := 1 To size2 Do + Begin + rest := 0; + For j := 1 To size1 Do + Begin + Trest := FGInt1.Number[j]; + Trest := Trest * FGInt2.Number[i]; + Trest := Trest + Prod.Number[j + i - 1]; + Trest := Trest + rest; + Prod.Number[j + i - 1] := Trest And 2147483647; + rest := Trest Shr 31; + End; + Prod.Number[i + size1] := rest; + End; + + Prod.Number[0] := size; + While (Prod.Number[size] = 0) And (size > 1) Do + size := size - 1; + If size <> Prod.Number[0] Then + Begin + SetLength(Prod.Number, size + 1); + Prod.Number[0] := size; + End; + If FGInt1.Sign = FGInt2.Sign Then + Prod.Sign := Positive + Else + prod.Sign := negative; +End; + + +// Square a FGInt, FGInt² = Square + +Procedure FGIntSquare(Const FGInt : TFGInt; Var Square : TFGInt); +Var + size, size1, i, j, rest : LongWord; + Trest : int64; +Begin + size1 := FGInt.Number[0]; + size := 2 * size1; + SetLength(Square.Number, (size + 1)); + Square.Number[0] := size; + For i := 1 To size Do + Square.Number[i] := 0; + For i := 1 To size1 Do + Begin + Trest := FGInt.Number[i]; + Trest := Trest * FGInt.Number[i]; + Trest := Trest + Square.Number[2 * i - 1]; + Square.Number[2 * i - 1] := Trest And 2147483647; + rest := Trest Shr 31; + For j := i + 1 To size1 Do + Begin + Trest := FGInt.Number[i] Shl 1; + Trest := Trest * FGInt.Number[j]; + Trest := Trest + Square.Number[i + j - 1]; + Trest := Trest + rest; + Square.Number[i + j - 1] := Trest And 2147483647; + rest := Trest Shr 31; + End; + Square.Number[i + size1] := rest; + End; + Square.Sign := positive; + While (Square.Number[size] = 0) And (size > 1) Do + size := size - 1; + If size <> (2 * size1) Then + Begin + SetLength(Square.Number, size + 1); + Square.Number[0] := size; + End; +End; + + +// Exponentiate a FGInt, FGInt^exp = res + +Procedure FGIntExp(Const FGInt, exp : TFGInt; Var res : TFGInt); +Var + temp2, temp3 : TFGInt; + S : String; + i : LongWord; +Begin + FGIntToBase2String(exp, S); + If S[length(S)] = '0' Then Base10StringToFGInt('1', res) Else FGIntCopy(FGInt, res); + FGIntCopy(FGInt, temp2); + If length(S) > 1 Then + For i := (length(S) - 1) Downto 1 Do + Begin + FGIntSquare(temp2, temp3); + FGIntCopy(temp3, temp2); + If S[i] = '1' Then + Begin + FGIntMul(res, temp2, temp3); + FGIntCopy(temp3, res); + End; + End; +End; + + +// Compute FGInt! = FGInt * (FGInt - 1) * (FGInt - 2) * ... * 3 * 2 * 1 + +Procedure FGIntFac(Const FGInt : TFGInt; Var res : TFGInt); +Var + one, temp, temp1 : TFGInt; +Begin + FGIntCopy(FGInt, temp); + Base10StringToFGInt('1', res); + Base10StringToFGInt('1', one); + + While Not (FGIntCompareAbs(temp, one) = Eq) Do + Begin + FGIntMul(temp, res, temp1); + FGIntCopy(temp1, res); + FGIntSubBis(temp, one); + End; + + FGIntDestroy(one); + FGIntDestroy(temp); +End; + + +// FGInt = FGInt * 2147483648 + +Procedure FGIntShiftLeftBy31(Var FGInt : TFGInt); +Var + f1, f2 : LongWord; + i, size : longint; +Begin + size := FGInt.Number[0]; + SetLength(FGInt.Number, size + 2); + f1 := 0; + For i := 1 To (size + 1) Do + Begin + f2 := FGInt.Number[i]; + FGInt.Number[i] := f1; + f1 := f2; + End; + FGInt.Number[0] := size + 1; +End; + + +// Divide 2 FGInts, FGInt1 = FGInt2 * QFGInt + MFGInt, MFGInt is always positive + +Procedure FGIntDivMod(Var FGInt1, FGInt2, QFGInt, MFGInt : TFGInt); +Var + one, zero, temp1, temp2 : TFGInt; + s1, s2 : TSign; + j, s, t : LongWord; + i : int64; +Begin + s1 := FGInt1.Sign; + s2 := FGInt2.Sign; + FGIntAbs(FGInt1); + FGIntAbs(FGInt2); + FGIntCopy(FGInt1, MFGInt); + FGIntCopy(FGInt2, temp1); + + If FGIntCompareAbs(FGInt1, FGInt2) <> St Then + Begin + s := FGInt1.Number[0] - FGInt2.Number[0]; + SetLength(QFGInt.Number, (s + 2)); + QFGInt.Number[0] := s + 1; + For t := 1 To s Do + Begin + FGIntShiftLeftBy31(temp1); + QFGInt.Number[t] := 0; + End; + j := s + 1; + QFGInt.Number[j] := 0; + While FGIntCompareAbs(MFGInt, FGInt2) <> St Do + Begin + While FGIntCompareAbs(MFGInt, temp1) <> St Do + Begin + If MFGInt.Number[0] > temp1.Number[0] Then + Begin + i := MFGInt.Number[MFGInt.Number[0]]; + i := i Shl 31; + i := i + MFGInt.Number[MFGInt.Number[0] - 1]; + i := i Div (temp1.Number[temp1.Number[0]] + 1); + End + Else + i := MFGInt.Number[MFGInt.Number[0]] Div (temp1.Number[temp1.Number[0]] + 1); + If (i <> 0) Then + Begin + FGIntCopy(temp1, temp2); + FGIntMulByIntBis(temp2, i); + FGIntSubBis(MFGInt, temp2); + QFGInt.Number[j] := QFGInt.Number[j] + i; + If FGIntCompareAbs(MFGInt, temp2) <> St Then + Begin + QFGInt.Number[j] := QFGInt.Number[j] + i; + FGIntSubBis(MFGInt, temp2); + End; + FGIntDestroy(temp2); + End + Else + Begin + QFGInt.Number[j] := QFGInt.Number[j] + 1; + FGIntSubBis(MFGInt, temp1); + End; + End; + If MFGInt.Number[0] <= temp1.Number[0] Then + If FGIntCompareAbs(temp1, FGInt2) <> Eq Then + Begin + FGIntShiftRightBy31(temp1); + j := j - 1; + End; + End; + End + Else + Base10StringToFGInt('0', QFGInt); + s := QFGInt.Number[0]; + While (s > 1) And (QFGInt.Number[s] = 0) Do + s := s - 1; + If s < QFGInt.Number[0] Then + Begin + setlength(QFGInt.Number, s + 1); + QFGInt.Number[0] := s; + End; + QFGInt.Sign := positive; + + FGIntDestroy(temp1); + Base10StringToFGInt('0', zero); + Base10StringToFGInt('1', one); + If s1 = negative Then + Begin + If FGIntCompareAbs(MFGInt, zero) <> Eq Then + Begin + FGIntadd(QFGInt, one, temp1); + FGIntDestroy(QFGInt); + FGIntCopy(temp1, QFGInt); + FGIntDestroy(temp1); + FGIntsub(FGInt2, MFGInt, temp1); + FGIntDestroy(MFGInt); + FGIntCopy(temp1, MFGInt); + FGIntDestroy(temp1); + End; + If s2 = positive Then QFGInt.Sign := negative; + End + Else + QFGInt.Sign := s2; + FGIntDestroy(one); + FGIntDestroy(zero); + + FGInt1.Sign := s1; + FGInt2.Sign := s2; +End; + + +// Same as above but doesn 't compute MFGInt + +Procedure FGIntDiv(Var FGInt1, FGInt2, QFGInt : TFGInt); +Var + one, zero, temp1, temp2, MFGInt : TFGInt; + s1, s2 : TSign; + j, s, t : LongWord; + i : int64; +Begin + s1 := FGInt1.Sign; + s2 := FGInt2.Sign; + FGIntAbs(FGInt1); + FGIntAbs(FGInt2); + FGIntCopy(FGInt1, MFGInt); + FGIntCopy(FGInt2, temp1); + + If FGIntCompareAbs(FGInt1, FGInt2) <> St Then + Begin + s := FGInt1.Number[0] - FGInt2.Number[0]; + SetLength(QFGInt.Number, (s + 2)); + QFGInt.Number[0] := s + 1; + For t := 1 To s Do + Begin + FGIntShiftLeftBy31(temp1); + QFGInt.Number[t] := 0; + End; + j := s + 1; + QFGInt.Number[j] := 0; + While FGIntCompareAbs(MFGInt, FGInt2) <> St Do + Begin + While FGIntCompareAbs(MFGInt, temp1) <> St Do + Begin + If MFGInt.Number[0] > temp1.Number[0] Then + Begin + i := MFGInt.Number[MFGInt.Number[0]]; + i := i Shl 31; + i := i + MFGInt.Number[MFGInt.Number[0] - 1]; + i := i Div (temp1.Number[temp1.Number[0]] + 1); + End + Else + i := MFGInt.Number[MFGInt.Number[0]] Div (temp1.Number[temp1.Number[0]] + 1); + If (i <> 0) Then + Begin + FGIntCopy(temp1, temp2); + FGIntMulByIntBis(temp2, i); + FGIntSubBis(MFGInt, temp2); + QFGInt.Number[j] := QFGInt.Number[j] + i; + If FGIntCompareAbs(MFGInt, temp2) <> St Then + Begin + QFGInt.Number[j] := QFGInt.Number[j] + i; + FGIntSubBis(MFGInt, temp2); + End; + FGIntDestroy(temp2); + End + Else + Begin + QFGInt.Number[j] := QFGInt.Number[j] + 1; + FGIntSubBis(MFGInt, temp1); + End; + End; + If MFGInt.Number[0] <= temp1.Number[0] Then + If FGIntCompareAbs(temp1, FGInt2) <> Eq Then + Begin + FGIntShiftRightBy31(temp1); + j := j - 1; + End; + End; + End + Else + Base10StringToFGInt('0', QFGInt); + s := QFGInt.Number[0]; + While (s > 1) And (QFGInt.Number[s] = 0) Do + s := s - 1; + If s < QFGInt.Number[0] Then + Begin + setlength(QFGInt.Number, s + 1); + QFGInt.Number[0] := s; + End; + QFGInt.Sign := positive; + + FGIntDestroy(temp1); + Base10StringToFGInt('0', zero); + Base10StringToFGInt('1', one); + If s1 = negative Then + Begin + If FGIntCompareAbs(MFGInt, zero) <> Eq Then + Begin + FGIntadd(QFGInt, one, temp1); + FGIntDestroy(QFGInt); + FGIntCopy(temp1, QFGInt); + FGIntDestroy(temp1); + FGIntsub(FGInt2, MFGInt, temp1); + FGIntDestroy(MFGInt); + FGIntCopy(temp1, MFGInt); + FGIntDestroy(temp1); + End; + If s2 = positive Then QFGInt.Sign := negative; + End + Else + QFGInt.Sign := s2; + FGIntDestroy(one); + FGIntDestroy(zero); + FGIntDestroy(MFGInt); + + FGInt1.Sign := s1; + FGInt2.Sign := s2; +End; + + + +// Same as above but this computes MFGInt in stead of QFGInt +// MFGInt = FGInt1 mod FGInt2 + +Procedure FGIntMod(Var FGInt1, FGInt2, MFGInt : TFGInt); +Var + one, zero, temp1, temp2 : TFGInt; + s1, s2 : TSign; + s, t : LongWord; + i : int64; +Begin + s1 := FGInt1.Sign; + s2 := FGInt2.Sign; + FGIntAbs(FGInt1); + FGIntAbs(FGInt2); + FGIntCopy(FGInt1, MFGInt); + FGIntCopy(FGInt2, temp1); + + If FGIntCompareAbs(FGInt1, FGInt2) <> St Then + Begin + s := FGInt1.Number[0] - FGInt2.Number[0]; + For t := 1 To s Do + FGIntShiftLeftBy31(temp1); + While FGIntCompareAbs(MFGInt, FGInt2) <> St Do + Begin + While FGIntCompareAbs(MFGInt, temp1) <> St Do + Begin + If MFGInt.Number[0] > temp1.Number[0] Then + Begin + i := MFGInt.Number[MFGInt.Number[0]]; + i := i Shl 31; + i := i + MFGInt.Number[MFGInt.Number[0] - 1]; + i := i Div (temp1.Number[temp1.Number[0]] + 1); + End + Else + i := MFGInt.Number[MFGInt.Number[0]] Div (temp1.Number[temp1.Number[0]] + 1); + If (i <> 0) Then + Begin + FGIntCopy(temp1, temp2); + FGIntMulByIntBis(temp2, i); + FGIntSubBis(MFGInt, temp2); + If FGIntCompareAbs(MFGInt, temp2) <> St Then FGIntSubBis(MFGInt, temp2); + FGIntDestroy(temp2); + End + Else + FGIntSubBis(MFGInt, temp1); +// If FGIntCompareAbs(MFGInt, temp1) <> St Then FGIntSubBis(MFGInt,temp1); + End; + If MFGInt.Number[0] <= temp1.Number[0] Then + If FGIntCompareAbs(temp1, FGInt2) <> Eq Then FGIntShiftRightBy31(temp1); + End; + End; + + FGIntDestroy(temp1); + Base10StringToFGInt('0', zero); + Base10StringToFGInt('1', one); + If s1 = negative Then + Begin + If FGIntCompareAbs(MFGInt, zero) <> Eq Then + Begin + FGIntSub(FGInt2, MFGInt, temp1); + FGIntDestroy(MFGInt); + FGIntCopy(temp1, MFGInt); + FGIntDestroy(temp1); + End; + End; + FGIntDestroy(one); + FGIntDestroy(zero); + + FGInt1.Sign := s1; + FGInt2.Sign := s2; +End; + + +// Square a FGInt modulo Modb, FGInt^2 mod Modb = FGIntSM + +Procedure FGIntSquareMod(Var FGInt, Modb, FGIntSM : TFGInt); +Var + temp : TFGInt; +Begin + FGIntSquare(FGInt, temp); + FGIntMod(temp, Modb, FGIntSM); + FGIntDestroy(temp); +End; + + +// Add 2 FGInts modulo base, (FGInt1 + FGInt2) mod base = FGIntres + +Procedure FGIntAddMod(Var FGInt1, FGInt2, base, FGIntres : TFGInt); +Var + temp : TFGInt; +Begin + FGIntadd(FGInt1, FGInt2, temp); + FGIntMod(temp, base, FGIntres); + FGIntDestroy(temp); +End; + + +// Multiply 2 FGInts modulo base, (FGInt1 * FGInt2) mod base = FGIntres + +Procedure FGIntMulMod(Var FGInt1, FGInt2, base, FGIntres : TFGInt); +Var + temp : TFGInt; +Begin + FGIntMul(FGInt1, FGInt2, temp); + FGIntMod(temp, base, FGIntres); + FGIntDestroy(temp); +End; + + +// Exponentiate 2 FGInts modulo base, (FGInt1 ^ FGInt2) mod modb = res + +Procedure FGIntModExp(Var FGInt, exp, modb, res : TFGInt); +Var + temp2, temp3 : TFGInt; + i : LongWord; + S : String; +Begin + If (Modb.Number[1] Mod 2) = 1 Then + Begin + FGIntMontgomeryModExp(FGInt, exp, modb, res); + exit; + End; + FGIntToBase2String(exp, S); + Base10StringToFGInt('1', res); + FGIntcopy(FGInt, temp2); + + For i := length(S) Downto 1 Do + Begin + If S[i] = '1' Then + Begin + FGIntmulMod(res, temp2, modb, temp3); + FGIntCopy(temp3, res); + End; + FGIntSquareMod(temp2, Modb, temp3); + FGIntCopy(temp3, temp2); + End; + FGIntDestroy(temp2); +End; + + +// Procedures for Montgomery Exponentiation + +Procedure FGIntModBis(Const FGInt : TFGInt; Var FGIntOut : TFGInt; b, head : LongWord); +Var + i : LongWord; +Begin + If b <= FGInt.Number[0] Then + Begin + SetLength(FGIntOut.Number, (b + 1)); + For i := 0 To b Do + FGIntOut.Number[i] := FGInt.Number[i]; + FGIntOut.Number[b] := FGIntOut.Number[b] And head; + i := b; + While (FGIntOut.Number[i] = 0) And (i > 1) Do + i := i - 1; + If i < b Then SetLength(FGIntOut.Number, i + 1); + FGIntOut.Number[0] := i; + FGIntOut.Sign := positive; + End + Else + FGIntCopy(FGInt, FGIntOut); +End; + + +Procedure FGIntMulModBis(Const FGInt1, FGInt2 : TFGInt; Var Prod : TFGInt; b, head : LongWord); +Var + i, j, size, size1, size2, t, rest : LongWord; + Trest : int64; +Begin + size1 := FGInt1.Number[0]; + size2 := FGInt2.Number[0]; + size := min(b, size1 + size2); + SetLength(Prod.Number, (size + 1)); + For i := 1 To size Do + Prod.Number[i] := 0; + + For i := 1 To size2 Do + Begin + rest := 0; + t := min(size1, b - i + 1); + For j := 1 To t Do + Begin + Trest := FGInt1.Number[j]; + Trest := Trest * FGInt2.Number[i]; + Trest := Trest + Prod.Number[j + i - 1]; + Trest := Trest + rest; + Prod.Number[j + i - 1] := Trest And 2147483647; + rest := Trest Shr 31; + End; + If (i + size1) <= b Then Prod.Number[i + size1] := rest; + End; + + Prod.Number[0] := size; + If size = b Then Prod.Number[b] := Prod.Number[b] And head; + While (Prod.Number[size] = 0) And (size > 1) Do + size := size - 1; + If size < Prod.Number[0] Then + Begin + SetLength(Prod.Number, size + 1); + Prod.Number[0] := size; + End; + If FGInt1.Sign = FGInt2.Sign Then + Prod.Sign := Positive + Else + prod.Sign := negative; +End; + + +Procedure FGIntMontgomeryMod(Const GInt, base, baseInv : TFGInt; Var MGInt : TFGInt; b : Longword; head : LongWord); +Var + m, temp, temp1 : TFGInt; + r : LongWord; +Begin + FGIntModBis(GInt, temp, b, head); + FGIntMulModBis(temp, baseInv, m, b, head); + FGIntMul(m, base, temp1); + FGIntDestroy(temp); + FGIntAdd(temp1, GInt, temp); + FGIntDestroy(temp1); + MGInt.Number := copy(temp.Number, b - 1, temp.Number[0] - b + 2); + MGInt.Sign := positive; + MGInt.Number[0] := temp.Number[0] - b + 1; + FGIntDestroy(temp); + If (head Shr 30) = 0 Then FGIntDivByIntBis(MGInt, head + 1, r) + Else FGIntShiftRightBy31(MGInt); + If FGIntCompareAbs(MGInt, base) <> St Then FGIntSubBis(MGInt, base); + FGIntDestroy(temp); + FGIntDestroy(m); +End; + + +Procedure FGIntMontgomeryModExp(Var FGInt, exp, modb, res : TFGInt); +Var + temp2, temp3, baseInv, r, zero : TFGInt; + i, j, t, b, head : LongWord; + S : String; +Begin + Base2StringToFGInt('0', zero); + FGIntMod(FGInt, modb, res); + If FGIntCompareAbs(res, zero)=Eq then + Begin + FGIntDestroy(zero); + Exit; + End else FGIntDestroy(res); + FGIntDestroy(zero); + + FGIntToBase2String(exp, S); + t := modb.Number[0]; + b := t; + + If (modb.Number[t] Shr 30) = 1 Then t := t + 1; + SetLength(r.Number, (t + 1)); + r.Number[0] := t; + r.Sign := positive; + For i := 1 To t Do + r.Number[i] := 0; + If t = modb.Number[0] Then + Begin + head := 2147483647; + For j := 29 Downto 0 Do + Begin + head := head Shr 1; + If (modb.Number[t] Shr j) = 1 Then + Begin + r.Number[t] := 1 Shl (j + 1); + break; + End; + End; + End + Else + Begin + r.Number[t] := 1; + head := 2147483647; + End; + + FGIntModInv(modb, r, temp2); + If temp2.Sign = negative Then + FGIntCopy(temp2, BaseInv) + Else + Begin + FGIntCopy(r, BaseInv); + FGIntSubBis(BaseInv, temp2); + End; +// FGIntBezoutBachet(r, modb, temp2, BaseInv); + FGIntAbs(BaseInv); + FGIntDestroy(temp2); + FGIntMod(r, modb, res); + FGIntMulMod(FGInt, res, modb, temp2); + FGIntDestroy(r); + + For i := length(S) Downto 1 Do + Begin + If S[i] = '1' Then + Begin + FGIntmul(res, temp2, temp3); + FGIntDestroy(res); + FGIntMontgomeryMod(temp3, modb, baseinv, res, b, head); + FGIntDestroy(temp3); + End; + FGIntSquare(temp2, temp3); + FGIntDestroy(temp2); + FGIntMontgomeryMod(temp3, modb, baseinv, temp2, b, head); + FGIntDestroy(temp3); + End; + FGIntDestroy(temp2); + FGIntMontgomeryMod(res, modb, baseinv, temp3, b, head); + FGIntCopy(temp3, res); + FGIntDestroy(temp3); + FGIntDestroy(baseinv); +End; + + +// Compute the Greatest Common Divisor of 2 FGInts + +Procedure FGIntGCD(Const FGInt1, FGInt2 : TFGInt; Var GCD : TFGInt); +Var + k : TCompare; + zero, temp1, temp2, temp3 : TFGInt; +Begin + k := FGIntCompareAbs(FGInt1, FGInt2); + If (k = Eq) Then FGIntCopy(FGInt1, GCD) Else + If (k = St) Then FGIntGCD(FGInt2, FGInt1, GCD) Else + Begin + Base10StringToFGInt('0', zero); + FGIntCopy(FGInt1, temp1); + FGIntCopy(FGInt2, temp2); + While (temp2.Number[0] <> 1) Or (temp2.Number[1] <> 0) Do + Begin + FGIntMod(temp1, temp2, temp3); + FGIntCopy(temp2, temp1); + FGIntCopy(temp3, temp2); + FGIntDestroy(temp3); + End; + FGIntCopy(temp1, GCD); + FGIntDestroy(temp2); + FGIntDestroy(zero); + End; +End; + + +// Compute the Least Common Multiple of 2 FGInts + +Procedure FGIntLCM(Const FGInt1, FGInt2 : TFGInt; Var LCM : TFGInt); +Var + temp1, temp2 : TFGInt; +Begin + FGIntGCD(FGInt1, FGInt2, temp1); + FGIntmul(FGInt1, FGInt2, temp2); + FGIntdiv(temp2, temp1, LCM); + FGIntDestroy(temp1); + FGIntDestroy(temp2); +End; + + +// Trialdivision of a FGInt upto 9999 and stopping when a divisor is found, returning ok=false + +Procedure FGIntTrialDiv9999(Const FGInt : TFGInt; Var ok : boolean); +Var + j : LongWord; + i : integer; +Begin + If ((FGInt.Number[1] Mod 2) = 0) Then ok := false + Else + Begin + i := 0; + ok := true; + While ok And (i < 1228) Do + Begin + i := i + 1; + FGIntmodbyint(FGInt, primes[i], j); + If j = 0 Then ok := false; + End; + End; +End; + + +// A prng + +Procedure FGIntRandom1(Var Seed, RandomFGInt : TFGInt); +Var + temp, base : TFGInt; +Begin + Base10StringToFGInt('281474976710656', base); + Base10StringToFGInt('44485709377909', temp); + FGIntMulMod(seed, temp, base, RandomFGInt); + FGIntDestroy(temp); + FGIntDestroy(base); +End; + + +// Perform a Rabin Miller Primality Test nrtest times on FGIntp, returns ok=true when FGIntp passes the test + +Procedure FGIntRabinMiller(Var FGIntp : TFGInt; nrtest : Longword; Var ok : boolean); +Var + j, b, i : LongWord; + m, z, temp1, temp2, temp3, zero, one, two, pmin1 : TFGInt; + ok1, ok2 : boolean; +Begin + randomize; + j := 0; + Base10StringToFGInt('0', zero); + Base10StringToFGInt('1', one); + Base10StringToFGInt('2', two); + FGIntsub(FGIntp, one, temp1); + FGIntsub(FGIntp, one, pmin1); + + b := 0; + While (temp1.Number[1] Mod 2) = 0 Do + Begin + b := b + 1; + FGIntShiftRight(temp1); + End; + m := temp1; + + i := 0; + ok := true; + Randomize; + While (i < nrtest) And ok Do + Begin + i := i + 1; + Base10StringToFGInt(inttostr(Primes[Random(1227) + 1]), temp2); + FGIntMontGomeryModExp(temp2, m, FGIntp, z); + FGIntDestroy(temp2); + ok1 := (FGIntCompareAbs(z, one) = Eq); + ok2 := (FGIntCompareAbs(z, pmin1) = Eq); + If Not (ok1 Or ok2) Then + Begin + + While (ok And (j < b)) Do + Begin + If (j > 0) And ok1 Then ok := false + Else + Begin + j := j + 1; + If (j < b) And (Not ok2) Then + Begin + FGIntSquaremod(z, FGIntp, temp3); + FGIntCopy(temp3, z); + ok1 := (FGIntCompareAbs(z, one) = Eq); + ok2 := (FGIntCompareAbs(z, pmin1) = Eq); + If ok2 Then j := b; + End + Else If (Not ok2) And (j >= b) Then ok := false; + End; + End; + + End + End; + + FGIntDestroy(zero); + FGIntDestroy(one); + FGIntDestroy(two); + FGIntDestroy(m); + FGIntDestroy(z); + FGIntDestroy(pmin1); +End; + + +// Compute the coefficients from the Bezout Bachet theorem, FGInt1 * a + FGInt2 * b = GCD(FGInt1, FGInt2) + +Procedure FGIntBezoutBachet(Var FGInt1, FGInt2, a, b : TFGInt); +Var + zero, r1, r2, r3, ta, gcd, temp, temp1, temp2 : TFGInt; +Begin + If FGIntCompareAbs(FGInt1, FGInt2) <> St Then + Begin + FGIntcopy(FGInt1, r1); + FGIntcopy(FGInt2, r2); + Base10StringToFGInt('0', zero); + Base10StringToFGInt('1', a); + Base10StringToFGInt('0', ta); + + Repeat + FGIntdivmod(r1, r2, temp, r3); + FGIntDestroy(r1); + r1 := r2; + r2 := r3; + + FGIntmul(ta, temp, temp1); + FGIntsub(a, temp1, temp2); + FGIntCopy(ta, a); + FGIntCopy(temp2, ta); + FGIntDestroy(temp1); + + FGIntDestroy(temp); + Until FGIntCompareAbs(r3, zero) = Eq; + + FGIntGCD(FGInt1, FGInt2, gcd); + FGIntmul(a, FGInt1, temp1); + FGIntsub(gcd, temp1, temp2); + FGIntDestroy(temp1); + FGIntdiv(temp2, FGInt2, b); + FGIntDestroy(temp2); + + FGIntDestroy(ta); + FGIntDestroy(r1); + FGIntDestroy(r2); + FGIntDestroy(gcd); + End + Else FGIntBezoutBachet(FGInt2, FGInt1, b, a); +End; + + +// Find the (multiplicative) Modular inverse of a FGInt in a finite ring +// of additive order base + +Procedure FGIntModInv(Const FGInt1, base : TFGInt; Var Inverse : TFGInt); +Var + zero, one, r1, r2, r3, tb, gcd, temp, temp1, temp2 : TFGInt; +Begin + Base10StringToFGInt('1', one); + FGIntGCD(FGInt1, base, gcd); + If FGIntCompareAbs(one, gcd) = Eq Then + Begin + FGIntcopy(base, r1); + FGIntcopy(FGInt1, r2); + Base10StringToFGInt('0', zero); + Base10StringToFGInt('0', inverse); + Base10StringToFGInt('1', tb); + + Repeat + FGIntDestroy(r3); + FGIntdivmod(r1, r2, temp, r3); + FGIntCopy(r2, r1); + FGIntCopy(r3, r2); + + FGIntmul(tb, temp, temp1); + FGIntsub(inverse, temp1, temp2); + FGIntDestroy(inverse); + FGIntDestroy(temp1); + FGIntCopy(tb, inverse); + FGIntCopy(temp2, tb); + + FGIntDestroy(temp); + Until FGIntCompareAbs(r3, zero) = Eq; + + If inverse.Sign = negative Then + Begin + FGIntadd(base, inverse, temp); + FGIntCopy(temp, inverse); + End; + + FGIntDestroy(tb); + FGIntDestroy(r1); + FGIntDestroy(r2); + End; + FGIntDestroy(gcd); + FGIntDestroy(one); +End; + + +// Perform a (combined) primality test on FGIntp consisting of a trialdivision upto 8192, +// if the FGInt passes perform nrRMtests Rabin Miller primality tests, returns ok when a +// FGInt is probably prime + +Procedure FGIntPrimetest(Var FGIntp : TFGInt; nrRMtests : integer; Var ok : boolean); +Begin + FGIntTrialdiv9999(FGIntp, ok); + If ok Then FGIntRabinMiller(FGIntp, nrRMtests, ok); +End; + + +// Computes the Legendre symbol for a any number and +// p a prime, returns 0 if p divides a, 1 if a is a +// quadratic residu mod p, -1 if a is a quadratic +// nonresidu mod p + +Procedure FGIntLegendreSymbol(Var a, p : TFGInt; Var L : integer); +Var + temp1, temp2, temp3, temp4, temp5, zero, one : TFGInt; + i : LongWord; + ok1, ok2 : boolean; +Begin + Base10StringToFGInt('0', zero); + Base10StringToFGInt('1', one); + FGIntMod(a, p, temp1); + If FGIntCompareAbs(zero, temp1) = Eq Then + Begin + FGIntDestroy(temp1); + L := 0; + End + Else + Begin + FGIntDestroy(temp1); + FGIntCopy(p, temp1); + FGIntCopy(a, temp2); + L := 1; + While FGIntCompareAbs(temp2, one) <> Eq Do + Begin + If (temp2.Number[1] Mod 2) = 0 Then + Begin + FGIntSquare(temp1, temp3); + FGIntSub(temp3, one, temp4); + FGIntDestroy(temp3); + FGIntDivByInt(temp4, temp3, 8, i); + If (temp3.Number[1] Mod 2) = 0 Then ok1 := false Else ok1 := true; + FGIntDestroy(temp3); + FGIntDestroy(temp4); + If ok1 = true Then L := L * (-1); + FGIntDivByIntBis(temp2, 2, i); + End + Else + Begin + FGIntSub(temp1, one, temp3); + FGIntSub(temp2, one, temp4); + FGIntMul(temp3, temp4, temp5); + FGIntDestroy(temp3); + FGIntDestroy(temp4); + FGIntDivByInt(temp5, temp3, 4, i); + If (temp3.Number[1] Mod 2) = 0 Then ok2 := false Else ok2 := true; + FGIntDestroy(temp5); + FGIntDestroy(temp3); + If ok2 = true Then L := L * (-1); + FGIntMod(temp1, temp2, temp3); + FGIntCopy(temp2, temp1); + FGIntCopy(temp3, temp2); + End; + End; + FGIntDestroy(temp1); + FGIntDestroy(temp2); + End; + FGIntDestroy(zero); + FGIntDestroy(one); +End; + + +// Compute a square root modulo a prime number +// SquareRoot^2 mod Prime = Square + +Procedure FGIntSquareRootModP(Square, Prime : TFGInt; Var SquareRoot : TFGInt); +Var + one, n, b, s, r, temp, temp1, temp2, temp3 : TFGInt; + a, i, j : longint; + L : Integer; +Begin + Base2StringToFGInt('1', one); + Base2StringToFGInt('10', n); + a := 0; + FGIntLegendreSymbol(n, Prime, L); + While L <> -1 Do + Begin + FGIntAddBis(n, one); + FGIntLegendreSymbol(n, Prime, L); + End; + FGIntCopy(Prime, s); + s.Number[1] := s.Number[1] - 1; + While (s.Number[1] Mod 2) = 0 Do + Begin + FGIntShiftRight(s); + a := a + 1; + End; + FGIntMontgomeryModExp(n, s, Prime, b); + FGIntAdd(s, one, temp); + FGIntShiftRight(temp); + FGIntMontgomeryModExp(Square, temp, Prime, r); + FGIntDestroy(temp); + FGIntModInv(Square, Prime, temp1); + + For i := 0 To (a - 2) Do + Begin + FGIntSquareMod(r, Prime, temp2); + FGIntMulMod(temp1, temp2, Prime, temp); + FGIntDestroy(temp2); + For j := 1 To (a - i - 2) Do + Begin + FGIntSquareMod(temp, Prime, temp2); + FGIntDestroy(temp); + FGIntCopy(temp2, temp); + FGIntDestroy(temp2); + End; + If FGIntCompareAbs(temp, one) <> Eq Then + Begin + FGIntMulMod(r, b, Prime, temp3); + FGIntDestroy(r); + FGIntCopy(temp3, r); + FGIntDestroy(temp3); + End; + FGIntDestroy(temp); + FGIntDestroy(temp2); + If i = (a - 2) Then break; + FGIntSquareMod(b, Prime, temp3); + FGIntDestroy(b); + FGIntCopy(temp3, b); + FGIntDestroy(temp3); + End; + + FGIntCopy(r, SquareRoot); + FGIntDestroy(r); + FGIntDestroy(s); + FGIntDestroy(b); + FGIntDestroy(temp1); + FGIntDestroy(one); + FGIntDestroy(n); +End; + + +End. diff --git a/lib/base/devel/bignums.nim b/lib/base/devel/bignums.nim new file mode 100644 index 000000000..1d2b3685d --- /dev/null +++ b/lib/base/devel/bignums.nim @@ -0,0 +1,1712 @@ +# +# +# Nimrod's Runtime Library +# (c) Copyright 2008 Andreas Rumpf +# +# See the file "copying.txt", included in this +# distribution, for details about the copyright. +# + +## This module implements big integers for Nimrod. +## This module is an adaptation of the FGInt module for Pascal by Walied +## Othman: http://triade.studentenweb.org + + +# License, info, etc +# ------------------ +# +# This implementation is made by me, Walied Othman, to contact me +# mail to Walied.Othman@belgacom.net or Triade@ulyssis.org, +# always mention wether it 's about the FGInt for Delphi or for +# FreePascal, or wether it 's about the 6xs, preferably in the subject line. +# If you 're going to use these implementations, at least mention my +# name or something and notify me so I may even put a link on my page. +# This implementation is freeware and according to the coderpunks' +# manifesto it should remain so, so don 't use these implementations +# in commercial software. Encryption, as a tool to ensure privacy +# should be free and accessible for anyone. If you plan to use these +# implementations in a commercial application, contact me before +# doing so, that way you can license the software to use it in commercial +# Software. If any algorithm is patented in your country, you should +# acquire a license before using this software. Modified versions of this +# software must contain an acknowledgement of the original author (=me). +# This implementation is available at +# http://triade.studentenweb.org +# +# copyright 2000, Walied Othman +# This header may not be removed. +# + +type + TBigInt* {.final.} = object ## type that represent an arbitrary long + ## signed integer + s: int # sign: -1 or 1 + n: seq[int] # the number part + +proc len(x: TBigInt): int {.inline.} = return x.n.len + +proc CompareAbs(a, b: TBigInt): int = + result = a.len - b.len + if result == 0: + var i = b.len-1 + while (i > 0) and a.n[i] == b.n[i]: dec(i) + result = a.n[i] - b.n[i] + +const + bitMask = high(int) + bitshift = sizeof(int)*8 - 1 + +proc cutZeros(a: var TBigInt) = + var L = a.len + while a.len > 0 and a[L-1] == 0: dec(L) + setLen(a.n, L) + +proc addAux(a, b: TBigInt, bSign: int): TBigInt + if a.len < b.len: + result = addAux(b, a, bSign) + elif a.s == bSign: + result.s = a.s + result.n = [] + setlen(result.n, a.len+1) + var rest = 0 + for i in 0..b.len-1: + var trest = a.n[i] + trest = trest +% b.n[i] +% rest + result.n[i] = trest and bitMask + rest = trest shr bitshift + for i in b.len .. a.len-1: + var trest = a.n[i] +% rest + result.n[i] = trest and bitMask + rest = trest shr bitshift + result.n[a.len] = rest + cutZeros(result) + elif compareAbs(a, b) > 0: + result = addAux(b, a, bSign) + else: + setlen(result.n, a.len+1) + result.s = a.s + var rest = 0 + for i in 0..b.len-1: + var Trest = low(int) + TRest = Trest +% a.n[i] -% b.n[i] -% rest + result.n[i] = Trest and bitmask + if Trest >% bitMask: rest = 0 else: rest = 1 + for i in b.len .. a.len-1: + var Trest = low(int) + TRest = Trest +% a.n[i] -% rest + result.n[i] = Trest and bitmask + if (Trest >% bitmask): rest = 0 else: rest = 1 + cutZeros(result) + +proc `+` *(a, b: TBigInt): TBigInt = + ## the `+` operator for bigints + result = addAux(a, b, +1) + +proc `-` *(a, b: TBigInt): TBigInt = + ## the `-` operator for bigints + result = addAux(a, b, -1) + +proc mulInPlace(a: var TBigInt, b: int) = + var + size, rest: int32 + Trest: int64 + size = FGInt.Number[0] + setlen(FGInt.Number, size + 2) + rest = 0 + for i in countup(1, size): + Trest = FGInt.Number[i] + TRest = Trest * by + TRest = Trest + rest + FGInt.Number[i] = Trest And 2147483647 + rest = Trest Shr 31 + if rest != 0: + size = size + 1 + FGInt.Number[size] = rest + else: + setlen(FGInt.Number, size + 1) + FGInt.Number[0] = size + + +import + SysUtils, Math + +type + TCompare* = enum + Lt, St, Eq, Er + TSign = enum + negative, positive + TBigInt* {.final.} = object + Sign: TSign + Number: seq[int32] + + +proc zeronetochar8*(g: var char, x: String) +proc zeronetochar6*(g: var int, x: String) +proc initialize8*(trans: var openarray[String]) +proc initialize6*(trans: var openarray[String]) +proc initialize6PGP*(trans: var openarray[String]) +proc ConvertBase256to64*(str256: String, str64: var String) +proc ConvertBase64to256*(str64: String, str256: var String) +proc ConvertBase256to2*(str256: String, str2: var String) +proc ConvertBase64to2*(str64: String, str2: var String) +proc ConvertBase2to256*(str2: String, str256: var String) +proc ConvertBase2to64*(str2: String, str64: var String) +proc ConvertBase256StringToHexString*(Str256: String, HexStr: var String) +proc ConvertHexStringToBase256String*(HexStr: String, Str256: var String) +proc PGPConvertBase256to64*(str256, str64: var String) +proc PGPConvertBase64to256*(str64: String, str256: var String) +proc PGPConvertBase64to2*(str64: String, str2: var String) +proc FGIntToBase2String*(FGInt: TBigInt, S: var String) +proc Base2StringToFGInt*(S: String, FGInt: var TBigInt) +proc FGIntToBase256String*(FGInt: TBigInt, str256: var String) +proc Base256StringToFGInt*(str256: String, FGInt: var TBigInt) +proc PGPMPIToFGInt*(PGPMPI: String, FGInt: var TBigInt) +proc FGIntToPGPMPI*(FGInt: TBigInt, PGPMPI: var String) +proc Base10StringToFGInt*(Base10: String, FGInt: var TBigInt) +proc FGIntToBase10String*(FGInt: TBigInt, Base10: var String) +proc FGIntDestroy*(FGInt: var TBigInt) +proc FGIntCompareAbs*(FGInt1, FGInt2: TBigInt): TCompare +proc FGIntAdd*(FGInt1, FGInt2: TBigInt, Sum: var TBigInt) +proc FGIntChangeSign*(FGInt: var TBigInt) +proc FGIntSub*(FGInt1, FGInt2, dif: var TBigInt) +proc FGIntMulByInt*(FGInt: TBigInt, res: var TBigInt, by: int32) +proc FGIntMulByIntbis*(FGInt: var TBigInt, by: int32) +proc FGIntDivByInt*(FGInt: TBigInt, res: var TBigInt, by: int32, modres: var int32) +proc FGIntDivByIntBis*(FGInt: var TBigInt, by: int32, modres: var int32) +proc FGIntModByInt*(FGInt: TBigInt, by: int32, modres: var int32) +proc FGIntAbs*(FGInt: var TBigInt) +proc FGIntCopy*(FGInt1: TBigInt, FGInt2: var TBigInt) +proc FGIntShiftLeft*(FGInt: var TBigInt) +proc FGIntShiftRight*(FGInt: var TBigInt) +proc FGIntShiftRightBy31*(FGInt: var TBigInt) +proc FGIntAddBis*(FGInt1: var TBigInt, FGInt2: TBigInt) +proc FGIntSubBis*(FGInt1: var TBigInt, FGInt2: TBigInt) +proc FGIntMul*(FGInt1, FGInt2: TBigInt, Prod: var TBigInt) +proc FGIntSquare*(FGInt: TBigInt, Square: var TBigInt) +proc FGIntExp*(FGInt, exp: TBigInt, res: var TBigInt) +proc FGIntFac*(FGInt: TBigInt, res: var TBigInt) +proc FGIntShiftLeftBy31*(FGInt: var TBigInt) +proc FGIntDivMod*(FGInt1, FGInt2, QFGInt, MFGInt: var TBigInt) +proc FGIntDiv*(FGInt1, FGInt2, QFGInt: var TBigInt) +proc FGIntMod*(FGInt1, FGInt2, MFGInt: var TBigInt) +proc FGIntSquareMod*(FGInt, Modb, FGIntSM: var TBigInt) +proc FGIntAddMod*(FGInt1, FGInt2, base, FGIntres: var TBigInt) +proc FGIntMulMod*(FGInt1, FGInt2, base, FGIntres: var TBigInt) +proc FGIntModExp*(FGInt, exp, modb, res: var TBigInt) +proc FGIntModBis*(FGInt: TBigInt, FGIntOut: var TBigInt, b, head: int32) +proc FGIntMulModBis*(FGInt1, FGInt2: TBigInt, Prod: var TBigInt, b, head: int32) +proc FGIntMontgomeryMod*(GInt, base, baseInv: TBigInt, MGInt: var TBigInt, + b: int32, head: int32) +proc FGIntMontgomeryModExp*(FGInt, exp, modb, res: var TBigInt) +proc FGIntGCD*(FGInt1, FGInt2: TBigInt, GCD: var TBigInt) +proc FGIntLCM*(FGInt1, FGInt2: TBigInt, LCM: var TBigInt) +proc FGIntTrialDiv9999*(FGInt: TBigInt, ok: var bool) +proc FGIntRandom1*(Seed, RandomFGInt: var TBigInt) +proc FGIntRabinMiller*(FGIntp: var TBigInt, nrtest: int32, ok: var bool) +proc FGIntBezoutBachet*(FGInt1, FGInt2, a, b: var TBigInt) +proc FGIntModInv*(FGInt1, base: TBigInt, Inverse: var TBigInt) +proc FGIntPrimetest*(FGIntp: var TBigInt, nrRMtests: int, ok: var bool) +proc FGIntLegendreSymbol*(a, p: var TBigInt, L: var int) +proc FGIntSquareRootModP*(Square, Prime: TBigInt, SquareRoot: var TBigInt) +# implementation + +var + primes: array[1..1228, int] = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, + 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, + 101, 103, 107, 109, 113, 127, 131, 137, 139, + 149, 151, 157, 163, 167, 173, 179, 181, 191, + 193, 197, 199, 211, 223, 227, 229, 233, 239, + 241, 251, 257, 263, 269, 271, 277, 281, 283, + 293, 307, 311, 313, 317, 331, 337, 347, 349, + 353, 359, 367, 373, 379, 383, 389, 397, 401, + 409, 419, 421, 431, 433, 439, 443, 449, 457, + 461, 463, 467, 479, 487, 491, 499, 503, 509, + 521, 523, 541, 547, 557, 563, 569, 571, 577, + 587, 593, 599, 601, 607, 613, 617, 619, 631, + 641, 643, 647, 653, 659, 661, 673, 677, 683, + 691, 701, 709, 719, 727, 733, 739, 743, 751, + 757, 761, 769, 773, 787, 797, 809, 811, 821, + 823, 827, 829, 839, 853, 857, 859, 863, 877, + 881, 883, 887, 907, 911, 919, 929, 937, 941, + 947, 953, 967, 971, 977, 983, 991, 997, 1009, + 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, + 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, + 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, + 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, + 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, + 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, + 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, + 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, + 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, + 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, + 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, + 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, + 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, + 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, + 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, + 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, + 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, + 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, + 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, + 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, + 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, + 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, + 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, + 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, + 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, + 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, + 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, + 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, + 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, + 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, + 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, + 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, + 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, + 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, + 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, + 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, + 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, + 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, + 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, + 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, + 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, + 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, + 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, + 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, + 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, + 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, + 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, + 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, + 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, + 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, + 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, + 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, + 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, + 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, + 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, + 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, + 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, + 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, + 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, + 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, + 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, + 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, + 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, + 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, + 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, + 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, + 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, + 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, + 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, + 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, + 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, + 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, + 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, + 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, + 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, + 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, + 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, + 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, + 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, + 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, + 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, + 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, + 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, + 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, + 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, + 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, + 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, + 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, + 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, + 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, + 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, + 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, + 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, + 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, + 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, + 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, + 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, + 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, + 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, + 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, + 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, + 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, + 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, + 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, + 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, + 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, + 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, + 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, + 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, + 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, + 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, + 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, + 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, + 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, + 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, + 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, + 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, + 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, + 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, + 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, + 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, + 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, + 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, + 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, + 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, + 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, + 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, + 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, + 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, + 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, + 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, + 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, + 9941, 9949, 9967, 9973] + chr64: array[1..64, char] = ['a', 'A', 'b', 'B', 'c', 'C', 'd', 'D', 'e', 'E', + 'f', 'F', 'g', 'G', 'h', 'H', 'i', 'I', 'j', 'J', + 'k', 'K', 'l', 'L', 'm', 'M', 'n', 'N', 'o', 'O', + 'p', 'P', 'q', 'Q', 'r', 'R', 's', 'S', 't', 'T', + 'u', 'U', 'v', 'V', 'w', 'W', 'x', 'X', 'y', 'Y', + 'z', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', '+', '='] + PGPchr64: array[1..64, char] = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', + 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', + 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', + 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', + 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', + 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', + '2', '3', '4', '5', '6', '7', '8', '9', '+', + '/'] + +proc zeronetochar8(g: var char, x: String) = + var b: int8 + b = 0 + for i in countup(1, 8): + if copy(x, i, 1) == '1': b = b Or (1 Shl (8 - I)) + g = chr(b) + +proc zeronetochar6(g: var int, x: String) = + G = 0 + for I in countup(1, len(X)): + if I > 6: break + if X[I] != '0': G = G Or (1 Shl (6 - I)) + Inc(G) + +proc initialize8(trans: var openarray[String]) = + var + x: String + g: char + for c1 in countup(0, 1): + for c2 in countup(0, 1): + for c3 in countup(0, 1): + for c4 in countup(0, 1): + for c5 in countup(0, 1): + for c6 in countup(0, 1): + for c7 in countup(0, 1): + for c8 in countup(0, 1): + x = chr(48 + c1) + chr(48 + c2) + chr(48 + c3) + chr(48 + c4) + + chr(48 + c5) + chr(48 + c6) + chr(48 + c7) + chr(48 + c8) + zeronetochar8(g, x) + trans[ord(g)] = x + +proc initialize6(trans: var openarray[String]) = + var + x: String + g: int + for c1 in countup(0, 1): + for c2 in countup(0, 1): + for c3 in countup(0, 1): + for c4 in countup(0, 1): + for c5 in countup(0, 1): + for c6 in countup(0, 1): + x = chr(48 + c1) + chr(48 + c2) + chr(48 + c3) + chr(48 + c4) + + chr(48 + c5) + chr(48 + c6) + zeronetochar6(g, x) + trans[ord(chr64[g])] = x + +proc initialize6PGP(trans: var openarray[String]) = + var + x: String + g: int + for c1 in countup(0, 1): + for c2 in countup(0, 1): + for c3 in countup(0, 1): + for c4 in countup(0, 1): + for c5 in countup(0, 1): + for c6 in countup(0, 1): + x = chr(48 + c1) + chr(48 + c2) + chr(48 + c3) + chr(48 + c4) + + chr(48 + c5) + chr(48 + c6) + zeronetochar6(g, x) + trans[ord(PGPchr64[g])] = x + +proc ConvertBase256to64(str256: String, str64: var String) = + var + temp: String + trans: array[0..255, String] + len6: int32 + g: int + initialize8(trans) + temp = "" + for i in countup(1, len(str256)): temp = temp + trans[ord(str256[i])] + while (len(temp) Mod 6) != 0: temp = temp & '0' + len6 = len(temp) Div 6 + str64 = "" + for i in countup(1, len6): + zeronetochar6(g, copy(temp, 1, 6)) + str64 = str64 + chr64[g] + delete(temp, 1, 6) + +proc ConvertBase64to256(str64: String, str256: var String) = + var + temp: String + trans: array[0..255, String] + len8: int32 + g: char + initialize6(trans) + temp = "" + for i in countup(1, len(str64)): temp = temp + trans[ord(str64[i])] + str256 = "" + len8 = len(temp) Div 8 + for i in countup(1, len8): + zeronetochar8(g, copy(temp, 1, 8)) + str256 = str256 + g + delete(temp, 1, 8) + +proc ConvertBase256to2(str256: String, str2: var String) = + var trans: array[0..255, String] + str2 = "" + initialize8(trans) + for i in countup(1, len(str256)): str2 = str2 + trans[ord(str256[i])] + +proc ConvertBase64to2(str64: String, str2: var String) = + var trans: array[0..255, String] + str2 = "" + initialize6(trans) + for i in countup(1, len(str64)): str2 = str2 + trans[ord(str64[i])] + +proc ConvertBase2to256(str2: String, str256: var String) = + var + len8: int32 + g: char + str256 = "" + while (len(str2) Mod 8) != 0: str2 = '0' & str2 + len8 = len(str2) Div 8 + for i in countup(1, len8): + zeronetochar8(g, copy(str2, 1, 8)) + str256 = str256 + g + delete(str2, 1, 8) + +proc ConvertBase2to64(str2: String, str64: var String) = + var + len6: int32 + g: int + str64 = "" + while (len(str2) Mod 6) != 0: str2 = '0' & str2 + len6 = len(str2) Div 6 + for i in countup(1, len6): + zeronetochar6(g, copy(str2, 1, 6)) + str64 = str64 + chr64[g] + delete(str2, 1, 6) + +proc ConvertBase256StringToHexString(Str256: String, HexStr: var String) = + var b: int8 + HexStr = "" + for i in countup(1, len(str256)): + b = ord(str256[i]) + if (b Shr 4) < 10: HexStr = HexStr + chr(48 + (b Shr 4)) + else: HexStr = HexStr + chr(55 + (b Shr 4)) + if (b And 15) < 10: HexStr = HexStr + chr(48 + (b And 15)) + else: HexStr = HexStr + chr(55 + (b And 15)) + +proc ConvertHexStringToBase256String(HexStr: String, Str256: var String) = + var + b, h1, h2: int8 + temp: string + Str256 = "" + if (len(Hexstr) mod 2) == 1: temp = '0' & HexStr + else: temp = HexStr + for i in countup(1, (len(temp) Div 2)): + h2 = ord(temp[2 * i]) + h1 = ord(temp[2 * i - 1]) + if h1 < 58: b = ((h1 - 48) Shl 4) + else: b = ((h1 - 55) Shl 4) + if h2 < 58: b = (b Or (h2 - 48)) + else: b = (b Or ((h2 - 55) and 15)) + Str256 = Str256 + chr(b) + +proc PGPConvertBase256to64(str256, str64: var String) = + var + temp, x, a: String + len6: int32 + g: int + trans: array[0..255, String] + initialize8(trans) + temp = "" + for i in countup(1, len(str256)): temp = temp + trans[ord(str256[i])] + if (len(temp) Mod 6) == 0: + a = "" + elif (len(temp) Mod 6) == 4: + temp = temp & "00" + a = '=' + else: + temp = temp & "0000" + a = "==" + str64 = "" + len6 = len(temp) Div 6 + for i in countup(1, len6): + x = copy(temp, 1, 6) + zeronetochar6(g, x) + str64 = str64 + PGPchr64[g] + delete(temp, 1, 6) + str64 = str64 + a + +proc PGPConvertBase64to256(str64: String, str256: var String) = + var + temp, x: String + j, len8: int32 + g: char + trans: array[0..255, String] + initialize6PGP(trans) + temp = "" + str256 = "" + if str64[len(str64) - 1] == '=': j = 2 + elif str64[len(str64)] == '=': j = 1 + else: j = 0 + for i in countup(1, (len(str64) - j)): temp = temp + trans[ord(str64[i])] + if j != 0: delete(temp, len(temp) - 2 * j + 1, 2 * j) + len8 = len(temp) Div 8 + for i in countup(1, len8): + x = copy(temp, 1, 8) + zeronetochar8(g, x) + str256 = str256 + g + delete(temp, 1, 8) + +proc PGPConvertBase64to2(str64: String, str2: var String) = + var + j: int32 + trans: array[0..255, String] + str2 = "" + initialize6(trans) + if str64[len(str64) - 1] == '=': j = 2 + elif str64[len(str64)] == '=': j = 1 + else: j = 0 + for i in countup(1, (len(str64) - j)): str2 = str2 + trans[ord(str64[i])] + delete(str2, len(str2) - 2 * j + 1, 2 * j) + +proc FGIntToBase2String(FGInt: TBigInt, S: var String) = + S = "" + for i in countup(1, FGInt.Number[0]): + for j in countup(0, 30): + if (1 And (FGInt.Number[i] Shr j)) == 1: S = '1' & S + else: S = '0' & S + while (len(S) > 1) And (S[1] == '0'): delete(S, 1, 1) + if S == "": S = '0' + +proc Base2StringToFGInt(S: String, FGInt: var TBigInt) = + var i, j, size: int32 + while (S[1] == '0') And (len(S) > 1): delete(S, 1, 1) + size = len(S) Div 31 + if (len(S) Mod 31) != 0: size = size + 1 + setlen(FGInt.Number, (size + 1)) + FGInt.Number[0] = size + j = 1 + FGInt.Number[j] = 0 + i = 0 + while len(S) > 0: + if S[len(S)] == '1': FGInt.Number[j] = FGInt.Number[j] Or (1 Shl i) + i = i + 1 + if i == 31: + i = 0 + j = j + 1 + if j <= size: FGInt.Number[j] = 0 + delete(S, len(S), 1) + FGInt.Sign = positive + +proc FGIntToBase256String(FGInt: TBigInt, str256: var String) = + var + temp1: String + len8: int32 + g: char + FGIntToBase2String(FGInt, temp1) + while (len(temp1) Mod 8) != 0: temp1 = '0' & temp1 + len8 = len(temp1) Div 8 + str256 = "" + for i in countup(1, len8): + zeronetochar8(g, copy(temp1, 1, 8)) + str256 = str256 + g + delete(temp1, 1, 8) + +proc Base256StringToFGInt(str256: String, FGInt: var TBigInt) = + var + temp1: String + trans: array[0..255, String] + temp1 = "" + initialize8(trans) + for i in countup(1, len(str256)): temp1 = temp1 + trans[ord(str256[i])] + while (temp1[1] == '0') And (temp1 != '0'): delete(temp1, 1, 1) + Base2StringToFGInt(temp1, FGInt) + +proc PGPMPIToFGInt(PGPMPI: String, FGInt: var TBigInt) = + var temp: String + temp = PGPMPI + delete(temp, 1, 2) + Base256StringToFGInt(temp, FGInt) + +proc FGIntToPGPMPI(FGInt: TBigInt, PGPMPI: var String) = + var + length: int16 + c: char + b: int8 + FGIntToBase256String(FGInt, PGPMPI) + length = len(PGPMPI) * 8 + c = PGPMPI[1] + for i in countdown(7, 0): + if (ord(c) Shr i) == 0: length = length - 1 + else: break + b = length Mod 256 + PGPMPI = chr(b) + PGPMPI + b = length Div 256 + PGPMPI = chr(b) + PGPMPI + +proc GIntDivByIntBis1(GInt: var TBigInt, by: int32, modres: var int16) = + var size, rest, temp: int32 + size = GInt.Number[0] + temp = 0 + for i in countdown(size, 1): + temp = temp * 10000 + rest = temp + GInt.Number[i] + GInt.Number[i] = rest Div by + temp = rest Mod by + modres = temp + while (GInt.Number[size] == 0) And (size > 1): size = size - 1 + if size != GInt.Number[0]: + setlen(GInt.Number, size + 1) + GInt.Number[0] = size + +proc Base10StringToFGInt(Base10: String, FGInt: var TBigInt) = + var + size: int32 + j: int16 + S, x: String + sign: TSign + while (Not (Base10[1] In {'-', '0'..'9'})) And (len(Base10) > 1): + delete(Base10, 1, 1) + if copy(Base10, 1, 1) == '-': + Sign = negative + delete(Base10, 1, 1) + else: + Sign = positive + while (len(Base10) > 1) And (copy(Base10, 1, 1) == '0'): delete(Base10, 1, 1) + size = len(Base10) Div 4 + if (len(Base10) Mod 4) != 0: size = size + 1 + setlen(FGInt.Number, size + 1) + FGInt.Number[0] = size + for i in countup(1, (size - 1)): + x = copy(Base10, len(Base10) - 3, 4) + FGInt.Number[i] = StrToInt(x) + delete(Base10, len(Base10) - 3, 4) + FGInt.Number[size] = StrToInt(Base10) + S = "" + while (FGInt.Number[0] != 1) Or (FGInt.Number[1] != 0): + GIntDivByIntBis1(FGInt, 2, j) + S = inttostr(j) + S + if S == "": S = '0' + FGIntDestroy(FGInt) + Base2StringToFGInt(S, FGInt) + FGInt.Sign = sign + +proc FGIntToBase10String(FGInt: TBigInt, Base10: var String) = + var + S: String + j: int32 + temp: TBigInt + FGIntCopy(FGInt, temp) + Base10 = "" + while (temp.Number[0] > 1) Or (temp.Number[1] > 0): + FGIntDivByIntBis(temp, 10000, j) + S = IntToStr(j) + while len(S) < 4: S = '0' & S + Base10 = S + Base10 + Base10 = '0' & Base10 + while (len(Base10) > 1) And (Base10[1] == '0'): delete(Base10, 1, 1) + if FGInt.Sign == negative: Base10 = '-' & Base10 + +proc FGIntDestroy(FGInt: var TBigInt) = + FGInt.Number = nil + +proc FGIntCompareAbs(FGInt1, FGInt2: TBigInt): TCompare = + var size1, size2, i: int32 + FGIntCompareAbs = Er + size1 = FGInt1.Number[0] + size2 = FGInt2.Number[0] + if size1 > size2: + FGIntCompareAbs = Lt + elif size1 < size2: + FGIntCompareAbs = St + else: + i = size2 + while (FGInt1.Number[i] == FGInt2.Number[i]) And (i > 1): i = i - 1 + if FGInt1.Number[i] == FGInt2.Number[i]: FGIntCompareAbs = Eq + elif FGInt1.Number[i] < FGInt2.Number[i]: FGIntCompareAbs = St + elif FGInt1.Number[i] > FGInt2.Number[i]: FGIntCompareAbs = Lt + +proc FGIntAdd(FGInt1, FGInt2: TBigInt, Sum: var TBigInt) = + var size1, size2, size, rest, Trest: int32 + size1 = FGInt1.Number[0] + size2 = FGInt2.Number[0] + if size1 < size2: + FGIntAdd(FGInt2, FGInt1, Sum) + else: + if FGInt1.Sign == FGInt2.Sign: + Sum.Sign = FGInt1.Sign + setlen(Sum.Number, (size1 + 2)) + rest = 0 + for i in countup(1, size2): + Trest = FGInt1.Number[i] + Trest = Trest + FGInt2.Number[i] + Trest = Trest + rest + Sum.Number[i] = Trest And 2147483647 + rest = Trest Shr 31 + for i in countup((size2 + 1), size1): + Trest = FGInt1.Number[i] + rest + Sum.Number[i] = Trest And 2147483647 + rest = Trest Shr 31 + size = size1 + 1 + Sum.Number[0] = size + Sum.Number[size] = rest + while (Sum.Number[size] == 0) And (size > 1): size = size - 1 + if Sum.Number[0] != size: setlen(Sum.Number, size + 1) + Sum.Number[0] = size + else: + if FGIntCompareAbs(FGInt2, FGInt1) == Lt: + FGIntAdd(FGInt2, FGInt1, Sum) + else: + setlen(Sum.Number, (size1 + 1)) + rest = 0 + for i in countup(1, size2): + Trest = 0x80000000 # 2147483648; + TRest = Trest + FGInt1.Number[i] + TRest = Trest - FGInt2.Number[i] + TRest = Trest - rest + Sum.Number[i] = Trest And 2147483647 + if (Trest > 2147483647): rest = 0 + else: rest = 1 + for i in countup((size2 + 1), size1): + Trest = 0x80000000 + TRest = Trest + FGInt1.Number[i] + TRest = Trest - rest + Sum.Number[i] = Trest And 2147483647 + if (Trest > 2147483647): rest = 0 + else: rest = 1 + size = size1 + while (Sum.Number[size] == 0) And (size > 1): size = size - 1 + if size != size1: setlen(Sum.Number, size + 1) + Sum.Number[0] = size + Sum.Sign = FGInt1.Sign + +proc FGIntChangeSign(FGInt: var TBigInt) = + if FGInt.Sign == negative: FGInt.Sign = positive + else: FGInt.Sign = negative + +proc FGIntSub(FGInt1, FGInt2, dif: var TBigInt) = + FGIntChangeSign(FGInt2) + FGIntAdd(FGInt1, FGInt2, dif) + FGIntChangeSign(FGInt2) + +proc FGIntMulByInt(FGInt: TBigInt, res: var TBigInt, by: int32) = + var + size, rest: int32 + Trest: int64 + size = FGInt.Number[0] + setlen(res.Number, (size + 2)) + rest = 0 + for i in countup(1, size): + Trest = FGInt.Number[i] + TRest = Trest * by + TRest = Trest + rest + res.Number[i] = Trest And 2147483647 + rest = Trest Shr 31 + if rest != 0: + size = size + 1 + Res.Number[size] = rest + else: + setlen(Res.Number, size + 1) + Res.Number[0] = size + Res.Sign = FGInt.Sign + +proc FGIntMulByIntbis(FGInt: var TBigInt, by: int32) = + var + size, rest: int32 + Trest: int64 + size = FGInt.Number[0] + setlen(FGInt.Number, size + 2) + rest = 0 + for i in countup(1, size): + Trest = FGInt.Number[i] + TRest = Trest * by + TRest = Trest + rest + FGInt.Number[i] = Trest And 2147483647 + rest = Trest Shr 31 + if rest != 0: + size = size + 1 + FGInt.Number[size] = rest + else: + setlen(FGInt.Number, size + 1) + FGInt.Number[0] = size + +proc FGIntDivByInt(FGInt: TBigInt, res: var TBigInt, by: int32, modres: var int32) = + var + size: int32 + rest: int64 + size = FGInt.Number[0] + setlen(res.Number, (size + 1)) + modres = 0 + for i in countdown(size, 1): + rest = modres + rest = rest Shl 31 + rest = rest Or FGInt.Number[i] + res.Number[i] = rest Div by + modres = rest Mod by + while (res.Number[size] == 0) And (size > 1): size = size - 1 + if size != FGInt.Number[0]: setlen(res.Number, size + 1) + res.Number[0] = size + Res.Sign = FGInt.Sign + if FGInt.sign == negative: modres = by - modres + +proc FGIntDivByIntBis(FGInt: var TBigInt, by: int32, modres: var int32) = + var + size: int32 + temp, rest: int64 + size = FGInt.Number[0] + temp = 0 + for i in countdown(size, 1): + temp = temp Shl 31 + rest = temp Or FGInt.Number[i] + FGInt.Number[i] = rest Div by + temp = rest Mod by + modres = temp + while (FGInt.Number[size] == 0) And (size > 1): size = size - 1 + if size != FGInt.Number[0]: + setlen(FGInt.Number, size + 1) + FGInt.Number[0] = size + +proc FGIntModByInt(FGInt: TBigInt, by: int32, modres: var int32) = + var + size: int32 + temp, rest: int64 + size = FGInt.Number[0] + temp = 0 + for i in countdown(size, 1): + temp = temp Shl 31 + rest = temp Or FGInt.Number[i] + temp = rest Mod by + modres = temp + if FGInt.sign == negative: modres = by - modres + +proc FGIntAbs(FGInt: var TBigInt) = + FGInt.Sign = positive + +proc FGIntCopy(FGInt1: TBigInt, FGInt2: var TBigInt) = + FGInt2.Sign = FGInt1.Sign + FGInt2.Number = nil + FGInt2.Number = Copy(FGInt1.Number, 0, FGInt1.Number[0] + 1) + +proc FGIntShiftLeft(FGInt: var TBigInt) = + var l, m, size: int32 + size = FGInt.Number[0] + l = 0 + for i in countup(1, Size): + m = FGInt.Number[i] Shr 30 + FGInt.Number[i] = ((FGInt.Number[i] Shl 1) Or l) And 2147483647 + l = m + if l != 0: + setlen(FGInt.Number, size + 2) + FGInt.Number[size + 1] = l + FGInt.Number[0] = size + 1 + +proc FGIntShiftRight(FGInt: var TBigInt) = + var l, m, size: int32 + size = FGInt.Number[0] + l = 0 + for i in countdown(size, 1): + m = FGInt.Number[i] And 1 + FGInt.Number[i] = (FGInt.Number[i] Shr 1) Or l + l = m Shl 30 + if (FGInt.Number[size] == 0) And (size > 1): + setlen(FGInt.Number, size) + FGInt.Number[0] = size - 1 + +proc FGIntShiftRightBy31(FGInt: var TBigInt) = + var size: int32 + size = FGInt.Number[0] + if size > 1: + for i in countup(1, size - 1): + FGInt.Number[i] = FGInt.Number[i + 1] + setlen(FGInt.Number, Size) + FGInt.Number[0] = size - 1 + else: + FGInt.Number[1] = 0 + +proc FGIntAddBis(FGInt1: var TBigInt, FGInt2: TBigInt) = + var size1, size2, Trest, rest: int32 + size1 = FGInt1.Number[0] + size2 = FGInt2.Number[0] + rest = 0 + for i in countup(1, size2): + Trest = FGInt1.Number[i] + FGInt2.Number[i] + rest + rest = Trest Shr 31 + FGInt1.Number[i] = Trest And 2147483647 + for i in countup(size2 + 1, size1): + Trest = FGInt1.Number[i] + rest + rest = Trest Shr 31 + FGInt1.Number[i] = Trest And 2147483647 + if rest != 0: + setlen(FGInt1.Number, size1 + 2) + FGInt1.Number[0] = size1 + 1 + FGInt1.Number[size1 + 1] = rest + +proc FGIntSubBis(FGInt1: var TBigInt, FGInt2: TBigInt) = + var size1, size2, rest, Trest: int32 + size1 = FGInt1.Number[0] + size2 = FGInt2.Number[0] + rest = 0 + for i in countup(1, size2): + Trest = (0x80000000 Or FGInt1.Number[i]) - FGInt2.Number[i] - rest + if (Trest > 2147483647): rest = 0 + else: rest = 1 + FGInt1.Number[i] = Trest And 2147483647 + for i in countup(size2 + 1, size1): + Trest = (0x80000000 Or FGInt1.Number[i]) - rest + if (Trest > 2147483647): rest = 0 + else: rest = 1 + FGInt1.Number[i] = Trest And 2147483647 + i = size1 + while (FGInt1.Number[i] == 0) And (i > 1): i = i - 1 + if i != size1: + setlen(FGInt1.Number, i + 1) + FGInt1.Number[0] = i + +proc FGIntMul(FGInt1, FGInt2: TBigInt, Prod: var TBigInt) = + var + size, size1, size2, rest: int32 + Trest: int64 + size1 = FGInt1.Number[0] + size2 = FGInt2.Number[0] + size = size1 + size2 + setlen(Prod.Number, (size + 1)) + for i in countup(1, size): Prod.Number[i] = 0 + for i in countup(1, size2): + rest = 0 + for j in countup(1, size1): + Trest = FGInt1.Number[j] + Trest = Trest * FGInt2.Number[i] + Trest = Trest + Prod.Number[j + i - 1] + Trest = Trest + rest + Prod.Number[j + i - 1] = Trest And 2147483647 + rest = Trest Shr 31 + Prod.Number[i + size1] = rest + Prod.Number[0] = size + while (Prod.Number[size] == 0) And (size > 1): size = size - 1 + if size != Prod.Number[0]: + setlen(Prod.Number, size + 1) + Prod.Number[0] = size + if FGInt1.Sign == FGInt2.Sign: Prod.Sign = Positive + else: prod.Sign = negative + +proc FGIntSquare(FGInt: TBigInt, Square: var TBigInt) = + var + size, size1, rest: int32 + Trest: int64 + size1 = FGInt.Number[0] + size = 2 * size1 + setlen(Square.Number, (size + 1)) + Square.Number[0] = size + for i in countup(1, size): Square.Number[i] = 0 + for i in countup(1, size1): + Trest = FGInt.Number[i] + Trest = Trest * FGInt.Number[i] + Trest = Trest + Square.Number[2 * i - 1] + Square.Number[2 * i - 1] = Trest And 2147483647 + rest = Trest Shr 31 + for j in countup(i + 1, size1): + Trest = FGInt.Number[i] Shl 1 + Trest = Trest * FGInt.Number[j] + Trest = Trest + Square.Number[i + j - 1] + Trest = Trest + rest + Square.Number[i + j - 1] = Trest And 2147483647 + rest = Trest Shr 31 + Square.Number[i + size1] = rest + Square.Sign = positive + while (Square.Number[size] == 0) And (size > 1): size = size - 1 + if size != (2 * size1): + setlen(Square.Number, size + 1) + Square.Number[0] = size + +proc FGIntExp(FGInt, exp: TBigInt, res: var TBigInt) = + var + temp2, temp3: TBigInt + S: String + FGIntToBase2String(exp, S) + if S[len(S)] == '0': Base10StringToFGInt('1', res) + else: FGIntCopy(FGInt, res) + FGIntCopy(FGInt, temp2) + if len(S) > 1: + for i in countdown((len(S) - 1), 1): + FGIntSquare(temp2, temp3) + FGIntCopy(temp3, temp2) + if S[i] == '1': + FGIntMul(res, temp2, temp3) + FGIntCopy(temp3, res) + +proc FGIntFac(FGInt: TBigInt, res: var TBigInt) = + var one, temp, temp1: TBigInt + FGIntCopy(FGInt, temp) + Base10StringToFGInt('1', res) + Base10StringToFGInt('1', one) + while Not (FGIntCompareAbs(temp, one) == Eq): + FGIntMul(temp, res, temp1) + FGIntCopy(temp1, res) + FGIntSubBis(temp, one) + FGIntDestroy(one) + FGIntDestroy(temp) + +proc FGIntShiftLeftBy31(FGInt: var TBigInt) = + var + f1, f2: int32 + size: int32 + size = FGInt.Number[0] + setlen(FGInt.Number, size + 2) + f1 = 0 + for i in countup(1, (size + 1)): + f2 = FGInt.Number[i] + FGInt.Number[i] = f1 + f1 = f2 + FGInt.Number[0] = size + 1 + +proc FGIntDivMod(FGInt1, FGInt2, QFGInt, MFGInt: var TBigInt) = + var + one, zero, temp1, temp2: TBigInt + s1, s2: TSign + j, s: int32 + i: int64 + s1 = FGInt1.Sign + s2 = FGInt2.Sign + FGIntAbs(FGInt1) + FGIntAbs(FGInt2) + FGIntCopy(FGInt1, MFGInt) + FGIntCopy(FGInt2, temp1) + if FGIntCompareAbs(FGInt1, FGInt2) != St: + s = FGInt1.Number[0] - FGInt2.Number[0] + setlen(QFGInt.Number, (s + 2)) + QFGInt.Number[0] = s + 1 + for t in countup(1, s): + FGIntShiftLeftBy31(temp1) + QFGInt.Number[t] = 0 + j = s + 1 + QFGInt.Number[j] = 0 + while FGIntCompareAbs(MFGInt, FGInt2) != St: + while FGIntCompareAbs(MFGInt, temp1) != St: + if MFGInt.Number[0] > temp1.Number[0]: + i = MFGInt.Number[MFGInt.Number[0]] + i = i Shl 31 + i = i + MFGInt.Number[MFGInt.Number[0] - 1] + i = i Div (temp1.Number[temp1.Number[0]] + 1) + else: + i = MFGInt.Number[MFGInt.Number[0]] Div + (temp1.Number[temp1.Number[0]] + 1) + if (i != 0): + FGIntCopy(temp1, temp2) + FGIntMulByIntBis(temp2, i) + FGIntSubBis(MFGInt, temp2) + QFGInt.Number[j] = QFGInt.Number[j] + i + if FGIntCompareAbs(MFGInt, temp2) != St: + QFGInt.Number[j] = QFGInt.Number[j] + i + FGIntSubBis(MFGInt, temp2) + FGIntDestroy(temp2) + else: + QFGInt.Number[j] = QFGInt.Number[j] + 1 + FGIntSubBis(MFGInt, temp1) + if MFGInt.Number[0] <= temp1.Number[0]: + if FGIntCompareAbs(temp1, FGInt2) != Eq: + FGIntShiftRightBy31(temp1) + j = j - 1 + else: + Base10StringToFGInt('0', QFGInt) + s = QFGInt.Number[0] + while (s > 1) And (QFGInt.Number[s] == 0): s = s - 1 + if s < QFGInt.Number[0]: + setlen(QFGInt.Number, s + 1) + QFGInt.Number[0] = s + QFGInt.Sign = positive + FGIntDestroy(temp1) + Base10StringToFGInt('0', zero) + Base10StringToFGInt('1', one) + if s1 == negative: + if FGIntCompareAbs(MFGInt, zero) != Eq: + FGIntadd(QFGInt, one, temp1) + FGIntDestroy(QFGInt) + FGIntCopy(temp1, QFGInt) + FGIntDestroy(temp1) + FGIntsub(FGInt2, MFGInt, temp1) + FGIntDestroy(MFGInt) + FGIntCopy(temp1, MFGInt) + FGIntDestroy(temp1) + if s2 == positive: QFGInt.Sign = negative + else: + QFGInt.Sign = s2 + FGIntDestroy(one) + FGIntDestroy(zero) + FGInt1.Sign = s1 + FGInt2.Sign = s2 + +proc FGIntDiv(FGInt1, FGInt2, QFGInt: var TBigInt) = + var + one, zero, temp1, temp2, MFGInt: TBigInt + s1, s2: TSign + j, s: int32 + i: int64 + s1 = FGInt1.Sign + s2 = FGInt2.Sign + FGIntAbs(FGInt1) + FGIntAbs(FGInt2) + FGIntCopy(FGInt1, MFGInt) + FGIntCopy(FGInt2, temp1) + if FGIntCompareAbs(FGInt1, FGInt2) != St: + s = FGInt1.Number[0] - FGInt2.Number[0] + setlen(QFGInt.Number, (s + 2)) + QFGInt.Number[0] = s + 1 + for t in countup(1, s): + FGIntShiftLeftBy31(temp1) + QFGInt.Number[t] = 0 + j = s + 1 + QFGInt.Number[j] = 0 + while FGIntCompareAbs(MFGInt, FGInt2) != St: + while FGIntCompareAbs(MFGInt, temp1) != St: + if MFGInt.Number[0] > temp1.Number[0]: + i = MFGInt.Number[MFGInt.Number[0]] + i = i Shl 31 + i = i + MFGInt.Number[MFGInt.Number[0] - 1] + i = i Div (temp1.Number[temp1.Number[0]] + 1) + else: + i = MFGInt.Number[MFGInt.Number[0]] Div + (temp1.Number[temp1.Number[0]] + 1) + if (i != 0): + FGIntCopy(temp1, temp2) + FGIntMulByIntBis(temp2, i) + FGIntSubBis(MFGInt, temp2) + QFGInt.Number[j] = QFGInt.Number[j] + i + if FGIntCompareAbs(MFGInt, temp2) != St: + QFGInt.Number[j] = QFGInt.Number[j] + i + FGIntSubBis(MFGInt, temp2) + FGIntDestroy(temp2) + else: + QFGInt.Number[j] = QFGInt.Number[j] + 1 + FGIntSubBis(MFGInt, temp1) + if MFGInt.Number[0] <= temp1.Number[0]: + if FGIntCompareAbs(temp1, FGInt2) != Eq: + FGIntShiftRightBy31(temp1) + j = j - 1 + else: + Base10StringToFGInt('0', QFGInt) + s = QFGInt.Number[0] + while (s > 1) And (QFGInt.Number[s] == 0): s = s - 1 + if s < QFGInt.Number[0]: + setlen(QFGInt.Number, s + 1) + QFGInt.Number[0] = s + QFGInt.Sign = positive + FGIntDestroy(temp1) + Base10StringToFGInt('0', zero) + Base10StringToFGInt('1', one) + if s1 == negative: + if FGIntCompareAbs(MFGInt, zero) != Eq: + FGIntadd(QFGInt, one, temp1) + FGIntDestroy(QFGInt) + FGIntCopy(temp1, QFGInt) + FGIntDestroy(temp1) + FGIntsub(FGInt2, MFGInt, temp1) + FGIntDestroy(MFGInt) + FGIntCopy(temp1, MFGInt) + FGIntDestroy(temp1) + if s2 == positive: QFGInt.Sign = negative + else: + QFGInt.Sign = s2 + FGIntDestroy(one) + FGIntDestroy(zero) + FGIntDestroy(MFGInt) + FGInt1.Sign = s1 + FGInt2.Sign = s2 + +proc FGIntMod(FGInt1, FGInt2, MFGInt: var TBigInt) = + var + one, zero, temp1, temp2: TBigInt + s1, s2: TSign + s: int32 + i: int64 + s1 = FGInt1.Sign + s2 = FGInt2.Sign + FGIntAbs(FGInt1) + FGIntAbs(FGInt2) + FGIntCopy(FGInt1, MFGInt) + FGIntCopy(FGInt2, temp1) + if FGIntCompareAbs(FGInt1, FGInt2) != St: + s = FGInt1.Number[0] - FGInt2.Number[0] + for t in countup(1, s): FGIntShiftLeftBy31(temp1) + while FGIntCompareAbs(MFGInt, FGInt2) != St: + while FGIntCompareAbs(MFGInt, temp1) != St: + if MFGInt.Number[0] > temp1.Number[0]: + i = MFGInt.Number[MFGInt.Number[0]] + i = i Shl 31 + i = i + MFGInt.Number[MFGInt.Number[0] - 1] + i = i Div (temp1.Number[temp1.Number[0]] + 1) + else: + i = MFGInt.Number[MFGInt.Number[0]] Div + (temp1.Number[temp1.Number[0]] + 1) + if (i != 0): + FGIntCopy(temp1, temp2) + FGIntMulByIntBis(temp2, i) + FGIntSubBis(MFGInt, temp2) + if FGIntCompareAbs(MFGInt, temp2) != St: FGIntSubBis(MFGInt, temp2) + FGIntDestroy(temp2) + else: + FGIntSubBis(MFGInt, temp1) # If FGIntCompareAbs(MFGInt, temp1) <> St Then FGIntSubBis(MFGInt,temp1); + if MFGInt.Number[0] <= temp1.Number[0]: + if FGIntCompareAbs(temp1, FGInt2) != Eq: FGIntShiftRightBy31(temp1) + FGIntDestroy(temp1) + Base10StringToFGInt('0', zero) + Base10StringToFGInt('1', one) + if s1 == negative: + if FGIntCompareAbs(MFGInt, zero) != Eq: + FGIntSub(FGInt2, MFGInt, temp1) + FGIntDestroy(MFGInt) + FGIntCopy(temp1, MFGInt) + FGIntDestroy(temp1) + FGIntDestroy(one) + FGIntDestroy(zero) + FGInt1.Sign = s1 + FGInt2.Sign = s2 + +proc FGIntSquareMod(FGInt, Modb, FGIntSM: var TBigInt) = + var temp: TBigInt + FGIntSquare(FGInt, temp) + FGIntMod(temp, Modb, FGIntSM) + FGIntDestroy(temp) + +proc FGIntAddMod(FGInt1, FGInt2, base, FGIntres: var TBigInt) = + var temp: TBigInt + FGIntadd(FGInt1, FGInt2, temp) + FGIntMod(temp, base, FGIntres) + FGIntDestroy(temp) + +proc FGIntMulMod(FGInt1, FGInt2, base, FGIntres: var TBigInt) = + var temp: TBigInt + FGIntMul(FGInt1, FGInt2, temp) + FGIntMod(temp, base, FGIntres) + FGIntDestroy(temp) + +proc FGIntModExp(FGInt, exp, modb, res: var TBigInt) = + var + temp2, temp3: TBigInt + S: String + if (Modb.Number[1] Mod 2) == 1: + FGIntMontgomeryModExp(FGInt, exp, modb, res) + return + FGIntToBase2String(exp, S) + Base10StringToFGInt('1', res) + FGIntcopy(FGInt, temp2) + for i in countdown(len(S), 1): + if S[i] == '1': + FGIntmulMod(res, temp2, modb, temp3) + FGIntCopy(temp3, res) + FGIntSquareMod(temp2, Modb, temp3) + FGIntCopy(temp3, temp2) + FGIntDestroy(temp2) + +proc FGIntModBis(FGInt: TBigInt, FGIntOut: var TBigInt, b, head: int32) = + if b <= FGInt.Number[0]: + setlen(FGIntOut.Number, (b + 1)) + for i in countup(0, b): FGIntOut.Number[i] = FGInt.Number[i] + FGIntOut.Number[b] = FGIntOut.Number[b] And head + i = b + while (FGIntOut.Number[i] == 0) And (i > 1): i = i - 1 + if i < b: setlen(FGIntOut.Number, i + 1) + FGIntOut.Number[0] = i + FGIntOut.Sign = positive + else: + FGIntCopy(FGInt, FGIntOut) + +proc FGIntMulModBis(FGInt1, FGInt2: TBigInt, Prod: var TBigInt, b, head: int32) = + var + size, size1, size2, t, rest: int32 + Trest: int64 + size1 = FGInt1.Number[0] + size2 = FGInt2.Number[0] + size = min(b, size1 + size2) + setlen(Prod.Number, (size + 1)) + for i in countup(1, size): Prod.Number[i] = 0 + for i in countup(1, size2): + rest = 0 + t = min(size1, b - i + 1) + for j in countup(1, t): + Trest = FGInt1.Number[j] + Trest = Trest * FGInt2.Number[i] + Trest = Trest + Prod.Number[j + i - 1] + Trest = Trest + rest + Prod.Number[j + i - 1] = Trest And 2147483647 + rest = Trest Shr 31 + if (i + size1) <= b: Prod.Number[i + size1] = rest + Prod.Number[0] = size + if size == b: Prod.Number[b] = Prod.Number[b] And head + while (Prod.Number[size] == 0) And (size > 1): size = size - 1 + if size < Prod.Number[0]: + setlen(Prod.Number, size + 1) + Prod.Number[0] = size + if FGInt1.Sign == FGInt2.Sign: Prod.Sign = Positive + else: prod.Sign = negative + +proc FGIntMontgomeryMod(GInt, base, baseInv: TBigInt, MGInt: var TBigInt, + b: int32, head: int32) = + var + m, temp, temp1: TBigInt + r: int32 + FGIntModBis(GInt, temp, b, head) + FGIntMulModBis(temp, baseInv, m, b, head) + FGIntMul(m, base, temp1) + FGIntDestroy(temp) + FGIntAdd(temp1, GInt, temp) + FGIntDestroy(temp1) + MGInt.Number = copy(temp.Number, b - 1, temp.Number[0] - b + 2) + MGInt.Sign = positive + MGInt.Number[0] = temp.Number[0] - b + 1 + FGIntDestroy(temp) + if (head Shr 30) == 0: FGIntDivByIntBis(MGInt, head + 1, r) + else: FGIntShiftRightBy31(MGInt) + if FGIntCompareAbs(MGInt, base) != St: FGIntSubBis(MGInt, base) + FGIntDestroy(temp) + FGIntDestroy(m) + +proc FGIntMontgomeryModExp(FGInt, exp, modb, res: var TBigInt) = + var + temp2, temp3, baseInv, r, zero: TBigInt + t, b, head: int32 + S: String + Base2StringToFGInt('0', zero) + FGIntMod(FGInt, modb, res) + if FGIntCompareAbs(res, zero) == Eq: + FGIntDestroy(zero) + return + else: + FGIntDestroy(res) + FGIntDestroy(zero) + FGIntToBase2String(exp, S) + t = modb.Number[0] + b = t + if (modb.Number[t] Shr 30) == 1: t = t + 1 + setlen(r.Number, (t + 1)) + r.Number[0] = t + r.Sign = positive + for i in countup(1, t): r.Number[i] = 0 + if t == modb.Number[0]: + head = 2147483647 + for j in countdown(29, 0): + head = head Shr 1 + if (modb.Number[t] Shr j) == 1: + r.Number[t] = 1 Shl (j + 1) + break + else: + r.Number[t] = 1 + head = 2147483647 + FGIntModInv(modb, r, temp2) + if temp2.Sign == negative: + FGIntCopy(temp2, BaseInv) + else: + FGIntCopy(r, BaseInv) + FGIntSubBis(BaseInv, temp2) + FGIntAbs(BaseInv) + FGIntDestroy(temp2) + FGIntMod(r, modb, res) + FGIntMulMod(FGInt, res, modb, temp2) + FGIntDestroy(r) + for i in countdown(len(S), 1): + if S[i] == '1': + FGIntmul(res, temp2, temp3) + FGIntDestroy(res) + FGIntMontgomeryMod(temp3, modb, baseinv, res, b, head) + FGIntDestroy(temp3) + FGIntSquare(temp2, temp3) + FGIntDestroy(temp2) + FGIntMontgomeryMod(temp3, modb, baseinv, temp2, b, head) + FGIntDestroy(temp3) + FGIntDestroy(temp2) + FGIntMontgomeryMod(res, modb, baseinv, temp3, b, head) + FGIntCopy(temp3, res) + FGIntDestroy(temp3) + FGIntDestroy(baseinv) + +proc FGIntGCD(FGInt1, FGInt2: TBigInt, GCD: var TBigInt) = + var + k: TCompare + zero, temp1, temp2, temp3: TBigInt + k = FGIntCompareAbs(FGInt1, FGInt2) + if (k == Eq): + FGIntCopy(FGInt1, GCD) + elif (k == St): + FGIntGCD(FGInt2, FGInt1, GCD) + else: + Base10StringToFGInt('0', zero) + FGIntCopy(FGInt1, temp1) + FGIntCopy(FGInt2, temp2) + while (temp2.Number[0] != 1) Or (temp2.Number[1] != 0): + FGIntMod(temp1, temp2, temp3) + FGIntCopy(temp2, temp1) + FGIntCopy(temp3, temp2) + FGIntDestroy(temp3) + FGIntCopy(temp1, GCD) + FGIntDestroy(temp2) + FGIntDestroy(zero) + +proc FGIntLCM(FGInt1, FGInt2: TBigInt, LCM: var TBigInt) = + var temp1, temp2: TBigInt + FGIntGCD(FGInt1, FGInt2, temp1) + FGIntmul(FGInt1, FGInt2, temp2) + FGIntdiv(temp2, temp1, LCM) + FGIntDestroy(temp1) + FGIntDestroy(temp2) + +proc FGIntTrialDiv9999(FGInt: TBigInt, ok: var bool) = + var + j: int32 + i: int + if ((FGInt.Number[1] Mod 2) == 0): + ok = false + else: + i = 0 + ok = true + while ok And (i < 1228): + i = i + 1 + FGIntmodbyint(FGInt, primes[i], j) + if j == 0: ok = false + +proc FGIntRandom1(Seed, RandomFGInt: var TBigInt) = + var temp, base: TBigInt + Base10StringToFGInt("281474976710656", base) + Base10StringToFGInt("44485709377909", temp) + FGIntMulMod(seed, temp, base, RandomFGInt) + FGIntDestroy(temp) + FGIntDestroy(base) + +proc FGIntRabinMiller(FGIntp: var TBigInt, nrtest: int32, ok: var bool) = + var + j, b, i: int32 + m, z, temp1, temp2, temp3, zero, one, two, pmin1: TBigInt + ok1, ok2: bool + randomize + j = 0 + Base10StringToFGInt('0', zero) + Base10StringToFGInt('1', one) + Base10StringToFGInt('2', two) + FGIntsub(FGIntp, one, temp1) + FGIntsub(FGIntp, one, pmin1) + b = 0 + while (temp1.Number[1] Mod 2) == 0: + b = b + 1 + FGIntShiftRight(temp1) + m = temp1 + i = 0 + ok = true + Randomize + while (i < nrtest) And ok: + i = i + 1 + Base10StringToFGInt(inttostr(Primes[Random(1227) + 1]), temp2) + FGIntMontGomeryModExp(temp2, m, FGIntp, z) + FGIntDestroy(temp2) + ok1 = (FGIntCompareAbs(z, one) == Eq) + ok2 = (FGIntCompareAbs(z, pmin1) == Eq) + if Not (ok1 Or ok2): + while (ok And (j < b)): + if (j > 0) And ok1: + ok = false + else: + j = j + 1 + if (j < b) And (Not ok2): + FGIntSquaremod(z, FGIntp, temp3) + FGIntCopy(temp3, z) + ok1 = (FGIntCompareAbs(z, one) == Eq) + ok2 = (FGIntCompareAbs(z, pmin1) == Eq) + if ok2: j = b + elif (Not ok2) And (j >= b): + ok = false + FGIntDestroy(zero) + FGIntDestroy(one) + FGIntDestroy(two) + FGIntDestroy(m) + FGIntDestroy(z) + FGIntDestroy(pmin1) + +proc FGIntBezoutBachet(FGInt1, FGInt2, a, b: var TBigInt) = + var zero, r1, r2, r3, ta, gcd, temp, temp1, temp2: TBigInt + if FGIntCompareAbs(FGInt1, FGInt2) != St: + FGIntcopy(FGInt1, r1) + FGIntcopy(FGInt2, r2) + Base10StringToFGInt('0', zero) + Base10StringToFGInt('1', a) + Base10StringToFGInt('0', ta) + while true: + FGIntdivmod(r1, r2, temp, r3) + FGIntDestroy(r1) + r1 = r2 + r2 = r3 + FGIntmul(ta, temp, temp1) + FGIntsub(a, temp1, temp2) + FGIntCopy(ta, a) + FGIntCopy(temp2, ta) + FGIntDestroy(temp1) + FGIntDestroy(temp) + if FGIntCompareAbs(r3, zero) == Eq: break + FGIntGCD(FGInt1, FGInt2, gcd) + FGIntmul(a, FGInt1, temp1) + FGIntsub(gcd, temp1, temp2) + FGIntDestroy(temp1) + FGIntdiv(temp2, FGInt2, b) + FGIntDestroy(temp2) + FGIntDestroy(ta) + FGIntDestroy(r1) + FGIntDestroy(r2) + FGIntDestroy(gcd) + else: + FGIntBezoutBachet(FGInt2, FGInt1, b, a) + +proc FGIntModInv(FGInt1, base: TBigInt, Inverse: var TBigInt) = + var zero, one, r1, r2, r3, tb, gcd, temp, temp1, temp2: TBigInt + Base10StringToFGInt('1', one) + FGIntGCD(FGInt1, base, gcd) + if FGIntCompareAbs(one, gcd) == Eq: + FGIntcopy(base, r1) + FGIntcopy(FGInt1, r2) + Base10StringToFGInt('0', zero) + Base10StringToFGInt('0', inverse) + Base10StringToFGInt('1', tb) + while true: + FGIntDestroy(r3) + FGIntdivmod(r1, r2, temp, r3) + FGIntCopy(r2, r1) + FGIntCopy(r3, r2) + FGIntmul(tb, temp, temp1) + FGIntsub(inverse, temp1, temp2) + FGIntDestroy(inverse) + FGIntDestroy(temp1) + FGIntCopy(tb, inverse) + FGIntCopy(temp2, tb) + FGIntDestroy(temp) + if FGIntCompareAbs(r3, zero) == Eq: break + if inverse.Sign == negative: + FGIntadd(base, inverse, temp) + FGIntCopy(temp, inverse) + FGIntDestroy(tb) + FGIntDestroy(r1) + FGIntDestroy(r2) + FGIntDestroy(gcd) + FGIntDestroy(one) + +proc FGIntPrimetest(FGIntp: var TBigInt, nrRMtests: int, ok: var bool) = + FGIntTrialdiv9999(FGIntp, ok) + if ok: FGIntRabinMiller(FGIntp, nrRMtests, ok) + +proc FGIntLegendreSymbol(a, p: var TBigInt, L: var int) = + var + temp1, temp2, temp3, temp4, temp5, zero, one: TBigInt + i: int32 + ok1, ok2: bool + Base10StringToFGInt('0', zero) + Base10StringToFGInt('1', one) + FGIntMod(a, p, temp1) + if FGIntCompareAbs(zero, temp1) == Eq: + FGIntDestroy(temp1) + L = 0 + else: + FGIntDestroy(temp1) + FGIntCopy(p, temp1) + FGIntCopy(a, temp2) + L = 1 + while FGIntCompareAbs(temp2, one) != Eq: + if (temp2.Number[1] Mod 2) == 0: + FGIntSquare(temp1, temp3) + FGIntSub(temp3, one, temp4) + FGIntDestroy(temp3) + FGIntDivByInt(temp4, temp3, 8, i) + if (temp3.Number[1] Mod 2) == 0: ok1 = false + else: ok1 = true + FGIntDestroy(temp3) + FGIntDestroy(temp4) + if ok1 == true: L = L * (- 1) + FGIntDivByIntBis(temp2, 2, i) + else: + FGIntSub(temp1, one, temp3) + FGIntSub(temp2, one, temp4) + FGIntMul(temp3, temp4, temp5) + FGIntDestroy(temp3) + FGIntDestroy(temp4) + FGIntDivByInt(temp5, temp3, 4, i) + if (temp3.Number[1] Mod 2) == 0: ok2 = false + else: ok2 = true + FGIntDestroy(temp5) + FGIntDestroy(temp3) + if ok2 == true: L = L * (- 1) + FGIntMod(temp1, temp2, temp3) + FGIntCopy(temp2, temp1) + FGIntCopy(temp3, temp2) + FGIntDestroy(temp1) + FGIntDestroy(temp2) + FGIntDestroy(zero) + FGIntDestroy(one) + +proc FGIntSquareRootModP(Square, Prime: TBigInt, SquareRoot: var TBigInt) = + var + one, n, b, s, r, temp, temp1, temp2, temp3: TBigInt + a: int32 + L: int + Base2StringToFGInt('1', one) + Base2StringToFGInt("10", n) + a = 0 + FGIntLegendreSymbol(n, Prime, L) + while L != - 1: + FGIntAddBis(n, one) + FGIntLegendreSymbol(n, Prime, L) + FGIntCopy(Prime, s) + s.Number[1] = s.Number[1] - 1 + while (s.Number[1] Mod 2) == 0: + FGIntShiftRight(s) + a = a + 1 + FGIntMontgomeryModExp(n, s, Prime, b) + FGIntAdd(s, one, temp) + FGIntShiftRight(temp) + FGIntMontgomeryModExp(Square, temp, Prime, r) + FGIntDestroy(temp) + FGIntModInv(Square, Prime, temp1) + for i in countup(0, (a - 2)): + FGIntSquareMod(r, Prime, temp2) + FGIntMulMod(temp1, temp2, Prime, temp) + FGIntDestroy(temp2) + for j in countup(1, (a - i - 2)): + FGIntSquareMod(temp, Prime, temp2) + FGIntDestroy(temp) + FGIntCopy(temp2, temp) + FGIntDestroy(temp2) + if FGIntCompareAbs(temp, one) != Eq: + FGIntMulMod(r, b, Prime, temp3) + FGIntDestroy(r) + FGIntCopy(temp3, r) + FGIntDestroy(temp3) + FGIntDestroy(temp) + FGIntDestroy(temp2) + if i == (a - 2): break + FGIntSquareMod(b, Prime, temp3) + FGIntDestroy(b) + FGIntCopy(temp3, b) + FGIntDestroy(temp3) + FGIntCopy(r, SquareRoot) + FGIntDestroy(r) + FGIntDestroy(s) + FGIntDestroy(b) + FGIntDestroy(temp1) + FGIntDestroy(one) + FGIntDestroy(n) diff --git a/lib/base/devel/diff.nim b/lib/base/devel/diff.nim new file mode 100644 index 000000000..4fda69b45 --- /dev/null +++ b/lib/base/devel/diff.nim @@ -0,0 +1,460 @@ +# +# +# Nimrod's Runtime Library +# (c) Copyright 2008 Andreas Rumpf +# +# See the file "copying.txt", included in this +# distribution, for details about the copyright. +# + +## This module implements the Difference Algorithm published in +## "An O(ND) Difference Algorithm and its Variations" by Eugene Myers +## Algorithmica Vol. 1 No. 2, 1986, p 251. + +## This implementation is based on: +## +## diff.cs: A port of the algorythm to C# +## Copyright (c) by Matthias Hertel, http://www.mathertel.de +## This work is licensed under a BSD style license. +## See http://www.mathertel.de/License.aspx + +{.push debugger:off .} # the user does not want to trace a part + # of the standard library! + +import + strutils + +type + TResultItem* = object of TObject + startA*: int ## start of line number in A + startB*: int ## start of line number in B + deletedA*: int ## number of deletions in A + deletedB*: int ## number of deletions in B + + SMSRD = tuple[x, y: int] ## shortest middle snake return data + + TDiffData {.final.} = object + len: int + data: seq[int] + modified: seq[bool] + +proc diffText*(a, b: seq[string], + eq: proc (x, y: string): bool): seq[TResultItem] = + ## returns the difference of two texts `a` and `b`. The texts are compared + ## line by line with the `eq` proc. + nil + +proc diffText*(a, b: string, eq: proc (x, y: string): bool): seq[TResultItem] = + ## returns the difference of two texts `a` and `b`. The texts are compared + ## line by line with the `eq` proc. + result = diffText(linesSeq(a), linesSeq(b), eq) + + /// <summary>details of one difference.</summary> + public struct Item + { + /// <summary>Start Line number in Data A.</summary> + public int StartA; + /// <summary>Start Line number in Data B.</summary> + public int StartB; + + /// <summary>Number of changes in Data A.</summary> + public int deletedA; + /// <summary>Number of changes in Data B.</summary> + public int insertedB; + } // Item + + /// <summary> + /// Shortest Middle Snake Return Data + /// </summary> + private struct SMSRD + { + internal int x, y; + // internal int u, v; // 2002.09.20: no need for 2 points + } + + + /// <summary> + /// Find the difference in 2 texts, comparing by textlines. + /// </summary> + /// <param name="TextA">A-version of the text (usualy the old one)</param> + /// <param name="TextB">B-version of the text (usualy the new one)</param> + /// <returns>Returns a array of Items that describe the differences.</returns> + public Item[] DiffText(string TextA, string TextB) { + return (DiffText(TextA, TextB, false, false, false)); + } // DiffText + + + /// <summary> + /// Find the difference in 2 text documents, comparing by textlines. + /// The algorithm itself is comparing 2 arrays of numbers so when comparing 2 text documents + /// each line is converted into a (hash) number. This hash-value is computed by storing all + /// textlines into a common hashtable so i can find dublicates in there, and generating a + /// new number each time a new textline is inserted. + /// </summary> + /// <param name="TextA">A-version of the text (usualy the old one)</param> + /// <param name="TextB">B-version of the text (usualy the new one)</param> + /// <param name="trimSpace">When set to true, all leading and trailing whitespace characters are stripped out before the comparation is done.</param> + /// <param name="ignoreSpace">When set to true, all whitespace characters are converted to a single space character before the comparation is done.</param> + /// <param name="ignoreCase">When set to true, all characters are converted to their lowercase equivivalence before the comparation is done.</param> + /// <returns>Returns a array of Items that describe the differences.</returns> + public static Item[] DiffText(string TextA, string TextB, bool trimSpace, bool ignoreSpace, bool ignoreCase) { + // prepare the input-text and convert to comparable numbers. + Hashtable h = new Hashtable(TextA.Length + TextB.Length); + + // The A-Version of the data (original data) to be compared. + DiffData DataA = new DiffData(DiffCodes(TextA, h, trimSpace, ignoreSpace, ignoreCase)); + + // The B-Version of the data (modified data) to be compared. + DiffData DataB = new DiffData(DiffCodes(TextB, h, trimSpace, ignoreSpace, ignoreCase)); + + h = null; // free up hashtable memory (maybe) + + int MAX = DataA.Length + DataB.Length + 1; + /// vector for the (0,0) to (x,y) search + int[] DownVector = new int[2 * MAX + 2]; + /// vector for the (u,v) to (N,M) search + int[] UpVector = new int[2 * MAX + 2]; + + LCS(DataA, 0, DataA.Length, DataB, 0, DataB.Length, DownVector, UpVector); + + Optimize(DataA); + Optimize(DataB); + return CreateDiffs(DataA, DataB); + } // DiffText + + +proc Optimize(d: var TDiffData) = + ## If a sequence of modified lines starts with a line that contains the + ## same content as the line that appends the changes, the difference sequence + ## is modified so that the appended line and not the starting line is marked + ## as modified. This leads to more readable diff sequences when comparing + ## text files. + var startPos = 0 + while startPos < d.len: + while StartPos < d.len and not d.modified[StartPos]: inc(startPos) + var endPos = startPos + while EndPos < d.len and d.modified[EndPos]: inc(endPos) + if EndPos < d.len and d.data[StartPos] == d.data[EndPos]: + d.modified[StartPos] = false + d.modified[EndPos] = true + else: + StartPos = EndPos + + + /// <summary> + /// Find the difference in 2 arrays of integers. + /// </summary> + /// <param name="ArrayA">A-version of the numbers (usualy the old one)</param> + /// <param name="ArrayB">B-version of the numbers (usualy the new one)</param> + /// <returns>Returns a array of Items that describe the differences.</returns> + public static Item[] DiffInt(int[] ArrayA, int[] ArrayB) { + // The A-Version of the data (original data) to be compared. + DiffData DataA = new DiffData(ArrayA); + + // The B-Version of the data (modified data) to be compared. + DiffData DataB = new DiffData(ArrayB); + + int MAX = DataA.Length + DataB.Length + 1; + /// vector for the (0,0) to (x,y) search + int[] DownVector = new int[2 * MAX + 2]; + /// vector for the (u,v) to (N,M) search + int[] UpVector = new int[2 * MAX + 2]; + + LCS(DataA, 0, DataA.Length, DataB, 0, DataB.Length, DownVector, UpVector); + return CreateDiffs(DataA, DataB); + } // Diff + + + /// <summary> + /// This function converts all textlines of the text into unique numbers for every unique textline + /// so further work can work only with simple numbers. + /// </summary> + /// <param name="aText">the input text</param> + /// <param name="h">This extern initialized hashtable is used for storing all ever used textlines.</param> + /// <param name="trimSpace">ignore leading and trailing space characters</param> + /// <returns>a array of integers.</returns> + private static int[] DiffCodes(string aText, Hashtable h, bool trimSpace, bool ignoreSpace, bool ignoreCase) { + // get all codes of the text + string[] Lines; + int[] Codes; + int lastUsedCode = h.Count; + object aCode; + string s; + + // strip off all cr, only use lf as textline separator. + aText = aText.Replace("\r", ""); + Lines = aText.Split('\n'); + + Codes = new int[Lines.Length]; + + for (int i = 0; i < Lines.Length; ++i) { + s = Lines[i]; + if (trimSpace) + s = s.Trim(); + + if (ignoreSpace) { + s = Regex.Replace(s, "\\s+", " "); // TODO: optimization: faster blank removal. + } + + if (ignoreCase) + s = s.ToLower(); + + aCode = h[s]; + if (aCode == null) { + lastUsedCode++; + h[s] = lastUsedCode; + Codes[i] = lastUsedCode; + } else { + Codes[i] = (int)aCode; + } // if + } // for + return (Codes); + } // DiffCodes + + + /// <summary> + /// This is the algorithm to find the Shortest Middle Snake (SMS). + /// </summary> + /// <param name="DataA">sequence A</param> + /// <param name="LowerA">lower bound of the actual range in DataA</param> + /// <param name="UpperA">upper bound of the actual range in DataA (exclusive)</param> + /// <param name="DataB">sequence B</param> + /// <param name="LowerB">lower bound of the actual range in DataB</param> + /// <param name="UpperB">upper bound of the actual range in DataB (exclusive)</param> + /// <param name="DownVector">a vector for the (0,0) to (x,y) search. Passed as a parameter for speed reasons.</param> + /// <param name="UpVector">a vector for the (u,v) to (N,M) search. Passed as a parameter for speed reasons.</param> + /// <returns>a MiddleSnakeData record containing x,y and u,v</returns> + private static SMSRD SMS(DiffData DataA, int LowerA, int UpperA, DiffData DataB, int LowerB, int UpperB, + int[] DownVector, int[] UpVector) { + + SMSRD ret; + int MAX = DataA.Length + DataB.Length + 1; + + int DownK = LowerA - LowerB; // the k-line to start the forward search + int UpK = UpperA - UpperB; // the k-line to start the reverse search + + int Delta = (UpperA - LowerA) - (UpperB - LowerB); + bool oddDelta = (Delta & 1) != 0; + + // The vectors in the publication accepts negative indexes. the vectors implemented here are 0-based + // and are access using a specific offset: UpOffset UpVector and DownOffset for DownVektor + int DownOffset = MAX - DownK; + int UpOffset = MAX - UpK; + + int MaxD = ((UpperA - LowerA + UpperB - LowerB) / 2) + 1; + + // Debug.Write(2, "SMS", String.Format("Search the box: A[{0}-{1}] to B[{2}-{3}]", LowerA, UpperA, LowerB, UpperB)); + + // init vectors + DownVector[DownOffset + DownK + 1] = LowerA; + UpVector[UpOffset + UpK - 1] = UpperA; + + for (int D = 0; D <= MaxD; D++) { + + // Extend the forward path. + for (int k = DownK - D; k <= DownK + D; k += 2) { + // Debug.Write(0, "SMS", "extend forward path " + k.ToString()); + + // find the only or better starting point + int x, y; + if (k == DownK - D) { + x = DownVector[DownOffset + k + 1]; // down + } else { + x = DownVector[DownOffset + k - 1] + 1; // a step to the right + if ((k < DownK + D) && (DownVector[DownOffset + k + 1] >= x)) + x = DownVector[DownOffset + k + 1]; // down + } + y = x - k; + + // find the end of the furthest reaching forward D-path in diagonal k. + while ((x < UpperA) && (y < UpperB) && (DataA.data[x] == DataB.data[y])) { + x++; y++; + } + DownVector[DownOffset + k] = x; + + // overlap ? + if (oddDelta && (UpK - D < k) && (k < UpK + D)) { + if (UpVector[UpOffset + k] <= DownVector[DownOffset + k]) { + ret.x = DownVector[DownOffset + k]; + ret.y = DownVector[DownOffset + k] - k; + // ret.u = UpVector[UpOffset + k]; // 2002.09.20: no need for 2 points + // ret.v = UpVector[UpOffset + k] - k; + return (ret); + } // if + } // if + + } // for k + + // Extend the reverse path. + for (int k = UpK - D; k <= UpK + D; k += 2) { + // Debug.Write(0, "SMS", "extend reverse path " + k.ToString()); + + // find the only or better starting point + int x, y; + if (k == UpK + D) { + x = UpVector[UpOffset + k - 1]; // up + } else { + x = UpVector[UpOffset + k + 1] - 1; // left + if ((k > UpK - D) && (UpVector[UpOffset + k - 1] < x)) + x = UpVector[UpOffset + k - 1]; // up + } // if + y = x - k; + + while ((x > LowerA) && (y > LowerB) && (DataA.data[x - 1] == DataB.data[y - 1])) { + x--; y--; // diagonal + } + UpVector[UpOffset + k] = x; + + // overlap ? + if (!oddDelta && (DownK - D <= k) && (k <= DownK + D)) { + if (UpVector[UpOffset + k] <= DownVector[DownOffset + k]) { + ret.x = DownVector[DownOffset + k]; + ret.y = DownVector[DownOffset + k] - k; + // ret.u = UpVector[UpOffset + k]; // 2002.09.20: no need for 2 points + // ret.v = UpVector[UpOffset + k] - k; + return (ret); + } // if + } // if + + } // for k + + } // for D + + throw new ApplicationException("the algorithm should never come here."); + } // SMS + + + /// <summary> + /// This is the divide-and-conquer implementation of the longes common-subsequence (LCS) + /// algorithm. + /// The published algorithm passes recursively parts of the A and B sequences. + /// To avoid copying these arrays the lower and upper bounds are passed while the sequences stay constant. + /// </summary> + /// <param name="DataA">sequence A</param> + /// <param name="LowerA">lower bound of the actual range in DataA</param> + /// <param name="UpperA">upper bound of the actual range in DataA (exclusive)</param> + /// <param name="DataB">sequence B</param> + /// <param name="LowerB">lower bound of the actual range in DataB</param> + /// <param name="UpperB">upper bound of the actual range in DataB (exclusive)</param> + /// <param name="DownVector">a vector for the (0,0) to (x,y) search. Passed as a parameter for speed reasons.</param> + /// <param name="UpVector">a vector for the (u,v) to (N,M) search. Passed as a parameter for speed reasons.</param> + private static void LCS(DiffData DataA, int LowerA, int UpperA, DiffData DataB, int LowerB, int UpperB, int[] DownVector, int[] UpVector) { + // Debug.Write(2, "LCS", String.Format("Analyse the box: A[{0}-{1}] to B[{2}-{3}]", LowerA, UpperA, LowerB, UpperB)); + + // Fast walkthrough equal lines at the start + while (LowerA < UpperA && LowerB < UpperB && DataA.data[LowerA] == DataB.data[LowerB]) { + LowerA++; LowerB++; + } + + // Fast walkthrough equal lines at the end + while (LowerA < UpperA && LowerB < UpperB && DataA.data[UpperA - 1] == DataB.data[UpperB - 1]) { + --UpperA; --UpperB; + } + + if (LowerA == UpperA) { + // mark as inserted lines. + while (LowerB < UpperB) + DataB.modified[LowerB++] = true; + + } else if (LowerB == UpperB) { + // mark as deleted lines. + while (LowerA < UpperA) + DataA.modified[LowerA++] = true; + + } else { + // Find the middle snakea and length of an optimal path for A and B + SMSRD smsrd = SMS(DataA, LowerA, UpperA, DataB, LowerB, UpperB, DownVector, UpVector); + // Debug.Write(2, "MiddleSnakeData", String.Format("{0},{1}", smsrd.x, smsrd.y)); + + // The path is from LowerX to (x,y) and (x,y) to UpperX + LCS(DataA, LowerA, smsrd.x, DataB, LowerB, smsrd.y, DownVector, UpVector); + LCS(DataA, smsrd.x, UpperA, DataB, smsrd.y, UpperB, DownVector, UpVector); // 2002.09.20: no need for 2 points + } + } // LCS() + + + /// <summary>Scan the tables of which lines are inserted and deleted, + /// producing an edit script in forward order. + /// </summary> + /// dynamic array + private static Item[] CreateDiffs(DiffData DataA, DiffData DataB) { + ArrayList a = new ArrayList(); + Item aItem; + Item[] result; + + int StartA, StartB; + int LineA, LineB; + + LineA = 0; + LineB = 0; + while (LineA < DataA.Length || LineB < DataB.Length) { + if ((LineA < DataA.Length) && (!DataA.modified[LineA]) + && (LineB < DataB.Length) && (!DataB.modified[LineB])) { + // equal lines + LineA++; + LineB++; + + } else { + // maybe deleted and/or inserted lines + StartA = LineA; + StartB = LineB; + + while (LineA < DataA.Length && (LineB >= DataB.Length || DataA.modified[LineA])) + // while (LineA < DataA.Length && DataA.modified[LineA]) + LineA++; + + while (LineB < DataB.Length && (LineA >= DataA.Length || DataB.modified[LineB])) + // while (LineB < DataB.Length && DataB.modified[LineB]) + LineB++; + + if ((StartA < LineA) || (StartB < LineB)) { + // store a new difference-item + aItem = new Item(); + aItem.StartA = StartA; + aItem.StartB = StartB; + aItem.deletedA = LineA - StartA; + aItem.insertedB = LineB - StartB; + a.Add(aItem); + } // if + } // if + } // while + + result = new Item[a.Count]; + a.CopyTo(result); + + return (result); + } + + } // class Diff + + /// <summary>Data on one input file being compared. + /// </summary> + internal class DiffData + { + + /// <summary>Number of elements (lines).</summary> + internal int Length; + + /// <summary>Buffer of numbers that will be compared.</summary> + internal int[] data; + + /// <summary> + /// Array of booleans that flag for modified data. + /// This is the result of the diff. + /// This means deletedA in the first Data or inserted in the second Data. + /// </summary> + internal bool[] modified; + + /// <summary> + /// Initialize the Diff-Data buffer. + /// </summary> + /// <param name="data">reference to the buffer</param> + internal DiffData(int[] initData) { + data = initData; + Length = initData.Length; + modified = new bool[Length + 2]; + } // DiffData + + } // class DiffData + +{.pop.} diff --git a/lib/base/devel/lex.nim b/lib/base/devel/lex.nim new file mode 100644 index 000000000..34f0c32a8 --- /dev/null +++ b/lib/base/devel/lex.nim @@ -0,0 +1,73 @@ +# Lexer generator for Nimrod +# (c) 2008 Andreas Rumpf + +# Stress testing for the macro feature + +# the syntax that should be supported is: + +# template numpostfix = +# '\'' & 'F'|'f'|'i'|'I' & "32"|"64"|"8"|"16" +# template edigits = +# 'e'|'E' & +digits +# tokens( +# tkIdent: +UniIdentStart & *UniIdentRest, +# tkHexNumber: '0' & ('x'|'X') & +hexDigits & ?( numpostfix ), +# tkOctNumber: '0' & ('c'|'C') & +octDigits & ?( numpostfix ), +# tkBinNumber: '0' & ('b'|'B') & +binDigits & ?( numpostfix ), +# tkIntNumber: +digits & ?( numpostfix ), +# tkFloatNumber: +digits & ('.' & +digits & ?(edigits) | edigits) & ?(numpostfix), +# +# ) +# actions( +# tkIdent: lookup +# ) +# + +# +# match inputstream +# of +('A'..'Z' | '_' | 'a'..'z') *('A'..'Z' | '_' | 'a'..'z' | '0'..'9') : +# +# x = inputstream[pos..length] +# of '0' 'x' +('0'..'9' | 'a'..'f' | '_' | 'A'..'F') : +# y = ... + +const + AsciiLetter = {'A'..'Z', 'a'..'z'} + uniLetter = AsciiLetter + {'\128'..'\255'} + digits = {'0'..'9'} + hexDigits = {'0'..'9', 'a'..'f', 'A'..'F'} + octDigits = {'0'..'7'} + binDigits = {'0'..'1'} + AsciiIdentStart = AsciiLetter + {'_'} + AsciiIdentRest = AsciiIdentStart + Digits + UniIdentStart = UniLetter + {'_'} + UniIdentRest = UniIdentStart + Digits + +# --> if match(s, +AsciiIdentStart & *AsciiIdentRest): + +# Regular expressions in Nimrod itself! +# ------------------------------------- +# +# 'a' -- matches the character a +# 'a'..'z' -- range operator '-' +# 'A' | 'B' -- alternative operator | +# * 'a' -- prefix * is needed +# + 'a' -- prefix + is needed +# ? 'a' -- prefix ? is needed +# *? prefix is needed +# +? prefix is needed +# letter -- character classes with real names! +# letters +# white +# whites +# any -- any character +# () -- are Nimrod syntax +# ! 'a'-'z' +# +# -- concatentation via proc call: +# +# re('A' 'Z' *word ) + +macro re(n: expr): expr = + + result = newCall("magic_re", x) diff --git a/lib/base/devel/nregex.nim b/lib/base/devel/nregex.nim new file mode 100644 index 000000000..77afb8421 --- /dev/null +++ b/lib/base/devel/nregex.nim @@ -0,0 +1,124 @@ +# new implementation of regular expressions + +type + TRegexKind = enum + regNone, + regChar, + regSet, + regConc, + regAlt, + regStar, + regPlus, + regMN, + regNewline + + TRegex = object of TObject + case kind: TRegexKind + of regChar: c: char + of regSet: s: ref set[char] + else: a, b: PRegEx + + PRegEx* = ref TRegEx + + TRegExFlag* = enum ## Flags concerning the semantics of regular expressions + reCaseInsensitive, ## case insensitive match + reStyleInsensitive ## style insensitive match + + + TRegExFlags* = set[TRegExFlag] + ## Flags concerning the semantics of regular expressions + +proc raiseRegex(msg: string) {.noreturn.} = + var e: ref Exception + new(e) + e.msg = msg + raise e + +proc compileAux(i: int, s: string, r: PRegEx): int + +proc compileBackslash(i: int, s: string, r: PRegEx): int = + var i = i + inc(i) + case s[i] + of 'A'..'Z': + of 'a'..'z': + of '0': + of '1'..'9': + + else: + r.kind = regChar + r.c = s[i] + inc(i) + result = i + +proc compileAtom(i: int, s: string, r: PRegEx): int = + var i = i + case s[i] + of '[': + inc(i) + var inverse = s[i] == '^' + if inverse: inc(i) + r.kind = regSet + new(r.s) + while true: + case s[i] + of '\\': i = compileBackslash(i, s, r) + of ']': + inc(i) + break + of '\0': + raiseRegex("']' expected") + elif s[i+1] == '-': + var x = s[i] + inc(i, 2) + var y = s[i] + inc(i) + r.s = r.s + {x..y} + else: + incl(r.s, s[i]) + inc(i) + if inverse: + r.s = {'\0'..'\255'} - r.s + of '\\': + inc(i) + i = compileBackslash(i, s, r) + of '.': + r.kind = regAny + inc(i) + of '(': + inc(i) + i = compileAux(i, s, r) + if s[i] = ')': inc(i) + else: raiseRegex("')' expected") + of '\0': nil # do nothing + else: + r.kind = regChar + r.c = s[i] + inc(i) + result = i + +proc compilePostfix(i: int, s: string, r: PRegEx): int = + var i = compileAtom(i, s, r) + var a: PRegEx + case s[i] + of '*': + of '+': + of '?': + else: nil + +proc compileAux(i: int, s: string, r: PRegEx): int = + var i = i + i = compileAtom(i, s, r) + + while s[i] != '\0': + + result = i + +proc compile*(regex: string, flags: TRegExFlags = {}): PRegEx = + ## Compiles the string `regex` that represents a regular expression into + ## an internal data structure that can be used for matching. + new(result) + var i = compileAux(0, regex, result) + if i < len(regex)-1: + # not all characters used for the regular expression? + raiseRegEx("invalid regular expression") diff --git a/lib/base/devel/python.nim b/lib/base/devel/python.nim new file mode 100644 index 000000000..d9e87af8c --- /dev/null +++ b/lib/base/devel/python.nim @@ -0,0 +1,1877 @@ +# +# Light-weight binding for the Python interpreter +# (c) 2008 Andreas Rumpf +# Based on 'PythonEngine' module by Dr. Dietmar Budelsky +# +# +#************************************************************************ +# +# Module: Unit 'PythonEngine' Copyright (c) 1997 +# +# Version: 3.0 Dr. Dietmar Budelsky +# Sub-Version: 0.25 dbudelsky@web.de +# Germany +# +# Morgan Martinet +# 4721 rue Brebeuf +# H2J 3L2 MONTREAL (QC) +# CANADA +# e-mail: mmm@free.fr +# +# look our page at: http://www.multimania.com/marat +#************************************************************************ +# Functionality: Delphi Components that provide an interface to the +# Python language (see python.txt for more infos on +# Python itself). +# +#************************************************************************ +# Contributors: +# Grzegorz Makarewicz (mak@mikroplan.com.pl) +# Andrew Robinson (andy@hps1.demon.co.uk) +# Mark Watts(mark_watts@hotmail.com) +# Olivier Deckmyn (olivier.deckmyn@mail.dotcom.fr) +# Sigve Tjora (public@tjora.no) +# Mark Derricutt (mark@talios.com) +# Igor E. Poteryaev (jah@mail.ru) +# Yuri Filimonov (fil65@mail.ru) +# Stefan Hoffmeister (Stefan.Hoffmeister@Econos.de) +#************************************************************************ +# This source code is distributed with no WARRANTY, for no reason or use. +# Everyone is allowed to use and change this code free for his own tasks +# and projects, as long as this header and its copyright text is intact. +# For changed versions of this code, which are public distributed the +# following additional conditions have to be fullfilled: +# 1) The header has to contain a comment on the change and the author of +# it. +# 2) A copy of the changed source has to be sent to the above E-Mail +# address or my then valid address, if this is possible to the +# author. +# The second condition has the target to maintain an up to date central +# version of the component. If this condition is not acceptable for +# confidential or legal reasons, everyone is free to derive a component +# or to generate a diff file to my or other original sources. +# Dr. Dietmar Budelsky, 1997-11-17 +#************************************************************************ + +import + dyncalls + +when defined(windows): + const + DllName* = "python24.dll" +else: + const + DllName* = "libpython2.4.so" # for UNIX systems +const + PYT_METHOD_BUFFER_INCREASE* = 10 + PYT_MEMBER_BUFFER_INCREASE* = 10 + PYT_GETSET_BUFFER_INCREASE* = 10 + METH_VARARGS* = 0x0001 + METH_KEYWORDS* = 0x0002 # Masks for the co_flags field of PyCodeObject + CO_OPTIMIZED* = 0x0001 + CO_NEWLOCALS* = 0x0002 + CO_VARARGS* = 0x0004 + CO_VARKEYWORDS* = 0x0008 + +type # Rich comparison opcodes introduced in version 2.1 + TRichComparisonOpcode* = enum + pyLT, pyLE, pyEQ, pyNE, pyGT, pyGE + +const + Py_TPFLAGS_HAVE_GETCHARBUFFER* = (1 shl 0) # PySequenceMethods contains sq_contains + Py_TPFLAGS_HAVE_SEQUENCE_IN* = (1 shl 1) # Objects which participate in garbage collection (see objimp.h) + Py_TPFLAGS_GC* = (1 shl 2) # PySequenceMethods and PyNumberMethods contain in-place operators + Py_TPFLAGS_HAVE_INPLACEOPS* = (1 shl 3) # PyNumberMethods do their own coercion */ + Py_TPFLAGS_CHECKTYPES* = (1 shl 4) + Py_TPFLAGS_HAVE_RICHCOMPARE* = (1 shl 5) # Objects which are weakly referencable if their tp_weaklistoffset is >0 + # XXX Should this have the same value as Py_TPFLAGS_HAVE_RICHCOMPARE? + # These both indicate a feature that appeared in the same alpha release. + Py_TPFLAGS_HAVE_WEAKREFS* = (1 shl 6) # tp_iter is defined + Py_TPFLAGS_HAVE_ITER* = (1 shl 7) # New members introduced by Python 2.2 exist + Py_TPFLAGS_HAVE_CLASS* = (1 shl 8) # Set if the type object is dynamically allocated + Py_TPFLAGS_HEAPTYPE* = (1 shl 9) # Set if the type allows subclassing + Py_TPFLAGS_BASETYPE* = (1 shl 10) # Set if the type is 'ready' -- fully initialized + Py_TPFLAGS_READY* = (1 shl 12) # Set while the type is being 'readied', to prevent recursive ready calls + Py_TPFLAGS_READYING* = (1 shl 13) # Objects support garbage collection (see objimp.h) + Py_TPFLAGS_HAVE_GC* = (1 shl 14) + Py_TPFLAGS_DEFAULT* = Py_TPFLAGS_HAVE_GETCHARBUFFER or + Py_TPFLAGS_HAVE_SEQUENCE_IN or Py_TPFLAGS_HAVE_INPLACEOPS or + Py_TPFLAGS_HAVE_RICHCOMPARE or Py_TPFLAGS_HAVE_WEAKREFS or + Py_TPFLAGS_HAVE_ITER or Py_TPFLAGS_HAVE_CLASS + +type + TPFlag* = enum + tpfHaveGetCharBuffer, tpfHaveSequenceIn, tpfGC, tpfHaveInplaceOps, + tpfCheckTypes, tpfHaveRichCompare, tpfHaveWeakRefs, tpfHaveIter, + tpfHaveClass, tpfHeapType, tpfBaseType, tpfReady, tpfReadying, tpfHaveGC + TPFlags* = set[TPFlag] + +const + TPFLAGS_DEFAULT* = {tpfHaveGetCharBuffer, tpfHaveSequenceIn, + tpfHaveInplaceOps, tpfHaveRichCompare, tpfHaveWeakRefs, tpfHaveIter, + tpfHaveClass} + +const # Python opcodes + single_input* = 256 + file_input* = 257 + eval_input* = 258 + funcdef* = 259 + parameters* = 260 + varargslist* = 261 + fpdef* = 262 + fplist* = 263 + stmt* = 264 + simple_stmt* = 265 + small_stmt* = 266 + expr_stmt* = 267 + augassign* = 268 + print_stmt* = 269 + del_stmt* = 270 + pass_stmt* = 271 + flow_stmt* = 272 + break_stmt* = 273 + continue_stmt* = 274 + return_stmt* = 275 + raise_stmt* = 276 + import_stmt* = 277 + import_as_name* = 278 + dotted_as_name* = 279 + dotted_name* = 280 + global_stmt* = 281 + exec_stmt* = 282 + assert_stmt* = 283 + compound_stmt* = 284 + if_stmt* = 285 + while_stmt* = 286 + for_stmt* = 287 + try_stmt* = 288 + except_clause* = 289 + suite* = 290 + test* = 291 + and_test* = 291 + not_test* = 293 + comparison* = 294 + comp_op* = 295 + expr* = 296 + xor_expr* = 297 + and_expr* = 298 + shift_expr* = 299 + arith_expr* = 300 + term* = 301 + factor* = 302 + power* = 303 + atom* = 304 + listmaker* = 305 + lambdef* = 306 + trailer* = 307 + subscriptlist* = 308 + subscript* = 309 + sliceop* = 310 + exprlist* = 311 + testlist* = 312 + dictmaker* = 313 + classdef* = 314 + arglist* = 315 + argument* = 316 + list_iter* = 317 + list_for* = 318 + list_if* = 319 + +const + T_SHORT* = 0 + T_INT* = 1 + T_LONG* = 2 + T_FLOAT* = 3 + T_DOUBLE* = 4 + T_STRING* = 5 + T_OBJECT* = 6 + T_CHAR* = 7 # 1-character string + T_BYTE* = 8 # 8-bit signed int + T_UBYTE* = 9 + T_USHORT* = 10 + T_UINT* = 11 + T_ULONG* = 12 + T_STRING_INPLACE* = 13 + T_OBJECT_EX* = 16 + READONLY* = 1 + RO* = READONLY # Shorthand + READ_RESTRICTED* = 2 + WRITE_RESTRICTED* = 4 + RESTRICTED* = (READ_RESTRICTED or WRITE_RESTRICTED) + +type + TPyMemberType* = enum + mtShort, mtInt, mtLong, mtFloat, mtDouble, mtString, mtObject, mtChar, + mtByte, mtUByte, mtUShort, mtUInt, mtULong, mtStringInplace, mtObjectEx + TPyMemberFlag* = enum + mfDefault, mfReadOnly, mfReadRestricted, mfWriteRestricted, mfRestricted + +type + TPChar* = array[0..16000, cstring] + PPChar* = ptr TPChar + PInt* = ptr int + PDouble* = ptr float64 + PFloat* = ptr float + PLong* = ptr int32 + PShort* = ptr int8 + PString* = ptr cstring + +type + PP_frozen* = ptr Pfrozen + P_frozen* = ptr Tfrozen + PPyObject* = ptr PyObject + PPPyObject* = ptr PPyObject + PPPPyObject* = ptr PPPyObject + PPyIntObject* = ptr PyIntObject + PPyTypeObject* = ptr PyTypeObject + PPySliceObject* = ptr PySliceObject + TPyCFunction* = proc (self, args: PPyObject): PPyObject{.cdecl.} + Tunaryfunc* = proc (ob1: PPyObject): PPyObject{.cdecl.} + Tbinaryfunc* = proc (ob1, ob2: PPyObject): PPyObject{.cdecl.} + Tternaryfunc* = proc (ob1, ob2, ob3: PPyObject): PPyObject{.cdecl.} + Tinquiry* = proc (ob1: PPyObject): int{.cdecl.} + Tcoercion* = proc (ob1, ob2: PPPyObject): int{.cdecl.} + Tintargfunc* = proc (ob1: PPyObject, i: int): PPyObject{.cdecl.} + Tintintargfunc* = proc (ob1: PPyObject, i1, i2: int): PPyObject{.cdecl.} + Tintobjargproc* = proc (ob1: PPyObject, i: int, ob2: PPyObject): int{.cdecl.} + Tintintobjargproc* = proc (ob1: PPyObject, i1, i2: int, ob2: PPyObject): int{. + cdecl.} + Tobjobjargproc* = proc (ob1, ob2, ob3: PPyObject): int{.cdecl.} + Tpydestructor* = proc (ob: PPyObject){.cdecl.} + Tprintfunc* = proc (ob: PPyObject, f: var file, i: int): int{.cdecl.} + Tgetattrfunc* = proc (ob1: PPyObject, name: cstring): PPyObject{.cdecl.} + Tsetattrfunc* = proc (ob1: PPyObject, name: cstring, ob2: PPyObject): int{. + cdecl.} + Tcmpfunc* = proc (ob1, ob2: PPyObject): int{.cdecl.} + Treprfunc* = proc (ob: PPyObject): PPyObject{.cdecl.} + Thashfunc* = proc (ob: PPyObject): int32{.cdecl.} + Tgetattrofunc* = proc (ob1, ob2: PPyObject): PPyObject{.cdecl.} + Tsetattrofunc* = proc (ob1, ob2, ob3: PPyObject): int{.cdecl.} + Tgetreadbufferproc* = proc (ob1: PPyObject, i: int, ptr: Pointer): int{.cdecl.} + Tgetwritebufferproc* = proc (ob1: PPyObject, i: int, ptr: Pointer): int{.cdecl.} + Tgetsegcountproc* = proc (ob1: PPyObject, i: int): int{.cdecl.} + Tgetcharbufferproc* = proc (ob1: PPyObject, i: int, pstr: cstring): int{.cdecl.} + Tobjobjproc* = proc (ob1, ob2: PPyObject): int{.cdecl.} + Tvisitproc* = proc (ob1: PPyObject, ptr: Pointer): int{.cdecl.} + Ttraverseproc* = proc (ob1: PPyObject, proc: visitproc, ptr: Pointer): int{. + cdecl.} + Trichcmpfunc* = proc (ob1, ob2: PPyObject, i: int): PPyObject{.cdecl.} + Tgetiterfunc* = proc (ob1: PPyObject): PPyObject{.cdecl.} + Titernextfunc* = proc (ob1: PPyObject): PPyObject{.cdecl.} + Tdescrgetfunc* = proc (ob1, ob2, ob3: PPyObject): PPyObject{.cdecl.} + Tdescrsetfunc* = proc (ob1, ob2, ob3: PPyObject): int{.cdecl.} + Tinitproc* = proc (self, args, kwds: PPyObject): int{.cdecl.} + Tnewfunc* = proc (subtype: PPyTypeObject, args, kwds: PPyObject): PPyObject{. + cdecl.} + Tallocfunc* = proc (self: PPyTypeObject, nitems: int): PPyObject{.cdecl.} + TPyNumberMethods*{.final.} = object + nb_add*: Tbinaryfunc + nb_substract*: Tbinaryfunc + nb_multiply*: Tbinaryfunc + nb_divide*: Tbinaryfunc + nb_remainder*: Tbinaryfunc + nb_divmod*: Tbinaryfunc + nb_power*: Tternaryfunc + nb_negative*: Tunaryfunc + nb_positive*: Tunaryfunc + nb_absolute*: Tunaryfunc + nb_nonzero*: Tinquiry + nb_invert*: Tunaryfunc + nb_lshift*: Tbinaryfunc + nb_rshift*: Tbinaryfunc + nb_and*: Tbinaryfunc + nb_xor*: Tbinaryfunc + nb_or*: Tbinaryfunc + nb_coerce*: Tcoercion + nb_int*: Tunaryfunc + nb_long*: Tunaryfunc + nb_float*: Tunaryfunc + nb_oct*: Tunaryfunc + nb_hex*: Tunaryfunc #/ jah 29-sep-2000: updated for python 2.0 + #/ added from .h + nb_inplace_add*: Tbinaryfunc + nb_inplace_subtract*: Tbinaryfunc + nb_inplace_multiply*: Tbinaryfunc + nb_inplace_divide*: Tbinaryfunc + nb_inplace_remainder*: Tbinaryfunc + nb_inplace_power*: Tternaryfunc + nb_inplace_lshift*: Tbinaryfunc + nb_inplace_rshift*: Tbinaryfunc + nb_inplace_and*: Tbinaryfunc + nb_inplace_xor*: Tbinaryfunc + nb_inplace_or*: Tbinaryfunc # Added in release 2.2 + # The following require the Py_TPFLAGS_HAVE_CLASS flag + nb_floor_divide*: Tbinaryfunc + nb_true_divide*: Tbinaryfunc + nb_inplace_floor_divide*: Tbinaryfunc + nb_inplace_true_divide*: Tbinaryfunc + + PPyNumberMethods* = ptr TPyNumberMethods + TPySequenceMethods*{.final.} = object + sq_length*: Tinquiry + sq_concat*: Tbinaryfunc + sq_repeat*: Tintargfunc + sq_item*: Tintargfunc + sq_slice*: Tintintargfunc + sq_ass_item*: Tintobjargproc + sq_ass_slice*: Tintintobjargproc #/ jah 29-sep-2000: updated for python 2.0 + #/ added from .h + sq_contains*: Tobjobjproc + sq_inplace_concat*: Tbinaryfunc + sq_inplace_repeat*: Tintargfunc + + PPySequenceMethods* = ptr TPySequenceMethods + TPyMappingMethods*{.final.} = object + mp_length*: Tinquiry + mp_subscript*: Tbinaryfunc + mp_ass_subscript*: Tobjobjargproc + + PPyMappingMethods* = ptr PyMappingMethods #/ jah 29-sep-2000: updated for python 2.0 + #/ added from .h + TPyBufferProcs*{.final.} = object + bf_getreadbuffer*: Tgetreadbufferproc + bf_getwritebuffer*: Tgetwritebufferproc + bf_getsegcount*: Tgetsegcountproc + bf_getcharbuffer*: Tgetcharbufferproc + + PPyBufferProcs* = ptr TPyBufferProcs + TPy_complex*{.final.} = object + float*: float64 + imag*: float64 + + TPyObject*{.pure.} = object + ob_refcnt*: int + ob_type*: PPyTypeObject + + TPyIntObject* = object of TPyObject + ob_ival*: int32 + + PByte* = ptr int8 + Tfrozen*{.final.} = object + name*: cstring + code*: PByte + size*: int + + TPySliceObject* = object of TPyObject + start*, stop*, step*: PPyObject + + PPyMethodDef* = ptr TPyMethodDef + TPyMethodDef*{.final.} = object # structmember.h + ml_name*: cstring + ml_meth*: TPyCFunction + ml_flags*: int + ml_doc*: cstring + + PPyMemberDef* = ptr TPyMemberDef + TPyMemberDef*{.final.} = object # descrobject.h + # Descriptors + name*: cstring + theType*: int + offset*: int + flags*: int + doc*: cstring + + Tgetter* = proc (obj: PPyObject, context: Pointer): PPyObject{.cdecl.} + Tsetter* = proc (obj, value: PPyObject, context: Pointer): int{.cdecl.} + PPyGetSetDef* = ptr TPyGetSetDef + TPyGetSetDef*{.final.} = object + name*: cstring + get*: Tgetter + set_*: Tsetter + doc*: cstring + closure*: Pointer + + Twrapperfunc* = proc (self, args: PPyObject, wrapped: Pointer): PPyObject{. + cdecl.} + pwrapperbase* = ptr Twrapperbase + Twrapperbase*{.final.} = object # Various kinds of descriptor objects + ##define PyDescr_COMMON \ + # PyObject_HEAD \ + # PyTypeObject *d_type; \ + # PyObject *d_name + # + name*: cstring + wrapper*: Twrapperfunc + doc*: cstring + + PPyDescrObject* = ptr TPyDescrObject + TPyDescrObject* = object of TPyObject + d_type*: PPyTypeObject + d_name*: PPyObject + + PPyMethodDescrObject* = ptr TPyMethodDescrObject + TPyMethodDescrObject* = object of TPyDescrObject + d_method*: PPyMethodDef + + PPyMemberDescrObject* = ptr TPyMemberDescrObject + TPyMemberDescrObject* = object of TPyDescrObject + d_member*: PPyMemberDef + + PPyGetSetDescrObject* = ptr TPyGetSetDescrObject + TPyGetSetDescrObject* = object of TPyDescrObject + d_getset*: PPyGetSetDef + + PPyWrapperDescrObject* = ptr TPyWrapperDescrObject + TPyWrapperDescrObject* = object of TPyDescrObject # object.h + d_base*: pwrapperbase + d_wrapped*: Pointer # This can be any function pointer + + TPyTypeObject* = object of TPyObject + ob_size*: int # Number of items in variable part + tp_name*: cstring # For printing + tp_basicsize*, tp_itemsize*: int # For allocation + # Methods to implement standard operations + tp_dealloc*: Tpydestructor + tp_print*: Tprintfunc + tp_getattr*: Tgetattrfunc + tp_setattr*: Tsetattrfunc + tp_compare*: Tcmpfunc + tp_repr*: Treprfunc # Method suites for standard classes + tp_as_number*: PPyNumberMethods + tp_as_sequence*: PPySequenceMethods + tp_as_mapping*: PPyMappingMethods # More standard operations (here for binary compatibility) + tp_hash*: Thashfunc + tp_call*: Tternaryfunc + tp_str*: Treprfunc + tp_getattro*: Tgetattrofunc + tp_setattro*: Tsetattrofunc #/ jah 29-sep-2000: updated for python 2.0 + # Functions to access object as input/output buffer + tp_as_buffer*: PPyBufferProcs # Flags to define presence of optional/expanded features + tp_flags*: int32 + tp_doc*: cstring # Documentation string + # call function for all accessible objects + tp_traverse*: Ttraverseproc # delete references to contained objects + tp_clear*: Tinquiry # rich comparisons + tp_richcompare*: Trichcmpfunc # weak reference enabler + tp_weaklistoffset*: int32 # Iterators + tp_iter*: Tgetiterfunc + tp_iternext*: Titernextfunc # Attribute descriptor and subclassing stuff + tp_methods*: PPyMethodDef + tp_members*: PPyMemberDef + tp_getset*: PPyGetSetDef + tp_base*: PPyTypeObject + tp_dict*: PPyObject + tp_descr_get*: Tdescrgetfunc + tp_descr_set*: Tdescrsetfunc + tp_dictoffset*: int32 + tp_init*: Tinitproc + tp_alloc*: Tallocfunc + tp_new*: Tnewfunc + tp_free*: Tpydestructor # Low-level free-memory routine + tp_is_gc*: Tinquiry # For PyObject_IS_GC + tp_bases*: PPyObject + tp_mro*: PPyObject # method resolution order + tp_cache*: PPyObject + tp_subclasses*: PPyObject + tp_weaklist*: PPyObject #More spares + tp_xxx7*: pointer + tp_xxx8*: pointer + + PPyMethodChain* = ptr TPyMethodChain + TPyMethodChain*{.final.} = object + methods*: PPyMethodDef + link*: PPyMethodChain + + PPyClassObject* = ptr TPyClassObject + TPyClassObject* = object of TPyObject + cl_bases*: PPyObject # A tuple of class objects + cl_dict*: PPyObject # A dictionary + cl_name*: PPyObject # A string + # The following three are functions or NULL + cl_getattr*: PPyObject + cl_setattr*: PPyObject + cl_delattr*: PPyObject + + PPyInstanceObject* = ptr TPyInstanceObject + TPyInstanceObject* = object of TPyObject # Instance method objects are used for two purposes: + # (a) as bound instance methods (returned by instancename.methodname) + # (b) as unbound methods (returned by ClassName.methodname) + # In case (b), im_self is NULL + # + in_class*: PPyClassObject # The class object + in_dict*: PPyObject # A dictionary + + PPyMethodObject* = ptr TPyMethodObject + TPyMethodObject* = object of TPyObject # Bytecode object, compile.h + im_func*: PPyObject # The function implementing the method + im_self*: PPyObject # The instance it is bound to, or NULL + im_class*: PPyObject # The class that defined the method + + PPyCodeObject* = ptr TPyCodeObject + TPyCodeObject* = object of TPyObject # from pystate.h + co_argcount*: int # #arguments, except *args + co_nlocals*: int # #local variables + co_stacksize*: int # #entries needed for evaluation stack + co_flags*: int # CO_..., see below + co_code*: PPyObject # instruction opcodes (it hides a PyStringObject) + co_consts*: PPyObject # list (constants used) + co_names*: PPyObject # list of strings (names used) + co_varnames*: PPyObject # tuple of strings (local variable names) + co_freevars*: PPyObject # tuple of strings (free variable names) + co_cellvars*: PPyObject # tuple of strings (cell variable names) + # The rest doesn't count for hash/cmp + co_filename*: PPyObject # string (where it was loaded from) + co_name*: PPyObject # string (name, for reference) + co_firstlineno*: int # first source line number + co_lnotab*: PPyObject # string (encoding addr<->lineno mapping) + + PPyInterpreterState* = ptr TPyInterpreterState + PPyThreadState* = ptr TPyThreadState + PPyFrameObject* = ptr TPyFrameObject # Interpreter environments + TPyInterpreterState*{.final.} = object # Thread specific information + next*: PPyInterpreterState + tstate_head*: PPyThreadState + modules*: PPyObject + sysdict*: PPyObject + builtins*: PPyObject + checkinterval*: int + + TPyThreadState*{.final.} = object # from frameobject.h + next*: PPyThreadState + interp*: PPyInterpreterState + frame*: PPyFrameObject + recursion_depth*: int + ticker*: int + tracing*: int + sys_profilefunc*: PPyObject + sys_tracefunc*: PPyObject + curexc_type*: PPyObject + curexc_value*: PPyObject + curexc_traceback*: PPyObject + exc_type*: PPyObject + exc_value*: PPyObject + exc_traceback*: PPyObject + dict*: PPyObject + + PPyTryBlock* = ptr TPyTryBlock + TPyTryBlock*{.final.} = object + b_type*: int # what kind of block this is + b_handler*: int # where to jump to find handler + b_level*: int # value stack level to pop to + + CO_MAXBLOCKS* = range[0..19] + TPyFrameObject* = object of TPyObject # start of the VAR_HEAD of an object + # From traceback.c + ob_size*: int # Number of items in variable part + # End of the Head of an object + f_back*: PPyFrameObject # previous frame, or NULL + f_code*: PPyCodeObject # code segment + f_builtins*: PPyObject # builtin symbol table (PyDictObject) + f_globals*: PPyObject # global symbol table (PyDictObject) + f_locals*: PPyObject # local symbol table (PyDictObject) + f_valuestack*: PPPyObject # points after the last local + # Next free slot in f_valuestack. Frame creation sets to f_valuestack. + # Frame evaluation usually NULLs it, but a frame that yields sets it + # to the current stack top. + f_stacktop*: PPPyObject + f_trace*: PPyObject # Trace function + f_exc_type*, f_exc_value*, f_exc_traceback*: PPyObject + f_tstate*: PPyThreadState + f_lasti*: int # Last instruction if called + f_lineno*: int # Current line number + f_restricted*: int # Flag set if restricted operations + # in this scope + f_iblock*: int # index in f_blockstack + f_blockstack*: array[CO_MAXBLOCKS, PyTryBlock] # for try and loop blocks + f_nlocals*: int # number of locals + f_ncells*: int + f_nfreevars*: int + f_stacksize*: int # size of value stack + f_localsplus*: array[0..0, PPyObject] # locals+stack, dynamically sized + + PPyTraceBackObject* = ptr TPyTraceBackObject + TPyTraceBackObject* = object of TPyObject # Parse tree node interface + tb_next*: PPyTraceBackObject + tb_frame*: PPyFrameObject + tb_lasti*: int + tb_lineno*: int + + PNode* = ptr Tnode + Tnode*{.final.} = object # From weakrefobject.h + n_type*: int16 + n_str*: cstring + n_lineno*: int16 + n_nchildren*: int16 + n_child*: PNode + + PPyWeakReference* = ptr TPyWeakReference + TPyWeakReference* = object of TPyObject # from datetime.h + #* Fields are packed into successive bytes, each viewed as unsigned and + # * big-endian, unless otherwise noted: + # * + # * byte offset + # * 0 year 2 bytes, 1-9999 + # * 2 month 1 byte, 1-12 + # * 3 day 1 byte, 1-31 + # * 4 hour 1 byte, 0-23 + # * 5 minute 1 byte, 0-59 + # * 6 second 1 byte, 0-59 + # * 7 usecond 3 bytes, 0-999999 + # * 10 + # * + wr_object*: PPyObject + wr_callback*: PPyObject + hash*: int32 + wr_prev*: PPyWeakReference + wr_next*: PPyWeakReference + + +const # # of bytes for year, month, and day. + PyDateTime_DATE_DATASIZE* = 4 # # of bytes for hour, minute, second, and usecond. + PyDateTime_TIME_DATASIZE* = 6 # # of bytes for year, month, day, hour, minute, second, and usecond. + PyDateTime_DATETIME_DATASIZE* = 10 + +type + TPyDateTime_Delta* = object of TPyObject + hashcode*: int # -1 when unknown + days*: int # -MAX_DELTA_DAYS <= days <= MAX_DELTA_DAYS + seconds*: int # 0 <= seconds < 24*3600 is invariant + microseconds*: int # 0 <= microseconds < 1000000 is invariant + + PPyDateTime_Delta* = ptr TPyDateTime_Delta + TPyDateTime_TZInfo* = object of TPyObject # a pure abstract base clase + PPyDateTime_TZInfo* = ptr TPyDateTime_TZInfo # + #/* The datetime and time types have hashcodes, and an optional tzinfo member, + # * present if and only if hastzinfo is true. + # */ + ##define _PyTZINFO_HEAD \ + # PyObject_HEAD \ + # long hashcode; \ + # char hastzinfo; /* boolean flag */ + # + #* No _PyDateTime_BaseTZInfo is allocated; it's just to have something + # * convenient to cast to, when getting at the hastzinfo member of objects + # * starting with _PyTZINFO_HEAD. + # * + TPyDateTime_BaseTZInfo* = object of TPyObject + hashcode*: int + hastzinfo*: bool # boolean flag + + PPyDateTime_BaseTZInfo* = ptr TPyDateTime_BaseTZInfo #* All time objects are of PyDateTime_TimeType, but that can be allocated + # * in two ways, with or without a tzinfo member. Without is the same as + # * tzinfo == None, but consumes less memory. _PyDateTime_BaseTime is an + # * internal struct used to allocate the right amount of space for the + # * "without" case. + # * + ##define _PyDateTime_TIMEHEAD \ + # _PyTZINFO_HEAD \ + # unsigned char data[_PyDateTime_TIME_DATASIZE]; + # + TPyDateTime_BaseTime* = object of TPyDateTime_BaseTZInfo + data*: array[0..Pred(PyDateTime_TIME_DATASIZE), int8] + + PPyDateTime_BaseTime* = ptr TPyDateTime_BaseTime + TPyDateTime_Time* = object of TPyDateTime_BaseTime # hastzinfo true + tzinfo*: PPyObject + + PPyDateTime_Time* = ptr PyDateTime_Time #* All datetime objects are of PyDateTime_DateTimeType, but that can be + # * allocated in two ways too, just like for time objects above. In addition, + # * the plain date type is a base class for datetime, so it must also have + # * a hastzinfo member (although it's unused there). + # * + TPyDateTime_Date* = object of TPyDateTime_BaseTZInfo + data*: array[0..Pred(PyDateTime_DATE_DATASIZE), int8] + + PPyDateTime_Date* = ptr TPyDateTime_Date # + ##define _PyDateTime_DATETIMEHEAD \ + # _PyTZINFO_HEAD \ + # unsigned char data[_PyDateTime_DATETIME_DATASIZE]; + # + TPyDateTime_BaseDateTime* = object of TPyDateTime_BaseTZInfo # hastzinfo false + data*: array[0..Pred(PyDateTime_DATETIME_DATASIZE), int8] + + PPyDateTime_BaseDateTime* = ptr TPyDateTime_BaseDateTime + TPyDateTime_DateTime* = object of TPyDateTime_BaseTZInfo # hastzinfo true + data*: array[0..Pred(PyDateTime_DATETIME_DATASIZE), int8] + tzinfo*: PPyObject + + PPyDateTime_DateTime* = ptr TPyDateTime_DateTime + +######################################################## +### ## +### New exception classes ## +### ## +######################################################## +# +# // Python's exceptions +# EPythonError = object(Exception) +# EName: String; +# EValue: String; +# end; +# EPyExecError = object(EPythonError) +# end; +# +# // Standard exception classes of Python +# +#/// jah 29-sep-2000: updated for python 2.0 +#/// base classes updated according python documentation +# +#{ Hierarchy of Python exceptions, Python 2.3, copied from <INSTALL>\Python\exceptions.c +# +#Exception\n\ +# |\n\ +# +-- SystemExit\n\ +# +-- StopIteration\n\ +# +-- StandardError\n\ +# | |\n\ +# | +-- KeyboardInterrupt\n\ +# | +-- ImportError\n\ +# | +-- EnvironmentError\n\ +# | | |\n\ +# | | +-- IOError\n\ +# | | +-- OSError\n\ +# | | |\n\ +# | | +-- WindowsError\n\ +# | | +-- VMSError\n\ +# | |\n\ +# | +-- EOFError\n\ +# | +-- RuntimeError\n\ +# | | |\n\ +# | | +-- NotImplementedError\n\ +# | |\n\ +# | +-- NameError\n\ +# | | |\n\ +# | | +-- UnboundLocalError\n\ +# | |\n\ +# | +-- AttributeError\n\ +# | +-- SyntaxError\n\ +# | | |\n\ +# | | +-- IndentationError\n\ +# | | |\n\ +# | | +-- TabError\n\ +# | |\n\ +# | +-- TypeError\n\ +# | +-- AssertionError\n\ +# | +-- LookupError\n\ +# | | |\n\ +# | | +-- IndexError\n\ +# | | +-- KeyError\n\ +# | |\n\ +# | +-- ArithmeticError\n\ +# | | |\n\ +# | | +-- OverflowError\n\ +# | | +-- ZeroDivisionError\n\ +# | | +-- FloatingPointError\n\ +# | |\n\ +# | +-- ValueError\n\ +# | | |\n\ +# | | +-- UnicodeError\n\ +# | | |\n\ +# | | +-- UnicodeEncodeError\n\ +# | | +-- UnicodeDecodeError\n\ +# | | +-- UnicodeTranslateError\n\ +# | |\n\ +# | +-- ReferenceError\n\ +# | +-- SystemError\n\ +# | +-- MemoryError\n\ +# |\n\ +# +---Warning\n\ +# |\n\ +# +-- UserWarning\n\ +# +-- DeprecationWarning\n\ +# +-- PendingDeprecationWarning\n\ +# +-- SyntaxWarning\n\ +# +-- OverflowWarning\n\ +# +-- RuntimeWarning\n\ +# +-- FutureWarning" +#} +# EPyException = class (EPythonError); +# EPyStandardError = class (EPyException); +# EPyArithmeticError = class (EPyStandardError); +# EPyLookupError = class (EPyStandardError); +# EPyAssertionError = class (EPyStandardError); +# EPyAttributeError = class (EPyStandardError); +# EPyEOFError = class (EPyStandardError); +# EPyFloatingPointError = class (EPyArithmeticError); +# EPyEnvironmentError = class (EPyStandardError); +# EPyIOError = class (EPyEnvironmentError); +# EPyOSError = class (EPyEnvironmentError); +# EPyImportError = class (EPyStandardError); +# EPyIndexError = class (EPyLookupError); +# EPyKeyError = class (EPyLookupError); +# EPyKeyboardInterrupt = class (EPyStandardError); +# EPyMemoryError = class (EPyStandardError); +# EPyNameError = class (EPyStandardError); +# EPyOverflowError = class (EPyArithmeticError); +# EPyRuntimeError = class (EPyStandardError); +# EPyNotImplementedError = class (EPyRuntimeError); +# EPySyntaxError = class (EPyStandardError) +# public +# EFileName: string; +# ELineStr: string; +# ELineNumber: Integer; +# EOffset: Integer; +# end; +# EPyIndentationError = class (EPySyntaxError); +# EPyTabError = class (EPyIndentationError); +# EPySystemError = class (EPyStandardError); +# EPySystemExit = class (EPyException); +# EPyTypeError = class (EPyStandardError); +# EPyUnboundLocalError = class (EPyNameError); +# EPyValueError = class (EPyStandardError); +# EPyUnicodeError = class (EPyValueError); +# UnicodeEncodeError = class (EPyUnicodeError); +# UnicodeDecodeError = class (EPyUnicodeError); +# UnicodeTranslateError = class (EPyUnicodeError); +# EPyZeroDivisionError = class (EPyArithmeticError); +# EPyStopIteration = class(EPyException); +# EPyWarning = class (EPyException); +# EPyUserWarning = class (EPyWarning); +# EPyDeprecationWarning = class (EPyWarning); +# PendingDeprecationWarning = class (EPyWarning); +# FutureWarning = class (EPyWarning); +# EPySyntaxWarning = class (EPyWarning); +# EPyOverflowWarning = class (EPyWarning); +# EPyRuntimeWarning = class (EPyWarning); +# EPyReferenceError = class (EPyStandardError); +# + +var + PyArg_Parse*: proc (args: PPyObject, format: cstring): int{.cdecl, varargs.} + PyArg_ParseTuple*: proc (args: PPyObject, format: cstring, x1: Pointer = nil, + x2: Pointer = nil, x3: Pointer = nil): int{.cdecl, varargs.} + Py_BuildValue*: proc (format: cstring): PPyObject{.cdecl, varargs.} + PyCode_Addr2Line*: proc (co: PPyCodeObject, addrq: int): int{.cdecl.} + DLL_Py_GetBuildInfo*: proc (): cstring{.cdecl.} # define Python flags. See file pyDebug.h + Py_DebugFlag*: PInt + Py_VerboseFlag*: PInt + Py_InteractiveFlag*: PInt + Py_OptimizeFlag*: PInt + Py_NoSiteFlag*: PInt + Py_UseClassExceptionsFlag*: PInt + Py_FrozenFlag*: PInt + Py_TabcheckFlag*: PInt + Py_UnicodeFlag*: PInt + Py_IgnoreEnvironmentFlag*: PInt + Py_DivisionWarningFlag*: PInt #_PySys_TraceFunc: PPPyObject; + #_PySys_ProfileFunc: PPPPyObject; + PyImport_FrozenModules*: PP_frozen + Py_None*: PPyObject + Py_Ellipsis*: PPyObject + Py_False*: PPyIntObject + Py_True*: PPyIntObject + Py_NotImplemented*: PPyObject + PyExc_AttributeError*: PPPyObject + PyExc_EOFError*: PPPyObject + PyExc_IOError*: PPPyObject + PyExc_ImportError*: PPPyObject + PyExc_IndexError*: PPPyObject + PyExc_KeyError*: PPPyObject + PyExc_KeyboardInterrupt*: PPPyObject + PyExc_MemoryError*: PPPyObject + PyExc_NameError*: PPPyObject + PyExc_OverflowError*: PPPyObject + PyExc_RuntimeError*: PPPyObject + PyExc_SyntaxError*: PPPyObject + PyExc_SystemError*: PPPyObject + PyExc_SystemExit*: PPPyObject + PyExc_TypeError*: PPPyObject + PyExc_ValueError*: PPPyObject + PyExc_ZeroDivisionError*: PPPyObject + PyExc_ArithmeticError*: PPPyObject + PyExc_Exception*: PPPyObject + PyExc_FloatingPointError*: PPPyObject + PyExc_LookupError*: PPPyObject + PyExc_StandardError*: PPPyObject + PyExc_AssertionError*: PPPyObject + PyExc_EnvironmentError*: PPPyObject + PyExc_IndentationError*: PPPyObject + PyExc_MemoryErrorInst*: PPPyObject + PyExc_NotImplementedError*: PPPyObject + PyExc_OSError*: PPPyObject + PyExc_TabError*: PPPyObject + PyExc_UnboundLocalError*: PPPyObject + PyExc_UnicodeError*: PPPyObject + PyExc_Warning*: PPPyObject + PyExc_DeprecationWarning*: PPPyObject + PyExc_RuntimeWarning*: PPPyObject + PyExc_SyntaxWarning*: PPPyObject + PyExc_UserWarning*: PPPyObject + PyExc_OverflowWarning*: PPPyObject + PyExc_ReferenceError*: PPPyObject + PyExc_StopIteration*: PPPyObject + PyExc_FutureWarning*: PPPyObject + PyExc_PendingDeprecationWarning*: PPPyObject + PyExc_UnicodeDecodeError*: PPPyObject + PyExc_UnicodeEncodeError*: PPPyObject + PyExc_UnicodeTranslateError*: PPPyObject + PyType_Type*: PPyTypeObject + PyCFunction_Type*: PPyTypeObject + PyCObject_Type*: PPyTypeObject + PyClass_Type*: PPyTypeObject + PyCode_Type*: PPyTypeObject + PyComplex_Type*: PPyTypeObject + PyDict_Type*: PPyTypeObject + PyFile_Type*: PPyTypeObject + PyFloat_Type*: PPyTypeObject + PyFrame_Type*: PPyTypeObject + PyFunction_Type*: PPyTypeObject + PyInstance_Type*: PPyTypeObject + PyInt_Type*: PPyTypeObject + PyList_Type*: PPyTypeObject + PyLong_Type*: PPyTypeObject + PyMethod_Type*: PPyTypeObject + PyModule_Type*: PPyTypeObject + PyObject_Type*: PPyTypeObject + PyRange_Type*: PPyTypeObject + PySlice_Type*: PPyTypeObject + PyString_Type*: PPyTypeObject + PyTuple_Type*: PPyTypeObject + PyBaseObject_Type*: PPyTypeObject + PyBuffer_Type*: PPyTypeObject + PyCallIter_Type*: PPyTypeObject + PyCell_Type*: PPyTypeObject + PyClassMethod_Type*: PPyTypeObject + PyProperty_Type*: PPyTypeObject + PySeqIter_Type*: PPyTypeObject + PyStaticMethod_Type*: PPyTypeObject + PySuper_Type*: PPyTypeObject + PySymtableEntry_Type*: PPyTypeObject + PyTraceBack_Type*: PPyTypeObject + PyUnicode_Type*: PPyTypeObject + PyWrapperDescr_Type*: PPyTypeObject + PyBaseString_Type*: PPyTypeObject + PyBool_Type*: PPyTypeObject + PyEnum_Type*: PPyTypeObject #PyArg_GetObject: function(args: PPyObject; nargs, i: integer; p_a: PPPyObject): integer; cdecl; + #PyArg_GetLong: function(args: PPyObject; nargs, i: integer; p_a: PLong): integer; cdecl; + #PyArg_GetShort: function(args: PPyObject; nargs, i: integer; p_a: PShort): integer; cdecl; + #PyArg_GetFloat: function(args: PPyObject; nargs, i: integer; p_a: PFloat): integer; cdecl; + #PyArg_GetString: function(args: PPyObject; nargs, i: integer; p_a: PString): integer; cdecl; + #PyArgs_VaParse: function (args: PPyObject; format: PChar; va_list: array of const): integer; cdecl; + # Does not work! + # Py_VaBuildValue: function (format: PChar; va_list: array of const): PPyObject; cdecl; + #PyBuiltin_Init: procedure; cdecl; + PyComplex_FromCComplex*: proc (c: TPy_complex): PPyObject{.cdecl.} + PyComplex_FromDoubles*: proc (realv, imag: float64): PPyObject{.cdecl.} + PyComplex_RealAsDouble*: proc (op: PPyObject): float64{.cdecl.} + PyComplex_ImagAsDouble*: proc (op: PPyObject): float64{.cdecl.} + PyComplex_AsCComplex*: proc (op: PPyObject): TPy_complex{.cdecl.} + PyCFunction_GetFunction*: proc (ob: PPyObject): Pointer{.cdecl.} + PyCFunction_GetSelf*: proc (ob: PPyObject): PPyObject{.cdecl.} + PyCallable_Check*: proc (ob: PPyObject): int{.cdecl.} + PyCObject_FromVoidPtr*: proc (cobj, destruct: Pointer): PPyObject{.cdecl.} + PyCObject_AsVoidPtr*: proc (ob: PPyObject): Pointer{.cdecl.} + PyClass_New*: proc (ob1, ob2, ob3: PPyObject): PPyObject{.cdecl.} + PyClass_IsSubclass*: proc (ob1, ob2: PPyObject): int{.cdecl.} + Py_InitModule4*: proc (name: cstring, methods: PPyMethodDef, doc: cstring, + passthrough: PPyObject, Api_Version: int): PPyObject{. + cdecl.} + PyErr_BadArgument*: proc (): int{.cdecl.} + PyErr_BadInternalCall*: proc (){.cdecl.} + PyErr_CheckSignals*: proc (): int{.cdecl.} + PyErr_Clear*: proc (){.cdecl.} + PyErr_Fetch*: proc (errtype, errvalue, errtraceback: PPPyObject){.cdecl.} + PyErr_NoMemory*: proc (): PPyObject{.cdecl.} + PyErr_Occurred*: proc (): PPyObject{.cdecl.} + PyErr_Print*: proc (){.cdecl.} + PyErr_Restore*: proc (errtype, errvalue, errtraceback: PPyObject){.cdecl.} + PyErr_SetFromErrno*: proc (ob: PPyObject): PPyObject{.cdecl.} + PyErr_SetNone*: proc (value: PPyObject){.cdecl.} + PyErr_SetObject*: proc (ob1, ob2: PPyObject){.cdecl.} + PyErr_SetString*: proc (ErrorObject: PPyObject, text: cstring){.cdecl.} + PyImport_GetModuleDict*: proc (): PPyObject{.cdecl.} + PyInt_FromLong*: proc (x: int32): PPyObject{.cdecl.} + Py_Initialize*: proc (){.cdecl.} + Py_Exit*: proc (RetVal: int){.cdecl.} + PyEval_GetBuiltins*: proc (): PPyObject{.cdecl.} + PyDict_GetItem*: proc (mp, key: PPyObject): PPyObject{.cdecl.} + PyDict_SetItem*: proc (mp, key, item: PPyObject): int{.cdecl.} + PyDict_DelItem*: proc (mp, key: PPyObject): int{.cdecl.} + PyDict_Clear*: proc (mp: PPyObject){.cdecl.} + PyDict_Next*: proc (mp: PPyObject, pos: PInt, key, value: PPPyObject): int{. + cdecl.} + PyDict_Keys*: proc (mp: PPyObject): PPyObject{.cdecl.} + PyDict_Values*: proc (mp: PPyObject): PPyObject{.cdecl.} + PyDict_Items*: proc (mp: PPyObject): PPyObject{.cdecl.} + PyDict_Size*: proc (mp: PPyObject): int{.cdecl.} + PyDict_DelItemString*: proc (dp: PPyObject, key: cstring): int{.cdecl.} + PyDict_New*: proc (): PPyObject{.cdecl.} + PyDict_GetItemString*: proc (dp: PPyObject, key: cstring): PPyObject{.cdecl.} + PyDict_SetItemString*: proc (dp: PPyObject, key: cstring, item: PPyObject): int{. + cdecl.} + PyDictProxy_New*: proc (obj: PPyObject): PPyObject{.cdecl.} + PyModule_GetDict*: proc (module: PPyObject): PPyObject{.cdecl.} + PyObject_Str*: proc (v: PPyObject): PPyObject{.cdecl.} + PyRun_String*: proc (str: cstring, start: int, globals: PPyObject, + locals: PPyObject): PPyObject{.cdecl.} + PyRun_SimpleString*: proc (str: cstring): int{.cdecl.} + PyString_AsString*: proc (ob: PPyObject): cstring{.cdecl.} + PyString_FromString*: proc (str: cstring): PPyObject{.cdecl.} + PySys_SetArgv*: proc (argc: int, argv: PPChar){.cdecl.} #+ means, Grzegorz or me has tested his non object version of this function + #+ + PyCFunction_New*: proc (md: PPyMethodDef, ob: PPyObject): PPyObject{.cdecl.} #+ + PyEval_CallObject*: proc (ob1, ob2: PPyObject): PPyObject{.cdecl.} #- + PyEval_CallObjectWithKeywords*: proc (ob1, ob2, ob3: PPyObject): PPyObject{. + cdecl.} #- + PyEval_GetFrame*: proc (): PPyObject{.cdecl.} #- + PyEval_GetGlobals*: proc (): PPyObject{.cdecl.} #- + PyEval_GetLocals*: proc (): PPyObject{.cdecl.} #- + #PyEval_GetOwner:function:PPyObject; cdecl; + #- + PyEval_GetRestricted*: proc (): int{.cdecl.} #- + PyEval_InitThreads*: proc (){.cdecl.} #- + PyEval_RestoreThread*: proc (tstate: PPyThreadState){.cdecl.} #- + PyEval_SaveThread*: proc (): PPyThreadState{.cdecl.} #- + PyFile_FromString*: proc (pc1, pc2: cstring): PPyObject{.cdecl.} #- + PyFile_GetLine*: proc (ob: PPyObject, i: int): PPyObject{.cdecl.} #- + PyFile_Name*: proc (ob: PPyObject): PPyObject{.cdecl.} #- + PyFile_SetBufSize*: proc (ob: PPyObject, i: int){.cdecl.} #- + PyFile_SoftSpace*: proc (ob: PPyObject, i: int): int{.cdecl.} #- + PyFile_WriteObject*: proc (ob1, ob2: PPyObject, i: int): int{.cdecl.} #- + PyFile_WriteString*: proc (s: cstring, ob: PPyObject){.cdecl.} #+ + PyFloat_AsDouble*: proc (ob: PPyObject): float64{.cdecl.} #+ + PyFloat_FromDouble*: proc (db: float64): PPyObject{.cdecl.} #- + PyFunction_GetCode*: proc (ob: PPyObject): PPyObject{.cdecl.} #- + PyFunction_GetGlobals*: proc (ob: PPyObject): PPyObject{.cdecl.} #- + PyFunction_New*: proc (ob1, ob2: PPyObject): PPyObject{.cdecl.} #- + PyImport_AddModule*: proc (name: cstring): PPyObject{.cdecl.} #- + PyImport_Cleanup*: proc (){.cdecl.} #- + PyImport_GetMagicNumber*: proc (): int32{.cdecl.} #+ + PyImport_ImportFrozenModule*: proc (key: cstring): int{.cdecl.} #+ + PyImport_ImportModule*: proc (name: cstring): PPyObject{.cdecl.} #+ + PyImport_Import*: proc (name: PPyObject): PPyObject{.cdecl.} #- + #PyImport_Init:procedure; cdecl; + #- + PyImport_ReloadModule*: proc (ob: PPyObject): PPyObject{.cdecl.} #- + PyInstance_New*: proc (obClass, obArg, obKW: PPyObject): PPyObject{.cdecl.} #+ + PyInt_AsLong*: proc (ob: PPyObject): int32{.cdecl.} #- + PyList_Append*: proc (ob1, ob2: PPyObject): int{.cdecl.} #- + PyList_AsTuple*: proc (ob: PPyObject): PPyObject{.cdecl.} #+ + PyList_GetItem*: proc (ob: PPyObject, i: int): PPyObject{.cdecl.} #- + PyList_GetSlice*: proc (ob: PPyObject, i1, i2: int): PPyObject{.cdecl.} #- + PyList_Insert*: proc (dp: PPyObject, idx: int, item: PPyObject): int{.cdecl.} #- + PyList_New*: proc (size: int): PPyObject{.cdecl.} #- + PyList_Reverse*: proc (ob: PPyObject): int{.cdecl.} #- + PyList_SetItem*: proc (dp: PPyObject, idx: int, item: PPyObject): int{.cdecl.} #- + PyList_SetSlice*: proc (ob: PPyObject, i1, i2: int, ob2: PPyObject): int{. + cdecl.} #+ + PyList_Size*: proc (ob: PPyObject): int{.cdecl.} #- + PyList_Sort*: proc (ob: PPyObject): int{.cdecl.} #- + PyLong_AsDouble*: proc (ob: PPyObject): float64{.cdecl.} #+ + PyLong_AsLong*: proc (ob: PPyObject): int32{.cdecl.} #+ + PyLong_FromDouble*: proc (db: float64): PPyObject{.cdecl.} #+ + PyLong_FromLong*: proc (l: int32): PPyObject{.cdecl.} #- + PyLong_FromString*: proc (pc: cstring, ppc: var cstring, i: int): PPyObject{. + cdecl.} #- + PyLong_FromUnsignedLong*: proc (val: int): PPyObject{.cdecl.} #- + PyLong_AsUnsignedLong*: proc (ob: PPyObject): int{.cdecl.} #- + PyLong_FromUnicode*: proc (ob: PPyObject, a, b: int): PPyObject{.cdecl.} #- + PyLong_FromLongLong*: proc (val: Int64): PPyObject{.cdecl.} #- + PyLong_AsLongLong*: proc (ob: PPyObject): Int64{.cdecl.} #- + PyMapping_Check*: proc (ob: PPyObject): int{.cdecl.} #- + PyMapping_GetItemString*: proc (ob: PPyObject, key: cstring): PPyObject{.cdecl.} #- + PyMapping_HasKey*: proc (ob, key: PPyObject): int{.cdecl.} #- + PyMapping_HasKeyString*: proc (ob: PPyObject, key: cstring): int{.cdecl.} #- + PyMapping_Length*: proc (ob: PPyObject): int{.cdecl.} #- + PyMapping_SetItemString*: proc (ob: PPyObject, key: cstring, value: PPyObject): int{. + cdecl.} #- + PyMethod_Class*: proc (ob: PPyObject): PPyObject{.cdecl.} #- + PyMethod_Function*: proc (ob: PPyObject): PPyObject{.cdecl.} #- + PyMethod_New*: proc (ob1, ob2, ob3: PPyObject): PPyObject{.cdecl.} #- + PyMethod_Self*: proc (ob: PPyObject): PPyObject{.cdecl.} #- + PyModule_GetName*: proc (ob: PPyObject): cstring{.cdecl.} #- + PyModule_New*: proc (key: cstring): PPyObject{.cdecl.} #- + PyNumber_Absolute*: proc (ob: PPyObject): PPyObject{.cdecl.} #- + PyNumber_Add*: proc (ob1, ob2: PPyObject): PPyObject{.cdecl.} #- + PyNumber_And*: proc (ob1, ob2: PPyObject): PPyObject{.cdecl.} #- + PyNumber_Check*: proc (ob: PPyObject): int{.cdecl.} #- + PyNumber_Coerce*: proc (ob1, ob2: var PPyObject): int{.cdecl.} #- + PyNumber_Divide*: proc (ob1, ob2: PPyObject): PPyObject{.cdecl.} #- + PyNumber_FloorDivide*: proc (ob1, ob2: PPyObject): PPyObject{.cdecl.} #- + PyNumber_TrueDivide*: proc (ob1, ob2: PPyObject): PPyObject{.cdecl.} #- + PyNumber_Divmod*: proc (ob1, ob2: PPyObject): PPyObject{.cdecl.} #- + PyNumber_Float*: proc (ob: PPyObject): PPyObject{.cdecl.} #- + PyNumber_Int*: proc (ob: PPyObject): PPyObject{.cdecl.} #- + PyNumber_Invert*: proc (ob: PPyObject): PPyObject{.cdecl.} #- + PyNumber_Long*: proc (ob: PPyObject): PPyObject{.cdecl.} #- + PyNumber_Lshift*: proc (ob1, ob2: PPyObject): PPyObject{.cdecl.} #- + PyNumber_Multiply*: proc (ob1, ob2: PPyObject): PPyObject{.cdecl.} #- + PyNumber_Negative*: proc (ob: PPyObject): PPyObject{.cdecl.} #- + PyNumber_Or*: proc (ob1, ob2: PPyObject): PPyObject{.cdecl.} #- + PyNumber_Positive*: proc (ob: PPyObject): PPyObject{.cdecl.} #- + PyNumber_Power*: proc (ob1, ob2, ob3: PPyObject): PPyObject{.cdecl.} #- + PyNumber_Remainder*: proc (ob1, ob2: PPyObject): PPyObject{.cdecl.} #- + PyNumber_Rshift*: proc (ob1, ob2: PPyObject): PPyObject{.cdecl.} #- + PyNumber_Subtract*: proc (ob1, ob2: PPyObject): PPyObject{.cdecl.} #- + PyNumber_Xor*: proc (ob1, ob2: PPyObject): PPyObject{.cdecl.} #- + PyOS_InitInterrupts*: proc (){.cdecl.} #- + PyOS_InterruptOccurred*: proc (): int{.cdecl.} #- + PyObject_CallObject*: proc (ob, args: PPyObject): PPyObject{.cdecl.} #- + PyObject_Compare*: proc (ob1, ob2: PPyObject): int{.cdecl.} #- + PyObject_GetAttr*: proc (ob1, ob2: PPyObject): PPyObject{.cdecl.} #+ + PyObject_GetAttrString*: proc (ob: PPyObject, c: cstring): PPyObject{.cdecl.} #- + PyObject_GetItem*: proc (ob, key: PPyObject): PPyObject{.cdecl.} #- + PyObject_DelItem*: proc (ob, key: PPyObject): PPyObject{.cdecl.} #- + PyObject_HasAttrString*: proc (ob: PPyObject, key: cstring): int{.cdecl.} #- + PyObject_Hash*: proc (ob: PPyObject): int32{.cdecl.} #- + PyObject_IsTrue*: proc (ob: PPyObject): int{.cdecl.} #- + PyObject_Length*: proc (ob: PPyObject): int{.cdecl.} #- + PyObject_Repr*: proc (ob: PPyObject): PPyObject{.cdecl.} #- + PyObject_SetAttr*: proc (ob1, ob2, ob3: PPyObject): int{.cdecl.} #- + PyObject_SetAttrString*: proc (ob: PPyObject, key: cstring, value: PPyObject): int{. + cdecl.} #- + PyObject_SetItem*: proc (ob1, ob2, ob3: PPyObject): int{.cdecl.} #- + PyObject_Init*: proc (ob: PPyObject, t: PPyTypeObject): PPyObject{.cdecl.} #- + PyObject_InitVar*: proc (ob: PPyObject, t: PPyTypeObject, size: int): PPyObject{. + cdecl.} #- + PyObject_New*: proc (t: PPyTypeObject): PPyObject{.cdecl.} #- + PyObject_NewVar*: proc (t: PPyTypeObject, size: int): PPyObject{.cdecl.} + PyObject_Free*: proc (ob: PPyObject){.cdecl.} #- + PyObject_IsInstance*: proc (inst, cls: PPyObject): int{.cdecl.} #- + PyObject_IsSubclass*: proc (derived, cls: PPyObject): int{.cdecl.} + PyObject_GenericGetAttr*: proc (obj, name: PPyObject): PPyObject{.cdecl.} + PyObject_GenericSetAttr*: proc (obj, name, value: PPyObject): int{.cdecl.} #- + PyObject_GC_Malloc*: proc (size: int): PPyObject{.cdecl.} #- + PyObject_GC_New*: proc (t: PPyTypeObject): PPyObject{.cdecl.} #- + PyObject_GC_NewVar*: proc (t: PPyTypeObject, size: int): PPyObject{.cdecl.} #- + PyObject_GC_Resize*: proc (t: PPyObject, newsize: int): PPyObject{.cdecl.} #- + PyObject_GC_Del*: proc (ob: PPyObject){.cdecl.} #- + PyObject_GC_Track*: proc (ob: PPyObject){.cdecl.} #- + PyObject_GC_UnTrack*: proc (ob: PPyObject){.cdecl.} #- + PyRange_New*: proc (l1, l2, l3: int32, i: int): PPyObject{.cdecl.} #- + PySequence_Check*: proc (ob: PPyObject): int{.cdecl.} #- + PySequence_Concat*: proc (ob1, ob2: PPyObject): PPyObject{.cdecl.} #- + PySequence_Count*: proc (ob1, ob2: PPyObject): int{.cdecl.} #- + PySequence_GetItem*: proc (ob: PPyObject, i: int): PPyObject{.cdecl.} #- + PySequence_GetSlice*: proc (ob: PPyObject, i1, i2: int): PPyObject{.cdecl.} #- + PySequence_In*: proc (ob1, ob2: PPyObject): int{.cdecl.} #- + PySequence_Index*: proc (ob1, ob2: PPyObject): int{.cdecl.} #- + PySequence_Length*: proc (ob: PPyObject): int{.cdecl.} #- + PySequence_Repeat*: proc (ob: PPyObject, count: int): PPyObject{.cdecl.} #- + PySequence_SetItem*: proc (ob: PPyObject, i: int, value: PPyObject): int{. + cdecl.} #- + PySequence_SetSlice*: proc (ob: PPyObject, i1, i2: int, value: PPyObject): int{. + cdecl.} #- + PySequence_DelSlice*: proc (ob: PPyObject, i1, i2: int): int{.cdecl.} #- + PySequence_Tuple*: proc (ob: PPyObject): PPyObject{.cdecl.} #- + PySequence_Contains*: proc (ob, value: PPyObject): int{.cdecl.} #- + PySlice_GetIndices*: proc (ob: PPySliceObject, len: int, + start, stop, step: var int): int{.cdecl.} #- + PySlice_GetIndicesEx*: proc (ob: PPySliceObject, len: int, + start, stop, step, slicelength: var int): int{. + cdecl.} #- + PySlice_New*: proc (start, stop, step: PPyObject): PPyObject{.cdecl.} #- + PyString_Concat*: proc (ob1: var PPyObject, ob2: PPyObject){.cdecl.} #- + PyString_ConcatAndDel*: proc (ob1: var PPyObject, ob2: PPyObject){.cdecl.} #- + PyString_Format*: proc (ob1, ob2: PPyObject): PPyObject{.cdecl.} #- + PyString_FromStringAndSize*: proc (s: cstring, i: int): PPyObject{.cdecl.} #- + PyString_Size*: proc (ob: PPyObject): int{.cdecl.} #- + PyString_DecodeEscape*: proc (s: cstring, length: int, errors: cstring, + unicode: int, recode_encoding: cstring): PPyObject{. + cdecl.} #- + PyString_Repr*: proc (ob: PPyObject, smartquotes: int): PPyObject{.cdecl.} #+ + PySys_GetObject*: proc (s: cstring): PPyObject{.cdecl.} #- + #PySys_Init:procedure; cdecl; + #- + PySys_SetObject*: proc (s: cstring, ob: PPyObject): int{.cdecl.} #- + PySys_SetPath*: proc (path: cstring){.cdecl.} #- + #PyTraceBack_Fetch:function:PPyObject; cdecl; + #- + PyTraceBack_Here*: proc (p: pointer): int{.cdecl.} #- + PyTraceBack_Print*: proc (ob1, ob2: PPyObject): int{.cdecl.} #- + #PyTraceBack_Store:function (ob:PPyObject):integer; cdecl; + #+ + PyTuple_GetItem*: proc (ob: PPyObject, i: int): PPyObject{.cdecl.} #- + PyTuple_GetSlice*: proc (ob: PPyObject, i1, i2: int): PPyObject{.cdecl.} #+ + PyTuple_New*: proc (size: int): PPyObject{.cdecl.} #+ + PyTuple_SetItem*: proc (ob: PPyObject, key: int, value: PPyObject): int{.cdecl.} #+ + PyTuple_Size*: proc (ob: PPyObject): int{.cdecl.} #+ + PyType_IsSubtype*: proc (a, b: PPyTypeObject): int{.cdecl.} + PyType_GenericAlloc*: proc (atype: PPyTypeObject, nitems: int): PPyObject{. + cdecl.} + PyType_GenericNew*: proc (atype: PPyTypeObject, args, kwds: PPyObject): PPyObject{. + cdecl.} + PyType_Ready*: proc (atype: PPyTypeObject): int{.cdecl.} #+ + PyUnicode_FromWideChar*: proc (w: PWideChar, size: int): PPyObject{.cdecl.} #+ + PyUnicode_AsWideChar*: proc (unicode: PPyObject, w: PWideChar, size: int): int{. + cdecl.} #- + PyUnicode_FromOrdinal*: proc (ordinal: int): PPyObject{.cdecl.} + PyWeakref_GetObject*: proc (ref: PPyObject): PPyObject{.cdecl.} + PyWeakref_NewProxy*: proc (ob, callback: PPyObject): PPyObject{.cdecl.} + PyWeakref_NewRef*: proc (ob, callback: PPyObject): PPyObject{.cdecl.} + PyWrapper_New*: proc (ob1, ob2: PPyObject): PPyObject{.cdecl.} + PyBool_FromLong*: proc (ok: int): PPyObject{.cdecl.} #- + Py_AtExit*: proc (proc: proc ()): int{.cdecl.} #- + #Py_Cleanup:procedure; cdecl; + #- + Py_CompileString*: proc (s1, s2: cstring, i: int): PPyObject{.cdecl.} #- + Py_FatalError*: proc (s: cstring){.cdecl.} #- + Py_FindMethod*: proc (md: PPyMethodDef, ob: PPyObject, key: cstring): PPyObject{. + cdecl.} #- + Py_FindMethodInChain*: proc (mc: PPyMethodChain, ob: PPyObject, key: cstring): PPyObject{. + cdecl.} #- + Py_FlushLine*: proc (){.cdecl.} #+ + Py_Finalize*: proc (){.cdecl.} #- + PyErr_ExceptionMatches*: proc (exc: PPyObject): int{.cdecl.} #- + PyErr_GivenExceptionMatches*: proc (raised_exc, exc: PPyObject): int{.cdecl.} #- + PyEval_EvalCode*: proc (co: PPyCodeObject, globals, locals: PPyObject): PPyObject{. + cdecl.} #+ + Py_GetVersion*: proc (): cstring{.cdecl.} #+ + Py_GetCopyright*: proc (): cstring{.cdecl.} #+ + Py_GetExecPrefix*: proc (): cstring{.cdecl.} #+ + Py_GetPath*: proc (): cstring{.cdecl.} #+ + Py_GetPrefix*: proc (): cstring{.cdecl.} #+ + Py_GetProgramName*: proc (): cstring{.cdecl.} #- + PyParser_SimpleParseString*: proc (str: cstring, start: int): PNode{.cdecl.} #- + PyNode_Free*: proc (n: PNode){.cdecl.} #- + PyErr_NewException*: proc (name: cstring, base, dict: PPyObject): PPyObject{. + cdecl.} #- + Py_Malloc*: proc (size: int): Pointer #- + PyMem_Malloc*: proc (size: int): Pointer #- + PyObject_CallMethod*: proc (obj: PPyObject, method, format: cstring): PPyObject{. + cdecl.} #New exported Objects in Python 1.5 + Py_SetProgramName*: proc (name: cstring){.cdecl.} + Py_IsInitialized*: proc (): int{.cdecl.} + Py_GetProgramFullPath*: proc (): cstring{.cdecl.} + Py_NewInterpreter*: proc (): PPyThreadState{.cdecl.} + Py_EndInterpreter*: proc (tstate: PPyThreadState){.cdecl.} + PyEval_AcquireLock*: proc (){.cdecl.} + PyEval_ReleaseLock*: proc (){.cdecl.} + PyEval_AcquireThread*: proc (tstate: PPyThreadState){.cdecl.} + PyEval_ReleaseThread*: proc (tstate: PPyThreadState){.cdecl.} + PyInterpreterState_New*: proc (): PPyInterpreterState{.cdecl.} + PyInterpreterState_Clear*: proc (interp: PPyInterpreterState){.cdecl.} + PyInterpreterState_Delete*: proc (interp: PPyInterpreterState){.cdecl.} + PyThreadState_New*: proc (interp: PPyInterpreterState): PPyThreadState{.cdecl.} + PyThreadState_Clear*: proc (tstate: PPyThreadState){.cdecl.} + PyThreadState_Delete*: proc (tstate: PPyThreadState){.cdecl.} + PyThreadState_Get*: proc (): PPyThreadState{.cdecl.} + PyThreadState_Swap*: proc (tstate: PPyThreadState): PPyThreadState{.cdecl.} + +#Further exported Objects, may be implemented later +# +# PyCode_New: Pointer; +# PyErr_SetInterrupt: Pointer; +# PyFile_AsFile: Pointer; +# PyFile_FromFile: Pointer; +# PyFloat_AsString: Pointer; +# PyFrame_BlockPop: Pointer; +# PyFrame_BlockSetup: Pointer; +# PyFrame_ExtendStack: Pointer; +# PyFrame_FastToLocals: Pointer; +# PyFrame_LocalsToFast: Pointer; +# PyFrame_New: Pointer; +# PyGrammar_AddAccelerators: Pointer; +# PyGrammar_FindDFA: Pointer; +# PyGrammar_LabelRepr: Pointer; +# PyInstance_DoBinOp: Pointer; +# PyInt_GetMax: Pointer; +# PyMarshal_Init: Pointer; +# PyMarshal_ReadLongFromFile: Pointer; +# PyMarshal_ReadObjectFromFile: Pointer; +# PyMarshal_ReadObjectFromString: Pointer; +# PyMarshal_WriteLongToFile: Pointer; +# PyMarshal_WriteObjectToFile: Pointer; +# PyMember_Get: Pointer; +# PyMember_Set: Pointer; +# PyNode_AddChild: Pointer; +# PyNode_Compile: Pointer; +# PyNode_New: Pointer; +# PyOS_GetLastModificationTime: Pointer; +# PyOS_Readline: Pointer; +# PyOS_strtol: Pointer; +# PyOS_strtoul: Pointer; +# PyObject_CallFunction: Pointer; +# PyObject_CallMethod: Pointer; +# PyObject_Print: Pointer; +# PyParser_AddToken: Pointer; +# PyParser_Delete: Pointer; +# PyParser_New: Pointer; +# PyParser_ParseFile: Pointer; +# PyParser_ParseString: Pointer; +# PyParser_SimpleParseFile: Pointer; +# PyRun_AnyFile: Pointer; +# PyRun_File: Pointer; +# PyRun_InteractiveLoop: Pointer; +# PyRun_InteractiveOne: Pointer; +# PyRun_SimpleFile: Pointer; +# PySys_GetFile: Pointer; +# PyToken_OneChar: Pointer; +# PyToken_TwoChars: Pointer; +# PyTokenizer_Free: Pointer; +# PyTokenizer_FromFile: Pointer; +# PyTokenizer_FromString: Pointer; +# PyTokenizer_Get: Pointer; +# Py_Main: Pointer; +# _PyObject_NewVar: Pointer; +# _PyParser_Grammar: Pointer; +# _PyParser_TokenNames: Pointer; +# _PyThread_Started: Pointer; +# _Py_c_diff: Pointer; +# _Py_c_neg: Pointer; +# _Py_c_pow: Pointer; +# _Py_c_prod: Pointer; +# _Py_c_quot: Pointer; +# _Py_c_sum: Pointer; +# + +# This function handles all cardinals, pointer types (with no adjustment of pointers!) +# (Extended) floats, which are handled as Python doubles and currencies, handled +# as (normalized) Python doubles. +proc PyImport_ExecCodeModule*(name: String, codeobject: PPyObject): PPyObject +proc PyString_Check*(obj: PPyObject): bool +proc PyString_CheckExact*(obj: PPyObject): bool +proc PyFloat_Check*(obj: PPyObject): bool +proc PyFloat_CheckExact*(obj: PPyObject): bool +proc PyInt_Check*(obj: PPyObject): bool +proc PyInt_CheckExact*(obj: PPyObject): bool +proc PyLong_Check*(obj: PPyObject): bool +proc PyLong_CheckExact*(obj: PPyObject): bool +proc PyTuple_Check*(obj: PPyObject): bool +proc PyTuple_CheckExact*(obj: PPyObject): bool +proc PyInstance_Check*(obj: PPyObject): bool +proc PyClass_Check*(obj: PPyObject): bool +proc PyMethod_Check*(obj: PPyObject): bool +proc PyList_Check*(obj: PPyObject): bool +proc PyList_CheckExact*(obj: PPyObject): bool +proc PyDict_Check*(obj: PPyObject): bool +proc PyDict_CheckExact*(obj: PPyObject): bool +proc PyModule_Check*(obj: PPyObject): bool +proc PyModule_CheckExact*(obj: PPyObject): bool +proc PySlice_Check*(obj: PPyObject): bool +proc PyFunction_Check*(obj: PPyObject): bool +proc PyUnicode_Check*(obj: PPyObject): bool +proc PyUnicode_CheckExact*(obj: PPyObject): bool +proc PyType_IS_GC*(t: PPyTypeObject): bool +proc PyObject_IS_GC*(obj: PPyObject): bool +proc PyWeakref_Check*(obj: PPyObject): bool +proc PyWeakref_CheckRef*(obj: PPyObject): bool +proc PyWeakref_CheckProxy*(obj: PPyObject): bool +proc PyBool_Check*(obj: PPyObject): bool +proc PyBaseString_Check*(obj: PPyObject): bool +proc PyEnum_Check*(obj: PPyObject): bool +proc PyObject_TypeCheck*(obj: PPyObject, t: PPyTypeObject): bool +proc Py_InitModule*(name: cstring, md: PPyMethodDef): PPyObject +proc PyType_HasFeature*(AType: PPyTypeObject, AFlag: int): bool +# implementation + +proc Py_INCREF*(op: PPyObject) {.inline.} = + Inc(op.ob_refcnt) + +proc Py_DECREF*(op: PPyObject) {.inline.} = + Dec(op.ob_refcnt) + if op.ob_refcnt == 0: + op.ob_type.tp_dealloc(op) + +proc Py_XINCREF*(op: PPyObject) {.inline.} = + if op != nil: Py_INCREF(op) + +proc Py_XDECREF*(op: PPyObject) {.inline.} = + if op != nil: Py_DECREF(op) + +proc PyImport_ExecCodeModule(name: String, codeobject: PPyObject): PPyObject = + var m, d, v, modules: PPyObject + m = PyImport_AddModule(cstring(name)) + if m == nil: + return nil + d = PyModule_GetDict(m) + if PyDict_GetItemString(d, "__builtins__") == nil: + if PyDict_SetItemString(d, "__builtins__", PyEval_GetBuiltins) != 0: + return nil + if PyDict_SetItemString(d, "__file__", PPyCodeObject(codeobject).co_filename) != + 0: + PyErr_Clear() # Not important enough to report + v = PyEval_EvalCode(PPyCodeObject(codeobject), d, d) # XXX owner ? + if v == nil: + return nil + Py_XDECREF(v) + modules = PyImport_GetModuleDict() + if PyDict_GetItemString(modules, cstring(name)) == nil: + PyErr_SetString(PyExc_ImportError^ , cstring( + Format("Loaded module %.200s not found in sys.modules", [name]))) + return nil + Py_XINCREF(m) + Result = m + +proc PyString_Check(obj: PPyObject): bool = + Result = PyObject_TypeCheck(obj, PyString_Type) + +proc PyString_CheckExact(obj: PPyObject): bool = + Result = (obj != nil) and (obj.ob_type == PPyTypeObject(PyString_Type)) + +proc PyFloat_Check(obj: PPyObject): bool = + Result = PyObject_TypeCheck(obj, PyFloat_Type) + +proc PyFloat_CheckExact(obj: PPyObject): bool = + Result = (obj != nil) and (obj.ob_type == PPyTypeObject(PyFloat_Type)) + +proc PyInt_Check(obj: PPyObject): bool = + Result = PyObject_TypeCheck(obj, PyInt_Type) + +proc PyInt_CheckExact(obj: PPyObject): bool = + Result = (obj != nil) and (obj.ob_type == PPyTypeObject(PyInt_Type)) + +proc PyLong_Check(obj: PPyObject): bool = + Result = PyObject_TypeCheck(obj, PyLong_Type) + +proc PyLong_CheckExact(obj: PPyObject): bool = + Result = (obj != nil) and (obj.ob_type == PPyTypeObject(PyLong_Type)) + +proc PyTuple_Check(obj: PPyObject): bool = + Result = PyObject_TypeCheck(obj, PyTuple_Type) + +proc PyTuple_CheckExact(obj: PPyObject): bool = + Result = (obj != nil) and (obj^ .ob_type == PPyTypeObject(PyTuple_Type)) + +proc PyInstance_Check(obj: PPyObject): bool = + Result = (obj != nil) and (obj^ .ob_type == PPyTypeObject(PyInstance_Type)) + +proc PyClass_Check(obj: PPyObject): bool = + Result = (obj != nil) and (obj^ .ob_type == PPyTypeObject(PyClass_Type)) + +proc PyMethod_Check(obj: PPyObject): bool = + Result = (obj != nil) and (obj^ .ob_type == PPyTypeObject(PyMethod_Type)) + +proc PyList_Check(obj: PPyObject): bool = + Result = PyObject_TypeCheck(obj, PyList_Type) + +proc PyList_CheckExact(obj: PPyObject): bool = + Result = (obj != nil) and (obj^ .ob_type == PPyTypeObject(PyList_Type)) + +proc PyDict_Check(obj: PPyObject): bool = + Result = PyObject_TypeCheck(obj, PyDict_Type) + +proc PyDict_CheckExact(obj: PPyObject): bool = + Result = (obj != nil) and (obj^ .ob_type == PPyTypeObject(PyDict_Type)) + +proc PyModule_Check(obj: PPyObject): bool = + Result = PyObject_TypeCheck(obj, PyModule_Type) + +proc PyModule_CheckExact(obj: PPyObject): bool = + Result = (obj != nil) and (obj^ .ob_type == PPyTypeObject(PyModule_Type)) + +proc PySlice_Check(obj: PPyObject): bool = + Result = (obj != nil) and (obj^ .ob_type == PPyTypeObject(PySlice_Type)) + +proc PyFunction_Check(obj: PPyObject): bool = + Result = (obj != nil) and + ((obj.ob_type == PPyTypeObject(PyCFunction_Type)) or + (obj.ob_type == PPyTypeObject(PyFunction_Type))) + +proc PyUnicode_Check(obj: PPyObject): bool = + Result = PyObject_TypeCheck(obj, PyUnicode_Type) + +proc PyUnicode_CheckExact(obj: PPyObject): bool = + Result = (obj != nil) and (obj^ .ob_type == PPyTypeObject(PyUnicode_Type)) + +proc PyType_IS_GC(t: PPyTypeObject): bool = + Result = PyType_HasFeature(t, Py_TPFLAGS_HAVE_GC) + +proc PyObject_IS_GC(obj: PPyObject): bool = + Result = PyType_IS_GC(obj.ob_type) and + ((obj.ob_type.tp_is_gc == nil) or (obj.ob_type.tp_is_gc(obj) == 1)) + +proc PyWeakref_Check(obj: PPyObject): bool = + Result = (obj != nil) and + (PyWeakref_CheckRef(obj) or PyWeakref_CheckProxy(obj)) + +proc PyWeakref_CheckRef(obj: PPyObject): bool = + Result = (obj != nil) and (obj.ob_type == PPyTypeObject(PyWeakref_RefType)) + +proc PyWeakref_CheckProxy(obj: PPyObject): bool = + Result = (obj != nil) and + ((obj.ob_type == PPyTypeObject(PyWeakref_ProxyType)) or + (obj.ob_type == PPyTypeObject(PyWeakref_CallableProxyType))) + +proc PyBool_Check(obj: PPyObject): bool = + Result = (obj != nil) and (obj.ob_type == PPyTypeObject(PyBool_Type)) + +proc PyBaseString_Check(obj: PPyObject): bool = + Result = PyObject_TypeCheck(obj, PyBaseString_Type) + +proc PyEnum_Check(obj: PPyObject): bool = + Result = (obj != nil) and (obj.ob_type == PPyTypeObject(PyEnum_Type)) + +proc PyObject_TypeCheck(obj: PPyObject, t: PPyTypeObject): bool = + Result = (obj != nil) and (obj.ob_type == t) + if not Result and (obj != nil) and (t != nil): + Result = PyType_IsSubtype(obj.ob_type, t) == 1 + +proc Py_InitModule(name: cstring, md: PPyMethodDef): PPyObject = + result = Py_InitModule4(name, md, nil, nil, 1012) + +proc PyType_HasFeature(AType: PPyTypeObject, AFlag: int): bool = + #(((t)->tp_flags & (f)) != 0) + Result = (AType.tp_flags and AFlag) != 0 + +proc init(lib: TLibHandle) = + Py_DebugFlag = getProcAddr(lib, "Py_DebugFlag") + Py_VerboseFlag = getProcAddr(lib, "Py_VerboseFlag") + Py_InteractiveFlag = getProcAddr(lib, "Py_InteractiveFlag") + Py_OptimizeFlag = getProcAddr(lib, "Py_OptimizeFlag") + Py_NoSiteFlag = getProcAddr(lib, "Py_NoSiteFlag") + Py_UseClassExceptionsFlag = getProcAddr(lib, "Py_UseClassExceptionsFlag") + Py_FrozenFlag = getProcAddr(lib, "Py_FrozenFlag") + Py_TabcheckFlag = getProcAddr(lib, "Py_TabcheckFlag") + Py_UnicodeFlag = getProcAddr(lib, "Py_UnicodeFlag") + Py_IgnoreEnvironmentFlag = getProcAddr(lib, "Py_IgnoreEnvironmentFlag") + Py_DivisionWarningFlag = getProcAddr(lib, "Py_DivisionWarningFlag") + Py_None = getProcAddr(lib, "_Py_NoneStruct") + Py_Ellipsis = getProcAddr(lib, "_Py_EllipsisObject") + Py_False = getProcAddr(lib, "_Py_ZeroStruct") + Py_True = getProcAddr(lib, "_Py_TrueStruct") + Py_NotImplemented = getProcAddr(lib, "_Py_NotImplementedStruct") + PyImport_FrozenModules = getProcAddr(lib, "PyImport_FrozenModules") + PyExc_AttributeError = getProcAddr(lib, "PyExc_AttributeError") + PyExc_EOFError = getProcAddr(lib, "PyExc_EOFError") + PyExc_IOError = getProcAddr(lib, "PyExc_IOError") + PyExc_ImportError = getProcAddr(lib, "PyExc_ImportError") + PyExc_IndexError = getProcAddr(lib, "PyExc_IndexError") + PyExc_KeyError = getProcAddr(lib, "PyExc_KeyError") + PyExc_KeyboardInterrupt = getProcAddr(lib, "PyExc_KeyboardInterrupt") + PyExc_MemoryError = getProcAddr(lib, "PyExc_MemoryError") + PyExc_NameError = getProcAddr(lib, "PyExc_NameError") + PyExc_OverflowError = getProcAddr(lib, "PyExc_OverflowError") + PyExc_RuntimeError = getProcAddr(lib, "PyExc_RuntimeError") + PyExc_SyntaxError = getProcAddr(lib, "PyExc_SyntaxError") + PyExc_SystemError = getProcAddr(lib, "PyExc_SystemError") + PyExc_SystemExit = getProcAddr(lib, "PyExc_SystemExit") + PyExc_TypeError = getProcAddr(lib, "PyExc_TypeError") + PyExc_ValueError = getProcAddr(lib, "PyExc_ValueError") + PyExc_ZeroDivisionError = getProcAddr(lib, "PyExc_ZeroDivisionError") + PyExc_ArithmeticError = getProcAddr(lib, "PyExc_ArithmeticError") + PyExc_Exception = getProcAddr(lib, "PyExc_Exception") + PyExc_FloatingPointError = getProcAddr(lib, "PyExc_FloatingPointError") + PyExc_LookupError = getProcAddr(lib, "PyExc_LookupError") + PyExc_StandardError = getProcAddr(lib, "PyExc_StandardError") + PyExc_AssertionError = getProcAddr(lib, "PyExc_AssertionError") + PyExc_EnvironmentError = getProcAddr(lib, "PyExc_EnvironmentError") + PyExc_IndentationError = getProcAddr(lib, "PyExc_IndentationError") + PyExc_MemoryErrorInst = getProcAddr(lib, "PyExc_MemoryErrorInst") + PyExc_NotImplementedError = getProcAddr(lib, "PyExc_NotImplementedError") + PyExc_OSError = getProcAddr(lib, "PyExc_OSError") + PyExc_TabError = getProcAddr(lib, "PyExc_TabError") + PyExc_UnboundLocalError = getProcAddr(lib, "PyExc_UnboundLocalError") + PyExc_UnicodeError = getProcAddr(lib, "PyExc_UnicodeError") + PyExc_Warning = getProcAddr(lib, "PyExc_Warning") + PyExc_DeprecationWarning = getProcAddr(lib, "PyExc_DeprecationWarning") + PyExc_RuntimeWarning = getProcAddr(lib, "PyExc_RuntimeWarning") + PyExc_SyntaxWarning = getProcAddr(lib, "PyExc_SyntaxWarning") + PyExc_UserWarning = getProcAddr(lib, "PyExc_UserWarning") + PyExc_OverflowWarning = getProcAddr(lib, "PyExc_OverflowWarning") + PyExc_ReferenceError = getProcAddr(lib, "PyExc_ReferenceError") + PyExc_StopIteration = getProcAddr(lib, "PyExc_StopIteration") + PyExc_FutureWarning = getProcAddr(lib, "PyExc_FutureWarning") + PyExc_PendingDeprecationWarning = getProcAddr(lib, + "PyExc_PendingDeprecationWarning") + PyExc_UnicodeDecodeError = getProcAddr(lib, "PyExc_UnicodeDecodeError") + PyExc_UnicodeEncodeError = getProcAddr(lib, "PyExc_UnicodeEncodeError") + PyExc_UnicodeTranslateError = getProcAddr(lib, "PyExc_UnicodeTranslateError") + PyType_Type = getProcAddr(lib, "PyType_Type") + PyCFunction_Type = getProcAddr(lib, "PyCFunction_Type") + PyCObject_Type = getProcAddr(lib, "PyCObject_Type") + PyClass_Type = getProcAddr(lib, "PyClass_Type") + PyCode_Type = getProcAddr(lib, "PyCode_Type") + PyComplex_Type = getProcAddr(lib, "PyComplex_Type") + PyDict_Type = getProcAddr(lib, "PyDict_Type") + PyFile_Type = getProcAddr(lib, "PyFile_Type") + PyFloat_Type = getProcAddr(lib, "PyFloat_Type") + PyFrame_Type = getProcAddr(lib, "PyFrame_Type") + PyFunction_Type = getProcAddr(lib, "PyFunction_Type") + PyInstance_Type = getProcAddr(lib, "PyInstance_Type") + PyInt_Type = getProcAddr(lib, "PyInt_Type") + PyList_Type = getProcAddr(lib, "PyList_Type") + PyLong_Type = getProcAddr(lib, "PyLong_Type") + PyMethod_Type = getProcAddr(lib, "PyMethod_Type") + PyModule_Type = getProcAddr(lib, "PyModule_Type") + PyObject_Type = getProcAddr(lib, "PyObject_Type") + PyRange_Type = getProcAddr(lib, "PyRange_Type") + PySlice_Type = getProcAddr(lib, "PySlice_Type") + PyString_Type = getProcAddr(lib, "PyString_Type") + PyTuple_Type = getProcAddr(lib, "PyTuple_Type") + PyUnicode_Type = getProcAddr(lib, "PyUnicode_Type") + PyBaseObject_Type = getProcAddr(lib, "PyBaseObject_Type") + PyBuffer_Type = getProcAddr(lib, "PyBuffer_Type") + PyCallIter_Type = getProcAddr(lib, "PyCallIter_Type") + PyCell_Type = getProcAddr(lib, "PyCell_Type") + PyClassMethod_Type = getProcAddr(lib, "PyClassMethod_Type") + PyProperty_Type = getProcAddr(lib, "PyProperty_Type") + PySeqIter_Type = getProcAddr(lib, "PySeqIter_Type") + PyStaticMethod_Type = getProcAddr(lib, "PyStaticMethod_Type") + PySuper_Type = getProcAddr(lib, "PySuper_Type") + PySymtableEntry_Type = getProcAddr(lib, "PySymtableEntry_Type") + PyTraceBack_Type = getProcAddr(lib, "PyTraceBack_Type") + PyWrapperDescr_Type = getProcAddr(lib, "PyWrapperDescr_Type") + PyBaseString_Type = getProcAddr(lib, "PyBaseString_Type") + PyBool_Type = getProcAddr(lib, "PyBool_Type") + PyEnum_Type = getProcAddr(lib, "PyEnum_Type") #PyArg_GetObject := getProcAddr(lib, 'PyArg_GetObject'); + #PyArg_GetLong := getProcAddr(lib, 'PyArg_GetLong'); + #PyArg_GetShort := getProcAddr(lib, 'PyArg_GetShort'); + #PyArg_GetFloat := getProcAddr(lib, 'PyArg_GetFloat'); + #PyArg_GetString := getProcAddr(lib, 'PyArg_GetString'); + #PyArgs_VaParse := getProcAddr(lib, 'PyArgs_VaParse'); + #Py_VaBuildValue := getProcAddr(lib, 'Py_VaBuildValue'); + #PyBuiltin_Init := getProcAddr(lib, 'PyBuiltin_Init'); + PyComplex_FromCComplex = getProcAddr(lib, "PyComplex_FromCComplex") + PyComplex_FromDoubles = getProcAddr(lib, "PyComplex_FromDoubles") + PyComplex_RealAsDouble = getProcAddr(lib, "PyComplex_RealAsDouble") + PyComplex_ImagAsDouble = getProcAddr(lib, "PyComplex_ImagAsDouble") + PyComplex_AsCComplex = getProcAddr(lib, "PyComplex_AsCComplex") + PyCFunction_GetFunction = getProcAddr(lib, "PyCFunction_GetFunction") + PyCFunction_GetSelf = getProcAddr(lib, "PyCFunction_GetSelf") + PyCallable_Check = getProcAddr(lib, "PyCallable_Check") + PyCObject_FromVoidPtr = getProcAddr(lib, "PyCObject_FromVoidPtr") + PyCObject_AsVoidPtr = getProcAddr(lib, "PyCObject_AsVoidPtr") + PyClass_New = getProcAddr(lib, "PyClass_New") + PyClass_IsSubclass = getProcAddr(lib, "PyClass_IsSubclass") + PyDict_GetItem = getProcAddr(lib, "PyDict_GetItem") + PyDict_SetItem = getProcAddr(lib, "PyDict_SetItem") + PyDict_DelItem = getProcAddr(lib, "PyDict_DelItem") + PyDict_Clear = getProcAddr(lib, "PyDict_Clear") + PyDict_Next = getProcAddr(lib, "PyDict_Next") + PyDict_Keys = getProcAddr(lib, "PyDict_Keys") + PyDict_Values = getProcAddr(lib, "PyDict_Values") + PyDict_Items = getProcAddr(lib, "PyDict_Items") + PyDict_Size = getProcAddr(lib, "PyDict_Size") + PyDict_DelItemString = getProcAddr(lib, "PyDict_DelItemString") + PyDictProxy_New = getProcAddr(lib, "PyDictProxy_New") + Py_InitModule4 = getProcAddr(lib, "Py_InitModule4") + PyErr_Print = getProcAddr(lib, "PyErr_Print") + PyErr_SetNone = getProcAddr(lib, "PyErr_SetNone") + PyErr_SetObject = getProcAddr(lib, "PyErr_SetObject") + PyErr_Restore = getProcAddr(lib, "PyErr_Restore") + PyErr_BadArgument = getProcAddr(lib, "PyErr_BadArgument") + PyErr_NoMemory = getProcAddr(lib, "PyErr_NoMemory") + PyErr_SetFromErrno = getProcAddr(lib, "PyErr_SetFromErrno") + PyErr_BadInternalCall = getProcAddr(lib, "PyErr_BadInternalCall") + PyErr_CheckSignals = getProcAddr(lib, "PyErr_CheckSignals") + PyErr_Occurred = getProcAddr(lib, "PyErr_Occurred") + PyErr_Clear = getProcAddr(lib, "PyErr_Clear") + PyErr_Fetch = getProcAddr(lib, "PyErr_Fetch") + PyErr_SetString = getProcAddr(lib, "PyErr_SetString") + PyEval_GetBuiltins = getProcAddr(lib, "PyEval_GetBuiltins") + PyImport_GetModuleDict = getProcAddr(lib, "PyImport_GetModuleDict") + PyInt_FromLong = getProcAddr(lib, "PyInt_FromLong") + PyArg_ParseTuple = getProcAddr(lib, "PyArg_ParseTuple") + PyArg_Parse = getProcAddr(lib, "PyArg_Parse") + Py_BuildValue = getProcAddr(lib, "Py_BuildValue") + Py_Initialize = getProcAddr(lib, "Py_Initialize") + PyDict_New = getProcAddr(lib, "PyDict_New") + PyDict_SetItemString = getProcAddr(lib, "PyDict_SetItemString") + PyModule_GetDict = getProcAddr(lib, "PyModule_GetDict") + PyObject_Str = getProcAddr(lib, "PyObject_Str") + PyRun_String = getProcAddr(lib, "PyRun_String") + PyRun_SimpleString = getProcAddr(lib, "PyRun_SimpleString") + PyDict_GetItemString = getProcAddr(lib, "PyDict_GetItemString") + PyString_AsString = getProcAddr(lib, "PyString_AsString") + PyString_FromString = getProcAddr(lib, "PyString_FromString") + PySys_SetArgv = getProcAddr(lib, "PySys_SetArgv") + Py_Exit = getProcAddr(lib, "Py_Exit") + PyCFunction_New = getProcAddr(lib, "PyCFunction_New") + PyEval_CallObject = getProcAddr(lib, "PyEval_CallObject") + PyEval_CallObjectWithKeywords = getProcAddr(lib, + "PyEval_CallObjectWithKeywords") + PyEval_GetFrame = getProcAddr(lib, "PyEval_GetFrame") + PyEval_GetGlobals = getProcAddr(lib, "PyEval_GetGlobals") + PyEval_GetLocals = getProcAddr(lib, "PyEval_GetLocals") #PyEval_GetOwner :=getProcAddr(lib, 'PyEval_GetOwner'); + PyEval_GetRestricted = getProcAddr(lib, "PyEval_GetRestricted") + PyEval_InitThreads = getProcAddr(lib, "PyEval_InitThreads") + PyEval_RestoreThread = getProcAddr(lib, "PyEval_RestoreThread") + PyEval_SaveThread = getProcAddr(lib, "PyEval_SaveThread") + PyFile_FromString = getProcAddr(lib, "PyFile_FromString") + PyFile_GetLine = getProcAddr(lib, "PyFile_GetLine") + PyFile_Name = getProcAddr(lib, "PyFile_Name") + PyFile_SetBufSize = getProcAddr(lib, "PyFile_SetBufSize") + PyFile_SoftSpace = getProcAddr(lib, "PyFile_SoftSpace") + PyFile_WriteObject = getProcAddr(lib, "PyFile_WriteObject") + PyFile_WriteString = getProcAddr(lib, "PyFile_WriteString") + PyFloat_AsDouble = getProcAddr(lib, "PyFloat_AsDouble") + PyFloat_FromDouble = getProcAddr(lib, "PyFloat_FromDouble") + PyFunction_GetCode = getProcAddr(lib, "PyFunction_GetCode") + PyFunction_GetGlobals = getProcAddr(lib, "PyFunction_GetGlobals") + PyFunction_New = getProcAddr(lib, "PyFunction_New") + PyImport_AddModule = getProcAddr(lib, "PyImport_AddModule") + PyImport_Cleanup = getProcAddr(lib, "PyImport_Cleanup") + PyImport_GetMagicNumber = getProcAddr(lib, "PyImport_GetMagicNumber") + PyImport_ImportFrozenModule = getProcAddr(lib, "PyImport_ImportFrozenModule") + PyImport_ImportModule = getProcAddr(lib, "PyImport_ImportModule") + PyImport_Import = getProcAddr(lib, "PyImport_Import") #@PyImport_Init :=getProcAddr(lib, 'PyImport_Init'); + PyImport_ReloadModule = getProcAddr(lib, "PyImport_ReloadModule") + PyInstance_New = getProcAddr(lib, "PyInstance_New") + PyInt_AsLong = getProcAddr(lib, "PyInt_AsLong") + PyList_Append = getProcAddr(lib, "PyList_Append") + PyList_AsTuple = getProcAddr(lib, "PyList_AsTuple") + PyList_GetItem = getProcAddr(lib, "PyList_GetItem") + PyList_GetSlice = getProcAddr(lib, "PyList_GetSlice") + PyList_Insert = getProcAddr(lib, "PyList_Insert") + PyList_New = getProcAddr(lib, "PyList_New") + PyList_Reverse = getProcAddr(lib, "PyList_Reverse") + PyList_SetItem = getProcAddr(lib, "PyList_SetItem") + PyList_SetSlice = getProcAddr(lib, "PyList_SetSlice") + PyList_Size = getProcAddr(lib, "PyList_Size") + PyList_Sort = getProcAddr(lib, "PyList_Sort") + PyLong_AsDouble = getProcAddr(lib, "PyLong_AsDouble") + PyLong_AsLong = getProcAddr(lib, "PyLong_AsLong") + PyLong_FromDouble = getProcAddr(lib, "PyLong_FromDouble") + PyLong_FromLong = getProcAddr(lib, "PyLong_FromLong") + PyLong_FromString = getProcAddr(lib, "PyLong_FromString") + PyLong_FromString = getProcAddr(lib, "PyLong_FromString") + PyLong_FromUnsignedLong = getProcAddr(lib, "PyLong_FromUnsignedLong") + PyLong_AsUnsignedLong = getProcAddr(lib, "PyLong_AsUnsignedLong") + PyLong_FromUnicode = getProcAddr(lib, "PyLong_FromUnicode") + PyLong_FromLongLong = getProcAddr(lib, "PyLong_FromLongLong") + PyLong_AsLongLong = getProcAddr(lib, "PyLong_AsLongLong") + PyMapping_Check = getProcAddr(lib, "PyMapping_Check") + PyMapping_GetItemString = getProcAddr(lib, "PyMapping_GetItemString") + PyMapping_HasKey = getProcAddr(lib, "PyMapping_HasKey") + PyMapping_HasKeyString = getProcAddr(lib, "PyMapping_HasKeyString") + PyMapping_Length = getProcAddr(lib, "PyMapping_Length") + PyMapping_SetItemString = getProcAddr(lib, "PyMapping_SetItemString") + PyMethod_Class = getProcAddr(lib, "PyMethod_Class") + PyMethod_Function = getProcAddr(lib, "PyMethod_Function") + PyMethod_New = getProcAddr(lib, "PyMethod_New") + PyMethod_Self = getProcAddr(lib, "PyMethod_Self") + PyModule_GetName = getProcAddr(lib, "PyModule_GetName") + PyModule_New = getProcAddr(lib, "PyModule_New") + PyNumber_Absolute = getProcAddr(lib, "PyNumber_Absolute") + PyNumber_Add = getProcAddr(lib, "PyNumber_Add") + PyNumber_And = getProcAddr(lib, "PyNumber_And") + PyNumber_Check = getProcAddr(lib, "PyNumber_Check") + PyNumber_Coerce = getProcAddr(lib, "PyNumber_Coerce") + PyNumber_Divide = getProcAddr(lib, "PyNumber_Divide") + PyNumber_FloorDivide = getProcAddr(lib, "PyNumber_FloorDivide") + PyNumber_TrueDivide = getProcAddr(lib, "PyNumber_TrueDivide") + PyNumber_Divmod = getProcAddr(lib, "PyNumber_Divmod") + PyNumber_Float = getProcAddr(lib, "PyNumber_Float") + PyNumber_Int = getProcAddr(lib, "PyNumber_Int") + PyNumber_Invert = getProcAddr(lib, "PyNumber_Invert") + PyNumber_Long = getProcAddr(lib, "PyNumber_Long") + PyNumber_Lshift = getProcAddr(lib, "PyNumber_Lshift") + PyNumber_Multiply = getProcAddr(lib, "PyNumber_Multiply") + PyNumber_Negative = getProcAddr(lib, "PyNumber_Negative") + PyNumber_Or = getProcAddr(lib, "PyNumber_Or") + PyNumber_Positive = getProcAddr(lib, "PyNumber_Positive") + PyNumber_Power = getProcAddr(lib, "PyNumber_Power") + PyNumber_Remainder = getProcAddr(lib, "PyNumber_Remainder") + PyNumber_Rshift = getProcAddr(lib, "PyNumber_Rshift") + PyNumber_Subtract = getProcAddr(lib, "PyNumber_Subtract") + PyNumber_Xor = getProcAddr(lib, "PyNumber_Xor") + PyOS_InitInterrupts = getProcAddr(lib, "PyOS_InitInterrupts") + PyOS_InterruptOccurred = getProcAddr(lib, "PyOS_InterruptOccurred") + PyObject_CallObject = getProcAddr(lib, "PyObject_CallObject") + PyObject_Compare = getProcAddr(lib, "PyObject_Compare") + PyObject_GetAttr = getProcAddr(lib, "PyObject_GetAttr") + PyObject_GetAttrString = getProcAddr(lib, "PyObject_GetAttrString") + PyObject_GetItem = getProcAddr(lib, "PyObject_GetItem") + PyObject_DelItem = getProcAddr(lib, "PyObject_DelItem") + PyObject_HasAttrString = getProcAddr(lib, "PyObject_HasAttrString") + PyObject_Hash = getProcAddr(lib, "PyObject_Hash") + PyObject_IsTrue = getProcAddr(lib, "PyObject_IsTrue") + PyObject_Length = getProcAddr(lib, "PyObject_Length") + PyObject_Repr = getProcAddr(lib, "PyObject_Repr") + PyObject_SetAttr = getProcAddr(lib, "PyObject_SetAttr") + PyObject_SetAttrString = getProcAddr(lib, "PyObject_SetAttrString") + PyObject_SetItem = getProcAddr(lib, "PyObject_SetItem") + PyObject_Init = getProcAddr(lib, "PyObject_Init") + PyObject_InitVar = getProcAddr(lib, "PyObject_InitVar") + PyObject_New = getProcAddr(lib, "_PyObject_New") + PyObject_NewVar = getProcAddr(lib, "_PyObject_NewVar") + PyObject_Free = getProcAddr(lib, "PyObject_Free") + PyObject_IsInstance = getProcAddr(lib, "PyObject_IsInstance") + PyObject_IsSubclass = getProcAddr(lib, "PyObject_IsSubclass") + PyObject_GenericGetAttr = getProcAddr(lib, "PyObject_GenericGetAttr") + PyObject_GenericSetAttr = getProcAddr(lib, "PyObject_GenericSetAttr") + PyObject_GC_Malloc = getProcAddr(lib, "_PyObject_GC_Malloc") + PyObject_GC_New = getProcAddr(lib, "_PyObject_GC_New") + PyObject_GC_NewVar = getProcAddr(lib, "_PyObject_GC_NewVar") + PyObject_GC_Resize = getProcAddr(lib, "_PyObject_GC_Resize") + PyObject_GC_Del = getProcAddr(lib, "PyObject_GC_Del") + PyObject_GC_Track = getProcAddr(lib, "PyObject_GC_Track") + PyObject_GC_UnTrack = getProcAddr(lib, "PyObject_GC_UnTrack") + PyRange_New = getProcAddr(lib, "PyRange_New") + PySequence_Check = getProcAddr(lib, "PySequence_Check") + PySequence_Concat = getProcAddr(lib, "PySequence_Concat") + PySequence_Count = getProcAddr(lib, "PySequence_Count") + PySequence_GetItem = getProcAddr(lib, "PySequence_GetItem") + PySequence_GetSlice = getProcAddr(lib, "PySequence_GetSlice") + PySequence_In = getProcAddr(lib, "PySequence_In") + PySequence_Index = getProcAddr(lib, "PySequence_Index") + PySequence_Length = getProcAddr(lib, "PySequence_Length") + PySequence_Repeat = getProcAddr(lib, "PySequence_Repeat") + PySequence_SetItem = getProcAddr(lib, "PySequence_SetItem") + PySequence_SetSlice = getProcAddr(lib, "PySequence_SetSlice") + PySequence_DelSlice = getProcAddr(lib, "PySequence_DelSlice") + PySequence_Tuple = getProcAddr(lib, "PySequence_Tuple") + PySequence_Contains = getProcAddr(lib, "PySequence_Contains") + PySlice_GetIndices = getProcAddr(lib, "PySlice_GetIndices") + PySlice_GetIndicesEx = getProcAddr(lib, "PySlice_GetIndicesEx") + PySlice_New = getProcAddr(lib, "PySlice_New") + PyString_Concat = getProcAddr(lib, "PyString_Concat") + PyString_ConcatAndDel = getProcAddr(lib, "PyString_ConcatAndDel") + PyString_Format = getProcAddr(lib, "PyString_Format") + PyString_FromStringAndSize = getProcAddr(lib, "PyString_FromStringAndSize") + PyString_Size = getProcAddr(lib, "PyString_Size") + PyString_DecodeEscape = getProcAddr(lib, "PyString_DecodeEscape") + PyString_Repr = getProcAddr(lib, "PyString_Repr") + PySys_GetObject = getProcAddr(lib, "PySys_GetObject") #PySys_Init :=getProcAddr(lib, 'PySys_Init'); + PySys_SetObject = getProcAddr(lib, "PySys_SetObject") + PySys_SetPath = getProcAddr(lib, "PySys_SetPath") #PyTraceBack_Fetch :=getProcAddr(lib, 'PyTraceBack_Fetch'); + PyTraceBack_Here = getProcAddr(lib, "PyTraceBack_Here") + PyTraceBack_Print = getProcAddr(lib, "PyTraceBack_Print") #PyTraceBack_Store :=getProcAddr(lib, 'PyTraceBack_Store'); + PyTuple_GetItem = getProcAddr(lib, "PyTuple_GetItem") + PyTuple_GetSlice = getProcAddr(lib, "PyTuple_GetSlice") + PyTuple_New = getProcAddr(lib, "PyTuple_New") + PyTuple_SetItem = getProcAddr(lib, "PyTuple_SetItem") + PyTuple_Size = getProcAddr(lib, "PyTuple_Size") + PyType_IsSubtype = getProcAddr(lib, "PyType_IsSubtype") + PyType_GenericAlloc = getProcAddr(lib, "PyType_GenericAlloc") + PyType_GenericNew = getProcAddr(lib, "PyType_GenericNew") + PyType_Ready = getProcAddr(lib, "PyType_Ready") + PyUnicode_FromWideChar = getProcAddr(lib, "PyUnicodeUCS2_FromWideChar") + PyUnicode_AsWideChar = getProcAddr(lib, "PyUnicodeUCS2_AsWideChar") + PyUnicode_FromOrdinal = getProcAddr(lib, "PyUnicodeUCS2_FromOrdinal") + PyWeakref_GetObject = getProcAddr(lib, "PyWeakref_GetObject") + PyWeakref_NewProxy = getProcAddr(lib, "PyWeakref_NewProxy") + PyWeakref_NewRef = getProcAddr(lib, "PyWeakref_NewRef") + PyWrapper_New = getProcAddr(lib, "PyWrapper_New") + PyBool_FromLong = getProcAddr(lib, "PyBool_FromLong") + Py_AtExit = getProcAddr(lib, "Py_AtExit") #Py_Cleanup :=getProcAddr(lib, 'Py_Cleanup'); + Py_CompileString = getProcAddr(lib, "Py_CompileString") + Py_FatalError = getProcAddr(lib, "Py_FatalError") + Py_FindMethod = getProcAddr(lib, "Py_FindMethod") + Py_FindMethodInChain = getProcAddr(lib, "Py_FindMethodInChain") + Py_FlushLine = getProcAddr(lib, "Py_FlushLine") + Py_Finalize = getProcAddr(lib, "Py_Finalize") + PyCode_Addr2Line = getProcAddr(lib, "PyCode_Addr2Line") + PyClass_IsSubclass = getProcAddr(lib, "PyClass_IsSubclass") + PyErr_ExceptionMatches = getProcAddr(lib, "PyErr_ExceptionMatches") + PyErr_GivenExceptionMatches = getProcAddr(lib, "PyErr_GivenExceptionMatches") + PyEval_EvalCode = getProcAddr(lib, "PyEval_EvalCode") + Py_GetVersion = getProcAddr(lib, "Py_GetVersion") + Py_GetCopyright = getProcAddr(lib, "Py_GetCopyright") + Py_GetExecPrefix = getProcAddr(lib, "Py_GetExecPrefix") + Py_GetPath = getProcAddr(lib, "Py_GetPath") + Py_GetPrefix = getProcAddr(lib, "Py_GetPrefix") + Py_GetProgramName = getProcAddr(lib, "Py_GetProgramName") + PyParser_SimpleParseString = getProcAddr(lib, "PyParser_SimpleParseString") + PyNode_Free = getProcAddr(lib, "PyNode_Free") + PyErr_NewException = getProcAddr(lib, "PyErr_NewException") #/ jah 29-sep-2000 : updated for python 2.0 + #/ replaced Py_Malloc with PyMem_Malloc + #/--- @Py_Malloc := Import ('Py_Malloc'); + #/+++ @Py_Malloc := Import ('PyMem_Malloc'); + Py_Malloc = getProcAddr(lib, "PyMem_Malloc") + PyMem_Malloc = getProcAddr(lib, "PyMem_Malloc") + PyObject_CallMethod = getProcAddr(lib, "PyObject_CallMethod") + Py_SetProgramName = getProcAddr(lib, "Py_SetProgramName") + Py_IsInitialized = getProcAddr(lib, "Py_IsInitialized") + Py_GetProgramFullPath = getProcAddr(lib, "Py_GetProgramFullPath") + DLL_Py_GetBuildInfo = getProcAddr(lib, "Py_GetBuildInfo") + Py_NewInterpreter = getProcAddr(lib, "Py_NewInterpreter") + Py_EndInterpreter = getProcAddr(lib, "Py_EndInterpreter") + PyEval_AcquireLock = getProcAddr(lib, "PyEval_AcquireLock") + PyEval_ReleaseLock = getProcAddr(lib, "PyEval_ReleaseLock") + PyEval_AcquireThread = getProcAddr(lib, "PyEval_AcquireThread") + PyEval_ReleaseThread = getProcAddr(lib, "PyEval_ReleaseThread") + PyInterpreterState_New = getProcAddr(lib, "PyInterpreterState_New") + PyInterpreterState_Clear = getProcAddr(lib, "PyInterpreterState_Clear") + PyInterpreterState_Delete = getProcAddr(lib, "PyInterpreterState_Delete") + PyThreadState_New = getProcAddr(lib, "PyThreadState_New") + PyThreadState_Clear = getProcAddr(lib, "PyThreadState_Clear") + PyThreadState_Delete = getProcAddr(lib, "PyThreadState_Delete") + PyThreadState_Get = getProcAddr(lib, "PyThreadState_Get") + PyThreadState_Swap = getProcAddr(lib, "PyThreadState_Swap") + +var lib: TLibHandle + +lib = loadLibrary(dllName) +if lib != NilLibHandle: init(lib) diff --git a/lib/base/devel/python.pas b/lib/base/devel/python.pas new file mode 100644 index 000000000..587ec6dc9 --- /dev/null +++ b/lib/base/devel/python.pas @@ -0,0 +1,2205 @@ +{ + Light-weight binding for the Python interpreter + (c) 2008 Andreas Rumpf + Based on 'PythonEngine' module by Dr. Dietmar Budelsky + +} + +(**************************************************************************) +(* *) +(* Module: Unit 'PythonEngine' Copyright (c) 1997 *) +(* *) +(* Version: 3.0 Dr. Dietmar Budelsky *) +(* Sub-Version: 0.25 dbudelsky@web.de *) +(* Germany *) +(* *) +(* Morgan Martinet *) +(* 4721 rue Brebeuf *) +(* H2J 3L2 MONTREAL (QC) *) +(* CANADA *) +(* e-mail: mmm@free.fr *) +(* *) +(* look our page at: http://www.multimania.com/marat *) +(**************************************************************************) +(* Functionality: Delphi Components that provide an interface to the *) +(* Python language (see python.txt for more infos on *) +(* Python itself). *) +(* *) +(**************************************************************************) +(* Contributors: *) +(* Grzegorz Makarewicz (mak@mikroplan.com.pl) *) +(* Andrew Robinson (andy@hps1.demon.co.uk) *) +(* Mark Watts(mark_watts@hotmail.com) *) +(* Olivier Deckmyn (olivier.deckmyn@mail.dotcom.fr) *) +(* Sigve Tjora (public@tjora.no) *) +(* Mark Derricutt (mark@talios.com) *) +(* Igor E. Poteryaev (jah@mail.ru) *) +(* Yuri Filimonov (fil65@mail.ru) *) +(* Stefan Hoffmeister (Stefan.Hoffmeister@Econos.de) *) +(**************************************************************************) +(* This source code is distributed with no WARRANTY, for no reason or use.*) +(* Everyone is allowed to use and change this code free for his own tasks *) +(* and projects, as long as this header and its copyright text is intact. *) +(* For changed versions of this code, which are public distributed the *) +(* following additional conditions have to be fullfilled: *) +(* 1) The header has to contain a comment on the change and the author of *) +(* it. *) +(* 2) A copy of the changed source has to be sent to the above E-Mail *) +(* address or my then valid address, if this is possible to the *) +(* author. *) +(* The second condition has the target to maintain an up to date central *) +(* version of the component. If this condition is not acceptable for *) +(* confidential or legal reasons, everyone is free to derive a component *) +(* or to generate a diff file to my or other original sources. *) +(* Dr. Dietmar Budelsky, 1997-11-17 *) +(**************************************************************************) +unit python; + +interface + +uses + dyncalls; + +{$ifdef windows} +const + DllName = 'python24.dll'; +{$else} +const + DllName = 'libpython2.4.so'; // for UNIX systems +{$endif} + +const + PYT_METHOD_BUFFER_INCREASE = 10; + PYT_MEMBER_BUFFER_INCREASE = 10; + PYT_GETSET_BUFFER_INCREASE = 10; + + METH_VARARGS = $0001; + METH_KEYWORDS = $0002; + + // Masks for the co_flags field of PyCodeObject + CO_OPTIMIZED = $0001; + CO_NEWLOCALS = $0002; + CO_VARARGS = $0004; + CO_VARKEYWORDS = $0008; + +type + // Rich comparison opcodes introduced in version 2.1 + TRichComparisonOpcode = (pyLT, pyLE, pyEQ, pyNE, pyGT, pyGE); +const +{Type flags (tp_flags) introduced in version 2.0 + +These flags are used to extend the type structure in a backwards-compatible +fashion. Extensions can use the flags to indicate (and test) when a given +type structure contains a new feature. The Python core will use these when +introducing new functionality between major revisions (to avoid mid-version +changes in the PYTHON_API_VERSION). + +Arbitration of the flag bit positions will need to be coordinated among +all extension writers who publically release their extensions (this will +be fewer than you might expect!).. + +Python 1.5.2 introduced the bf_getcharbuffer slot into PyBufferProcs. + +Type definitions should use Py_TPFLAGS_DEFAULT for their tp_flags value. + +Code can use PyType_HasFeature(type_ob, flag_value) to test whether the +given type object has a specified feature. +} + +// PyBufferProcs contains bf_getcharbuffer + Py_TPFLAGS_HAVE_GETCHARBUFFER = (1 shl 0); + +// PySequenceMethods contains sq_contains + Py_TPFLAGS_HAVE_SEQUENCE_IN = (1 shl 1); + +// Objects which participate in garbage collection (see objimp.h) + Py_TPFLAGS_GC = (1 shl 2); + +// PySequenceMethods and PyNumberMethods contain in-place operators + Py_TPFLAGS_HAVE_INPLACEOPS = (1 shl 3); + +// PyNumberMethods do their own coercion */ + Py_TPFLAGS_CHECKTYPES = (1 shl 4); + + Py_TPFLAGS_HAVE_RICHCOMPARE = (1 shl 5); + +// Objects which are weakly referencable if their tp_weaklistoffset is >0 +// XXX Should this have the same value as Py_TPFLAGS_HAVE_RICHCOMPARE? +// These both indicate a feature that appeared in the same alpha release. + + Py_TPFLAGS_HAVE_WEAKREFS = (1 shl 6); + +// tp_iter is defined + Py_TPFLAGS_HAVE_ITER = (1 shl 7); + +// New members introduced by Python 2.2 exist + Py_TPFLAGS_HAVE_CLASS = (1 shl 8); + +// Set if the type object is dynamically allocated + Py_TPFLAGS_HEAPTYPE = (1 shl 9); + +// Set if the type allows subclassing + Py_TPFLAGS_BASETYPE = (1 shl 10); + +// Set if the type is 'ready' -- fully initialized + Py_TPFLAGS_READY = (1 shl 12); + +// Set while the type is being 'readied', to prevent recursive ready calls + Py_TPFLAGS_READYING = (1 shl 13); + +// Objects support garbage collection (see objimp.h) + Py_TPFLAGS_HAVE_GC = (1 shl 14); + + Py_TPFLAGS_DEFAULT = Py_TPFLAGS_HAVE_GETCHARBUFFER + or Py_TPFLAGS_HAVE_SEQUENCE_IN + or Py_TPFLAGS_HAVE_INPLACEOPS + or Py_TPFLAGS_HAVE_RICHCOMPARE + or Py_TPFLAGS_HAVE_WEAKREFS + or Py_TPFLAGS_HAVE_ITER + or Py_TPFLAGS_HAVE_CLASS; + +// See function PyType_HasFeature below for testing the flags. + +// Delphi equivalent used by TPythonType +type + TPFlag = (tpfHaveGetCharBuffer, tpfHaveSequenceIn, tpfGC, tpfHaveInplaceOps, + tpfCheckTypes, tpfHaveRichCompare, tpfHaveWeakRefs, + tpfHaveIter, tpfHaveClass, tpfHeapType, tpfBaseType, tpfReady, + tpfReadying, tpfHaveGC + ); + TPFlags = set of TPFlag; +const + TPFLAGS_DEFAULT = [tpfHaveGetCharBuffer, tpfHaveSequenceIn, tpfHaveInplaceOps, + tpfHaveRichCompare, tpfHaveWeakRefs, tpfHaveIter, + tpfHaveClass]; +//------- Python opcodes ----------// +Const + single_input = 256; + file_input = 257; + eval_input = 258; + funcdef = 259; + parameters = 260; + varargslist = 261; + fpdef = 262; + fplist = 263; + stmt = 264; + simple_stmt = 265; + small_stmt = 266; + expr_stmt = 267; + augassign = 268; + print_stmt = 269; + del_stmt = 270; + pass_stmt = 271; + flow_stmt = 272; + break_stmt = 273; + continue_stmt = 274; + return_stmt = 275; + raise_stmt = 276; + import_stmt = 277; + import_as_name = 278; + dotted_as_name = 279; + dotted_name = 280; + global_stmt = 281; + exec_stmt = 282; + assert_stmt = 283; + compound_stmt = 284; + if_stmt = 285; + while_stmt = 286; + for_stmt = 287; + try_stmt = 288; + except_clause = 289; + suite = 290; + test = 291; + and_test = 291; + not_test = 293; + comparison = 294; + comp_op = 295; + expr = 296; + xor_expr = 297; + and_expr = 298; + shift_expr = 299; + arith_expr = 300; + term = 301; + factor = 302; + power = 303; + atom = 304; + listmaker = 305; + lambdef = 306; + trailer = 307; + subscriptlist = 308; + subscript = 309; + sliceop = 310; + exprlist = 311; + testlist = 312; + dictmaker = 313; + classdef = 314; + arglist = 315; + argument = 316; + list_iter = 317; + list_for = 318; + list_if = 319; + +const + T_SHORT = 0; + T_INT = 1; + T_LONG = 2; + T_FLOAT = 3; + T_DOUBLE = 4; + T_STRING = 5; + T_OBJECT = 6; + T_CHAR = 7; // 1-character string + T_BYTE = 8; // 8-bit signed int + T_UBYTE = 9; + T_USHORT = 10; + T_UINT = 11; + T_ULONG = 12; + +// Added by Jack: strings contained in the structure + T_STRING_INPLACE= 13; + + T_OBJECT_EX = 16;{ Like T_OBJECT, but raises AttributeError + when the value is NULL, instead of + converting to None. } + +// Flags + READONLY = 1; + RO = READONLY; // Shorthand + READ_RESTRICTED = 2; + WRITE_RESTRICTED = 4; + RESTRICTED = (READ_RESTRICTED or WRITE_RESTRICTED); +type + TPyMemberType = (mtShort, mtInt, mtLong, mtFloat, mtDouble, mtString, + mtObject, mtChar, mtByte, mtUByte, mtUShort, mtUInt, + mtULong, mtStringInplace, mtObjectEx); + TPyMemberFlag = (mfDefault, mfReadOnly, mfReadRestricted, mfWriteRestricted, mfRestricted); + +//####################################################### +//## ## +//## Global declarations, nothing Python specific ## +//## ## +//####################################################### + +type + TPChar = array[0..16000] of PChar; + PPChar = ^TPChar; + PInt = ^Integer; + PDouble = ^Double; + PFloat = ^Real; + PLong = ^LongInt; + PShort = ^ShortInt; + PString = ^PChar; + +//####################################################### +//## ## +//## Python specific interface ## +//## ## +//####################################################### + +type + PP_frozen = ^Pfrozen; + P_frozen = ^Tfrozen; + PPyObject = ^PyObject; + PPPyObject = ^PPyObject; + PPPPyObject = ^PPPyObject; + PPyIntObject = ^PyIntObject; + PPyTypeObject = ^PyTypeObject; + PPySliceObject = ^PySliceObject; + + TPyCFunction = function (self, args: PPyObject): PPyObject; cdecl; + + Tunaryfunc = function (ob1: PPyObject): PPyObject; cdecl; + Tbinaryfunc = function (ob1,ob2: PPyObject): PPyObject; cdecl; + Tternaryfunc = function (ob1,ob2,ob3: PPyObject): PPyObject; cdecl; + Tinquiry = function (ob1: PPyObject): integer; cdecl; + Tcoercion = function (ob1,ob2: PPPyObject): integer; cdecl; + Tintargfunc = function (ob1: PPyObject; i: integer): PPyObject; cdecl; + Tintintargfunc = function (ob1: PPyObject; i1, i2: integer): + PPyObject; cdecl; + Tintobjargproc = function (ob1: PPyObject; i: integer; ob2: PPyObject): + integer; cdecl; + Tintintobjargproc = function (ob1: PPyObject; i1, i2: integer; + ob2: PPyObject): integer; cdecl; + Tobjobjargproc = function (ob1,ob2,ob3: PPyObject): integer; cdecl; + + Tpydestructor = procedure (ob: PPyObject); cdecl; + Tprintfunc = function (ob: PPyObject; var f: file; i: integer): integer; cdecl; + Tgetattrfunc = function (ob1: PPyObject; name: PChar): PPyObject; cdecl; + Tsetattrfunc = function (ob1: PPyObject; name: PChar; ob2: PPyObject): integer; cdecl; + Tcmpfunc = function (ob1, ob2: PPyObject): integer; cdecl; + Treprfunc = function (ob: PPyObject): PPyObject; cdecl; + Thashfunc = function (ob: PPyObject): LongInt; cdecl; + Tgetattrofunc = function (ob1, ob2: PPyObject): PPyObject; cdecl; + Tsetattrofunc = function (ob1, ob2, ob3: PPyObject): integer; cdecl; + +/// jah 29-sep-2000: updated for python 2.0 +/// added from object.h + Tgetreadbufferproc = function (ob1: PPyObject; i: integer; ptr: Pointer): integer; cdecl; + Tgetwritebufferproc= function (ob1: PPyObject; i: integer; ptr: Pointer): integer; cdecl; + Tgetsegcountproc = function (ob1: PPyObject; i: integer): integer; cdecl; + Tgetcharbufferproc = function (ob1: PPyObject; i: integer; const pstr: PChar): integer; cdecl; + Tobjobjproc = function (ob1, ob2: PPyObject): integer; cdecl; + Tvisitproc = function (ob1: PPyObject; ptr: Pointer): integer; cdecl; + Ttraverseproc = function (ob1: PPyObject; proc: visitproc; ptr: Pointer): integer; cdecl; + + Trichcmpfunc = function (ob1, ob2: PPyObject; i: Integer): PPyObject; cdecl; + Tgetiterfunc = function (ob1: PPyObject): PPyObject; cdecl; + Titernextfunc = function (ob1: PPyObject): PPyObject; cdecl; + Tdescrgetfunc = function (ob1, ob2, ob3: PPyObject): PPyObject; cdecl; + Tdescrsetfunc = function (ob1, ob2, ob3: PPyObject): Integer; cdecl; + Tinitproc = function (self, args, kwds: PPyObject): Integer; cdecl; + Tnewfunc = function (subtype: PPyTypeObject; args, kwds: PPyObject): PPyObject; cdecl; + Tallocfunc = function (self: PPyTypeObject; nitems: integer): PPyObject; cdecl; + + TPyNumberMethods = record + nb_add: Tbinaryfunc; + nb_substract: Tbinaryfunc; + nb_multiply: Tbinaryfunc; + nb_divide: Tbinaryfunc; + nb_remainder: Tbinaryfunc; + nb_divmod: Tbinaryfunc; + nb_power: Tternaryfunc; + nb_negative: Tunaryfunc; + nb_positive: Tunaryfunc; + nb_absolute: Tunaryfunc; + nb_nonzero: Tinquiry; + nb_invert: Tunaryfunc; + nb_lshift: Tbinaryfunc; + nb_rshift: Tbinaryfunc; + nb_and: Tbinaryfunc; + nb_xor: Tbinaryfunc; + nb_or: Tbinaryfunc; + nb_coerce: Tcoercion; + nb_int: Tunaryfunc; + nb_long: Tunaryfunc; + nb_float: Tunaryfunc; + nb_oct: Tunaryfunc; + nb_hex: Tunaryfunc; +/// jah 29-sep-2000: updated for python 2.0 +/// added from .h + nb_inplace_add: Tbinaryfunc; + nb_inplace_subtract: Tbinaryfunc; + nb_inplace_multiply: Tbinaryfunc; + nb_inplace_divide: Tbinaryfunc; + nb_inplace_remainder: Tbinaryfunc; + nb_inplace_power: Tternaryfunc; + nb_inplace_lshift: Tbinaryfunc; + nb_inplace_rshift: Tbinaryfunc; + nb_inplace_and: Tbinaryfunc; + nb_inplace_xor: Tbinaryfunc; + nb_inplace_or: Tbinaryfunc; + // Added in release 2.2 + // The following require the Py_TPFLAGS_HAVE_CLASS flag + nb_floor_divide: Tbinaryfunc; + nb_true_divide: Tbinaryfunc; + nb_inplace_floor_divide: Tbinaryfunc; + nb_inplace_true_divide: Tbinaryfunc; + end; + PPyNumberMethods = ^TPyNumberMethods; + + TPySequenceMethods = record + sq_length: Tinquiry; + sq_concat: Tbinaryfunc; + sq_repeat: Tintargfunc; + sq_item: Tintargfunc; + sq_slice: Tintintargfunc; + sq_ass_item: Tintobjargproc; + sq_ass_slice: Tintintobjargproc; +/// jah 29-sep-2000: updated for python 2.0 +/// added from .h + sq_contains: Tobjobjproc; + sq_inplace_concat: Tbinaryfunc; + sq_inplace_repeat: Tintargfunc; + end; + PPySequenceMethods = ^TPySequenceMethods; + + TPyMappingMethods = record + mp_length : Tinquiry; + mp_subscript: Tbinaryfunc; + mp_ass_subscript: Tobjobjargproc; + end; + PPyMappingMethods = ^PyMappingMethods; + +/// jah 29-sep-2000: updated for python 2.0 +/// added from .h + TPyBufferProcs = record + bf_getreadbuffer: Tgetreadbufferproc; + bf_getwritebuffer: Tgetwritebufferproc; + bf_getsegcount: Tgetsegcountproc; + bf_getcharbuffer: Tgetcharbufferproc; + end; + PPyBufferProcs = ^TPyBufferProcs; + + TPy_complex = record + real: double; + imag: double; + end; + + TPyObject = record + ob_refcnt: Integer; + ob_type: PPyTypeObject; + end; + + TPyIntObject = object(TPyObject) + ob_ival: LongInt; + end; + + PByte = ^Byte; + Tfrozen = packed record + name: PChar; + code: PByte; + size: Integer; + end; + + TPySliceObject = object(TPyObject) + start, stop, step: PPyObject; + end; + + PPyMethodDef = ^TPyMethodDef; + TPyMethodDef = record + ml_name: PChar; + ml_meth: TPyCFunction; + ml_flags: Integer; + ml_doc: PChar; + end; + + // structmember.h + PPyMemberDef = ^TPyMemberDef; + TPyMemberDef = record + name: PChar; + theType: integer; + offset: integer; + flags: integer; + doc: PChar; + end; + + // descrobject.h + + // Descriptors + + Tgetter = function (obj: PPyObject; context: Pointer): PPyObject; cdecl; + Tsetter = function (obj, value: PPyObject; context: Pointer): integer; cdecl; + + PPyGetSetDef = ^TPyGetSetDef; + TPyGetSetDef = record + name: PChar; + get: Tgetter; + set_: Tsetter; + doc: PChar; + closure: Pointer; + end; + + Twrapperfunc = function (self, args: PPyObject; wrapped: Pointer): PPyObject; cdecl; + + pwrapperbase = ^Twrapperbase; + Twrapperbase = record + name: PChar; + wrapper: Twrapperfunc; + doc: PChar; + end; + + // Various kinds of descriptor objects + + {#define PyDescr_COMMON \ + PyObject_HEAD \ + PyTypeObject *d_type; \ + PyObject *d_name + } + + PPyDescrObject = ^TPyDescrObject; + TPyDescrObject = object(TPyObject) + d_type: PPyTypeObject; + d_name: PPyObject; + end; + + PPyMethodDescrObject = ^TPyMethodDescrObject; + TPyMethodDescrObject = object(TPyDescrObject) + d_method: PPyMethodDef; + end; + + PPyMemberDescrObject = ^TPyMemberDescrObject; + TPyMemberDescrObject = object(TPyDescrObject) + d_member: PPyMemberDef; + end; + + PPyGetSetDescrObject = ^TPyGetSetDescrObject; + TPyGetSetDescrObject = object(TPyDescrObject) + d_getset: PPyGetSetDef; + end; + + PPyWrapperDescrObject = ^TPyWrapperDescrObject; + TPyWrapperDescrObject = object(TPyDescrObject) + d_base: pwrapperbase; + d_wrapped: Pointer; // This can be any function pointer + end; + + // object.h + TPyTypeObject = object(TPyObject) + ob_size: Integer; // Number of items in variable part + tp_name: PChar; // For printing + tp_basicsize, tp_itemsize: Integer; // For allocation + + // Methods to implement standard operations + + tp_dealloc: Tpydestructor; + tp_print: Tprintfunc; + tp_getattr: Tgetattrfunc; + tp_setattr: Tsetattrfunc; + tp_compare: Tcmpfunc; + tp_repr: Treprfunc; + + // Method suites for standard classes + + tp_as_number: PPyNumberMethods; + tp_as_sequence: PPySequenceMethods; + tp_as_mapping: PPyMappingMethods; + + // More standard operations (here for binary compatibility) + + tp_hash: Thashfunc; + tp_call: Tternaryfunc; + tp_str: Treprfunc; + tp_getattro: Tgetattrofunc; + tp_setattro: Tsetattrofunc; + +/// jah 29-sep-2000: updated for python 2.0 + + // Functions to access object as input/output buffer + tp_as_buffer: PPyBufferProcs; + // Flags to define presence of optional/expanded features + tp_flags: LongInt; + + tp_doc: PChar; // Documentation string + + // call function for all accessible objects + tp_traverse: Ttraverseproc; + + // delete references to contained objects + tp_clear: Tinquiry; + // rich comparisons + tp_richcompare: Trichcmpfunc; + + // weak reference enabler + tp_weaklistoffset: Longint; + // Iterators + tp_iter: Tgetiterfunc; + tp_iternext: Titernextfunc; + + // Attribute descriptor and subclassing stuff + tp_methods: PPyMethodDef; + tp_members: PPyMemberDef; + tp_getset: PPyGetSetDef; + tp_base: PPyTypeObject; + tp_dict: PPyObject; + tp_descr_get: Tdescrgetfunc; + tp_descr_set: Tdescrsetfunc; + tp_dictoffset: longint; + tp_init: Tinitproc; + tp_alloc: Tallocfunc; + tp_new: Tnewfunc; + tp_free: Tpydestructor; // Low-level free-memory routine + tp_is_gc: Tinquiry; // For PyObject_IS_GC + tp_bases: PPyObject; + tp_mro: PPyObject; // method resolution order + tp_cache: PPyObject; + tp_subclasses: PPyObject; + tp_weaklist: PPyObject; + //More spares + tp_xxx7: pointer; + tp_xxx8: pointer; + end; + + PPyMethodChain = ^TPyMethodChain; + TPyMethodChain = record + methods: PPyMethodDef; + link: PPyMethodChain; + end; + + PPyClassObject = ^TPyClassObject; + TPyClassObject = object(TPyObject) + cl_bases: PPyObject; // A tuple of class objects + cl_dict: PPyObject; // A dictionary + cl_name: PPyObject; // A string + // The following three are functions or NULL + cl_getattr: PPyObject; + cl_setattr: PPyObject; + cl_delattr: PPyObject; + end; + + PPyInstanceObject = ^TPyInstanceObject; + TPyInstanceObject = object(TPyObject) + in_class: PPyClassObject; // The class object + in_dict: PPyObject; // A dictionary + end; + +{ Instance method objects are used for two purposes: + (a) as bound instance methods (returned by instancename.methodname) + (b) as unbound methods (returned by ClassName.methodname) + In case (b), im_self is NULL +} + + PPyMethodObject = ^TPyMethodObject; + TPyMethodObject = object(TPyObject) + im_func: PPyObject; // The function implementing the method + im_self: PPyObject; // The instance it is bound to, or NULL + im_class: PPyObject; // The class that defined the method + end; + + // Bytecode object, compile.h + PPyCodeObject = ^TPyCodeObject; + TPyCodeObject = object(TPyObject) + co_argcount: Integer; // #arguments, except *args + co_nlocals: Integer; // #local variables + co_stacksize: Integer; // #entries needed for evaluation stack + co_flags: Integer; // CO_..., see below + co_code: PPyObject; // instruction opcodes (it hides a PyStringObject) + co_consts: PPyObject; // list (constants used) + co_names: PPyObject; // list of strings (names used) + co_varnames: PPyObject; // tuple of strings (local variable names) + co_freevars: PPyObject; // tuple of strings (free variable names) + co_cellvars: PPyObject; // tuple of strings (cell variable names) + // The rest doesn't count for hash/cmp + co_filename: PPyObject; // string (where it was loaded from) + co_name: PPyObject; // string (name, for reference) + co_firstlineno: Integer; // first source line number + co_lnotab: PPyObject; // string (encoding addr<->lineno mapping) + end; + + // from pystate.h + PPyInterpreterState = ^TPyInterpreterState; + PPyThreadState = ^TPyThreadState; + PPyFrameObject = ^TPyFrameObject; + + // Interpreter environments + TPyInterpreterState = record + next: PPyInterpreterState; + tstate_head: PPyThreadState; + + modules: PPyObject; + sysdict: PPyObject; + builtins: PPyObject; + + checkinterval: integer; + end; + + // Thread specific information + TPyThreadState = record + next: PPyThreadState; + interp: PPyInterpreterState; + + frame: PPyFrameObject; + recursion_depth: integer; + ticker: integer; + tracing: integer; + + sys_profilefunc: PPyObject; + sys_tracefunc: PPyObject; + + curexc_type: PPyObject; + curexc_value: PPyObject; + curexc_traceback: PPyObject; + + exc_type: PPyObject; + exc_value: PPyObject; + exc_traceback: PPyObject; + + dict: PPyObject; + end; + + // from frameobject.h + + PPyTryBlock = ^TPyTryBlock; + TPyTryBlock = record + b_type: Integer; // what kind of block this is + b_handler: Integer; // where to jump to find handler + b_level: Integer; // value stack level to pop to + end; + + CO_MAXBLOCKS = 0..19; + TPyFrameObject = object(TPyObject) + // start of the VAR_HEAD of an object + ob_size: Integer; // Number of items in variable part + // End of the Head of an object + f_back: PPyFrameObject; // previous frame, or NULL + f_code: PPyCodeObject; // code segment + f_builtins: PPyObject; // builtin symbol table (PyDictObject) + f_globals: PPyObject; // global symbol table (PyDictObject) + f_locals: PPyObject; // local symbol table (PyDictObject) + f_valuestack: PPPyObject; // points after the last local + (* Next free slot in f_valuestack. Frame creation sets to f_valuestack. + Frame evaluation usually NULLs it, but a frame that yields sets it + to the current stack top. *) + f_stacktop: PPPyObject; + f_trace: PPyObject; // Trace function + f_exc_type, f_exc_value, f_exc_traceback: PPyObject; + f_tstate: PPyThreadState; + f_lasti: Integer; // Last instruction if called + f_lineno: Integer; // Current line number + f_restricted: Integer; // Flag set if restricted operations + // in this scope + f_iblock: Integer; // index in f_blockstack + f_blockstack: array[CO_MAXBLOCKS] of PyTryBlock; // for try and loop blocks + f_nlocals: Integer; // number of locals + f_ncells: Integer; + f_nfreevars: Integer; + f_stacksize: Integer; // size of value stack + f_localsplus: array[0..0] of PPyObject; // locals+stack, dynamically sized + end; + + // From traceback.c + PPyTraceBackObject = ^TPyTraceBackObject; + TPyTraceBackObject = object(TPyObject) + tb_next: PPyTraceBackObject; + tb_frame: PPyFrameObject; + tb_lasti: Integer; + tb_lineno: Integer; + end; + + // Parse tree node interface + + PNode = ^Tnode; + Tnode = record + n_type: smallint; + n_str: PChar; + n_lineno: smallint; + n_nchildren: smallint; + n_child: PNode; + end; + + // From weakrefobject.h + + PPyWeakReference = ^TPyWeakReference; + TPyWeakReference = object(TPyObject) + wr_object: PPyObject; + wr_callback: PPyObject; + hash: longint; + wr_prev: PPyWeakReference; + wr_next: PPyWeakReference; + end; + + // from datetime.h + + +{* Fields are packed into successive bytes, each viewed as unsigned and + * big-endian, unless otherwise noted: + * + * byte offset + * 0 year 2 bytes, 1-9999 + * 2 month 1 byte, 1-12 + * 3 day 1 byte, 1-31 + * 4 hour 1 byte, 0-23 + * 5 minute 1 byte, 0-59 + * 6 second 1 byte, 0-59 + * 7 usecond 3 bytes, 0-999999 + * 10 + *} + +const + { # of bytes for year, month, and day. } + PyDateTime_DATE_DATASIZE = 4; + + { # of bytes for hour, minute, second, and usecond. } + PyDateTime_TIME_DATASIZE = 6; + + { # of bytes for year, month, day, hour, minute, second, and usecond. } + PyDateTime_DATETIME_DATASIZE = 10; +type + TPyDateTime_Delta = object(TPyObject) + hashcode: Integer; // -1 when unknown + days: Integer; // -MAX_DELTA_DAYS <= days <= MAX_DELTA_DAYS + seconds: Integer; // 0 <= seconds < 24*3600 is invariant + microseconds: Integer; // 0 <= microseconds < 1000000 is invariant + end; + PPyDateTime_Delta = ^TPyDateTime_Delta; + + TPyDateTime_TZInfo = object(TPyObject) // a pure abstract base clase + end; + PPyDateTime_TZInfo = ^TPyDateTime_TZInfo; + +{ +/* The datetime and time types have hashcodes, and an optional tzinfo member, + * present if and only if hastzinfo is true. + */ +#define _PyTZINFO_HEAD \ + PyObject_HEAD \ + long hashcode; \ + char hastzinfo; /* boolean flag */ +} + +{* No _PyDateTime_BaseTZInfo is allocated; it's just to have something + * convenient to cast to, when getting at the hastzinfo member of objects + * starting with _PyTZINFO_HEAD. + *} + TPyDateTime_BaseTZInfo = object(TPyObject) + hashcode: Integer; + hastzinfo: bool; // boolean flag + end; + PPyDateTime_BaseTZInfo = ^TPyDateTime_BaseTZInfo; + +{* All time objects are of PyDateTime_TimeType, but that can be allocated + * in two ways, with or without a tzinfo member. Without is the same as + * tzinfo == None, but consumes less memory. _PyDateTime_BaseTime is an + * internal struct used to allocate the right amount of space for the + * "without" case. + *} +{#define _PyDateTime_TIMEHEAD \ + _PyTZINFO_HEAD \ + unsigned char data[_PyDateTime_TIME_DATASIZE]; +} + + TPyDateTime_BaseTime = object(TPyDateTime_BaseTZInfo) + data: array[0..Pred(PyDateTime_TIME_DATASIZE)] of Byte; + end; + PPyDateTime_BaseTime = ^TPyDateTime_BaseTime; + + TPyDateTime_Time = object(TPyDateTime_BaseTime) // hastzinfo true + tzinfo: PPyObject; + end; + PPyDateTime_Time = ^PyDateTime_Time; + +{* All datetime objects are of PyDateTime_DateTimeType, but that can be + * allocated in two ways too, just like for time objects above. In addition, + * the plain date type is a base class for datetime, so it must also have + * a hastzinfo member (although it's unused there). + *} + TPyDateTime_Date = object(TPyDateTime_BaseTZInfo) + data: array [0..Pred(PyDateTime_DATE_DATASIZE)] of Byte; + end; + PPyDateTime_Date = ^TPyDateTime_Date; + + { +#define _PyDateTime_DATETIMEHEAD \ + _PyTZINFO_HEAD \ + unsigned char data[_PyDateTime_DATETIME_DATASIZE]; +} + + TPyDateTime_BaseDateTime = object(TPyDateTime_BaseTZInfo) // hastzinfo false + data: array[0..Pred(PyDateTime_DATETIME_DATASIZE)] of Byte; + end; + PPyDateTime_BaseDateTime = ^TPyDateTime_BaseDateTime; + + TPyDateTime_DateTime = object(TPyDateTime_BaseTZInfo) // hastzinfo true + data: array[0..Pred(PyDateTime_DATETIME_DATASIZE)] of Byte; + tzinfo: PPyObject; + end; + PPyDateTime_DateTime = ^TPyDateTime_DateTime; + + +//####################################################### +//## ## +//## New exception classes ## +//## ## +//####################################################### +(* + // Python's exceptions + EPythonError = object(Exception) + EName: String; + EValue: String; + end; + EPyExecError = object(EPythonError) + end; + + // Standard exception classes of Python + +/// jah 29-sep-2000: updated for python 2.0 +/// base classes updated according python documentation + +{ Hierarchy of Python exceptions, Python 2.3, copied from <INSTALL>\Python\exceptions.c + +Exception\n\ + |\n\ + +-- SystemExit\n\ + +-- StopIteration\n\ + +-- StandardError\n\ + | |\n\ + | +-- KeyboardInterrupt\n\ + | +-- ImportError\n\ + | +-- EnvironmentError\n\ + | | |\n\ + | | +-- IOError\n\ + | | +-- OSError\n\ + | | |\n\ + | | +-- WindowsError\n\ + | | +-- VMSError\n\ + | |\n\ + | +-- EOFError\n\ + | +-- RuntimeError\n\ + | | |\n\ + | | +-- NotImplementedError\n\ + | |\n\ + | +-- NameError\n\ + | | |\n\ + | | +-- UnboundLocalError\n\ + | |\n\ + | +-- AttributeError\n\ + | +-- SyntaxError\n\ + | | |\n\ + | | +-- IndentationError\n\ + | | |\n\ + | | +-- TabError\n\ + | |\n\ + | +-- TypeError\n\ + | +-- AssertionError\n\ + | +-- LookupError\n\ + | | |\n\ + | | +-- IndexError\n\ + | | +-- KeyError\n\ + | |\n\ + | +-- ArithmeticError\n\ + | | |\n\ + | | +-- OverflowError\n\ + | | +-- ZeroDivisionError\n\ + | | +-- FloatingPointError\n\ + | |\n\ + | +-- ValueError\n\ + | | |\n\ + | | +-- UnicodeError\n\ + | | |\n\ + | | +-- UnicodeEncodeError\n\ + | | +-- UnicodeDecodeError\n\ + | | +-- UnicodeTranslateError\n\ + | |\n\ + | +-- ReferenceError\n\ + | +-- SystemError\n\ + | +-- MemoryError\n\ + |\n\ + +---Warning\n\ + |\n\ + +-- UserWarning\n\ + +-- DeprecationWarning\n\ + +-- PendingDeprecationWarning\n\ + +-- SyntaxWarning\n\ + +-- OverflowWarning\n\ + +-- RuntimeWarning\n\ + +-- FutureWarning" +} + EPyException = class (EPythonError); + EPyStandardError = class (EPyException); + EPyArithmeticError = class (EPyStandardError); + EPyLookupError = class (EPyStandardError); + EPyAssertionError = class (EPyStandardError); + EPyAttributeError = class (EPyStandardError); + EPyEOFError = class (EPyStandardError); + EPyFloatingPointError = class (EPyArithmeticError); + EPyEnvironmentError = class (EPyStandardError); + EPyIOError = class (EPyEnvironmentError); + EPyOSError = class (EPyEnvironmentError); + EPyImportError = class (EPyStandardError); + EPyIndexError = class (EPyLookupError); + EPyKeyError = class (EPyLookupError); + EPyKeyboardInterrupt = class (EPyStandardError); + EPyMemoryError = class (EPyStandardError); + EPyNameError = class (EPyStandardError); + EPyOverflowError = class (EPyArithmeticError); + EPyRuntimeError = class (EPyStandardError); + EPyNotImplementedError = class (EPyRuntimeError); + EPySyntaxError = class (EPyStandardError) + public + EFileName: string; + ELineStr: string; + ELineNumber: Integer; + EOffset: Integer; + end; + EPyIndentationError = class (EPySyntaxError); + EPyTabError = class (EPyIndentationError); + EPySystemError = class (EPyStandardError); + EPySystemExit = class (EPyException); + EPyTypeError = class (EPyStandardError); + EPyUnboundLocalError = class (EPyNameError); + EPyValueError = class (EPyStandardError); + EPyUnicodeError = class (EPyValueError); + UnicodeEncodeError = class (EPyUnicodeError); + UnicodeDecodeError = class (EPyUnicodeError); + UnicodeTranslateError = class (EPyUnicodeError); + EPyZeroDivisionError = class (EPyArithmeticError); + EPyStopIteration = class(EPyException); + EPyWarning = class (EPyException); + EPyUserWarning = class (EPyWarning); + EPyDeprecationWarning = class (EPyWarning); + PendingDeprecationWarning = class (EPyWarning); + FutureWarning = class (EPyWarning); + EPySyntaxWarning = class (EPyWarning); + EPyOverflowWarning = class (EPyWarning); + EPyRuntimeWarning = class (EPyWarning); + EPyReferenceError = class (EPyStandardError); +*) + +var + PyArg_Parse: function(args: PPyObject; format: PChar): + Integer; cdecl;// varargs; + PyArg_ParseTuple: function(args: PPyObject; format: PChar; + x1: Pointer = nil; + x2: Pointer = nil; + x3: Pointer = nil): + Integer; cdecl;// varargs + Py_BuildValue: function(format: PChar): PPyObject; cdecl; // varargs + PyCode_Addr2Line: function (co: PPyCodeObject; addrq: Integer): Integer; cdecl; + DLL_Py_GetBuildInfo: function: PChar; cdecl; + + // define Python flags. See file pyDebug.h + Py_DebugFlag: PInt; + Py_VerboseFlag: PInt; + Py_InteractiveFlag: PInt; + Py_OptimizeFlag: PInt; + Py_NoSiteFlag: PInt; + Py_UseClassExceptionsFlag: PInt; + Py_FrozenFlag: PInt; + Py_TabcheckFlag: PInt; + Py_UnicodeFlag: PInt; + Py_IgnoreEnvironmentFlag: PInt; + Py_DivisionWarningFlag: PInt; + //_PySys_TraceFunc: PPPyObject; + //_PySys_ProfileFunc: PPPPyObject; + + PyImport_FrozenModules: PP_frozen; + + Py_None: PPyObject; + Py_Ellipsis: PPyObject; + Py_False: PPyIntObject; + Py_True: PPyIntObject; + Py_NotImplemented: PPyObject; + + PyExc_AttributeError: PPPyObject; + PyExc_EOFError: PPPyObject; + PyExc_IOError: PPPyObject; + PyExc_ImportError: PPPyObject; + PyExc_IndexError: PPPyObject; + PyExc_KeyError: PPPyObject; + PyExc_KeyboardInterrupt: PPPyObject; + PyExc_MemoryError: PPPyObject; + PyExc_NameError: PPPyObject; + PyExc_OverflowError: PPPyObject; + PyExc_RuntimeError: PPPyObject; + PyExc_SyntaxError: PPPyObject; + PyExc_SystemError: PPPyObject; + PyExc_SystemExit: PPPyObject; + PyExc_TypeError: PPPyObject; + PyExc_ValueError: PPPyObject; + PyExc_ZeroDivisionError: PPPyObject; + PyExc_ArithmeticError: PPPyObject; + PyExc_Exception: PPPyObject; + PyExc_FloatingPointError: PPPyObject; + PyExc_LookupError: PPPyObject; + PyExc_StandardError: PPPyObject; + PyExc_AssertionError: PPPyObject; + PyExc_EnvironmentError: PPPyObject; + PyExc_IndentationError: PPPyObject; + PyExc_MemoryErrorInst: PPPyObject; + PyExc_NotImplementedError: PPPyObject; + PyExc_OSError: PPPyObject; + PyExc_TabError: PPPyObject; + PyExc_UnboundLocalError: PPPyObject; + PyExc_UnicodeError: PPPyObject; + + PyExc_Warning: PPPyObject; + PyExc_DeprecationWarning: PPPyObject; + PyExc_RuntimeWarning: PPPyObject; + PyExc_SyntaxWarning: PPPyObject; + PyExc_UserWarning: PPPyObject; + PyExc_OverflowWarning: PPPyObject; + PyExc_ReferenceError: PPPyObject; + PyExc_StopIteration: PPPyObject; + PyExc_FutureWarning: PPPyObject; + PyExc_PendingDeprecationWarning: PPPyObject; + PyExc_UnicodeDecodeError: PPPyObject; + PyExc_UnicodeEncodeError: PPPyObject; + PyExc_UnicodeTranslateError: PPPyObject; + + PyType_Type: PPyTypeObject; + PyCFunction_Type: PPyTypeObject; + PyCObject_Type: PPyTypeObject; + PyClass_Type: PPyTypeObject; + PyCode_Type: PPyTypeObject; + PyComplex_Type: PPyTypeObject; + PyDict_Type: PPyTypeObject; + PyFile_Type: PPyTypeObject; + PyFloat_Type: PPyTypeObject; + PyFrame_Type: PPyTypeObject; + PyFunction_Type: PPyTypeObject; + PyInstance_Type: PPyTypeObject; + PyInt_Type: PPyTypeObject; + PyList_Type: PPyTypeObject; + PyLong_Type: PPyTypeObject; + PyMethod_Type: PPyTypeObject; + PyModule_Type: PPyTypeObject; + PyObject_Type: PPyTypeObject; + PyRange_Type: PPyTypeObject; + PySlice_Type: PPyTypeObject; + PyString_Type: PPyTypeObject; + PyTuple_Type: PPyTypeObject; + + PyBaseObject_Type: PPyTypeObject; + PyBuffer_Type: PPyTypeObject; + PyCallIter_Type: PPyTypeObject; + PyCell_Type: PPyTypeObject; + PyClassMethod_Type: PPyTypeObject; + PyProperty_Type: PPyTypeObject; + PySeqIter_Type: PPyTypeObject; + PyStaticMethod_Type: PPyTypeObject; + PySuper_Type: PPyTypeObject; + PySymtableEntry_Type: PPyTypeObject; + PyTraceBack_Type: PPyTypeObject; + PyUnicode_Type: PPyTypeObject; + PyWrapperDescr_Type: PPyTypeObject; + + PyBaseString_Type: PPyTypeObject; + PyBool_Type: PPyTypeObject; + PyEnum_Type: PPyTypeObject; + + //PyArg_GetObject: function(args: PPyObject; nargs, i: integer; p_a: PPPyObject): integer; cdecl; + //PyArg_GetLong: function(args: PPyObject; nargs, i: integer; p_a: PLong): integer; cdecl; + //PyArg_GetShort: function(args: PPyObject; nargs, i: integer; p_a: PShort): integer; cdecl; + //PyArg_GetFloat: function(args: PPyObject; nargs, i: integer; p_a: PFloat): integer; cdecl; + //PyArg_GetString: function(args: PPyObject; nargs, i: integer; p_a: PString): integer; cdecl; + //PyArgs_VaParse: function (args: PPyObject; format: PChar; va_list: array of const): integer; cdecl; + // Does not work! + // Py_VaBuildValue: function (format: PChar; va_list: array of const): PPyObject; cdecl; + //PyBuiltin_Init: procedure; cdecl; + + PyComplex_FromCComplex: function(c: TPy_complex):PPyObject; cdecl; + PyComplex_FromDoubles: function(realv,imag: double):PPyObject; cdecl; + PyComplex_RealAsDouble: function(op: PPyObject): double; cdecl; + PyComplex_ImagAsDouble: function(op: PPyObject): double; cdecl; + PyComplex_AsCComplex: function(op: PPyObject): TPy_complex; cdecl; + PyCFunction_GetFunction: function(ob: PPyObject): Pointer; cdecl; + PyCFunction_GetSelf: function(ob: PPyObject): PPyObject; cdecl; + PyCallable_Check: function(ob : PPyObject): integer; cdecl; + PyCObject_FromVoidPtr: function(cobj, destruct: Pointer): PPyObject; cdecl; + PyCObject_AsVoidPtr: function(ob: PPyObject): Pointer; cdecl; + PyClass_New: function (ob1,ob2,ob3: PPyObject): PPyObject; cdecl; + PyClass_IsSubclass: function (ob1, ob2: PPyObject): integer cdecl; + + Py_InitModule4: function(name: PChar; methods: PPyMethodDef; doc: PChar; + passthrough: PPyObject; Api_Version: Integer):PPyObject; cdecl; + PyErr_BadArgument: function: integer; cdecl; + PyErr_BadInternalCall: procedure; cdecl; + PyErr_CheckSignals: function: integer; cdecl; + PyErr_Clear: procedure; cdecl; + PyErr_Fetch: procedure(errtype, errvalue, errtraceback: PPPyObject); cdecl; + PyErr_NoMemory: function: PPyObject; cdecl; + PyErr_Occurred: function: PPyObject; cdecl; + PyErr_Print: procedure; cdecl; + PyErr_Restore: procedure (errtype, errvalue, errtraceback: PPyObject); cdecl; + PyErr_SetFromErrno: function (ob: PPyObject):PPyObject; cdecl; + PyErr_SetNone: procedure(value: PPyObject); cdecl; + PyErr_SetObject: procedure (ob1, ob2 : PPyObject); cdecl; + PyErr_SetString: procedure(ErrorObject: PPyObject; text: PChar); cdecl; + PyImport_GetModuleDict: function: PPyObject; cdecl; + PyInt_FromLong: function(x: LongInt):PPyObject; cdecl; + Py_Initialize: procedure; cdecl; + Py_Exit: procedure(RetVal: Integer); cdecl; + PyEval_GetBuiltins: function: PPyObject; cdecl; + PyDict_GetItem: function(mp, key: PPyObject):PPyObject; cdecl; + PyDict_SetItem: function(mp, key, item:PPyObject):integer; cdecl; + PyDict_DelItem: function(mp, key: PPyObject):integer; cdecl; + PyDict_Clear: procedure(mp: PPyObject); cdecl; + PyDict_Next: function(mp: PPyObject; pos: PInt; key, value: PPPyObject):integer; cdecl; + PyDict_Keys: function(mp: PPyObject):PPyObject; cdecl; + PyDict_Values: function(mp: PPyObject):PPyObject; cdecl; + PyDict_Items: function(mp: PPyObject):PPyObject; cdecl; + PyDict_Size: function(mp: PPyObject):integer; cdecl; + PyDict_DelItemString: function(dp: PPyObject;key: PChar):integer; cdecl; + PyDict_New: function: PPyObject; cdecl; + PyDict_GetItemString: function(dp: PPyObject; key: PChar): PPyObject; cdecl; + PyDict_SetItemString: function(dp: PPyObject; key: PChar; item: PPyObject): + Integer; cdecl; + PyDictProxy_New: function (obj: PPyObject): PPyObject; cdecl; + PyModule_GetDict: function(module:PPyObject): PPyObject; cdecl; + PyObject_Str: function(v: PPyObject): PPyObject; cdecl; + PyRun_String: function(str: PChar; start: Integer; globals: PPyObject; + locals: PPyObject): PPyObject; cdecl; + PyRun_SimpleString: function(str: PChar): Integer; cdecl; + PyString_AsString: function(ob: PPyObject): PChar; cdecl; + PyString_FromString: function(str: PChar): PPyObject; cdecl; + PySys_SetArgv: procedure(argc: Integer; argv: PPChar); cdecl; + +{+ means, Grzegorz or me has tested his non object version of this function} +{+} PyCFunction_New: function(md:PPyMethodDef;ob:PPyObject):PPyObject; cdecl; +{+} PyEval_CallObject: function(ob1,ob2:PPyObject):PPyObject; cdecl; +{-} PyEval_CallObjectWithKeywords:function (ob1,ob2,ob3:PPyObject):PPyObject; cdecl; +{-} PyEval_GetFrame:function:PPyObject; cdecl; +{-} PyEval_GetGlobals:function:PPyObject; cdecl; +{-} PyEval_GetLocals:function:PPyObject; cdecl; +{-} //PyEval_GetOwner:function:PPyObject; cdecl; +{-} PyEval_GetRestricted:function:integer; cdecl; + +{-} PyEval_InitThreads:procedure; cdecl; +{-} PyEval_RestoreThread:procedure(tstate: PPyThreadState); cdecl; +{-} PyEval_SaveThread:function:PPyThreadState; cdecl; + +{-} PyFile_FromString:function (pc1,pc2:PChar):PPyObject; cdecl; +{-} PyFile_GetLine:function (ob:PPyObject;i:integer):PPyObject; cdecl; +{-} PyFile_Name:function (ob:PPyObject):PPyObject; cdecl; +{-} PyFile_SetBufSize:procedure(ob:PPyObject;i:integer); cdecl; +{-} PyFile_SoftSpace:function (ob:PPyObject;i:integer):integer; cdecl; +{-} PyFile_WriteObject:function (ob1,ob2:PPyObject;i:integer):integer; cdecl; +{-} PyFile_WriteString:procedure(s:PChar;ob:PPyObject); cdecl; +{+} PyFloat_AsDouble:function (ob:PPyObject):DOUBLE; cdecl; +{+} PyFloat_FromDouble:function (db:double):PPyObject; cdecl; +{-} PyFunction_GetCode:function (ob:PPyObject):PPyObject; cdecl; +{-} PyFunction_GetGlobals:function (ob:PPyObject):PPyObject; cdecl; +{-} PyFunction_New:function (ob1,ob2:PPyObject):PPyObject; cdecl; +{-} PyImport_AddModule:function (name:PChar):PPyObject; cdecl; +{-} PyImport_Cleanup:procedure; cdecl; +{-} PyImport_GetMagicNumber:function:LONGINT; cdecl; +{+} PyImport_ImportFrozenModule:function (key:PChar):integer; cdecl; +{+} PyImport_ImportModule:function (name:PChar):PPyObject; cdecl; +{+} PyImport_Import:function (name:PPyObject):PPyObject; cdecl; +{-} //PyImport_Init:procedure; cdecl; +{-} PyImport_ReloadModule:function (ob:PPyObject):PPyObject; cdecl; +{-} PyInstance_New:function (obClass, obArg, obKW:PPyObject):PPyObject; cdecl; +{+} PyInt_AsLong:function (ob:PPyObject):LONGINT; cdecl; +{-} PyList_Append:function (ob1,ob2:PPyObject):integer; cdecl; +{-} PyList_AsTuple:function (ob:PPyObject):PPyObject; cdecl; +{+} PyList_GetItem:function (ob:PPyObject;i:integer):PPyObject; cdecl; +{-} PyList_GetSlice:function (ob:PPyObject;i1,i2:integer):PPyObject; cdecl; +{-} PyList_Insert:function (dp:PPyObject;idx:Integer;item:PPyObject):integer; cdecl; +{-} PyList_New:function (size:integer):PPyObject; cdecl; +{-} PyList_Reverse:function (ob:PPyObject):integer; cdecl; +{-} PyList_SetItem:function (dp:PPyObject;idx:Integer;item:PPyObject):integer; cdecl; +{-} PyList_SetSlice:function (ob:PPyObject;i1,i2:integer;ob2:PPyObject):integer; cdecl; +{+} PyList_Size:function (ob:PPyObject):integer; cdecl; +{-} PyList_Sort:function (ob:PPyObject):integer; cdecl; +{-} PyLong_AsDouble:function (ob:PPyObject):DOUBLE; cdecl; +{+} PyLong_AsLong:function (ob:PPyObject):LONGINT; cdecl; +{+} PyLong_FromDouble:function (db:double):PPyObject; cdecl; +{+} PyLong_FromLong:function (l:longint):PPyObject; cdecl; +{-} PyLong_FromString:function (pc:PChar;var ppc:PChar;i:integer):PPyObject; cdecl; +{-} PyLong_FromUnsignedLong:function(val:cardinal): PPyObject; cdecl; +{-} PyLong_AsUnsignedLong:function(ob:PPyObject): Cardinal; cdecl; +{-} PyLong_FromUnicode:function(ob:PPyObject; a, b: integer): PPyObject; cdecl; +{-} PyLong_FromLongLong:function(val:Int64): PPyObject; cdecl; +{-} PyLong_AsLongLong:function(ob:PPyObject): Int64; cdecl; +{-} PyMapping_Check:function (ob:PPyObject):integer; cdecl; +{-} PyMapping_GetItemString:function (ob:PPyObject;key:PChar):PPyObject; cdecl; +{-} PyMapping_HasKey:function (ob,key:PPyObject):integer; cdecl; +{-} PyMapping_HasKeyString:function (ob:PPyObject;key:PChar):integer; cdecl; +{-} PyMapping_Length:function (ob:PPyObject):integer; cdecl; +{-} PyMapping_SetItemString:function (ob:PPyObject; key:PChar; value:PPyObject):integer; cdecl; +{-} PyMethod_Class:function (ob:PPyObject):PPyObject; cdecl; +{-} PyMethod_Function:function (ob:PPyObject):PPyObject; cdecl; +{-} PyMethod_New:function (ob1,ob2,ob3:PPyObject):PPyObject; cdecl; +{-} PyMethod_Self:function (ob:PPyObject):PPyObject; cdecl; +{-} PyModule_GetName:function (ob:PPyObject):PChar; cdecl; +{-} PyModule_New:function (key:PChar):PPyObject; cdecl; +{-} PyNumber_Absolute:function (ob:PPyObject):PPyObject; cdecl; +{-} PyNumber_Add:function (ob1,ob2:PPyObject):PPyObject; cdecl; +{-} PyNumber_And:function (ob1,ob2:PPyObject):PPyObject; cdecl; +{-} PyNumber_Check:function (ob:PPyObject):integer; cdecl; +{-} PyNumber_Coerce:function (var ob1,ob2:PPyObject):integer; cdecl; +{-} PyNumber_Divide:function (ob1,ob2:PPyObject):PPyObject; cdecl; +{-} PyNumber_FloorDivide:function (ob1,ob2:PPyObject):PPyObject; cdecl; +{-} PyNumber_TrueDivide:function (ob1,ob2:PPyObject):PPyObject; cdecl; +{-} PyNumber_Divmod:function (ob1,ob2:PPyObject):PPyObject; cdecl; +{-} PyNumber_Float:function (ob:PPyObject):PPyObject; cdecl; +{-} PyNumber_Int:function (ob:PPyObject):PPyObject; cdecl; +{-} PyNumber_Invert:function (ob:PPyObject):PPyObject; cdecl; +{-} PyNumber_Long:function (ob:PPyObject):PPyObject; cdecl; +{-} PyNumber_Lshift:function (ob1,ob2:PPyObject):PPyObject; cdecl; +{-} PyNumber_Multiply:function (ob1,ob2:PPyObject):PPyObject; cdecl; +{-} PyNumber_Negative:function (ob:PPyObject):PPyObject; cdecl; +{-} PyNumber_Or:function (ob1,ob2:PPyObject):PPyObject; cdecl; +{-} PyNumber_Positive:function (ob:PPyObject):PPyObject; cdecl; +{-} PyNumber_Power:function (ob1,ob2,ob3:PPyObject):PPyObject; cdecl; +{-} PyNumber_Remainder:function (ob1,ob2:PPyObject):PPyObject; cdecl; +{-} PyNumber_Rshift:function (ob1,ob2:PPyObject):PPyObject; cdecl; +{-} PyNumber_Subtract:function (ob1,ob2:PPyObject):PPyObject; cdecl; +{-} PyNumber_Xor:function (ob1,ob2:PPyObject):PPyObject; cdecl; +{-} PyOS_InitInterrupts:procedure; cdecl; +{-} PyOS_InterruptOccurred:function:integer; cdecl; +{-} PyObject_CallObject:function (ob,args:PPyObject):PPyObject; cdecl; +{-} PyObject_Compare:function (ob1,ob2:PPyObject):integer; cdecl; +{-} PyObject_GetAttr:function (ob1,ob2:PPyObject):PPyObject; cdecl; +{+} PyObject_GetAttrString:function (ob:PPyObject;c:PChar):PPyObject; cdecl; +{-} PyObject_GetItem:function (ob,key:PPyObject):PPyObject; cdecl; +{-} PyObject_DelItem:function (ob,key:PPyObject):PPyObject; cdecl; +{-} PyObject_HasAttrString:function (ob:PPyObject;key:PChar):integer; cdecl; +{-} PyObject_Hash:function (ob:PPyObject):LONGINT; cdecl; +{-} PyObject_IsTrue:function (ob:PPyObject):integer; cdecl; +{-} PyObject_Length:function (ob:PPyObject):integer; cdecl; +{-} PyObject_Repr:function (ob:PPyObject):PPyObject; cdecl; +{-} PyObject_SetAttr:function (ob1,ob2,ob3:PPyObject):integer; cdecl; +{-} PyObject_SetAttrString:function (ob:PPyObject;key:Pchar;value:PPyObject):integer; cdecl; +{-} PyObject_SetItem:function (ob1,ob2,ob3:PPyObject):integer; cdecl; +{-} PyObject_Init:function (ob:PPyObject; t:PPyTypeObject):PPyObject; cdecl; +{-} PyObject_InitVar:function (ob:PPyObject; t:PPyTypeObject; size:integer):PPyObject; cdecl; +{-} PyObject_New:function (t:PPyTypeObject):PPyObject; cdecl; +{-} PyObject_NewVar:function (t:PPyTypeObject; size:integer):PPyObject; cdecl; + PyObject_Free:procedure (ob:PPyObject); cdecl; +{-} PyObject_IsInstance:function (inst, cls:PPyObject):integer; cdecl; +{-} PyObject_IsSubclass:function (derived, cls:PPyObject):integer; cdecl; + PyObject_GenericGetAttr:function (obj, name: PPyObject): PPyObject; cdecl; + PyObject_GenericSetAttr:function (obj, name, value: PPyObject): Integer; cdecl; +{-} PyObject_GC_Malloc:function (size:integer):PPyObject; cdecl; +{-} PyObject_GC_New:function (t:PPyTypeObject):PPyObject; cdecl; +{-} PyObject_GC_NewVar:function (t:PPyTypeObject; size:integer):PPyObject; cdecl; +{-} PyObject_GC_Resize:function (t:PPyObject; newsize:integer):PPyObject; cdecl; +{-} PyObject_GC_Del:procedure (ob:PPyObject); cdecl; +{-} PyObject_GC_Track:procedure (ob:PPyObject); cdecl; +{-} PyObject_GC_UnTrack:procedure (ob:PPyObject); cdecl; +{-} PyRange_New:function (l1,l2,l3:longint;i:integer):PPyObject; cdecl; +{-} PySequence_Check:function (ob:PPyObject):integer; cdecl; +{-} PySequence_Concat:function (ob1,ob2:PPyObject):PPyObject; cdecl; +{-} PySequence_Count:function (ob1,ob2:PPyObject):integer; cdecl; +{-} PySequence_GetItem:function (ob:PPyObject;i:integer):PPyObject; cdecl; +{-} PySequence_GetSlice:function (ob:PPyObject;i1,i2:integer):PPyObject; cdecl; +{-} PySequence_In:function (ob1,ob2:PPyObject):integer; cdecl; +{-} PySequence_Index:function (ob1,ob2:PPyObject):integer; cdecl; +{-} PySequence_Length:function (ob:PPyObject):integer; cdecl; +{-} PySequence_Repeat:function (ob:PPyObject;count:integer):PPyObject; cdecl; +{-} PySequence_SetItem:function (ob:PPyObject;i:integer;value:PPyObject):integer; cdecl; +{-} PySequence_SetSlice:function (ob:PPyObject;i1,i2:integer;value:PPyObject):integer; cdecl; +{-} PySequence_DelSlice:function (ob:PPyObject;i1,i2:integer):integer; cdecl; +{-} PySequence_Tuple:function (ob:PPyObject):PPyObject; cdecl; +{-} PySequence_Contains:function (ob, value:PPyObject):integer; cdecl; +{-} PySlice_GetIndices:function (ob:PPySliceObject;length:integer;var start,stop,step:integer):integer; cdecl; +{-} PySlice_GetIndicesEx:function (ob:PPySliceObject;length:integer;var start,stop,step,slicelength:integer):integer; cdecl; +{-} PySlice_New:function (start,stop,step:PPyObject):PPyObject; cdecl; +{-} PyString_Concat:procedure(var ob1:PPyObject;ob2:PPyObject); cdecl; +{-} PyString_ConcatAndDel:procedure(var ob1:PPyObject;ob2:PPyObject); cdecl; +{-} PyString_Format:function (ob1,ob2:PPyObject):PPyObject; cdecl; +{-} PyString_FromStringAndSize:function (s:PChar;i:integer):PPyObject; cdecl; +{-} PyString_Size:function (ob:PPyObject):integer; cdecl; +{-} PyString_DecodeEscape:function(s:PChar; len:integer; errors:PChar; unicode:integer; recode_encoding:PChar):PPyObject; cdecl; +{-} PyString_Repr:function(ob:PPyObject; smartquotes:integer):PPyObject; cdecl; +{+} PySys_GetObject:function (s:PChar):PPyObject; cdecl; +{-} //PySys_Init:procedure; cdecl; +{-} PySys_SetObject:function (s:PChar;ob:PPyObject):integer; cdecl; +{-} PySys_SetPath:procedure(path:PChar); cdecl; +{-} //PyTraceBack_Fetch:function:PPyObject; cdecl; +{-} PyTraceBack_Here:function (p:pointer):integer; cdecl; +{-} PyTraceBack_Print:function (ob1,ob2:PPyObject):integer; cdecl; +{-} //PyTraceBack_Store:function (ob:PPyObject):integer; cdecl; +{+} PyTuple_GetItem:function (ob:PPyObject;i:integer):PPyObject; cdecl; +{-} PyTuple_GetSlice:function (ob:PPyObject;i1,i2:integer):PPyObject; cdecl; +{+} PyTuple_New:function (size:Integer):PPyObject; cdecl; +{+} PyTuple_SetItem:function (ob:PPyObject;key:integer;value:PPyObject):integer; cdecl; +{+} PyTuple_Size:function (ob:PPyObject):integer; cdecl; +{+} PyType_IsSubtype:function (a, b: PPyTypeObject):integer; cdecl; + PyType_GenericAlloc:function(atype: PPyTypeObject; nitems:Integer): PPyObject; cdecl; + PyType_GenericNew:function(atype: PPyTypeObject; args, kwds: PPyObject): PPyObject; cdecl; + PyType_Ready:function(atype: PPyTypeObject): integer; cdecl; +{+} PyUnicode_FromWideChar:function (const w:PWideChar; size:integer):PPyObject; cdecl; +{+} PyUnicode_AsWideChar:function (unicode: PPyObject; w:PWideChar; size:integer):integer; cdecl; +{-} PyUnicode_FromOrdinal:function (ordinal:integer):PPyObject; cdecl; + PyWeakref_GetObject: function (ref: PPyObject): PPyObject; cdecl; + PyWeakref_NewProxy: function (ob, callback: PPyObject): PPyObject; cdecl; + PyWeakref_NewRef: function (ob, callback: PPyObject): PPyObject; cdecl; + PyWrapper_New: function (ob1, ob2: PPyObject): PPyObject; cdecl; + PyBool_FromLong: function (ok: Integer): PPyObject; cdecl; +{-} Py_AtExit:function (proc: procedure):integer; cdecl; +{-} //Py_Cleanup:procedure; cdecl; +{-} Py_CompileString:function (s1,s2:PChar;i:integer):PPyObject; cdecl; +{-} Py_FatalError:procedure(s:PChar); cdecl; +{-} Py_FindMethod:function (md:PPyMethodDef;ob:PPyObject;key:PChar):PPyObject; cdecl; +{-} Py_FindMethodInChain:function (mc:PPyMethodChain;ob:PPyObject;key:PChar):PPyObject; cdecl; +{-} Py_FlushLine:procedure; cdecl; +{+} Py_Finalize: procedure; cdecl; +{-} PyErr_ExceptionMatches: function (exc: PPyObject): Integer; cdecl; +{-} PyErr_GivenExceptionMatches: function (raised_exc, exc: PPyObject): Integer; cdecl; +{-} PyEval_EvalCode: function (co: PPyCodeObject; globals, locals: PPyObject): PPyObject; cdecl; +{+} Py_GetVersion: function: PChar; cdecl; +{+} Py_GetCopyright: function: PChar; cdecl; +{+} Py_GetExecPrefix: function: PChar; cdecl; +{+} Py_GetPath: function: PChar; cdecl; +{+} Py_GetPrefix: function: PChar; cdecl; +{+} Py_GetProgramName: function: PChar; cdecl; + +{-} PyParser_SimpleParseString: function (str: PChar; start: Integer): PNode; cdecl; +{-} PyNode_Free: procedure(n: PNode); cdecl; +{-} PyErr_NewException: function (name: PChar; base, dict: PPyObject): PPyObject; cdecl; +{-} Py_Malloc: function (size: Integer): Pointer; +{-} PyMem_Malloc: function (size: Integer): Pointer; +{-} PyObject_CallMethod: function (obj: PPyObject; method, format: PChar): PPyObject; cdecl; + +{New exported Objects in Python 1.5} + Py_SetProgramName: procedure(name: PChar); cdecl; + Py_IsInitialized: function: integer; cdecl; + Py_GetProgramFullPath: function: PChar; cdecl; + Py_NewInterpreter: function: PPyThreadState; cdecl; + Py_EndInterpreter: procedure(tstate: PPyThreadState); cdecl; + PyEval_AcquireLock: procedure; cdecl; + PyEval_ReleaseLock: procedure; cdecl; + PyEval_AcquireThread: procedure(tstate: PPyThreadState); cdecl; + PyEval_ReleaseThread: procedure(tstate: PPyThreadState); cdecl; + PyInterpreterState_New: function: PPyInterpreterState; cdecl; + PyInterpreterState_Clear: procedure(interp: PPyInterpreterState); cdecl; + PyInterpreterState_Delete: procedure(interp: PPyInterpreterState); cdecl; + PyThreadState_New: function (interp: PPyInterpreterState): PPyThreadState; cdecl; + PyThreadState_Clear: procedure(tstate: PPyThreadState); cdecl; + PyThreadState_Delete: procedure(tstate: PPyThreadState); cdecl; + PyThreadState_Get: function: PPyThreadState; cdecl; + PyThreadState_Swap: function (tstate: PPyThreadState): PPyThreadState; cdecl; + +{Further exported Objects, may be implemented later} +{ + PyCode_New: Pointer; + PyErr_SetInterrupt: Pointer; + PyFile_AsFile: Pointer; + PyFile_FromFile: Pointer; + PyFloat_AsString: Pointer; + PyFrame_BlockPop: Pointer; + PyFrame_BlockSetup: Pointer; + PyFrame_ExtendStack: Pointer; + PyFrame_FastToLocals: Pointer; + PyFrame_LocalsToFast: Pointer; + PyFrame_New: Pointer; + PyGrammar_AddAccelerators: Pointer; + PyGrammar_FindDFA: Pointer; + PyGrammar_LabelRepr: Pointer; + PyInstance_DoBinOp: Pointer; + PyInt_GetMax: Pointer; + PyMarshal_Init: Pointer; + PyMarshal_ReadLongFromFile: Pointer; + PyMarshal_ReadObjectFromFile: Pointer; + PyMarshal_ReadObjectFromString: Pointer; + PyMarshal_WriteLongToFile: Pointer; + PyMarshal_WriteObjectToFile: Pointer; + PyMember_Get: Pointer; + PyMember_Set: Pointer; + PyNode_AddChild: Pointer; + PyNode_Compile: Pointer; + PyNode_New: Pointer; + PyOS_GetLastModificationTime: Pointer; + PyOS_Readline: Pointer; + PyOS_strtol: Pointer; + PyOS_strtoul: Pointer; + PyObject_CallFunction: Pointer; + PyObject_CallMethod: Pointer; + PyObject_Print: Pointer; + PyParser_AddToken: Pointer; + PyParser_Delete: Pointer; + PyParser_New: Pointer; + PyParser_ParseFile: Pointer; + PyParser_ParseString: Pointer; + PyParser_SimpleParseFile: Pointer; + PyRun_AnyFile: Pointer; + PyRun_File: Pointer; + PyRun_InteractiveLoop: Pointer; + PyRun_InteractiveOne: Pointer; + PyRun_SimpleFile: Pointer; + PySys_GetFile: Pointer; + PyToken_OneChar: Pointer; + PyToken_TwoChars: Pointer; + PyTokenizer_Free: Pointer; + PyTokenizer_FromFile: Pointer; + PyTokenizer_FromString: Pointer; + PyTokenizer_Get: Pointer; + Py_Main: Pointer; + _PyObject_NewVar: Pointer; + _PyParser_Grammar: Pointer; + _PyParser_TokenNames: Pointer; + _PyThread_Started: Pointer; + _Py_c_diff: Pointer; + _Py_c_neg: Pointer; + _Py_c_pow: Pointer; + _Py_c_prod: Pointer; + _Py_c_quot: Pointer; + _Py_c_sum: Pointer; +} +// functions redefined in Delphi +procedure Py_INCREF(op: PPyObject); +procedure Py_DECREF(op: PPyObject); +procedure Py_XINCREF(op: PPyObject); +procedure Py_XDECREF(op: PPyObject); + +// This function handles all cardinals, pointer types (with no adjustment of pointers!) +// (Extended) floats, which are handled as Python doubles and currencies, handled +// as (normalized) Python doubles. +function PyImport_ExecCodeModule(const name: String; codeobject: PPyObject): PPyObject; +function PyString_Check(obj: PPyObject): Boolean; +function PyString_CheckExact(obj: PPyObject): Boolean; +function PyFloat_Check(obj: PPyObject): Boolean; +function PyFloat_CheckExact(obj: PPyObject): Boolean; +function PyInt_Check(obj: PPyObject): Boolean; +function PyInt_CheckExact(obj: PPyObject): Boolean; +function PyLong_Check(obj: PPyObject): Boolean; +function PyLong_CheckExact(obj: PPyObject): Boolean; +function PyTuple_Check(obj: PPyObject): Boolean; +function PyTuple_CheckExact(obj: PPyObject): Boolean; +function PyInstance_Check(obj: PPyObject): Boolean; +function PyClass_Check(obj: PPyObject): Boolean; +function PyMethod_Check(obj: PPyObject): Boolean; +function PyList_Check(obj: PPyObject): Boolean; +function PyList_CheckExact(obj: PPyObject): Boolean; +function PyDict_Check(obj: PPyObject): Boolean; +function PyDict_CheckExact(obj: PPyObject): Boolean; +function PyModule_Check(obj: PPyObject): Boolean; +function PyModule_CheckExact(obj: PPyObject): Boolean; +function PySlice_Check(obj: PPyObject): Boolean; +function PyFunction_Check(obj: PPyObject): Boolean; +function PyUnicode_Check(obj: PPyObject): Boolean; +function PyUnicode_CheckExact(obj: PPyObject): Boolean; +function PyType_IS_GC(t: PPyTypeObject): Boolean; +function PyObject_IS_GC(obj: PPyObject): Boolean; +function PyWeakref_Check(obj: PPyObject): Boolean; +function PyWeakref_CheckRef(obj: PPyObject): Boolean; +function PyWeakref_CheckProxy(obj: PPyObject): Boolean; +function PyBool_Check(obj: PPyObject): Boolean; +function PyBaseString_Check(obj: PPyObject): Boolean; +function PyEnum_Check(obj: PPyObject): Boolean; +function PyObject_TypeCheck(obj:PPyObject; t:PPyTypeObject): Boolean; +function Py_InitModule(const name: PChar; md: PPyMethodDef): PPyObject; + +function PyType_HasFeature(AType: PPyTypeObject; AFlag: Integer): Boolean; + +implementation + +procedure Py_INCREF(op: PPyObject); +begin + Inc(op.ob_refcnt); +end; + +procedure Py_DECREF(op: PPyObject); +begin + Dec(op.ob_refcnt); + if op.ob_refcnt = 0 then begin + op.ob_type.tp_dealloc(op); + end; +end; + +procedure Py_XINCREF(op: PPyObject); +begin + if op <> nil then Py_INCREF(op); +end; + +procedure Py_XDECREF(op: PPyObject); +begin + if op <> nil then Py_DECREF(op); +end; + +function PyImport_ExecCodeModule(const name: String; + codeobject: PPyObject): PPyObject; +var + m, d, v, modules: PPyObject; +begin + m:= PyImport_AddModule(PChar(name)); + if m = nil then + begin + Result:= nil; + Exit; + end; + d:= PyModule_GetDict(m); + if PyDict_GetItemString(d, '__builtins__') = nil then + begin + if PyDict_SetItemString(d, '__builtins__', PyEval_GetBuiltins) <> 0 then + begin + Result:= nil; + Exit; + end; + end; + // Remember the fielname as the __file__ attribute + if PyDict_SetItemString(d, '__file__', PPyCodeObject(codeobject).co_filename) <> 0 then + PyErr_Clear(); // Not important enough to report + v:= PyEval_EvalCode(PPyCodeObject(codeobject), d, d); // XXX owner ? + if v = nil then + begin + Result:= nil; + Exit; + end; + Py_XDECREF(v); + modules:= PyImport_GetModuleDict(); + if PyDict_GetItemString(modules, PChar(name)) = nil then + begin + PyErr_SetString(PyExc_ImportError^, PChar(Format('Loaded module %.200s not found in sys.modules', [name]))); + Result:= nil; + Exit; + end; + Py_XINCREF(m); + Result:= m; +end; + +function PyString_Check(obj: PPyObject): Boolean; +begin + Result:= PyObject_TypeCheck(obj, PyString_Type); +end; + +function PyString_CheckExact(obj: PPyObject): Boolean; +begin + Result:= (obj <> nil) and (obj.ob_type = PPyTypeObject(PyString_Type)); +end; + +function PyFloat_Check(obj: PPyObject): Boolean; +begin + Result:= PyObject_TypeCheck(obj, PyFloat_Type); +end; + +function PyFloat_CheckExact(obj: PPyObject): Boolean; +begin + Result:= (obj <> nil) and (obj.ob_type = PPyTypeObject(PyFloat_Type)); +end; + +function PyInt_Check(obj: PPyObject): Boolean; +begin + Result:= PyObject_TypeCheck(obj, PyInt_Type); +end; + +function PyInt_CheckExact(obj: PPyObject): Boolean; +begin + Result:= (obj <> nil) and (obj.ob_type = PPyTypeObject(PyInt_Type)); +end; + +function PyLong_Check(obj: PPyObject): Boolean; +begin + Result:= PyObject_TypeCheck(obj, PyLong_Type); +end; + +function PyLong_CheckExact(obj: PPyObject): Boolean; +begin + Result:= (obj <> nil) and (obj.ob_type = PPyTypeObject(PyLong_Type)); +end; + +function PyTuple_Check(obj: PPyObject): Boolean; +begin + Result:= PyObject_TypeCheck(obj, PyTuple_Type); +end; + +function PyTuple_CheckExact(obj: PPyObject): Boolean; +begin + Result:= ( obj<> nil) and (obj^.ob_type = PPyTypeObject(PyTuple_Type)); +end; + +function PyInstance_Check(obj: PPyObject): Boolean; +begin + Result:= (obj <> nil) and (obj^.ob_type = PPyTypeObject(PyInstance_Type)); +end; + +function PyClass_Check(obj: PPyObject): Boolean; +begin + Result:= ( obj<> nil) and (obj^.ob_type = PPyTypeObject(PyClass_Type)); +end; + +function PyMethod_Check(obj: PPyObject): Boolean; +begin + Result:= (obj <> nil) and (obj^.ob_type = PPyTypeObject(PyMethod_Type)); +end; + +function PyList_Check(obj: PPyObject): Boolean; +begin + Result:= PyObject_TypeCheck(obj, PyList_Type); +end; + +function PyList_CheckExact(obj: PPyObject): Boolean; +begin + Result:= (obj<>nil) and (obj^.ob_type = PPyTypeObject(PyList_Type)); +end; + +function PyDict_Check(obj: PPyObject): Boolean; +begin + Result:= PyObject_TypeCheck(obj, PyDict_Type); +end; + +function PyDict_CheckExact(obj: PPyObject): Boolean; +begin + Result:= (obj<>nil) and (obj^.ob_type = PPyTypeObject(PyDict_Type)); +end; + +function PyModule_Check(obj: PPyObject): Boolean; +begin + Result:= PyObject_TypeCheck(obj, PyModule_Type); +end; + +function PyModule_CheckExact(obj: PPyObject): Boolean; +begin + Result:= (obj<>nil) and (obj^.ob_type = PPyTypeObject(PyModule_Type)); +end; + +function PySlice_Check(obj: PPyObject): Boolean; +begin + Result:= (obj<>nil) and (obj^.ob_type = PPyTypeObject(PySlice_Type)); +end; + +function PyFunction_Check(obj: PPyObject): Boolean; +begin + Result:= (obj<>nil) and + ((obj.ob_type = PPyTypeObject(PyCFunction_Type)) or + (obj.ob_type = PPyTypeObject(PyFunction_Type))); +end; + +function PyUnicode_Check(obj: PPyObject): Boolean; +begin + Result:= PyObject_TypeCheck(obj, PyUnicode_Type); +end; + +function PyUnicode_CheckExact(obj: PPyObject): Boolean; +begin + Result:= (obj<>nil) and (obj^.ob_type = PPyTypeObject(PyUnicode_Type)); +end; + +function PyType_IS_GC(t: PPyTypeObject): Boolean; +begin + Result:= PyType_HasFeature(t, Py_TPFLAGS_HAVE_GC); +end; + +function PyObject_IS_GC(obj: PPyObject): Boolean; +begin + Result:= PyType_IS_GC(obj.ob_type) and + ((obj.ob_type.tp_is_gc = nil) or (obj.ob_type.tp_is_gc(obj) = 1)); +end; + +function PyWeakref_Check(obj: PPyObject): Boolean; +begin + Result:= (obj<>nil) and (PyWeakref_CheckRef(obj) or PyWeakref_CheckProxy(obj)); +end; + +function PyWeakref_CheckRef(obj: PPyObject): Boolean; +begin + Result:= (obj<>nil) and (obj.ob_type = PPyTypeObject(PyWeakref_RefType)); +end; + +function PyWeakref_CheckProxy(obj: PPyObject): Boolean; +begin + Result:= (obj<>nil) and + ((obj.ob_type = PPyTypeObject(PyWeakref_ProxyType)) or + (obj.ob_type = PPyTypeObject(PyWeakref_CallableProxyType))); +end; + +function PyBool_Check(obj: PPyObject): Boolean; +begin + Result:= (obj<>nil) and (obj.ob_type = PPyTypeObject(PyBool_Type)); +end; + +function PyBaseString_Check(obj: PPyObject): Boolean; +begin + Result:= PyObject_TypeCheck(obj, PyBaseString_Type); +end; + +function PyEnum_Check(obj: PPyObject): Boolean; +begin + Result:= (obj<>nil) and (obj.ob_type = PPyTypeObject(PyEnum_Type)); +end; + +function PyObject_TypeCheck(obj: PPyObject; t: PPyTypeObject): Boolean; +begin + Result:= (obj<>nil) and (obj.ob_type = t); + if not Result and (obj<>nil) and (t<>nil) then + Result:= PyType_IsSubtype(obj.ob_type, t) = 1; +end; + +function Py_InitModule(const name: PChar; md: PPyMethodDef): PPyObject; +begin + result:= Py_InitModule4(name, md, nil, nil, 1012); +end; + +function PyType_HasFeature(AType: PPyTypeObject; AFlag: Integer): Boolean; +begin + //(((t)->tp_flags & (f)) != 0) + Result:= (AType.tp_flags and AFlag) <> 0; +end; + +procedure init(lib: TLibHandle); +begin + Py_DebugFlag := getProcAddr(lib, 'Py_DebugFlag'); + Py_VerboseFlag := getProcAddr(lib, 'Py_VerboseFlag'); + Py_InteractiveFlag := getProcAddr(lib, 'Py_InteractiveFlag'); + Py_OptimizeFlag := getProcAddr(lib, 'Py_OptimizeFlag'); + Py_NoSiteFlag := getProcAddr(lib, 'Py_NoSiteFlag'); + Py_UseClassExceptionsFlag := getProcAddr(lib, 'Py_UseClassExceptionsFlag'); + Py_FrozenFlag := getProcAddr(lib, 'Py_FrozenFlag'); + Py_TabcheckFlag := getProcAddr(lib, 'Py_TabcheckFlag'); + Py_UnicodeFlag := getProcAddr(lib, 'Py_UnicodeFlag'); + + Py_IgnoreEnvironmentFlag := getProcAddr(lib, 'Py_IgnoreEnvironmentFlag'); + Py_DivisionWarningFlag := getProcAddr(lib, 'Py_DivisionWarningFlag'); + Py_None := getProcAddr(lib, '_Py_NoneStruct'); + Py_Ellipsis := getProcAddr(lib, '_Py_EllipsisObject'); + Py_False := getProcAddr(lib, '_Py_ZeroStruct'); + Py_True := getProcAddr(lib, '_Py_TrueStruct'); + Py_NotImplemented := getProcAddr(lib, '_Py_NotImplementedStruct'); + + PyImport_FrozenModules := getProcAddr(lib, 'PyImport_FrozenModules'); + + PyExc_AttributeError := getProcAddr(lib, 'PyExc_AttributeError'); + PyExc_EOFError := getProcAddr(lib, 'PyExc_EOFError'); + PyExc_IOError := getProcAddr(lib, 'PyExc_IOError'); + PyExc_ImportError := getProcAddr(lib, 'PyExc_ImportError'); + PyExc_IndexError := getProcAddr(lib, 'PyExc_IndexError'); + PyExc_KeyError := getProcAddr(lib, 'PyExc_KeyError'); + PyExc_KeyboardInterrupt := getProcAddr(lib, 'PyExc_KeyboardInterrupt'); + PyExc_MemoryError := getProcAddr(lib, 'PyExc_MemoryError'); + PyExc_NameError := getProcAddr(lib, 'PyExc_NameError'); + PyExc_OverflowError := getProcAddr(lib, 'PyExc_OverflowError'); + PyExc_RuntimeError := getProcAddr(lib, 'PyExc_RuntimeError'); + PyExc_SyntaxError := getProcAddr(lib, 'PyExc_SyntaxError'); + PyExc_SystemError := getProcAddr(lib, 'PyExc_SystemError'); + PyExc_SystemExit := getProcAddr(lib, 'PyExc_SystemExit'); + PyExc_TypeError := getProcAddr(lib, 'PyExc_TypeError'); + PyExc_ValueError := getProcAddr(lib, 'PyExc_ValueError'); + PyExc_ZeroDivisionError := getProcAddr(lib, 'PyExc_ZeroDivisionError'); + PyExc_ArithmeticError := getProcAddr(lib, 'PyExc_ArithmeticError'); + PyExc_Exception := getProcAddr(lib, 'PyExc_Exception'); + PyExc_FloatingPointError := getProcAddr(lib, 'PyExc_FloatingPointError'); + PyExc_LookupError := getProcAddr(lib, 'PyExc_LookupError'); + PyExc_StandardError := getProcAddr(lib, 'PyExc_StandardError'); + + PyExc_AssertionError := getProcAddr(lib, 'PyExc_AssertionError'); + PyExc_EnvironmentError := getProcAddr(lib, 'PyExc_EnvironmentError'); + PyExc_IndentationError := getProcAddr(lib, 'PyExc_IndentationError'); + PyExc_MemoryErrorInst := getProcAddr(lib, 'PyExc_MemoryErrorInst'); + PyExc_NotImplementedError := getProcAddr(lib, 'PyExc_NotImplementedError'); + PyExc_OSError := getProcAddr(lib, 'PyExc_OSError'); + PyExc_TabError := getProcAddr(lib, 'PyExc_TabError'); + PyExc_UnboundLocalError := getProcAddr(lib, 'PyExc_UnboundLocalError'); + PyExc_UnicodeError := getProcAddr(lib, 'PyExc_UnicodeError'); + + PyExc_Warning := getProcAddr(lib, 'PyExc_Warning'); + PyExc_DeprecationWarning := getProcAddr(lib, 'PyExc_DeprecationWarning'); + PyExc_RuntimeWarning := getProcAddr(lib, 'PyExc_RuntimeWarning'); + PyExc_SyntaxWarning := getProcAddr(lib, 'PyExc_SyntaxWarning'); + PyExc_UserWarning := getProcAddr(lib, 'PyExc_UserWarning'); + + PyExc_OverflowWarning := getProcAddr(lib, 'PyExc_OverflowWarning'); + PyExc_ReferenceError := getProcAddr(lib, 'PyExc_ReferenceError'); + PyExc_StopIteration := getProcAddr(lib, 'PyExc_StopIteration'); + + PyExc_FutureWarning := getProcAddr(lib, 'PyExc_FutureWarning'); + PyExc_PendingDeprecationWarning:= getProcAddr(lib, 'PyExc_PendingDeprecationWarning'); + PyExc_UnicodeDecodeError := getProcAddr(lib, 'PyExc_UnicodeDecodeError'); + PyExc_UnicodeEncodeError := getProcAddr(lib, 'PyExc_UnicodeEncodeError'); + PyExc_UnicodeTranslateError:= getProcAddr(lib, 'PyExc_UnicodeTranslateError'); + + PyType_Type := getProcAddr(lib, 'PyType_Type'); + PyCFunction_Type := getProcAddr(lib, 'PyCFunction_Type'); + PyCObject_Type := getProcAddr(lib, 'PyCObject_Type'); + PyClass_Type := getProcAddr(lib, 'PyClass_Type'); + PyCode_Type := getProcAddr(lib, 'PyCode_Type'); + PyComplex_Type := getProcAddr(lib, 'PyComplex_Type'); + PyDict_Type := getProcAddr(lib, 'PyDict_Type'); + PyFile_Type := getProcAddr(lib, 'PyFile_Type'); + PyFloat_Type := getProcAddr(lib, 'PyFloat_Type'); + PyFrame_Type := getProcAddr(lib, 'PyFrame_Type'); + PyFunction_Type := getProcAddr(lib, 'PyFunction_Type'); + PyInstance_Type := getProcAddr(lib, 'PyInstance_Type'); + PyInt_Type := getProcAddr(lib, 'PyInt_Type'); + PyList_Type := getProcAddr(lib, 'PyList_Type'); + PyLong_Type := getProcAddr(lib, 'PyLong_Type'); + PyMethod_Type := getProcAddr(lib, 'PyMethod_Type'); + PyModule_Type := getProcAddr(lib, 'PyModule_Type'); + PyObject_Type := getProcAddr(lib, 'PyObject_Type'); + PyRange_Type := getProcAddr(lib, 'PyRange_Type'); + PySlice_Type := getProcAddr(lib, 'PySlice_Type'); + PyString_Type := getProcAddr(lib, 'PyString_Type'); + PyTuple_Type := getProcAddr(lib, 'PyTuple_Type'); + + PyUnicode_Type := getProcAddr(lib, 'PyUnicode_Type'); + + PyBaseObject_Type := getProcAddr(lib, 'PyBaseObject_Type'); + PyBuffer_Type := getProcAddr(lib, 'PyBuffer_Type'); + PyCallIter_Type := getProcAddr(lib, 'PyCallIter_Type'); + PyCell_Type := getProcAddr(lib, 'PyCell_Type'); + PyClassMethod_Type := getProcAddr(lib, 'PyClassMethod_Type'); + PyProperty_Type := getProcAddr(lib, 'PyProperty_Type'); + PySeqIter_Type := getProcAddr(lib, 'PySeqIter_Type'); + PyStaticMethod_Type := getProcAddr(lib, 'PyStaticMethod_Type'); + PySuper_Type := getProcAddr(lib, 'PySuper_Type'); + PySymtableEntry_Type := getProcAddr(lib, 'PySymtableEntry_Type'); + PyTraceBack_Type := getProcAddr(lib, 'PyTraceBack_Type'); + PyWrapperDescr_Type := getProcAddr(lib, 'PyWrapperDescr_Type'); + + PyBaseString_Type := getProcAddr(lib, 'PyBaseString_Type'); + PyBool_Type := getProcAddr(lib, 'PyBool_Type'); + PyEnum_Type := getProcAddr(lib, 'PyEnum_Type'); + + + //PyArg_GetObject := getProcAddr(lib, 'PyArg_GetObject'); + //PyArg_GetLong := getProcAddr(lib, 'PyArg_GetLong'); + //PyArg_GetShort := getProcAddr(lib, 'PyArg_GetShort'); + //PyArg_GetFloat := getProcAddr(lib, 'PyArg_GetFloat'); + //PyArg_GetString := getProcAddr(lib, 'PyArg_GetString'); + //PyArgs_VaParse := getProcAddr(lib, 'PyArgs_VaParse'); + //Py_VaBuildValue := getProcAddr(lib, 'Py_VaBuildValue'); + //PyBuiltin_Init := getProcAddr(lib, 'PyBuiltin_Init'); + PyComplex_FromCComplex := getProcAddr(lib, 'PyComplex_FromCComplex'); + PyComplex_FromDoubles := getProcAddr(lib, 'PyComplex_FromDoubles'); + PyComplex_RealAsDouble := getProcAddr(lib, 'PyComplex_RealAsDouble'); + PyComplex_ImagAsDouble := getProcAddr(lib, 'PyComplex_ImagAsDouble'); + PyComplex_AsCComplex := getProcAddr(lib, 'PyComplex_AsCComplex'); + PyCFunction_GetFunction := getProcAddr(lib, 'PyCFunction_GetFunction'); + PyCFunction_GetSelf := getProcAddr(lib, 'PyCFunction_GetSelf'); + PyCallable_Check := getProcAddr(lib, 'PyCallable_Check'); + PyCObject_FromVoidPtr := getProcAddr(lib, 'PyCObject_FromVoidPtr'); + PyCObject_AsVoidPtr := getProcAddr(lib, 'PyCObject_AsVoidPtr'); + PyClass_New := getProcAddr(lib, 'PyClass_New'); + PyClass_IsSubclass := getProcAddr(lib, 'PyClass_IsSubclass'); + PyDict_GetItem := getProcAddr(lib, 'PyDict_GetItem'); + PyDict_SetItem := getProcAddr(lib, 'PyDict_SetItem'); + PyDict_DelItem := getProcAddr(lib, 'PyDict_DelItem'); + PyDict_Clear := getProcAddr(lib, 'PyDict_Clear'); + PyDict_Next := getProcAddr(lib, 'PyDict_Next'); + PyDict_Keys := getProcAddr(lib, 'PyDict_Keys'); + PyDict_Values := getProcAddr(lib, 'PyDict_Values'); + PyDict_Items := getProcAddr(lib, 'PyDict_Items'); + PyDict_Size := getProcAddr(lib, 'PyDict_Size'); + PyDict_DelItemString := getProcAddr(lib, 'PyDict_DelItemString'); + PyDictProxy_New := getProcAddr(lib, 'PyDictProxy_New'); + Py_InitModule4 := getProcAddr(lib, 'Py_InitModule4'); + PyErr_Print := getProcAddr(lib, 'PyErr_Print'); + PyErr_SetNone := getProcAddr(lib, 'PyErr_SetNone'); + PyErr_SetObject := getProcAddr(lib, 'PyErr_SetObject'); + PyErr_Restore := getProcAddr(lib, 'PyErr_Restore'); + PyErr_BadArgument := getProcAddr(lib, 'PyErr_BadArgument'); + PyErr_NoMemory := getProcAddr(lib, 'PyErr_NoMemory'); + PyErr_SetFromErrno := getProcAddr(lib, 'PyErr_SetFromErrno'); + PyErr_BadInternalCall := getProcAddr(lib, 'PyErr_BadInternalCall'); + PyErr_CheckSignals := getProcAddr(lib, 'PyErr_CheckSignals'); + PyErr_Occurred := getProcAddr(lib, 'PyErr_Occurred'); + PyErr_Clear := getProcAddr(lib, 'PyErr_Clear'); + PyErr_Fetch := getProcAddr(lib, 'PyErr_Fetch'); + PyErr_SetString := getProcAddr(lib, 'PyErr_SetString'); + PyEval_GetBuiltins := getProcAddr(lib, 'PyEval_GetBuiltins'); + PyImport_GetModuleDict := getProcAddr(lib, 'PyImport_GetModuleDict'); + PyInt_FromLong := getProcAddr(lib, 'PyInt_FromLong'); + PyArg_ParseTuple := getProcAddr(lib, 'PyArg_ParseTuple'); + PyArg_Parse := getProcAddr(lib, 'PyArg_Parse'); + Py_BuildValue := getProcAddr(lib, 'Py_BuildValue'); + Py_Initialize := getProcAddr(lib, 'Py_Initialize'); + PyDict_New := getProcAddr(lib, 'PyDict_New'); + PyDict_SetItemString := getProcAddr(lib, 'PyDict_SetItemString'); + PyModule_GetDict := getProcAddr(lib, 'PyModule_GetDict'); + PyObject_Str := getProcAddr(lib, 'PyObject_Str'); + PyRun_String := getProcAddr(lib, 'PyRun_String'); + PyRun_SimpleString := getProcAddr(lib, 'PyRun_SimpleString'); + PyDict_GetItemString := getProcAddr(lib, 'PyDict_GetItemString'); + PyString_AsString := getProcAddr(lib, 'PyString_AsString'); + PyString_FromString := getProcAddr(lib, 'PyString_FromString'); + PySys_SetArgv := getProcAddr(lib, 'PySys_SetArgv'); + Py_Exit := getProcAddr(lib, 'Py_Exit'); + + PyCFunction_New :=getProcAddr(lib, 'PyCFunction_New'); + PyEval_CallObject :=getProcAddr(lib, 'PyEval_CallObject'); + PyEval_CallObjectWithKeywords:=getProcAddr(lib, 'PyEval_CallObjectWithKeywords'); + PyEval_GetFrame :=getProcAddr(lib, 'PyEval_GetFrame'); + PyEval_GetGlobals :=getProcAddr(lib, 'PyEval_GetGlobals'); + PyEval_GetLocals :=getProcAddr(lib, 'PyEval_GetLocals'); + //PyEval_GetOwner :=getProcAddr(lib, 'PyEval_GetOwner'); + PyEval_GetRestricted :=getProcAddr(lib, 'PyEval_GetRestricted'); + PyEval_InitThreads :=getProcAddr(lib, 'PyEval_InitThreads'); + PyEval_RestoreThread :=getProcAddr(lib, 'PyEval_RestoreThread'); + PyEval_SaveThread :=getProcAddr(lib, 'PyEval_SaveThread'); + PyFile_FromString :=getProcAddr(lib, 'PyFile_FromString'); + PyFile_GetLine :=getProcAddr(lib, 'PyFile_GetLine'); + PyFile_Name :=getProcAddr(lib, 'PyFile_Name'); + PyFile_SetBufSize :=getProcAddr(lib, 'PyFile_SetBufSize'); + PyFile_SoftSpace :=getProcAddr(lib, 'PyFile_SoftSpace'); + PyFile_WriteObject :=getProcAddr(lib, 'PyFile_WriteObject'); + PyFile_WriteString :=getProcAddr(lib, 'PyFile_WriteString'); + PyFloat_AsDouble :=getProcAddr(lib, 'PyFloat_AsDouble'); + PyFloat_FromDouble :=getProcAddr(lib, 'PyFloat_FromDouble'); + PyFunction_GetCode :=getProcAddr(lib, 'PyFunction_GetCode'); + PyFunction_GetGlobals :=getProcAddr(lib, 'PyFunction_GetGlobals'); + PyFunction_New :=getProcAddr(lib, 'PyFunction_New'); + PyImport_AddModule :=getProcAddr(lib, 'PyImport_AddModule'); + PyImport_Cleanup :=getProcAddr(lib, 'PyImport_Cleanup'); + PyImport_GetMagicNumber :=getProcAddr(lib, 'PyImport_GetMagicNumber'); + PyImport_ImportFrozenModule:=getProcAddr(lib, 'PyImport_ImportFrozenModule'); + PyImport_ImportModule :=getProcAddr(lib, 'PyImport_ImportModule'); + PyImport_Import :=getProcAddr(lib, 'PyImport_Import'); + //@PyImport_Init :=getProcAddr(lib, 'PyImport_Init'); + PyImport_ReloadModule :=getProcAddr(lib, 'PyImport_ReloadModule'); + PyInstance_New :=getProcAddr(lib, 'PyInstance_New'); + PyInt_AsLong :=getProcAddr(lib, 'PyInt_AsLong'); + PyList_Append :=getProcAddr(lib, 'PyList_Append'); + PyList_AsTuple :=getProcAddr(lib, 'PyList_AsTuple'); + PyList_GetItem :=getProcAddr(lib, 'PyList_GetItem'); + PyList_GetSlice :=getProcAddr(lib, 'PyList_GetSlice'); + PyList_Insert :=getProcAddr(lib, 'PyList_Insert'); + PyList_New :=getProcAddr(lib, 'PyList_New'); + PyList_Reverse :=getProcAddr(lib, 'PyList_Reverse'); + PyList_SetItem :=getProcAddr(lib, 'PyList_SetItem'); + PyList_SetSlice :=getProcAddr(lib, 'PyList_SetSlice'); + PyList_Size :=getProcAddr(lib, 'PyList_Size'); + PyList_Sort :=getProcAddr(lib, 'PyList_Sort'); + PyLong_AsDouble :=getProcAddr(lib, 'PyLong_AsDouble'); + PyLong_AsLong :=getProcAddr(lib, 'PyLong_AsLong'); + PyLong_FromDouble :=getProcAddr(lib, 'PyLong_FromDouble'); + PyLong_FromLong :=getProcAddr(lib, 'PyLong_FromLong'); + PyLong_FromString :=getProcAddr(lib, 'PyLong_FromString'); + PyLong_FromString :=getProcAddr(lib, 'PyLong_FromString'); + PyLong_FromUnsignedLong :=getProcAddr(lib, 'PyLong_FromUnsignedLong'); + PyLong_AsUnsignedLong :=getProcAddr(lib, 'PyLong_AsUnsignedLong'); + PyLong_FromUnicode :=getProcAddr(lib, 'PyLong_FromUnicode'); + PyLong_FromLongLong :=getProcAddr(lib, 'PyLong_FromLongLong'); + PyLong_AsLongLong :=getProcAddr(lib, 'PyLong_AsLongLong'); + + PyMapping_Check :=getProcAddr(lib, 'PyMapping_Check'); + PyMapping_GetItemString :=getProcAddr(lib, 'PyMapping_GetItemString'); + PyMapping_HasKey :=getProcAddr(lib, 'PyMapping_HasKey'); + PyMapping_HasKeyString :=getProcAddr(lib, 'PyMapping_HasKeyString'); + PyMapping_Length :=getProcAddr(lib, 'PyMapping_Length'); + PyMapping_SetItemString :=getProcAddr(lib, 'PyMapping_SetItemString'); + PyMethod_Class :=getProcAddr(lib, 'PyMethod_Class'); + PyMethod_Function :=getProcAddr(lib, 'PyMethod_Function'); + PyMethod_New :=getProcAddr(lib, 'PyMethod_New'); + PyMethod_Self :=getProcAddr(lib, 'PyMethod_Self'); + PyModule_GetName :=getProcAddr(lib, 'PyModule_GetName'); + PyModule_New :=getProcAddr(lib, 'PyModule_New'); + PyNumber_Absolute :=getProcAddr(lib, 'PyNumber_Absolute'); + PyNumber_Add :=getProcAddr(lib, 'PyNumber_Add'); + PyNumber_And :=getProcAddr(lib, 'PyNumber_And'); + PyNumber_Check :=getProcAddr(lib, 'PyNumber_Check'); + PyNumber_Coerce :=getProcAddr(lib, 'PyNumber_Coerce'); + PyNumber_Divide :=getProcAddr(lib, 'PyNumber_Divide'); + + PyNumber_FloorDivide :=getProcAddr(lib, 'PyNumber_FloorDivide'); + PyNumber_TrueDivide :=getProcAddr(lib, 'PyNumber_TrueDivide'); + PyNumber_Divmod :=getProcAddr(lib, 'PyNumber_Divmod'); + PyNumber_Float :=getProcAddr(lib, 'PyNumber_Float'); + PyNumber_Int :=getProcAddr(lib, 'PyNumber_Int'); + PyNumber_Invert :=getProcAddr(lib, 'PyNumber_Invert'); + PyNumber_Long :=getProcAddr(lib, 'PyNumber_Long'); + PyNumber_Lshift :=getProcAddr(lib, 'PyNumber_Lshift'); + PyNumber_Multiply :=getProcAddr(lib, 'PyNumber_Multiply'); + PyNumber_Negative :=getProcAddr(lib, 'PyNumber_Negative'); + PyNumber_Or :=getProcAddr(lib, 'PyNumber_Or'); + PyNumber_Positive :=getProcAddr(lib, 'PyNumber_Positive'); + PyNumber_Power :=getProcAddr(lib, 'PyNumber_Power'); + PyNumber_Remainder :=getProcAddr(lib, 'PyNumber_Remainder'); + PyNumber_Rshift :=getProcAddr(lib, 'PyNumber_Rshift'); + PyNumber_Subtract :=getProcAddr(lib, 'PyNumber_Subtract'); + PyNumber_Xor :=getProcAddr(lib, 'PyNumber_Xor'); + PyOS_InitInterrupts :=getProcAddr(lib, 'PyOS_InitInterrupts'); + PyOS_InterruptOccurred :=getProcAddr(lib, 'PyOS_InterruptOccurred'); + PyObject_CallObject :=getProcAddr(lib, 'PyObject_CallObject'); + PyObject_Compare :=getProcAddr(lib, 'PyObject_Compare'); + PyObject_GetAttr :=getProcAddr(lib, 'PyObject_GetAttr'); + PyObject_GetAttrString :=getProcAddr(lib, 'PyObject_GetAttrString'); + PyObject_GetItem :=getProcAddr(lib, 'PyObject_GetItem'); + PyObject_DelItem :=getProcAddr(lib, 'PyObject_DelItem'); + PyObject_HasAttrString :=getProcAddr(lib, 'PyObject_HasAttrString'); + PyObject_Hash :=getProcAddr(lib, 'PyObject_Hash'); + PyObject_IsTrue :=getProcAddr(lib, 'PyObject_IsTrue'); + PyObject_Length :=getProcAddr(lib, 'PyObject_Length'); + PyObject_Repr :=getProcAddr(lib, 'PyObject_Repr'); + PyObject_SetAttr :=getProcAddr(lib, 'PyObject_SetAttr'); + PyObject_SetAttrString :=getProcAddr(lib, 'PyObject_SetAttrString'); + PyObject_SetItem :=getProcAddr(lib, 'PyObject_SetItem'); + + PyObject_Init :=getProcAddr(lib, 'PyObject_Init'); + PyObject_InitVar :=getProcAddr(lib, 'PyObject_InitVar'); + PyObject_New :=getProcAddr(lib, '_PyObject_New'); + PyObject_NewVar :=getProcAddr(lib, '_PyObject_NewVar'); + PyObject_Free :=getProcAddr(lib, 'PyObject_Free'); + + PyObject_IsInstance :=getProcAddr(lib, 'PyObject_IsInstance'); + PyObject_IsSubclass :=getProcAddr(lib, 'PyObject_IsSubclass'); + + PyObject_GenericGetAttr :=getProcAddr(lib, 'PyObject_GenericGetAttr'); + PyObject_GenericSetAttr :=getProcAddr(lib, 'PyObject_GenericSetAttr'); + + PyObject_GC_Malloc :=getProcAddr(lib, '_PyObject_GC_Malloc'); + PyObject_GC_New :=getProcAddr(lib, '_PyObject_GC_New'); + PyObject_GC_NewVar :=getProcAddr(lib, '_PyObject_GC_NewVar'); + PyObject_GC_Resize :=getProcAddr(lib, '_PyObject_GC_Resize'); + PyObject_GC_Del :=getProcAddr(lib, 'PyObject_GC_Del'); + PyObject_GC_Track :=getProcAddr(lib, 'PyObject_GC_Track'); + PyObject_GC_UnTrack :=getProcAddr(lib, 'PyObject_GC_UnTrack'); + + PyRange_New :=getProcAddr(lib, 'PyRange_New'); + PySequence_Check :=getProcAddr(lib, 'PySequence_Check'); + PySequence_Concat :=getProcAddr(lib, 'PySequence_Concat'); + PySequence_Count :=getProcAddr(lib, 'PySequence_Count'); + PySequence_GetItem :=getProcAddr(lib, 'PySequence_GetItem'); + PySequence_GetSlice :=getProcAddr(lib, 'PySequence_GetSlice'); + PySequence_In :=getProcAddr(lib, 'PySequence_In'); + PySequence_Index :=getProcAddr(lib, 'PySequence_Index'); + PySequence_Length :=getProcAddr(lib, 'PySequence_Length'); + PySequence_Repeat :=getProcAddr(lib, 'PySequence_Repeat'); + PySequence_SetItem :=getProcAddr(lib, 'PySequence_SetItem'); + PySequence_SetSlice :=getProcAddr(lib, 'PySequence_SetSlice'); + PySequence_DelSlice :=getProcAddr(lib, 'PySequence_DelSlice'); + PySequence_Tuple :=getProcAddr(lib, 'PySequence_Tuple'); + PySequence_Contains :=getProcAddr(lib, 'PySequence_Contains'); + PySlice_GetIndices :=getProcAddr(lib, 'PySlice_GetIndices'); + PySlice_GetIndicesEx :=getProcAddr(lib, 'PySlice_GetIndicesEx'); + PySlice_New :=getProcAddr(lib, 'PySlice_New'); + PyString_Concat :=getProcAddr(lib, 'PyString_Concat'); + PyString_ConcatAndDel :=getProcAddr(lib, 'PyString_ConcatAndDel'); + PyString_Format :=getProcAddr(lib, 'PyString_Format'); + PyString_FromStringAndSize:=getProcAddr(lib, 'PyString_FromStringAndSize'); + PyString_Size :=getProcAddr(lib, 'PyString_Size'); + PyString_DecodeEscape :=getProcAddr(lib, 'PyString_DecodeEscape'); + PyString_Repr :=getProcAddr(lib, 'PyString_Repr'); + PySys_GetObject :=getProcAddr(lib, 'PySys_GetObject'); + //PySys_Init :=getProcAddr(lib, 'PySys_Init'); + PySys_SetObject :=getProcAddr(lib, 'PySys_SetObject'); + PySys_SetPath :=getProcAddr(lib, 'PySys_SetPath'); + //PyTraceBack_Fetch :=getProcAddr(lib, 'PyTraceBack_Fetch'); + PyTraceBack_Here :=getProcAddr(lib, 'PyTraceBack_Here'); + PyTraceBack_Print :=getProcAddr(lib, 'PyTraceBack_Print'); + //PyTraceBack_Store :=getProcAddr(lib, 'PyTraceBack_Store'); + PyTuple_GetItem :=getProcAddr(lib, 'PyTuple_GetItem'); + PyTuple_GetSlice :=getProcAddr(lib, 'PyTuple_GetSlice'); + PyTuple_New :=getProcAddr(lib, 'PyTuple_New'); + PyTuple_SetItem :=getProcAddr(lib, 'PyTuple_SetItem'); + PyTuple_Size :=getProcAddr(lib, 'PyTuple_Size'); + + PyType_IsSubtype :=getProcAddr(lib, 'PyType_IsSubtype'); + PyType_GenericAlloc :=getProcAddr(lib, 'PyType_GenericAlloc'); + PyType_GenericNew :=getProcAddr(lib, 'PyType_GenericNew'); + PyType_Ready :=getProcAddr(lib, 'PyType_Ready'); + + PyUnicode_FromWideChar :=getProcAddr(lib, 'PyUnicodeUCS2_FromWideChar'); + PyUnicode_AsWideChar :=getProcAddr(lib, 'PyUnicodeUCS2_AsWideChar'); + PyUnicode_FromOrdinal :=getProcAddr(lib, 'PyUnicodeUCS2_FromOrdinal'); + + PyWeakref_GetObject :=getProcAddr(lib, 'PyWeakref_GetObject'); + PyWeakref_NewProxy :=getProcAddr(lib, 'PyWeakref_NewProxy'); + PyWeakref_NewRef :=getProcAddr(lib, 'PyWeakref_NewRef'); + PyWrapper_New :=getProcAddr(lib, 'PyWrapper_New'); + + PyBool_FromLong :=getProcAddr(lib, 'PyBool_FromLong'); + + Py_AtExit :=getProcAddr(lib, 'Py_AtExit'); + //Py_Cleanup :=getProcAddr(lib, 'Py_Cleanup'); + Py_CompileString :=getProcAddr(lib, 'Py_CompileString'); + Py_FatalError :=getProcAddr(lib, 'Py_FatalError'); + Py_FindMethod :=getProcAddr(lib, 'Py_FindMethod'); + Py_FindMethodInChain :=getProcAddr(lib, 'Py_FindMethodInChain'); + Py_FlushLine :=getProcAddr(lib, 'Py_FlushLine'); + Py_Finalize :=getProcAddr(lib, 'Py_Finalize'); + PyCode_Addr2Line := getProcAddr(lib, 'PyCode_Addr2Line'); + PyClass_IsSubclass :=getProcAddr(lib, 'PyClass_IsSubclass'); + PyErr_ExceptionMatches :=getProcAddr(lib, 'PyErr_ExceptionMatches'); + PyErr_GivenExceptionMatches:=getProcAddr(lib, 'PyErr_GivenExceptionMatches'); + PyEval_EvalCode :=getProcAddr(lib, 'PyEval_EvalCode'); + Py_GetVersion :=getProcAddr(lib, 'Py_GetVersion'); + Py_GetCopyright :=getProcAddr(lib, 'Py_GetCopyright'); + Py_GetExecPrefix :=getProcAddr(lib, 'Py_GetExecPrefix'); + Py_GetPath :=getProcAddr(lib, 'Py_GetPath'); + Py_GetPrefix :=getProcAddr(lib, 'Py_GetPrefix'); + Py_GetProgramName :=getProcAddr(lib, 'Py_GetProgramName'); + PyParser_SimpleParseString :=getProcAddr(lib, 'PyParser_SimpleParseString'); + PyNode_Free :=getProcAddr(lib, 'PyNode_Free'); + PyErr_NewException :=getProcAddr(lib, 'PyErr_NewException'); +/// jah 29-sep-2000 : updated for python 2.0 +/// replaced Py_Malloc with PyMem_Malloc +///--- @Py_Malloc := Import ('Py_Malloc'); +///+++ @Py_Malloc := Import ('PyMem_Malloc'); + Py_Malloc := getProcAddr(lib, 'PyMem_Malloc'); + PyMem_Malloc := getProcAddr(lib, 'PyMem_Malloc'); + PyObject_CallMethod := getProcAddr(lib, 'PyObject_CallMethod'); + Py_SetProgramName := getProcAddr(lib, 'Py_SetProgramName'); + Py_IsInitialized := getProcAddr(lib, 'Py_IsInitialized'); + Py_GetProgramFullPath := getProcAddr(lib, 'Py_GetProgramFullPath'); + DLL_Py_GetBuildInfo := getProcAddr(lib, 'Py_GetBuildInfo'); + Py_NewInterpreter := getProcAddr(lib, 'Py_NewInterpreter'); + Py_EndInterpreter := getProcAddr(lib, 'Py_EndInterpreter'); + PyEval_AcquireLock := getProcAddr(lib, 'PyEval_AcquireLock'); + PyEval_ReleaseLock := getProcAddr(lib, 'PyEval_ReleaseLock'); + PyEval_AcquireThread := getProcAddr(lib, 'PyEval_AcquireThread'); + PyEval_ReleaseThread := getProcAddr(lib, 'PyEval_ReleaseThread'); + PyInterpreterState_New := getProcAddr(lib, 'PyInterpreterState_New'); + PyInterpreterState_Clear := getProcAddr(lib, 'PyInterpreterState_Clear'); + PyInterpreterState_Delete:= getProcAddr(lib, 'PyInterpreterState_Delete'); + PyThreadState_New := getProcAddr(lib, 'PyThreadState_New'); + PyThreadState_Clear := getProcAddr(lib, 'PyThreadState_Clear'); + PyThreadState_Delete := getProcAddr(lib, 'PyThreadState_Delete'); + PyThreadState_Get := getProcAddr(lib, 'PyThreadState_Get'); + PyThreadState_Swap := getProcAddr(lib, 'PyThreadState_Swap'); +end; + +var + lib: TLibHandle; +initialization + lib := loadLibrary(dllName); + if lib <> NilLibHandle then init(lib); +end. diff --git a/lib/base/lua/lauxlib.nim b/lib/base/lua/lauxlib.nim new file mode 100644 index 000000000..143a6cc46 --- /dev/null +++ b/lib/base/lua/lauxlib.nim @@ -0,0 +1,224 @@ +#***************************************************************************** +# * * +# * File: lauxlib.pas * +# * Authors: TeCGraf (C headers + actual Lua libraries) * +# * Lavergne Thomas (original translation to Pascal) * +# * Bram Kuijvenhoven (update to Lua 5.1.1 for FreePascal) * +# * Description: Lua auxiliary library * +# * * +# ***************************************************************************** +# +#** $Id: lauxlib.h,v 1.59 2003/03/18 12:25:32 roberto Exp $ +#** Auxiliary functions for building Lua libraries +#** See Copyright Notice in lua.h +# +# +#** Translated to pascal by Lavergne Thomas +#** Notes : +#** - Pointers type was prefixed with 'P' +#** Bug reports : +#** - thomas.lavergne@laposte.net +#** In french or in english +# + +import "lib/base/lua/lua" + +proc lua_pushstring*(L: Plua_State, s: string) + # compatibilty macros +proc luaL_getn*(L: Plua_State, n: int): int + # calls lua_objlen +proc luaL_setn*(L: Plua_State, t, n: int) + # does nothing! +type + TLuaL_reg*{.final.} = object + name*: cstring + func*: lua_CFunction + + PluaL_reg* = ptr TLuaL_reg + +proc luaL_openlib*(L: Plua_State, libname: cstring, lr: PluaL_reg, nup: int){. + cdecl, dynlib: LUA_LIB_NAME, importc.} +proc luaL_register*(L: Plua_State, libname: cstring, lr: PluaL_reg){.cdecl, + dynlib: LUA_LIB_NAME, importc.} +proc luaL_getmetafield*(L: Plua_State, obj: int, e: cstring): int{.cdecl, + dynlib: LUA_LIB_NAME, importc.} +proc luaL_callmeta*(L: Plua_State, obj: int, e: cstring): int{.cdecl, + dynlib: LUA_LIB_NAME, importc.} +proc luaL_typerror*(L: Plua_State, narg: int, tname: cstring): int{.cdecl, + dynlib: LUA_LIB_NAME, importc.} +proc luaL_argerror*(L: Plua_State, numarg: int, extramsg: cstring): int{.cdecl, + dynlib: LUA_LIB_NAME, importc.} +proc luaL_checklstring*(L: Plua_State, numArg: int, l_: Psize_t): cstring{. + cdecl, dynlib: LUA_LIB_NAME, importc.} +proc luaL_optlstring*(L: Plua_State, numArg: int, def: cstring, l_: Psize_t): cstring{. + cdecl, dynlib: LUA_LIB_NAME, importc.} +proc luaL_checknumber*(L: Plua_State, numArg: int): lua_Number{.cdecl, + dynlib: LUA_LIB_NAME, importc.} +proc luaL_optnumber*(L: Plua_State, nArg: int, def: lua_Number): lua_Number{. + cdecl, dynlib: LUA_LIB_NAME, importc.} +proc luaL_checkinteger*(L: Plua_State, numArg: int): lua_Integer{.cdecl, + dynlib: LUA_LIB_NAME, importc.} +proc luaL_optinteger*(L: Plua_State, nArg: int, def: lua_Integer): lua_Integer{. + cdecl, dynlib: LUA_LIB_NAME, importc.} +proc luaL_checkstack*(L: Plua_State, sz: int, msg: cstring){.cdecl, + dynlib: LUA_LIB_NAME, importc.} +proc luaL_checktype*(L: Plua_State, narg, t: int){.cdecl, dynlib: LUA_LIB_NAME, + importc.} +proc luaL_checkany*(L: Plua_State, narg: int){.cdecl, dynlib: LUA_LIB_NAME, + importc.} +proc luaL_newmetatable*(L: Plua_State, tname: cstring): int{.cdecl, + dynlib: LUA_LIB_NAME, importc.} +proc luaL_checkudata*(L: Plua_State, ud: int, tname: cstring): Pointer{.cdecl, + dynlib: LUA_LIB_NAME, importc.} +proc luaL_where*(L: Plua_State, lvl: int){.cdecl, dynlib: LUA_LIB_NAME, importc.} +proc luaL_error*(L: Plua_State, fmt: cstring): int{.cdecl, varargs, + dynlib: LUA_LIB_NAME, importc.} +proc luaL_checkoption*(L: Plua_State, narg: int, def: cstring, lst: cstringArray): int{. + cdecl, dynlib: LUA_LIB_NAME, importc.} +proc luaL_ref*(L: Plua_State, t: int): int{.cdecl, dynlib: LUA_LIB_NAME, importc.} +proc luaL_unref*(L: Plua_State, t, theref: int){.cdecl, dynlib: LUA_LIB_NAME, + importc.} +proc luaL_loadfile*(L: Plua_State, filename: cstring): int{.cdecl, + dynlib: LUA_LIB_NAME, importc.} +proc luaL_loadbuffer*(L: Plua_State, buff: cstring, size: size_t, name: cstring): int{. + cdecl, dynlib: LUA_LIB_NAME, importc.} +proc luaL_loadstring*(L: Plua_State, s: cstring): int{.cdecl, + dynlib: LUA_LIB_NAME, importc.} +proc luaL_newstate*(): Plua_State{.cdecl, dynlib: LUA_LIB_NAME, importc.} +proc lua_open*(): Plua_State + # compatibility; moved from unit lua to lauxlib because it needs luaL_newstate + # + #** =============================================================== + #** some useful macros + #** =============================================================== + # +proc luaL_argcheck*(L: Plua_State, cond: bool, numarg: int, extramsg: cstring) +proc luaL_checkstring*(L: Plua_State, n: int): cstring +proc luaL_optstring*(L: Plua_State, n: int, d: cstring): cstring +proc luaL_checkint*(L: Plua_State, n: int): int +proc luaL_checklong*(L: Plua_State, n: int): int32 +proc luaL_optint*(L: Plua_State, n: int, d: float64): int +proc luaL_optlong*(L: Plua_State, n: int, d: float64): int32 +proc luaL_typename*(L: Plua_State, i: int): cstring +proc lua_dofile*(L: Plua_State, filename: cstring): int +proc lua_dostring*(L: Plua_State, str: cstring): int +proc lua_Lgetmetatable*(L: Plua_State, tname: cstring) + # not translated: + # #define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) + # + #** ======================================================= + #** Generic Buffer manipulation + #** ======================================================= + # +const # note: this is just arbitrary, as it related to the BUFSIZ defined in stdio.h ... + LUAL_BUFFERSIZE* = 4096 + +type + luaL_Buffer*{.final.} = object + p*: cstring # current position in buffer + lvl*: int # number of strings in the stack (level) + L*: Plua_State + buffer*: array[0..LUAL_BUFFERSIZE - 1, Char] # warning: see note above about LUAL_BUFFERSIZE + + PluaL_Buffer* = ptr luaL_Buffer + +proc luaL_addchar*(B: PluaL_Buffer, c: Char) + # warning: see note above about LUAL_BUFFERSIZE + # compatibility only (alias for luaL_addchar) +proc luaL_putchar*(B: PluaL_Buffer, c: Char) + # warning: see note above about LUAL_BUFFERSIZE +proc luaL_addsize*(B: PluaL_Buffer, n: int) +proc luaL_buffinit*(L: Plua_State, B: PluaL_Buffer){.cdecl, + dynlib: LUA_LIB_NAME, importc.} +proc luaL_prepbuffer*(B: PluaL_Buffer): cstring{.cdecl, dynlib: LUA_LIB_NAME, + importc.} +proc luaL_addlstring*(B: PluaL_Buffer, s: cstring, L: size_t){.cdecl, + dynlib: LUA_LIB_NAME, importc.} +proc luaL_addstring*(B: PluaL_Buffer, s: cstring){.cdecl, dynlib: LUA_LIB_NAME, + importc.} +proc luaL_addvalue*(B: PluaL_Buffer){.cdecl, dynlib: LUA_LIB_NAME, importc.} +proc luaL_pushresult*(B: PluaL_Buffer){.cdecl, dynlib: LUA_LIB_NAME, importc.} +proc luaL_gsub*(L: Plua_State, s, p, r: cstring): cstring{.cdecl, + dynlib: LUA_LIB_NAME, importc.} +proc luaL_findtable*(L: Plua_State, idx: int, fname: cstring, szhint: int): cstring{. + cdecl, dynlib: LUA_LIB_NAME, importc.} + # compatibility with ref system + # pre-defined references +const + LUA_NOREF* = - 2 + LUA_REFNIL* = - 1 + +proc lua_unref*(L: Plua_State, theref: int) +proc lua_getref*(L: Plua_State, theref: int) + # + #** Compatibility macros and functions + # + +# implementation + +proc lua_pushstring(L: Plua_State, s: string) = + lua_pushlstring(L, cstring(s), len(s)) + +proc luaL_getn(L: Plua_State, n: int): int = + Result = lua_objlen(L, n) + +proc luaL_setn(L: Plua_State, t, n: int) = + # does nothing as this operation is deprecated + nil + +proc lua_open(): Plua_State = + Result = luaL_newstate() + +proc luaL_typename(L: Plua_State, i: int): cstring = + Result = lua_typename(L, lua_type(L, i)) + +proc lua_dofile(L: Plua_State, filename: cstring): int = + Result = luaL_loadfile(L, filename) + if Result == 0: Result = lua_pcall(L, 0, LUA_MULTRET, 0) + +proc lua_dostring(L: Plua_State, str: cstring): int = + Result = luaL_loadstring(L, str) + if Result == 0: Result = lua_pcall(L, 0, LUA_MULTRET, 0) + +proc lua_Lgetmetatable(L: Plua_State, tname: cstring) = + lua_getfield(L, LUA_REGISTRYINDEX, tname) + +proc luaL_argcheck(L: Plua_State, cond: bool, numarg: int, extramsg: cstring) = + if not cond: + discard luaL_argerror(L, numarg, extramsg) + +proc luaL_checkstring(L: Plua_State, n: int): cstring = + Result = luaL_checklstring(L, n, nil) + +proc luaL_optstring(L: Plua_State, n: int, d: cstring): cstring = + Result = luaL_optlstring(L, n, d, nil) + +proc luaL_checkint(L: Plua_State, n: int): int = + Result = toInt(luaL_checknumber(L, n)) + +proc luaL_checklong(L: Plua_State, n: int): int32 = + Result = int32(ToInt(luaL_checknumber(L, n))) + +proc luaL_optint(L: Plua_State, n: int, d: float64): int = + Result = int(ToInt(luaL_optnumber(L, n, d))) + +proc luaL_optlong(L: Plua_State, n: int, d: float64): int32 = + Result = int32(ToInt(luaL_optnumber(L, n, d))) + +proc luaL_addchar(B: PluaL_Buffer, c: Char) = + if cast[int](addr((B.p))) < (cast[int](addr((B.buffer[0]))) + LUAL_BUFFERSIZE): + discard luaL_prepbuffer(B) + B.p[1] = c + B.p = cast[cstring](cast[int](B.p) + 1) + +proc luaL_putchar(B: PluaL_Buffer, c: Char) = + luaL_addchar(B, c) + +proc luaL_addsize(B: PluaL_Buffer, n: int) = + B.p = cast[cstring](cast[int](B.p) + n) + +proc lua_unref(L: Plua_State, theref: int) = + luaL_unref(L, LUA_REGISTRYINDEX, theref) + +proc lua_getref(L: Plua_State, theref: int) = + lua_rawgeti(L, LUA_REGISTRYINDEX, theref) diff --git a/lib/base/lua/lua.nim b/lib/base/lua/lua.nim new file mode 100644 index 000000000..ab872fd23 --- /dev/null +++ b/lib/base/lua/lua.nim @@ -0,0 +1,384 @@ +#***************************************************************************** +# * * +# * File: lua.pas * +# * Authors: TeCGraf (C headers + actual Lua libraries) * +# * Lavergne Thomas (original translation to Pascal) * +# * Bram Kuijvenhoven (update to Lua 5.1.1 for FreePascal) * +# * Description: Basic Lua library * +# * * +# ***************************************************************************** +# +#** $Id: lua.h,v 1.175 2003/03/18 12:31:39 roberto Exp $ +#** Lua - An Extensible Extension Language +#** TeCGraf: Computer Graphics Technology Group, PUC-Rio, Brazil +#** http://www.lua.org mailto:info@lua.org +#** See Copyright Notice at the end of this file +# +# +#** Updated to Lua 5.1.1 by Bram Kuijvenhoven (bram at kuijvenhoven dot net), +#** Hexis BV (http://www.hexis.nl), the Netherlands +#** Notes: +#** - Only tested with FPC (FreePascal Compiler) +#** - Using LuaBinaries styled DLL/SO names, which include version names +#** - LUA_YIELD was suffixed by '_' for avoiding name collision +# +# +#** Translated to pascal by Lavergne Thomas +#** Notes : +#** - Pointers type was prefixed with 'P' +#** - lua_upvalueindex constant was transformed to function +#** - Some compatibility function was isolated because with it you must have +#** lualib. +#** - LUA_VERSION was suffixed by '_' for avoiding name collision. +#** Bug reports : +#** - thomas.lavergne@laposte.net +#** In french or in english +# + +when defined(MACOSX): + const + LUA_NAME* = "liblua5.1.dylib" + LUA_LIB_NAME* = "liblua5.1.dylib" +elif defined(UNIX): + const + LUA_NAME* = "liblua5.1.so" + LUA_LIB_NAME* = "liblua5.1.so" +else: + const + LUA_NAME* = "lua5.1.dll" + LUA_LIB_NAME* = "lua5.1.dll" +type + size_t* = int + Psize_t* = ptr size_t + +const + LUA_VERSION* = "Lua 5.1" + LUA_RELEASE* = "Lua 5.1.1" + LUA_VERSION_NUM* = 501 + LUA_COPYRIGHT* = "Copyright (C) 1994-2006 Lua.org, PUC-Rio" + LUA_AUTHORS* = "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" # option for multiple returns in `lua_pcall' and `lua_call' + LUA_MULTRET* = - 1 # + #** pseudo-indices + # + LUA_REGISTRYINDEX* = - 10000 + LUA_ENVIRONINDEX* = - 10001 + LUA_GLOBALSINDEX* = - 10002 + +proc lua_upvalueindex*(I: int): int +const # thread status; 0 is OK + LUA_YIELD_* = 1 + LUA_ERRRUN* = 2 + LUA_ERRSYNTAX* = 3 + LUA_ERRMEM* = 4 + LUA_ERRERR* = 5 + +type + Plua_State* = Pointer + lua_CFunction* = proc (L: Plua_State): int{.cdecl.} # + #** functions that read/write blocks when loading/dumping Lua chunks + # + +type + lua_Reader* = proc (L: Plua_State, ud: Pointer, sz: Psize_t): cstring{.cdecl.} + lua_Writer* = proc (L: Plua_State, p: Pointer, sz: size_t, ud: Pointer): int{. + cdecl.} # + #** prototype for memory-allocation functions + # + lua_Alloc* = proc (ud, theptr: Pointer, osize, nsize: size_t){.cdecl.} + +const + LUA_TNONE* = - 1 + LUA_TNIL* = 0 + LUA_TBOOLEAN* = 1 + LUA_TLIGHTUSERDATA* = 2 + LUA_TNUMBER* = 3 + LUA_TSTRING* = 4 + LUA_TTABLE* = 5 + LUA_TFUNCTION* = 6 + LUA_TUSERDATA* = 7 + LUA_TTHREAD* = 8 # minimum Lua stack available to a C function + LUA_MINSTACK* = 20 + +type # Type of Numbers in Lua + lua_Number* = float + lua_Integer* = int + +proc lua_newstate*(f: lua_Alloc, ud: Pointer): Plua_State{.cdecl, + dynlib: LUA_NAME, importc.} +proc lua_close*(L: Plua_State){.cdecl, dynlib: LUA_NAME, importc.} +proc lua_newthread*(L: Plua_State): Plua_State{.cdecl, dynlib: LUA_NAME, importc.} +proc lua_atpanic*(L: Plua_State, panicf: lua_CFunction): lua_CFunction{.cdecl, + dynlib: LUA_NAME, importc.} +proc lua_gettop*(L: Plua_State): int{.cdecl, dynlib: LUA_NAME, importc.} +proc lua_settop*(L: Plua_State, idx: int){.cdecl, dynlib: LUA_NAME, importc.} +proc lua_pushvalue*(L: Plua_State, Idx: int){.cdecl, dynlib: LUA_NAME, importc.} +proc lua_remove*(L: Plua_State, idx: int){.cdecl, dynlib: LUA_NAME, importc.} +proc lua_insert*(L: Plua_State, idx: int){.cdecl, dynlib: LUA_NAME, importc.} +proc lua_replace*(L: Plua_State, idx: int){.cdecl, dynlib: LUA_NAME, importc.} +proc lua_checkstack*(L: Plua_State, sz: int): cint{.cdecl, dynlib: LUA_NAME, + importc.} +proc lua_xmove*(`from`, `to`: Plua_State, n: int){.cdecl, dynlib: LUA_NAME, importc.} +proc lua_isnumber*(L: Plua_State, idx: int): cint{.cdecl, dynlib: LUA_NAME, + importc.} +proc lua_isstring*(L: Plua_State, idx: int): cint{.cdecl, dynlib: LUA_NAME, + importc.} +proc lua_iscfunction*(L: Plua_State, idx: int): cint{.cdecl, + dynlib: LUA_NAME, importc.} +proc lua_isuserdata*(L: Plua_State, idx: int): cint{.cdecl, + dynlib: LUA_NAME, importc.} +proc lua_type*(L: Plua_State, idx: int): int{.cdecl, dynlib: LUA_NAME, importc.} +proc lua_typename*(L: Plua_State, tp: int): cstring{.cdecl, dynlib: LUA_NAME, + importc.} +proc lua_equal*(L: Plua_State, idx1, idx2: int): cint{.cdecl, + dynlib: LUA_NAME, importc.} +proc lua_rawequal*(L: Plua_State, idx1, idx2: int): cint{.cdecl, + dynlib: LUA_NAME, importc.} +proc lua_lessthan*(L: Plua_State, idx1, idx2: int): cint{.cdecl, + dynlib: LUA_NAME, importc.} +proc lua_tonumber*(L: Plua_State, idx: int): lua_Number{.cdecl, + dynlib: LUA_NAME, importc.} +proc lua_tointeger*(L: Plua_State, idx: int): lua_Integer{.cdecl, + dynlib: LUA_NAME, importc.} +proc lua_toboolean*(L: Plua_State, idx: int): cint{.cdecl, dynlib: LUA_NAME, + importc.} +proc lua_tolstring*(L: Plua_State, idx: int, length: Psize_t): cstring{.cdecl, + dynlib: LUA_NAME, importc.} +proc lua_objlen*(L: Plua_State, idx: int): size_t{.cdecl, dynlib: LUA_NAME, + importc.} +proc lua_tocfunction*(L: Plua_State, idx: int): lua_CFunction{.cdecl, + dynlib: LUA_NAME, importc.} +proc lua_touserdata*(L: Plua_State, idx: int): Pointer{.cdecl, dynlib: LUA_NAME, + importc.} +proc lua_tothread*(L: Plua_State, idx: int): Plua_State{.cdecl, + dynlib: LUA_NAME, importc.} +proc lua_topointer*(L: Plua_State, idx: int): Pointer{.cdecl, dynlib: LUA_NAME, + importc.} +proc lua_pushnil*(L: Plua_State){.cdecl, dynlib: LUA_NAME, importc.} +proc lua_pushnumber*(L: Plua_State, n: lua_Number){.cdecl, dynlib: LUA_NAME, + importc.} +proc lua_pushinteger*(L: Plua_State, n: lua_Integer){.cdecl, dynlib: LUA_NAME, + importc.} +proc lua_pushlstring*(L: Plua_State, s: cstring, l_: size_t){.cdecl, + dynlib: LUA_NAME, importc.} +proc lua_pushstring*(L: Plua_State, s: cstring){.cdecl, dynlib: LUA_NAME, + importc.} +proc lua_pushvfstring*(L: Plua_State, fmt: cstring, argp: Pointer): cstring{. + cdecl, dynlib: LUA_NAME, importc.} +proc lua_pushfstring*(L: Plua_State, fmt: cstring): cstring{.cdecl, varargs, + dynlib: LUA_NAME, importc.} +proc lua_pushcclosure*(L: Plua_State, fn: lua_CFunction, n: int){.cdecl, + dynlib: LUA_NAME, importc.} +proc lua_pushboolean*(L: Plua_State, b: cint){.cdecl, dynlib: LUA_NAME, + importc.} +proc lua_pushlightuserdata*(L: Plua_State, p: Pointer){.cdecl, dynlib: LUA_NAME, + importc.} +proc lua_pushthread*(L: Plua_State){.cdecl, dynlib: LUA_NAME, importc.} +proc lua_gettable*(L: Plua_State, idx: int){.cdecl, dynlib: LUA_NAME, importc.} +proc lua_getfield*(L: Plua_state, idx: int, k: cstring){.cdecl, + dynlib: LUA_NAME, importc.} +proc lua_rawget*(L: Plua_State, idx: int){.cdecl, dynlib: LUA_NAME, importc.} +proc lua_rawgeti*(L: Plua_State, idx, n: int){.cdecl, dynlib: LUA_NAME, importc.} +proc lua_createtable*(L: Plua_State, narr, nrec: int){.cdecl, dynlib: LUA_NAME, + importc.} +proc lua_newuserdata*(L: Plua_State, sz: size_t): Pointer{.cdecl, + dynlib: LUA_NAME, importc.} +proc lua_getmetatable*(L: Plua_State, objindex: int): int{.cdecl, + dynlib: LUA_NAME, importc.} +proc lua_getfenv*(L: Plua_State, idx: int){.cdecl, dynlib: LUA_NAME, importc.} +proc lua_settable*(L: Plua_State, idx: int){.cdecl, dynlib: LUA_NAME, importc.} +proc lua_setfield*(L: Plua_State, idx: int, k: cstring){.cdecl, + dynlib: LUA_NAME, importc.} +proc lua_rawset*(L: Plua_State, idx: int){.cdecl, dynlib: LUA_NAME, importc.} +proc lua_rawseti*(L: Plua_State, idx, n: int){.cdecl, dynlib: LUA_NAME, importc.} +proc lua_setmetatable*(L: Plua_State, objindex: int): int{.cdecl, + dynlib: LUA_NAME, importc.} +proc lua_setfenv*(L: Plua_State, idx: int): int{.cdecl, dynlib: LUA_NAME, + importc.} +proc lua_call*(L: Plua_State, nargs, nresults: int){.cdecl, dynlib: LUA_NAME, + importc.} +proc lua_pcall*(L: Plua_State, nargs, nresults, errf: int): int{.cdecl, + dynlib: LUA_NAME, importc.} +proc lua_cpcall*(L: Plua_State, func: lua_CFunction, ud: Pointer): int{.cdecl, + dynlib: LUA_NAME, importc.} +proc lua_load*(L: Plua_State, reader: lua_Reader, dt: Pointer, + chunkname: cstring): int{.cdecl, dynlib: LUA_NAME, importc.} +proc lua_dump*(L: Plua_State, writer: lua_Writer, data: Pointer): int{.cdecl, + dynlib: LUA_NAME, importc.} +proc lua_yield*(L: Plua_State, nresults: int): int{.cdecl, dynlib: LUA_NAME, + importc.} +proc lua_resume*(L: Plua_State, narg: int): int{.cdecl, dynlib: LUA_NAME, + importc.} +proc lua_status*(L: Plua_State): int{.cdecl, dynlib: LUA_NAME, importc.} +proc lua_gc*(L: Plua_State, what, data: int): int{.cdecl, dynlib: LUA_NAME, + importc.} +proc lua_error*(L: Plua_State): int{.cdecl, dynlib: LUA_NAME, importc.} +proc lua_next*(L: Plua_State, idx: int): int{.cdecl, dynlib: LUA_NAME, importc.} +proc lua_concat*(L: Plua_State, n: int){.cdecl, dynlib: LUA_NAME, importc.} +proc lua_getallocf*(L: Plua_State, ud: ptr Pointer): lua_Alloc{.cdecl, + dynlib: LUA_NAME, importc.} +proc lua_setallocf*(L: Plua_State, f: lua_Alloc, ud: Pointer){.cdecl, + dynlib: LUA_NAME, importc.} + # + #** Garbage-collection functions and options + # +const + LUA_GCSTOP* = 0 + LUA_GCRESTART* = 1 + LUA_GCCOLLECT* = 2 + LUA_GCCOUNT* = 3 + LUA_GCCOUNTB* = 4 + LUA_GCSTEP* = 5 + LUA_GCSETPAUSE* = 6 + LUA_GCSETSTEPMUL* = 7 # + #** =============================================================== + #** some useful macros + #** =============================================================== + # + +proc lua_pop*(L: Plua_State, n: int) +proc lua_newtable*(L: Plua_state) +proc lua_register*(L: Plua_State, n: cstring, f: lua_CFunction) +proc lua_pushcfunction*(L: Plua_State, f: lua_CFunction) +proc lua_strlen*(L: Plua_state, i: int): size_t +proc lua_isfunction*(L: Plua_State, n: int): bool +proc lua_istable*(L: Plua_State, n: int): bool +proc lua_islightuserdata*(L: Plua_State, n: int): bool +proc lua_isnil*(L: Plua_State, n: int): bool +proc lua_isboolean*(L: Plua_State, n: int): bool +proc lua_isthread*(L: Plua_State, n: int): bool +proc lua_isnone*(L: Plua_State, n: int): bool +proc lua_isnoneornil*(L: Plua_State, n: int): bool +proc lua_pushliteral*(L: Plua_State, s: cstring) +proc lua_setglobal*(L: Plua_State, s: cstring) +proc lua_getglobal*(L: Plua_State, s: cstring) +proc lua_tostring*(L: Plua_State, i: int): cstring + # + #** compatibility macros and functions + # +proc lua_getregistry*(L: Plua_State) +proc lua_getgccount*(L: Plua_State): int +type + lua_Chunkreader* = lua_Reader + lua_Chunkwriter* = lua_Writer # + #** {====================================================================== + #** Debug API + #** ======================================================================= + # + +const + LUA_HOOKCALL* = 0 + LUA_HOOKRET* = 1 + LUA_HOOKLINE* = 2 + LUA_HOOKCOUNT* = 3 + LUA_HOOKTAILRET* = 4 + +const + LUA_MASKCALL* = 1 shl Ord(LUA_HOOKCALL) + LUA_MASKRET* = 1 shl Ord(LUA_HOOKRET) + LUA_MASKLINE* = 1 shl Ord(LUA_HOOKLINE) + LUA_MASKCOUNT* = 1 shl Ord(LUA_HOOKCOUNT) + +const + LUA_IDSIZE* = 60 + +type + lua_Debug*{.final.} = object # activation record + event*: int + name*: cstring # (n) + namewhat*: cstring # (n) `global', `local', `field', `method' + what*: cstring # (S) `Lua', `C', `main', `tail' + source*: cstring # (S) + currentline*: int # (l) + nups*: int # (u) number of upvalues + linedefined*: int # (S) + lastlinedefined*: int # (S) + short_src*: array[0..LUA_IDSIZE - 1, Char] # (S) + # private part + i_ci*: int # active function + + Plua_Debug* = ptr lua_Debug + lua_Hook* = proc (L: Plua_State, ar: Plua_Debug){.cdecl.} # + #** {====================================================================== + #** Debug API + #** ======================================================================= + # + +proc lua_getstack*(L: Plua_State, level: int, ar: Plua_Debug): int{.cdecl, + dynlib: LUA_NAME, importc.} +proc lua_getinfo*(L: Plua_State, what: cstring, ar: Plua_Debug): int{.cdecl, + dynlib: LUA_NAME, importc.} +proc lua_getlocal*(L: Plua_State, ar: Plua_Debug, n: int): cstring{.cdecl, + dynlib: LUA_NAME, importc.} +proc lua_setlocal*(L: Plua_State, ar: Plua_Debug, n: int): cstring{.cdecl, + dynlib: LUA_NAME, importc.} +proc lua_getupvalue*(L: Plua_State, funcindex: int, n: int): cstring{.cdecl, + dynlib: LUA_NAME, importc.} +proc lua_setupvalue*(L: Plua_State, funcindex: int, n: int): cstring{.cdecl, + dynlib: LUA_NAME, importc.} +proc lua_sethook*(L: Plua_State, func: lua_Hook, mask: int, count: int): int{. + cdecl, dynlib: LUA_NAME, importc.} +proc lua_gethook*(L: Plua_State): lua_Hook{.cdecl, dynlib: LUA_NAME, importc.} +proc lua_gethookmask*(L: Plua_State): int{.cdecl, dynlib: LUA_NAME, importc.} +proc lua_gethookcount*(L: Plua_State): int{.cdecl, dynlib: LUA_NAME, importc.} +# implementation + +proc lua_upvalueindex(I: int): int = + Result = LUA_GLOBALSINDEX - i + +proc lua_pop(L: Plua_State, n: int) = + lua_settop(L, - n - 1) + +proc lua_newtable(L: Plua_State) = + lua_createtable(L, 0, 0) + +proc lua_register(L: Plua_State, n: cstring, f: lua_CFunction) = + lua_pushcfunction(L, f) + lua_setglobal(L, n) + +proc lua_pushcfunction(L: Plua_State, f: lua_CFunction) = + lua_pushcclosure(L, f, 0) + +proc lua_strlen(L: Plua_State, i: int): size_t = + Result = lua_objlen(L, i) + +proc lua_isfunction(L: Plua_State, n: int): bool = + Result = lua_type(L, n) == LUA_TFUNCTION + +proc lua_istable(L: Plua_State, n: int): bool = + Result = lua_type(L, n) == LUA_TTABLE + +proc lua_islightuserdata(L: Plua_State, n: int): bool = + Result = lua_type(L, n) == LUA_TLIGHTUSERDATA + +proc lua_isnil(L: Plua_State, n: int): bool = + Result = lua_type(L, n) == LUA_TNIL + +proc lua_isboolean(L: Plua_State, n: int): bool = + Result = lua_type(L, n) == LUA_TBOOLEAN + +proc lua_isthread(L: Plua_State, n: int): bool = + Result = lua_type(L, n) == LUA_TTHREAD + +proc lua_isnone(L: Plua_State, n: int): bool = + Result = lua_type(L, n) == LUA_TNONE + +proc lua_isnoneornil(L: Plua_State, n: int): bool = + Result = lua_type(L, n) <= 0 + +proc lua_pushliteral(L: Plua_State, s: cstring) = + lua_pushlstring(L, s, len(s)) + +proc lua_setglobal(L: Plua_State, s: cstring) = + lua_setfield(L, LUA_GLOBALSINDEX, s) + +proc lua_getglobal(L: Plua_State, s: cstring) = + lua_getfield(L, LUA_GLOBALSINDEX, s) + +proc lua_tostring(L: Plua_State, i: int): cstring = + Result = lua_tolstring(L, i, nil) + +proc lua_getregistry(L: Plua_State) = + lua_pushvalue(L, LUA_REGISTRYINDEX) + +proc lua_getgccount(L: Plua_State): int = + Result = lua_gc(L, LUA_GCCOUNT, 0) diff --git a/lib/base/lua/lualib.nim b/lib/base/lua/lualib.nim new file mode 100644 index 000000000..efd3ab923 --- /dev/null +++ b/lib/base/lua/lualib.nim @@ -0,0 +1,73 @@ +#***************************************************************************** +# * * +# * File: lualib.pas * +# * Authors: TeCGraf (C headers + actual Lua libraries) * +# * Lavergne Thomas (original translation to Pascal) * +# * Bram Kuijvenhoven (update to Lua 5.1.1 for FreePascal) * +# * Description: Standard Lua libraries * +# * * +# ***************************************************************************** +# +#** $Id: lualib.h,v 1.28 2003/03/18 12:24:26 roberto Exp $ +#** Lua standard libraries +#** See Copyright Notice in lua.h +# +# +#** Translated to pascal by Lavergne Thomas +#** Bug reports : +#** - thomas.lavergne@laposte.net +#** In french or in english +# + +import "lib/base/lua/lua" + +const + LUA_COLIBNAME* = "coroutine" + LUA_TABLIBNAME* = "table" + LUA_IOLIBNAME* = "io" + LUA_OSLIBNAME* = "os" + LUA_STRLINAME* = "string" + LUA_MATHLIBNAME* = "math" + LUA_DBLIBNAME* = "debug" + LUA_LOADLIBNAME* = "package" + +proc luaopen_base*(L: Plua_State): cint{.cdecl, dynlib: LUA_LIB_NAME, + importc.} +proc luaopen_table*(L: Plua_State): cint{.cdecl, dynlib: LUA_LIB_NAME, + importc.} +proc luaopen_io*(L: Plua_State): cint{.cdecl, dynlib: LUA_LIB_NAME, importc.} +proc luaopen_string*(L: Plua_State): cint{.cdecl, dynlib: LUA_LIB_NAME, + importc.} +proc luaopen_math*(L: Plua_State): cint{.cdecl, dynlib: LUA_LIB_NAME, + importc.} +proc luaopen_debug*(L: Plua_State): cint{.cdecl, dynlib: LUA_LIB_NAME, + importc.} +proc luaopen_package*(L: Plua_State): cint{.cdecl, dynlib: LUA_LIB_NAME, + importc.} +proc luaL_openlibs*(L: Plua_State){.cdecl, dynlib: LUA_LIB_NAME, importc.} + # compatibility code +proc lua_baselibopen*(L: Plua_State): Bool +proc lua_tablibopen*(L: Plua_State): Bool +proc lua_iolibopen*(L: Plua_State): Bool +proc lua_strlibopen*(L: Plua_State): Bool +proc lua_mathlibopen*(L: Plua_State): Bool +proc lua_dblibopen*(L: Plua_State): Bool +# implementation + +proc lua_baselibopen(L: Plua_State): Bool = + Result = luaopen_base(L) != 0'i32 + +proc lua_tablibopen(L: Plua_State): Bool = + Result = luaopen_table(L) != 0'i32 + +proc lua_iolibopen(L: Plua_State): Bool = + Result = luaopen_io(L) != 0'i32 + +proc lua_strlibopen(L: Plua_State): Bool = + Result = luaopen_string(L) != 0'i32 + +proc lua_mathlibopen(L: Plua_State): Bool = + Result = luaopen_math(L) != 0'i32 + +proc lua_dblibopen(L: Plua_State): Bool = + Result = luaopen_debug(L) != 0'i32 diff --git a/lib/base/odbcsql.nim b/lib/base/odbcsql.nim new file mode 100644 index 000000000..e6eda0106 --- /dev/null +++ b/lib/base/odbcsql.nim @@ -0,0 +1,783 @@ + +when not defined(ODBCVER): + const + ODBCVER = 0x0351 ## define ODBC version 3.51 by default + +when defined(windows): + {.push callconv: stdcall.} + const odbclib = "odbc32.dll" +else: + {.push callconv: cdecl.} + const odbclib = "libodbc.so" + +# DATA TYPES CORRESPONDENCE +# BDE fields ODBC types +# ---------- ------------------ +# ftBlob SQL_BINARY +# ftBoolean SQL_BIT +# ftDate SQL_TYPE_DATE +# ftTime SQL_TYPE_TIME +# ftDateTime SQL_TYPE_TIMESTAMP +# ftInteger SQL_INTEGER +# ftSmallint SQL_SMALLINT +# ftFloat SQL_DOUBLE +# ftString SQL_CHAR +# ftMemo SQL_BINARY // SQL_VARCHAR +# + +type + TSqlChar* = char + TSqlSmallInt* = int16 + TSqlUSmallInt* = int16 + TSqlHandle* = pointer + TSqlHEnv* = TSqlHandle + TSqlHDBC* = TSqlHandle + TSqlHStmt* = TSqlHandle + TSqlHDesc* = TSqlHandle + TSqlInteger* = int + TSqlUInteger* = int + TSqlPointer* = pointer + TSqlReal* = cfloat + TSqlDouble* = cdouble + TSqlFloat* = cdouble + TSqlHWND* = pointer + PSQLCHAR* = cstring + PSQLINTEGER* = ptr TSqlInteger + PSQLUINTEGER* = ptr TSqlUInteger + PSQLSMALLINT* = ptr TSqlSmallInt + PSQLUSMALLINT* = ptr TSqlUSmallInt + PSQLREAL* = ptr TSqlReal + PSQLDOUBLE* = ptr TSqlDouble + PSQLFLOAT* = ptr TSqlFloat + PSQLHANDLE* = ptr TSqlHandle + +const # SQL data type codes + SQL_UNKNOWN_TYPE* = 0 + SQL_LONGVARCHAR* = (- 1) + SQL_BINARY* = (- 2) + SQL_VARBINARY* = (- 3) + SQL_LONGVARBINARY* = (- 4) + SQL_BIGINT* = (- 5) + SQL_TINYINT* = (- 6) + SQL_BIT* = (- 7) + SQL_WCHAR* = (- 8) + SQL_WVARCHAR* = (- 9) + SQL_WLONGVARCHAR* = (- 10) + SQL_CHAR* = 1 + SQL_NUMERIC* = 2 + SQL_DECIMAL* = 3 + SQL_INTEGER* = 4 + SQL_SMALLINT* = 5 + SQL_FLOAT* = 6 + SQL_REAL* = 7 + SQL_DOUBLE* = 8 + SQL_DATETIME* = 9 + SQL_VARCHAR* = 12 + SQL_TYPE_DATE* = 91 + SQL_TYPE_TIME* = 92 + SQL_TYPE_TIMESTAMP* = 93 + SQL_DATE* = 9 + SQL_TIME* = 10 + SQL_TIMESTAMP* = 11 + SQL_INTERVAL* = 10 + SQL_GUID* = - 11 # interval codes + +when ODBCVER >= 0x0300: + const + SQL_CODE_YEAR* = 1 + SQL_CODE_MONTH* = 2 + SQL_CODE_DAY* = 3 + SQL_CODE_HOUR* = 4 + SQL_CODE_MINUTE* = 5 + SQL_CODE_SECOND* = 6 + SQL_CODE_YEAR_TO_MONTH* = 7 + SQL_CODE_DAY_TO_HOUR* = 8 + SQL_CODE_DAY_TO_MINUTE* = 9 + SQL_CODE_DAY_TO_SECOND* = 10 + SQL_CODE_HOUR_TO_MINUTE* = 11 + SQL_CODE_HOUR_TO_SECOND* = 12 + SQL_CODE_MINUTE_TO_SECOND* = 13 + SQL_INTERVAL_YEAR* = 100 + SQL_CODE_YEAR + SQL_INTERVAL_MONTH* = 100 + SQL_CODE_MONTH + SQL_INTERVAL_DAY* = 100 + SQL_CODE_DAY + SQL_INTERVAL_HOUR* = 100 + SQL_CODE_HOUR + SQL_INTERVAL_MINUTE* = 100 + SQL_CODE_MINUTE + SQL_INTERVAL_SECOND* = 100 + SQL_CODE_SECOND + SQL_INTERVAL_YEAR_TO_MONTH* = 100 + SQL_CODE_YEAR_TO_MONTH + SQL_INTERVAL_DAY_TO_HOUR* = 100 + SQL_CODE_DAY_TO_HOUR + SQL_INTERVAL_DAY_TO_MINUTE* = 100 + SQL_CODE_DAY_TO_MINUTE + SQL_INTERVAL_DAY_TO_SECOND* = 100 + SQL_CODE_DAY_TO_SECOND + SQL_INTERVAL_HOUR_TO_MINUTE* = 100 + SQL_CODE_HOUR_TO_MINUTE + SQL_INTERVAL_HOUR_TO_SECOND* = 100 + SQL_CODE_HOUR_TO_SECOND + SQL_INTERVAL_MINUTE_TO_SECOND* = 100 + SQL_CODE_MINUTE_TO_SECOND +else: + const + SQL_INTERVAL_YEAR* = - 80 + SQL_INTERVAL_MONTH* = - 81 + SQL_INTERVAL_YEAR_TO_MONTH* = - 82 + SQL_INTERVAL_DAY* = - 83 + SQL_INTERVAL_HOUR* = - 84 + SQL_INTERVAL_MINUTE* = - 85 + SQL_INTERVAL_SECOND* = - 86 + SQL_INTERVAL_DAY_TO_HOUR* = - 87 + SQL_INTERVAL_DAY_TO_MINUTE* = - 88 + SQL_INTERVAL_DAY_TO_SECOND* = - 89 + SQL_INTERVAL_HOUR_TO_MINUTE* = - 90 + SQL_INTERVAL_HOUR_TO_SECOND* = - 91 + SQL_INTERVAL_MINUTE_TO_SECOND* = - 92 + + +when ODBCVER < 0x0300: + const + SQL_UNICODE* = - 95 + SQL_UNICODE_VARCHAR* = - 96 + SQL_UNICODE_LONGVARCHAR* = - 97 + SQL_UNICODE_CHAR* = SQL_UNICODE +else: + # The previous definitions for SQL_UNICODE_ are historical and obsolete + const + SQL_UNICODE* = SQL_WCHAR + SQL_UNICODE_VARCHAR* = SQL_WVARCHAR + SQL_UNICODE_LONGVARCHAR* = SQL_WLONGVARCHAR + SQL_UNICODE_CHAR* = SQL_WCHAR +const # C datatype to SQL datatype mapping + SQL_C_CHAR* = SQL_CHAR + SQL_C_LONG* = SQL_INTEGER + SQL_C_SHORT* = SQL_SMALLINT + SQL_C_FLOAT* = SQL_REAL + SQL_C_DOUBLE* = SQL_DOUBLE + SQL_C_NUMERIC* = SQL_NUMERIC + SQL_C_DEFAULT* = 99 + SQL_SIGNED_OFFSET* = - 20 + SQL_UNSIGNED_OFFSET* = - 22 + SQL_C_DATE* = SQL_DATE + SQL_C_TIME* = SQL_TIME + SQL_C_TIMESTAMP* = SQL_TIMESTAMP + SQL_C_TYPE_DATE* = SQL_TYPE_DATE + SQL_C_TYPE_TIME* = SQL_TYPE_TIME + SQL_C_TYPE_TIMESTAMP* = SQL_TYPE_TIMESTAMP + SQL_C_INTERVAL_YEAR* = SQL_INTERVAL_YEAR + SQL_C_INTERVAL_MONTH* = SQL_INTERVAL_MONTH + SQL_C_INTERVAL_DAY* = SQL_INTERVAL_DAY + SQL_C_INTERVAL_HOUR* = SQL_INTERVAL_HOUR + SQL_C_INTERVAL_MINUTE* = SQL_INTERVAL_MINUTE + SQL_C_INTERVAL_SECOND* = SQL_INTERVAL_SECOND + SQL_C_INTERVAL_YEAR_TO_MONTH* = SQL_INTERVAL_YEAR_TO_MONTH + SQL_C_INTERVAL_DAY_TO_HOUR* = SQL_INTERVAL_DAY_TO_HOUR + SQL_C_INTERVAL_DAY_TO_MINUTE* = SQL_INTERVAL_DAY_TO_MINUTE + SQL_C_INTERVAL_DAY_TO_SECOND* = SQL_INTERVAL_DAY_TO_SECOND + SQL_C_INTERVAL_HOUR_TO_MINUTE* = SQL_INTERVAL_HOUR_TO_MINUTE + SQL_C_INTERVAL_HOUR_TO_SECOND* = SQL_INTERVAL_HOUR_TO_SECOND + SQL_C_INTERVAL_MINUTE_TO_SECOND* = SQL_INTERVAL_MINUTE_TO_SECOND + SQL_C_BINARY* = SQL_BINARY + SQL_C_BIT* = SQL_BIT + SQL_C_SBIGINT* = SQL_BIGINT + SQL_SIGNED_OFFSET # SIGNED BIGINT + SQL_C_UBIGINT* = SQL_BIGINT + SQL_UNSIGNED_OFFSET # UNSIGNED BIGINT + SQL_C_TINYINT* = SQL_TINYINT + SQL_C_SLONG* = SQL_C_LONG + SQL_SIGNED_OFFSET # SIGNED INTEGER + SQL_C_SSHORT* = SQL_C_SHORT + SQL_SIGNED_OFFSET # SIGNED SMALLINT + SQL_C_STINYINT* = SQL_TINYINT + SQL_SIGNED_OFFSET # SIGNED TINYINT + SQL_C_ULONG* = SQL_C_LONG + SQL_UNSIGNED_OFFSET # UNSIGNED INTEGER + SQL_C_USHORT* = SQL_C_SHORT + SQL_UNSIGNED_OFFSET # UNSIGNED SMALLINT + SQL_C_UTINYINT* = SQL_TINYINT + SQL_UNSIGNED_OFFSET # UNSIGNED TINYINT + SQL_C_BOOKMARK* = SQL_C_ULONG # BOOKMARK + SQL_C_GUID* = SQL_GUID + SQL_TYPE_NULL* = 0 + +when ODBCVER < 0x0300: + const + SQL_TYPE_MIN* = SQL_BIT + SQL_TYPE_MAX* = SQL_VARCHAR + +const + SQL_C_VARBOOKMARK* = SQL_C_BINARY + SQL_API_SQLDESCRIBEPARAM* = 58 + SQL_NO_TOTAL* = - 4 + +type + SQL_DATE_STRUCT* {.final, pure.} = object + Year*: TSqlSmallInt + Month*: TSqlUSmallInt + Day*: TSqlUSmallInt + + PSQL_DATE_STRUCT* = ptr SQL_DATE_STRUCT + SQL_TIME_STRUCT* {.final, pure.} = object + Hour*: TSqlUSmallInt + Minute*: TSqlUSmallInt + Second*: TSqlUSmallInt + + PSQL_TIME_STRUCT* = ptr SQL_TIME_STRUCT + SQL_TIMESTAMP_STRUCT* {.final, pure.} = object + Year*: TSqlUSmallInt + Month*: TSqlUSmallInt + Day*: TSqlUSmallInt + Hour*: TSqlUSmallInt + Minute*: TSqlUSmallInt + Second*: TSqlUSmallInt + Fraction*: TSqlUInteger + + PSQL_TIMESTAMP_STRUCT* = ptr SQL_TIMESTAMP_STRUCT + +const + SQL_NAME_LEN* = 128 + SQL_OV_ODBC3* = 3 + SQL_OV_ODBC2* = 2 + SQL_ATTR_ODBC_VERSION* = 200 # Options for SQLDriverConnect + SQL_DRIVER_NOPROMPT* = 0 + SQL_DRIVER_COMPLETE* = 1 + SQL_DRIVER_PROMPT* = 2 + SQL_DRIVER_COMPLETE_REQUIRED* = 3 # whether an attribute is a pointer or not + SQL_IS_POINTER* = (- 4) + SQL_IS_UINTEGER* = (- 5) + SQL_IS_INTEGER* = (- 6) + SQL_IS_USMALLINT* = (- 7) + SQL_IS_SMALLINT* = (- 8) # SQLExtendedFetch "fFetchType" values + SQL_FETCH_BOOKMARK* = 8 + SQL_SCROLL_OPTIONS* = 44 # SQL_USE_BOOKMARKS options + SQL_UB_OFF* = 0 + SQL_UB_ON* = 1 + SQL_UB_DEFAULT* = SQL_UB_OFF + SQL_UB_FIXED* = SQL_UB_ON + SQL_UB_VARIABLE* = 2 # SQL_SCROLL_OPTIONS masks + SQL_SO_FORWARD_ONLY* = 0x00000001 + SQL_SO_KEYSET_DRIVEN* = 0x00000002 + SQL_SO_DYNAMIC* = 0x00000004 + SQL_SO_MIXED* = 0x00000008 + SQL_SO_STATIC* = 0x00000010 + SQL_BOOKMARK_PERSISTENCE* = 82 + SQL_STATIC_SENSITIVITY* = 83 # SQL_BOOKMARK_PERSISTENCE values + SQL_BP_CLOSE* = 0x00000001 + SQL_BP_DELETE* = 0x00000002 + SQL_BP_DROP* = 0x00000004 + SQL_BP_TRANSACTION* = 0x00000008 + SQL_BP_UPDATE* = 0x00000010 + SQL_BP_OTHER_HSTMT* = 0x00000020 + SQL_BP_SCROLL* = 0x00000040 + SQL_DYNAMIC_CURSOR_ATTRIBUTES1* = 144 + SQL_DYNAMIC_CURSOR_ATTRIBUTES2* = 145 + SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1* = 146 + SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2* = 147 + SQL_INDEX_KEYWORDS* = 148 + SQL_INFO_SCHEMA_VIEWS* = 149 + SQL_KEYSET_CURSOR_ATTRIBUTES1* = 150 + SQL_KEYSET_CURSOR_ATTRIBUTES2* = 151 + SQL_STATIC_CURSOR_ATTRIBUTES1* = 167 + SQL_STATIC_CURSOR_ATTRIBUTES2* = 168 # supported SQLFetchScroll FetchOrientation's + SQL_CA1_NEXT* = 1 + SQL_CA1_ABSOLUTE* = 2 + SQL_CA1_RELATIVE* = 4 + SQL_CA1_BOOKMARK* = 8 # supported SQLSetPos LockType's + SQL_CA1_LOCK_NO_CHANGE* = 0x00000040 + SQL_CA1_LOCK_EXCLUSIVE* = 0x00000080 + SQL_CA1_LOCK_UNLOCK* = 0x00000100 # supported SQLSetPos Operations + SQL_CA1_POS_POSITION* = 0x00000200 + SQL_CA1_POS_UPDATE* = 0x00000400 + SQL_CA1_POS_DELETE* = 0x00000800 + SQL_CA1_POS_REFRESH* = 0x00001000 # positioned updates and deletes + SQL_CA1_POSITIONED_UPDATE* = 0x00002000 + SQL_CA1_POSITIONED_DELETE* = 0x00004000 + SQL_CA1_SELECT_FOR_UPDATE* = 0x00008000 # supported SQLBulkOperations operations + SQL_CA1_BULK_ADD* = 0x00010000 + SQL_CA1_BULK_UPDATE_BY_BOOKMARK* = 0x00020000 + SQL_CA1_BULK_DELETE_BY_BOOKMARK* = 0x00040000 + SQL_CA1_BULK_FETCH_BY_BOOKMARK* = 0x00080000 # supported values for SQL_ATTR_SCROLL_CONCURRENCY + SQL_CA2_READ_ONLY_CONCURRENCY* = 1 + SQL_CA2_LOCK_CONCURRENCY* = 2 + SQL_CA2_OPT_ROWVER_CONCURRENCY* = 4 + SQL_CA2_OPT_VALUES_CONCURRENCY* = 8 # sensitivity of the cursor to its own inserts, deletes, and updates + SQL_CA2_SENSITIVITY_ADDITIONS* = 0x00000010 + SQL_CA2_SENSITIVITY_DELETIONS* = 0x00000020 + SQL_CA2_SENSITIVITY_UPDATES* = 0x00000040 # semantics of SQL_ATTR_MAX_ROWS + SQL_CA2_MAX_ROWS_SELECT* = 0x00000080 + SQL_CA2_MAX_ROWS_INSERT* = 0x00000100 + SQL_CA2_MAX_ROWS_DELETE* = 0x00000200 + SQL_CA2_MAX_ROWS_UPDATE* = 0x00000400 + SQL_CA2_MAX_ROWS_CATALOG* = 0x00000800 + SQL_CA2_MAX_ROWS_AFFECTS_ALL* = (SQL_CA2_MAX_ROWS_SELECT or + SQL_CA2_MAX_ROWS_INSERT or SQL_CA2_MAX_ROWS_DELETE or + SQL_CA2_MAX_ROWS_UPDATE or SQL_CA2_MAX_ROWS_CATALOG) # semantics of + # SQL_DIAG_CURSOR_ROW_COUNT + SQL_CA2_CRC_EXACT* = 0x00001000 + SQL_CA2_CRC_APPROXIMATE* = 0x00002000 # the kinds of positioned statements that can be simulated + SQL_CA2_SIMULATE_NON_UNIQUE* = 0x00004000 + SQL_CA2_SIMULATE_TRY_UNIQUE* = 0x00008000 + SQL_CA2_SIMULATE_UNIQUE* = 0x00010000 # Operations in SQLBulkOperations + SQL_ADD* = 4 + SQL_SETPOS_MAX_OPTION_VALUE* = SQL_ADD + SQL_UPDATE_BY_BOOKMARK* = 5 + SQL_DELETE_BY_BOOKMARK* = 6 + SQL_FETCH_BY_BOOKMARK* = 7 # Operations in SQLSetPos + SQL_POSITION* = 0 + SQL_REFRESH* = 1 + SQL_UPDATE* = 2 + SQL_DELETE* = 3 # Lock options in SQLSetPos + SQL_LOCK_NO_CHANGE* = 0 + SQL_LOCK_EXCLUSIVE* = 1 + SQL_LOCK_UNLOCK* = 2 # SQLExtendedFetch "rgfRowStatus" element values + SQL_ROW_SUCCESS* = 0 + SQL_ROW_DELETED* = 1 + SQL_ROW_UPDATED* = 2 + SQL_ROW_NOROW* = 3 + SQL_ROW_ADDED* = 4 + SQL_ROW_ERROR* = 5 + SQL_ROW_SUCCESS_WITH_INFO* = 6 + SQL_ROW_PROCEED* = 0 + SQL_ROW_IGNORE* = 1 + SQL_MAX_DSN_LENGTH* = 32 # maximum data source name size + SQL_MAX_OPTION_STRING_LENGTH* = 256 + SQL_ODBC_CURSORS* = 110 + SQL_ATTR_ODBC_CURSORS* = SQL_ODBC_CURSORS # SQL_ODBC_CURSORS options + SQL_CUR_USE_IF_NEEDED* = 0 + SQL_CUR_USE_ODBC* = 1 + SQL_CUR_USE_DRIVER* = 2 + SQL_CUR_DEFAULT* = SQL_CUR_USE_DRIVER + SQL_PARAM_TYPE_UNKNOWN* = 0 + SQL_PARAM_INPUT* = 1 + SQL_PARAM_INPUT_OUTPUT* = 2 + SQL_RESULT_COL* = 3 + SQL_PARAM_OUTPUT* = 4 + SQL_RETURN_VALUE* = 5 # special length/indicator values + SQL_NULL_DATA* = (- 1) + SQL_DATA_AT_EXEC* = (- 2) + SQL_SUCCESS* = 0 + SQL_SUCCESS_WITH_INFO* = 1 + SQL_NO_DATA* = 100 + SQL_ERROR* = (- 1) + SQL_INVALID_HANDLE* = (- 2) + SQL_STILL_EXECUTING* = 2 + SQL_NEED_DATA* = 99 # flags for null-terminated string + SQL_NTS* = (- 3) # maximum message length + SQL_MAX_MESSAGE_LENGTH* = 512 # date/time length constants + SQL_DATE_LEN* = 10 + SQL_TIME_LEN* = 8 # add P+1 if precision is nonzero + SQL_TIMESTAMP_LEN* = 19 # add P+1 if precision is nonzero + # handle type identifiers + SQL_HANDLE_ENV* = 1 + SQL_HANDLE_DBC* = 2 + SQL_HANDLE_STMT* = 3 + SQL_HANDLE_DESC* = 4 # environment attribute + SQL_ATTR_OUTPUT_NTS* = 10001 # connection attributes + SQL_ATTR_AUTO_IPD* = 10001 + SQL_ATTR_METADATA_ID* = 10014 # statement attributes + SQL_ATTR_APP_ROW_DESC* = 10010 + SQL_ATTR_APP_PARAM_DESC* = 10011 + SQL_ATTR_IMP_ROW_DESC* = 10012 + SQL_ATTR_IMP_PARAM_DESC* = 10013 + SQL_ATTR_CURSOR_SCROLLABLE* = (- 1) + SQL_ATTR_CURSOR_SENSITIVITY* = (- 2) + SQL_QUERY_TIMEOUT* = 0 + SQL_MAX_ROWS* = 1 + SQL_NOSCAN* = 2 + SQL_MAX_LENGTH* = 3 + SQL_ASYNC_ENABLE* = 4 # same as SQL_ATTR_ASYNC_ENABLE */ + SQL_BIND_TYPE* = 5 + SQL_CURSOR_TYPE* = 6 + SQL_CONCURRENCY* = 7 + SQL_KEYSET_SIZE* = 8 + SQL_ROWSET_SIZE* = 9 + SQL_SIMULATE_CURSOR* = 10 + SQL_RETRIEVE_DATA* = 11 + SQL_USE_BOOKMARKS* = 12 + SQL_GET_BOOKMARK* = 13 # GetStmtOption Only */ + SQL_ROW_NUMBER* = 14 # GetStmtOption Only */ + SQL_ATTR_CURSOR_TYPE* = SQL_CURSOR_TYPE + SQL_ATTR_CONCURRENCY* = SQL_CONCURRENCY + SQL_ATTR_FETCH_BOOKMARK_PTR* = 16 + SQL_ATTR_ROW_STATUS_PTR* = 25 + SQL_ATTR_ROWS_FETCHED_PTR* = 26 + SQL_AUTOCOMMIT* = 102 + SQL_ATTR_AUTOCOMMIT* = SQL_AUTOCOMMIT + SQL_ATTR_ROW_NUMBER* = SQL_ROW_NUMBER + SQL_TXN_ISOLATION* = 108 + SQL_ATTR_TXN_ISOLATION* = SQL_TXN_ISOLATION + SQL_ATTR_MAX_ROWS* = SQL_MAX_ROWS + SQL_ATTR_USE_BOOKMARKS* = SQL_USE_BOOKMARKS #* connection attributes */ + SQL_ACCESS_MODE* = 101 # SQL_AUTOCOMMIT =102; + SQL_LOGIN_TIMEOUT* = 103 + SQL_OPT_TRACE* = 104 + SQL_OPT_TRACEFILE* = 105 + SQL_TRANSLATE_DLL* = 106 + SQL_TRANSLATE_OPTION* = 107 # SQL_TXN_ISOLATION =108; + SQL_CURRENT_QUALIFIER* = 109 # SQL_ODBC_CURSORS =110; + SQL_QUIET_MODE* = 111 + SQL_PACKET_SIZE* = 112 #* connection attributes with new names */ + SQL_ATTR_ACCESS_MODE* = SQL_ACCESS_MODE # SQL_ATTR_AUTOCOMMIT =SQL_AUTOCOMMIT; + SQL_ATTR_CONNECTION_DEAD* = 1209 #* GetConnectAttr only */ + SQL_ATTR_CONNECTION_TIMEOUT* = 113 + SQL_ATTR_CURRENT_CATALOG* = SQL_CURRENT_QUALIFIER + SQL_ATTR_DISCONNECT_BEHAVIOR* = 114 + SQL_ATTR_ENLIST_IN_DTC* = 1207 + SQL_ATTR_ENLIST_IN_XA* = 1208 + SQL_ATTR_LOGIN_TIMEOUT* = SQL_LOGIN_TIMEOUT # SQL_ATTR_ODBC_CURSORS =SQL_ODBC_CURSORS; + SQL_ATTR_PACKET_SIZE* = SQL_PACKET_SIZE + SQL_ATTR_QUIET_MODE* = SQL_QUIET_MODE + SQL_ATTR_TRACE* = SQL_OPT_TRACE + SQL_ATTR_TRACEFILE* = SQL_OPT_TRACEFILE + SQL_ATTR_TRANSLATE_LIB* = SQL_TRANSLATE_DLL + SQL_ATTR_TRANSLATE_OPTION* = SQL_TRANSLATE_OPTION # SQL_ATTR_TXN_ISOLATION =SQL_TXN_ISOLATION; + #* SQL_ACCESS_MODE options */ + SQL_MODE_READ_WRITE* = 0 + SQL_MODE_READ_ONLY* = 1 + SQL_MODE_DEFAULT* = SQL_MODE_READ_WRITE #* SQL_AUTOCOMMIT options */ + SQL_AUTOCOMMIT_OFF* = 0 + SQL_AUTOCOMMIT_ON* = 1 + SQL_AUTOCOMMIT_DEFAULT* = SQL_AUTOCOMMIT_ON # SQL_ATTR_CURSOR_SCROLLABLE values + SQL_NONSCROLLABLE* = 0 + SQL_SCROLLABLE* = 1 # SQL_CURSOR_TYPE options + SQL_CURSOR_FORWARD_ONLY* = 0 + SQL_CURSOR_KEYSET_DRIVEN* = 1 + SQL_CURSOR_DYNAMIC* = 2 + SQL_CURSOR_STATIC* = 3 + SQL_CURSOR_TYPE_DEFAULT* = SQL_CURSOR_FORWARD_ONLY # Default value + # SQL_CONCURRENCY options + SQL_CONCUR_READ_ONLY* = 1 + SQL_CONCUR_LOCK* = 2 + SQL_CONCUR_ROWVER* = 3 + SQL_CONCUR_VALUES* = 4 + SQL_CONCUR_DEFAULT* = SQL_CONCUR_READ_ONLY # Default value + # identifiers of fields in the SQL descriptor + SQL_DESC_COUNT* = 1001 + SQL_DESC_TYPE* = 1002 + SQL_DESC_LENGTH* = 1003 + SQL_DESC_OCTET_LENGTH_PTR* = 1004 + SQL_DESC_PRECISION* = 1005 + SQL_DESC_SCALE* = 1006 + SQL_DESC_DATETIME_INTERVAL_CODE* = 1007 + SQL_DESC_NULLABLE* = 1008 + SQL_DESC_INDICATOR_PTR* = 1009 + SQL_DESC_DATA_PTR* = 1010 + SQL_DESC_NAME* = 1011 + SQL_DESC_UNNAMED* = 1012 + SQL_DESC_OCTET_LENGTH* = 1013 + SQL_DESC_ALLOC_TYPE* = 1099 # identifiers of fields in the diagnostics area + SQL_DIAG_RETURNCODE* = 1 + SQL_DIAG_NUMBER* = 2 + SQL_DIAG_ROW_COUNT* = 3 + SQL_DIAG_SQLSTATE* = 4 + SQL_DIAG_NATIVE* = 5 + SQL_DIAG_MESSAGE_TEXT* = 6 + SQL_DIAG_DYNAMIC_FUNCTION* = 7 + SQL_DIAG_CLASS_ORIGIN* = 8 + SQL_DIAG_SUBCLASS_ORIGIN* = 9 + SQL_DIAG_CONNECTION_NAME* = 10 + SQL_DIAG_SERVER_NAME* = 11 + SQL_DIAG_DYNAMIC_FUNCTION_CODE* = 12 # dynamic function codes + SQL_DIAG_ALTER_TABLE* = 4 + SQL_DIAG_CREATE_INDEX* = (- 1) + SQL_DIAG_CREATE_TABLE* = 77 + SQL_DIAG_CREATE_VIEW* = 84 + SQL_DIAG_DELETE_WHERE* = 19 + SQL_DIAG_DROP_INDEX* = (- 2) + SQL_DIAG_DROP_TABLE* = 32 + SQL_DIAG_DROP_VIEW* = 36 + SQL_DIAG_DYNAMIC_DELETE_CURSOR* = 38 + SQL_DIAG_DYNAMIC_UPDATE_CURSOR* = 81 + SQL_DIAG_GRANT* = 48 + SQL_DIAG_INSERT* = 50 + SQL_DIAG_REVOKE* = 59 + SQL_DIAG_SELECT_CURSOR* = 85 + SQL_DIAG_UNKNOWN_STATEMENT* = 0 + SQL_DIAG_UPDATE_WHERE* = 82 # Statement attribute values for cursor sensitivity + SQL_UNSPECIFIED* = 0 + SQL_INSENSITIVE* = 1 + SQL_SENSITIVE* = 2 # GetTypeInfo() request for all data types + SQL_ALL_TYPES* = 0 # Default conversion code for SQLBindCol(), SQLBindParam() and SQLGetData() + SQL_DEFAULT* = 99 # SQLGetData() code indicating that the application row descriptor + # specifies the data type + SQL_ARD_TYPE* = (- 99) # SQL date/time type subcodes + SQL_CODE_DATE* = 1 + SQL_CODE_TIME* = 2 + SQL_CODE_TIMESTAMP* = 3 # CLI option values + SQL_FALSE* = 0 + SQL_TRUE* = 1 # values of NULLABLE field in descriptor + SQL_NO_NULLS* = 0 + SQL_NULLABLE* = 1 # Value returned by SQLGetTypeInfo() to denote that it is + # not known whether or not a data type supports null values. + SQL_NULLABLE_UNKNOWN* = 2 + SQL_CLOSE* = 0 + SQL_DROP* = 1 + SQL_UNBIND* = 2 + SQL_RESET_PARAMS* = 3 # Codes used for FetchOrientation in SQLFetchScroll(), + # and in SQLDataSources() + SQL_FETCH_NEXT* = 1 + SQL_FETCH_FIRST* = 2 + SQL_FETCH_FIRST_USER* = 31 + SQL_FETCH_FIRST_SYSTEM* = 32 # Other codes used for FetchOrientation in SQLFetchScroll() + SQL_FETCH_LAST* = 3 + SQL_FETCH_PRIOR* = 4 + SQL_FETCH_ABSOLUTE* = 5 + SQL_FETCH_RELATIVE* = 6 + SQL_NULL_HENV* = TSqlHEnv(nil) + SQL_NULL_HDBC* = TSqlHDBC(nil) + SQL_NULL_HSTMT* = TSqlHStmt(nil) + SQL_NULL_HDESC* = TSqlHDesc(nil) #* null handle used in place of parent handle when allocating HENV */ + SQL_NULL_HANDLE* = TSqlHandle(nil) #* Values that may appear in the result set of SQLSpecialColumns() */ + SQL_SCOPE_CURROW* = 0 + SQL_SCOPE_TRANSACTION* = 1 + SQL_SCOPE_SESSION* = 2 #* Column types and scopes in SQLSpecialColumns. */ + SQL_BEST_ROWID* = 1 + SQL_ROWVER* = 2 + SQL_ROW_IDENTIFIER* = 1 #* Reserved values for UNIQUE argument of SQLStatistics() */ + SQL_INDEX_UNIQUE* = 0 + SQL_INDEX_ALL* = 1 #* Reserved values for RESERVED argument of SQLStatistics() */ + SQL_QUICK* = 0 + SQL_ENSURE* = 1 #* Values that may appear in the result set of SQLStatistics() */ + SQL_TABLE_STAT* = 0 + SQL_INDEX_CLUSTERED* = 1 + SQL_INDEX_HASHED* = 2 + SQL_INDEX_OTHER* = 3 + SQL_SCROLL_CONCURRENCY* = 43 + SQL_TXN_CAPABLE* = 46 + SQL_TRANSACTION_CAPABLE* = SQL_TXN_CAPABLE + SQL_USER_NAME* = 47 + SQL_TXN_ISOLATION_OPTION* = 72 + SQL_TRANSACTION_ISOLATION_OPTION* = SQL_TXN_ISOLATION_OPTION + SQL_OJ_CAPABILITIES* = 115 + SQL_OUTER_JOIN_CAPABILITIES* = SQL_OJ_CAPABILITIES + SQL_XOPEN_CLI_YEAR* = 10000 + SQL_CURSOR_SENSITIVITY* = 10001 + SQL_DESCRIBE_PARAMETER* = 10002 + SQL_CATALOG_NAME* = 10003 + SQL_COLLATION_SEQ* = 10004 + SQL_MAX_IDENTIFIER_LEN* = 10005 + SQL_MAXIMUM_IDENTIFIER_LENGTH* = SQL_MAX_IDENTIFIER_LEN + SQL_SCCO_READ_ONLY* = 1 + SQL_SCCO_LOCK* = 2 + SQL_SCCO_OPT_ROWVER* = 4 + SQL_SCCO_OPT_VALUES* = 8 #* SQL_TXN_CAPABLE values */ + SQL_TC_NONE* = 0 + SQL_TC_DML* = 1 + SQL_TC_ALL* = 2 + SQL_TC_DDL_COMMIT* = 3 + SQL_TC_DDL_IGNORE* = 4 #* SQL_TXN_ISOLATION_OPTION bitmasks */ + SQL_TXN_READ_UNCOMMITTED* = 1 + SQL_TRANSACTION_READ_UNCOMMITTED* = SQL_TXN_READ_UNCOMMITTED + SQL_TXN_READ_COMMITTED* = 2 + SQL_TRANSACTION_READ_COMMITTED* = SQL_TXN_READ_COMMITTED + SQL_TXN_REPEATABLE_READ* = 4 + SQL_TRANSACTION_REPEATABLE_READ* = SQL_TXN_REPEATABLE_READ + SQL_TXN_SERIALIZABLE* = 8 + SQL_TRANSACTION_SERIALIZABLE* = SQL_TXN_SERIALIZABLE + SQL_SS_ADDITIONS* = 1 + SQL_SS_DELETIONS* = 2 + SQL_SS_UPDATES* = 4 # SQLColAttributes defines + SQL_COLUMN_COUNT* = 0 + SQL_COLUMN_NAME* = 1 + SQL_COLUMN_TYPE* = 2 + SQL_COLUMN_LENGTH* = 3 + SQL_COLUMN_PRECISION* = 4 + SQL_COLUMN_SCALE* = 5 + SQL_COLUMN_DISPLAY_SIZE* = 6 + SQL_COLUMN_NULLABLE* = 7 + SQL_COLUMN_UNSIGNED* = 8 + SQL_COLUMN_MONEY* = 9 + SQL_COLUMN_UPDATABLE* = 10 + SQL_COLUMN_AUTO_INCREMENT* = 11 + SQL_COLUMN_CASE_SENSITIVE* = 12 + SQL_COLUMN_SEARCHABLE* = 13 + SQL_COLUMN_TYPE_NAME* = 14 + SQL_COLUMN_TABLE_NAME* = 15 + SQL_COLUMN_OWNER_NAME* = 16 + SQL_COLUMN_QUALIFIER_NAME* = 17 + SQL_COLUMN_LABEL* = 18 + SQL_COLATT_OPT_MAX* = SQL_COLUMN_LABEL + SQL_COLUMN_DRIVER_START* = 1000 + SQL_DESC_ARRAY_SIZE* = 20 + SQL_DESC_ARRAY_STATUS_PTR* = 21 + SQL_DESC_AUTO_UNIQUE_VALUE* = SQL_COLUMN_AUTO_INCREMENT + SQL_DESC_BASE_COLUMN_NAME* = 22 + SQL_DESC_BASE_TABLE_NAME* = 23 + SQL_DESC_BIND_OFFSET_PTR* = 24 + SQL_DESC_BIND_TYPE* = 25 + SQL_DESC_CASE_SENSITIVE* = SQL_COLUMN_CASE_SENSITIVE + SQL_DESC_CATALOG_NAME* = SQL_COLUMN_QUALIFIER_NAME + SQL_DESC_CONCISE_TYPE* = SQL_COLUMN_TYPE + SQL_DESC_DATETIME_INTERVAL_PRECISION* = 26 + SQL_DESC_DISPLAY_SIZE* = SQL_COLUMN_DISPLAY_SIZE + SQL_DESC_FIXED_PREC_SCALE* = SQL_COLUMN_MONEY + SQL_DESC_LABEL* = SQL_COLUMN_LABEL + SQL_DESC_LITERAL_PREFIX* = 27 + SQL_DESC_LITERAL_SUFFIX* = 28 + SQL_DESC_LOCAL_TYPE_NAME* = 29 + SQL_DESC_MAXIMUM_SCALE* = 30 + SQL_DESC_MINIMUM_SCALE* = 31 + SQL_DESC_NUM_PREC_RADIX* = 32 + SQL_DESC_PARAMETER_TYPE* = 33 + SQL_DESC_ROWS_PROCESSED_PTR* = 34 + SQL_DESC_SCHEMA_NAME* = SQL_COLUMN_OWNER_NAME + SQL_DESC_SEARCHABLE* = SQL_COLUMN_SEARCHABLE + SQL_DESC_TYPE_NAME* = SQL_COLUMN_TYPE_NAME + SQL_DESC_TABLE_NAME* = SQL_COLUMN_TABLE_NAME + SQL_DESC_UNSIGNED* = SQL_COLUMN_UNSIGNED + SQL_DESC_UPDATABLE* = SQL_COLUMN_UPDATABLE #* SQLEndTran() options */ + SQL_COMMIT* = 0 + SQL_ROLLBACK* = 1 + SQL_ATTR_ROW_ARRAY_SIZE* = 27 #* SQLConfigDataSource() options */ + ODBC_ADD_DSN* = 1 + ODBC_CONFIG_DSN* = 2 + ODBC_REMOVE_DSN* = 3 + ODBC_ADD_SYS_DSN* = 4 + ODBC_CONFIG_SYS_DSN* = 5 + ODBC_REMOVE_SYS_DSN* = 6 + +proc SQLAllocHandle*(HandleType: TSqlSmallInt, InputHandle: TSqlHandle, + OutputHandlePtr: var TSqlHandle): TSqlSmallInt{. + dynlib: odbclib, importc.} +proc SQLSetEnvAttr*(EnvironmentHandle: TSqlHEnv, Attribute: TSqlInteger, + Value: TSqlPointer, StringLength: TSqlInteger): TSqlSmallInt{. + dynlib: odbclib, importc.} +proc SQLGetEnvAttr*(EnvironmentHandle: TSqlHEnv, Attribute: TSqlInteger, + Value: TSqlPointer, BufferLength: TSqlInteger, + StringLength: PSQLINTEGER): TSqlSmallInt{.dynlib: odbclib, + importc.} +proc SQLFreeHandle*(HandleType: TSqlSmallInt, Handle: TSqlHandle): TSqlSmallInt{. + dynlib: odbclib, importc.} +proc SQLGetDiagRec*(HandleType: TSqlSmallInt, Handle: TSqlHandle, + RecNumber: TSqlSmallInt, Sqlstate: PSQLCHAR, + NativeError: var TSqlInteger, MessageText: PSQLCHAR, + BufferLength: TSqlSmallInt, TextLength: var TSqlSmallInt): TSqlSmallInt{. + dynlib: odbclib, importc.} +proc SQLGetDiagField*(HandleType: TSqlSmallInt, Handle: TSqlHandle, + RecNumber: TSqlSmallInt, DiagIdentifier: TSqlSmallInt, + DiagInfoPtr: TSqlPointer, BufferLength: TSqlSmallInt, + StringLengthPtr: var TSqlSmallInt): TSqlSmallInt{. + dynlib: odbclib, importc.} +proc SQLConnect*(ConnectionHandle: TSqlHDBC, ServerName: PSQLCHAR, + NameLength1: TSqlSmallInt, UserName: PSQLCHAR, + NameLength2: TSqlSmallInt, Authentication: PSQLCHAR, + NameLength3: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.} +proc SQLDisconnect*(ConnectionHandle: TSqlHDBC): TSqlSmallInt{.dynlib: odbclib, + importc.} +proc SQLDriverConnect*(hdbc: TSqlHDBC, hwnd: TSqlHWND, szCsin: cstring, + szCLen: TSqlSmallInt, szCsout: cstring, + cbCSMax: TSqlSmallInt, cbCsOut: var TSqlSmallInt, + f: TSqlUSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.} +proc SQLBrowseConnect*(hdbc: TSqlHDBC, szConnStrIn: PSQLCHAR, + cbConnStrIn: TSqlSmallInt, szConnStrOut: PSQLCHAR, + cbConnStrOutMax: TSqlSmallInt, + cbConnStrOut: var TSqlSmallInt): TSqlSmallInt{. + dynlib: odbclib, importc.} +proc SQLExecDirect*(StatementHandle: TSqlHStmt, StatementText: PSQLCHAR, + TextLength: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.} +proc SQLPrepare*(StatementHandle: TSqlHStmt, StatementText: PSQLCHAR, + TextLength: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.} +proc SQLCloseCursor*(StatementHandle: TSqlHStmt): TSqlSmallInt{.dynlib: odbclib, + importc.} +proc SQLExecute*(StatementHandle: TSqlHStmt): TSqlSmallInt{.dynlib: odbclib, importc.} +proc SQLFetch*(StatementHandle: TSqlHStmt): TSqlSmallInt{.dynlib: odbclib, importc.} +proc SQLNumResultCols*(StatementHandle: TSqlHStmt, ColumnCount: var TSqlSmallInt): TSqlSmallInt{. + dynlib: odbclib, importc.} +proc SQLDescribeCol*(StatementHandle: TSqlHStmt, ColumnNumber: TSqlUSmallInt, + ColumnName: PSQLCHAR, BufferLength: TSqlSmallInt, + NameLength: var TSqlSmallInt, DataType: var TSqlSmallInt, + ColumnSize: var TSqlUInteger, + DecimalDigits: var TSqlSmallInt, Nullable: var TSqlSmallInt): TSqlSmallInt{. + dynlib: odbclib, importc.} +proc SQLFetchScroll*(StatementHandle: TSqlHStmt, FetchOrientation: TSqlSmallInt, + FetchOffset: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, + importc.} +proc SQLExtendedFetch*(hstmt: TSqlHStmt, fFetchType: TSqlUSmallInt, + irow: TSqlInteger, pcrow: PSQLUINTEGER, + rgfRowStatus: PSQLUSMALLINT): TSqlSmallInt{.dynlib: odbclib, + importc.} +proc SQLGetData*(StatementHandle: TSqlHStmt, ColumnNumber: TSqlUSmallInt, + TargetType: TSqlSmallInt, TargetValue: TSqlPointer, + BufferLength: TSqlInteger, StrLen_or_Ind: PSQLINTEGER): TSqlSmallInt{. + dynlib: odbclib, importc.} +proc SQLSetStmtAttr*(StatementHandle: TSqlHStmt, Attribute: TSqlInteger, + Value: TSqlPointer, StringLength: TSqlInteger): TSqlSmallInt{. + dynlib: odbclib, importc.} +proc SQLGetStmtAttr*(StatementHandle: TSqlHStmt, Attribute: TSqlInteger, + Value: TSqlPointer, BufferLength: TSqlInteger, + StringLength: PSQLINTEGER): TSqlSmallInt{.dynlib: odbclib, + importc.} +proc SQLGetInfo*(ConnectionHandle: TSqlHDBC, InfoType: TSqlUSmallInt, + InfoValue: TSqlPointer, BufferLength: TSqlSmallInt, + StringLength: PSQLSMALLINT): TSqlSmallInt{.dynlib: odbclib, + importc.} +proc SQLBulkOperations*(StatementHandle: TSqlHStmt, Operation: TSqlSmallInt): TSqlSmallInt{. + dynlib: odbclib, importc.} +proc SQLPutData*(StatementHandle: TSqlHStmt, Data: TSqlPointer, + StrLen_or_Ind: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.} +proc SQLBindCol*(StatementHandle: TSqlHStmt, ColumnNumber: TSqlUSmallInt, + TargetType: TSqlSmallInt, TargetValue: TSqlPointer, + BufferLength: TSqlInteger, StrLen_or_Ind: PSQLINTEGER): TSqlSmallInt{. + dynlib: odbclib, importc.} +proc SQLSetPos*(hstmt: TSqlHStmt, irow: TSqlUSmallInt, fOption: TSqlUSmallInt, + fLock: TSqlUSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.} +proc SQLDataSources*(EnvironmentHandle: TSqlHEnv, Direction: TSqlUSmallInt, + ServerName: PSQLCHAR, BufferLength1: TSqlSmallInt, + NameLength1: PSQLSMALLINT, Description: PSQLCHAR, + BufferLength2: TSqlSmallInt, NameLength2: PSQLSMALLINT): TSqlSmallInt{. + dynlib: odbclib, importc.} +proc SQLDrivers*(EnvironmentHandle: TSqlHEnv, Direction: TSqlUSmallInt, + DriverDescription: PSQLCHAR, BufferLength1: TSqlSmallInt, + DescriptionLength1: PSQLSMALLINT, DriverAttributes: PSQLCHAR, + BufferLength2: TSqlSmallInt, AttributesLength2: PSQLSMALLINT): TSqlSmallInt{. + dynlib: odbclib, importc.} +proc SQLSetConnectAttr*(ConnectionHandle: TSqlHDBC, Attribute: TSqlInteger, + Value: TSqlPointer, StringLength: TSqlInteger): TSqlSmallInt{. + dynlib: odbclib, importc.} +proc SQLGetCursorName*(StatementHandle: TSqlHStmt, CursorName: PSQLCHAR, + BufferLength: TSqlSmallInt, NameLength: PSQLSMALLINT): TSqlSmallInt{. + dynlib: odbclib, importc.} +proc SQLSetCursorName*(StatementHandle: TSqlHStmt, CursorName: PSQLCHAR, + NameLength: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, + importc.} +proc SQLRowCount*(StatementHandle: TSqlHStmt, RowCount: var TSqlInteger): TSqlSmallInt{. + dynlib: odbclib, importc.} +proc SQLBindParameter*(hstmt: TSqlHStmt, ipar: TSqlUSmallInt, + fParamType: TSqlSmallInt, fCType: TSqlSmallInt, + fSqlType: TSqlSmallInt, cbColDef: TSqlUInteger, + ibScale: TSqlSmallInt, rgbValue: TSqlPointer, + cbValueMax: TSqlInteger, pcbValue: PSQLINTEGER): TSqlSmallInt{. + dynlib: odbclib, importc.} +proc SQLFreeStmt*(StatementHandle: TSqlHStmt, Option: TSqlUSmallInt): TSqlSmallInt{. + dynlib: odbclib, importc.} +proc SQLColAttribute*(StatementHandle: TSqlHStmt, ColumnNumber: TSqlUSmallInt, + FieldIdentifier: TSqlUSmallInt, + CharacterAttribute: PSQLCHAR, BufferLength: TSqlSmallInt, + StringLength: PSQLSMALLINT, NumericAttribute: TSqlPointer): TSqlSmallInt{. + dynlib: odbclib, importc.} +proc SQLEndTran*(HandleType: TSqlSmallInt, Handle: TSqlHandle, + CompletionType: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, + importc.} +proc SQLTables*(hstmt: TSqlHStmt, szTableQualifier: PSQLCHAR, + cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR, + cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR, + cbTableName: TSqlSmallInt, szTableType: PSQLCHAR, + cbTableType: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.} +proc SQLColumns*(hstmt: TSqlHStmt, szTableQualifier: PSQLCHAR, + cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR, + cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR, + cbTableName: TSqlSmallInt, szColumnName: PSQLCHAR, + cbColumnName: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.} +proc SQLSpecialColumns*(StatementHandle: TSqlHStmt, IdentifierType: TSqlUSmallInt, + CatalogName: PSQLCHAR, NameLength1: TSqlSmallInt, + SchemaName: PSQLCHAR, NameLength2: TSqlSmallInt, + TableName: PSQLCHAR, NameLength3: TSqlSmallInt, + Scope: TSqlUSmallInt, Nullable: TSqlUSmallInt): TSqlSmallInt{. + dynlib: odbclib, importc.} +proc SQLProcedures*(hstmt: TSqlHStmt, szTableQualifier: PSQLCHAR, + cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR, + cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR, + cbTableName: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, + importc.} +proc SQLPrimaryKeys*(hstmt: TSqlHStmt, CatalogName: PSQLCHAR, + NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR, + NameLength2: TSqlSmallInt, TableName: PSQLCHAR, + NameLength3: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, + importc.} +proc SQLProcedureColumns*(hstmt: TSqlHStmt, CatalogName: PSQLCHAR, + NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR, + NameLength2: TSqlSmallInt, ProcName: PSQLCHAR, + NameLength3: TSqlSmallInt, ColumnName: PSQLCHAR, + NameLength4: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, + importc.} +proc SQLStatistics*(hstmt: TSqlHStmt, CatalogName: PSQLCHAR, + NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR, + NameLength2: TSqlSmallInt, TableName: PSQLCHAR, + NameLength3: TSqlSmallInt, Unique: TSqlUSmallInt, + Reserved: TSqlUSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.} + +{.pop.} \ No newline at end of file diff --git a/lib/base/opengl/gl.nim b/lib/base/opengl/gl.nim new file mode 100644 index 000000000..4cc84cba1 --- /dev/null +++ b/lib/base/opengl/gl.nim @@ -0,0 +1,1432 @@ +# +# +# Adaption of the delphi3d.net OpenGL units to FreePascal +# Sebastian Guenther (sg@freepascal.org) in 2002 +# These units are free to use +# +#****************************************************************************** +# Converted to Delphi by Tom Nuydens (tom@delphi3d.net) +# For the latest updates, visit Delphi3D: http://www.delphi3d.net +#****************************************************************************** + +when defined(windows): + {.push callconv: stdcall.} +else: + {.push callconv: cdecl.} + +when defined(windows): + const dllname* = "opengl32.dll" +elif defined(macosx): + const dllname* = "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib" +else: + const dllname* = "libGL.so.1" + +type + PGLenum* = ptr TGLenum + PGLboolean* = ptr TGLboolean + PGLbitfield* = ptr TGLbitfield + TGLbyte* = int8 + PGLbyte* = ptr TGlbyte + PGLshort* = ptr TGLshort + PGLint* = ptr TGLint + PGLsizei* = ptr TGLsizei + PGLubyte* = ptr TGLubyte + PGLushort* = ptr TGLushort + PGLuint* = ptr TGLuint + PGLfloat* = ptr TGLfloat + PGLclampf* = ptr TGLclampf + PGLdouble* = ptr TGLdouble + PGLclampd* = ptr TGLclampd + PGLvoid* = Pointer + PPGLvoid* = ptr PGLvoid + TGLenum* = cint + TGLboolean* = bool + TGLbitfield* = cint + TGLshort* = int16 + TGLint* = cint + TGLsizei* = int + TGLubyte* = int8 + TGLushort* = int16 + TGLuint* = cint + TGLfloat* = float32 + TGLclampf* = float32 + TGLdouble* = float + TGLclampd* = float + +const # Version + GL_VERSION_1_1* = 1 # AccumOp + constGL_ACCUM* = 0x00000100 + GL_LOAD* = 0x00000101 + GL_RETURN* = 0x00000102 + GL_MULT* = 0x00000103 + GL_ADD* = 0x00000104 # AlphaFunction + GL_NEVER* = 0x00000200 + GL_LESS* = 0x00000201 + GL_EQUAL* = 0x00000202 + GL_LEQUAL* = 0x00000203 + GL_GREATER* = 0x00000204 + GL_NOTEQUAL* = 0x00000205 + GL_GEQUAL* = 0x00000206 + GL_ALWAYS* = 0x00000207 # AttribMask + GL_CURRENT_BIT* = 0x00000001 + GL_POINT_BIT* = 0x00000002 + GL_LINE_BIT* = 0x00000004 + GL_POLYGON_BIT* = 0x00000008 + GL_POLYGON_STIPPLE_BIT* = 0x00000010 + GL_PIXEL_MODE_BIT* = 0x00000020 + GL_LIGHTING_BIT* = 0x00000040 + GL_FOG_BIT* = 0x00000080 + GL_DEPTH_BUFFER_BIT* = 0x00000100 + GL_ACCUM_BUFFER_BIT* = 0x00000200 + GL_STENCIL_BUFFER_BIT* = 0x00000400 + GL_VIEWPORT_BIT* = 0x00000800 + GL_TRANSFORM_BIT* = 0x00001000 + GL_ENABLE_BIT* = 0x00002000 + GL_COLOR_BUFFER_BIT* = 0x00004000 + GL_HINT_BIT* = 0x00008000 + GL_EVAL_BIT* = 0x00010000 + GL_LIST_BIT* = 0x00020000 + GL_TEXTURE_BIT* = 0x00040000 + GL_SCISSOR_BIT* = 0x00080000 + GL_ALL_ATTRIB_BITS* = 0x000FFFFF # BeginMode + GL_POINTS* = 0x00000000 + GL_LINES* = 0x00000001 + GL_LINE_LOOP* = 0x00000002 + GL_LINE_STRIP* = 0x00000003 + GL_TRIANGLES* = 0x00000004 + GL_TRIANGLE_STRIP* = 0x00000005 + GL_TRIANGLE_FAN* = 0x00000006 + GL_QUADS* = 0x00000007 + GL_QUAD_STRIP* = 0x00000008 + GL_POLYGON* = 0x00000009 # BlendingFactorDest + GL_ZERO* = 0 + GL_ONE* = 1 + GL_SRC_COLOR* = 0x00000300 + GL_ONE_MINUS_SRC_COLOR* = 0x00000301 + GL_SRC_ALPHA* = 0x00000302 + GL_ONE_MINUS_SRC_ALPHA* = 0x00000303 + GL_DST_ALPHA* = 0x00000304 + GL_ONE_MINUS_DST_ALPHA* = 0x00000305 # BlendingFactorSrc + # GL_ZERO + # GL_ONE + GL_DST_COLOR* = 0x00000306 + GL_ONE_MINUS_DST_COLOR* = 0x00000307 + GL_SRC_ALPHA_SATURATE* = 0x00000308 # GL_SRC_ALPHA + # GL_ONE_MINUS_SRC_ALPHA + # GL_DST_ALPHA + # GL_ONE_MINUS_DST_ALPHA + # Boolean + GL_TRUE* = 1 + GL_FALSE* = 0 # ClearBufferMask + # GL_COLOR_BUFFER_BIT + # GL_ACCUM_BUFFER_BIT + # GL_STENCIL_BUFFER_BIT + # GL_DEPTH_BUFFER_BIT + # ClientArrayType + # GL_VERTEX_ARRAY + # GL_NORMAL_ARRAY + # GL_COLOR_ARRAY + # GL_INDEX_ARRAY + # GL_TEXTURE_COORD_ARRAY + # GL_EDGE_FLAG_ARRAY + # ClipPlaneName + GL_CLIP_PLANE0* = 0x00003000 + GL_CLIP_PLANE1* = 0x00003001 + GL_CLIP_PLANE2* = 0x00003002 + GL_CLIP_PLANE3* = 0x00003003 + GL_CLIP_PLANE4* = 0x00003004 + GL_CLIP_PLANE5* = 0x00003005 # ColorMaterialFace + # GL_FRONT + # GL_BACK + # GL_FRONT_AND_BACK + # ColorMaterialParameter + # GL_AMBIENT + # GL_DIFFUSE + # GL_SPECULAR + # GL_EMISSION + # GL_AMBIENT_AND_DIFFUSE + # ColorPointerType + # GL_BYTE + # GL_UNSIGNED_BYTE + # GL_SHORT + # GL_UNSIGNED_SHORT + # GL_INT + # GL_UNSIGNED_INT + # GL_FLOAT + # GL_DOUBLE + # CullFaceMode + # GL_FRONT + # GL_BACK + # GL_FRONT_AND_BACK + # DataType + GL_BYTE* = 0x00001400 + GL_UNSIGNED_BYTE* = 0x00001401 + GL_SHORT* = 0x00001402 + GL_UNSIGNED_SHORT* = 0x00001403 + GL_INT* = 0x00001404 + GL_UNSIGNED_INT* = 0x00001405 + GL_FLOAT* = 0x00001406 + GL_2_BYTES* = 0x00001407 + GL_3_BYTES* = 0x00001408 + GL_4_BYTES* = 0x00001409 + GL_DOUBLE* = 0x0000140A # DepthFunction + # GL_NEVER + # GL_LESS + # GL_EQUAL + # GL_LEQUAL + # GL_GREATER + # GL_NOTEQUAL + # GL_GEQUAL + # GL_ALWAYS + # DrawBufferMode + GL_NONE* = 0 + GL_FRONT_LEFT* = 0x00000400 + GL_FRONT_RIGHT* = 0x00000401 + GL_BACK_LEFT* = 0x00000402 + GL_BACK_RIGHT* = 0x00000403 + GL_FRONT* = 0x00000404 + GL_BACK* = 0x00000405 + GL_LEFT* = 0x00000406 + GL_RIGHT* = 0x00000407 + GL_FRONT_AND_BACK* = 0x00000408 + GL_AUX0* = 0x00000409 + GL_AUX1* = 0x0000040A + GL_AUX2* = 0x0000040B + GL_AUX3* = 0x0000040C # Enable + # GL_FOG + # GL_LIGHTING + # GL_TEXTURE_1D + # GL_TEXTURE_2D + # GL_LINE_STIPPLE + # GL_POLYGON_STIPPLE + # GL_CULL_FACE + # GL_ALPHA_TEST + # GL_BLEND + # GL_INDEX_LOGIC_OP + # GL_COLOR_LOGIC_OP + # GL_DITHER + # GL_STENCIL_TEST + # GL_DEPTH_TEST + # GL_CLIP_PLANE0 + # GL_CLIP_PLANE1 + # GL_CLIP_PLANE2 + # GL_CLIP_PLANE3 + # GL_CLIP_PLANE4 + # GL_CLIP_PLANE5 + # GL_LIGHT0 + # GL_LIGHT1 + # GL_LIGHT2 + # GL_LIGHT3 + # GL_LIGHT4 + # GL_LIGHT5 + # GL_LIGHT6 + # GL_LIGHT7 + # GL_TEXTURE_GEN_S + # GL_TEXTURE_GEN_T + # GL_TEXTURE_GEN_R + # GL_TEXTURE_GEN_Q + # GL_MAP1_VERTEX_3 + # GL_MAP1_VERTEX_4 + # GL_MAP1_COLOR_4 + # GL_MAP1_INDEX + # GL_MAP1_NORMAL + # GL_MAP1_TEXTURE_COORD_1 + # GL_MAP1_TEXTURE_COORD_2 + # GL_MAP1_TEXTURE_COORD_3 + # GL_MAP1_TEXTURE_COORD_4 + # GL_MAP2_VERTEX_3 + # GL_MAP2_VERTEX_4 + # GL_MAP2_COLOR_4 + # GL_MAP2_INDEX + # GL_MAP2_NORMAL + # GL_MAP2_TEXTURE_COORD_1 + # GL_MAP2_TEXTURE_COORD_2 + # GL_MAP2_TEXTURE_COORD_3 + # GL_MAP2_TEXTURE_COORD_4 + # GL_POINT_SMOOTH + # GL_LINE_SMOOTH + # GL_POLYGON_SMOOTH + # GL_SCISSOR_TEST + # GL_COLOR_MATERIAL + # GL_NORMALIZE + # GL_AUTO_NORMAL + # GL_VERTEX_ARRAY + # GL_NORMAL_ARRAY + # GL_COLOR_ARRAY + # GL_INDEX_ARRAY + # GL_TEXTURE_COORD_ARRAY + # GL_EDGE_FLAG_ARRAY + # GL_POLYGON_OFFSET_POINT + # GL_POLYGON_OFFSET_LINE + # GL_POLYGON_OFFSET_FILL + # ErrorCode + GL_NO_ERROR* = 0 + GL_INVALID_ENUM* = 0x00000500 + GL_INVALID_VALUE* = 0x00000501 + GL_INVALID_OPERATION* = 0x00000502 + GL_STACK_OVERFLOW* = 0x00000503 + GL_STACK_UNDERFLOW* = 0x00000504 + GL_OUT_OF_MEMORY* = 0x00000505 # FeedBackMode + GL_2D* = 0x00000600 + GL_3D* = 0x00000601 + GL_3D_COLOR* = 0x00000602 + GL_3D_COLOR_TEXTURE* = 0x00000603 + GL_4D_COLOR_TEXTURE* = 0x00000604 # FeedBackToken + GL_PASS_THROUGH_TOKEN* = 0x00000700 + GL_POINT_TOKEN* = 0x00000701 + GL_LINE_TOKEN* = 0x00000702 + GL_POLYGON_TOKEN* = 0x00000703 + GL_BITMAP_TOKEN* = 0x00000704 + GL_DRAW_PIXEL_TOKEN* = 0x00000705 + GL_COPY_PIXEL_TOKEN* = 0x00000706 + GL_LINE_RESET_TOKEN* = 0x00000707 # FogMode + # GL_LINEAR + GL_EXP* = 0x00000800 + GL_EXP2* = 0x00000801 # FogParameter + # GL_FOG_COLOR + # GL_FOG_DENSITY + # GL_FOG_END + # GL_FOG_INDEX + # GL_FOG_MODE + # GL_FOG_START + # FrontFaceDirection + GL_CW* = 0x00000900 + GL_CCW* = 0x00000901 # GetMapTarget + GL_COEFF* = 0x00000A00 + GL_ORDER* = 0x00000A01 + GL_DOMAIN* = 0x00000A02 # GetPixelMap + # GL_PIXEL_MAP_I_TO_I + # GL_PIXEL_MAP_S_TO_S + # GL_PIXEL_MAP_I_TO_R + # GL_PIXEL_MAP_I_TO_G + # GL_PIXEL_MAP_I_TO_B + # GL_PIXEL_MAP_I_TO_A + # GL_PIXEL_MAP_R_TO_R + # GL_PIXEL_MAP_G_TO_G + # GL_PIXEL_MAP_B_TO_B + # GL_PIXEL_MAP_A_TO_A + # GetPointerTarget + # GL_VERTEX_ARRAY_POINTER + # GL_NORMAL_ARRAY_POINTER + # GL_COLOR_ARRAY_POINTER + # GL_INDEX_ARRAY_POINTER + # GL_TEXTURE_COORD_ARRAY_POINTER + # GL_EDGE_FLAG_ARRAY_POINTER + # GetTarget + GL_CURRENT_COLOR* = 0x00000B00 + GL_CURRENT_INDEX* = 0x00000B01 + GL_CURRENT_NORMAL* = 0x00000B02 + GL_CURRENT_TEXTURE_COORDS* = 0x00000B03 + GL_CURRENT_RASTER_COLOR* = 0x00000B04 + GL_CURRENT_RASTER_INDEX* = 0x00000B05 + GL_CURRENT_RASTER_TEXTURE_COORDS* = 0x00000B06 + GL_CURRENT_RASTER_POSITION* = 0x00000B07 + GL_CURRENT_RASTER_POSITION_VALID* = 0x00000B08 + GL_CURRENT_RASTER_DISTANCE* = 0x00000B09 + GL_POINT_SMOOTH* = 0x00000B10 + constGL_POINT_SIZE* = 0x00000B11 + GL_POINT_SIZE_RANGE* = 0x00000B12 + GL_POINT_SIZE_GRANULARITY* = 0x00000B13 + GL_LINE_SMOOTH* = 0x00000B20 + constGL_LINE_WIDTH* = 0x00000B21 + GL_LINE_WIDTH_RANGE* = 0x00000B22 + GL_LINE_WIDTH_GRANULARITY* = 0x00000B23 + constGL_LINE_STIPPLE* = 0x00000B24 + GL_LINE_STIPPLE_PATTERN* = 0x00000B25 + GL_LINE_STIPPLE_REPEAT* = 0x00000B26 + GL_LIST_MODE* = 0x00000B30 + GL_MAX_LIST_NESTING* = 0x00000B31 + constGL_LIST_BASE* = 0x00000B32 + GL_LIST_INDEX* = 0x00000B33 + constGL_POLYGON_MODE* = 0x00000B40 + GL_POLYGON_SMOOTH* = 0x00000B41 + constGL_POLYGON_STIPPLE* = 0x00000B42 + constGL_EDGE_FLAG* = 0x00000B43 + constGL_CULL_FACE* = 0x00000B44 + GL_CULL_FACE_MODE* = 0x00000B45 + constGL_FRONT_FACE* = 0x00000B46 + GL_LIGHTING* = 0x00000B50 + GL_LIGHT_MODEL_LOCAL_VIEWER* = 0x00000B51 + GL_LIGHT_MODEL_TWO_SIDE* = 0x00000B52 + GL_LIGHT_MODEL_AMBIENT* = 0x00000B53 + constGL_SHADE_MODEL* = 0x00000B54 + GL_COLOR_MATERIAL_FACE* = 0x00000B55 + GL_COLOR_MATERIAL_PARAMETER* = 0x00000B56 + constGL_COLOR_MATERIAL* = 0x00000B57 + GL_FOG* = 0x00000B60 + GL_FOG_INDEX* = 0x00000B61 + GL_FOG_DENSITY* = 0x00000B62 + GL_FOG_START* = 0x00000B63 + GL_FOG_END* = 0x00000B64 + GL_FOG_MODE* = 0x00000B65 + GL_FOG_COLOR* = 0x00000B66 + constGL_DEPTH_RANGE* = 0x00000B70 + GL_DEPTH_TEST* = 0x00000B71 + GL_DEPTH_WRITEMASK* = 0x00000B72 + GL_DEPTH_CLEAR_VALUE* = 0x00000B73 + constGL_DEPTH_FUNC* = 0x00000B74 + GL_ACCUM_CLEAR_VALUE* = 0x00000B80 + GL_STENCIL_TEST* = 0x00000B90 + GL_STENCIL_CLEAR_VALUE* = 0x00000B91 + constGL_STENCIL_FUNC* = 0x00000B92 + GL_STENCIL_VALUE_MASK* = 0x00000B93 + GL_STENCIL_FAIL* = 0x00000B94 + GL_STENCIL_PASS_DEPTH_FAIL* = 0x00000B95 + GL_STENCIL_PASS_DEPTH_PASS* = 0x00000B96 + GL_STENCIL_REF* = 0x00000B97 + GL_STENCIL_WRITEMASK* = 0x00000B98 + constGL_MATRIX_MODE* = 0x00000BA0 + GL_NORMALIZE* = 0x00000BA1 + constGL_VIEWPORT* = 0x00000BA2 + GL_MODELVIEW_STACK_DEPTH* = 0x00000BA3 + GL_PROJECTION_STACK_DEPTH* = 0x00000BA4 + GL_TEXTURE_STACK_DEPTH* = 0x00000BA5 + GL_MODELVIEW_MATRIX* = 0x00000BA6 + GL_PROJECTION_MATRIX* = 0x00000BA7 + GL_TEXTURE_MATRIX* = 0x00000BA8 + GL_ATTRIB_STACK_DEPTH* = 0x00000BB0 + GL_CLIENT_ATTRIB_STACK_DEPTH* = 0x00000BB1 + GL_ALPHA_TEST* = 0x00000BC0 + GL_ALPHA_TEST_FUNC* = 0x00000BC1 + GL_ALPHA_TEST_REF* = 0x00000BC2 + GL_DITHER* = 0x00000BD0 + GL_BLEND_DST* = 0x00000BE0 + GL_BLEND_SRC* = 0x00000BE1 + GL_BLEND* = 0x00000BE2 + GL_LOGIC_OP_MODE* = 0x00000BF0 + GL_INDEX_LOGIC_OP* = 0x00000BF1 + GL_COLOR_LOGIC_OP* = 0x00000BF2 + GL_AUX_BUFFERS* = 0x00000C00 + constGL_DRAW_BUFFER* = 0x00000C01 + constGL_READ_BUFFER* = 0x00000C02 + GL_SCISSOR_BOX* = 0x00000C10 + GL_SCISSOR_TEST* = 0x00000C11 + GL_INDEX_CLEAR_VALUE* = 0x00000C20 + GL_INDEX_WRITEMASK* = 0x00000C21 + GL_COLOR_CLEAR_VALUE* = 0x00000C22 + GL_COLOR_WRITEMASK* = 0x00000C23 + GL_INDEX_MODE* = 0x00000C30 + GL_RGBA_MODE* = 0x00000C31 + GL_DOUBLEBUFFER* = 0x00000C32 + GL_STEREO* = 0x00000C33 + constGL_RENDER_MODE* = 0x00000C40 + GL_PERSPECTIVE_CORRECTION_HINT* = 0x00000C50 + GL_POINT_SMOOTH_HINT* = 0x00000C51 + GL_LINE_SMOOTH_HINT* = 0x00000C52 + GL_POLYGON_SMOOTH_HINT* = 0x00000C53 + GL_FOG_HINT* = 0x00000C54 + GL_TEXTURE_GEN_S* = 0x00000C60 + GL_TEXTURE_GEN_T* = 0x00000C61 + GL_TEXTURE_GEN_R* = 0x00000C62 + GL_TEXTURE_GEN_Q* = 0x00000C63 + GL_PIXEL_MAP_I_TO_I* = 0x00000C70 + GL_PIXEL_MAP_S_TO_S* = 0x00000C71 + GL_PIXEL_MAP_I_TO_R* = 0x00000C72 + GL_PIXEL_MAP_I_TO_G* = 0x00000C73 + GL_PIXEL_MAP_I_TO_B* = 0x00000C74 + GL_PIXEL_MAP_I_TO_A* = 0x00000C75 + GL_PIXEL_MAP_R_TO_R* = 0x00000C76 + GL_PIXEL_MAP_G_TO_G* = 0x00000C77 + GL_PIXEL_MAP_B_TO_B* = 0x00000C78 + GL_PIXEL_MAP_A_TO_A* = 0x00000C79 + GL_PIXEL_MAP_I_TO_I_SIZE* = 0x00000CB0 + GL_PIXEL_MAP_S_TO_S_SIZE* = 0x00000CB1 + GL_PIXEL_MAP_I_TO_R_SIZE* = 0x00000CB2 + GL_PIXEL_MAP_I_TO_G_SIZE* = 0x00000CB3 + GL_PIXEL_MAP_I_TO_B_SIZE* = 0x00000CB4 + GL_PIXEL_MAP_I_TO_A_SIZE* = 0x00000CB5 + GL_PIXEL_MAP_R_TO_R_SIZE* = 0x00000CB6 + GL_PIXEL_MAP_G_TO_G_SIZE* = 0x00000CB7 + GL_PIXEL_MAP_B_TO_B_SIZE* = 0x00000CB8 + GL_PIXEL_MAP_A_TO_A_SIZE* = 0x00000CB9 + GL_UNPACK_SWAP_BYTES* = 0x00000CF0 + GL_UNPACK_LSB_FIRST* = 0x00000CF1 + GL_UNPACK_ROW_LENGTH* = 0x00000CF2 + GL_UNPACK_SKIP_ROWS* = 0x00000CF3 + GL_UNPACK_SKIP_PIXELS* = 0x00000CF4 + GL_UNPACK_ALIGNMENT* = 0x00000CF5 + GL_PACK_SWAP_BYTES* = 0x00000D00 + GL_PACK_LSB_FIRST* = 0x00000D01 + GL_PACK_ROW_LENGTH* = 0x00000D02 + GL_PACK_SKIP_ROWS* = 0x00000D03 + GL_PACK_SKIP_PIXELS* = 0x00000D04 + GL_PACK_ALIGNMENT* = 0x00000D05 + GL_MAP_COLOR* = 0x00000D10 + GL_MAP_STENCIL* = 0x00000D11 + GL_INDEX_SHIFT* = 0x00000D12 + GL_INDEX_OFFSET* = 0x00000D13 + GL_RED_SCALE* = 0x00000D14 + GL_RED_BIAS* = 0x00000D15 + GL_ZOOM_X* = 0x00000D16 + GL_ZOOM_Y* = 0x00000D17 + GL_GREEN_SCALE* = 0x00000D18 + GL_GREEN_BIAS* = 0x00000D19 + GL_BLUE_SCALE* = 0x00000D1A + GL_BLUE_BIAS* = 0x00000D1B + GL_ALPHA_SCALE* = 0x00000D1C + GL_ALPHA_BIAS* = 0x00000D1D + GL_DEPTH_SCALE* = 0x00000D1E + GL_DEPTH_BIAS* = 0x00000D1F + GL_MAX_EVAL_ORDER* = 0x00000D30 + GL_MAX_LIGHTS* = 0x00000D31 + GL_MAX_CLIP_PLANES* = 0x00000D32 + GL_MAX_TEXTURE_SIZE* = 0x00000D33 + GL_MAX_PIXEL_MAP_TABLE* = 0x00000D34 + GL_MAX_ATTRIB_STACK_DEPTH* = 0x00000D35 + GL_MAX_MODELVIEW_STACK_DEPTH* = 0x00000D36 + GL_MAX_NAME_STACK_DEPTH* = 0x00000D37 + GL_MAX_PROJECTION_STACK_DEPTH* = 0x00000D38 + GL_MAX_TEXTURE_STACK_DEPTH* = 0x00000D39 + GL_MAX_VIEWPORT_DIMS* = 0x00000D3A + GL_MAX_CLIENT_ATTRIB_STACK_DEPTH* = 0x00000D3B + GL_SUBPIXEL_BITS* = 0x00000D50 + GL_INDEX_BITS* = 0x00000D51 + GL_RED_BITS* = 0x00000D52 + GL_GREEN_BITS* = 0x00000D53 + GL_BLUE_BITS* = 0x00000D54 + GL_ALPHA_BITS* = 0x00000D55 + GL_DEPTH_BITS* = 0x00000D56 + GL_STENCIL_BITS* = 0x00000D57 + GL_ACCUM_RED_BITS* = 0x00000D58 + GL_ACCUM_GREEN_BITS* = 0x00000D59 + GL_ACCUM_BLUE_BITS* = 0x00000D5A + GL_ACCUM_ALPHA_BITS* = 0x00000D5B + GL_NAME_STACK_DEPTH* = 0x00000D70 + GL_AUTO_NORMAL* = 0x00000D80 + GL_MAP1_COLOR_4* = 0x00000D90 + GL_MAP1_INDEX* = 0x00000D91 + GL_MAP1_NORMAL* = 0x00000D92 + GL_MAP1_TEXTURE_COORD_1* = 0x00000D93 + GL_MAP1_TEXTURE_COORD_2* = 0x00000D94 + GL_MAP1_TEXTURE_COORD_3* = 0x00000D95 + GL_MAP1_TEXTURE_COORD_4* = 0x00000D96 + GL_MAP1_VERTEX_3* = 0x00000D97 + GL_MAP1_VERTEX_4* = 0x00000D98 + GL_MAP2_COLOR_4* = 0x00000DB0 + GL_MAP2_INDEX* = 0x00000DB1 + GL_MAP2_NORMAL* = 0x00000DB2 + GL_MAP2_TEXTURE_COORD_1* = 0x00000DB3 + GL_MAP2_TEXTURE_COORD_2* = 0x00000DB4 + GL_MAP2_TEXTURE_COORD_3* = 0x00000DB5 + GL_MAP2_TEXTURE_COORD_4* = 0x00000DB6 + GL_MAP2_VERTEX_3* = 0x00000DB7 + GL_MAP2_VERTEX_4* = 0x00000DB8 + GL_MAP1_GRID_DOMAIN* = 0x00000DD0 + GL_MAP1_GRID_SEGMENTS* = 0x00000DD1 + GL_MAP2_GRID_DOMAIN* = 0x00000DD2 + GL_MAP2_GRID_SEGMENTS* = 0x00000DD3 + GL_TEXTURE_1D* = 0x00000DE0 + GL_TEXTURE_2D* = 0x00000DE1 + GL_FEEDBACK_BUFFER_POINTER* = 0x00000DF0 + GL_FEEDBACK_BUFFER_SIZE* = 0x00000DF1 + GL_FEEDBACK_BUFFER_TYPE* = 0x00000DF2 + GL_SELECTION_BUFFER_POINTER* = 0x00000DF3 + GL_SELECTION_BUFFER_SIZE* = 0x00000DF4 # GL_TEXTURE_BINDING_1D + # GL_TEXTURE_BINDING_2D + # GL_VERTEX_ARRAY + # GL_NORMAL_ARRAY + # GL_COLOR_ARRAY + # GL_INDEX_ARRAY + # GL_TEXTURE_COORD_ARRAY + # GL_EDGE_FLAG_ARRAY + # GL_VERTEX_ARRAY_SIZE + # GL_VERTEX_ARRAY_TYPE + # GL_VERTEX_ARRAY_STRIDE + # GL_NORMAL_ARRAY_TYPE + # GL_NORMAL_ARRAY_STRIDE + # GL_COLOR_ARRAY_SIZE + # GL_COLOR_ARRAY_TYPE + # GL_COLOR_ARRAY_STRIDE + # GL_INDEX_ARRAY_TYPE + # GL_INDEX_ARRAY_STRIDE + # GL_TEXTURE_COORD_ARRAY_SIZE + # GL_TEXTURE_COORD_ARRAY_TYPE + # GL_TEXTURE_COORD_ARRAY_STRIDE + # GL_EDGE_FLAG_ARRAY_STRIDE + # GL_POLYGON_OFFSET_FACTOR + # GL_POLYGON_OFFSET_UNITS + # GetTextureParameter + # GL_TEXTURE_MAG_FILTER + # GL_TEXTURE_MIN_FILTER + # GL_TEXTURE_WRAP_S + # GL_TEXTURE_WRAP_T + GL_TEXTURE_WIDTH* = 0x00001000 + GL_TEXTURE_HEIGHT* = 0x00001001 + GL_TEXTURE_INTERNAL_FORMAT* = 0x00001003 + GL_TEXTURE_BORDER_COLOR* = 0x00001004 + GL_TEXTURE_BORDER* = 0x00001005 # GL_TEXTURE_RED_SIZE + # GL_TEXTURE_GREEN_SIZE + # GL_TEXTURE_BLUE_SIZE + # GL_TEXTURE_ALPHA_SIZE + # GL_TEXTURE_LUMINANCE_SIZE + # GL_TEXTURE_INTENSITY_SIZE + # GL_TEXTURE_PRIORITY + # GL_TEXTURE_RESIDENT + # HintMode + GL_DONT_CARE* = 0x00001100 + GL_FASTEST* = 0x00001101 + GL_NICEST* = 0x00001102 # HintTarget + # GL_PERSPECTIVE_CORRECTION_HINT + # GL_POINT_SMOOTH_HINT + # GL_LINE_SMOOTH_HINT + # GL_POLYGON_SMOOTH_HINT + # GL_FOG_HINT + # IndexPointerType + # GL_SHORT + # GL_INT + # GL_FLOAT + # GL_DOUBLE + # LightModelParameter + # GL_LIGHT_MODEL_AMBIENT + # GL_LIGHT_MODEL_LOCAL_VIEWER + # GL_LIGHT_MODEL_TWO_SIDE + # LightName + GL_LIGHT0* = 0x00004000 + GL_LIGHT1* = 0x00004001 + GL_LIGHT2* = 0x00004002 + GL_LIGHT3* = 0x00004003 + GL_LIGHT4* = 0x00004004 + GL_LIGHT5* = 0x00004005 + GL_LIGHT6* = 0x00004006 + GL_LIGHT7* = 0x00004007 # LightParameter + GL_AMBIENT* = 0x00001200 + GL_DIFFUSE* = 0x00001201 + GL_SPECULAR* = 0x00001202 + GL_POSITION* = 0x00001203 + GL_SPOT_DIRECTION* = 0x00001204 + GL_SPOT_EXPONENT* = 0x00001205 + GL_SPOT_CUTOFF* = 0x00001206 + GL_CONSTANT_ATTENUATION* = 0x00001207 + GL_LINEAR_ATTENUATION* = 0x00001208 + GL_QUADRATIC_ATTENUATION* = 0x00001209 # InterleavedArrays + # GL_V2F + # GL_V3F + # GL_C4UB_V2F + # GL_C4UB_V3F + # GL_C3F_V3F + # GL_N3F_V3F + # GL_C4F_N3F_V3F + # GL_T2F_V3F + # GL_T4F_V4F + # GL_T2F_C4UB_V3F + # GL_T2F_C3F_V3F + # GL_T2F_N3F_V3F + # GL_T2F_C4F_N3F_V3F + # GL_T4F_C4F_N3F_V4F + # ListMode + GL_COMPILE* = 0x00001300 + GL_COMPILE_AND_EXECUTE* = 0x00001301 # ListNameType + # GL_BYTE + # GL_UNSIGNED_BYTE + # GL_SHORT + # GL_UNSIGNED_SHORT + # GL_INT + # GL_UNSIGNED_INT + # GL_FLOAT + # GL_2_BYTES + # GL_3_BYTES + # GL_4_BYTES + # LogicOp + constGL_CLEAR* = 0x00001500 + GL_AND* = 0x00001501 + GL_AND_REVERSE* = 0x00001502 + GL_COPY* = 0x00001503 + GL_AND_INVERTED* = 0x00001504 + GL_NOOP* = 0x00001505 + GL_XOR* = 0x00001506 + GL_OR* = 0x00001507 + GL_NOR* = 0x00001508 + GL_EQUIV* = 0x00001509 + GL_INVERT* = 0x0000150A + GL_OR_REVERSE* = 0x0000150B + GL_COPY_INVERTED* = 0x0000150C + GL_OR_INVERTED* = 0x0000150D + GL_NAND* = 0x0000150E + GL_SET* = 0x0000150F # MapTarget + # GL_MAP1_COLOR_4 + # GL_MAP1_INDEX + # GL_MAP1_NORMAL + # GL_MAP1_TEXTURE_COORD_1 + # GL_MAP1_TEXTURE_COORD_2 + # GL_MAP1_TEXTURE_COORD_3 + # GL_MAP1_TEXTURE_COORD_4 + # GL_MAP1_VERTEX_3 + # GL_MAP1_VERTEX_4 + # GL_MAP2_COLOR_4 + # GL_MAP2_INDEX + # GL_MAP2_NORMAL + # GL_MAP2_TEXTURE_COORD_1 + # GL_MAP2_TEXTURE_COORD_2 + # GL_MAP2_TEXTURE_COORD_3 + # GL_MAP2_TEXTURE_COORD_4 + # GL_MAP2_VERTEX_3 + # GL_MAP2_VERTEX_4 + # MaterialFace + # GL_FRONT + # GL_BACK + # GL_FRONT_AND_BACK + # MaterialParameter + GL_EMISSION* = 0x00001600 + GL_SHININESS* = 0x00001601 + GL_AMBIENT_AND_DIFFUSE* = 0x00001602 + GL_COLOR_INDEXES* = 0x00001603 # GL_AMBIENT + # GL_DIFFUSE + # GL_SPECULAR + # MatrixMode + GL_MODELVIEW* = 0x00001700 + GL_PROJECTION* = 0x00001701 + GL_TEXTURE* = 0x00001702 # MeshMode1 + # GL_POINT + # GL_LINE + # MeshMode2 + # GL_POINT + # GL_LINE + # GL_FILL + # NormalPointerType + # GL_BYTE + # GL_SHORT + # GL_INT + # GL_FLOAT + # GL_DOUBLE + # PixelCopyType + GL_COLOR* = 0x00001800 + GL_DEPTH* = 0x00001801 + GL_STENCIL* = 0x00001802 # PixelFormat + GL_COLOR_INDEX* = 0x00001900 + GL_STENCIL_INDEX* = 0x00001901 + GL_DEPTH_COMPONENT* = 0x00001902 + GL_RED* = 0x00001903 + GL_GREEN* = 0x00001904 + GL_BLUE* = 0x00001905 + GL_ALPHA* = 0x00001906 + GL_RGB* = 0x00001907 + GL_RGBA* = 0x00001908 + GL_LUMINANCE* = 0x00001909 + GL_LUMINANCE_ALPHA* = 0x0000190A # PixelMap + # GL_PIXEL_MAP_I_TO_I + # GL_PIXEL_MAP_S_TO_S + # GL_PIXEL_MAP_I_TO_R + # GL_PIXEL_MAP_I_TO_G + # GL_PIXEL_MAP_I_TO_B + # GL_PIXEL_MAP_I_TO_A + # GL_PIXEL_MAP_R_TO_R + # GL_PIXEL_MAP_G_TO_G + # GL_PIXEL_MAP_B_TO_B + # GL_PIXEL_MAP_A_TO_A + # PixelStore + # GL_UNPACK_SWAP_BYTES + # GL_UNPACK_LSB_FIRST + # GL_UNPACK_ROW_LENGTH + # GL_UNPACK_SKIP_ROWS + # GL_UNPACK_SKIP_PIXELS + # GL_UNPACK_ALIGNMENT + # GL_PACK_SWAP_BYTES + # GL_PACK_LSB_FIRST + # GL_PACK_ROW_LENGTH + # GL_PACK_SKIP_ROWS + # GL_PACK_SKIP_PIXELS + # GL_PACK_ALIGNMENT + # PixelTransfer + # GL_MAP_COLOR + # GL_MAP_STENCIL + # GL_INDEX_SHIFT + # GL_INDEX_OFFSET + # GL_RED_SCALE + # GL_RED_BIAS + # GL_GREEN_SCALE + # GL_GREEN_BIAS + # GL_BLUE_SCALE + # GL_BLUE_BIAS + # GL_ALPHA_SCALE + # GL_ALPHA_BIAS + # GL_DEPTH_SCALE + # GL_DEPTH_BIAS + # PixelType + constGL_BITMAP* = 0x00001A00 + GL_POINT* = 0x00001B00 + GL_LINE* = 0x00001B01 + GL_FILL* = 0x00001B02 # ReadBufferMode + # GL_FRONT_LEFT + # GL_FRONT_RIGHT + # GL_BACK_LEFT + # GL_BACK_RIGHT + # GL_FRONT + # GL_BACK + # GL_LEFT + # GL_RIGHT + # GL_AUX0 + # GL_AUX1 + # GL_AUX2 + # GL_AUX3 + # RenderingMode + GL_RENDER* = 0x00001C00 + GL_FEEDBACK* = 0x00001C01 + GL_SELECT* = 0x00001C02 # ShadingModel + GL_FLAT* = 0x00001D00 + GL_SMOOTH* = 0x00001D01 # StencilFunction + # GL_NEVER + # GL_LESS + # GL_EQUAL + # GL_LEQUAL + # GL_GREATER + # GL_NOTEQUAL + # GL_GEQUAL + # GL_ALWAYS + # StencilOp + # GL_ZERO + GL_KEEP* = 0x00001E00 + GL_REPLACE* = 0x00001E01 + GL_INCR* = 0x00001E02 + GL_DECR* = 0x00001E03 # GL_INVERT + # StringName + GL_VENDOR* = 0x00001F00 + GL_RENDERER* = 0x00001F01 + GL_VERSION* = 0x00001F02 + GL_EXTENSIONS* = 0x00001F03 # TextureCoordName + GL_S* = 0x00002000 + GL_T* = 0x00002001 + GL_R* = 0x00002002 + GL_Q* = 0x00002003 # TexCoordPointerType + # GL_SHORT + # GL_INT + # GL_FLOAT + # GL_DOUBLE + # TextureEnvMode + GL_MODULATE* = 0x00002100 + GL_DECAL* = 0x00002101 # GL_BLEND + # GL_REPLACE + # TextureEnvParameter + GL_TEXTURE_ENV_MODE* = 0x00002200 + GL_TEXTURE_ENV_COLOR* = 0x00002201 # TextureEnvTarget + GL_TEXTURE_ENV* = 0x00002300 # TextureGenMode + GL_EYE_LINEAR* = 0x00002400 + GL_OBJECT_LINEAR* = 0x00002401 + GL_SPHERE_MAP* = 0x00002402 # TextureGenParameter + GL_TEXTURE_GEN_MODE* = 0x00002500 + GL_OBJECT_PLANE* = 0x00002501 + GL_EYE_PLANE* = 0x00002502 # TextureMagFilter + GL_NEAREST* = 0x00002600 + GL_LINEAR* = 0x00002601 # TextureMinFilter + # GL_NEAREST + # GL_LINEAR + GL_NEAREST_MIPMAP_NEAREST* = 0x00002700 + GL_LINEAR_MIPMAP_NEAREST* = 0x00002701 + GL_NEAREST_MIPMAP_LINEAR* = 0x00002702 + GL_LINEAR_MIPMAP_LINEAR* = 0x00002703 # TextureParameterName + GL_TEXTURE_MAG_FILTER* = 0x00002800 + GL_TEXTURE_MIN_FILTER* = 0x00002801 + GL_TEXTURE_WRAP_S* = 0x00002802 + GL_TEXTURE_WRAP_T* = 0x00002803 # GL_TEXTURE_BORDER_COLOR + # GL_TEXTURE_PRIORITY + # TextureTarget + # GL_TEXTURE_1D + # GL_TEXTURE_2D + # GL_PROXY_TEXTURE_1D + # GL_PROXY_TEXTURE_2D + # TextureWrapMode + GL_CLAMP* = 0x00002900 + GL_REPEAT* = 0x00002901 # VertexPointerType + # GL_SHORT + # GL_INT + # GL_FLOAT + # GL_DOUBLE + # ClientAttribMask + GL_CLIENT_PIXEL_STORE_BIT* = 0x00000001 + GL_CLIENT_VERTEX_ARRAY_BIT* = 0x00000002 + GL_CLIENT_ALL_ATTRIB_BITS* = 0xFFFFFFFF # polygon_offset + GL_POLYGON_OFFSET_FACTOR* = 0x00008038 + GL_POLYGON_OFFSET_UNITS* = 0x00002A00 + GL_POLYGON_OFFSET_POINT* = 0x00002A01 + GL_POLYGON_OFFSET_LINE* = 0x00002A02 + GL_POLYGON_OFFSET_FILL* = 0x00008037 # texture + GL_ALPHA4* = 0x0000803B + GL_ALPHA8* = 0x0000803C + GL_ALPHA12* = 0x0000803D + GL_ALPHA16* = 0x0000803E + GL_LUMINANCE4* = 0x0000803F + GL_LUMINANCE8* = 0x00008040 + GL_LUMINANCE12* = 0x00008041 + GL_LUMINANCE16* = 0x00008042 + GL_LUMINANCE4_ALPHA4* = 0x00008043 + GL_LUMINANCE6_ALPHA2* = 0x00008044 + GL_LUMINANCE8_ALPHA8* = 0x00008045 + GL_LUMINANCE12_ALPHA4* = 0x00008046 + GL_LUMINANCE12_ALPHA12* = 0x00008047 + GL_LUMINANCE16_ALPHA16* = 0x00008048 + GL_INTENSITY* = 0x00008049 + GL_INTENSITY4* = 0x0000804A + GL_INTENSITY8* = 0x0000804B + GL_INTENSITY12* = 0x0000804C + GL_INTENSITY16* = 0x0000804D + GL_R3_G3_B2* = 0x00002A10 + GL_RGB4* = 0x0000804F + GL_RGB5* = 0x00008050 + GL_RGB8* = 0x00008051 + GL_RGB10* = 0x00008052 + GL_RGB12* = 0x00008053 + GL_RGB16* = 0x00008054 + GL_RGBA2* = 0x00008055 + GL_RGBA4* = 0x00008056 + GL_RGB5_A1* = 0x00008057 + GL_RGBA8* = 0x00008058 + GL_RGB10_A2* = 0x00008059 + GL_RGBA12* = 0x0000805A + GL_RGBA16* = 0x0000805B + GL_TEXTURE_RED_SIZE* = 0x0000805C + GL_TEXTURE_GREEN_SIZE* = 0x0000805D + GL_TEXTURE_BLUE_SIZE* = 0x0000805E + GL_TEXTURE_ALPHA_SIZE* = 0x0000805F + GL_TEXTURE_LUMINANCE_SIZE* = 0x00008060 + GL_TEXTURE_INTENSITY_SIZE* = 0x00008061 + GL_PROXY_TEXTURE_1D* = 0x00008063 + GL_PROXY_TEXTURE_2D* = 0x00008064 # texture_object + GL_TEXTURE_PRIORITY* = 0x00008066 + GL_TEXTURE_RESIDENT* = 0x00008067 + GL_TEXTURE_BINDING_1D* = 0x00008068 + GL_TEXTURE_BINDING_2D* = 0x00008069 # vertex_array + GL_VERTEX_ARRAY* = 0x00008074 + GL_NORMAL_ARRAY* = 0x00008075 + GL_COLOR_ARRAY* = 0x00008076 + GL_INDEX_ARRAY* = 0x00008077 + GL_TEXTURE_COORD_ARRAY* = 0x00008078 + GL_EDGE_FLAG_ARRAY* = 0x00008079 + GL_VERTEX_ARRAY_SIZE* = 0x0000807A + GL_VERTEX_ARRAY_TYPE* = 0x0000807B + GL_VERTEX_ARRAY_STRIDE* = 0x0000807C + GL_NORMAL_ARRAY_TYPE* = 0x0000807E + GL_NORMAL_ARRAY_STRIDE* = 0x0000807F + GL_COLOR_ARRAY_SIZE* = 0x00008081 + GL_COLOR_ARRAY_TYPE* = 0x00008082 + GL_COLOR_ARRAY_STRIDE* = 0x00008083 + GL_INDEX_ARRAY_TYPE* = 0x00008085 + GL_INDEX_ARRAY_STRIDE* = 0x00008086 + GL_TEXTURE_COORD_ARRAY_SIZE* = 0x00008088 + GL_TEXTURE_COORD_ARRAY_TYPE* = 0x00008089 + GL_TEXTURE_COORD_ARRAY_STRIDE* = 0x0000808A + GL_EDGE_FLAG_ARRAY_STRIDE* = 0x0000808C + GL_VERTEX_ARRAY_POINTER* = 0x0000808E + GL_NORMAL_ARRAY_POINTER* = 0x0000808F + GL_COLOR_ARRAY_POINTER* = 0x00008090 + GL_INDEX_ARRAY_POINTER* = 0x00008091 + GL_TEXTURE_COORD_ARRAY_POINTER* = 0x00008092 + GL_EDGE_FLAG_ARRAY_POINTER* = 0x00008093 + GL_V2F* = 0x00002A20 + GL_V3F* = 0x00002A21 + GL_C4UB_V2F* = 0x00002A22 + GL_C4UB_V3F* = 0x00002A23 + GL_C3F_V3F* = 0x00002A24 + GL_N3F_V3F* = 0x00002A25 + GL_C4F_N3F_V3F* = 0x00002A26 + GL_T2F_V3F* = 0x00002A27 + GL_T4F_V4F* = 0x00002A28 + GL_T2F_C4UB_V3F* = 0x00002A29 + GL_T2F_C3F_V3F* = 0x00002A2A + GL_T2F_N3F_V3F* = 0x00002A2B + GL_T2F_C4F_N3F_V3F* = 0x00002A2C + GL_T4F_C4F_N3F_V4F* = 0x00002A2D # Extensions + GL_EXT_vertex_array* = 1 + GL_WIN_swap_hint* = 1 + GL_EXT_bgra* = 1 + GL_EXT_paletted_texture* = 1 # EXT_vertex_array + GL_VERTEX_ARRAY_EXT* = 0x00008074 + GL_NORMAL_ARRAY_EXT* = 0x00008075 + GL_COLOR_ARRAY_EXT* = 0x00008076 + GL_INDEX_ARRAY_EXT* = 0x00008077 + GL_TEXTURE_COORD_ARRAY_EXT* = 0x00008078 + GL_EDGE_FLAG_ARRAY_EXT* = 0x00008079 + GL_VERTEX_ARRAY_SIZE_EXT* = 0x0000807A + GL_VERTEX_ARRAY_TYPE_EXT* = 0x0000807B + GL_VERTEX_ARRAY_STRIDE_EXT* = 0x0000807C + GL_VERTEX_ARRAY_COUNT_EXT* = 0x0000807D + GL_NORMAL_ARRAY_TYPE_EXT* = 0x0000807E + GL_NORMAL_ARRAY_STRIDE_EXT* = 0x0000807F + GL_NORMAL_ARRAY_COUNT_EXT* = 0x00008080 + GL_COLOR_ARRAY_SIZE_EXT* = 0x00008081 + GL_COLOR_ARRAY_TYPE_EXT* = 0x00008082 + GL_COLOR_ARRAY_STRIDE_EXT* = 0x00008083 + GL_COLOR_ARRAY_COUNT_EXT* = 0x00008084 + GL_INDEX_ARRAY_TYPE_EXT* = 0x00008085 + GL_INDEX_ARRAY_STRIDE_EXT* = 0x00008086 + GL_INDEX_ARRAY_COUNT_EXT* = 0x00008087 + GL_TEXTURE_COORD_ARRAY_SIZE_EXT* = 0x00008088 + GL_TEXTURE_COORD_ARRAY_TYPE_EXT* = 0x00008089 + GL_TEXTURE_COORD_ARRAY_STRIDE_EXT* = 0x0000808A + GL_TEXTURE_COORD_ARRAY_COUNT_EXT* = 0x0000808B + GL_EDGE_FLAG_ARRAY_STRIDE_EXT* = 0x0000808C + GL_EDGE_FLAG_ARRAY_COUNT_EXT* = 0x0000808D + GL_VERTEX_ARRAY_POINTER_EXT* = 0x0000808E + GL_NORMAL_ARRAY_POINTER_EXT* = 0x0000808F + GL_COLOR_ARRAY_POINTER_EXT* = 0x00008090 + GL_INDEX_ARRAY_POINTER_EXT* = 0x00008091 + GL_TEXTURE_COORD_ARRAY_POINTER_EXT* = 0x00008092 + GL_EDGE_FLAG_ARRAY_POINTER_EXT* = 0x00008093 + GL_DOUBLE_EXT* = GL_DOUBLE # EXT_bgra + GL_BGR_EXT* = 0x000080E0 + GL_BGRA_EXT* = 0x000080E1 # EXT_paletted_texture + # These must match the GL_COLOR_TABLE_*_SGI enumerants + GL_COLOR_TABLE_FORMAT_EXT* = 0x000080D8 + GL_COLOR_TABLE_WIDTH_EXT* = 0x000080D9 + GL_COLOR_TABLE_RED_SIZE_EXT* = 0x000080DA + GL_COLOR_TABLE_GREEN_SIZE_EXT* = 0x000080DB + GL_COLOR_TABLE_BLUE_SIZE_EXT* = 0x000080DC + GL_COLOR_TABLE_ALPHA_SIZE_EXT* = 0x000080DD + GL_COLOR_TABLE_LUMINANCE_SIZE_EXT* = 0x000080DE + GL_COLOR_TABLE_INTENSITY_SIZE_EXT* = 0x000080DF + GL_COLOR_INDEX1_EXT* = 0x000080E2 + GL_COLOR_INDEX2_EXT* = 0x000080E3 + GL_COLOR_INDEX4_EXT* = 0x000080E4 + GL_COLOR_INDEX8_EXT* = 0x000080E5 + GL_COLOR_INDEX12_EXT* = 0x000080E6 + GL_COLOR_INDEX16_EXT* = 0x000080E7 # For compatibility with OpenGL v1.0 + constGL_LOGIC_OP* = GL_INDEX_LOGIC_OP + GL_TEXTURE_COMPONENTS* = GL_TEXTURE_INTERNAL_FORMAT + +proc glAccum*(op: TGLenum, value: TGLfloat){.dynlib: dllname, importc.} +proc glAlphaFunc*(func: TGLenum, theref: TGLclampf){.dynlib: dllname, importc.} +proc glAreTexturesResident*(n: TGLsizei, textures: PGLuint, + residences: PGLboolean): TGLboolean{.dynlib: dllname, + importc.} +proc glArrayElement*(i: TGLint){.dynlib: dllname, importc.} +proc glBegin*(mode: TGLenum){.dynlib: dllname, importc.} +proc glBindTexture*(target: TGLenum, texture: TGLuint){.dynlib: dllname, importc.} +proc glBitmap*(width, height: TGLsizei, xorig, yorig: TGLfloat, + xmove, ymove: TGLfloat, bitmap: PGLubyte){.dynlib: dllname, + importc.} +proc glBlendFunc*(sfactor, dfactor: TGLenum){.dynlib: dllname, importc.} +proc glCallList*(list: TGLuint){.dynlib: dllname, importc.} +proc glCallLists*(n: TGLsizei, atype: TGLenum, lists: Pointer){.dynlib: dllname, + importc.} +proc glClear*(mask: TGLbitfield){.dynlib: dllname, importc.} +proc glClearAccum*(red, green, blue, alpha: TGLfloat){.dynlib: dllname, importc.} +proc glClearColor*(red, green, blue, alpha: TGLclampf){.dynlib: dllname, importc.} +proc glClearDepth*(depth: TGLclampd){.dynlib: dllname, importc.} +proc glClearIndex*(c: TGLfloat){.dynlib: dllname, importc.} +proc glClearStencil*(s: TGLint){.dynlib: dllname, importc.} +proc glClipPlane*(plane: TGLenum, equation: PGLdouble){.dynlib: dllname, importc.} +proc glColor3b*(red, green, blue: TGlbyte){.dynlib: dllname, importc.} +proc glColor3bv*(v: PGLbyte){.dynlib: dllname, importc.} +proc glColor3d*(red, green, blue: TGLdouble){.dynlib: dllname, importc.} +proc glColor3dv*(v: PGLdouble){.dynlib: dllname, importc.} +proc glColor3f*(red, green, blue: TGLfloat){.dynlib: dllname, importc.} +proc glColor3fv*(v: PGLfloat){.dynlib: dllname, importc.} +proc glColor3i*(red, green, blue: TGLint){.dynlib: dllname, importc.} +proc glColor3iv*(v: PGLint){.dynlib: dllname, importc.} +proc glColor3s*(red, green, blue: TGLshort){.dynlib: dllname, importc.} +proc glColor3sv*(v: PGLshort){.dynlib: dllname, importc.} +proc glColor3ub*(red, green, blue: TGLubyte){.dynlib: dllname, importc.} +proc glColor3ubv*(v: PGLubyte){.dynlib: dllname, importc.} +proc glColor3ui*(red, green, blue: TGLuint){.dynlib: dllname, importc.} +proc glColor3uiv*(v: PGLuint){.dynlib: dllname, importc.} +proc glColor3us*(red, green, blue: TGLushort){.dynlib: dllname, importc.} +proc glColor3usv*(v: PGLushort){.dynlib: dllname, importc.} +proc glColor4b*(red, green, blue, alpha: TGlbyte){.dynlib: dllname, importc.} +proc glColor4bv*(v: PGLbyte){.dynlib: dllname, importc.} +proc glColor4d*(red, green, blue, alpha: TGLdouble){.dynlib: dllname, importc.} +proc glColor4dv*(v: PGLdouble){.dynlib: dllname, importc.} +proc glColor4f*(red, green, blue, alpha: TGLfloat){.dynlib: dllname, importc.} +proc glColor4fv*(v: PGLfloat){.dynlib: dllname, importc.} +proc glColor4i*(red, green, blue, alpha: TGLint){.dynlib: dllname, importc.} +proc glColor4iv*(v: PGLint){.dynlib: dllname, importc.} +proc glColor4s*(red, green, blue, alpha: TGLshort){.dynlib: dllname, importc.} +proc glColor4sv*(v: PGLshort){.dynlib: dllname, importc.} +proc glColor4ub*(red, green, blue, alpha: TGLubyte){.dynlib: dllname, importc.} +proc glColor4ubv*(v: PGLubyte){.dynlib: dllname, importc.} +proc glColor4ui*(red, green, blue, alpha: TGLuint){.dynlib: dllname, importc.} +proc glColor4uiv*(v: PGLuint){.dynlib: dllname, importc.} +proc glColor4us*(red, green, blue, alpha: TGLushort){.dynlib: dllname, importc.} +proc glColor4usv*(v: PGLushort){.dynlib: dllname, importc.} +proc glColorMask*(red, green, blue, alpha: TGLboolean){.dynlib: dllname, importc.} +proc glColorMaterial*(face, mode: TGLenum){.dynlib: dllname, importc.} +proc glColorPointer*(size: TGLint, atype: TGLenum, stride: TGLsizei, + pointer: Pointer){.dynlib: dllname, importc.} +proc glCopyPixels*(x, y: TGLint, width, height: TGLsizei, atype: TGLenum){. + dynlib: dllname, importc.} +proc glCopyTexImage1D*(target: TGLenum, level: TGLint, internalFormat: TGLenum, + x, y: TGLint, width: TGLsizei, border: TGLint){. + dynlib: dllname, importc.} +proc glCopyTexImage2D*(target: TGLenum, level: TGLint, internalFormat: TGLenum, + x, y: TGLint, width, height: TGLsizei, border: TGLint){. + dynlib: dllname, importc.} +proc glCopyTexSubImage1D*(target: TGLenum, level, xoffset, x, y: TGLint, + width: TGLsizei){.dynlib: dllname, importc.} +proc glCopyTexSubImage2D*(target: TGLenum, level, xoffset, yoffset, x, y: TGLint, + width, height: TGLsizei){.dynlib: dllname, importc.} +proc glCullFace*(mode: TGLenum){.dynlib: dllname, importc.} +proc glDeleteLists*(list: TGLuint, range: TGLsizei){.dynlib: dllname, importc.} +proc glDeleteTextures*(n: TGLsizei, textures: PGLuint){.dynlib: dllname, importc.} +proc glDepthFunc*(func: TGLenum){.dynlib: dllname, importc.} +proc glDepthMask*(flag: TGLboolean){.dynlib: dllname, importc.} +proc glDepthRange*(zNear, zFar: TGLclampd){.dynlib: dllname, importc.} +proc glDisable*(cap: TGLenum){.dynlib: dllname, importc.} +proc glDisableClientState*(aarray: TGLenum){.dynlib: dllname, importc.} +proc glDrawArrays*(mode: TGLenum, first: TGLint, count: TGLsizei){.dynlib: dllname, + importc.} +proc glDrawBuffer*(mode: TGLenum){.dynlib: dllname, importc.} +proc glDrawElements*(mode: TGLenum, count: TGLsizei, atype: TGLenum, + indices: Pointer){.dynlib: dllname, importc.} +proc glDrawPixels*(width, height: TGLsizei, format, atype: TGLenum, + pixels: Pointer){.dynlib: dllname, importc.} +proc glEdgeFlag*(flag: TGLboolean){.dynlib: dllname, importc.} +proc glEdgeFlagPointer*(stride: TGLsizei, pointer: Pointer){.dynlib: dllname, + importc.} +proc glEdgeFlagv*(flag: PGLboolean){.dynlib: dllname, importc.} +proc glEnable*(cap: TGLenum){.dynlib: dllname, importc.} +proc glEnableClientState*(aarray: TGLenum){.dynlib: dllname, importc.} +proc glEnd*(){.dynlib: dllname, importc.} +proc glEndList*(){.dynlib: dllname, importc.} +proc glEvalCoord1d*(u: TGLdouble){.dynlib: dllname, importc.} +proc glEvalCoord1dv*(u: PGLdouble){.dynlib: dllname, importc.} +proc glEvalCoord1f*(u: TGLfloat){.dynlib: dllname, importc.} +proc glEvalCoord1fv*(u: PGLfloat){.dynlib: dllname, importc.} +proc glEvalCoord2d*(u, v: TGLdouble){.dynlib: dllname, importc.} +proc glEvalCoord2dv*(u: PGLdouble){.dynlib: dllname, importc.} +proc glEvalCoord2f*(u, v: TGLfloat){.dynlib: dllname, importc.} +proc glEvalCoord2fv*(u: PGLfloat){.dynlib: dllname, importc.} +proc glEvalMesh1*(mode: TGLenum, i1, i2: TGLint){.dynlib: dllname, importc.} +proc glEvalMesh2*(mode: TGLenum, i1, i2, j1, j2: TGLint){.dynlib: dllname, importc.} +proc glEvalPoint1*(i: TGLint){.dynlib: dllname, importc.} +proc glEvalPoint2*(i, j: TGLint){.dynlib: dllname, importc.} +proc glFeedbackBuffer*(size: TGLsizei, atype: TGLenum, buffer: PGLfloat){. + dynlib: dllname, importc.} +proc glFinish*(){.dynlib: dllname, importc.} +proc glFlush*(){.dynlib: dllname, importc.} +proc glFogf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc.} +proc glFogfv*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, importc.} +proc glFogi*(pname: TGLenum, param: TGLint){.dynlib: dllname, importc.} +proc glFogiv*(pname: TGLenum, params: PGLint){.dynlib: dllname, importc.} +proc glFrontFace*(mode: TGLenum){.dynlib: dllname, importc.} +proc glFrustum*(left, right, bottom, top, zNear, zFar: TGLdouble){. + dynlib: dllname, importc.} +proc glGenLists*(range: TGLsizei): TGLuint{.dynlib: dllname, importc.} +proc glGenTextures*(n: TGLsizei, textures: PGLuint){.dynlib: dllname, importc.} +proc glGetBooleanv*(pname: TGLenum, params: PGLboolean){.dynlib: dllname, importc.} +proc glGetClipPlane*(plane: TGLenum, equation: PGLdouble){.dynlib: dllname, + importc.} +proc glGetDoublev*(pname: TGLenum, params: PGLdouble){.dynlib: dllname, importc.} +proc glGetError*(): TGLenum{.dynlib: dllname, importc.} +proc glGetFloatv*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, importc.} +proc glGetIntegerv*(pname: TGLenum, params: PGLint){.dynlib: dllname, importc.} +proc glGetLightfv*(light, pname: TGLenum, params: PGLfloat){.dynlib: dllname, + importc.} +proc glGetLightiv*(light, pname: TGLenum, params: PGLint){.dynlib: dllname, + importc.} +proc glGetMapdv*(target, query: TGLenum, v: PGLdouble){.dynlib: dllname, importc.} +proc glGetMapfv*(target, query: TGLenum, v: PGLfloat){.dynlib: dllname, importc.} +proc glGetMapiv*(target, query: TGLenum, v: PGLint){.dynlib: dllname, importc.} +proc glGetMaterialfv*(face, pname: TGLenum, params: PGLfloat){.dynlib: dllname, + importc.} +proc glGetMaterialiv*(face, pname: TGLenum, params: PGLint){.dynlib: dllname, + importc.} +proc glGetPixelMapfv*(map: TGLenum, values: PGLfloat){.dynlib: dllname, importc.} +proc glGetPixelMapuiv*(map: TGLenum, values: PGLuint){.dynlib: dllname, importc.} +proc glGetPixelMapusv*(map: TGLenum, values: PGLushort){.dynlib: dllname, importc.} +proc glGetPointerv*(pname: TGLenum, params: Pointer){.dynlib: dllname, importc.} +proc glGetPolygonStipple*(mask: PGLubyte){.dynlib: dllname, importc.} +proc glGetString*(name: TGLenum): cstring{.dynlib: dllname, importc.} +proc glGetTexEnvfv*(target, pname: TGLenum, params: PGLfloat){.dynlib: dllname, + importc.} +proc glGetTexEnviv*(target, pname: TGLenum, params: PGLint){.dynlib: dllname, + importc.} +proc glGetTexGendv*(coord, pname: TGLenum, params: PGLdouble){.dynlib: dllname, + importc.} +proc glGetTexGenfv*(coord, pname: TGLenum, params: PGLfloat){.dynlib: dllname, + importc.} +proc glGetTexGeniv*(coord, pname: TGLenum, params: PGLint){.dynlib: dllname, + importc.} +proc glGetTexImage*(target: TGLenum, level: TGLint, format: TGLenum, atype: TGLenum, + pixels: Pointer){.dynlib: dllname, importc.} +proc glGetTexLevelParameterfv*(target: TGLenum, level: TGLint, pname: TGLenum, + params: Pointer){.dynlib: dllname, importc.} +proc glGetTexLevelParameteriv*(target: TGLenum, level: TGLint, pname: TGLenum, + params: PGLint){.dynlib: dllname, importc.} +proc glGetTexParameterfv*(target, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc.} +proc glGetTexParameteriv*(target, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glHint*(target, mode: TGLenum){.dynlib: dllname, importc.} +proc glIndexMask*(mask: TGLuint){.dynlib: dllname, importc.} +proc glIndexPointer*(atype: TGLenum, stride: TGLsizei, pointer: Pointer){. + dynlib: dllname, importc.} +proc glIndexd*(c: TGLdouble){.dynlib: dllname, importc.} +proc glIndexdv*(c: PGLdouble){.dynlib: dllname, importc.} +proc glIndexf*(c: TGLfloat){.dynlib: dllname, importc.} +proc glIndexfv*(c: PGLfloat){.dynlib: dllname, importc.} +proc glIndexi*(c: TGLint){.dynlib: dllname, importc.} +proc glIndexiv*(c: PGLint){.dynlib: dllname, importc.} +proc glIndexs*(c: TGLshort){.dynlib: dllname, importc.} +proc glIndexsv*(c: PGLshort){.dynlib: dllname, importc.} +proc glIndexub*(c: TGLubyte){.dynlib: dllname, importc.} +proc glIndexubv*(c: PGLubyte){.dynlib: dllname, importc.} +proc glInitNames*(){.dynlib: dllname, importc.} +proc glInterleavedArrays*(format: TGLenum, stride: TGLsizei, pointer: Pointer){. + dynlib: dllname, importc.} +proc glIsEnabled*(cap: TGLenum): TGLboolean{.dynlib: dllname, importc.} +proc glIsList*(list: TGLuint): TGLboolean{.dynlib: dllname, importc.} +proc glIsTexture*(texture: TGLuint): TGLboolean{.dynlib: dllname, importc.} +proc glLightModelf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc.} +proc glLightModelfv*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, importc.} +proc glLightModeli*(pname: TGLenum, param: TGLint){.dynlib: dllname, importc.} +proc glLightModeliv*(pname: TGLenum, params: PGLint){.dynlib: dllname, importc.} +proc glLightf*(light, pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc.} +proc glLightfv*(light, pname: TGLenum, params: PGLfloat){.dynlib: dllname, + importc.} +proc glLighti*(light, pname: TGLenum, param: TGLint){.dynlib: dllname, importc.} +proc glLightiv*(light, pname: TGLenum, params: PGLint){.dynlib: dllname, importc.} +proc glLineStipple*(factor: TGLint, pattern: TGLushort){.dynlib: dllname, importc.} +proc glLineWidth*(width: TGLfloat){.dynlib: dllname, importc.} +proc glListBase*(base: TGLuint){.dynlib: dllname, importc.} +proc glLoadIdentity*(){.dynlib: dllname, importc.} +proc glLoadMatrixd*(m: PGLdouble){.dynlib: dllname, importc.} +proc glLoadMatrixf*(m: PGLfloat){.dynlib: dllname, importc.} +proc glLoadName*(name: TGLuint){.dynlib: dllname, importc.} +proc glLogicOp*(opcode: TGLenum){.dynlib: dllname, importc.} +proc glMap1d*(target: TGLenum, u1, u2: TGLdouble, stride, order: TGLint, + points: PGLdouble){.dynlib: dllname, importc.} +proc glMap1f*(target: TGLenum, u1, u2: TGLfloat, stride, order: TGLint, + points: PGLfloat){.dynlib: dllname, importc.} +proc glMap2d*(target: TGLenum, u1, u2: TGLdouble, ustride, uorder: TGLint, + v1, v2: TGLdouble, vstride, vorder: TGLint, points: PGLdouble){. + dynlib: dllname, importc.} +proc glMap2f*(target: TGLenum, u1, u2: TGLfloat, ustride, uorder: TGLint, + v1, v2: TGLfloat, vstride, vorder: TGLint, points: PGLfloat){. + dynlib: dllname, importc.} +proc glMapGrid1d*(un: TGLint, u1, u2: TGLdouble){.dynlib: dllname, importc.} +proc glMapGrid1f*(un: TGLint, u1, u2: TGLfloat){.dynlib: dllname, importc.} +proc glMapGrid2d*(un: TGLint, u1, u2: TGLdouble, vn: TGLint, v1, v2: TGLdouble){. + dynlib: dllname, importc.} +proc glMapGrid2f*(un: TGLint, u1, u2: TGLfloat, vn: TGLint, v1, v2: TGLfloat){. + dynlib: dllname, importc.} +proc glMaterialf*(face, pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc.} +proc glMaterialfv*(face, pname: TGLenum, params: PGLfloat){.dynlib: dllname, + importc.} +proc glMateriali*(face, pname: TGLenum, param: TGLint){.dynlib: dllname, importc.} +proc glMaterialiv*(face, pname: TGLenum, params: PGLint){.dynlib: dllname, + importc.} +proc glMatrixMode*(mode: TGLenum){.dynlib: dllname, importc.} +proc glMultMatrixd*(m: PGLdouble){.dynlib: dllname, importc.} +proc glMultMatrixf*(m: PGLfloat){.dynlib: dllname, importc.} +proc glNewList*(list: TGLuint, mode: TGLenum){.dynlib: dllname, importc.} +proc glNormal3b*(nx, ny, nz: TGlbyte){.dynlib: dllname, importc.} +proc glNormal3bv*(v: PGLbyte){.dynlib: dllname, importc.} +proc glNormal3d*(nx, ny, nz: TGLdouble){.dynlib: dllname, importc.} +proc glNormal3dv*(v: PGLdouble){.dynlib: dllname, importc.} +proc glNormal3f*(nx, ny, nz: TGLfloat){.dynlib: dllname, importc.} +proc glNormal3fv*(v: PGLfloat){.dynlib: dllname, importc.} +proc glNormal3i*(nx, ny, nz: TGLint){.dynlib: dllname, importc.} +proc glNormal3iv*(v: PGLint){.dynlib: dllname, importc.} +proc glNormal3s*(nx, ny, nz: TGLshort){.dynlib: dllname, importc.} +proc glNormal3sv*(v: PGLshort){.dynlib: dllname, importc.} +proc glNormalPointer*(atype: TGLenum, stride: TGLsizei, pointer: Pointer){. + dynlib: dllname, importc.} +proc glOrtho*(left, right, bottom, top, zNear, zFar: TGLdouble){.dynlib: dllname, + importc.} +proc glPassThrough*(token: TGLfloat){.dynlib: dllname, importc.} +proc glPixelMapfv*(map: TGLenum, mapsize: TGLsizei, values: PGLfloat){. + dynlib: dllname, importc.} +proc glPixelMapuiv*(map: TGLenum, mapsize: TGLsizei, values: PGLuint){. + dynlib: dllname, importc.} +proc glPixelMapusv*(map: TGLenum, mapsize: TGLsizei, values: PGLushort){. + dynlib: dllname, importc.} +proc glPixelStoref*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc.} +proc glPixelStorei*(pname: TGLenum, param: TGLint){.dynlib: dllname, importc.} +proc glPixelTransferf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc.} +proc glPixelTransferi*(pname: TGLenum, param: TGLint){.dynlib: dllname, importc.} +proc glPixelZoom*(xfactor, yfactor: TGLfloat){.dynlib: dllname, importc.} +proc glPointSize*(size: TGLfloat){.dynlib: dllname, importc.} +proc glPolygonMode*(face, mode: TGLenum){.dynlib: dllname, importc.} +proc glPolygonOffset*(factor, units: TGLfloat){.dynlib: dllname, importc.} +proc glPolygonStipple*(mask: PGLubyte){.dynlib: dllname, importc.} +proc glPopAttrib*(){.dynlib: dllname, importc.} +proc glPopClientAttrib*(){.dynlib: dllname, importc.} +proc glPopMatrix*(){.dynlib: dllname, importc.} +proc glPopName*(){.dynlib: dllname, importc.} +proc glPrioritizeTextures*(n: TGLsizei, textures: PGLuint, priorities: PGLclampf){. + dynlib: dllname, importc.} +proc glPushAttrib*(mask: TGLbitfield){.dynlib: dllname, importc.} +proc glPushClientAttrib*(mask: TGLbitfield){.dynlib: dllname, importc.} +proc glPushMatrix*(){.dynlib: dllname, importc.} +proc glPushName*(name: TGLuint){.dynlib: dllname, importc.} +proc glRasterPos2d*(x, y: TGLdouble){.dynlib: dllname, importc.} +proc glRasterPos2dv*(v: PGLdouble){.dynlib: dllname, importc.} +proc glRasterPos2f*(x, y: TGLfloat){.dynlib: dllname, importc.} +proc glRasterPos2fv*(v: PGLfloat){.dynlib: dllname, importc.} +proc glRasterPos2i*(x, y: TGLint){.dynlib: dllname, importc.} +proc glRasterPos2iv*(v: PGLint){.dynlib: dllname, importc.} +proc glRasterPos2s*(x, y: TGLshort){.dynlib: dllname, importc.} +proc glRasterPos2sv*(v: PGLshort){.dynlib: dllname, importc.} +proc glRasterPos3d*(x, y, z: TGLdouble){.dynlib: dllname, importc.} +proc glRasterPos3dv*(v: PGLdouble){.dynlib: dllname, importc.} +proc glRasterPos3f*(x, y, z: TGLfloat){.dynlib: dllname, importc.} +proc glRasterPos3fv*(v: PGLfloat){.dynlib: dllname, importc.} +proc glRasterPos3i*(x, y, z: TGLint){.dynlib: dllname, importc.} +proc glRasterPos3iv*(v: PGLint){.dynlib: dllname, importc.} +proc glRasterPos3s*(x, y, z: TGLshort){.dynlib: dllname, importc.} +proc glRasterPos3sv*(v: PGLshort){.dynlib: dllname, importc.} +proc glRasterPos4d*(x, y, z, w: TGLdouble){.dynlib: dllname, importc.} +proc glRasterPos4dv*(v: PGLdouble){.dynlib: dllname, importc.} +proc glRasterPos4f*(x, y, z, w: TGLfloat){.dynlib: dllname, importc.} +proc glRasterPos4fv*(v: PGLfloat){.dynlib: dllname, importc.} +proc glRasterPos4i*(x, y, z, w: TGLint){.dynlib: dllname, importc.} +proc glRasterPos4iv*(v: PGLint){.dynlib: dllname, importc.} +proc glRasterPos4s*(x, y, z, w: TGLshort){.dynlib: dllname, importc.} +proc glRasterPos4sv*(v: PGLshort){.dynlib: dllname, importc.} +proc glReadBuffer*(mode: TGLenum){.dynlib: dllname, importc.} +proc glReadPixels*(x, y: TGLint, width, height: TGLsizei, format, atype: TGLenum, + pixels: Pointer){.dynlib: dllname, importc.} +proc glRectd*(x1, y1, x2, y2: TGLdouble){.dynlib: dllname, importc.} +proc glRectdv*(v1: PGLdouble, v2: PGLdouble){.dynlib: dllname, importc.} +proc glRectf*(x1, y1, x2, y2: TGLfloat){.dynlib: dllname, importc.} +proc glRectfv*(v1: PGLfloat, v2: PGLfloat){.dynlib: dllname, importc.} +proc glRecti*(x1, y1, x2, y2: TGLint){.dynlib: dllname, importc.} +proc glRectiv*(v1: PGLint, v2: PGLint){.dynlib: dllname, importc.} +proc glRects*(x1, y1, x2, y2: TGLshort){.dynlib: dllname, importc.} +proc glRectsv*(v1: PGLshort, v2: PGLshort){.dynlib: dllname, importc.} +proc glRenderMode*(mode: TGLint): TGLint{.dynlib: dllname, importc.} +proc glRotated*(angle, x, y, z: TGLdouble){.dynlib: dllname, importc.} +proc glRotatef*(angle, x, y, z: TGLfloat){.dynlib: dllname, importc.} +proc glScaled*(x, y, z: TGLdouble){.dynlib: dllname, importc.} +proc glScalef*(x, y, z: TGLfloat){.dynlib: dllname, importc.} +proc glScissor*(x, y: TGLint, width, height: TGLsizei){.dynlib: dllname, importc.} +proc glSelectBuffer*(size: TGLsizei, buffer: PGLuint){.dynlib: dllname, importc.} +proc glShadeModel*(mode: TGLenum){.dynlib: dllname, importc.} +proc glStencilFunc*(func: TGLenum, theref: TGLint, mask: TGLuint){.dynlib: dllname, + importc.} +proc glStencilMask*(mask: TGLuint){.dynlib: dllname, importc.} +proc glStencilOp*(fail, zfail, zpass: TGLenum){.dynlib: dllname, importc.} +proc glTexCoord1d*(s: TGLdouble){.dynlib: dllname, importc.} +proc glTexCoord1dv*(v: PGLdouble){.dynlib: dllname, importc.} +proc glTexCoord1f*(s: TGLfloat){.dynlib: dllname, importc.} +proc glTexCoord1fv*(v: PGLfloat){.dynlib: dllname, importc.} +proc glTexCoord1i*(s: TGLint){.dynlib: dllname, importc.} +proc glTexCoord1iv*(v: PGLint){.dynlib: dllname, importc.} +proc glTexCoord1s*(s: TGLshort){.dynlib: dllname, importc.} +proc glTexCoord1sv*(v: PGLshort){.dynlib: dllname, importc.} +proc glTexCoord2d*(s, t: TGLdouble){.dynlib: dllname, importc.} +proc glTexCoord2dv*(v: PGLdouble){.dynlib: dllname, importc.} +proc glTexCoord2f*(s, t: TGLfloat){.dynlib: dllname, importc.} +proc glTexCoord2fv*(v: PGLfloat){.dynlib: dllname, importc.} +proc glTexCoord2i*(s, t: TGLint){.dynlib: dllname, importc.} +proc glTexCoord2iv*(v: PGLint){.dynlib: dllname, importc.} +proc glTexCoord2s*(s, t: TGLshort){.dynlib: dllname, importc.} +proc glTexCoord2sv*(v: PGLshort){.dynlib: dllname, importc.} +proc glTexCoord3d*(s, t, r: TGLdouble){.dynlib: dllname, importc.} +proc glTexCoord3dv*(v: PGLdouble){.dynlib: dllname, importc.} +proc glTexCoord3f*(s, t, r: TGLfloat){.dynlib: dllname, importc.} +proc glTexCoord3fv*(v: PGLfloat){.dynlib: dllname, importc.} +proc glTexCoord3i*(s, t, r: TGLint){.dynlib: dllname, importc.} +proc glTexCoord3iv*(v: PGLint){.dynlib: dllname, importc.} +proc glTexCoord3s*(s, t, r: TGLshort){.dynlib: dllname, importc.} +proc glTexCoord3sv*(v: PGLshort){.dynlib: dllname, importc.} +proc glTexCoord4d*(s, t, r, q: TGLdouble){.dynlib: dllname, importc.} +proc glTexCoord4dv*(v: PGLdouble){.dynlib: dllname, importc.} +proc glTexCoord4f*(s, t, r, q: TGLfloat){.dynlib: dllname, importc.} +proc glTexCoord4fv*(v: PGLfloat){.dynlib: dllname, importc.} +proc glTexCoord4i*(s, t, r, q: TGLint){.dynlib: dllname, importc.} +proc glTexCoord4iv*(v: PGLint){.dynlib: dllname, importc.} +proc glTexCoord4s*(s, t, r, q: TGLshort){.dynlib: dllname, importc.} +proc glTexCoord4sv*(v: PGLshort){.dynlib: dllname, importc.} +proc glTexCoordPointer*(size: TGLint, atype: TGLenum, stride: TGLsizei, + pointer: Pointer){.dynlib: dllname, importc.} +proc glTexEnvf*(target: TGLenum, pname: TGLenum, param: TGLfloat){.dynlib: dllname, + importc.} +proc glTexEnvfv*(target: TGLenum, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc.} +proc glTexEnvi*(target: TGLenum, pname: TGLenum, param: TGLint){.dynlib: dllname, + importc.} +proc glTexEnviv*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glTexGend*(coord: TGLenum, pname: TGLenum, param: TGLdouble){.dynlib: dllname, + importc.} +proc glTexGendv*(coord: TGLenum, pname: TGLenum, params: PGLdouble){. + dynlib: dllname, importc.} +proc glTexGenf*(coord: TGLenum, pname: TGLenum, param: TGLfloat){.dynlib: dllname, + importc.} +proc glTexGenfv*(coord: TGLenum, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc.} +proc glTexGeni*(coord: TGLenum, pname: TGLenum, param: TGLint){.dynlib: dllname, + importc.} +proc glTexGeniv*(coord: TGLenum, pname: TGLenum, params: PGLint){.dynlib: dllname, + importc.} +proc glTexImage1D*(target: TGLenum, level, internalformat: TGLint, width: TGLsizei, + border: TGLint, format, atype: TGLenum, pixels: Pointer){. + dynlib: dllname, importc.} +proc glTexImage2D*(target: TGLenum, level, internalformat: TGLint, + width, height: TGLsizei, border: TGLint, format, atype: TGLenum, + pixels: Pointer){.dynlib: dllname, importc.} +proc glTexParameterf*(target: TGLenum, pname: TGLenum, param: TGLfloat){. + dynlib: dllname, importc.} +proc glTexParameterfv*(target: TGLenum, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc.} +proc glTexParameteri*(target: TGLenum, pname: TGLenum, param: TGLint){. + dynlib: dllname, importc.} +proc glTexParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glTexSubImage1D*(target: TGLenum, level, xoffset: TGLint, width: TGLsizei, + format, atype: TGLenum, pixels: Pointer){.dynlib: dllname, + importc.} +proc glTexSubImage2D*(target: TGLenum, level, xoffset, yoffset: TGLint, + width, height: TGLsizei, format, atype: TGLenum, + pixels: Pointer){.dynlib: dllname, importc.} +proc glTranslated*(x, y, z: TGLdouble){.dynlib: dllname, importc.} +proc glTranslatef*(x, y, z: TGLfloat){.dynlib: dllname, importc.} +proc glVertex2d*(x, y: TGLdouble){.dynlib: dllname, importc.} +proc glVertex2dv*(v: PGLdouble){.dynlib: dllname, importc.} +proc glVertex2f*(x, y: TGLfloat){.dynlib: dllname, importc.} +proc glVertex2fv*(v: PGLfloat){.dynlib: dllname, importc.} +proc glVertex2i*(x, y: TGLint){.dynlib: dllname, importc.} +proc glVertex2iv*(v: PGLint){.dynlib: dllname, importc.} +proc glVertex2s*(x, y: TGLshort){.dynlib: dllname, importc.} +proc glVertex2sv*(v: PGLshort){.dynlib: dllname, importc.} +proc glVertex3d*(x, y, z: TGLdouble){.dynlib: dllname, importc.} +proc glVertex3dv*(v: PGLdouble){.dynlib: dllname, importc.} +proc glVertex3f*(x, y, z: TGLfloat){.dynlib: dllname, importc.} +proc glVertex3fv*(v: PGLfloat){.dynlib: dllname, importc.} +proc glVertex3i*(x, y, z: TGLint){.dynlib: dllname, importc.} +proc glVertex3iv*(v: PGLint){.dynlib: dllname, importc.} +proc glVertex3s*(x, y, z: TGLshort){.dynlib: dllname, importc.} +proc glVertex3sv*(v: PGLshort){.dynlib: dllname, importc.} +proc glVertex4d*(x, y, z, w: TGLdouble){.dynlib: dllname, importc.} +proc glVertex4dv*(v: PGLdouble){.dynlib: dllname, importc.} +proc glVertex4f*(x, y, z, w: TGLfloat){.dynlib: dllname, importc.} +proc glVertex4fv*(v: PGLfloat){.dynlib: dllname, importc.} +proc glVertex4i*(x, y, z, w: TGLint){.dynlib: dllname, importc.} +proc glVertex4iv*(v: PGLint){.dynlib: dllname, importc.} +proc glVertex4s*(x, y, z, w: TGLshort){.dynlib: dllname, importc.} +proc glVertex4sv*(v: PGLshort){.dynlib: dllname, importc.} +proc glVertexPointer*(size: TGLint, atype: TGLenum, stride: TGLsizei, + pointer: Pointer){.dynlib: dllname, importc.} +proc glViewport*(x, y: TGLint, width, height: TGLsizei){.dynlib: dllname, importc.} +type + PFNGLARRAYELEMENTEXTPROC* = proc (i: TGLint) + PFNGLDRAWARRAYSEXTPROC* = proc (mode: TGLenum, first: TGLint, count: TGLsizei) + PFNGLVERTEXPOINTEREXTPROC* = proc (size: TGLint, atype: TGLenum, + stride, count: TGLsizei, pointer: Pointer) + PFNGLNORMALPOINTEREXTPROC* = proc (atype: TGLenum, stride, count: TGLsizei, + pointer: Pointer) + PFNGLCOLORPOINTEREXTPROC* = proc (size: TGLint, atype: TGLenum, + stride, count: TGLsizei, pointer: Pointer) + PFNGLINDEXPOINTEREXTPROC* = proc (atype: TGLenum, stride, count: TGLsizei, + pointer: Pointer) + PFNGLTEXCOORDPOINTEREXTPROC* = proc (size: TGLint, atype: TGLenum, + stride, count: TGLsizei, pointer: Pointer) + PFNGLEDGEFLAGPOINTEREXTPROC* = proc (stride, count: TGLsizei, + pointer: PGLboolean) + PFNGLGETPOINTERVEXTPROC* = proc (pname: TGLenum, params: Pointer) + PFNGLARRAYELEMENTARRAYEXTPROC* = proc (mode: TGLenum, count: TGLsizei, + pi: Pointer) # WIN_swap_hint + PFNGLADDSWAPHINTRECTWINPROC* = proc (x, y: TGLint, width, height: TGLsizei) + PFNGLCOLORTABLEEXTPROC* = proc (target, internalFormat: TGLenum, + width: TGLsizei, format, atype: TGLenum, + data: Pointer) + PFNGLCOLORSUBTABLEEXTPROC* = proc (target: TGLenum, start, count: TGLsizei, + format, atype: TGLenum, data: Pointer) + PFNGLGETCOLORTABLEEXTPROC* = proc (target, format, atype: TGLenum, + data: Pointer) + PFNGLGETCOLORTABLEPARAMETERIVEXTPROC* = proc (target, pname: TGLenum, + params: PGLint) + PFNGLGETCOLORTABLEPARAMETERFVEXTPROC* = proc (target, pname: TGLenum, + params: PGLfloat) + +{.pop.} + +# implementation diff --git a/lib/base/opengl/gl.pp b/lib/base/opengl/gl.pp new file mode 100644 index 000000000..f6e0ddc39 --- /dev/null +++ b/lib/base/opengl/gl.pp @@ -0,0 +1,1548 @@ +{ + + Adaption of the delphi3d.net OpenGL units to FreePascal + Sebastian Guenther (sg@freepascal.org) in 2002 + These units are free to use +} + +(*++ BUILD Version: 0004 // Increment this if a change has global effects + +Copyright (c) 1985-96, Microsoft Corporation + +Module Name: + + gl.h + +Abstract: + + Procedure declarations, constant definitions and macros for the OpenGL + component. + +--*) + +{* +** Copyright 1996 Silicon Graphics, Inc. +** All Rights Reserved. +** +** This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; +** the contents of this file may not be disclosed to third parties, copied or +** duplicated in any form, in whole or in part, without the prior written +** permission of Silicon Graphics, Inc. +** +** RESTRICTED RIGHTS LEGEND: +** Use, duplication or disclosure by the Government is subject to restrictions +** as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data +** and Computer Software clause at DFARS 252.227-7013, and/or in similar or +** successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished - +** rights reserved under the Copyright Laws of the United States. +*} + +{******************************************************************************} +{ Converted to Delphi by Tom Nuydens (tom@delphi3d.net) } +{ For the latest updates, visit Delphi3D: http://www.delphi3d.net } +{******************************************************************************} +(* +{$MODE Delphi} +{$MACRO ON} +{$IFDEF Windows} + {$DEFINE extdecl := stdcall} +{$ELSE} + {$DEFINE extdecl := cdecl} + {$IFDEF MorphOS} + {$INLINE ON} + {$DEFINE GL_UNIT} + {$ELSE} + {$LINKLIB c} + {$ENDIF} +{$ENDIF} *) + +unit GL; + +interface + +const + dllname = 'opengl32.dll'; + dylibname = '/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib'; + posixname = 'libGL.so.1'; + +type + GLenum = Cardinal; PGLenum = ^GLenum; + GLboolean = Byte; PGLboolean = ^GLboolean; + GLbitfield = Cardinal; PGLbitfield = ^GLbitfield; + GLbyte = ShortInt; PGLbyte = ^GLbyte; + GLshort = SmallInt; PGLshort = ^GLshort; + GLint = Integer; PGLint = ^GLint; + GLsizei = Integer; PGLsizei = ^GLsizei; + GLubyte = Byte; PGLubyte = ^GLubyte; + GLushort = Word; PGLushort = ^GLushort; + GLuint = Cardinal; PGLuint = ^GLuint; + GLfloat = Single; PGLfloat = ^GLfloat; + GLclampf = Single; PGLclampf = ^GLclampf; + GLdouble = Double; PGLdouble = ^GLdouble; + GLclampd = Double; PGLclampd = ^GLclampd; +{ GLvoid = void; } PGLvoid = Pointer; + PPGLvoid = ^PGLvoid; + + TGLenum = GLenum; + TGLboolean = GLboolean; + TGLbitfield = GLbitfield; + TGLbyte = GLbyte; + TGLshort = GLshort; + TGLint = GLint; + TGLsizei = GLsizei; + TGLubyte = GLubyte; + TGLushort = GLushort; + TGLuint = GLuint; + TGLfloat = GLfloat; + TGLclampf = GLclampf; + TGLdouble = GLdouble; + TGLclampd = GLclampd; + +{******************************************************************************} + +const + // Version + GL_VERSION_1_1 = 1; + + // AccumOp + GL_ACCUM = $0100; + GL_LOAD = $0101; + GL_RETURN = $0102; + GL_MULT = $0103; + GL_ADD = $0104; + + // AlphaFunction + GL_NEVER = $0200; + GL_LESS = $0201; + GL_EQUAL = $0202; + GL_LEQUAL = $0203; + GL_GREATER = $0204; + GL_NOTEQUAL = $0205; + GL_GEQUAL = $0206; + GL_ALWAYS = $0207; + + // AttribMask + GL_CURRENT_BIT = $00000001; + GL_POINT_BIT = $00000002; + GL_LINE_BIT = $00000004; + GL_POLYGON_BIT = $00000008; + GL_POLYGON_STIPPLE_BIT = $00000010; + GL_PIXEL_MODE_BIT = $00000020; + GL_LIGHTING_BIT = $00000040; + GL_FOG_BIT = $00000080; + GL_DEPTH_BUFFER_BIT = $00000100; + GL_ACCUM_BUFFER_BIT = $00000200; + GL_STENCIL_BUFFER_BIT = $00000400; + GL_VIEWPORT_BIT = $00000800; + GL_TRANSFORM_BIT = $00001000; + GL_ENABLE_BIT = $00002000; + GL_COLOR_BUFFER_BIT = $00004000; + GL_HINT_BIT = $00008000; + GL_EVAL_BIT = $00010000; + GL_LIST_BIT = $00020000; + GL_TEXTURE_BIT = $00040000; + GL_SCISSOR_BIT = $00080000; + GL_ALL_ATTRIB_BITS = $000FFFFF; + + // BeginMode + GL_POINTS = $0000; + GL_LINES = $0001; + GL_LINE_LOOP = $0002; + GL_LINE_STRIP = $0003; + GL_TRIANGLES = $0004; + GL_TRIANGLE_STRIP = $0005; + GL_TRIANGLE_FAN = $0006; + GL_QUADS = $0007; + GL_QUAD_STRIP = $0008; + GL_POLYGON = $0009; + + // BlendingFactorDest + GL_ZERO = 0; + GL_ONE = 1; + GL_SRC_COLOR = $0300; + GL_ONE_MINUS_SRC_COLOR = $0301; + GL_SRC_ALPHA = $0302; + GL_ONE_MINUS_SRC_ALPHA = $0303; + GL_DST_ALPHA = $0304; + GL_ONE_MINUS_DST_ALPHA = $0305; + + // BlendingFactorSrc + // GL_ZERO + // GL_ONE + GL_DST_COLOR = $0306; + GL_ONE_MINUS_DST_COLOR = $0307; + GL_SRC_ALPHA_SATURATE = $0308; + // GL_SRC_ALPHA + // GL_ONE_MINUS_SRC_ALPHA + // GL_DST_ALPHA + // GL_ONE_MINUS_DST_ALPHA + + // Boolean + GL_TRUE = 1; + GL_FALSE = 0; + + // ClearBufferMask + // GL_COLOR_BUFFER_BIT + // GL_ACCUM_BUFFER_BIT + // GL_STENCIL_BUFFER_BIT + // GL_DEPTH_BUFFER_BIT + + // ClientArrayType + // GL_VERTEX_ARRAY + // GL_NORMAL_ARRAY + // GL_COLOR_ARRAY + // GL_INDEX_ARRAY + // GL_TEXTURE_COORD_ARRAY + // GL_EDGE_FLAG_ARRAY + + // ClipPlaneName + GL_CLIP_PLANE0 = $3000; + GL_CLIP_PLANE1 = $3001; + GL_CLIP_PLANE2 = $3002; + GL_CLIP_PLANE3 = $3003; + GL_CLIP_PLANE4 = $3004; + GL_CLIP_PLANE5 = $3005; + + // ColorMaterialFace + // GL_FRONT + // GL_BACK + // GL_FRONT_AND_BACK + + // ColorMaterialParameter + // GL_AMBIENT + // GL_DIFFUSE + // GL_SPECULAR + // GL_EMISSION + // GL_AMBIENT_AND_DIFFUSE + + // ColorPointerType + // GL_BYTE + // GL_UNSIGNED_BYTE + // GL_SHORT + // GL_UNSIGNED_SHORT + // GL_INT + // GL_UNSIGNED_INT + // GL_FLOAT + // GL_DOUBLE + + // CullFaceMode + // GL_FRONT + // GL_BACK + // GL_FRONT_AND_BACK + + // DataType + GL_BYTE = $1400; + GL_UNSIGNED_BYTE = $1401; + GL_SHORT = $1402; + GL_UNSIGNED_SHORT = $1403; + GL_INT = $1404; + GL_UNSIGNED_INT = $1405; + GL_FLOAT = $1406; + GL_2_BYTES = $1407; + GL_3_BYTES = $1408; + GL_4_BYTES = $1409; + GL_DOUBLE = $140A; + + // DepthFunction + // GL_NEVER + // GL_LESS + // GL_EQUAL + // GL_LEQUAL + // GL_GREATER + // GL_NOTEQUAL + // GL_GEQUAL + // GL_ALWAYS + + // DrawBufferMode + GL_NONE = 0; + GL_FRONT_LEFT = $0400; + GL_FRONT_RIGHT = $0401; + GL_BACK_LEFT = $0402; + GL_BACK_RIGHT = $0403; + GL_FRONT = $0404; + GL_BACK = $0405; + GL_LEFT = $0406; + GL_RIGHT = $0407; + GL_FRONT_AND_BACK = $0408; + GL_AUX0 = $0409; + GL_AUX1 = $040A; + GL_AUX2 = $040B; + GL_AUX3 = $040C; + + // Enable + // GL_FOG + // GL_LIGHTING + // GL_TEXTURE_1D + // GL_TEXTURE_2D + // GL_LINE_STIPPLE + // GL_POLYGON_STIPPLE + // GL_CULL_FACE + // GL_ALPHA_TEST + // GL_BLEND + // GL_INDEX_LOGIC_OP + // GL_COLOR_LOGIC_OP + // GL_DITHER + // GL_STENCIL_TEST + // GL_DEPTH_TEST + // GL_CLIP_PLANE0 + // GL_CLIP_PLANE1 + // GL_CLIP_PLANE2 + // GL_CLIP_PLANE3 + // GL_CLIP_PLANE4 + // GL_CLIP_PLANE5 + // GL_LIGHT0 + // GL_LIGHT1 + // GL_LIGHT2 + // GL_LIGHT3 + // GL_LIGHT4 + // GL_LIGHT5 + // GL_LIGHT6 + // GL_LIGHT7 + // GL_TEXTURE_GEN_S + // GL_TEXTURE_GEN_T + // GL_TEXTURE_GEN_R + // GL_TEXTURE_GEN_Q + // GL_MAP1_VERTEX_3 + // GL_MAP1_VERTEX_4 + // GL_MAP1_COLOR_4 + // GL_MAP1_INDEX + // GL_MAP1_NORMAL + // GL_MAP1_TEXTURE_COORD_1 + // GL_MAP1_TEXTURE_COORD_2 + // GL_MAP1_TEXTURE_COORD_3 + // GL_MAP1_TEXTURE_COORD_4 + // GL_MAP2_VERTEX_3 + // GL_MAP2_VERTEX_4 + // GL_MAP2_COLOR_4 + // GL_MAP2_INDEX + // GL_MAP2_NORMAL + // GL_MAP2_TEXTURE_COORD_1 + // GL_MAP2_TEXTURE_COORD_2 + // GL_MAP2_TEXTURE_COORD_3 + // GL_MAP2_TEXTURE_COORD_4 + // GL_POINT_SMOOTH + // GL_LINE_SMOOTH + // GL_POLYGON_SMOOTH + // GL_SCISSOR_TEST + // GL_COLOR_MATERIAL + // GL_NORMALIZE + // GL_AUTO_NORMAL + // GL_VERTEX_ARRAY + // GL_NORMAL_ARRAY + // GL_COLOR_ARRAY + // GL_INDEX_ARRAY + // GL_TEXTURE_COORD_ARRAY + // GL_EDGE_FLAG_ARRAY + // GL_POLYGON_OFFSET_POINT + // GL_POLYGON_OFFSET_LINE + // GL_POLYGON_OFFSET_FILL + + // ErrorCode + GL_NO_ERROR = 0; + GL_INVALID_ENUM = $0500; + GL_INVALID_VALUE = $0501; + GL_INVALID_OPERATION = $0502; + GL_STACK_OVERFLOW = $0503; + GL_STACK_UNDERFLOW = $0504; + GL_OUT_OF_MEMORY = $0505; + + // FeedBackMode + GL_2D = $0600; + GL_3D = $0601; + GL_3D_COLOR = $0602; + GL_3D_COLOR_TEXTURE = $0603; + GL_4D_COLOR_TEXTURE = $0604; + + // FeedBackToken + GL_PASS_THROUGH_TOKEN = $0700; + GL_POINT_TOKEN = $0701; + GL_LINE_TOKEN = $0702; + GL_POLYGON_TOKEN = $0703; + GL_BITMAP_TOKEN = $0704; + GL_DRAW_PIXEL_TOKEN = $0705; + GL_COPY_PIXEL_TOKEN = $0706; + GL_LINE_RESET_TOKEN = $0707; + + // FogMode + // GL_LINEAR + GL_EXP = $0800; + GL_EXP2 = $0801; + + // FogParameter + // GL_FOG_COLOR + // GL_FOG_DENSITY + // GL_FOG_END + // GL_FOG_INDEX + // GL_FOG_MODE + // GL_FOG_START + + // FrontFaceDirection + GL_CW = $0900; + GL_CCW = $0901; + + // GetMapTarget + GL_COEFF = $0A00; + GL_ORDER = $0A01; + GL_DOMAIN = $0A02; + + // GetPixelMap + // GL_PIXEL_MAP_I_TO_I + // GL_PIXEL_MAP_S_TO_S + // GL_PIXEL_MAP_I_TO_R + // GL_PIXEL_MAP_I_TO_G + // GL_PIXEL_MAP_I_TO_B + // GL_PIXEL_MAP_I_TO_A + // GL_PIXEL_MAP_R_TO_R + // GL_PIXEL_MAP_G_TO_G + // GL_PIXEL_MAP_B_TO_B + // GL_PIXEL_MAP_A_TO_A + + // GetPointerTarget + // GL_VERTEX_ARRAY_POINTER + // GL_NORMAL_ARRAY_POINTER + // GL_COLOR_ARRAY_POINTER + // GL_INDEX_ARRAY_POINTER + // GL_TEXTURE_COORD_ARRAY_POINTER + // GL_EDGE_FLAG_ARRAY_POINTER + + // GetTarget + GL_CURRENT_COLOR = $0B00; + GL_CURRENT_INDEX = $0B01; + GL_CURRENT_NORMAL = $0B02; + GL_CURRENT_TEXTURE_COORDS = $0B03; + GL_CURRENT_RASTER_COLOR = $0B04; + GL_CURRENT_RASTER_INDEX = $0B05; + GL_CURRENT_RASTER_TEXTURE_COORDS = $0B06; + GL_CURRENT_RASTER_POSITION = $0B07; + GL_CURRENT_RASTER_POSITION_VALID = $0B08; + GL_CURRENT_RASTER_DISTANCE = $0B09; + GL_POINT_SMOOTH = $0B10; + GL_POINT_SIZE = $0B11; + GL_POINT_SIZE_RANGE = $0B12; + GL_POINT_SIZE_GRANULARITY = $0B13; + GL_LINE_SMOOTH = $0B20; + GL_LINE_WIDTH = $0B21; + GL_LINE_WIDTH_RANGE = $0B22; + GL_LINE_WIDTH_GRANULARITY = $0B23; + GL_LINE_STIPPLE = $0B24; + GL_LINE_STIPPLE_PATTERN = $0B25; + GL_LINE_STIPPLE_REPEAT = $0B26; + GL_LIST_MODE = $0B30; + GL_MAX_LIST_NESTING = $0B31; + GL_LIST_BASE = $0B32; + GL_LIST_INDEX = $0B33; + GL_POLYGON_MODE = $0B40; + GL_POLYGON_SMOOTH = $0B41; + GL_POLYGON_STIPPLE = $0B42; + GL_EDGE_FLAG = $0B43; + GL_CULL_FACE = $0B44; + GL_CULL_FACE_MODE = $0B45; + GL_FRONT_FACE = $0B46; + GL_LIGHTING = $0B50; + GL_LIGHT_MODEL_LOCAL_VIEWER = $0B51; + GL_LIGHT_MODEL_TWO_SIDE = $0B52; + GL_LIGHT_MODEL_AMBIENT = $0B53; + GL_SHADE_MODEL = $0B54; + GL_COLOR_MATERIAL_FACE = $0B55; + GL_COLOR_MATERIAL_PARAMETER = $0B56; + GL_COLOR_MATERIAL = $0B57; + GL_FOG = $0B60; + GL_FOG_INDEX = $0B61; + GL_FOG_DENSITY = $0B62; + GL_FOG_START = $0B63; + GL_FOG_END = $0B64; + GL_FOG_MODE = $0B65; + GL_FOG_COLOR = $0B66; + GL_DEPTH_RANGE = $0B70; + GL_DEPTH_TEST = $0B71; + GL_DEPTH_WRITEMASK = $0B72; + GL_DEPTH_CLEAR_VALUE = $0B73; + GL_DEPTH_FUNC = $0B74; + GL_ACCUM_CLEAR_VALUE = $0B80; + GL_STENCIL_TEST = $0B90; + GL_STENCIL_CLEAR_VALUE = $0B91; + GL_STENCIL_FUNC = $0B92; + GL_STENCIL_VALUE_MASK = $0B93; + GL_STENCIL_FAIL = $0B94; + GL_STENCIL_PASS_DEPTH_FAIL = $0B95; + GL_STENCIL_PASS_DEPTH_PASS = $0B96; + GL_STENCIL_REF = $0B97; + GL_STENCIL_WRITEMASK = $0B98; + GL_MATRIX_MODE = $0BA0; + GL_NORMALIZE = $0BA1; + GL_VIEWPORT = $0BA2; + GL_MODELVIEW_STACK_DEPTH = $0BA3; + GL_PROJECTION_STACK_DEPTH = $0BA4; + GL_TEXTURE_STACK_DEPTH = $0BA5; + GL_MODELVIEW_MATRIX = $0BA6; + GL_PROJECTION_MATRIX = $0BA7; + GL_TEXTURE_MATRIX = $0BA8; + GL_ATTRIB_STACK_DEPTH = $0BB0; + GL_CLIENT_ATTRIB_STACK_DEPTH = $0BB1; + GL_ALPHA_TEST = $0BC0; + GL_ALPHA_TEST_FUNC = $0BC1; + GL_ALPHA_TEST_REF = $0BC2; + GL_DITHER = $0BD0; + GL_BLEND_DST = $0BE0; + GL_BLEND_SRC = $0BE1; + GL_BLEND = $0BE2; + GL_LOGIC_OP_MODE = $0BF0; + GL_INDEX_LOGIC_OP = $0BF1; + GL_COLOR_LOGIC_OP = $0BF2; + GL_AUX_BUFFERS = $0C00; + GL_DRAW_BUFFER = $0C01; + GL_READ_BUFFER = $0C02; + GL_SCISSOR_BOX = $0C10; + GL_SCISSOR_TEST = $0C11; + GL_INDEX_CLEAR_VALUE = $0C20; + GL_INDEX_WRITEMASK = $0C21; + GL_COLOR_CLEAR_VALUE = $0C22; + GL_COLOR_WRITEMASK = $0C23; + GL_INDEX_MODE = $0C30; + GL_RGBA_MODE = $0C31; + GL_DOUBLEBUFFER = $0C32; + GL_STEREO = $0C33; + GL_RENDER_MODE = $0C40; + GL_PERSPECTIVE_CORRECTION_HINT = $0C50; + GL_POINT_SMOOTH_HINT = $0C51; + GL_LINE_SMOOTH_HINT = $0C52; + GL_POLYGON_SMOOTH_HINT = $0C53; + GL_FOG_HINT = $0C54; + GL_TEXTURE_GEN_S = $0C60; + GL_TEXTURE_GEN_T = $0C61; + GL_TEXTURE_GEN_R = $0C62; + GL_TEXTURE_GEN_Q = $0C63; + GL_PIXEL_MAP_I_TO_I = $0C70; + GL_PIXEL_MAP_S_TO_S = $0C71; + GL_PIXEL_MAP_I_TO_R = $0C72; + GL_PIXEL_MAP_I_TO_G = $0C73; + GL_PIXEL_MAP_I_TO_B = $0C74; + GL_PIXEL_MAP_I_TO_A = $0C75; + GL_PIXEL_MAP_R_TO_R = $0C76; + GL_PIXEL_MAP_G_TO_G = $0C77; + GL_PIXEL_MAP_B_TO_B = $0C78; + GL_PIXEL_MAP_A_TO_A = $0C79; + GL_PIXEL_MAP_I_TO_I_SIZE = $0CB0; + GL_PIXEL_MAP_S_TO_S_SIZE = $0CB1; + GL_PIXEL_MAP_I_TO_R_SIZE = $0CB2; + GL_PIXEL_MAP_I_TO_G_SIZE = $0CB3; + GL_PIXEL_MAP_I_TO_B_SIZE = $0CB4; + GL_PIXEL_MAP_I_TO_A_SIZE = $0CB5; + GL_PIXEL_MAP_R_TO_R_SIZE = $0CB6; + GL_PIXEL_MAP_G_TO_G_SIZE = $0CB7; + GL_PIXEL_MAP_B_TO_B_SIZE = $0CB8; + GL_PIXEL_MAP_A_TO_A_SIZE = $0CB9; + GL_UNPACK_SWAP_BYTES = $0CF0; + GL_UNPACK_LSB_FIRST = $0CF1; + GL_UNPACK_ROW_LENGTH = $0CF2; + GL_UNPACK_SKIP_ROWS = $0CF3; + GL_UNPACK_SKIP_PIXELS = $0CF4; + GL_UNPACK_ALIGNMENT = $0CF5; + GL_PACK_SWAP_BYTES = $0D00; + GL_PACK_LSB_FIRST = $0D01; + GL_PACK_ROW_LENGTH = $0D02; + GL_PACK_SKIP_ROWS = $0D03; + GL_PACK_SKIP_PIXELS = $0D04; + GL_PACK_ALIGNMENT = $0D05; + GL_MAP_COLOR = $0D10; + GL_MAP_STENCIL = $0D11; + GL_INDEX_SHIFT = $0D12; + GL_INDEX_OFFSET = $0D13; + GL_RED_SCALE = $0D14; + GL_RED_BIAS = $0D15; + GL_ZOOM_X = $0D16; + GL_ZOOM_Y = $0D17; + GL_GREEN_SCALE = $0D18; + GL_GREEN_BIAS = $0D19; + GL_BLUE_SCALE = $0D1A; + GL_BLUE_BIAS = $0D1B; + GL_ALPHA_SCALE = $0D1C; + GL_ALPHA_BIAS = $0D1D; + GL_DEPTH_SCALE = $0D1E; + GL_DEPTH_BIAS = $0D1F; + GL_MAX_EVAL_ORDER = $0D30; + GL_MAX_LIGHTS = $0D31; + GL_MAX_CLIP_PLANES = $0D32; + GL_MAX_TEXTURE_SIZE = $0D33; + GL_MAX_PIXEL_MAP_TABLE = $0D34; + GL_MAX_ATTRIB_STACK_DEPTH = $0D35; + GL_MAX_MODELVIEW_STACK_DEPTH = $0D36; + GL_MAX_NAME_STACK_DEPTH = $0D37; + GL_MAX_PROJECTION_STACK_DEPTH = $0D38; + GL_MAX_TEXTURE_STACK_DEPTH = $0D39; + GL_MAX_VIEWPORT_DIMS = $0D3A; + GL_MAX_CLIENT_ATTRIB_STACK_DEPTH = $0D3B; + GL_SUBPIXEL_BITS = $0D50; + GL_INDEX_BITS = $0D51; + GL_RED_BITS = $0D52; + GL_GREEN_BITS = $0D53; + GL_BLUE_BITS = $0D54; + GL_ALPHA_BITS = $0D55; + GL_DEPTH_BITS = $0D56; + GL_STENCIL_BITS = $0D57; + GL_ACCUM_RED_BITS = $0D58; + GL_ACCUM_GREEN_BITS = $0D59; + GL_ACCUM_BLUE_BITS = $0D5A; + GL_ACCUM_ALPHA_BITS = $0D5B; + GL_NAME_STACK_DEPTH = $0D70; + GL_AUTO_NORMAL = $0D80; + GL_MAP1_COLOR_4 = $0D90; + GL_MAP1_INDEX = $0D91; + GL_MAP1_NORMAL = $0D92; + GL_MAP1_TEXTURE_COORD_1 = $0D93; + GL_MAP1_TEXTURE_COORD_2 = $0D94; + GL_MAP1_TEXTURE_COORD_3 = $0D95; + GL_MAP1_TEXTURE_COORD_4 = $0D96; + GL_MAP1_VERTEX_3 = $0D97; + GL_MAP1_VERTEX_4 = $0D98; + GL_MAP2_COLOR_4 = $0DB0; + GL_MAP2_INDEX = $0DB1; + GL_MAP2_NORMAL = $0DB2; + GL_MAP2_TEXTURE_COORD_1 = $0DB3; + GL_MAP2_TEXTURE_COORD_2 = $0DB4; + GL_MAP2_TEXTURE_COORD_3 = $0DB5; + GL_MAP2_TEXTURE_COORD_4 = $0DB6; + GL_MAP2_VERTEX_3 = $0DB7; + GL_MAP2_VERTEX_4 = $0DB8; + GL_MAP1_GRID_DOMAIN = $0DD0; + GL_MAP1_GRID_SEGMENTS = $0DD1; + GL_MAP2_GRID_DOMAIN = $0DD2; + GL_MAP2_GRID_SEGMENTS = $0DD3; + GL_TEXTURE_1D = $0DE0; + GL_TEXTURE_2D = $0DE1; + GL_FEEDBACK_BUFFER_POINTER = $0DF0; + GL_FEEDBACK_BUFFER_SIZE = $0DF1; + GL_FEEDBACK_BUFFER_TYPE = $0DF2; + GL_SELECTION_BUFFER_POINTER = $0DF3; + GL_SELECTION_BUFFER_SIZE = $0DF4; + // GL_TEXTURE_BINDING_1D + // GL_TEXTURE_BINDING_2D + // GL_VERTEX_ARRAY + // GL_NORMAL_ARRAY + // GL_COLOR_ARRAY + // GL_INDEX_ARRAY + // GL_TEXTURE_COORD_ARRAY + // GL_EDGE_FLAG_ARRAY + // GL_VERTEX_ARRAY_SIZE + // GL_VERTEX_ARRAY_TYPE + // GL_VERTEX_ARRAY_STRIDE + // GL_NORMAL_ARRAY_TYPE + // GL_NORMAL_ARRAY_STRIDE + // GL_COLOR_ARRAY_SIZE + // GL_COLOR_ARRAY_TYPE + // GL_COLOR_ARRAY_STRIDE + // GL_INDEX_ARRAY_TYPE + // GL_INDEX_ARRAY_STRIDE + // GL_TEXTURE_COORD_ARRAY_SIZE + // GL_TEXTURE_COORD_ARRAY_TYPE + // GL_TEXTURE_COORD_ARRAY_STRIDE + // GL_EDGE_FLAG_ARRAY_STRIDE + // GL_POLYGON_OFFSET_FACTOR + // GL_POLYGON_OFFSET_UNITS + + // GetTextureParameter + // GL_TEXTURE_MAG_FILTER + // GL_TEXTURE_MIN_FILTER + // GL_TEXTURE_WRAP_S + // GL_TEXTURE_WRAP_T + GL_TEXTURE_WIDTH = $1000; + GL_TEXTURE_HEIGHT = $1001; + GL_TEXTURE_INTERNAL_FORMAT = $1003; + GL_TEXTURE_BORDER_COLOR = $1004; + GL_TEXTURE_BORDER = $1005; + // GL_TEXTURE_RED_SIZE + // GL_TEXTURE_GREEN_SIZE + // GL_TEXTURE_BLUE_SIZE + // GL_TEXTURE_ALPHA_SIZE + // GL_TEXTURE_LUMINANCE_SIZE + // GL_TEXTURE_INTENSITY_SIZE + // GL_TEXTURE_PRIORITY + // GL_TEXTURE_RESIDENT + + // HintMode + GL_DONT_CARE = $1100; + GL_FASTEST = $1101; + GL_NICEST = $1102; + + // HintTarget + // GL_PERSPECTIVE_CORRECTION_HINT + // GL_POINT_SMOOTH_HINT + // GL_LINE_SMOOTH_HINT + // GL_POLYGON_SMOOTH_HINT + // GL_FOG_HINT + + // IndexPointerType + // GL_SHORT + // GL_INT + // GL_FLOAT + // GL_DOUBLE + + // LightModelParameter + // GL_LIGHT_MODEL_AMBIENT + // GL_LIGHT_MODEL_LOCAL_VIEWER + // GL_LIGHT_MODEL_TWO_SIDE + + // LightName + GL_LIGHT0 = $4000; + GL_LIGHT1 = $4001; + GL_LIGHT2 = $4002; + GL_LIGHT3 = $4003; + GL_LIGHT4 = $4004; + GL_LIGHT5 = $4005; + GL_LIGHT6 = $4006; + GL_LIGHT7 = $4007; + + // LightParameter + GL_AMBIENT = $1200; + GL_DIFFUSE = $1201; + GL_SPECULAR = $1202; + GL_POSITION = $1203; + GL_SPOT_DIRECTION = $1204; + GL_SPOT_EXPONENT = $1205; + GL_SPOT_CUTOFF = $1206; + GL_CONSTANT_ATTENUATION = $1207; + GL_LINEAR_ATTENUATION = $1208; + GL_QUADRATIC_ATTENUATION = $1209; + + // InterleavedArrays + // GL_V2F + // GL_V3F + // GL_C4UB_V2F + // GL_C4UB_V3F + // GL_C3F_V3F + // GL_N3F_V3F + // GL_C4F_N3F_V3F + // GL_T2F_V3F + // GL_T4F_V4F + // GL_T2F_C4UB_V3F + // GL_T2F_C3F_V3F + // GL_T2F_N3F_V3F + // GL_T2F_C4F_N3F_V3F + // GL_T4F_C4F_N3F_V4F + + // ListMode + GL_COMPILE = $1300; + GL_COMPILE_AND_EXECUTE = $1301; + + // ListNameType + // GL_BYTE + // GL_UNSIGNED_BYTE + // GL_SHORT + // GL_UNSIGNED_SHORT + // GL_INT + // GL_UNSIGNED_INT + // GL_FLOAT + // GL_2_BYTES + // GL_3_BYTES + // GL_4_BYTES + + // LogicOp + GL_CLEAR = $1500; + GL_AND = $1501; + GL_AND_REVERSE = $1502; + GL_COPY = $1503; + GL_AND_INVERTED = $1504; + GL_NOOP = $1505; + GL_XOR = $1506; + GL_OR = $1507; + GL_NOR = $1508; + GL_EQUIV = $1509; + GL_INVERT = $150A; + GL_OR_REVERSE = $150B; + GL_COPY_INVERTED = $150C; + GL_OR_INVERTED = $150D; + GL_NAND = $150E; + GL_SET = $150F; + + // MapTarget + // GL_MAP1_COLOR_4 + // GL_MAP1_INDEX + // GL_MAP1_NORMAL + // GL_MAP1_TEXTURE_COORD_1 + // GL_MAP1_TEXTURE_COORD_2 + // GL_MAP1_TEXTURE_COORD_3 + // GL_MAP1_TEXTURE_COORD_4 + // GL_MAP1_VERTEX_3 + // GL_MAP1_VERTEX_4 + // GL_MAP2_COLOR_4 + // GL_MAP2_INDEX + // GL_MAP2_NORMAL + // GL_MAP2_TEXTURE_COORD_1 + // GL_MAP2_TEXTURE_COORD_2 + // GL_MAP2_TEXTURE_COORD_3 + // GL_MAP2_TEXTURE_COORD_4 + // GL_MAP2_VERTEX_3 + // GL_MAP2_VERTEX_4 + + // MaterialFace + // GL_FRONT + // GL_BACK + // GL_FRONT_AND_BACK + + // MaterialParameter + GL_EMISSION = $1600; + GL_SHININESS = $1601; + GL_AMBIENT_AND_DIFFUSE = $1602; + GL_COLOR_INDEXES = $1603; + // GL_AMBIENT + // GL_DIFFUSE + // GL_SPECULAR + + // MatrixMode + GL_MODELVIEW = $1700; + GL_PROJECTION = $1701; + GL_TEXTURE = $1702; + + // MeshMode1 + // GL_POINT + // GL_LINE + + // MeshMode2 + // GL_POINT + // GL_LINE + // GL_FILL + + // NormalPointerType + // GL_BYTE + // GL_SHORT + // GL_INT + // GL_FLOAT + // GL_DOUBLE + + // PixelCopyType + GL_COLOR = $1800; + GL_DEPTH = $1801; + GL_STENCIL = $1802; + + // PixelFormat + GL_COLOR_INDEX = $1900; + GL_STENCIL_INDEX = $1901; + GL_DEPTH_COMPONENT = $1902; + GL_RED = $1903; + GL_GREEN = $1904; + GL_BLUE = $1905; + GL_ALPHA = $1906; + GL_RGB = $1907; + GL_RGBA = $1908; + GL_LUMINANCE = $1909; + GL_LUMINANCE_ALPHA = $190A; + + // PixelMap + // GL_PIXEL_MAP_I_TO_I + // GL_PIXEL_MAP_S_TO_S + // GL_PIXEL_MAP_I_TO_R + // GL_PIXEL_MAP_I_TO_G + // GL_PIXEL_MAP_I_TO_B + // GL_PIXEL_MAP_I_TO_A + // GL_PIXEL_MAP_R_TO_R + // GL_PIXEL_MAP_G_TO_G + // GL_PIXEL_MAP_B_TO_B + // GL_PIXEL_MAP_A_TO_A + + // PixelStore + // GL_UNPACK_SWAP_BYTES + // GL_UNPACK_LSB_FIRST + // GL_UNPACK_ROW_LENGTH + // GL_UNPACK_SKIP_ROWS + // GL_UNPACK_SKIP_PIXELS + // GL_UNPACK_ALIGNMENT + // GL_PACK_SWAP_BYTES + // GL_PACK_LSB_FIRST + // GL_PACK_ROW_LENGTH + // GL_PACK_SKIP_ROWS + // GL_PACK_SKIP_PIXELS + // GL_PACK_ALIGNMENT + + // PixelTransfer + // GL_MAP_COLOR + // GL_MAP_STENCIL + // GL_INDEX_SHIFT + // GL_INDEX_OFFSET + // GL_RED_SCALE + // GL_RED_BIAS + // GL_GREEN_SCALE + // GL_GREEN_BIAS + // GL_BLUE_SCALE + // GL_BLUE_BIAS + // GL_ALPHA_SCALE + // GL_ALPHA_BIAS + // GL_DEPTH_SCALE + // GL_DEPTH_BIAS + + // PixelType + GL_BITMAP = $1A00; + // GL_BYTE + // GL_UNSIGNED_BYTE + // GL_SHORT + // GL_UNSIGNED_SHORT + // GL_INT + // GL_UNSIGNED_INT + // GL_FLOAT + + // PolygonMode + GL_POINT = $1B00; + GL_LINE = $1B01; + GL_FILL = $1B02; + + // ReadBufferMode + // GL_FRONT_LEFT + // GL_FRONT_RIGHT + // GL_BACK_LEFT + // GL_BACK_RIGHT + // GL_FRONT + // GL_BACK + // GL_LEFT + // GL_RIGHT + // GL_AUX0 + // GL_AUX1 + // GL_AUX2 + // GL_AUX3 + + // RenderingMode + GL_RENDER = $1C00; + GL_FEEDBACK = $1C01; + GL_SELECT = $1C02; + + // ShadingModel + GL_FLAT = $1D00; + GL_SMOOTH = $1D01; + + // StencilFunction + // GL_NEVER + // GL_LESS + // GL_EQUAL + // GL_LEQUAL + // GL_GREATER + // GL_NOTEQUAL + // GL_GEQUAL + // GL_ALWAYS + + // StencilOp + // GL_ZERO + GL_KEEP = $1E00; + GL_REPLACE = $1E01; + GL_INCR = $1E02; + GL_DECR = $1E03; + // GL_INVERT + + // StringName + GL_VENDOR = $1F00; + GL_RENDERER = $1F01; + GL_VERSION = $1F02; + GL_EXTENSIONS = $1F03; + + // TextureCoordName + GL_S = $2000; + GL_T = $2001; + GL_R = $2002; + GL_Q = $2003; + + // TexCoordPointerType + // GL_SHORT + // GL_INT + // GL_FLOAT + // GL_DOUBLE + + // TextureEnvMode + GL_MODULATE = $2100; + GL_DECAL = $2101; + // GL_BLEND + // GL_REPLACE + + // TextureEnvParameter + GL_TEXTURE_ENV_MODE = $2200; + GL_TEXTURE_ENV_COLOR = $2201; + + // TextureEnvTarget + GL_TEXTURE_ENV = $2300; + + // TextureGenMode + GL_EYE_LINEAR = $2400; + GL_OBJECT_LINEAR = $2401; + GL_SPHERE_MAP = $2402; + + // TextureGenParameter + GL_TEXTURE_GEN_MODE = $2500; + GL_OBJECT_PLANE = $2501; + GL_EYE_PLANE = $2502; + + // TextureMagFilter + GL_NEAREST = $2600; + GL_LINEAR = $2601; + + // TextureMinFilter + // GL_NEAREST + // GL_LINEAR + GL_NEAREST_MIPMAP_NEAREST = $2700; + GL_LINEAR_MIPMAP_NEAREST = $2701; + GL_NEAREST_MIPMAP_LINEAR = $2702; + GL_LINEAR_MIPMAP_LINEAR = $2703; + + // TextureParameterName + GL_TEXTURE_MAG_FILTER = $2800; + GL_TEXTURE_MIN_FILTER = $2801; + GL_TEXTURE_WRAP_S = $2802; + GL_TEXTURE_WRAP_T = $2803; + // GL_TEXTURE_BORDER_COLOR + // GL_TEXTURE_PRIORITY + + // TextureTarget + // GL_TEXTURE_1D + // GL_TEXTURE_2D + // GL_PROXY_TEXTURE_1D + // GL_PROXY_TEXTURE_2D + + // TextureWrapMode + GL_CLAMP = $2900; + GL_REPEAT = $2901; + + // VertexPointerType + // GL_SHORT + // GL_INT + // GL_FLOAT + // GL_DOUBLE + + // ClientAttribMask + GL_CLIENT_PIXEL_STORE_BIT = $00000001; + GL_CLIENT_VERTEX_ARRAY_BIT = $00000002; + GL_CLIENT_ALL_ATTRIB_BITS = $FFFFFFFF; + + // polygon_offset + GL_POLYGON_OFFSET_FACTOR = $8038; + GL_POLYGON_OFFSET_UNITS = $2A00; + GL_POLYGON_OFFSET_POINT = $2A01; + GL_POLYGON_OFFSET_LINE = $2A02; + GL_POLYGON_OFFSET_FILL = $8037; + + // texture + GL_ALPHA4 = $803B; + GL_ALPHA8 = $803C; + GL_ALPHA12 = $803D; + GL_ALPHA16 = $803E; + GL_LUMINANCE4 = $803F; + GL_LUMINANCE8 = $8040; + GL_LUMINANCE12 = $8041; + GL_LUMINANCE16 = $8042; + GL_LUMINANCE4_ALPHA4 = $8043; + GL_LUMINANCE6_ALPHA2 = $8044; + GL_LUMINANCE8_ALPHA8 = $8045; + GL_LUMINANCE12_ALPHA4 = $8046; + GL_LUMINANCE12_ALPHA12 = $8047; + GL_LUMINANCE16_ALPHA16 = $8048; + GL_INTENSITY = $8049; + GL_INTENSITY4 = $804A; + GL_INTENSITY8 = $804B; + GL_INTENSITY12 = $804C; + GL_INTENSITY16 = $804D; + GL_R3_G3_B2 = $2A10; + GL_RGB4 = $804F; + GL_RGB5 = $8050; + GL_RGB8 = $8051; + GL_RGB10 = $8052; + GL_RGB12 = $8053; + GL_RGB16 = $8054; + GL_RGBA2 = $8055; + GL_RGBA4 = $8056; + GL_RGB5_A1 = $8057; + GL_RGBA8 = $8058; + GL_RGB10_A2 = $8059; + GL_RGBA12 = $805A; + GL_RGBA16 = $805B; + GL_TEXTURE_RED_SIZE = $805C; + GL_TEXTURE_GREEN_SIZE = $805D; + GL_TEXTURE_BLUE_SIZE = $805E; + GL_TEXTURE_ALPHA_SIZE = $805F; + GL_TEXTURE_LUMINANCE_SIZE = $8060; + GL_TEXTURE_INTENSITY_SIZE = $8061; + GL_PROXY_TEXTURE_1D = $8063; + GL_PROXY_TEXTURE_2D = $8064; + + // texture_object + GL_TEXTURE_PRIORITY = $8066; + GL_TEXTURE_RESIDENT = $8067; + GL_TEXTURE_BINDING_1D = $8068; + GL_TEXTURE_BINDING_2D = $8069; + + // vertex_array + GL_VERTEX_ARRAY = $8074; + GL_NORMAL_ARRAY = $8075; + GL_COLOR_ARRAY = $8076; + GL_INDEX_ARRAY = $8077; + GL_TEXTURE_COORD_ARRAY = $8078; + GL_EDGE_FLAG_ARRAY = $8079; + GL_VERTEX_ARRAY_SIZE = $807A; + GL_VERTEX_ARRAY_TYPE = $807B; + GL_VERTEX_ARRAY_STRIDE = $807C; + GL_NORMAL_ARRAY_TYPE = $807E; + GL_NORMAL_ARRAY_STRIDE = $807F; + GL_COLOR_ARRAY_SIZE = $8081; + GL_COLOR_ARRAY_TYPE = $8082; + GL_COLOR_ARRAY_STRIDE = $8083; + GL_INDEX_ARRAY_TYPE = $8085; + GL_INDEX_ARRAY_STRIDE = $8086; + GL_TEXTURE_COORD_ARRAY_SIZE = $8088; + GL_TEXTURE_COORD_ARRAY_TYPE = $8089; + GL_TEXTURE_COORD_ARRAY_STRIDE = $808A; + GL_EDGE_FLAG_ARRAY_STRIDE = $808C; + GL_VERTEX_ARRAY_POINTER = $808E; + GL_NORMAL_ARRAY_POINTER = $808F; + GL_COLOR_ARRAY_POINTER = $8090; + GL_INDEX_ARRAY_POINTER = $8091; + GL_TEXTURE_COORD_ARRAY_POINTER = $8092; + GL_EDGE_FLAG_ARRAY_POINTER = $8093; + GL_V2F = $2A20; + GL_V3F = $2A21; + GL_C4UB_V2F = $2A22; + GL_C4UB_V3F = $2A23; + GL_C3F_V3F = $2A24; + GL_N3F_V3F = $2A25; + GL_C4F_N3F_V3F = $2A26; + GL_T2F_V3F = $2A27; + GL_T4F_V4F = $2A28; + GL_T2F_C4UB_V3F = $2A29; + GL_T2F_C3F_V3F = $2A2A; + GL_T2F_N3F_V3F = $2A2B; + GL_T2F_C4F_N3F_V3F = $2A2C; + GL_T4F_C4F_N3F_V4F = $2A2D; + + // Extensions + GL_EXT_vertex_array = 1; + GL_WIN_swap_hint = 1; + GL_EXT_bgra = 1; + GL_EXT_paletted_texture = 1; + + // EXT_vertex_array + GL_VERTEX_ARRAY_EXT = $8074; + GL_NORMAL_ARRAY_EXT = $8075; + GL_COLOR_ARRAY_EXT = $8076; + GL_INDEX_ARRAY_EXT = $8077; + GL_TEXTURE_COORD_ARRAY_EXT = $8078; + GL_EDGE_FLAG_ARRAY_EXT = $8079; + GL_VERTEX_ARRAY_SIZE_EXT = $807A; + GL_VERTEX_ARRAY_TYPE_EXT = $807B; + GL_VERTEX_ARRAY_STRIDE_EXT = $807C; + GL_VERTEX_ARRAY_COUNT_EXT = $807D; + GL_NORMAL_ARRAY_TYPE_EXT = $807E; + GL_NORMAL_ARRAY_STRIDE_EXT = $807F; + GL_NORMAL_ARRAY_COUNT_EXT = $8080; + GL_COLOR_ARRAY_SIZE_EXT = $8081; + GL_COLOR_ARRAY_TYPE_EXT = $8082; + GL_COLOR_ARRAY_STRIDE_EXT = $8083; + GL_COLOR_ARRAY_COUNT_EXT = $8084; + GL_INDEX_ARRAY_TYPE_EXT = $8085; + GL_INDEX_ARRAY_STRIDE_EXT = $8086; + GL_INDEX_ARRAY_COUNT_EXT = $8087; + GL_TEXTURE_COORD_ARRAY_SIZE_EXT = $8088; + GL_TEXTURE_COORD_ARRAY_TYPE_EXT = $8089; + GL_TEXTURE_COORD_ARRAY_STRIDE_EXT = $808A; + GL_TEXTURE_COORD_ARRAY_COUNT_EXT = $808B; + GL_EDGE_FLAG_ARRAY_STRIDE_EXT = $808C; + GL_EDGE_FLAG_ARRAY_COUNT_EXT = $808D; + GL_VERTEX_ARRAY_POINTER_EXT = $808E; + GL_NORMAL_ARRAY_POINTER_EXT = $808F; + GL_COLOR_ARRAY_POINTER_EXT = $8090; + GL_INDEX_ARRAY_POINTER_EXT = $8091; + GL_TEXTURE_COORD_ARRAY_POINTER_EXT = $8092; + GL_EDGE_FLAG_ARRAY_POINTER_EXT = $8093; + GL_DOUBLE_EXT = GL_DOUBLE; + + // EXT_bgra + GL_BGR_EXT = $80E0; + GL_BGRA_EXT = $80E1; + + // EXT_paletted_texture + + // These must match the GL_COLOR_TABLE_*_SGI enumerants + GL_COLOR_TABLE_FORMAT_EXT = $80D8; + GL_COLOR_TABLE_WIDTH_EXT = $80D9; + GL_COLOR_TABLE_RED_SIZE_EXT = $80DA; + GL_COLOR_TABLE_GREEN_SIZE_EXT = $80DB; + GL_COLOR_TABLE_BLUE_SIZE_EXT = $80DC; + GL_COLOR_TABLE_ALPHA_SIZE_EXT = $80DD; + GL_COLOR_TABLE_LUMINANCE_SIZE_EXT = $80DE; + GL_COLOR_TABLE_INTENSITY_SIZE_EXT = $80DF; + + GL_COLOR_INDEX1_EXT = $80E2; + GL_COLOR_INDEX2_EXT = $80E3; + GL_COLOR_INDEX4_EXT = $80E4; + GL_COLOR_INDEX8_EXT = $80E5; + GL_COLOR_INDEX12_EXT = $80E6; + GL_COLOR_INDEX16_EXT = $80E7; + + // For compatibility with OpenGL v1.0 + GL_LOGIC_OP = GL_INDEX_LOGIC_OP; + GL_TEXTURE_COMPONENTS = GL_TEXTURE_INTERNAL_FORMAT; + +{******************************************************************************} + +procedure glAccum(op: GLenum; value: GLfloat); external dllname; +procedure glAlphaFunc(func: GLenum; ref: GLclampf); external dllname; +function glAreTexturesResident (n: GLsizei; const textures: PGLuint; residences: PGLboolean): GLboolean; external dllname; +procedure glArrayElement(i: GLint); external dllname; +procedure glBegin(mode: GLenum); external dllname; +procedure glBindTexture(target: GLenum; texture: GLuint); external dllname; +procedure glBitmap (width, height: GLsizei; xorig, yorig: GLfloat; xmove, ymove: GLfloat; const bitmap: PGLubyte); external dllname; +procedure glBlendFunc(sfactor, dfactor: GLenum); external dllname; +procedure glCallList(list: GLuint); external dllname; +procedure glCallLists(n: GLsizei; atype: GLenum; const lists: Pointer); external dllname; +procedure glClear(mask: GLbitfield); external dllname; +procedure glClearAccum(red, green, blue, alpha: GLfloat); external dllname; +procedure glClearColor(red, green, blue, alpha: GLclampf); external dllname; +procedure glClearDepth(depth: GLclampd); external dllname; +procedure glClearIndex(c: GLfloat); external dllname; +procedure glClearStencil(s: GLint); external dllname; +procedure glClipPlane(plane: GLenum; const equation: PGLdouble); external dllname; +procedure glColor3b(red, green, blue: GLbyte); external dllname; +procedure glColor3bv(const v: PGLbyte); external dllname; +procedure glColor3d(red, green, blue: GLdouble); external dllname; +procedure glColor3dv(const v: PGLdouble); external dllname; +procedure glColor3f(red, green, blue: GLfloat); external dllname; +procedure glColor3fv(const v: PGLfloat); external dllname; +procedure glColor3i(red, green, blue: GLint); external dllname; +procedure glColor3iv(const v: PGLint); external dllname; +procedure glColor3s(red, green, blue: GLshort); external dllname; +procedure glColor3sv(const v: PGLshort); external dllname; +procedure glColor3ub(red, green, blue: GLubyte); external dllname; +procedure glColor3ubv(const v: PGLubyte); external dllname; +procedure glColor3ui(red, green, blue: GLuint); external dllname; +procedure glColor3uiv(const v: PGLuint); external dllname; +procedure glColor3us(red, green, blue: GLushort); external dllname; +procedure glColor3usv(const v: PGLushort); external dllname; +procedure glColor4b(red, green, blue, alpha: GLbyte); external dllname; +procedure glColor4bv(const v: PGLbyte); external dllname; +procedure glColor4d(red, green, blue, alpha: GLdouble); external dllname; +procedure glColor4dv(const v: PGLdouble); external dllname; +procedure glColor4f(red, green, blue, alpha: GLfloat); external dllname; +procedure glColor4fv(const v: PGLfloat); external dllname; +procedure glColor4i(red, green, blue, alpha: GLint); external dllname; +procedure glColor4iv(const v: PGLint); external dllname; +procedure glColor4s(red, green, blue, alpha: GLshort); external dllname; +procedure glColor4sv(const v: PGLshort); external dllname; +procedure glColor4ub(red, green, blue, alpha: GLubyte); external dllname; +procedure glColor4ubv(const v: PGLubyte); external dllname; +procedure glColor4ui(red, green, blue, alpha: GLuint); external dllname; +procedure glColor4uiv(const v: PGLuint); external dllname; +procedure glColor4us(red, green, blue, alpha: GLushort); external dllname; +procedure glColor4usv(const v: PGLushort); external dllname; +procedure glColorMask(red, green, blue, alpha: GLboolean); external dllname; +procedure glColorMaterial(face, mode: GLenum); external dllname; +procedure glColorPointer(size: GLint; atype: GLenum; stride: GLsizei; const pointer: Pointer); external dllname; +procedure glCopyPixels(x, y: GLint; width, height: GLsizei; atype: GLenum); external dllname; +procedure glCopyTexImage1D (target: GLenum; level: GLint; internalFormat: GLenum; x, y: GLint; width: GLsizei; border: GLint); external dllname; +procedure glCopyTexImage2D(target: GLenum; level: GLint; internalFormat: GLenum; x, y: GLint; width, height: GLsizei; border: GLint); external dllname; +procedure glCopyTexSubImage1D(target: GLenum; level, xoffset, x, y: GLint; width: GLsizei); external dllname; +procedure glCopyTexSubImage2D(target: GLenum; level, xoffset, yoffset, x, y: GLint; width, height: GLsizei); external dllname; +procedure glCullFace(mode: GLenum); external dllname; +procedure glDeleteLists(list: GLuint; range: GLsizei); external dllname; +procedure glDeleteTextures(n: GLsizei; const textures: PGLuint); external dllname; +procedure glDepthFunc(func: GLenum); external dllname; +procedure glDepthMask(flag: GLboolean); external dllname; +procedure glDepthRange(zNear, zFar: GLclampd); external dllname; +procedure glDisable(cap: GLenum); external dllname; +procedure glDisableClientState(aarray: GLenum); external dllname; +procedure glDrawArrays(mode: GLenum; first: GLint; count: GLsizei); external dllname; +procedure glDrawBuffer(mode: GLenum); external dllname; +procedure glDrawElements(mode: GLenum; count: GLsizei; atype: GLenum; const indices: Pointer); external dllname; +procedure glDrawPixels(width, height: GLsizei; format, atype: GLenum; const pixels: Pointer); external dllname; +procedure glEdgeFlag(flag: GLboolean); external dllname; +procedure glEdgeFlagPointer(stride: GLsizei; const pointer: Pointer); external dllname; +procedure glEdgeFlagv(const flag: PGLboolean); external dllname; +procedure glEnable(cap: GLenum); external dllname; +procedure glEnableClientState(aarray: GLenum); external dllname; +procedure glEnd; external dllname; +procedure glEndList; external dllname; +procedure glEvalCoord1d(u: GLdouble); external dllname; +procedure glEvalCoord1dv(const u: PGLdouble); external dllname; +procedure glEvalCoord1f(u: GLfloat); external dllname; +procedure glEvalCoord1fv(const u: PGLfloat); external dllname; +procedure glEvalCoord2d(u, v: GLdouble); external dllname; +procedure glEvalCoord2dv(const u: PGLdouble); external dllname; +procedure glEvalCoord2f(u, v: GLfloat); external dllname; +procedure glEvalCoord2fv(const u: PGLfloat); external dllname; +procedure glEvalMesh1(mode: GLenum; i1, i2: GLint); external dllname; +procedure glEvalMesh2(mode: GLenum; i1, i2, j1, j2: GLint); external dllname; +procedure glEvalPoint1(i: GLint); external dllname; +procedure glEvalPoint2(i, j: GLint); external dllname; +procedure glFeedbackBuffer(size: GLsizei; atype: GLenum; buffer: PGLfloat); external dllname; +procedure glFinish; external dllname; +procedure glFlush; external dllname; +procedure glFogf(pname: GLenum; param: GLfloat); external dllname; +procedure glFogfv(pname: GLenum; const params: PGLfloat); external dllname; +procedure glFogi(pname: GLenum; param: GLint); external dllname; +procedure glFogiv(pname: GLenum; const params: PGLint); external dllname; +procedure glFrontFace(mode: GLenum); external dllname; +procedure glFrustum(left, right, bottom, top, zNear, zFar: GLdouble); external dllname; +function glGenLists(range: GLsizei): GLuint; external dllname; +procedure glGenTextures(n: GLsizei; textures: PGLuint); external dllname; +procedure glGetBooleanv(pname: GLenum; params: PGLboolean); external dllname; +procedure glGetClipPlane(plane: GLenum; equation: PGLdouble); external dllname; +procedure glGetDoublev(pname: GLenum; params: PGLdouble); external dllname; +function glGetError: GLenum; external dllname; +procedure glGetFloatv(pname: GLenum; params: PGLfloat); external dllname; +procedure glGetIntegerv(pname: GLenum; params: PGLint); external dllname; +procedure glGetLightfv(light, pname: GLenum; params: PGLfloat); external dllname; +procedure glGetLightiv(light, pname: GLenum; params: PGLint); external dllname; +procedure glGetMapdv(target, query: GLenum; v: PGLdouble); external dllname; +procedure glGetMapfv(target, query: GLenum; v: PGLfloat); external dllname; +procedure glGetMapiv(target, query: GLenum; v: PGLint); external dllname; +procedure glGetMaterialfv(face, pname: GLenum; params: PGLfloat); external dllname; +procedure glGetMaterialiv(face, pname: GLenum; params: PGLint); external dllname; +procedure glGetPixelMapfv(map: GLenum; values: PGLfloat); external dllname; +procedure glGetPixelMapuiv(map: GLenum; values: PGLuint); external dllname; +procedure glGetPixelMapusv(map: GLenum; values: PGLushort); external dllname; +procedure glGetPointerv(pname: GLenum; params: Pointer); external dllname; +procedure glGetPolygonStipple(mask: PGLubyte); external dllname; +function glGetString(name: GLenum): PChar; external dllname; +procedure glGetTexEnvfv(target, pname: GLenum; params: PGLfloat); external dllname; +procedure glGetTexEnviv(target, pname: GLenum; params: PGLint); external dllname; +procedure glGetTexGendv(coord, pname: GLenum; params: PGLdouble); external dllname; +procedure glGetTexGenfv(coord, pname: GLenum; params: PGLfloat); external dllname; +procedure glGetTexGeniv(coord, pname: GLenum; params: PGLint); external dllname; +procedure glGetTexImage(target: GLenum; level: GLint; format: GLenum; atype: GLenum; pixels: Pointer); external dllname; +procedure glGetTexLevelParameterfv(target: GLenum; level: GLint; pname: GLenum; params: Pointer); external dllname; +procedure glGetTexLevelParameteriv(target: GLenum; level: GLint; pname: GLenum; params: PGLint); external dllname; +procedure glGetTexParameterfv(target, pname: GLenum; params: PGLfloat); external dllname; +procedure glGetTexParameteriv(target, pname: GLenum; params: PGLint); external dllname; +procedure glHint(target, mode: GLenum); external dllname; +procedure glIndexMask(mask: GLuint); external dllname; +procedure glIndexPointer(atype: GLenum; stride: GLsizei; const pointer: Pointer); external dllname; +procedure glIndexd(c: GLdouble); external dllname; +procedure glIndexdv(const c: PGLdouble); external dllname; +procedure glIndexf(c: GLfloat); external dllname; +procedure glIndexfv(const c: PGLfloat); external dllname; +procedure glIndexi(c: GLint); external dllname; +procedure glIndexiv(const c: PGLint); external dllname; +procedure glIndexs(c: GLshort); external dllname; +procedure glIndexsv(const c: PGLshort); external dllname; +procedure glIndexub(c: GLubyte); external dllname; +procedure glIndexubv(const c: PGLubyte); external dllname; +procedure glInitNames; external dllname; +procedure glInterleavedArrays(format: GLenum; stride: GLsizei; const pointer: Pointer); external dllname; +function glIsEnabled(cap: GLenum): GLboolean; external dllname; +function glIsList(list: GLuint): GLboolean; external dllname; +function glIsTexture(texture: GLuint): GLboolean; external dllname; +procedure glLightModelf(pname: GLenum; param: GLfloat); external dllname; +procedure glLightModelfv(pname: GLenum; const params: PGLfloat); external dllname; +procedure glLightModeli(pname: GLenum; param: GLint); external dllname; +procedure glLightModeliv(pname: GLenum; const params: PGLint); external dllname; +procedure glLightf(light, pname: GLenum; param: GLfloat); external dllname; +procedure glLightfv(light, pname: GLenum; const params: PGLfloat); external dllname; +procedure glLighti(light, pname: GLenum; param: GLint); external dllname; +procedure glLightiv(light, pname: GLenum; const params: PGLint); external dllname; +procedure glLineStipple(factor: GLint; pattern: GLushort); external dllname; +procedure glLineWidth(width: GLfloat); external dllname; +procedure glListBase(base: GLuint); external dllname; +procedure glLoadIdentity; external dllname; +procedure glLoadMatrixd(const m: PGLdouble); external dllname; +procedure glLoadMatrixf(const m: PGLfloat); external dllname; +procedure glLoadName(name: GLuint); external dllname; +procedure glLogicOp(opcode: GLenum); external dllname; +procedure glMap1d(target: GLenum; u1, u2: GLdouble; stride, order: GLint; const points: PGLdouble); external dllname; +procedure glMap1f(target: GLenum; u1, u2: GLfloat; stride, order: GLint; const points: PGLfloat); external dllname; +procedure glMap2d(target: GLenum; u1, u2: GLdouble; ustride, uorder: GLint; v1, v2: GLdouble; vstride, vorder: GLint; const points: PGLdouble); external dllname; +procedure glMap2f(target: GLenum; u1, u2: GLfloat; ustride, uorder: GLint; v1, v2: GLfloat; vstride, vorder: GLint; const points: PGLfloat); external dllname; +procedure glMapGrid1d(un: GLint; u1, u2: GLdouble); external dllname; +procedure glMapGrid1f(un: GLint; u1, u2: GLfloat); external dllname; +procedure glMapGrid2d(un: GLint; u1, u2: GLdouble; vn: GLint; v1, v2: GLdouble); external dllname; +procedure glMapGrid2f(un: GLint; u1, u2: GLfloat; vn: GLint; v1, v2: GLfloat); external dllname; +procedure glMaterialf(face, pname: GLenum; param: GLfloat); external dllname; +procedure glMaterialfv(face, pname: GLenum; const params: PGLfloat); external dllname; +procedure glMateriali(face, pname: GLenum; param: GLint); external dllname; +procedure glMaterialiv(face, pname: GLenum; const params: PGLint); external dllname; +procedure glMatrixMode(mode: GLenum); external dllname; +procedure glMultMatrixd(const m: PGLdouble); external dllname; +procedure glMultMatrixf(const m: PGLfloat); external dllname; +procedure glNewList(list: GLuint; mode: GLenum); external dllname; +procedure glNormal3b(nx, ny, nz: GLbyte); external dllname; +procedure glNormal3bv(const v: PGLbyte); external dllname; +procedure glNormal3d(nx, ny, nz: GLdouble); external dllname; +procedure glNormal3dv(const v: PGLdouble); external dllname; +procedure glNormal3f(nx, ny, nz: GLfloat); external dllname; +procedure glNormal3fv(const v: PGLfloat); external dllname; +procedure glNormal3i(nx, ny, nz: GLint); external dllname; +procedure glNormal3iv(const v: PGLint); external dllname; +procedure glNormal3s(nx, ny, nz: GLshort); external dllname; +procedure glNormal3sv(const v: PGLshort); external dllname; +procedure glNormalPointer(atype: GLenum; stride: GLsizei; const pointer: Pointer); external dllname; +procedure glOrtho(left, right, bottom, top, zNear, zFar: GLdouble); external dllname; +procedure glPassThrough(token: GLfloat); external dllname; +procedure glPixelMapfv(map: GLenum; mapsize: GLsizei; const values: PGLfloat); external dllname; +procedure glPixelMapuiv(map: GLenum; mapsize: GLsizei; const values: PGLuint); external dllname; +procedure glPixelMapusv(map: GLenum; mapsize: GLsizei; const values: PGLushort); external dllname; +procedure glPixelStoref(pname: GLenum; param: GLfloat); external dllname; +procedure glPixelStorei(pname: GLenum; param: GLint); external dllname; +procedure glPixelTransferf(pname: GLenum; param: GLfloat); external dllname; +procedure glPixelTransferi(pname: GLenum; param: GLint); external dllname; +procedure glPixelZoom(xfactor, yfactor: GLfloat); external dllname; +procedure glPointSize(size: GLfloat); external dllname; +procedure glPolygonMode(face, mode: GLenum); external dllname; +procedure glPolygonOffset(factor, units: GLfloat); external dllname; +procedure glPolygonStipple(const mask: PGLubyte); external dllname; +procedure glPopAttrib; external dllname; +procedure glPopClientAttrib; external dllname; +procedure glPopMatrix; external dllname; +procedure glPopName; external dllname; +procedure glPrioritizeTextures(n: GLsizei; const textures: PGLuint; const priorities: PGLclampf); external dllname; +procedure glPushAttrib(mask: GLbitfield); external dllname; +procedure glPushClientAttrib(mask: GLbitfield); external dllname; +procedure glPushMatrix; external dllname; +procedure glPushName(name: GLuint); external dllname; +procedure glRasterPos2d(x, y: GLdouble); external dllname; +procedure glRasterPos2dv(const v: PGLdouble); external dllname; +procedure glRasterPos2f(x, y: GLfloat); external dllname; +procedure glRasterPos2fv(const v: PGLfloat); external dllname; +procedure glRasterPos2i(x, y: GLint); external dllname; +procedure glRasterPos2iv(const v: PGLint); external dllname; +procedure glRasterPos2s(x, y: GLshort); external dllname; +procedure glRasterPos2sv(const v: PGLshort); external dllname; +procedure glRasterPos3d(x, y, z: GLdouble); external dllname; +procedure glRasterPos3dv(const v: PGLdouble); external dllname; +procedure glRasterPos3f(x, y, z: GLfloat); external dllname; +procedure glRasterPos3fv(const v: PGLfloat); external dllname; +procedure glRasterPos3i(x, y, z: GLint); external dllname; +procedure glRasterPos3iv(const v: PGLint); external dllname; +procedure glRasterPos3s(x, y, z: GLshort); external dllname; +procedure glRasterPos3sv(const v: PGLshort); external dllname; +procedure glRasterPos4d(x, y, z, w: GLdouble); external dllname; +procedure glRasterPos4dv(const v: PGLdouble); external dllname; +procedure glRasterPos4f(x, y, z, w: GLfloat); external dllname; +procedure glRasterPos4fv(const v: PGLfloat); external dllname; +procedure glRasterPos4i(x, y, z, w: GLint); external dllname; +procedure glRasterPos4iv(const v: PGLint); external dllname; +procedure glRasterPos4s(x, y, z, w: GLshort); external dllname; +procedure glRasterPos4sv(const v: PGLshort); external dllname; +procedure glReadBuffer(mode: GLenum); external dllname; +procedure glReadPixels(x, y: GLint; width, height: GLsizei; format, atype: GLenum; pixels: Pointer); external dllname; +procedure glRectd(x1, y1, x2, y2: GLdouble); external dllname; +procedure glRectdv(const v1: PGLdouble; const v2: PGLdouble); external dllname; +procedure glRectf(x1, y1, x2, y2: GLfloat); external dllname; +procedure glRectfv(const v1: PGLfloat; const v2: PGLfloat); external dllname; +procedure glRecti(x1, y1, x2, y2: GLint); external dllname; +procedure glRectiv(const v1: PGLint; const v2: PGLint); external dllname; +procedure glRects(x1, y1, x2, y2: GLshort); external dllname; +procedure glRectsv(const v1: PGLshort; const v2: PGLshort); external dllname; +function glRenderMode(mode: GLint): GLint; external dllname; +procedure glRotated(angle, x, y, z: GLdouble); external dllname; +procedure glRotatef(angle, x, y, z: GLfloat); external dllname; +procedure glScaled(x, y, z: GLdouble); external dllname; +procedure glScalef(x, y, z: GLfloat); external dllname; +procedure glScissor(x, y: GLint; width, height: GLsizei); external dllname; +procedure glSelectBuffer(size: GLsizei; buffer: PGLuint); external dllname; +procedure glShadeModel(mode: GLenum); external dllname; +procedure glStencilFunc(func: GLenum; ref: GLint; mask: GLuint); external dllname; +procedure glStencilMask(mask: GLuint); external dllname; +procedure glStencilOp(fail, zfail, zpass: GLenum); external dllname; +procedure glTexCoord1d(s: GLdouble); external dllname; +procedure glTexCoord1dv(const v: PGLdouble); external dllname; +procedure glTexCoord1f(s: GLfloat); external dllname; +procedure glTexCoord1fv(const v: PGLfloat); external dllname; +procedure glTexCoord1i(s: GLint); external dllname; +procedure glTexCoord1iv(const v: PGLint); external dllname; +procedure glTexCoord1s(s: GLshort); external dllname; +procedure glTexCoord1sv(const v: PGLshort); external dllname; +procedure glTexCoord2d(s, t: GLdouble); external dllname; +procedure glTexCoord2dv(const v: PGLdouble); external dllname; +procedure glTexCoord2f(s, t: GLfloat); external dllname; +procedure glTexCoord2fv(const v: PGLfloat); external dllname; +procedure glTexCoord2i(s, t: GLint); external dllname; +procedure glTexCoord2iv(const v: PGLint); external dllname; +procedure glTexCoord2s(s, t: GLshort); external dllname; +procedure glTexCoord2sv(const v: PGLshort); external dllname; +procedure glTexCoord3d(s, t, r: GLdouble); external dllname; +procedure glTexCoord3dv(const v: PGLdouble); external dllname; +procedure glTexCoord3f(s, t, r: GLfloat); external dllname; +procedure glTexCoord3fv(const v: PGLfloat); external dllname; +procedure glTexCoord3i(s, t, r: GLint); external dllname; +procedure glTexCoord3iv(const v: PGLint); external dllname; +procedure glTexCoord3s(s, t, r: GLshort); external dllname; +procedure glTexCoord3sv(const v: PGLshort); external dllname; +procedure glTexCoord4d(s, t, r, q: GLdouble); external dllname; +procedure glTexCoord4dv(const v: PGLdouble); external dllname; +procedure glTexCoord4f(s, t, r, q: GLfloat); external dllname; +procedure glTexCoord4fv(const v: PGLfloat); external dllname; +procedure glTexCoord4i(s, t, r, q: GLint); external dllname; +procedure glTexCoord4iv(const v: PGLint); external dllname; +procedure glTexCoord4s(s, t, r, q: GLshort); external dllname; +procedure glTexCoord4sv(const v: PGLshort); external dllname; +procedure glTexCoordPointer(size: GLint; atype: GLenum; stride: GLsizei; const pointer: Pointer); external dllname; +procedure glTexEnvf(target: GLenum; pname: GLenum; param: GLfloat); external dllname; +procedure glTexEnvfv(target: GLenum; pname: GLenum; const params: PGLfloat); external dllname; +procedure glTexEnvi(target: GLenum; pname: GLenum; param: GLint); external dllname; +procedure glTexEnviv(target: GLenum; pname: GLenum; const params: PGLint); external dllname; +procedure glTexGend(coord: GLenum; pname: GLenum; param: GLdouble); external dllname; +procedure glTexGendv(coord: GLenum; pname: GLenum; const params: PGLdouble); external dllname; +procedure glTexGenf(coord: GLenum; pname: GLenum; param: GLfloat); external dllname; +procedure glTexGenfv(coord: GLenum; pname: GLenum; const params: PGLfloat); external dllname; +procedure glTexGeni(coord: GLenum; pname: GLenum; param: GLint); external dllname; +procedure glTexGeniv(coord: GLenum; pname: GLenum; const params: PGLint); external dllname; +procedure glTexImage1D(target: GLenum; level, internalformat: GLint; width: GLsizei; border: GLint; format, atype: GLenum; const pixels: Pointer); external dllname; +procedure glTexImage2D(target: GLenum; level, internalformat: GLint; width, height: GLsizei; border: GLint; format, atype: GLenum; const pixels: Pointer); external dllname; +procedure glTexParameterf(target: GLenum; pname: GLenum; param: GLfloat); external dllname; +procedure glTexParameterfv(target: GLenum; pname: GLenum; const params: PGLfloat); external dllname; +procedure glTexParameteri(target: GLenum; pname: GLenum; param: GLint); external dllname; +procedure glTexParameteriv(target: GLenum; pname: GLenum; const params: PGLint); external dllname; +procedure glTexSubImage1D(target: GLenum; level, xoffset: GLint; width: GLsizei; format, atype: GLenum; const pixels: Pointer); external dllname; +procedure glTexSubImage2D(target: GLenum; level, xoffset, yoffset: GLint; width, height: GLsizei; format, atype: GLenum; const pixels: Pointer); external dllname; +procedure glTranslated(x, y, z: GLdouble); external dllname; +procedure glTranslatef(x, y, z: GLfloat); external dllname; +procedure glVertex2d(x, y: GLdouble); external dllname; +procedure glVertex2dv(const v: PGLdouble); external dllname; +procedure glVertex2f(x, y: GLfloat); external dllname; +procedure glVertex2fv(const v: PGLfloat); external dllname; +procedure glVertex2i(x, y: GLint); external dllname; +procedure glVertex2iv(const v: PGLint); external dllname; +procedure glVertex2s(x, y: GLshort); external dllname; +procedure glVertex2sv(const v: PGLshort); external dllname; +procedure glVertex3d(x, y, z: GLdouble); external dllname; +procedure glVertex3dv(const v: PGLdouble); external dllname; +procedure glVertex3f(x, y, z: GLfloat); external dllname; +procedure glVertex3fv(const v: PGLfloat); external dllname; +procedure glVertex3i(x, y, z: GLint); external dllname; +procedure glVertex3iv(const v: PGLint); external dllname; +procedure glVertex3s(x, y, z: GLshort); external dllname; +procedure glVertex3sv(const v: PGLshort); external dllname; +procedure glVertex4d(x, y, z, w: GLdouble); external dllname; +procedure glVertex4dv(const v: PGLdouble); external dllname; +procedure glVertex4f(x, y, z, w: GLfloat); external dllname; +procedure glVertex4fv(const v: PGLfloat); external dllname; +procedure glVertex4i(x, y, z, w: GLint); external dllname; +procedure glVertex4iv(const v: PGLint); external dllname; +procedure glVertex4s(x, y, z, w: GLshort); external dllname; +procedure glVertex4sv(const v: PGLshort); external dllname; +procedure glVertexPointer(size: GLint; atype: GLenum; stride: GLsizei; const pointer: Pointer); external dllname; +procedure glViewport(x, y: GLint; width, height: GLsizei); external dllname; + +type + // EXT_vertex_array + PFNGLARRAYELEMENTEXTPROC = procedure(i: GLint); + PFNGLDRAWARRAYSEXTPROC = procedure(mode: GLenum; first: GLint; count: GLsizei); + PFNGLVERTEXPOINTEREXTPROC = procedure(size: GLint; atype: GLenum; + stride, count: GLsizei; const pointer: Pointer); + PFNGLNORMALPOINTEREXTPROC = procedure(atype: GLenum; stride, count: GLsizei; + const pointer: Pointer); + PFNGLCOLORPOINTEREXTPROC = procedure(size: GLint; atype: GLenum; stride, count: GLsizei; + const pointer: Pointer); + PFNGLINDEXPOINTEREXTPROC = procedure(atype: GLenum; stride, count: GLsizei; + const pointer: Pointer); + PFNGLTEXCOORDPOINTEREXTPROC = procedure(size: GLint; atype: GLenum; + stride, count: GLsizei; const pointer: Pointer); + PFNGLEDGEFLAGPOINTEREXTPROC = procedure(stride, count: GLsizei; + const pointer: PGLboolean); + PFNGLGETPOINTERVEXTPROC = procedure(pname: GLenum; params: Pointer); + PFNGLARRAYELEMENTARRAYEXTPROC = procedure(mode: GLenum; count: GLsizei; + const pi: Pointer); + // WIN_swap_hint + PFNGLADDSWAPHINTRECTWINPROC = procedure(x, y: GLint; width, height: GLsizei); + + // EXT_paletted_texture + PFNGLCOLORTABLEEXTPROC = procedure(target, internalFormat: GLenum; width: GLsizei; + format, atype: GLenum; const data: Pointer); + PFNGLCOLORSUBTABLEEXTPROC = procedure(target: GLenum; start, count: GLsizei; + format, atype: GLenum; const data: Pointer); + PFNGLGETCOLORTABLEEXTPROC = procedure(target, format, atype: GLenum; data: Pointer); + PFNGLGETCOLORTABLEPARAMETERIVEXTPROC = procedure(target, pname: GLenum; params: PGLint); + PFNGLGETCOLORTABLEPARAMETERFVEXTPROC = procedure(target, pname: GLenum; params: PGLfloat); + +implementation + +end. diff --git a/lib/base/opengl/glext.nim b/lib/base/opengl/glext.nim new file mode 100644 index 000000000..0a2138584 --- /dev/null +++ b/lib/base/opengl/glext.nim @@ -0,0 +1,4175 @@ +# +# +# Adaption of the delphi3d.net OpenGL units to FreePascal +# Sebastian Guenther (sg@freepascal.org) in 2002 +# These units are free to use +# +# + +#************************************************* +# * OpenGL extension loading library * +# * Generated by MetaGLext, written by Tom Nuydens * +# * (tom@delphi3d.net -- http://www.delphi3d.net * +# ************************************************* +#*** Generated on 10/11/2002 + +when defined(windows): + {.push callconv: stdcall.} +else: + {.push callconv: cdecl.} + +import + gl + +type + GLcharARB* = Char + TGLcharARB* = GLcharARB + PGLcharARB* = ptr GLcharARB + GLhandleARB* = int + TGLhandleARB* = GLhandleARB + PGLhandleARB* = ptr GLhandleARB + GLintptr* = int + TGLintptr* = GLintptr + PGLintptr* = ptr GLintptr + GLsizeiptr* = int + TGLsizeiptr* = GLsizeiptr + PGLsizeiptr* = ptr GLsizeiptr + GLchar* = Char + TGLchar* = GLchar + PGLchar* = cstring #***** GL_version_1_2 *****// + +const + GL_UNSIGNED_BYTE_3_3_2* = 0x00008032 + GL_UNSIGNED_SHORT_4_4_4_4* = 0x00008033 + GL_UNSIGNED_SHORT_5_5_5_1* = 0x00008034 + GL_UNSIGNED_INT_8_8_8_8* = 0x00008035 + GL_UNSIGNED_INT_10_10_10_2* = 0x00008036 + GL_RESCALE_NORMAL* = 0x0000803A + GL_UNSIGNED_BYTE_2_3_3_REV* = 0x00008362 + GL_UNSIGNED_SHORT_5_6_5* = 0x00008363 + GL_UNSIGNED_SHORT_5_6_5_REV* = 0x00008364 + GL_UNSIGNED_SHORT_4_4_4_4_REV* = 0x00008365 + GL_UNSIGNED_SHORT_1_5_5_5_REV* = 0x00008366 + GL_UNSIGNED_INT_8_8_8_8_REV* = 0x00008367 + GL_UNSIGNED_INT_2_10_10_10_REV* = 0x00008368 + GL_BGR* = 0x000080E0 + GL_BGRA* = 0x000080E1 + GL_MAX_ELEMENTS_VERTICES* = 0x000080E8 + GL_MAX_ELEMENTS_INDICES* = 0x000080E9 + GL_CLAMP_TO_EDGE* = 0x0000812F + GL_TEXTURE_MIN_LOD* = 0x0000813A + GL_TEXTURE_MAX_LOD* = 0x0000813B + GL_TEXTURE_BASE_LEVEL* = 0x0000813C + GL_TEXTURE_MAX_LEVEL* = 0x0000813D + GL_LIGHT_MODEL_COLOR_CONTROL* = 0x000081F8 + GL_SINGLE_COLOR* = 0x000081F9 + GL_SEPARATE_SPECULAR_COLOR* = 0x000081FA + GL_SMOOTH_POINT_SIZE_RANGE* = 0x00000B12 + GL_SMOOTH_POINT_SIZE_GRANULARITY* = 0x00000B13 + GL_SMOOTH_LINE_WIDTH_RANGE* = 0x00000B22 + GL_SMOOTH_LINE_WIDTH_GRANULARITY* = 0x00000B23 + GL_ALIASED_POINT_SIZE_RANGE* = 0x0000846D + GL_ALIASED_LINE_WIDTH_RANGE* = 0x0000846E + GL_PACK_SKIP_IMAGES* = 0x0000806B + GL_PACK_IMAGE_HEIGHT* = 0x0000806C + GL_UNPACK_SKIP_IMAGES* = 0x0000806D + GL_UNPACK_IMAGE_HEIGHT* = 0x0000806E + GL_TEXTURE_3D* = 0x0000806F + GL_PROXY_TEXTURE_3D* = 0x00008070 + GL_TEXTURE_DEPTH* = 0x00008071 + GL_TEXTURE_WRAP_R* = 0x00008072 + GL_MAX_3D_TEXTURE_SIZE* = 0x00008073 + +proc glBlendColor*(red: TGLclampf, green: TGLclampf, blue: TGLclampf, + alpha: TGLclampf){.dynlib: dllname, importc.} +proc glBlendEquation*(mode: TGLenum){.dynlib: dllname, importc.} +proc glDrawRangeElements*(mode: TGLenum, start: TGLuint, theend: TGLuint, + count: TGLsizei, thetype: TGLenum, indices: PGLvoid){. + dynlib: dllname, importc.} +proc glColorTable*(target: TGLenum, internalformat: TGLenum, width: TGLsizei, + format: TGLenum, thetype: TGLenum, table: PGLvoid){. + dynlib: dllname, importc.} +proc glColorTableParameterfv*(target: TGLenum, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc.} +proc glColorTableParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glCopyColorTable*(target: TGLenum, internalformat: TGLenum, x: TGLint, + y: TGLint, width: TGLsizei){.dynlib: dllname, importc.} +proc glGetColorTable*(target: TGLenum, format: TGLenum, thetype: TGLenum, + table: PGLvoid){.dynlib: dllname, importc.} +proc glGetColorTableParameterfv*(target: TGLenum, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc.} +proc glGetColorTableParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glColorSubTable*(target: TGLenum, start: TGLsizei, count: TGLsizei, + format: TGLenum, thetype: TGLenum, data: PGLvoid){. + dynlib: dllname, importc.} +proc glCopyColorSubTable*(target: TGLenum, start: TGLsizei, x: TGLint, y: TGLint, + width: TGLsizei){.dynlib: dllname, importc.} +proc glConvolutionFilter1D*(target: TGLenum, internalformat: TGLenum, + width: TGLsizei, format: TGLenum, thetype: TGLenum, + image: PGLvoid){.dynlib: dllname, importc.} +proc glConvolutionFilter2D*(target: TGLenum, internalformat: TGLenum, + width: TGLsizei, height: TGLsizei, format: TGLenum, + thetype: TGLenum, image: PGLvoid){.dynlib: dllname, + importc.} +proc glConvolutionParameterf*(target: TGLenum, pname: TGLenum, params: TGLfloat){. + dynlib: dllname, importc.} +proc glConvolutionParameterfv*(target: TGLenum, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc.} +proc glConvolutionParameteri*(target: TGLenum, pname: TGLenum, params: TGLint){. + dynlib: dllname, importc.} +proc glConvolutionParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glCopyConvolutionFilter1D*(target: TGLenum, internalformat: TGLenum, + x: TGLint, y: TGLint, width: TGLsizei){. + dynlib: dllname, importc.} +proc glCopyConvolutionFilter2D*(target: TGLenum, internalformat: TGLenum, + x: TGLint, y: TGLint, width: TGLsizei, + height: TGLsizei){.dynlib: dllname, importc.} +proc glGetConvolutionFilter*(target: TGLenum, format: TGLenum, thetype: TGLenum, + image: PGLvoid){.dynlib: dllname, importc.} +proc glGetConvolutionParameterfv*(target: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, importc.} +proc glGetConvolutionParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glGetSeparableFilter*(target: TGLenum, format: TGLenum, thetype: TGLenum, + row: PGLvoid, column: PGLvoid, span: PGLvoid){. + dynlib: dllname, importc.} +proc glSeparableFilter2D*(target: TGLenum, internalformat: TGLenum, + width: TGLsizei, height: TGLsizei, format: TGLenum, + thetype: TGLenum, row: PGLvoid, column: PGLvoid){. + dynlib: dllname, importc.} +proc glGetHistogram*(target: TGLenum, reset: TGLboolean, format: TGLenum, + thetype: TGLenum, values: PGLvoid){.dynlib: dllname, importc.} +proc glGetHistogramParameterfv*(target: TGLenum, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc.} +proc glGetHistogramParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glGetMinmax*(target: TGLenum, reset: TGLboolean, format: TGLenum, + thetype: TGLenum, values: PGLvoid){.dynlib: dllname, importc.} +proc glGetMinmaxParameterfv*(target: TGLenum, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc.} +proc glGetMinmaxParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glHistogram*(target: TGLenum, width: TGLsizei, internalformat: TGLenum, + sink: TGLboolean){.dynlib: dllname, importc.} +proc glMinmax*(target: TGLenum, internalformat: TGLenum, sink: TGLboolean){. + dynlib: dllname, importc.} +proc glResetHistogram*(target: TGLenum){.dynlib: dllname, importc.} +proc glResetMinmax*(target: TGLenum){.dynlib: dllname, importc.} +proc glTexImage3D*(target: TGLenum, level: TGLint, internalformat: TGLint, + width: TGLsizei, height: TGLsizei, depth: TGLsizei, + border: TGLint, format: TGLenum, thetype: TGLenum, + pixels: PGLvoid){.dynlib: dllname, importc.} +proc glTexSubImage3D*(target: TGLenum, level: TGLint, xoffset: TGLint, + yoffset: TGLint, zoffset: TGLint, width: TGLsizei, + height: TGLsizei, depth: TGLsizei, format: TGLenum, + thetype: TGLenum, pixels: PGLvoid){.dynlib: dllname, + importc.} +proc glCopyTexSubImage3D*(target: TGLenum, level: TGLint, xoffset: TGLint, + yoffset: TGLint, zoffset: TGLint, x: TGLint, y: TGLint, + width: TGLsizei, height: TGLsizei){.dynlib: dllname, + importc.} + + +proc glActiveTextureARB*(texture: TGLenum){.dynlib: dllname, importc.} +proc glClientActiveTextureARB*(texture: TGLenum){.dynlib: dllname, importc.} +proc glMultiTexCoord1dARB*(target: TGLenum, s: TGLdouble){.dynlib: dllname, + importc.} +proc glMultiTexCoord1dvARB*(target: TGLenum, v: PGLdouble){.dynlib: dllname, + importc.} +proc glMultiTexCoord1fARB*(target: TGLenum, s: TGLfloat){.dynlib: dllname, importc.} +proc glMultiTexCoord1fvARB*(target: TGLenum, v: PGLfloat){.dynlib: dllname, + importc.} +proc glMultiTexCoord1iARB*(target: TGLenum, s: TGLint){.dynlib: dllname, importc.} +proc glMultiTexCoord1ivARB*(target: TGLenum, v: PGLint){.dynlib: dllname, importc.} +proc glMultiTexCoord1sARB*(target: TGLenum, s: TGLshort){.dynlib: dllname, importc.} +proc glMultiTexCoord1svARB*(target: TGLenum, v: PGLshort){.dynlib: dllname, + importc.} +proc glMultiTexCoord2dARB*(target: TGLenum, s: TGLdouble, t: TGLdouble){. + dynlib: dllname, importc.} +proc glMultiTexCoord2dvARB*(target: TGLenum, v: PGLdouble){.dynlib: dllname, + importc.} +proc glMultiTexCoord2fARB*(target: TGLenum, s: TGLfloat, t: TGLfloat){. + dynlib: dllname, importc.} +proc glMultiTexCoord2fvARB*(target: TGLenum, v: PGLfloat){.dynlib: dllname, + importc.} +proc glMultiTexCoord2iARB*(target: TGLenum, s: TGLint, t: TGLint){.dynlib: dllname, + importc.} +proc glMultiTexCoord2ivARB*(target: TGLenum, v: PGLint){.dynlib: dllname, importc.} +proc glMultiTexCoord2sARB*(target: TGLenum, s: TGLshort, t: TGLshort){. + dynlib: dllname, importc.} +proc glMultiTexCoord2svARB*(target: TGLenum, v: PGLshort){.dynlib: dllname, + importc.} +proc glMultiTexCoord3dARB*(target: TGLenum, s: TGLdouble, t: TGLdouble, r: TGLdouble){. + dynlib: dllname, importc.} +proc glMultiTexCoord3dvARB*(target: TGLenum, v: PGLdouble){.dynlib: dllname, + importc.} +proc glMultiTexCoord3fARB*(target: TGLenum, s: TGLfloat, t: TGLfloat, r: TGLfloat){. + dynlib: dllname, importc.} +proc glMultiTexCoord3fvARB*(target: TGLenum, v: PGLfloat){.dynlib: dllname, + importc.} +proc glMultiTexCoord3iARB*(target: TGLenum, s: TGLint, t: TGLint, r: TGLint){. + dynlib: dllname, importc.} +proc glMultiTexCoord3ivARB*(target: TGLenum, v: PGLint){.dynlib: dllname, importc.} +proc glMultiTexCoord3sARB*(target: TGLenum, s: TGLshort, t: TGLshort, r: TGLshort){. + dynlib: dllname, importc.} +proc glMultiTexCoord3svARB*(target: TGLenum, v: PGLshort){.dynlib: dllname, + importc.} +proc glMultiTexCoord4dARB*(target: TGLenum, s: TGLdouble, t: TGLdouble, + r: TGLdouble, q: TGLdouble){.dynlib: dllname, importc.} +proc glMultiTexCoord4dvARB*(target: TGLenum, v: PGLdouble){.dynlib: dllname, + importc.} +proc glMultiTexCoord4fARB*(target: TGLenum, s: TGLfloat, t: TGLfloat, r: TGLfloat, + q: TGLfloat){.dynlib: dllname, importc.} +proc glMultiTexCoord4fvARB*(target: TGLenum, v: PGLfloat){.dynlib: dllname, + importc.} +proc glMultiTexCoord4iARB*(target: TGLenum, s: TGLint, t: TGLint, r: TGLint, + q: TGLint){.dynlib: dllname, importc.} +proc glMultiTexCoord4ivARB*(target: TGLenum, v: PGLint){.dynlib: dllname, importc.} +proc glMultiTexCoord4sARB*(target: TGLenum, s: TGLshort, t: TGLshort, r: TGLshort, + q: TGLshort){.dynlib: dllname, importc.} +proc glMultiTexCoord4svARB*(target: TGLenum, v: PGLshort){.dynlib: dllname, + importc.} + +proc glSampleCoverageARB*(value: TGLclampf, invert: TGLboolean){.dynlib: dllname, + importc.} + #***** GL_ARB_texture_env_add *****// + + +proc glWeightbvARB*(size: TGLint, weights: PGLbyte){.dynlib: dllname, importc.} +proc glWeightsvARB*(size: TGLint, weights: PGLshort){.dynlib: dllname, importc.} +proc glWeightivARB*(size: TGLint, weights: PGLint){.dynlib: dllname, importc.} +proc glWeightfvARB*(size: TGLint, weights: PGLfloat){.dynlib: dllname, importc.} +proc glWeightdvARB*(size: TGLint, weights: PGLdouble){.dynlib: dllname, importc.} +proc glWeightvARB*(size: TGLint, weights: PGLdouble){.dynlib: dllname, importc.} +proc glWeightubvARB*(size: TGLint, weights: PGLubyte){.dynlib: dllname, importc.} +proc glWeightusvARB*(size: TGLint, weights: PGLushort){.dynlib: dllname, importc.} +proc glWeightuivARB*(size: TGLint, weights: PGLuint){.dynlib: dllname, importc.} +proc glWeightPointerARB*(size: TGLint, thetype: TGLenum, stride: TGLsizei, + pointer: PGLvoid){.dynlib: dllname, importc.} +proc glVertexBlendARB*(count: TGLint){.dynlib: dllname, importc.} + + + +proc glVertexAttrib1sARB*(index: TGLuint, x: TGLshort){.dynlib: dllname, importc.} +proc glVertexAttrib1fARB*(index: TGLuint, x: TGLfloat){.dynlib: dllname, importc.} +proc glVertexAttrib1dARB*(index: TGLuint, x: TGLdouble){.dynlib: dllname, importc.} +proc glVertexAttrib2sARB*(index: TGLuint, x: TGLshort, y: TGLshort){. + dynlib: dllname, importc.} +proc glVertexAttrib2fARB*(index: TGLuint, x: TGLfloat, y: TGLfloat){. + dynlib: dllname, importc.} +proc glVertexAttrib2dARB*(index: TGLuint, x: TGLdouble, y: TGLdouble){. + dynlib: dllname, importc.} +proc glVertexAttrib3sARB*(index: TGLuint, x: TGLshort, y: TGLshort, z: TGLshort){. + dynlib: dllname, importc.} +proc glVertexAttrib3fARB*(index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat){. + dynlib: dllname, importc.} +proc glVertexAttrib3dARB*(index: TGLuint, x: TGLdouble, y: TGLdouble, z: TGLdouble){. + dynlib: dllname, importc.} +proc glVertexAttrib4sARB*(index: TGLuint, x: TGLshort, y: TGLshort, z: TGLshort, + w: TGLshort){.dynlib: dllname, importc.} +proc glVertexAttrib4fARB*(index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat, + w: TGLfloat){.dynlib: dllname, importc.} +proc glVertexAttrib4dARB*(index: TGLuint, x: TGLdouble, y: TGLdouble, z: TGLdouble, + w: TGLdouble){.dynlib: dllname, importc.} +proc glVertexAttrib4NubARB*(index: TGLuint, x: TGLubyte, y: TGLubyte, z: TGLubyte, + w: TGLubyte){.dynlib: dllname, importc.} +proc glVertexAttrib1svARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc.} +proc glVertexAttrib1fvARB*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc.} +proc glVertexAttrib1dvARB*(index: TGLuint, v: PGLdouble){.dynlib: dllname, + importc.} +proc glVertexAttrib2svARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc.} +proc glVertexAttrib2fvARB*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc.} +proc glVertexAttrib2dvARB*(index: TGLuint, v: PGLdouble){.dynlib: dllname, + importc.} +proc glVertexAttrib3svARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc.} +proc glVertexAttrib3fvARB*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc.} +proc glVertexAttrib3dvARB*(index: TGLuint, v: PGLdouble){.dynlib: dllname, + importc.} +proc glVertexAttrib4bvARB*(index: TGLuint, v: PGLbyte){.dynlib: dllname, importc.} +proc glVertexAttrib4svARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc.} +proc glVertexAttrib4ivARB*(index: TGLuint, v: PGLint){.dynlib: dllname, importc.} +proc glVertexAttrib4ubvARB*(index: TGLuint, v: PGLubyte){.dynlib: dllname, + importc.} +proc glVertexAttrib4usvARB*(index: TGLuint, v: PGLushort){.dynlib: dllname, + importc.} +proc glVertexAttrib4uivARB*(index: TGLuint, v: PGLuint){.dynlib: dllname, importc.} +proc glVertexAttrib4fvARB*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc.} +proc glVertexAttrib4dvARB*(index: TGLuint, v: PGLdouble){.dynlib: dllname, + importc.} +proc glVertexAttrib4NbvARB*(index: TGLuint, v: PGLbyte){.dynlib: dllname, importc.} +proc glVertexAttrib4NsvARB*(index: TGLuint, v: PGLshort){.dynlib: dllname, + importc.} +proc glVertexAttrib4NivARB*(index: TGLuint, v: PGLint){.dynlib: dllname, importc.} +proc glVertexAttrib4NubvARB*(index: TGLuint, v: PGLubyte){.dynlib: dllname, + importc.} +proc glVertexAttrib4NusvARB*(index: TGLuint, v: PGLushort){.dynlib: dllname, + importc.} +proc glVertexAttrib4NuivARB*(index: TGLuint, v: PGLuint){.dynlib: dllname, + importc.} +proc glVertexAttribPointerARB*(index: TGLuint, size: TGLint, thetype: TGLenum, + normalized: TGLboolean, stride: TGLsizei, + pointer: PGLvoid){.dynlib: dllname, importc.} +proc glEnableVertexAttribArrayARB*(index: TGLuint){.dynlib: dllname, importc.} +proc glDisableVertexAttribArrayARB*(index: TGLuint){.dynlib: dllname, importc.} +proc glProgramStringARB*(target: TGLenum, format: TGLenum, length: TGLsizei, + str: PGLvoid){.dynlib: dllname, importc.} +proc glBindProgramARB*(target: TGLenum, theProgram: TGLuint){.dynlib: dllname, + importc.} +proc glDeleteProgramsARB*(n: TGLsizei, programs: PGLuint){.dynlib: dllname, + importc.} +proc glGenProgramsARB*(n: TGLsizei, programs: PGLuint){.dynlib: dllname, importc.} +proc glProgramEnvParameter4dARB*(target: TGLenum, index: TGLuint, x: TGLdouble, + y: TGLdouble, z: TGLdouble, w: TGLdouble){. + dynlib: dllname, importc.} +proc glProgramEnvParameter4dvARB*(target: TGLenum, index: TGLuint, + params: PGLdouble){.dynlib: dllname, importc.} +proc glProgramEnvParameter4fARB*(target: TGLenum, index: TGLuint, x: TGLfloat, + y: TGLfloat, z: TGLfloat, w: TGLfloat){. + dynlib: dllname, importc.} +proc glProgramEnvParameter4fvARB*(target: TGLenum, index: TGLuint, + params: PGLfloat){.dynlib: dllname, importc.} +proc glProgramLocalParameter4dARB*(target: TGLenum, index: TGLuint, x: TGLdouble, + y: TGLdouble, z: TGLdouble, w: TGLdouble){. + dynlib: dllname, importc.} +proc glProgramLocalParameter4dvARB*(target: TGLenum, index: TGLuint, + params: PGLdouble){.dynlib: dllname, importc.} +proc glProgramLocalParameter4fARB*(target: TGLenum, index: TGLuint, x: TGLfloat, + y: TGLfloat, z: TGLfloat, w: TGLfloat){. + dynlib: dllname, importc.} +proc glProgramLocalParameter4fvARB*(target: TGLenum, index: TGLuint, + params: PGLfloat){.dynlib: dllname, importc.} +proc glGetProgramEnvParameterdvARB*(target: TGLenum, index: TGLuint, + params: PGLdouble){.dynlib: dllname, importc.} +proc glGetProgramEnvParameterfvARB*(target: TGLenum, index: TGLuint, + params: PGLfloat){.dynlib: dllname, importc.} +proc glGetProgramLocalParameterdvARB*(target: TGLenum, index: TGLuint, + params: PGLdouble){.dynlib: dllname, + importc.} +proc glGetProgramLocalParameterfvARB*(target: TGLenum, index: TGLuint, + params: PGLfloat){.dynlib: dllname, + importc.} +proc glGetProgramivARB*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glGetProgramStringARB*(target: TGLenum, pname: TGLenum, str: PGLvoid){. + dynlib: dllname, importc.} +proc glGetVertexAttribdvARB*(index: TGLuint, pname: TGLenum, params: PGLdouble){. + dynlib: dllname, importc.} +proc glGetVertexAttribfvARB*(index: TGLuint, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc.} +proc glGetVertexAttribivARB*(index: TGLuint, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glGetVertexAttribPointervARB*(index: TGLuint, pname: TGLenum, + pointer: PGLvoid){.dynlib: dllname, importc.} +proc glIsProgramARB*(theProgram: TGLuint): TGLboolean{.dynlib: dllname, importc.} + #***** GL_ARB_window_pos *****// +proc glWindowPos2dARB*(x: TGLdouble, y: TGLdouble){.dynlib: dllname, importc.} +proc glWindowPos2fARB*(x: TGLfloat, y: TGLfloat){.dynlib: dllname, importc.} +proc glWindowPos2iARB*(x: TGLint, y: TGLint){.dynlib: dllname, importc.} +proc glWindowPos2sARB*(x: TGLshort, y: TGLshort){.dynlib: dllname, importc.} +proc glWindowPos2dvARB*(p: PGLdouble){.dynlib: dllname, importc.} +proc glWindowPos2fvARB*(p: PGLfloat){.dynlib: dllname, importc.} +proc glWindowPos2ivARB*(p: PGLint){.dynlib: dllname, importc.} +proc glWindowPos2svARB*(p: PGLshort){.dynlib: dllname, importc.} +proc glWindowPos3dARB*(x: TGLdouble, y: TGLdouble, z: TGLdouble){.dynlib: dllname, + importc.} +proc glWindowPos3fARB*(x: TGLfloat, y: TGLfloat, z: TGLfloat){.dynlib: dllname, + importc.} +proc glWindowPos3iARB*(x: TGLint, y: TGLint, z: TGLint){.dynlib: dllname, importc.} +proc glWindowPos3sARB*(x: TGLshort, y: TGLshort, z: TGLshort){.dynlib: dllname, + importc.} +proc glWindowPos3dvARB*(p: PGLdouble){.dynlib: dllname, importc.} +proc glWindowPos3fvARB*(p: PGLfloat){.dynlib: dllname, importc.} +proc glWindowPos3ivARB*(p: PGLint){.dynlib: dllname, importc.} +proc glWindowPos3svARB*(p: PGLshort){.dynlib: dllname, importc.} + + + +proc glBlendEquationSeparate*(modeRGB: TGLenum, modeAlpha: TGLenum){. + dynlib: dllname, importc.} +proc glDrawBuffers*(n: TGLsizei, bufs: PGLenum){.dynlib: dllname, importc.} +proc glStencilOpSeparate*(face: TGLenum, sfail: TGLenum, dpfail: TGLenum, + dppass: TGLenum){.dynlib: dllname, importc.} +proc glStencilFuncSeparate*(frontfunc: TGLenum, backfunc: TGLenum, theRef: TGLint, + mask: TGLuint){.dynlib: dllname, importc.} +proc glStencilMaskSeparate*(face: TGLenum, mask: TGLuint){.dynlib: dllname, + importc.} +proc glAttachShader*(theProgram: TGLuint, shader: TGLuint){.dynlib: dllname, + importc.} +proc glBindAttribLocation*(theProgram: TGLuint, index: TGLuint, name: PGLchar){. + dynlib: dllname, importc.} +proc glCompileShader*(shader: TGLuint){.dynlib: dllname, importc.} +proc glCreateProgram*(): TGLuint{.dynlib: dllname, importc.} +proc glCreateShader*(thetype: TGLenum): TGLuint{.dynlib: dllname, importc.} +proc glDeleteProgram*(theProgram: TGLuint){.dynlib: dllname, importc.} +proc glDeleteShader*(shader: TGLuint){.dynlib: dllname, importc.} +proc glDetachShader*(theProgram: TGLuint, shader: TGLuint){.dynlib: dllname, + importc.} +proc glDisableVertexAttribArray*(index: TGLuint){.dynlib: dllname, importc.} +proc glEnableVertexAttribArray*(index: TGLuint){.dynlib: dllname, importc.} +proc glGetActiveAttrib*(theProgram: TGLuint, index: TGLuint, bufSize: TGLsizei, + len: PGLsizei, size: PGLint, thetype: PGLenum, + name: PGLchar){.dynlib: dllname, importc.} +proc glGetActiveUniform*(theProgram: TGLuint, index: TGLuint, bufSize: TGLsizei, + len: PGLsizei, size: PGLint, thetype: PGLenum, + name: PGLchar){.dynlib: dllname, importc.} +proc glGetAttachedShaders*(theProgram: TGLuint, maxCount: TGLsizei, + count: PGLsizei, obj: PGLuint){.dynlib: dllname, + importc.} +proc glGetAttribLocation*(theProgram: TGLuint, name: PGLchar): TGLint{. + dynlib: dllname, importc.} +proc glGetProgramiv*(theProgram: TGLuint, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glGetProgramInfoLog*(theProgram: TGLuint, bufSize: TGLsizei, len: PGLsizei, + infoLog: PGLchar){.dynlib: dllname, importc.} +proc glGetShaderiv*(shader: TGLuint, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glGetShaderInfoLog*(shader: TGLuint, bufSize: TGLsizei, len: PGLsizei, + infoLog: PGLchar){.dynlib: dllname, importc.} +proc glGetShaderSource*(shader: TGLuint, bufSize: TGLsizei, len: PGLsizei, + source: PGLchar){.dynlib: dllname, importc.} +proc glGetUniformLocation*(theProgram: TGLuint, name: PGLchar): TGLint{. + dynlib: dllname, importc.} +proc glGetUniformfv*(theProgram: TGLuint, location: TGLint, params: PGLfloat){. + dynlib: dllname, importc.} +proc glGetUniformiv*(theProgram: TGLuint, location: TGLint, params: PGLint){. + dynlib: dllname, importc.} +proc glGetVertexAttribdv*(index: TGLuint, pname: TGLenum, params: PGLdouble){. + dynlib: dllname, importc.} +proc glGetVertexAttribfv*(index: TGLuint, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc.} +proc glGetVertexAttribiv*(index: TGLuint, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glGetVertexAttribPointerv*(index: TGLuint, pname: TGLenum, pointer: PGLvoid){. + dynlib: dllname, importc.} +proc glIsProgram*(theProgram: TGLuint): TGLboolean{.dynlib: dllname, importc.} +proc glIsShader*(shader: TGLuint): TGLboolean{.dynlib: dllname, importc.} +proc glLinkProgram*(theProgram: TGLuint){.dynlib: dllname, importc.} +proc glShaderSource*(shader: TGLuint, count: TGLsizei, str: PGLchar, len: PGLint){. + dynlib: dllname, importc.} +proc glUseProgram*(theProgram: TGLuint){.dynlib: dllname, importc.} +proc glUniform1f*(location: TGLint, v0: TGLfloat){.dynlib: dllname, importc.} +proc glUniform2f*(location: TGLint, v0: TGLfloat, v1: TGLfloat){.dynlib: dllname, + importc.} +proc glUniform3f*(location: TGLint, v0: TGLfloat, v1: TGLfloat, v2: TGLfloat){. + dynlib: dllname, importc.} +proc glUniform4f*(location: TGLint, v0: TGLfloat, v1: TGLfloat, v2: TGLfloat, + v3: TGLfloat){.dynlib: dllname, importc.} +proc glUniform1i*(location: TGLint, v0: TGLint){.dynlib: dllname, importc.} +proc glUniform2i*(location: TGLint, v0: TGLint, v1: TGLint){.dynlib: dllname, + importc.} +proc glUniform3i*(location: TGLint, v0: TGLint, v1: TGLint, v2: TGLint){. + dynlib: dllname, importc.} +proc glUniform4i*(location: TGLint, v0: TGLint, v1: TGLint, v2: TGLint, v3: TGLint){. + dynlib: dllname, importc.} +proc glUniform1fv*(location: TGLint, count: TGLsizei, value: PGLfloat){. + dynlib: dllname, importc.} +proc glUniform2fv*(location: TGLint, count: TGLsizei, value: PGLfloat){. + dynlib: dllname, importc.} +proc glUniform3fv*(location: TGLint, count: TGLsizei, value: PGLfloat){. + dynlib: dllname, importc.} +proc glUniform4fv*(location: TGLint, count: TGLsizei, value: PGLfloat){. + dynlib: dllname, importc.} +proc glUniform1iv*(location: TGLint, count: TGLsizei, value: PGLint){. + dynlib: dllname, importc.} +proc glUniform2iv*(location: TGLint, count: TGLsizei, value: PGLint){. + dynlib: dllname, importc.} +proc glUniform3iv*(location: TGLint, count: TGLsizei, value: PGLint){. + dynlib: dllname, importc.} +proc glUniform4iv*(location: TGLint, count: TGLsizei, value: PGLint){. + dynlib: dllname, importc.} +proc glUniformMatrix2fv*(location: TGLint, count: TGLsizei, transpose: TGLboolean, + value: PGLfloat){.dynlib: dllname, importc.} +proc glUniformMatrix3fv*(location: TGLint, count: TGLsizei, transpose: TGLboolean, + value: PGLfloat){.dynlib: dllname, importc.} +proc glUniformMatrix4fv*(location: TGLint, count: TGLsizei, transpose: TGLboolean, + value: PGLfloat){.dynlib: dllname, importc.} +proc glValidateProgram*(theProgram: TGLuint){.dynlib: dllname, importc.} +proc glVertexAttrib1d*(index: TGLuint, x: TGLdouble){.dynlib: dllname, importc.} +proc glVertexAttrib1dv*(index: TGLuint, v: PGLdouble){.dynlib: dllname, importc.} +proc glVertexAttrib1f*(index: TGLuint, x: TGLfloat){.dynlib: dllname, importc.} +proc glVertexAttrib1fv*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc.} +proc glVertexAttrib1s*(index: TGLuint, x: TGLshort){.dynlib: dllname, importc.} +proc glVertexAttrib1sv*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc.} +proc glVertexAttrib2d*(index: TGLuint, x: TGLdouble, y: TGLdouble){. + dynlib: dllname, importc.} +proc glVertexAttrib2dv*(index: TGLuint, v: PGLdouble){.dynlib: dllname, importc.} +proc glVertexAttrib2f*(index: TGLuint, x: TGLfloat, y: TGLfloat){.dynlib: dllname, + importc.} +proc glVertexAttrib2fv*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc.} +proc glVertexAttrib2s*(index: TGLuint, x: TGLshort, y: TGLshort){.dynlib: dllname, + importc.} +proc glVertexAttrib2sv*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc.} +proc glVertexAttrib3d*(index: TGLuint, x: TGLdouble, y: TGLdouble, z: TGLdouble){. + dynlib: dllname, importc.} +proc glVertexAttrib3dv*(index: TGLuint, v: PGLdouble){.dynlib: dllname, importc.} +proc glVertexAttrib3f*(index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat){. + dynlib: dllname, importc.} +proc glVertexAttrib3fv*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc.} +proc glVertexAttrib3s*(index: TGLuint, x: TGLshort, y: TGLshort, z: TGLshort){. + dynlib: dllname, importc.} +proc glVertexAttrib3sv*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc.} +proc glVertexAttrib4Nbv*(index: TGLuint, v: PGLbyte){.dynlib: dllname, importc.} +proc glVertexAttrib4Niv*(index: TGLuint, v: PGLint){.dynlib: dllname, importc.} +proc glVertexAttrib4Nsv*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc.} +proc glVertexAttrib4Nub*(index: TGLuint, x: TGLubyte, y: TGLubyte, z: TGLubyte, + w: TGLubyte){.dynlib: dllname, importc.} +proc glVertexAttrib4Nubv*(index: TGLuint, v: PGLubyte){.dynlib: dllname, importc.} +proc glVertexAttrib4Nuiv*(index: TGLuint, v: PGLuint){.dynlib: dllname, importc.} +proc glVertexAttrib4Nusv*(index: TGLuint, v: PGLushort){.dynlib: dllname, importc.} +proc glVertexAttrib4bv*(index: TGLuint, v: PGLbyte){.dynlib: dllname, importc.} +proc glVertexAttrib4d*(index: TGLuint, x: TGLdouble, y: TGLdouble, z: TGLdouble, + w: TGLdouble){.dynlib: dllname, importc.} +proc glVertexAttrib4dv*(index: TGLuint, v: PGLdouble){.dynlib: dllname, importc.} +proc glVertexAttrib4f*(index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat, + w: TGLfloat){.dynlib: dllname, importc.} +proc glVertexAttrib4fv*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc.} +proc glVertexAttrib4iv*(index: TGLuint, v: PGLint){.dynlib: dllname, importc.} +proc glVertexAttrib4s*(index: TGLuint, x: TGLshort, y: TGLshort, z: TGLshort, + w: TGLshort){.dynlib: dllname, importc.} +proc glVertexAttrib4sv*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc.} +proc glVertexAttrib4ubv*(index: TGLuint, v: PGLubyte){.dynlib: dllname, importc.} +proc glVertexAttrib4uiv*(index: TGLuint, v: PGLuint){.dynlib: dllname, importc.} +proc glVertexAttrib4usv*(index: TGLuint, v: PGLushort){.dynlib: dllname, importc.} +proc glVertexAttribPointer*(index: TGLuint, size: TGLint, thetype: TGLenum, + normalized: TGLboolean, stride: TGLsizei, + pointer: PGLvoid){.dynlib: dllname, importc.} + +const + GL_CONSTANT_COLOR* = 0x00008001 + GL_ONE_MINUS_CONSTANT_COLOR* = 0x00008002 + GL_CONSTANT_ALPHA* = 0x00008003 + GL_ONE_MINUS_CONSTANT_ALPHA* = 0x00008004 + constGL_BLEND_COLOR* = 0x00008005 + GL_FUNC_ADD* = 0x00008006 + GL_MIN* = 0x00008007 + GL_MAX* = 0x00008008 + constGL_BLEND_EQUATION* = 0x00008009 + GL_FUNC_SUBTRACT* = 0x0000800A + GL_FUNC_REVERSE_SUBTRACT* = 0x0000800B + GL_CONVOLUTION_1D* = 0x00008010 + GL_CONVOLUTION_2D* = 0x00008011 + GL_SEPARABLE_2D* = 0x00008012 + GL_CONVOLUTION_BORDER_MODE* = 0x00008013 + GL_CONVOLUTION_FILTER_SCALE* = 0x00008014 + GL_CONVOLUTION_FILTER_BIAS* = 0x00008015 + GL_REDUCE* = 0x00008016 + GL_CONVOLUTION_FORMAT* = 0x00008017 + GL_CONVOLUTION_WIDTH* = 0x00008018 + GL_CONVOLUTION_HEIGHT* = 0x00008019 + GL_MAX_CONVOLUTION_WIDTH* = 0x0000801A + GL_MAX_CONVOLUTION_HEIGHT* = 0x0000801B + GL_POST_CONVOLUTION_RED_SCALE* = 0x0000801C + GL_POST_CONVOLUTION_GREEN_SCALE* = 0x0000801D + GL_POST_CONVOLUTION_BLUE_SCALE* = 0x0000801E + GL_POST_CONVOLUTION_ALPHA_SCALE* = 0x0000801F + GL_POST_CONVOLUTION_RED_BIAS* = 0x00008020 + GL_POST_CONVOLUTION_GREEN_BIAS* = 0x00008021 + GL_POST_CONVOLUTION_BLUE_BIAS* = 0x00008022 + GL_POST_CONVOLUTION_ALPHA_BIAS* = 0x00008023 + constGL_HISTOGRAM* = 0x00008024 + GL_PROXY_HISTOGRAM* = 0x00008025 + GL_HISTOGRAM_WIDTH* = 0x00008026 + GL_HISTOGRAM_FORMAT* = 0x00008027 + GL_HISTOGRAM_RED_SIZE* = 0x00008028 + GL_HISTOGRAM_GREEN_SIZE* = 0x00008029 + GL_HISTOGRAM_BLUE_SIZE* = 0x0000802A + GL_HISTOGRAM_ALPHA_SIZE* = 0x0000802B + GL_HISTOGRAM_LUMINANCE_SIZE* = 0x0000802C + GL_HISTOGRAM_SINK* = 0x0000802D + constGL_MINMAX* = 0x0000802E + GL_MINMAX_FORMAT* = 0x0000802F + GL_MINMAX_SINK* = 0x00008030 + GL_TABLE_TOO_LARGE* = 0x00008031 + GL_COLOR_MATRIX* = 0x000080B1 + GL_COLOR_MATRIX_STACK_DEPTH* = 0x000080B2 + GL_MAX_COLOR_MATRIX_STACK_DEPTH* = 0x000080B3 + GL_POST_COLOR_MATRIX_RED_SCALE* = 0x000080B4 + GL_POST_COLOR_MATRIX_GREEN_SCALE* = 0x000080B5 + GL_POST_COLOR_MATRIX_BLUE_SCALE* = 0x000080B6 + GL_POST_COLOR_MATRIX_ALPHA_SCALE* = 0x000080B7 + GL_POST_COLOR_MATRIX_RED_BIAS* = 0x000080B8 + GL_POST_COLOR_MATRIX_GREEN_BIAS* = 0x000080B9 + GL_POST_COLOR_MATRIX_BLUE_BIAS* = 0x000080BA + GL_POST_COLOR_MATIX_ALPHA_BIAS* = 0x000080BB + constGL_COLOR_TABLE* = 0x000080D0 + GL_POST_CONVOLUTION_COLOR_TABLE* = 0x000080D1 + GL_POST_COLOR_MATRIX_COLOR_TABLE* = 0x000080D2 + GL_PROXY_COLOR_TABLE* = 0x000080D3 + GL_PROXY_POST_CONVOLUTION_COLOR_TABLE* = 0x000080D4 + GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE* = 0x000080D5 + GL_COLOR_TABLE_SCALE* = 0x000080D6 + GL_COLOR_TABLE_BIAS* = 0x000080D7 + GL_COLOR_TABLE_FORMAT* = 0x000080D8 + GL_COLOR_TABLE_WIDTH* = 0x000080D9 + GL_COLOR_TABLE_RED_SIZE* = 0x000080DA + GL_COLOR_TABLE_GREEN_SIZE* = 0x000080DB + GL_COLOR_TABLE_BLUE_SIZE* = 0x000080DC + GL_COLOR_TABLE_ALPHA_SIZE* = 0x000080DD + GL_COLOR_TABLE_LUMINANCE_SIZE* = 0x000080DE + GL_COLOR_TABLE_INTENSITY_SIZE* = 0x000080DF + GL_IGNORE_BORDER* = 0x00008150 + GL_CONSTANT_BORDER* = 0x00008151 + GL_WRAP_BORDER* = 0x00008152 + GL_REPLICATE_BORDER* = 0x00008153 + GL_CONVOLUTION_BORDER_COLOR* = 0x00008154 + +proc glActiveTexture*(texture: TGLenum){.dynlib: dllname, importc.} +proc glClientActiveTexture*(texture: TGLenum){.dynlib: dllname, importc.} +proc glMultiTexCoord1d*(target: TGLenum, s: TGLdouble){.dynlib: dllname, importc.} +proc glMultiTexCoord1dv*(target: TGLenum, v: PGLdouble){.dynlib: dllname, importc.} +proc glMultiTexCoord1f*(target: TGLenum, s: TGLfloat){.dynlib: dllname, importc.} +proc glMultiTexCoord1fv*(target: TGLenum, v: PGLfloat){.dynlib: dllname, importc.} +proc glMultiTexCoord1i*(target: TGLenum, s: TGLint){.dynlib: dllname, importc.} +proc glMultiTexCoord1iv*(target: TGLenum, v: PGLint){.dynlib: dllname, importc.} +proc glMultiTexCoord1s*(target: TGLenum, s: TGLshort){.dynlib: dllname, importc.} +proc glMultiTexCoord1sv*(target: TGLenum, v: PGLshort){.dynlib: dllname, importc.} +proc glMultiTexCoord2d*(target: TGLenum, s: TGLdouble, t: TGLdouble){. + dynlib: dllname, importc.} +proc glMultiTexCoord2dv*(target: TGLenum, v: PGLdouble){.dynlib: dllname, importc.} +proc glMultiTexCoord2f*(target: TGLenum, s: TGLfloat, t: TGLfloat){. + dynlib: dllname, importc.} +proc glMultiTexCoord2fv*(target: TGLenum, v: PGLfloat){.dynlib: dllname, importc.} +proc glMultiTexCoord2i*(target: TGLenum, s: TGLint, t: TGLint){.dynlib: dllname, + importc.} +proc glMultiTexCoord2iv*(target: TGLenum, v: PGLint){.dynlib: dllname, importc.} +proc glMultiTexCoord2s*(target: TGLenum, s: TGLshort, t: TGLshort){. + dynlib: dllname, importc.} +proc glMultiTexCoord2sv*(target: TGLenum, v: PGLshort){.dynlib: dllname, importc.} +proc glMultiTexCoord3d*(target: TGLenum, s: TGLdouble, t: TGLdouble, r: TGLdouble){. + dynlib: dllname, importc.} +proc glMultiTexCoord3dv*(target: TGLenum, v: PGLdouble){.dynlib: dllname, importc.} +proc glMultiTexCoord3f*(target: TGLenum, s: TGLfloat, t: TGLfloat, r: TGLfloat){. + dynlib: dllname, importc.} +proc glMultiTexCoord3fv*(target: TGLenum, v: PGLfloat){.dynlib: dllname, importc.} +proc glMultiTexCoord3i*(target: TGLenum, s: TGLint, t: TGLint, r: TGLint){. + dynlib: dllname, importc.} +proc glMultiTexCoord3iv*(target: TGLenum, v: PGLint){.dynlib: dllname, importc.} +proc glMultiTexCoord3s*(target: TGLenum, s: TGLshort, t: TGLshort, r: TGLshort){. + dynlib: dllname, importc.} +proc glMultiTexCoord3sv*(target: TGLenum, v: PGLshort){.dynlib: dllname, importc.} +proc glMultiTexCoord4d*(target: TGLenum, s: TGLdouble, t: TGLdouble, r: TGLdouble, + q: TGLdouble){.dynlib: dllname, importc.} +proc glMultiTexCoord4dv*(target: TGLenum, v: PGLdouble){.dynlib: dllname, importc.} +proc glMultiTexCoord4f*(target: TGLenum, s: TGLfloat, t: TGLfloat, r: TGLfloat, + q: TGLfloat){.dynlib: dllname, importc.} +proc glMultiTexCoord4fv*(target: TGLenum, v: PGLfloat){.dynlib: dllname, importc.} +proc glMultiTexCoord4i*(target: TGLenum, s: TGLint, t: TGLint, r: TGLint, q: TGLint){. + dynlib: dllname, importc.} +proc glMultiTexCoord4iv*(target: TGLenum, v: PGLint){.dynlib: dllname, importc.} +proc glMultiTexCoord4s*(target: TGLenum, s: TGLshort, t: TGLshort, r: TGLshort, + q: TGLshort){.dynlib: dllname, importc.} +proc glMultiTexCoord4sv*(target: TGLenum, v: PGLshort){.dynlib: dllname, importc.} +proc glLoadTransposeMatrixf*(m: PGLfloat){.dynlib: dllname, importc.} +proc glLoadTransposeMatrixd*(m: PGLdouble){.dynlib: dllname, importc.} +proc glMultTransposeMatrixf*(m: PGLfloat){.dynlib: dllname, importc.} +proc glMultTransposeMatrixd*(m: PGLdouble){.dynlib: dllname, importc.} +proc glSampleCoverage*(value: TGLclampf, invert: TGLboolean){.dynlib: dllname, + importc.} +proc glCompressedTexImage3D*(target: TGLenum, level: TGLint, + internalformat: TGLenum, width: TGLsizei, + height: TGLsizei, depth: TGLsizei, border: TGLint, + imageSize: TGLsizei, data: PGLvoid){. + dynlib: dllname, importc.} +proc glCompressedTexImage2D*(target: TGLenum, level: TGLint, + internalformat: TGLenum, width: TGLsizei, + height: TGLsizei, border: TGLint, imageSize: TGLsizei, + data: PGLvoid){.dynlib: dllname, importc.} +proc glCompressedTexImage1D*(target: TGLenum, level: TGLint, + internalformat: TGLenum, width: TGLsizei, + border: TGLint, imageSize: TGLsizei, data: PGLvoid){. + dynlib: dllname, importc.} +proc glCompressedTexSubImage3D*(target: TGLenum, level: TGLint, xoffset: TGLint, + yoffset: TGLint, zoffset: TGLint, width: TGLsizei, + height: TGLsizei, depth: TGLsizei, format: TGLenum, + imageSize: TGLsizei, data: PGLvoid){. + dynlib: dllname, importc.} +proc glCompressedTexSubImage2D*(target: TGLenum, level: TGLint, xoffset: TGLint, + yoffset: TGLint, width: TGLsizei, height: TGLsizei, + format: TGLenum, imageSize: TGLsizei, + data: PGLvoid){.dynlib: dllname, importc.} +proc glCompressedTexSubImage1D*(target: TGLenum, level: TGLint, xoffset: TGLint, + width: TGLsizei, format: TGLenum, + imageSize: TGLsizei, data: PGLvoid){. + dynlib: dllname, importc.} +proc glGetCompressedTexImage*(target: TGLenum, level: TGLint, img: PGLvoid){. + dynlib: dllname, importc.} + + #***** GL_version_1_3 *****// +const + GL_TEXTURE0* = 0x000084C0 + GL_TEXTURE1* = 0x000084C1 + GL_TEXTURE2* = 0x000084C2 + GL_TEXTURE3* = 0x000084C3 + GL_TEXTURE4* = 0x000084C4 + GL_TEXTURE5* = 0x000084C5 + GL_TEXTURE6* = 0x000084C6 + GL_TEXTURE7* = 0x000084C7 + GL_TEXTURE8* = 0x000084C8 + GL_TEXTURE9* = 0x000084C9 + GL_TEXTURE10* = 0x000084CA + GL_TEXTURE11* = 0x000084CB + GL_TEXTURE12* = 0x000084CC + GL_TEXTURE13* = 0x000084CD + GL_TEXTURE14* = 0x000084CE + GL_TEXTURE15* = 0x000084CF + GL_TEXTURE16* = 0x000084D0 + GL_TEXTURE17* = 0x000084D1 + GL_TEXTURE18* = 0x000084D2 + GL_TEXTURE19* = 0x000084D3 + GL_TEXTURE20* = 0x000084D4 + GL_TEXTURE21* = 0x000084D5 + GL_TEXTURE22* = 0x000084D6 + GL_TEXTURE23* = 0x000084D7 + GL_TEXTURE24* = 0x000084D8 + GL_TEXTURE25* = 0x000084D9 + GL_TEXTURE26* = 0x000084DA + GL_TEXTURE27* = 0x000084DB + GL_TEXTURE28* = 0x000084DC + GL_TEXTURE29* = 0x000084DD + GL_TEXTURE30* = 0x000084DE + GL_TEXTURE31* = 0x000084DF + constGL_ACTIVE_TEXTURE* = 0x000084E0 + constGL_CLIENT_ACTIVE_TEXTURE* = 0x000084E1 + GL_MAX_TEXTURE_UNITS* = 0x000084E2 + GL_TRANSPOSE_MODELVIEW_MATRIX* = 0x000084E3 + GL_TRANSPOSE_PROJECTION_MATRIX* = 0x000084E4 + GL_TRANSPOSE_TEXTURE_MATRIX* = 0x000084E5 + GL_TRANSPOSE_COLOR_MATRIX* = 0x000084E6 + GL_MULTISAMPLE* = 0x0000809D + GL_SAMPLE_ALPHA_TO_COVERAGE* = 0x0000809E + GL_SAMPLE_ALPHA_TO_ONE* = 0x0000809F + constGL_SAMPLE_COVERAGE* = 0x000080A0 + GL_SAMPLE_BUFFERS* = 0x000080A8 + GL_SAMPLES* = 0x000080A9 + GL_SAMPLE_COVERAGE_VALUE* = 0x000080AA + GL_SAMPLE_COVERAGE_INVERT* = 0x000080AB + GL_MULTISAMPLE_BIT* = 0x20000000 + GL_NORMAL_MAP* = 0x00008511 + GL_REFLECTION_MAP* = 0x00008512 + GL_TEXTURE_CUBE_MAP* = 0x00008513 + GL_TEXTURE_BINDING_CUBE_MAP* = 0x00008514 + GL_TEXTURE_CUBE_MAP_POSITIVE_X* = 0x00008515 + GL_TEXTURE_CUBE_MAP_NEGATIVE_X* = 0x00008516 + GL_TEXTURE_CUBE_MAP_POSITIVE_Y* = 0x00008517 + GL_TEXTURE_CUBE_MAP_NEGATIVE_Y* = 0x00008518 + GL_TEXTURE_CUBE_MAP_POSITIVE_Z* = 0x00008519 + GL_TEXTURE_CUBE_MAP_NEGATIVE_Z* = 0x0000851A + GL_PROXY_TEXTURE_CUBE_MAP* = 0x0000851B + GL_MAX_CUBE_MAP_TEXTURE_SIZE* = 0x0000851C + GL_COMPRESSED_ALPHA* = 0x000084E9 + GL_COMPRESSED_LUMINANCE* = 0x000084EA + GL_COMPRESSED_LUMINANCE_ALPHA* = 0x000084EB + GL_COMPRESSED_INTENSITY* = 0x000084EC + GL_COMPRESSED_RGB* = 0x000084ED + GL_COMPRESSED_RGBA* = 0x000084EE + GL_TEXTURE_COMPRESSION_HINT* = 0x000084EF + GL_TEXTURE_COMPRESSED_IMAGE_SIZE* = 0x000086A0 + GL_TEXTURE_COMPRESSED* = 0x000086A1 + GL_NUM_COMPRESSED_TEXTURE_FORMATS* = 0x000086A2 + GL_COMPRESSED_TEXTURE_FORMATS* = 0x000086A3 + GL_CLAMP_TO_BORDER* = 0x0000812D + GL_CLAMP_TO_BORDER_SGIS* = 0x0000812D + GL_COMBINE* = 0x00008570 + GL_COMBINE_RGB* = 0x00008571 + GL_COMBINE_ALPHA* = 0x00008572 + GL_SOURCE0_RGB* = 0x00008580 + GL_SOURCE1_RGB* = 0x00008581 + GL_SOURCE2_RGB* = 0x00008582 + GL_SOURCE0_ALPHA* = 0x00008588 + GL_SOURCE1_ALPHA* = 0x00008589 + GL_SOURCE2_ALPHA* = 0x0000858A + GL_OPERAND0_RGB* = 0x00008590 + GL_OPERAND1_RGB* = 0x00008591 + GL_OPERAND2_RGB* = 0x00008592 + GL_OPERAND0_ALPHA* = 0x00008598 + GL_OPERAND1_ALPHA* = 0x00008599 + GL_OPERAND2_ALPHA* = 0x0000859A + GL_RGB_SCALE* = 0x00008573 + GL_ADD_SIGNED* = 0x00008574 + GL_INTERPOLATE* = 0x00008575 + GL_SUBTRACT* = 0x000084E7 + GL_CONSTANT* = 0x00008576 + GL_PRIMARY_COLOR* = 0x00008577 + GL_PREVIOUS* = 0x00008578 + GL_DOT3_RGB* = 0x000086AE + GL_DOT3_RGBA* = 0x000086AF + +const + GL_TEXTURE0_ARB* = 0x000084C0 + GL_TEXTURE1_ARB* = 0x000084C1 + GL_TEXTURE2_ARB* = 0x000084C2 + GL_TEXTURE3_ARB* = 0x000084C3 + GL_TEXTURE4_ARB* = 0x000084C4 + GL_TEXTURE5_ARB* = 0x000084C5 + GL_TEXTURE6_ARB* = 0x000084C6 + GL_TEXTURE7_ARB* = 0x000084C7 + GL_TEXTURE8_ARB* = 0x000084C8 + GL_TEXTURE9_ARB* = 0x000084C9 + GL_TEXTURE10_ARB* = 0x000084CA + GL_TEXTURE11_ARB* = 0x000084CB + GL_TEXTURE12_ARB* = 0x000084CC + GL_TEXTURE13_ARB* = 0x000084CD + GL_TEXTURE14_ARB* = 0x000084CE + GL_TEXTURE15_ARB* = 0x000084CF + GL_TEXTURE16_ARB* = 0x000084D0 + GL_TEXTURE17_ARB* = 0x000084D1 + GL_TEXTURE18_ARB* = 0x000084D2 + GL_TEXTURE19_ARB* = 0x000084D3 + GL_TEXTURE20_ARB* = 0x000084D4 + GL_TEXTURE21_ARB* = 0x000084D5 + GL_TEXTURE22_ARB* = 0x000084D6 + GL_TEXTURE23_ARB* = 0x000084D7 + GL_TEXTURE24_ARB* = 0x000084D8 + GL_TEXTURE25_ARB* = 0x000084D9 + GL_TEXTURE26_ARB* = 0x000084DA + GL_TEXTURE27_ARB* = 0x000084DB + GL_TEXTURE28_ARB* = 0x000084DC + GL_TEXTURE29_ARB* = 0x000084DD + GL_TEXTURE30_ARB* = 0x000084DE + GL_TEXTURE31_ARB* = 0x000084DF + constGL_ACTIVE_TEXTURE_ARB* = 0x000084E0 + constGL_CLIENT_ACTIVE_TEXTURE_ARB* = 0x000084E1 + GL_MAX_TEXTURE_UNITS_ARB* = 0x000084E2 + + #***** GL_ARB_transpose_matrix *****// +const + GL_TRANSPOSE_MODELVIEW_MATRIX_ARB* = 0x000084E3 + GL_TRANSPOSE_PROJECTION_MATRIX_ARB* = 0x000084E4 + GL_TRANSPOSE_TEXTURE_MATRIX_ARB* = 0x000084E5 + GL_TRANSPOSE_COLOR_MATRIX_ARB* = 0x000084E6 + +proc glLoadTransposeMatrixfARB*(m: PGLfloat){.dynlib: dllname, importc.} +proc glLoadTransposeMatrixdARB*(m: PGLdouble){.dynlib: dllname, importc.} +proc glMultTransposeMatrixfARB*(m: PGLfloat){.dynlib: dllname, importc.} +proc glMultTransposeMatrixdARB*(m: PGLdouble){.dynlib: dllname, importc.} + +const + WGL_SAMPLE_BUFFERS_ARB* = 0x00002041 + WGL_SAMPLES_ARB* = 0x00002042 + GL_MULTISAMPLE_ARB* = 0x0000809D + GL_SAMPLE_ALPHA_TO_COVERAGE_ARB* = 0x0000809E + GL_SAMPLE_ALPHA_TO_ONE_ARB* = 0x0000809F + constGL_SAMPLE_COVERAGE_ARB* = 0x000080A0 + GL_MULTISAMPLE_BIT_ARB* = 0x20000000 + GL_SAMPLE_BUFFERS_ARB* = 0x000080A8 + GL_SAMPLES_ARB* = 0x000080A9 + GL_SAMPLE_COVERAGE_VALUE_ARB* = 0x000080AA + GL_SAMPLE_COVERAGE_INVERT_ARB* = 0x000080AB + +const + GL_NORMAL_MAP_ARB* = 0x00008511 + GL_REFLECTION_MAP_ARB* = 0x00008512 + GL_TEXTURE_CUBE_MAP_ARB* = 0x00008513 + GL_TEXTURE_BINDING_CUBE_MAP_ARB* = 0x00008514 + GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB* = 0x00008515 + GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB* = 0x00008516 + GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB* = 0x00008517 + GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB* = 0x00008518 + GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB* = 0x00008519 + GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB* = 0x0000851A + GL_PROXY_TEXTURE_CUBE_MAP_ARB* = 0x0000851B + GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB* = 0x0000851C + +const + GL_DEPTH_COMPONENT16_ARB* = 0x000081A5 + GL_DEPTH_COMPONENT24_ARB* = 0x000081A6 + GL_DEPTH_COMPONENT32_ARB* = 0x000081A7 + GL_TEXTURE_DEPTH_SIZE_ARB* = 0x0000884A + GL_DEPTH_TEXTURE_MODE_ARB* = 0x0000884B + + #***** GL_ARB_point_parameters *****// +const + GL_POINT_SIZE_MIN_ARB* = 0x00008126 + GL_POINT_SIZE_MAX_ARB* = 0x00008127 + GL_POINT_FADE_THRESHOLD_SIZE_ARB* = 0x00008128 + GL_POINT_DISTANCE_ATTENUATION_ARB* = 0x00008129 + +proc glPointParameterfARB*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, + importc.} +proc glPointParameterfvARB*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, + importc.} +const + GL_TEXTURE_COMPARE_MODE_ARB* = 0x0000884C + GL_TEXTURE_COMPARE_FUNC_ARB* = 0x0000884D + GL_COMPARE_R_TO_TEXTURE_ARB* = 0x0000884E + +const + GL_TEXTURE_COMPARE_FAIL_VALUE_ARB* = 0x000080BF + GL_CLAMP_TO_BORDER_ARB* = 0x0000812D + +const + GL_COMPRESSED_ALPHA_ARB* = 0x000084E9 + GL_COMPRESSED_LUMINANCE_ARB* = 0x000084EA + GL_COMPRESSED_LUMINANCE_ALPHA_ARB* = 0x000084EB + GL_COMPRESSED_INTENSITY_ARB* = 0x000084EC + GL_COMPRESSED_RGB_ARB* = 0x000084ED + GL_COMPRESSED_RGBA_ARB* = 0x000084EE + GL_TEXTURE_COMPRESSION_HINT_ARB* = 0x000084EF + GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB* = 0x000086A0 + GL_TEXTURE_COMPRESSED_ARB* = 0x000086A1 + GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB* = 0x000086A2 + GL_COMPRESSED_TEXTURE_FORMATS_ARB* = 0x000086A3 + +proc glCompressedTexImage3DARB*(target: TGLenum, level: TGLint, + internalformat: TGLenum, width: TGLsizei, + height: TGLsizei, depth: TGLsizei, border: TGLint, + imageSize: TGLsizei, data: PGLvoid){. + dynlib: dllname, importc.} +proc glCompressedTexImage2DARB*(target: TGLenum, level: TGLint, + internalformat: TGLenum, width: TGLsizei, + height: TGLsizei, border: TGLint, + imageSize: TGLsizei, data: PGLvoid){. + dynlib: dllname, importc.} +proc glCompressedTexImage1DARB*(target: TGLenum, level: TGLint, + internalformat: TGLenum, width: TGLsizei, + border: TGLint, imageSize: TGLsizei, data: PGLvoid){. + dynlib: dllname, importc.} +proc glCompressedTexSubImage3DARB*(target: TGLenum, level: TGLint, xoffset: TGLint, + yoffset: TGLint, zoffset: TGLint, + width: TGLsizei, height: TGLsizei, + depth: TGLsizei, format: TGLenum, + imageSize: TGLsizei, data: PGLvoid){. + dynlib: dllname, importc.} +proc glCompressedTexSubImage2DARB*(target: TGLenum, level: TGLint, xoffset: TGLint, + yoffset: TGLint, width: TGLsizei, + height: TGLsizei, format: TGLenum, + imageSize: TGLsizei, data: PGLvoid){. + dynlib: dllname, importc.} +proc glCompressedTexSubImage1DARB*(target: TGLenum, level: TGLint, xoffset: TGLint, + width: TGLsizei, format: TGLenum, + imageSize: TGLsizei, data: PGLvoid){. + dynlib: dllname, importc.} +proc glGetCompressedTexImageARB*(target: TGLenum, lod: TGLint, img: PGLvoid){. + dynlib: dllname, importc.} + #***** GL_ARB_texture_env_combine *****// +const + GL_COMBINE_ARB* = 0x00008570 + GL_COMBINE_RGB_ARB* = 0x00008571 + GL_COMBINE_ALPHA_ARB* = 0x00008572 + GL_SOURCE0_RGB_ARB* = 0x00008580 + GL_SOURCE1_RGB_ARB* = 0x00008581 + GL_SOURCE2_RGB_ARB* = 0x00008582 + GL_SOURCE0_ALPHA_ARB* = 0x00008588 + GL_SOURCE1_ALPHA_ARB* = 0x00008589 + GL_SOURCE2_ALPHA_ARB* = 0x0000858A + GL_OPERAND0_RGB_ARB* = 0x00008590 + GL_OPERAND1_RGB_ARB* = 0x00008591 + GL_OPERAND2_RGB_ARB* = 0x00008592 + GL_OPERAND0_ALPHA_ARB* = 0x00008598 + GL_OPERAND1_ALPHA_ARB* = 0x00008599 + GL_OPERAND2_ALPHA_ARB* = 0x0000859A + GL_RGB_SCALE_ARB* = 0x00008573 + GL_ADD_SIGNED_ARB* = 0x00008574 + GL_INTERPOLATE_ARB* = 0x00008575 + GL_SUBTRACT_ARB* = 0x000084E7 + GL_CONSTANT_ARB* = 0x00008576 + GL_PRIMARY_COLOR_ARB* = 0x00008577 + GL_PREVIOUS_ARB* = 0x00008578 + + #***** GL_ARB_texture_env_crossbar *****// + #***** GL_ARB_texture_env_dot3 *****// +const + GL_DOT3_RGB_ARB* = 0x000086AE + GL_DOT3_RGBA_ARB* = 0x000086AF + + #***** GL_ARB_texture_mirrored_repeat *****// +const + GL_MIRRORED_REPEAT_ARB* = 0x00008370 + + #***** GL_ARB_vertex_blend *****// +const + GL_MAX_VERTEX_UNITS_ARB* = 0x000086A4 + GL_ACTIVE_VERTEX_UNITS_ARB* = 0x000086A5 + GL_WEIGHT_SUM_UNITY_ARB* = 0x000086A6 + constGL_VERTEX_BLEND_ARB* = 0x000086A7 + GL_MODELVIEW0_ARB* = 0x00001700 + GL_MODELVIEW1_ARB* = 0x0000850A + GL_MODELVIEW2_ARB* = 0x00008722 + GL_MODELVIEW3_ARB* = 0x00008723 + GL_MODELVIEW4_ARB* = 0x00008724 + GL_MODELVIEW5_ARB* = 0x00008725 + GL_MODELVIEW6_ARB* = 0x00008726 + GL_MODELVIEW7_ARB* = 0x00008727 + GL_MODELVIEW8_ARB* = 0x00008728 + GL_MODELVIEW9_ARB* = 0x00008729 + GL_MODELVIEW10_ARB* = 0x0000872A + GL_MODELVIEW11_ARB* = 0x0000872B + GL_MODELVIEW12_ARB* = 0x0000872C + GL_MODELVIEW13_ARB* = 0x0000872D + GL_MODELVIEW14_ARB* = 0x0000872E + GL_MODELVIEW15_ARB* = 0x0000872F + GL_MODELVIEW16_ARB* = 0x00008730 + GL_MODELVIEW17_ARB* = 0x00008731 + GL_MODELVIEW18_ARB* = 0x00008732 + GL_MODELVIEW19_ARB* = 0x00008733 + GL_MODELVIEW20_ARB* = 0x00008734 + GL_MODELVIEW21_ARB* = 0x00008735 + GL_MODELVIEW22_ARB* = 0x00008736 + GL_MODELVIEW23_ARB* = 0x00008737 + GL_MODELVIEW24_ARB* = 0x00008738 + GL_MODELVIEW25_ARB* = 0x00008739 + GL_MODELVIEW26_ARB* = 0x0000873A + GL_MODELVIEW27_ARB* = 0x0000873B + GL_MODELVIEW28_ARB* = 0x0000873C + GL_MODELVIEW29_ARB* = 0x0000873D + GL_MODELVIEW30_ARB* = 0x0000873E + GL_MODELVIEW31_ARB* = 0x0000873F + GL_CURRENT_WEIGHT_ARB* = 0x000086A8 + GL_WEIGHT_ARRAY_TYPE_ARB* = 0x000086A9 + GL_WEIGHT_ARRAY_STRIDE_ARB* = 0x000086AA + GL_WEIGHT_ARRAY_SIZE_ARB* = 0x000086AB + GL_WEIGHT_ARRAY_POINTER_ARB* = 0x000086AC + GL_WEIGHT_ARRAY_ARB* = 0x000086AD + +const + GL_VERTEX_PROGRAM_ARB* = 0x00008620 + GL_VERTEX_PROGRAM_POINT_SIZE_ARB* = 0x00008642 + GL_VERTEX_PROGRAM_TWO_SIDE_ARB* = 0x00008643 + GL_COLOR_SUM_ARB* = 0x00008458 + GL_PROGRAM_FORMAT_ASCII_ARB* = 0x00008875 + GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB* = 0x00008622 + GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB* = 0x00008623 + GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB* = 0x00008624 + GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB* = 0x00008625 + GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB* = 0x0000886A + GL_CURRENT_VERTEX_ATTRIB_ARB* = 0x00008626 + GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB* = 0x00008645 + GL_PROGRAM_LENGTH_ARB* = 0x00008627 + GL_PROGRAM_FORMAT_ARB* = 0x00008876 + GL_PROGRAM_BINDING_ARB* = 0x00008677 + GL_PROGRAM_INSTRUCTIONS_ARB* = 0x000088A0 + GL_MAX_PROGRAM_INSTRUCTIONS_ARB* = 0x000088A1 + GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB* = 0x000088A2 + GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB* = 0x000088A3 + GL_PROGRAM_TEMPORARIES_ARB* = 0x000088A4 + GL_MAX_PROGRAM_TEMPORARIES_ARB* = 0x000088A5 + GL_PROGRAM_NATIVE_TEMPORARIES_ARB* = 0x000088A6 + GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB* = 0x000088A7 + GL_PROGRAM_PARAMETERS_ARB* = 0x000088A8 + GL_MAX_PROGRAM_PARAMETERS_ARB* = 0x000088A9 + GL_PROGRAM_NATIVE_PARAMETERS_ARB* = 0x000088AA + GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB* = 0x000088AB + GL_PROGRAM_ATTRIBS_ARB* = 0x000088AC + GL_MAX_PROGRAM_ATTRIBS_ARB* = 0x000088AD + GL_PROGRAM_NATIVE_ATTRIBS_ARB* = 0x000088AE + GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB* = 0x000088AF + GL_PROGRAM_ADDRESS_REGISTERS_ARB* = 0x000088B0 + GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB* = 0x000088B1 + GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB* = 0x000088B2 + GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB* = 0x000088B3 + GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB* = 0x000088B4 + GL_MAX_PROGRAM_ENV_PARAMETERS_ARB* = 0x000088B5 + GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB* = 0x000088B6 + constGL_PROGRAM_STRING_ARB* = 0x00008628 + GL_PROGRAM_ERROR_POSITION_ARB* = 0x0000864B + GL_CURRENT_MATRIX_ARB* = 0x00008641 + GL_TRANSPOSE_CURRENT_MATRIX_ARB* = 0x000088B7 + GL_CURRENT_MATRIX_STACK_DEPTH_ARB* = 0x00008640 + GL_MAX_VERTEX_ATTRIBS_ARB* = 0x00008869 + GL_MAX_PROGRAM_MATRICES_ARB* = 0x0000862F + GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB* = 0x0000862E + GL_PROGRAM_ERROR_STRING_ARB* = 0x00008874 + GL_MATRIX0_ARB* = 0x000088C0 + GL_MATRIX1_ARB* = 0x000088C1 + GL_MATRIX2_ARB* = 0x000088C2 + GL_MATRIX3_ARB* = 0x000088C3 + GL_MATRIX4_ARB* = 0x000088C4 + GL_MATRIX5_ARB* = 0x000088C5 + GL_MATRIX6_ARB* = 0x000088C6 + GL_MATRIX7_ARB* = 0x000088C7 + GL_MATRIX8_ARB* = 0x000088C8 + GL_MATRIX9_ARB* = 0x000088C9 + GL_MATRIX10_ARB* = 0x000088CA + GL_MATRIX11_ARB* = 0x000088CB + GL_MATRIX12_ARB* = 0x000088CC + GL_MATRIX13_ARB* = 0x000088CD + GL_MATRIX14_ARB* = 0x000088CE + GL_MATRIX15_ARB* = 0x000088CF + GL_MATRIX16_ARB* = 0x000088D0 + GL_MATRIX17_ARB* = 0x000088D1 + GL_MATRIX18_ARB* = 0x000088D2 + GL_MATRIX19_ARB* = 0x000088D3 + GL_MATRIX20_ARB* = 0x000088D4 + GL_MATRIX21_ARB* = 0x000088D5 + GL_MATRIX22_ARB* = 0x000088D6 + GL_MATRIX23_ARB* = 0x000088D7 + GL_MATRIX24_ARB* = 0x000088D8 + GL_MATRIX25_ARB* = 0x000088D9 + GL_MATRIX26_ARB* = 0x000088DA + GL_MATRIX27_ARB* = 0x000088DB + GL_MATRIX28_ARB* = 0x000088DC + GL_MATRIX29_ARB* = 0x000088DD + GL_MATRIX30_ARB* = 0x000088DE + GL_MATRIX31_ARB* = 0x000088DF + +const + GL_422_EXT* = 0x000080CC + GL_422_REV_EXT* = 0x000080CD + GL_422_AVERAGE_EXT* = 0x000080CE + GL_422_REV_AVERAGE_EXT* = 0x000080CF + + #***** GL_EXT_abgr *****// +const + GL_ABGR_EXT* = 0x00008000 + + #***** GL_EXT_bgra *****// +const + GL_BGR_EXT* = 0x000080E0 + GL_BGRA_EXT* = 0x000080E1 + + #***** GL_EXT_blend_color *****// +const + GL_CONSTANT_COLOR_EXT* = 0x00008001 + GL_ONE_MINUS_CONSTANT_COLOR_EXT* = 0x00008002 + GL_CONSTANT_ALPHA_EXT* = 0x00008003 + GL_ONE_MINUS_CONSTANT_ALPHA_EXT* = 0x00008004 + constGL_BLEND_COLOR_EXT* = 0x00008005 + +proc glBlendColorEXT*(red: TGLclampf, green: TGLclampf, blue: TGLclampf, + alpha: TGLclampf){.dynlib: dllname, importc.} + #***** GL_EXT_blend_func_separate *****// +const + GL_BLEND_DST_RGB_EXT* = 0x000080C8 + GL_BLEND_SRC_RGB_EXT* = 0x000080C9 + GL_BLEND_DST_ALPHA_EXT* = 0x000080CA + GL_BLEND_SRC_ALPHA_EXT* = 0x000080CB + +proc glBlendFuncSeparateEXT*(sfactorRGB: TGLenum, dfactorRGB: TGLenum, + sfactorAlpha: TGLenum, dfactorAlpha: TGLenum){. + dynlib: dllname, importc.} + #***** GL_EXT_blend_logic_op *****// + #***** GL_EXT_blend_minmax *****// +const + GL_FUNC_ADD_EXT* = 0x00008006 + GL_MIN_EXT* = 0x00008007 + GL_MAX_EXT* = 0x00008008 + constGL_BLEND_EQUATION_EXT* = 0x00008009 + +proc glBlendEquationEXT*(mode: TGLenum){.dynlib: dllname, importc.} + #***** GL_EXT_blend_subtract *****// +const + GL_FUNC_SUBTRACT_EXT* = 0x0000800A + GL_FUNC_REVERSE_SUBTRACT_EXT* = 0x0000800B + + #***** GL_EXT_clip_volume_hint *****// +const + GL_CLIP_VOLUME_CLIPPING_HINT_EXT* = 0x000080F0 + + #***** GL_EXT_color_subtable *****// +proc glColorSubTableEXT*(target: TGLenum, start: TGLsizei, count: TGLsizei, + format: TGLenum, thetype: TGLenum, data: PGLvoid){. + dynlib: dllname, importc.} +proc glCopyColorSubTableEXT*(target: TGLenum, start: TGLsizei, x: TGLint, y: TGLint, + width: TGLsizei){.dynlib: dllname, importc.} + #***** GL_EXT_compiled_vertex_array *****// +const + GL_ARRAY_ELEMENT_LOCK_FIRST_EXT* = 0x000081A8 + GL_ARRAY_ELEMENT_LOCK_COUNT_EXT* = 0x000081A9 + +proc glLockArraysEXT*(first: TGLint, count: TGLsizei){.dynlib: dllname, importc.} +proc glUnlockArraysEXT*(){.dynlib: dllname, importc.} + #***** GL_EXT_convolution *****// +const + GL_CONVOLUTION_1D_EXT* = 0x00008010 + GL_CONVOLUTION_2D_EXT* = 0x00008011 + GL_SEPARABLE_2D_EXT* = 0x00008012 + GL_CONVOLUTION_BORDER_MODE_EXT* = 0x00008013 + GL_CONVOLUTION_FILTER_SCALE_EXT* = 0x00008014 + GL_CONVOLUTION_FILTER_BIAS_EXT* = 0x00008015 + GL_REDUCE_EXT* = 0x00008016 + GL_CONVOLUTION_FORMAT_EXT* = 0x00008017 + GL_CONVOLUTION_WIDTH_EXT* = 0x00008018 + GL_CONVOLUTION_HEIGHT_EXT* = 0x00008019 + GL_MAX_CONVOLUTION_WIDTH_EXT* = 0x0000801A + GL_MAX_CONVOLUTION_HEIGHT_EXT* = 0x0000801B + GL_POST_CONVOLUTION_RED_SCALE_EXT* = 0x0000801C + GL_POST_CONVOLUTION_GREEN_SCALE_EXT* = 0x0000801D + GL_POST_CONVOLUTION_BLUE_SCALE_EXT* = 0x0000801E + GL_POST_CONVOLUTION_ALPHA_SCALE_EXT* = 0x0000801F + GL_POST_CONVOLUTION_RED_BIAS_EXT* = 0x00008020 + GL_POST_CONVOLUTION_GREEN_BIAS_EXT* = 0x00008021 + GL_POST_CONVOLUTION_BLUE_BIAS_EXT* = 0x00008022 + GL_POST_CONVOLUTION_ALPHA_BIAS_EXT* = 0x00008023 + +proc glConvolutionFilter1DEXT*(target: TGLenum, internalformat: TGLenum, + width: TGLsizei, format: TGLenum, thetype: TGLenum, + image: PGLvoid){.dynlib: dllname, importc.} +proc glConvolutionFilter2DEXT*(target: TGLenum, internalformat: TGLenum, + width: TGLsizei, height: TGLsizei, format: TGLenum, + thetype: TGLenum, image: PGLvoid){. + dynlib: dllname, importc.} +proc glCopyConvolutionFilter1DEXT*(target: TGLenum, internalformat: TGLenum, + x: TGLint, y: TGLint, width: TGLsizei){. + dynlib: dllname, importc.} +proc glCopyConvolutionFilter2DEXT*(target: TGLenum, internalformat: TGLenum, + x: TGLint, y: TGLint, width: TGLsizei, + height: TGLsizei){.dynlib: dllname, importc.} +proc glGetConvolutionFilterEXT*(target: TGLenum, format: TGLenum, thetype: TGLenum, + image: PGLvoid){.dynlib: dllname, importc.} +proc glSeparableFilter2DEXT*(target: TGLenum, internalformat: TGLenum, + width: TGLsizei, height: TGLsizei, format: TGLenum, + thetype: TGLenum, row: PGLvoid, column: PGLvoid){. + dynlib: dllname, importc.} +proc glGetSeparableFilterEXT*(target: TGLenum, format: TGLenum, thetype: TGLenum, + row: PGLvoid, column: PGLvoid, span: PGLvoid){. + dynlib: dllname, importc.} +proc glConvolutionParameteriEXT*(target: TGLenum, pname: TGLenum, param: TGLint){. + dynlib: dllname, importc.} +proc glConvolutionParameterivEXT*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glConvolutionParameterfEXT*(target: TGLenum, pname: TGLenum, param: TGLfloat){. + dynlib: dllname, importc.} +proc glConvolutionParameterfvEXT*(target: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, importc.} +proc glGetConvolutionParameterivEXT*(target: TGLenum, pname: TGLenum, + params: PGLint){.dynlib: dllname, importc.} +proc glGetConvolutionParameterfvEXT*(target: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, importc.} + #***** GL_EXT_fog_coord *****// +const + GL_FOG_COORDINATE_SOURCE_EXT* = 0x00008450 + GL_FOG_COORDINATE_EXT* = 0x00008451 + GL_FRAGMENT_DEPTH_EXT* = 0x00008452 + GL_CURRENT_FOG_COORDINATE_EXT* = 0x00008453 + GL_FOG_COORDINATE_ARRAY_TYPE_EXT* = 0x00008454 + GL_FOG_COORDINATE_ARRAY_STRIDE_EXT* = 0x00008455 + GL_FOG_COORDINATE_ARRAY_POINTER_EXT* = 0x00008456 + GL_FOG_COORDINATE_ARRAY_EXT* = 0x00008457 + +proc glFogCoordfEXfloat*(coord: TGLfloat){.dynlib: dllname, importc.} +proc glFogCoorddEXdouble*(coord: TGLdouble){.dynlib: dllname, importc.} +proc glFogCoordfvEXfloat*(coord: TGLfloat){.dynlib: dllname, importc.} +proc glFogCoorddvEXdouble*(coord: TGLdouble){.dynlib: dllname, importc.} +proc glFogCoordPointerEXT*(thetype: TGLenum, stride: TGLsizei, pointer: PGLvoid){. + dynlib: dllname, importc.} + #***** GL_EXT_histogram *****// +const + constGL_HISTOGRAM_EXT* = 0x00008024 + GL_PROXY_HISTOGRAM_EXT* = 0x00008025 + GL_HISTOGRAM_WIDTH_EXT* = 0x00008026 + GL_HISTOGRAM_FORMAT_EXT* = 0x00008027 + GL_HISTOGRAM_RED_SIZE_EXT* = 0x00008028 + GL_HISTOGRAM_GREEN_SIZE_EXT* = 0x00008029 + GL_HISTOGRAM_BLUE_SIZE_EXT* = 0x0000802A + GL_HISTOGRAM_ALPHA_SIZE_EXT* = 0x0000802B + GL_HISTOGRAM_LUMINANCE_SIZE_EXT* = 0x0000802C + GL_HISTOGRAM_SINK_EXT* = 0x0000802D + constGL_MINMAX_EXT* = 0x0000802E + GL_MINMAX_FORMAT_EXT* = 0x0000802F + GL_MINMAX_SINK_EXT* = 0x00008030 + +proc glHistogramEXT*(target: TGLenum, width: TGLsizei, internalformat: TGLenum, + sink: TGLboolean){.dynlib: dllname, importc.} +proc glResetHistogramEXT*(target: TGLenum){.dynlib: dllname, importc.} +proc glGetHistogramEXT*(target: TGLenum, reset: TGLboolean, format: TGLenum, + thetype: TGLenum, values: PGLvoid){.dynlib: dllname, + importc.} +proc glGetHistogramParameterivEXT*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glGetHistogramParameterfvEXT*(target: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, importc.} +proc glMinmaxEXT*(target: TGLenum, internalformat: TGLenum, sink: TGLboolean){. + dynlib: dllname, importc.} +proc glResetMinmaxEXT*(target: TGLenum){.dynlib: dllname, importc.} +proc glGetMinmaxEXT*(target: TGLenum, reset: TGLboolean, format: TGLenum, + thetype: TGLenum, values: PGLvoid){.dynlib: dllname, importc.} +proc glGetMinmaxParameterivEXT*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glGetMinmaxParameterfvEXT*(target: TGLenum, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc.} + #***** GL_EXT_multi_draw_arrays *****// +proc glMultiDrawArraysEXT*(mode: TGLenum, first: PGLint, count: PGLsizei, + primcount: TGLsizei){.dynlib: dllname, importc.} +proc glMultiDrawElementsEXT*(mode: TGLenum, count: PGLsizei, thetype: TGLenum, + indices: PGLvoid, primcount: TGLsizei){. + dynlib: dllname, importc.} + #***** GL_EXT_packed_pixels *****// +const + GL_UNSIGNED_BYTE_3_3_2_EXT* = 0x00008032 + GL_UNSIGNED_SHORT_4_4_4_4_EXT* = 0x00008033 + GL_UNSIGNED_SHORT_5_5_5_1_EXT* = 0x00008034 + GL_UNSIGNED_INT_8_8_8_8_EXT* = 0x00008035 + GL_UNSIGNED_INT_10_10_10_2_EXT* = 0x00008036 + + #***** GL_EXT_paletted_texture *****// +const + GL_COLOR_INDEX1_EXT* = 0x000080E2 + GL_COLOR_INDEX2_EXT* = 0x000080E3 + GL_COLOR_INDEX4_EXT* = 0x000080E4 + GL_COLOR_INDEX8_EXT* = 0x000080E5 + GL_COLOR_INDEX12_EXT* = 0x000080E6 + GL_COLOR_INDEX16_EXT* = 0x000080E7 + GL_COLOR_TABLE_FORMAT_EXT* = 0x000080D8 + GL_COLOR_TABLE_WIDTH_EXT* = 0x000080D9 + GL_COLOR_TABLE_RED_SIZE_EXT* = 0x000080DA + GL_COLOR_TABLE_GREEN_SIZE_EXT* = 0x000080DB + GL_COLOR_TABLE_BLUE_SIZE_EXT* = 0x000080DC + GL_COLOR_TABLE_ALPHA_SIZE_EXT* = 0x000080DD + GL_COLOR_TABLE_LUMINANCE_SIZE_EXT* = 0x000080DE + GL_COLOR_TABLE_INTENSITY_SIZE_EXT* = 0x000080DF + GL_TEXTURE_INDEX_SIZE_EXT* = 0x000080ED + GL_TEXTURE_1D* = 0x00000DE0 + GL_TEXTURE_2D* = 0x00000DE1 + GL_TEXTURE_3D_EXT* = 0x0000806F # GL_TEXTURE_CUBE_MAP_ARB { already defined } + GL_PROXY_TEXTURE_1D* = 0x00008063 + GL_PROXY_TEXTURE_2D* = 0x00008064 + GL_PROXY_TEXTURE_3D_EXT* = 0x00008070 # GL_PROXY_TEXTURE_CUBE_MAP_ARB { already defined } + # GL_TEXTURE_1D { already defined } + # GL_TEXTURE_2D { already defined } + # GL_TEXTURE_3D_EXT { already defined } + # GL_TEXTURE_CUBE_MAP_ARB { already defined } + +proc glColorTableEXT*(target: TGLenum, internalFormat: TGLenum, width: TGLsizei, + format: TGLenum, thetype: TGLenum, data: PGLvoid){. + dynlib: dllname, importc.} + # glColorSubTableEXT { already defined } +proc glGetColorTableEXT*(target: TGLenum, format: TGLenum, thetype: TGLenum, + data: PGLvoid){.dynlib: dllname, importc.} +proc glGetColorTableParameterivEXT*(target: TGLenum, pname: TGLenum, + params: PGLint){.dynlib: dllname, importc.} +proc glGetColorTableParameterfvEXT*(target: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, importc.} + #***** GL_EXT_point_parameters *****// +const + GL_POINT_SIZE_MIN_EXT* = 0x00008126 + GL_POINT_SIZE_MAX_EXT* = 0x00008127 + GL_POINT_FADE_THRESHOLD_SIZE_EXT* = 0x00008128 + GL_DISTANCE_ATTENUATION_EXT* = 0x00008129 + +proc glPointParameterfEXT*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, + importc.} +proc glPointParameterfvEXT*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, + importc.} + #***** GL_EXT_polygon_offset *****// +const + constGL_POLYGON_OFFSET_EXT* = 0x00008037 + GL_POLYGON_OFFSET_FACTOR_EXT* = 0x00008038 + GL_POLYGON_OFFSET_BIAS_EXT* = 0x00008039 + +proc glPolygonOffsetEXT*(factor: TGLfloat, bias: TGLfloat){.dynlib: dllname, + importc.} + #***** GL_EXT_secondary_color *****// +const + GL_COLOR_SUM_EXT* = 0x00008458 + GL_CURRENT_SECONDARY_COLOR_EXT* = 0x00008459 + GL_SECONDARY_COLOR_ARRAY_SIZE_EXT* = 0x0000845A + GL_SECONDARY_COLOR_ARRAY_TYPE_EXT* = 0x0000845B + GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT* = 0x0000845C + GL_SECONDARY_COLOR_ARRAY_POINTER_EXT* = 0x0000845D + GL_SECONDARY_COLOR_ARRAY_EXT* = 0x0000845E + +proc glSecondaryColor3bEXT*(components: TGLbyte){.dynlib: dllname, importc.} +proc glSecondaryColor3sEXT*(components: TGLshort){.dynlib: dllname, importc.} +proc glSecondaryColor3iEXT*(components: TGLint){.dynlib: dllname, importc.} +proc glSecondaryColor3fEXT*(components: TGLfloat){.dynlib: dllname, importc.} +proc glSecondaryColor3dEXT*(components: TGLdouble){.dynlib: dllname, importc.} +proc glSecondaryColor3ubEXT*(components: TGLubyte){.dynlib: dllname, importc.} +proc glSecondaryColor3usEXT*(components: TGLushort){.dynlib: dllname, importc.} +proc glSecondaryColor3uiEXT*(components: TGLuint){.dynlib: dllname, importc.} +proc glSecondaryColor3bvEXT*(components: TGLbyte){.dynlib: dllname, importc.} +proc glSecondaryColor3svEXT*(components: TGLshort){.dynlib: dllname, importc.} +proc glSecondaryColor3ivEXT*(components: TGLint){.dynlib: dllname, importc.} +proc glSecondaryColor3fvEXT*(components: TGLfloat){.dynlib: dllname, importc.} +proc glSecondaryColor3dvEXT*(components: TGLdouble){.dynlib: dllname, importc.} +proc glSecondaryColor3ubvEXT*(components: TGLubyte){.dynlib: dllname, importc.} +proc glSecondaryColor3usvEXT*(components: TGLushort){.dynlib: dllname, importc.} +proc glSecondaryColor3uivEXT*(components: TGLuint){.dynlib: dllname, importc.} +proc glSecondaryColorPointerEXT*(size: TGLint, thetype: TGLenum, stride: TGLsizei, + pointer: PGLvoid){.dynlib: dllname, importc.} + #***** GL_EXT_separate_specular_color *****// +const + GL_LIGHT_MODEL_COLOR_CONTROL_EXT* = 0x000081F8 + GL_SINGLE_COLOR_EXT* = 0x000081F9 + GL_SEPARATE_SPECULAR_COLOR_EXT* = 0x000081FA + + #***** GL_EXT_shadow_funcs *****// + #***** GL_EXT_shared_texture_palette *****// +const + GL_SHARED_TEXTURE_PALETTE_EXT* = 0x000081FB + + #***** GL_EXT_stencil_two_side *****// +const + GL_STENCIL_TEST_TWO_SIDE_EXT* = 0x00008910 + constGL_ACTIVE_STENCIL_FACE_EXT* = 0x00008911 + +proc glActiveStencilFaceEXT*(face: TGLenum){.dynlib: dllname, importc.} + #***** GL_EXT_stencil_wrap *****// +const + GL_INCR_WRAP_EXT* = 0x00008507 + GL_DECR_WRAP_EXT* = 0x00008508 + + #***** GL_EXT_subtexture *****// +proc glTexSubImage1DEXT*(target: TGLenum, level: TGLint, xoffset: TGLint, + width: TGLsizei, format: TGLenum, thetype: TGLenum, + pixels: PGLvoid){.dynlib: dllname, importc.} +proc glTexSubImage2DEXT*(target: TGLenum, level: TGLint, xoffset: TGLint, + yoffset: TGLint, width: TGLsizei, height: TGLsizei, + format: TGLenum, thetype: TGLenum, pixels: PGLvoid){. + dynlib: dllname, importc.} +proc glTexSubImage3DEXT*(target: TGLenum, level: TGLint, xoffset: TGLint, + yoffset: TGLint, zoffset: TGLint, width: TGLsizei, + height: TGLsizei, depth: TGLsizei, format: TGLenum, + thetype: TGLenum, pixels: PGLvoid){.dynlib: dllname, + importc.} + #***** GL_EXT_texture3D *****// +const + GL_PACK_SKIP_IMAGES_EXT* = 0x0000806B + GL_PACK_IMAGE_HEIGHT_EXT* = 0x0000806C + GL_UNPACK_SKIP_IMAGES_EXT* = 0x0000806D + GL_UNPACK_IMAGE_HEIGHT_EXT* = 0x0000806E # GL_TEXTURE_3D_EXT { already defined } + # GL_PROXY_TEXTURE_3D_EXT { already defined } + GL_TEXTURE_DEPTH_EXT* = 0x00008071 + GL_TEXTURE_WRAP_R_EXT* = 0x00008072 + GL_MAX_3D_TEXTURE_SIZE_EXT* = 0x00008073 + +proc glTexImage3DEXT*(target: TGLenum, level: TGLint, internalformat: TGLenum, + width: TGLsizei, height: TGLsizei, depth: TGLsizei, + border: TGLint, format: TGLenum, thetype: TGLenum, + pixels: PGLvoid){.dynlib: dllname, importc.} + #***** GL_EXT_texture_compression_s3tc *****// +const + GL_COMPRESSED_RGB_S3TC_DXT1_EXT* = 0x000083F0 + GL_COMPRESSED_RGBA_S3TC_DXT1_EXT* = 0x000083F1 + GL_COMPRESSED_RGBA_S3TC_DXT3_EXT* = 0x000083F2 + GL_COMPRESSED_RGBA_S3TC_DXT5_EXT* = 0x000083F3 + + #***** GL_EXT_texture_env_add *****// + #***** GL_EXT_texture_env_combine *****// +const + GL_COMBINE_EXT* = 0x00008570 + GL_COMBINE_RGB_EXT* = 0x00008571 + GL_COMBINE_ALPHA_EXT* = 0x00008572 + GL_SOURCE0_RGB_EXT* = 0x00008580 + GL_SOURCE1_RGB_EXT* = 0x00008581 + GL_SOURCE2_RGB_EXT* = 0x00008582 + GL_SOURCE0_ALPHA_EXT* = 0x00008588 + GL_SOURCE1_ALPHA_EXT* = 0x00008589 + GL_SOURCE2_ALPHA_EXT* = 0x0000858A + GL_OPERAND0_RGB_EXT* = 0x00008590 + GL_OPERAND1_RGB_EXT* = 0x00008591 + GL_OPERAND2_RGB_EXT* = 0x00008592 + GL_OPERAND0_ALPHA_EXT* = 0x00008598 + GL_OPERAND1_ALPHA_EXT* = 0x00008599 + GL_OPERAND2_ALPHA_EXT* = 0x0000859A + GL_RGB_SCALE_EXT* = 0x00008573 + GL_ADD_SIGNED_EXT* = 0x00008574 + GL_INTERPOLATE_EXT* = 0x00008575 + GL_CONSTANT_EXT* = 0x00008576 + GL_PRIMARY_COLOR_EXT* = 0x00008577 + GL_PREVIOUS_EXT* = 0x00008578 + + #***** GL_EXT_texture_env_dot3 *****// +const + GL_DOT3_RGB_EXT* = 0x00008740 + GL_DOT3_RGBA_EXT* = 0x00008741 + + #***** GL_EXT_texture_filter_anisotropic *****// +const + GL_TEXTURE_MAX_ANISOTROPY_EXT* = 0x000084FE + GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT* = 0x000084FF + + #***** GL_EXT_texture_lod_bias *****// +const + GL_TEXTURE_FILTER_CONTROL_EXT* = 0x00008500 + GL_TEXTURE_LOD_BIAS_EXT* = 0x00008501 + GL_MAX_TEXTURE_LOD_BIAS_EXT* = 0x000084FD + + #***** GL_EXT_texture_object *****// +const + GL_TEXTURE_PRIORITY_EXT* = 0x00008066 + GL_TEXTURE_RESIDENT_EXT* = 0x00008067 + GL_TEXTURE_1D_BINDING_EXT* = 0x00008068 + GL_TEXTURE_2D_BINDING_EXT* = 0x00008069 + GL_TEXTURE_3D_BINDING_EXT* = 0x0000806A + +proc glGenTexturesEXT*(n: TGLsizei, textures: PGLuint){.dynlib: dllname, importc.} +proc glDeleteTexturesEXT*(n: TGLsizei, textures: PGLuint){.dynlib: dllname, + importc.} +proc glBindTextureEXT*(target: TGLenum, texture: TGLuint){.dynlib: dllname, + importc.} +proc glPrioritizeTexturesEXT*(n: TGLsizei, textures: PGLuint, + priorities: PGLclampf){.dynlib: dllname, importc.} +proc glAreTexturesResidentEXT*(n: TGLsizei, textures: PGLuint, + residences: PGLboolean): TGLboolean{. + dynlib: dllname, importc.} +proc glIsTextureEXT*(texture: TGLuint): TGLboolean{.dynlib: dllname, importc.} + #***** GL_EXT_vertex_array *****// +const + GL_VERTEX_ARRAY_EXT* = 0x00008074 + GL_NORMAL_ARRAY_EXT* = 0x00008075 + GL_COLOR_ARRAY_EXT* = 0x00008076 + GL_INDEX_ARRAY_EXT* = 0x00008077 + GL_TEXTURE_COORD_ARRAY_EXT* = 0x00008078 + GL_EDGE_FLAG_ARRAY_EXT* = 0x00008079 + GL_DOUBLE_EXT* = 0x0000140A + GL_VERTEX_ARRAY_SIZE_EXT* = 0x0000807A + GL_VERTEX_ARRAY_TYPE_EXT* = 0x0000807B + GL_VERTEX_ARRAY_STRIDE_EXT* = 0x0000807C + GL_VERTEX_ARRAY_COUNT_EXT* = 0x0000807D + GL_NORMAL_ARRAY_TYPE_EXT* = 0x0000807E + GL_NORMAL_ARRAY_STRIDE_EXT* = 0x0000807F + GL_NORMAL_ARRAY_COUNT_EXT* = 0x00008080 + GL_COLOR_ARRAY_SIZE_EXT* = 0x00008081 + GL_COLOR_ARRAY_TYPE_EXT* = 0x00008082 + GL_COLOR_ARRAY_STRIDE_EXT* = 0x00008083 + GL_COLOR_ARRAY_COUNT_EXT* = 0x00008084 + GL_INDEX_ARRAY_TYPE_EXT* = 0x00008085 + GL_INDEX_ARRAY_STRIDE_EXT* = 0x00008086 + GL_INDEX_ARRAY_COUNT_EXT* = 0x00008087 + GL_TEXTURE_COORD_ARRAY_SIZE_EXT* = 0x00008088 + GL_TEXTURE_COORD_ARRAY_TYPE_EXT* = 0x00008089 + GL_TEXTURE_COORD_ARRAY_STRIDE_EXT* = 0x0000808A + GL_TEXTURE_COORD_ARRAY_COUNT_EXT* = 0x0000808B + GL_EDGE_FLAG_ARRAY_STRIDE_EXT* = 0x0000808C + GL_EDGE_FLAG_ARRAY_COUNT_EXT* = 0x0000808D + GL_VERTEX_ARRAY_POINTER_EXT* = 0x0000808E + GL_NORMAL_ARRAY_POINTER_EXT* = 0x0000808F + GL_COLOR_ARRAY_POINTER_EXT* = 0x00008090 + GL_INDEX_ARRAY_POINTER_EXT* = 0x00008091 + GL_TEXTURE_COORD_ARRAY_POINTER_EXT* = 0x00008092 + GL_EDGE_FLAG_ARRAY_POINTER_EXT* = 0x00008093 + +proc glArrayElementEXT*(i: TGLint){.dynlib: dllname, importc.} +proc glDrawArraysEXT*(mode: TGLenum, first: TGLint, count: TGLsizei){. + dynlib: dllname, importc.} +proc glVertexPointerEXT*(size: TGLint, thetype: TGLenum, stride: TGLsizei, + count: TGLsizei, pointer: PGLvoid){.dynlib: dllname, + importc.} +proc glNormalPointerEXT*(thetype: TGLenum, stride: TGLsizei, count: TGLsizei, + pointer: PGLvoid){.dynlib: dllname, importc.} +proc glColorPointerEXT*(size: TGLint, thetype: TGLenum, stride: TGLsizei, + count: TGLsizei, pointer: PGLvoid){.dynlib: dllname, + importc.} +proc glIndexPointerEXT*(thetype: TGLenum, stride: TGLsizei, count: TGLsizei, + pointer: PGLvoid){.dynlib: dllname, importc.} +proc glTexCoordPointerEXT*(size: TGLint, thetype: TGLenum, stride: TGLsizei, + count: TGLsizei, pointer: PGLvoid){.dynlib: dllname, + importc.} +proc glEdgeFlagPointerEXT*(stride: TGLsizei, count: TGLsizei, pointer: PGLboolean){. + dynlib: dllname, importc.} +proc glGetPointervEXT*(pname: TGLenum, params: PGLvoid){.dynlib: dllname, importc.} + #***** GL_EXT_vertex_shader *****// +const + GL_VERTEX_SHADER_EXT* = 0x00008780 + GL_VARIANT_VALUE_EXT* = 0x000087E4 + GL_VARIANT_DATATYPE_EXT* = 0x000087E5 + GL_VARIANT_ARRAY_STRIDE_EXT* = 0x000087E6 + GL_VARIANT_ARRAY_TYPE_EXT* = 0x000087E7 + GL_VARIANT_ARRAY_EXT* = 0x000087E8 + GL_VARIANT_ARRAY_POINTER_EXT* = 0x000087E9 + GL_INVARIANT_VALUE_EXT* = 0x000087EA + GL_INVARIANT_DATATYPE_EXT* = 0x000087EB + GL_LOCAL_CONSTANT_VALUE_EXT* = 0x000087EC + GL_LOCAL_CONSTANT_DATATYPE_EXT* = 0x000087ED + GL_OP_INDEX_EXT* = 0x00008782 + GL_OP_NEGATE_EXT* = 0x00008783 + GL_OP_DOT3_EXT* = 0x00008784 + GL_OP_DOT4_EXT* = 0x00008785 + GL_OP_MUL_EXT* = 0x00008786 + GL_OP_ADD_EXT* = 0x00008787 + GL_OP_MADD_EXT* = 0x00008788 + GL_OP_FRAC_EXT* = 0x00008789 + GL_OP_MAX_EXT* = 0x0000878A + GL_OP_MIN_EXT* = 0x0000878B + GL_OP_SET_GE_EXT* = 0x0000878C + GL_OP_SET_LT_EXT* = 0x0000878D + GL_OP_CLAMP_EXT* = 0x0000878E + GL_OP_FLOOR_EXT* = 0x0000878F + GL_OP_ROUND_EXT* = 0x00008790 + GL_OP_EXP_BASE_2_EXT* = 0x00008791 + GL_OP_LOG_BASE_2_EXT* = 0x00008792 + GL_OP_POWER_EXT* = 0x00008793 + GL_OP_RECIP_EXT* = 0x00008794 + GL_OP_RECIP_SQRT_EXT* = 0x00008795 + GL_OP_SUB_EXT* = 0x00008796 + GL_OP_CROSS_PRODUCT_EXT* = 0x00008797 + GL_OP_MULTIPLY_MATRIX_EXT* = 0x00008798 + GL_OP_MOV_EXT* = 0x00008799 + GL_OUTPUT_VERTEX_EXT* = 0x0000879A + GL_OUTPUT_COLOR0_EXT* = 0x0000879B + GL_OUTPUT_COLOR1_EXT* = 0x0000879C + GL_OUTPUT_TEXTURE_COORD0_EXT* = 0x0000879D + GL_OUTPUT_TEXTURE_COORD1_EXT* = 0x0000879E + GL_OUTPUT_TEXTURE_COORD2_EXT* = 0x0000879F + GL_OUTPUT_TEXTURE_COORD3_EXT* = 0x000087A0 + GL_OUTPUT_TEXTURE_COORD4_EXT* = 0x000087A1 + GL_OUTPUT_TEXTURE_COORD5_EXT* = 0x000087A2 + GL_OUTPUT_TEXTURE_COORD6_EXT* = 0x000087A3 + GL_OUTPUT_TEXTURE_COORD7_EXT* = 0x000087A4 + GL_OUTPUT_TEXTURE_COORD8_EXT* = 0x000087A5 + GL_OUTPUT_TEXTURE_COORD9_EXT* = 0x000087A6 + GL_OUTPUT_TEXTURE_COORD10_EXT* = 0x000087A7 + GL_OUTPUT_TEXTURE_COORD11_EXT* = 0x000087A8 + GL_OUTPUT_TEXTURE_COORD12_EXT* = 0x000087A9 + GL_OUTPUT_TEXTURE_COORD13_EXT* = 0x000087AA + GL_OUTPUT_TEXTURE_COORD14_EXT* = 0x000087AB + GL_OUTPUT_TEXTURE_COORD15_EXT* = 0x000087AC + GL_OUTPUT_TEXTURE_COORD16_EXT* = 0x000087AD + GL_OUTPUT_TEXTURE_COORD17_EXT* = 0x000087AE + GL_OUTPUT_TEXTURE_COORD18_EXT* = 0x000087AF + GL_OUTPUT_TEXTURE_COORD19_EXT* = 0x000087B0 + GL_OUTPUT_TEXTURE_COORD20_EXT* = 0x000087B1 + GL_OUTPUT_TEXTURE_COORD21_EXT* = 0x000087B2 + GL_OUTPUT_TEXTURE_COORD22_EXT* = 0x000087B3 + GL_OUTPUT_TEXTURE_COORD23_EXT* = 0x000087B4 + GL_OUTPUT_TEXTURE_COORD24_EXT* = 0x000087B5 + GL_OUTPUT_TEXTURE_COORD25_EXT* = 0x000087B6 + GL_OUTPUT_TEXTURE_COORD26_EXT* = 0x000087B7 + GL_OUTPUT_TEXTURE_COORD27_EXT* = 0x000087B8 + GL_OUTPUT_TEXTURE_COORD28_EXT* = 0x000087B9 + GL_OUTPUT_TEXTURE_COORD29_EXT* = 0x000087BA + GL_OUTPUT_TEXTURE_COORD30_EXT* = 0x000087BB + GL_OUTPUT_TEXTURE_COORD31_EXT* = 0x000087BC + GL_OUTPUT_FOG_EXT* = 0x000087BD + GL_SCALAR_EXT* = 0x000087BE + GL_VECTOR_EXT* = 0x000087BF + GL_MATRIX_EXT* = 0x000087C0 + GL_VARIANT_EXT* = 0x000087C1 + GL_INVARIANT_EXT* = 0x000087C2 + GL_LOCAL_CONSTANT_EXT* = 0x000087C3 + GL_LOCAL_EXT* = 0x000087C4 + GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT* = 0x000087C5 + GL_MAX_VERTEX_SHADER_VARIANTS_EXT* = 0x000087C6 + GL_MAX_VERTEX_SHADER_INVARIANTS_EXT* = 0x000087C7 + GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT* = 0x000087C8 + GL_MAX_VERTEX_SHADER_LOCALS_EXT* = 0x000087C9 + GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT* = 0x000087CA + GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT* = 0x000087CB + GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT* = 0x000087CC + GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT* = 0x000087CD + GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT* = 0x000087CE + GL_VERTEX_SHADER_INSTRUCTIONS_EXT* = 0x000087CF + GL_VERTEX_SHADER_VARIANTS_EXT* = 0x000087D0 + GL_VERTEX_SHADER_INVARIANTS_EXT* = 0x000087D1 + GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT* = 0x000087D2 + GL_VERTEX_SHADER_LOCALS_EXT* = 0x000087D3 + GL_VERTEX_SHADER_BINDING_EXT* = 0x00008781 + GL_VERTEX_SHADER_OPTIMIZED_EXT* = 0x000087D4 + GL_X_EXT* = 0x000087D5 + GL_Y_EXT* = 0x000087D6 + GL_Z_EXT* = 0x000087D7 + GL_W_EXT* = 0x000087D8 + GL_NEGATIVE_X_EXT* = 0x000087D9 + GL_NEGATIVE_Y_EXT* = 0x000087DA + GL_NEGATIVE_Z_EXT* = 0x000087DB + GL_NEGATIVE_W_EXT* = 0x000087DC + GL_ZERO_EXT* = 0x000087DD + GL_ONE_EXT* = 0x000087DE + GL_NEGATIVE_ONE_EXT* = 0x000087DF + GL_NORMALIZED_RANGE_EXT* = 0x000087E0 + GL_FULL_RANGE_EXT* = 0x000087E1 + GL_CURRENT_VERTEX_EXT* = 0x000087E2 + GL_MVP_MATRIX_EXT* = 0x000087E3 + +proc glBeginVertexShaderEXT*(){.dynlib: dllname, importc.} +proc glEndVertexShaderEXT*(){.dynlib: dllname, importc.} +proc glBindVertexShaderEXT*(id: TGLuint){.dynlib: dllname, importc.} +proc glGenVertexShadersEXT*(range: TGLuint): TGLuint{.dynlib: dllname, importc.} +proc glDeleteVertexShaderEXT*(id: TGLuint){.dynlib: dllname, importc.} +proc glShaderOp1EXT*(op: TGLenum, res: TGLuint, arg1: TGLuint){.dynlib: dllname, + importc.} +proc glShaderOp2EXT*(op: TGLenum, res: TGLuint, arg1: TGLuint, arg2: TGLuint){. + dynlib: dllname, importc.} +proc glShaderOp3EXT*(op: TGLenum, res: TGLuint, arg1: TGLuint, arg2: TGLuint, + arg3: TGLuint){.dynlib: dllname, importc.} +proc glSwizzleEXT*(res: TGLuint, theIn: TGLuint, outX: TGLenum, outY: TGLenum, + outZ: TGLenum, outW: TGLenum){.dynlib: dllname, importc.} +proc glWriteMaskEXT*(res: TGLuint, theIn: TGLuint, outX: TGLenum, outY: TGLenum, + outZ: TGLenum, outW: TGLenum){.dynlib: dllname, importc.} +proc glInsertComponentEXT*(res: TGLuint, src: TGLuint, num: TGLuint){. + dynlib: dllname, importc.} +proc glExtractComponentEXT*(res: TGLuint, src: TGLuint, num: TGLuint){. + dynlib: dllname, importc.} +proc glGenSymbolsEXT*(datatype: TGLenum, storagetype: TGLenum, range: TGLenum, + components: TGLuint): TGLuint{.dynlib: dllname, importc.} +proc glSetInvariantEXT*(id: TGLuint, thetype: TGLenum, address: PGLvoid){. + dynlib: dllname, importc.} +proc glSetLocalConstantEXT*(id: TGLuint, thetype: TGLenum, address: PGLvoid){. + dynlib: dllname, importc.} +proc glVariantbvEXT*(id: TGLuint, address: PGLbyte){.dynlib: dllname, importc.} +proc glVariantsvEXT*(id: TGLuint, address: PGLshort){.dynlib: dllname, importc.} +proc glVariantivEXT*(id: TGLuint, address: PGLint){.dynlib: dllname, importc.} +proc glVariantfvEXT*(id: TGLuint, address: PGLfloat){.dynlib: dllname, importc.} +proc glVariantdvEXT*(id: TGLuint, address: PGLdouble){.dynlib: dllname, importc.} +proc glVariantubvEXT*(id: TGLuint, address: PGLubyte){.dynlib: dllname, importc.} +proc glVariantusvEXT*(id: TGLuint, address: PGLushort){.dynlib: dllname, importc.} +proc glVariantuivEXT*(id: TGLuint, address: PGLuint){.dynlib: dllname, importc.} +proc glVariantPointerEXT*(id: TGLuint, thetype: TGLenum, stride: TGLuint, + address: PGLvoid){.dynlib: dllname, importc.} +proc glEnableVariantClientStateEXT*(id: TGLuint){.dynlib: dllname, importc.} +proc glDisableVariantClientStateEXT*(id: TGLuint){.dynlib: dllname, importc.} +proc glBindLightParameterEXT*(light: TGLenum, value: TGLenum): TGLuint{. + dynlib: dllname, importc.} +proc glBindMaterialParameterEXT*(face: TGLenum, value: TGLenum): TGLuint{. + dynlib: dllname, importc.} +proc glBindTexGenParameterEXT*(theunit: TGLenum, coord: TGLenum, value: TGLenum): TGLuint{. + dynlib: dllname, importc.} +proc glBindTextureUnitParameterEXT*(theunit: TGLenum, value: TGLenum): TGLuint{. + dynlib: dllname, importc.} +proc glBindParameterEXT*(value: TGLenum): TGLuint{.dynlib: dllname, importc.} +proc glIsVariantEnabledEXT*(id: TGLuint, cap: TGLenum): TGLboolean{. + dynlib: dllname, importc.} +proc glGetVariantBooleanvEXT*(id: TGLuint, value: TGLenum, data: PGLboolean){. + dynlib: dllname, importc.} +proc glGetVariantIntegervEXT*(id: TGLuint, value: TGLenum, data: PGLint){. + dynlib: dllname, importc.} +proc glGetVariantFloatvEXT*(id: TGLuint, value: TGLenum, data: PGLfloat){. + dynlib: dllname, importc.} +proc glGetVariantPointervEXT*(id: TGLuint, value: TGLenum, data: PGLvoid){. + dynlib: dllname, importc.} +proc glGetInvariantBooleanvEXT*(id: TGLuint, value: TGLenum, data: PGLboolean){. + dynlib: dllname, importc.} +proc glGetInvariantIntegervEXT*(id: TGLuint, value: TGLenum, data: PGLint){. + dynlib: dllname, importc.} +proc glGetInvariantFloatvEXT*(id: TGLuint, value: TGLenum, data: PGLfloat){. + dynlib: dllname, importc.} +proc glGetLocalConstantBooleanvEXT*(id: TGLuint, value: TGLenum, data: PGLboolean){. + dynlib: dllname, importc.} +proc glGetLocalConstantIntegervEXT*(id: TGLuint, value: TGLenum, data: PGLint){. + dynlib: dllname, importc.} +proc glGetLocalConstantFloatvEXT*(id: TGLuint, value: TGLenum, data: PGLfloat){. + dynlib: dllname, importc.} + #***** GL_EXT_vertex_weighting *****// +const + GL_VERTEX_WEIGHTING_EXT* = 0x00008509 + GL_MODELVIEW0_EXT* = 0x00001700 + GL_MODELVIEW1_EXT* = 0x0000850A + GL_MODELVIEW0_MATRIX_EXT* = 0x00000BA6 + GL_MODELVIEW1_MATRIX_EXT* = 0x00008506 + GL_CURRENT_VERTEX_WEIGHT_EXT* = 0x0000850B + GL_VERTEX_WEIGHT_ARRAY_EXT* = 0x0000850C + GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT* = 0x0000850D + GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT* = 0x0000850E + GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT* = 0x0000850F + GL_MODELVIEW0_STACK_DEPTH_EXT* = 0x00000BA3 + GL_MODELVIEW1_STACK_DEPTH_EXT* = 0x00008502 + GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT* = 0x00008510 + +proc glVertexWeightfEXT*(weight: TGLfloat){.dynlib: dllname, importc.} +proc glVertexWeightfvEXT*(weight: PGLfloat){.dynlib: dllname, importc.} +proc glVertexWeightPointerEXT*(size: TGLint, thetype: TGLenum, stride: TGLsizei, + pointer: PGLvoid){.dynlib: dllname, importc.} + #***** GL_HP_occlusion_test *****// +const + GL_OCCLUSION_TEST_HP* = 0x00008165 + GL_OCCLUSION_TEST_RESULT_HP* = 0x00008166 + + #***** GL_NV_blend_square *****// + #***** GL_NV_copy_depth_to_color *****// +const + GL_DEPTH_STENCIL_TO_RGBA_NV* = 0x0000886E + GL_DEPTH_STENCIL_TO_BGRA_NV* = 0x0000886F + + #***** GL_NV_depth_clamp *****// +const + GL_DEPTH_CLAMP_NV* = 0x0000864F + + #***** GL_NV_evaluators *****// +const + GL_EVAL_2D_NV* = 0x000086C0 + GL_EVAL_TRIANGULAR_2D_NV* = 0x000086C1 + GL_MAP_TESSELLATION_NV* = 0x000086C2 + GL_MAP_ATTRIB_U_ORDER_NV* = 0x000086C3 + GL_MAP_ATTRIB_V_ORDER_NV* = 0x000086C4 + GL_EVAL_FRACTIONAL_TESSELLATION_NV* = 0x000086C5 + GL_EVAL_VERTEX_ATTRIB0_NV* = 0x000086C6 + GL_EVAL_VERTEX_ATTRIB1_NV* = 0x000086C7 + GL_EVAL_VERTEX_ATTRIB2_NV* = 0x000086C8 + GL_EVAL_VERTEX_ATTRIB3_NV* = 0x000086C9 + GL_EVAL_VERTEX_ATTRIB4_NV* = 0x000086CA + GL_EVAL_VERTEX_ATTRIB5_NV* = 0x000086CB + GL_EVAL_VERTEX_ATTRIB6_NV* = 0x000086CC + GL_EVAL_VERTEX_ATTRIB7_NV* = 0x000086CD + GL_EVAL_VERTEX_ATTRIB8_NV* = 0x000086CE + GL_EVAL_VERTEX_ATTRIB9_NV* = 0x000086CF + GL_EVAL_VERTEX_ATTRIB10_NV* = 0x000086D0 + GL_EVAL_VERTEX_ATTRIB11_NV* = 0x000086D1 + GL_EVAL_VERTEX_ATTRIB12_NV* = 0x000086D2 + GL_EVAL_VERTEX_ATTRIB13_NV* = 0x000086D3 + GL_EVAL_VERTEX_ATTRIB14_NV* = 0x000086D4 + GL_EVAL_VERTEX_ATTRIB15_NV* = 0x000086D5 + GL_MAX_MAP_TESSELLATION_NV* = 0x000086D6 + GL_MAX_RATIONAL_EVAL_ORDER_NV* = 0x000086D7 + +proc glMapControlPointsNV*(target: TGLenum, index: TGLuint, thetype: TGLenum, + ustride: TGLsizei, vstride: TGLsizei, uorder: TGLint, + vorder: TGLint, thepacked: TGLboolean, points: PGLvoid){. + dynlib: dllname, importc.} +proc glMapParameterivNV*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glMapParameterfvNV*(target: TGLenum, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc.} +proc glGetMapControlPointsNV*(target: TGLenum, index: TGLuint, thetype: TGLenum, + ustride: TGLsizei, vstride: TGLsizei, + thepacked: TGLboolean, points: PGLvoid){. + dynlib: dllname, importc.} +proc glGetMapParameterivNV*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glGetMapParameterfvNV*(target: TGLenum, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc.} +proc glGetMapAttribParameterivNV*(target: TGLenum, index: TGLuint, pname: TGLenum, + params: PGLint){.dynlib: dllname, importc.} +proc glGetMapAttribParameterfvNV*(target: TGLenum, index: TGLuint, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, importc.} +proc glEvalMapsNV*(target: TGLenum, mode: TGLenum){.dynlib: dllname, importc.} + #***** GL_NV_fence *****// +const + GL_ALL_COMPLETED_NV* = 0x000084F2 + GL_FENCE_STATUS_NV* = 0x000084F3 + GL_FENCE_CONDITION_NV* = 0x000084F4 + +proc glGenFencesNV*(n: TGLsizei, fences: PGLuint){.dynlib: dllname, importc.} +proc glDeleteFencesNV*(n: TGLsizei, fences: PGLuint){.dynlib: dllname, importc.} +proc glSetFenceNV*(fence: TGLuint, condition: TGLenum){.dynlib: dllname, importc.} +proc glTestFenceNV*(fence: TGLuint): TGLboolean{.dynlib: dllname, importc.} +proc glFinishFenceNV*(fence: TGLuint){.dynlib: dllname, importc.} +proc glIsFenceNV*(fence: TGLuint): TGLboolean{.dynlib: dllname, importc.} +proc glGetFenceivNV*(fence: TGLuint, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} + #***** GL_NV_fog_distance *****// +const + GL_FOG_DISTANCE_MODE_NV* = 0x0000855A + GL_EYE_RADIAL_NV* = 0x0000855B + GL_EYE_PLANE_ABSOLUTE_NV* = 0x0000855C + + #***** GL_NV_light_max_exponent *****// +const + GL_MAX_SHININESS_NV* = 0x00008504 + GL_MAX_SPOT_EXPONENT_NV* = 0x00008505 + + #***** GL_NV_multisample_filter_hint *****// +const + GL_MULTISAMPLE_FILTER_HINT_NV* = 0x00008534 + + #***** GL_NV_occlusion_query *****// + # GL_OCCLUSION_TEST_HP { already defined } + # GL_OCCLUSION_TEST_RESULT_HP { already defined } +const + GL_PIXEL_COUNTER_BITS_NV* = 0x00008864 + GL_CURRENT_OCCLUSION_QUERY_ID_NV* = 0x00008865 + GL_PIXEL_COUNT_NV* = 0x00008866 + GL_PIXEL_COUNT_AVAILABLE_NV* = 0x00008867 + +proc glGenOcclusionQueriesNV*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, + importc.} +proc glDeleteOcclusionQueriesNV*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, + importc.} +proc glIsOcclusionQueryNV*(id: TGLuint): TGLboolean{.dynlib: dllname, importc.} +proc glBeginOcclusionQueryNV*(id: TGLuint){.dynlib: dllname, importc.} +proc glEndOcclusionQueryNV*(){.dynlib: dllname, importc.} +proc glGetOcclusionQueryivNV*(id: TGLuint, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glGetOcclusionQueryuivNV*(id: TGLuint, pname: TGLenum, params: PGLuint){. + dynlib: dllname, importc.} + #***** GL_NV_packed_depth_stencil *****// +const + GL_DEPTH_STENCIL_NV* = 0x000084F9 + GL_UNSIGNED_INT_24_8_NV* = 0x000084FA + + #***** GL_NV_point_sprite *****// +const + GL_POINT_SPRITE_NV* = 0x00008861 + GL_COORD_REPLACE_NV* = 0x00008862 + GL_POINT_SPRITE_R_MODE_NV* = 0x00008863 + +proc glPointParameteriNV*(pname: TGLenum, param: TGLint){.dynlib: dllname, importc.} +proc glPointParameterivNV*(pname: TGLenum, params: PGLint){.dynlib: dllname, + importc.} + #***** GL_NV_register_combiners *****// +const + GL_REGISTER_COMBINERS_NV* = 0x00008522 + GL_COMBINER0_NV* = 0x00008550 + GL_COMBINER1_NV* = 0x00008551 + GL_COMBINER2_NV* = 0x00008552 + GL_COMBINER3_NV* = 0x00008553 + GL_COMBINER4_NV* = 0x00008554 + GL_COMBINER5_NV* = 0x00008555 + GL_COMBINER6_NV* = 0x00008556 + GL_COMBINER7_NV* = 0x00008557 + GL_VARIABLE_A_NV* = 0x00008523 + GL_VARIABLE_B_NV* = 0x00008524 + GL_VARIABLE_C_NV* = 0x00008525 + GL_VARIABLE_D_NV* = 0x00008526 + GL_VARIABLE_E_NV* = 0x00008527 + GL_VARIABLE_F_NV* = 0x00008528 + GL_VARIABLE_G_NV* = 0x00008529 + GL_CONSTANT_COLOR0_NV* = 0x0000852A + GL_CONSTANT_COLOR1_NV* = 0x0000852B + GL_PRIMARY_COLOR_NV* = 0x0000852C + GL_SECONDARY_COLOR_NV* = 0x0000852D + GL_SPARE0_NV* = 0x0000852E + GL_SPARE1_NV* = 0x0000852F + GL_UNSIGNED_IDENTITY_NV* = 0x00008536 + GL_UNSIGNED_INVERT_NV* = 0x00008537 + GL_EXPAND_NORMAL_NV* = 0x00008538 + GL_EXPAND_NEGATE_NV* = 0x00008539 + GL_HALF_BIAS_NORMAL_NV* = 0x0000853A + GL_HALF_BIAS_NEGATE_NV* = 0x0000853B + GL_SIGNED_IDENTITY_NV* = 0x0000853C + GL_SIGNED_NEGATE_NV* = 0x0000853D + GL_E_TIMES_F_NV* = 0x00008531 + GL_SPARE0_PLUS_SECONDARY_COLOR_NV* = 0x00008532 + GL_SCALE_BY_TWO_NV* = 0x0000853E + GL_SCALE_BY_FOUR_NV* = 0x0000853F + GL_SCALE_BY_ONE_HALF_NV* = 0x00008540 + GL_BIAS_BY_NEGATIVE_ONE_HALF_NV* = 0x00008541 + GL_DISCARD_NV* = 0x00008530 + constGL_COMBINER_INPUT_NV* = 0x00008542 + GL_COMBINER_MAPPING_NV* = 0x00008543 + GL_COMBINER_COMPONENT_USAGE_NV* = 0x00008544 + GL_COMBINER_AB_DOT_PRODUCT_NV* = 0x00008545 + GL_COMBINER_CD_DOT_PRODUCT_NV* = 0x00008546 + GL_COMBINER_MUX_SUM_NV* = 0x00008547 + GL_COMBINER_SCALE_NV* = 0x00008548 + GL_COMBINER_BIAS_NV* = 0x00008549 + GL_COMBINER_AB_OUTPUT_NV* = 0x0000854A + GL_COMBINER_CD_OUTPUT_NV* = 0x0000854B + GL_COMBINER_SUM_OUTPUT_NV* = 0x0000854C + GL_NUM_GENERAL_COMBINERS_NV* = 0x0000854E + GL_COLOR_SUM_CLAMP_NV* = 0x0000854F + GL_MAX_GENERAL_COMBINERS_NV* = 0x0000854D + +proc glCombinerParameterfvNV*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, + importc.} +proc glCombinerParameterivNV*(pname: TGLenum, params: PGLint){.dynlib: dllname, + importc.} +proc glCombinerParameterfNV*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, + importc.} +proc glCombinerParameteriNV*(pname: TGLenum, param: TGLint){.dynlib: dllname, + importc.} +proc glCombinerInputNV*(stage: TGLenum, portion: TGLenum, variable: TGLenum, + input: TGLenum, mapping: TGLenum, componentUsage: TGLenum){. + dynlib: dllname, importc.} +proc glCombinerOutputNV*(stage: TGLenum, portion: TGLenum, abOutput: TGLenum, + cdOutput: TGLenum, sumOutput: TGLenum, scale: TGLenum, + bias: TGLenum, abDotProduct: TGLboolean, + cdDotProduct: TGLboolean, muxSum: TGLboolean){. + dynlib: dllname, importc.} +proc glFinalCombinerInputNV*(variable: TGLenum, input: TGLenum, mapping: TGLenum, + componentUsage: TGLenum){.dynlib: dllname, importc.} +proc glGetCombinerInputParameterfvNV*(stage: TGLenum, portion: TGLenum, + variable: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, + importc.} +proc glGetCombinerInputParameterivNV*(stage: TGLenum, portion: TGLenum, + variable: TGLenum, pname: TGLenum, + params: PGLint){.dynlib: dllname, importc.} +proc glGetCombinerOutputParameterfvNV*(stage: TGLenum, portion: TGLenum, + pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc.} +proc glGetCombinerOutputParameterivNV*(stage: TGLenum, portion: TGLenum, + pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glGetFinalCombinerInputParameterfvNV*(variable: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, importc.} +proc glGetFinalCombinerInputParameterivNV*(variable: TGLenum, pname: TGLenum, + params: PGLint){.dynlib: dllname, importc.} + #***** GL_NV_register_combiners2 *****// +const + GL_PER_STAGE_CONSTANTS_NV* = 0x00008535 + +proc glCombinerStageParameterfvNV*(stage: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, importc.} +proc glGetCombinerStageParameterfvNV*(stage: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, + importc.} + #***** GL_NV_texgen_emboss *****// +const + GL_EMBOSS_MAP_NV* = 0x0000855F + GL_EMBOSS_LIGHT_NV* = 0x0000855D + GL_EMBOSS_CONSTANT_NV* = 0x0000855E + + #***** GL_NV_texgen_reflection *****// +const + GL_NORMAL_MAP_NV* = 0x00008511 + GL_REFLECTION_MAP_NV* = 0x00008512 + + #***** GL_NV_texture_compression_vtc *****// + # GL_COMPRESSED_RGB_S3TC_DXT1_EXT { already defined } + # GL_COMPRESSED_RGBA_S3TC_DXT1_EXT { already defined } + # GL_COMPRESSED_RGBA_S3TC_DXT3_EXT { already defined } + # GL_COMPRESSED_RGBA_S3TC_DXT5_EXT { already defined } + #***** GL_NV_texture_env_combine4 *****// +const + GL_COMBINE4_NV* = 0x00008503 + GL_SOURCE3_RGB_NV* = 0x00008583 + GL_SOURCE3_ALPHA_NV* = 0x0000858B + GL_OPERAND3_RGB_NV* = 0x00008593 + GL_OPERAND3_ALPHA_NV* = 0x0000859B + + #***** GL_NV_texture_rectangle *****// +const + GL_TEXTURE_RECTANGLE_NV* = 0x000084F5 + GL_TEXTURE_BINDING_RECTANGLE_NV* = 0x000084F6 + GL_PROXY_TEXTURE_RECTANGLE_NV* = 0x000084F7 + GL_MAX_RECTANGLE_TEXTURE_SIZE_NV* = 0x000084F8 + + #***** GL_NV_texture_shader *****// +const + GL_TEXTURE_SHADER_NV* = 0x000086DE + GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV* = 0x000086D9 + GL_SHADER_OPERATION_NV* = 0x000086DF + GL_CULL_MODES_NV* = 0x000086E0 + GL_OFFSET_TEXTURE_MATRIX_NV* = 0x000086E1 + GL_OFFSET_TEXTURE_SCALE_NV* = 0x000086E2 + GL_OFFSET_TEXTURE_BIAS_NV* = 0x000086E3 + GL_PREVIOUS_TEXTURE_INPUT_NV* = 0x000086E4 + GL_CONST_EYE_NV* = 0x000086E5 + GL_SHADER_CONSISTENT_NV* = 0x000086DD + GL_PASS_THROUGH_NV* = 0x000086E6 + GL_CULL_FRAGMENT_NV* = 0x000086E7 + GL_OFFSET_TEXTURE_2D_NV* = 0x000086E8 + GL_OFFSET_TEXTURE_RECTANGLE_NV* = 0x0000864C + GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV* = 0x0000864D + GL_DEPENDENT_AR_TEXTURE_2D_NV* = 0x000086E9 + GL_DEPENDENT_GB_TEXTURE_2D_NV* = 0x000086EA + GL_DOT_PRODUCT_NV* = 0x000086EC + GL_DOT_PRODUCT_DEPTH_REPLACE_NV* = 0x000086ED + GL_DOT_PRODUCT_TEXTURE_2D_NV* = 0x000086EE + GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV* = 0x0000864E + GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV* = 0x000086F0 + GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV* = 0x000086F1 + GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV* = 0x000086F2 + GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV* = 0x000086F3 + GL_HILO_NV* = 0x000086F4 + GL_DSDT_NV* = 0x000086F5 + GL_DSDT_MAG_NV* = 0x000086F6 + GL_DSDT_MAG_VIB_NV* = 0x000086F7 + GL_UNSIGNED_INT_S8_S8_8_8_NV* = 0x000086DA + GL_UNSIGNED_INT_8_8_S8_S8_REV_NV* = 0x000086DB + GL_SIGNED_RGBA_NV* = 0x000086FB + GL_SIGNED_RGBA8_NV* = 0x000086FC + GL_SIGNED_RGB_NV* = 0x000086FE + GL_SIGNED_RGB8_NV* = 0x000086FF + GL_SIGNED_LUMINANCE_NV* = 0x00008701 + GL_SIGNED_LUMINANCE8_NV* = 0x00008702 + GL_SIGNED_LUMINANCE_ALPHA_NV* = 0x00008703 + GL_SIGNED_LUMINANCE8_ALPHA8_NV* = 0x00008704 + GL_SIGNED_ALPHA_NV* = 0x00008705 + GL_SIGNED_ALPHA8_NV* = 0x00008706 + GL_SIGNED_INTENSITY_NV* = 0x00008707 + GL_SIGNED_INTENSITY8_NV* = 0x00008708 + GL_SIGNED_RGB_UNSIGNED_ALPHA_NV* = 0x0000870C + GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV* = 0x0000870D + GL_HILO16_NV* = 0x000086F8 + GL_SIGNED_HILO_NV* = 0x000086F9 + GL_SIGNED_HILO16_NV* = 0x000086FA + GL_DSDT8_NV* = 0x00008709 + GL_DSDT8_MAG8_NV* = 0x0000870A + GL_DSDT_MAG_INTENSITY_NV* = 0x000086DC + GL_DSDT8_MAG8_INTENSITY8_NV* = 0x0000870B + GL_HI_SCALE_NV* = 0x0000870E + GL_LO_SCALE_NV* = 0x0000870F + GL_DS_SCALE_NV* = 0x00008710 + GL_DT_SCALE_NV* = 0x00008711 + GL_MAGNITUDE_SCALE_NV* = 0x00008712 + GL_VIBRANCE_SCALE_NV* = 0x00008713 + GL_HI_BIAS_NV* = 0x00008714 + GL_LO_BIAS_NV* = 0x00008715 + GL_DS_BIAS_NV* = 0x00008716 + GL_DT_BIAS_NV* = 0x00008717 + GL_MAGNITUDE_BIAS_NV* = 0x00008718 + GL_VIBRANCE_BIAS_NV* = 0x00008719 + GL_TEXTURE_BORDER_VALUES_NV* = 0x0000871A + GL_TEXTURE_HI_SIZE_NV* = 0x0000871B + GL_TEXTURE_LO_SIZE_NV* = 0x0000871C + GL_TEXTURE_DS_SIZE_NV* = 0x0000871D + GL_TEXTURE_DT_SIZE_NV* = 0x0000871E + GL_TEXTURE_MAG_SIZE_NV* = 0x0000871F + + #***** GL_NV_texture_shader2 *****// +const + GL_DOT_PRODUCT_TEXTURE_3D_NV* = 0x000086EF # GL_HILO_NV { already defined } + # GL_DSDT_NV { already defined } + # GL_DSDT_MAG_NV { already defined } + # GL_DSDT_MAG_VIB_NV { already defined } + # GL_UNSIGNED_INT_S8_S8_8_8_NV { already defined } + # GL_UNSIGNED_INT_8_8_S8_S8_REV_NV { already defined } + # GL_SIGNED_RGBA_NV { already defined } + # GL_SIGNED_RGBA8_NV { already defined } + # GL_SIGNED_RGB_NV { already defined } + # GL_SIGNED_RGB8_NV { already defined } + # GL_SIGNED_LUMINANCE_NV { already defined } + # GL_SIGNED_LUMINANCE8_NV { already defined } + # GL_SIGNED_LUMINANCE_ALPHA_NV { already defined } + # GL_SIGNED_LUMINANCE8_ALPHA8_NV { already defined } + # GL_SIGNED_ALPHA_NV { already defined } + # GL_SIGNED_ALPHA8_NV { already defined } + # GL_SIGNED_INTENSITY_NV { already defined } + # GL_SIGNED_INTENSITY8_NV { already defined } + # GL_SIGNED_RGB_UNSIGNED_ALPHA_NV { already defined } + # GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV { already defined } + # GL_HILO16_NV { already defined } + # GL_SIGNED_HILO_NV { already defined } + # GL_SIGNED_HILO16_NV { already defined } + # GL_DSDT8_NV { already defined } + # GL_DSDT8_MAG8_NV { already defined } + # GL_DSDT_MAG_INTENSITY_NV { already defined } + # GL_DSDT8_MAG8_INTENSITY8_NV { already defined } + + #***** GL_NV_texture_shader3 *****// +const + GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV* = 0x00008850 + GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV* = 0x00008851 + GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV* = 0x00008852 + GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV* = 0x00008853 + GL_OFFSET_HILO_TEXTURE_2D_NV* = 0x00008854 + GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV* = 0x00008855 + GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV* = 0x00008856 + GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV* = 0x00008857 + GL_DEPENDENT_HILO_TEXTURE_2D_NV* = 0x00008858 + GL_DEPENDENT_RGB_TEXTURE_3D_NV* = 0x00008859 + GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV* = 0x0000885A + GL_DOT_PRODUCT_PASS_THROUGH_NV* = 0x0000885B + GL_DOT_PRODUCT_TEXTURE_1D_NV* = 0x0000885C + GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV* = 0x0000885D + GL_HILO8_NV* = 0x0000885E + GL_SIGNED_HILO8_NV* = 0x0000885F + GL_FORCE_BLUE_TO_ONE_NV* = 0x00008860 + + #***** GL_NV_vertex_array_range *****// +const + constGL_VERTEX_ARRAY_RANGE_NV* = 0x0000851D + GL_VERTEX_ARRAY_RANGE_LENGTH_NV* = 0x0000851E + GL_VERTEX_ARRAY_RANGE_VALID_NV* = 0x0000851F + GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV* = 0x00008520 + GL_VERTEX_ARRAY_RANGE_POINTER_NV* = 0x00008521 + +proc glVertexArrayRangeNV*(len: TGLsizei, pointer: PGLvoid){.dynlib: dllname, + importc.} +proc glFlushVertexArrayRangeNV*(){.dynlib: dllname, importc.} + #***** GL_NV_vertex_array_range2 *****// +const + GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV* = 0x00008533 + + #***** GL_NV_vertex_program *****// +const + GL_VERTEX_PROGRAM_NV* = 0x00008620 + GL_VERTEX_PROGRAM_POINT_SIZE_NV* = 0x00008642 + GL_VERTEX_PROGRAM_TWO_SIDE_NV* = 0x00008643 + GL_VERTEX_STATE_PROGRAM_NV* = 0x00008621 + GL_ATTRIB_ARRAY_SIZE_NV* = 0x00008623 + GL_ATTRIB_ARRAY_STRIDE_NV* = 0x00008624 + GL_ATTRIB_ARRAY_TYPE_NV* = 0x00008625 + GL_CURRENT_ATTRIB_NV* = 0x00008626 + GL_PROGRAM_PARAMETER_NV* = 0x00008644 + GL_ATTRIB_ARRAY_POINTER_NV* = 0x00008645 + GL_PROGRAM_TARGET_NV* = 0x00008646 + GL_PROGRAM_LENGTH_NV* = 0x00008627 + GL_PROGRAM_RESIDENT_NV* = 0x00008647 + GL_PROGRAM_STRING_NV* = 0x00008628 + constGL_TRACK_MATRIX_NV* = 0x00008648 + GL_TRACK_MATRIX_TRANSFORM_NV* = 0x00008649 + GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV* = 0x0000862E + GL_MAX_TRACK_MATRICES_NV* = 0x0000862F + GL_CURRENT_MATRIX_STACK_DEPTH_NV* = 0x00008640 + GL_CURRENT_MATRIX_NV* = 0x00008641 + GL_VERTEX_PROGRAM_BINDING_NV* = 0x0000864A + GL_PROGRAM_ERROR_POSITION_NV* = 0x0000864B + GL_MODELVIEW_PROJECTION_NV* = 0x00008629 + GL_MATRIX0_NV* = 0x00008630 + GL_MATRIX1_NV* = 0x00008631 + GL_MATRIX2_NV* = 0x00008632 + GL_MATRIX3_NV* = 0x00008633 + GL_MATRIX4_NV* = 0x00008634 + GL_MATRIX5_NV* = 0x00008635 + GL_MATRIX6_NV* = 0x00008636 + GL_MATRIX7_NV* = 0x00008637 + GL_IDENTITY_NV* = 0x0000862A + GL_INVERSE_NV* = 0x0000862B + GL_TRANSPOSE_NV* = 0x0000862C + GL_INVERSE_TRANSPOSE_NV* = 0x0000862D + GL_VERTEX_ATTRIB_ARRAY0_NV* = 0x00008650 + GL_VERTEX_ATTRIB_ARRAY1_NV* = 0x00008651 + GL_VERTEX_ATTRIB_ARRAY2_NV* = 0x00008652 + GL_VERTEX_ATTRIB_ARRAY3_NV* = 0x00008653 + GL_VERTEX_ATTRIB_ARRAY4_NV* = 0x00008654 + GL_VERTEX_ATTRIB_ARRAY5_NV* = 0x00008655 + GL_VERTEX_ATTRIB_ARRAY6_NV* = 0x00008656 + GL_VERTEX_ATTRIB_ARRAY7_NV* = 0x00008657 + GL_VERTEX_ATTRIB_ARRAY8_NV* = 0x00008658 + GL_VERTEX_ATTRIB_ARRAY9_NV* = 0x00008659 + GL_VERTEX_ATTRIB_ARRAY10_NV* = 0x0000865A + GL_VERTEX_ATTRIB_ARRAY11_NV* = 0x0000865B + GL_VERTEX_ATTRIB_ARRAY12_NV* = 0x0000865C + GL_VERTEX_ATTRIB_ARRAY13_NV* = 0x0000865D + GL_VERTEX_ATTRIB_ARRAY14_NV* = 0x0000865E + GL_VERTEX_ATTRIB_ARRAY15_NV* = 0x0000865F + GL_MAP1_VERTEX_ATTRIB0_4_NV* = 0x00008660 + GL_MAP1_VERTEX_ATTRIB1_4_NV* = 0x00008661 + GL_MAP1_VERTEX_ATTRIB2_4_NV* = 0x00008662 + GL_MAP1_VERTEX_ATTRIB3_4_NV* = 0x00008663 + GL_MAP1_VERTEX_ATTRIB4_4_NV* = 0x00008664 + GL_MAP1_VERTEX_ATTRIB5_4_NV* = 0x00008665 + GL_MAP1_VERTEX_ATTRIB6_4_NV* = 0x00008666 + GL_MAP1_VERTEX_ATTRIB7_4_NV* = 0x00008667 + GL_MAP1_VERTEX_ATTRIB8_4_NV* = 0x00008668 + GL_MAP1_VERTEX_ATTRIB9_4_NV* = 0x00008669 + GL_MAP1_VERTEX_ATTRIB10_4_NV* = 0x0000866A + GL_MAP1_VERTEX_ATTRIB11_4_NV* = 0x0000866B + GL_MAP1_VERTEX_ATTRIB12_4_NV* = 0x0000866C + GL_MAP1_VERTEX_ATTRIB13_4_NV* = 0x0000866D + GL_MAP1_VERTEX_ATTRIB14_4_NV* = 0x0000866E + GL_MAP1_VERTEX_ATTRIB15_4_NV* = 0x0000866F + GL_MAP2_VERTEX_ATTRIB0_4_NV* = 0x00008670 + GL_MAP2_VERTEX_ATTRIB1_4_NV* = 0x00008671 + GL_MAP2_VERTEX_ATTRIB2_4_NV* = 0x00008672 + GL_MAP2_VERTEX_ATTRIB3_4_NV* = 0x00008673 + GL_MAP2_VERTEX_ATTRIB4_4_NV* = 0x00008674 + GL_MAP2_VERTEX_ATTRIB5_4_NV* = 0x00008675 + GL_MAP2_VERTEX_ATTRIB6_4_NV* = 0x00008676 + GL_MAP2_VERTEX_ATTRIB7_4_NV* = 0x00008677 + GL_MAP2_VERTEX_ATTRIB8_4_NV* = 0x00008678 + GL_MAP2_VERTEX_ATTRIB9_4_NV* = 0x00008679 + GL_MAP2_VERTEX_ATTRIB10_4_NV* = 0x0000867A + GL_MAP2_VERTEX_ATTRIB11_4_NV* = 0x0000867B + GL_MAP2_VERTEX_ATTRIB12_4_NV* = 0x0000867C + GL_MAP2_VERTEX_ATTRIB13_4_NV* = 0x0000867D + GL_MAP2_VERTEX_ATTRIB14_4_NV* = 0x0000867E + GL_MAP2_VERTEX_ATTRIB15_4_NV* = 0x0000867F + +proc glBindProgramNV*(target: TGLenum, id: TGLuint){.dynlib: dllname, importc.} +proc glDeleteProgramsNV*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, importc.} +proc glExecuteProgramNV*(target: TGLenum, id: TGLuint, params: PGLfloat){. + dynlib: dllname, importc.} +proc glGenProgramsNV*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, importc.} +proc glAreProgramsResidentNV*(n: TGLsizei, ids: PGLuint, residences: PGLboolean): TGLboolean{. + dynlib: dllname, importc.} +proc glRequestResidentProgramsNV*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, + importc.} +proc glGetProgramParameterfvNV*(target: TGLenum, index: TGLuint, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, importc.} +proc glGetProgramParameterdvNV*(target: TGLenum, index: TGLuint, pname: TGLenum, + params: PGLdouble){.dynlib: dllname, importc.} +proc glGetProgramivNV*(id: TGLuint, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glGetProgramStringNV*(id: TGLuint, pname: TGLenum, theProgram: PGLubyte){. + dynlib: dllname, importc.} +proc glGetTrackMatrixivNV*(target: TGLenum, address: TGLuint, pname: TGLenum, + params: PGLint){.dynlib: dllname, importc.} +proc glGetVertexAttribdvNV*(index: TGLuint, pname: TGLenum, params: PGLdouble){. + dynlib: dllname, importc.} +proc glGetVertexAttribfvNV*(index: TGLuint, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc.} +proc glGetVertexAttribivNV*(index: TGLuint, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glGetVertexAttribPointervNV*(index: TGLuint, pname: TGLenum, pointer: PGLvoid){. + dynlib: dllname, importc.} +proc glIsProgramNV*(id: TGLuint): TGLboolean{.dynlib: dllname, importc.} +proc glLoadProgramNV*(target: TGLenum, id: TGLuint, length: TGLsizei, + theProgram: PGLubyte){.dynlib: dllname, importc.} +proc glProgramParameter4fNV*(target: TGLenum, index: TGLuint, x: TGLfloat, + y: TGLfloat, z: TGLfloat, w: TGLfloat){. + dynlib: dllname, importc.} +proc glProgramParameter4fvNV*(target: TGLenum, index: TGLuint, params: PGLfloat){. + dynlib: dllname, importc.} +proc glProgramParameters4dvNV*(target: TGLenum, index: TGLuint, num: TGLuint, + params: PGLdouble){.dynlib: dllname, importc.} +proc glProgramParameters4fvNV*(target: TGLenum, index: TGLuint, num: TGLuint, + params: PGLfloat){.dynlib: dllname, importc.} +proc glTrackMatrixNV*(target: TGLenum, address: TGLuint, matrix: TGLenum, + transform: TGLenum){.dynlib: dllname, importc.} +proc glVertexAttribPointerNV*(index: TGLuint, size: TGLint, thetype: TGLenum, + stride: TGLsizei, pointer: PGLvoid){. + dynlib: dllname, importc.} +proc glVertexAttrib1sNV*(index: TGLuint, x: TGLshort){.dynlib: dllname, importc.} +proc glVertexAttrib1fNV*(index: TGLuint, x: TGLfloat){.dynlib: dllname, importc.} +proc glVertexAttrib1dNV*(index: TGLuint, x: TGLdouble){.dynlib: dllname, importc.} +proc glVertexAttrib2sNV*(index: TGLuint, x: TGLshort, y: TGLshort){. + dynlib: dllname, importc.} +proc glVertexAttrib2fNV*(index: TGLuint, x: TGLfloat, y: TGLfloat){. + dynlib: dllname, importc.} +proc glVertexAttrib2dNV*(index: TGLuint, x: TGLdouble, y: TGLdouble){. + dynlib: dllname, importc.} +proc glVertexAttrib3sNV*(index: TGLuint, x: TGLshort, y: TGLshort, z: TGLshort){. + dynlib: dllname, importc.} +proc glVertexAttrib3fNV*(index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat){. + dynlib: dllname, importc.} +proc glVertexAttrib3dNV*(index: TGLuint, x: TGLdouble, y: TGLdouble, z: TGLdouble){. + dynlib: dllname, importc.} +proc glVertexAttrib4sNV*(index: TGLuint, x: TGLshort, y: TGLshort, z: TGLshort, + w: TGLshort){.dynlib: dllname, importc.} +proc glVertexAttrib4fNV*(index: TGLuint, x: TGLfloat, y: TGLfloat, z: TGLfloat, + w: TGLfloat){.dynlib: dllname, importc.} +proc glVertexAttrib4dNV*(index: TGLuint, x: TGLdouble, y: TGLdouble, z: TGLdouble, + w: TGLdouble){.dynlib: dllname, importc.} +proc glVertexAttrib4ubNV*(index: TGLuint, x: TGLubyte, y: TGLubyte, z: TGLubyte, + w: TGLubyte){.dynlib: dllname, importc.} +proc glVertexAttrib1svNV*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc.} +proc glVertexAttrib1fvNV*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc.} +proc glVertexAttrib1dvNV*(index: TGLuint, v: PGLdouble){.dynlib: dllname, importc.} +proc glVertexAttrib2svNV*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc.} +proc glVertexAttrib2fvNV*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc.} +proc glVertexAttrib2dvNV*(index: TGLuint, v: PGLdouble){.dynlib: dllname, importc.} +proc glVertexAttrib3svNV*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc.} +proc glVertexAttrib3fvNV*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc.} +proc glVertexAttrib3dvNV*(index: TGLuint, v: PGLdouble){.dynlib: dllname, importc.} +proc glVertexAttrib4svNV*(index: TGLuint, v: PGLshort){.dynlib: dllname, importc.} +proc glVertexAttrib4fvNV*(index: TGLuint, v: PGLfloat){.dynlib: dllname, importc.} +proc glVertexAttrib4dvNV*(index: TGLuint, v: PGLdouble){.dynlib: dllname, importc.} +proc glVertexAttrib4ubvNV*(index: TGLuint, v: PGLubyte){.dynlib: dllname, importc.} +proc glVertexAttribs1svNV*(index: TGLuint, n: TGLsizei, v: PGLshort){. + dynlib: dllname, importc.} +proc glVertexAttribs1fvNV*(index: TGLuint, n: TGLsizei, v: PGLfloat){. + dynlib: dllname, importc.} +proc glVertexAttribs1dvNV*(index: TGLuint, n: TGLsizei, v: PGLdouble){. + dynlib: dllname, importc.} +proc glVertexAttribs2svNV*(index: TGLuint, n: TGLsizei, v: PGLshort){. + dynlib: dllname, importc.} +proc glVertexAttribs2fvNV*(index: TGLuint, n: TGLsizei, v: PGLfloat){. + dynlib: dllname, importc.} +proc glVertexAttribs2dvNV*(index: TGLuint, n: TGLsizei, v: PGLdouble){. + dynlib: dllname, importc.} +proc glVertexAttribs3svNV*(index: TGLuint, n: TGLsizei, v: PGLshort){. + dynlib: dllname, importc.} +proc glVertexAttribs3fvNV*(index: TGLuint, n: TGLsizei, v: PGLfloat){. + dynlib: dllname, importc.} +proc glVertexAttribs3dvNV*(index: TGLuint, n: TGLsizei, v: PGLdouble){. + dynlib: dllname, importc.} +proc glVertexAttribs4svNV*(index: TGLuint, n: TGLsizei, v: PGLshort){. + dynlib: dllname, importc.} +proc glVertexAttribs4fvNV*(index: TGLuint, n: TGLsizei, v: PGLfloat){. + dynlib: dllname, importc.} +proc glVertexAttribs4dvNV*(index: TGLuint, n: TGLsizei, v: PGLdouble){. + dynlib: dllname, importc.} +proc glVertexAttribs4ubvNV*(index: TGLuint, n: TGLsizei, v: PGLubyte){. + dynlib: dllname, importc.} + #***** GL_NV_vertex_program1_1 *****// + #***** GL_ATI_element_array *****// +const + GL_ELEMENT_ARRAY_ATI* = 0x00008768 + GL_ELEMENT_ARRAY_TYPE_ATI* = 0x00008769 + GL_ELEMENT_ARRAY_POINTER_ATI* = 0x0000876A + +proc glElementPointerATI*(thetype: TGLenum, pointer: PGLvoid){.dynlib: dllname, + importc.} +proc glDrawElementArrayATI*(mode: TGLenum, count: TGLsizei){.dynlib: dllname, + importc.} +proc glDrawRangeElementArrayATI*(mode: TGLenum, start: TGLuint, theend: TGLuint, + count: TGLsizei){.dynlib: dllname, importc.} + #***** GL_ATI_envmap_bumpmap *****// +const + GL_BUMP_ROT_MATRIX_ATI* = 0x00008775 + GL_BUMP_ROT_MATRIX_SIZE_ATI* = 0x00008776 + GL_BUMP_NUM_TEX_UNITS_ATI* = 0x00008777 + GL_BUMP_TEX_UNITS_ATI* = 0x00008778 + GL_DUDV_ATI* = 0x00008779 + GL_DU8DV8_ATI* = 0x0000877A + GL_BUMP_ENVMAP_ATI* = 0x0000877B + GL_BUMP_TARGET_ATI* = 0x0000877C + +proc glTexBumpParameterivATI*(pname: TGLenum, param: PGLint){.dynlib: dllname, + importc.} +proc glTexBumpParameterfvATI*(pname: TGLenum, param: PGLfloat){.dynlib: dllname, + importc.} +proc glGetTexBumpParameterivATI*(pname: TGLenum, param: PGLint){.dynlib: dllname, + importc.} +proc glGetTexBumpParameterfvATI*(pname: TGLenum, param: PGLfloat){. + dynlib: dllname, importc.} + #***** GL_ATI_fragment_shader *****// +const + GL_FRAGMENT_SHADER_ATI* = 0x00008920 + GL_REG_0_ATI* = 0x00008921 + GL_REG_1_ATI* = 0x00008922 + GL_REG_2_ATI* = 0x00008923 + GL_REG_3_ATI* = 0x00008924 + GL_REG_4_ATI* = 0x00008925 + GL_REG_5_ATI* = 0x00008926 + GL_CON_0_ATI* = 0x00008941 + GL_CON_1_ATI* = 0x00008942 + GL_CON_2_ATI* = 0x00008943 + GL_CON_3_ATI* = 0x00008944 + GL_CON_4_ATI* = 0x00008945 + GL_CON_5_ATI* = 0x00008946 + GL_CON_6_ATI* = 0x00008947 + GL_CON_7_ATI* = 0x00008948 + GL_MOV_ATI* = 0x00008961 + GL_ADD_ATI* = 0x00008963 + GL_MUL_ATI* = 0x00008964 + GL_SUB_ATI* = 0x00008965 + GL_DOT3_ATI* = 0x00008966 + GL_DOT4_ATI* = 0x00008967 + GL_MAD_ATI* = 0x00008968 + GL_LERP_ATI* = 0x00008969 + GL_CND_ATI* = 0x0000896A + GL_CND0_ATI* = 0x0000896B + GL_DOT2_ADD_ATI* = 0x0000896C + GL_SECONDARY_INTERPOLATOR_ATI* = 0x0000896D + GL_SWIZZLE_STR_ATI* = 0x00008976 + GL_SWIZZLE_STQ_ATI* = 0x00008977 + GL_SWIZZLE_STR_DR_ATI* = 0x00008978 + GL_SWIZZLE_STQ_DQ_ATI* = 0x00008979 + GL_RED_BIT_ATI* = 0x00000001 + GL_GREEN_BIT_ATI* = 0x00000002 + GL_BLUE_BIT_ATI* = 0x00000004 + GL_2X_BIT_ATI* = 0x00000001 + GL_4X_BIT_ATI* = 0x00000002 + GL_8X_BIT_ATI* = 0x00000004 + GL_HALF_BIT_ATI* = 0x00000008 + GL_QUARTER_BIT_ATI* = 0x00000010 + GL_EIGHTH_BIT_ATI* = 0x00000020 + GL_SATURATE_BIT_ATI* = 0x00000040 # GL_2X_BIT_ATI { already defined } + GL_COMP_BIT_ATI* = 0x00000002 + GL_NEGATE_BIT_ATI* = 0x00000004 + GL_BIAS_BIT_ATI* = 0x00000008 + +proc glGenFragmentShadersATI*(range: TGLuint): TGLuint{.dynlib: dllname, importc.} +proc glBindFragmentShaderATI*(id: TGLuint){.dynlib: dllname, importc.} +proc glDeleteFragmentShaderATI*(id: TGLuint){.dynlib: dllname, importc.} +proc glBeginFragmentShaderATI*(){.dynlib: dllname, importc.} +proc glEndFragmentShaderATI*(){.dynlib: dllname, importc.} +proc glPassTexCoordATI*(dst: TGLuint, coord: TGLuint, swizzle: TGLenum){. + dynlib: dllname, importc.} +proc glSampleMapATI*(dst: TGLuint, interp: TGLuint, swizzle: TGLenum){. + dynlib: dllname, importc.} +proc glColorFragmentOp1ATI*(op: TGLenum, dst: TGLuint, dstMask: TGLuint, + dstMod: TGLuint, arg1: TGLuint, arg1Rep: TGLuint, + arg1Mod: TGLuint){.dynlib: dllname, importc.} +proc glColorFragmentOp2ATI*(op: TGLenum, dst: TGLuint, dstMask: TGLuint, + dstMod: TGLuint, arg1: TGLuint, arg1Rep: TGLuint, + arg1Mod: TGLuint, arg2: TGLuint, arg2Rep: TGLuint, + arg2Mod: TGLuint){.dynlib: dllname, importc.} +proc glColorFragmentOp3ATI*(op: TGLenum, dst: TGLuint, dstMask: TGLuint, + dstMod: TGLuint, arg1: TGLuint, arg1Rep: TGLuint, + arg1Mod: TGLuint, arg2: TGLuint, arg2Rep: TGLuint, + arg2Mod: TGLuint, arg3: TGLuint, arg3Rep: TGLuint, + arg3Mod: TGLuint){.dynlib: dllname, importc.} +proc glAlphaFragmentOp1ATI*(op: TGLenum, dst: TGLuint, dstMod: TGLuint, + arg1: TGLuint, arg1Rep: TGLuint, arg1Mod: TGLuint){. + dynlib: dllname, importc.} +proc glAlphaFragmentOp2ATI*(op: TGLenum, dst: TGLuint, dstMod: TGLuint, + arg1: TGLuint, arg1Rep: TGLuint, arg1Mod: TGLuint, + arg2: TGLuint, arg2Rep: TGLuint, arg2Mod: TGLuint){. + dynlib: dllname, importc.} +proc glAlphaFragmentOp3ATI*(op: TGLenum, dst: TGLuint, dstMod: TGLuint, + arg1: TGLuint, arg1Rep: TGLuint, arg1Mod: TGLuint, + arg2: TGLuint, arg2Rep: TGLuint, arg2Mod: TGLuint, + arg3: TGLuint, arg3Rep: TGLuint, arg3Mod: TGLuint){. + dynlib: dllname, importc.} +proc glSetFragmentShaderConstantATI*(dst: TGLuint, value: PGLfloat){. + dynlib: dllname, importc.} + #***** GL_ATI_pn_triangles *****// +const + GL_PN_TRIANGLES_ATI* = 0x000087F0 + GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI* = 0x000087F1 + GL_PN_TRIANGLES_POINT_MODE_ATI* = 0x000087F2 + GL_PN_TRIANGLES_NORMAL_MODE_ATI* = 0x000087F3 + GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI* = 0x000087F4 + GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI* = 0x000087F5 + GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI* = 0x000087F6 + GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI* = 0x000087F7 + GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI* = 0x000087F8 + +proc glPNTrianglesiATI*(pname: TGLenum, param: TGLint){.dynlib: dllname, importc.} +proc glPNTrianglesfATI*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc.} + #***** GL_ATI_texture_mirror_once *****// +const + GL_MIRROR_CLAMP_ATI* = 0x00008742 + GL_MIRROR_CLAMP_TO_EDGE_ATI* = 0x00008743 + + #***** GL_ATI_vertex_array_object *****// +const + GL_STATIC_ATI* = 0x00008760 + GL_DYNAMIC_ATI* = 0x00008761 + GL_PRESERVE_ATI* = 0x00008762 + GL_DISCARD_ATI* = 0x00008763 + GL_OBJECT_BUFFER_SIZE_ATI* = 0x00008764 + GL_OBJECT_BUFFER_USAGE_ATI* = 0x00008765 + GL_ARRAY_OBJECT_BUFFER_ATI* = 0x00008766 + GL_ARRAY_OBJECT_OFFSET_ATI* = 0x00008767 + +proc glNewObjectBufferATI*(size: TGLsizei, pointer: PGLvoid, usage: TGLenum): TGLuint{. + dynlib: dllname, importc.} +proc glIsObjectBufferATI*(buffer: TGLuint): TGLboolean{.dynlib: dllname, importc.} +proc glUpdateObjectBufferATI*(buffer: TGLuint, offset: TGLuint, size: TGLsizei, + pointer: PGLvoid, preserve: TGLenum){. + dynlib: dllname, importc.} +proc glGetObjectBufferfvATI*(buffer: TGLuint, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc.} +proc glGetObjectBufferivATI*(buffer: TGLuint, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glDeleteObjectBufferATI*(buffer: TGLuint){.dynlib: dllname, importc.} +proc glArrayObjectATI*(thearray: TGLenum, size: TGLint, thetype: TGLenum, + stride: TGLsizei, buffer: TGLuint, offset: TGLuint){. + dynlib: dllname, importc.} +proc glGetArrayObjectfvATI*(thearray: TGLenum, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc.} +proc glGetArrayObjectivATI*(thearray: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glVariantArrayObjectATI*(id: TGLuint, thetype: TGLenum, stride: TGLsizei, + buffer: TGLuint, offset: TGLuint){.dynlib: dllname, + importc.} +proc glGetVariantArrayObjectfvATI*(id: TGLuint, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc.} +proc glGetVariantArrayObjectivATI*(id: TGLuint, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} + #***** GL_ATI_vertex_streams *****// +const + GL_MAX_VERTEX_STREAMS_ATI* = 0x0000876B + GL_VERTEX_STREAM0_ATI* = 0x0000876C + GL_VERTEX_STREAM1_ATI* = 0x0000876D + GL_VERTEX_STREAM2_ATI* = 0x0000876E + GL_VERTEX_STREAM3_ATI* = 0x0000876F + GL_VERTEX_STREAM4_ATI* = 0x00008770 + GL_VERTEX_STREAM5_ATI* = 0x00008771 + GL_VERTEX_STREAM6_ATI* = 0x00008772 + GL_VERTEX_STREAM7_ATI* = 0x00008773 + GL_VERTEX_SOURCE_ATI* = 0x00008774 + +proc glVertexStream1s*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, + importc.} +proc glVertexStream1i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc.} +proc glVertexStream1f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, + importc.} +proc glVertexStream1d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, + importc.} +proc glVertexStream1sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, + importc.} +proc glVertexStream1iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc.} +proc glVertexStream1fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, + importc.} +proc glVertexStream1dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, + importc.} +proc glVertexStream2s*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, + importc.} +proc glVertexStream2i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc.} +proc glVertexStream2f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, + importc.} +proc glVertexStream2d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, + importc.} +proc glVertexStream2sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, + importc.} +proc glVertexStream2iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc.} +proc glVertexStream2fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, + importc.} +proc glVertexStream2dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, + importc.} +proc glVertexStream3s*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, + importc.} +proc glVertexStream3i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc.} +proc glVertexStream3f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, + importc.} +proc glVertexStream3d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, + importc.} +proc glVertexStream3sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, + importc.} +proc glVertexStream3iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc.} +proc glVertexStream3fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, + importc.} +proc glVertexStream3dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, + importc.} +proc glVertexStream4s*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, + importc.} +proc glVertexStream4i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc.} +proc glVertexStream4f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, + importc.} +proc glVertexStream4d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, + importc.} +proc glVertexStream4sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, + importc.} +proc glVertexStream4iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc.} +proc glVertexStream4fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, + importc.} +proc glVertexStream4dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, + importc.} +proc glNormalStream3b*(stream: TGLenum, coords: TGLByte){.dynlib: dllname, importc.} +proc glNormalStream3s*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, + importc.} +proc glNormalStream3i*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc.} +proc glNormalStream3f*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, + importc.} +proc glNormalStream3d*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, + importc.} +proc glNormalStream3bv*(stream: TGLenum, coords: TGLByte){.dynlib: dllname, + importc.} +proc glNormalStream3sv*(stream: TGLenum, coords: TGLshort){.dynlib: dllname, + importc.} +proc glNormalStream3iv*(stream: TGLenum, coords: TGLint){.dynlib: dllname, importc.} +proc glNormalStream3fv*(stream: TGLenum, coords: TGLfloat){.dynlib: dllname, + importc.} +proc glNormalStream3dv*(stream: TGLenum, coords: TGLdouble){.dynlib: dllname, + importc.} +proc glClientActiveVertexStream*(stream: TGLenum){.dynlib: dllname, importc.} +proc glVertexBlendEnvi*(pname: TGLenum, param: TGLint){.dynlib: dllname, importc.} +proc glVertexBlendEnvf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc.} + #***** GL_3DFX_texture_compression_FXT1 *****// +const + GL_COMPRESSED_RGB_FXT1_3DFX* = 0x000086B0 + GL_COMPRESSED_RGBA_FXT1_3DFX* = 0x000086B1 + + #***** GL_IBM_cull_vertex *****// +const + GL_CULL_VERTEX_IBM* = 0x0001928A + + #***** GL_IBM_multimode_draw_arrays *****// +proc glMultiModeDrawArraysIBM*(mode: PGLenum, first: PGLint, count: PGLsizei, + primcount: TGLsizei, modestride: TGLint){. + dynlib: dllname, importc.} +proc glMultiModeDrawElementsIBM*(mode: PGLenum, count: PGLsizei, + thetype: TGLenum, indices: PGLvoid, + primcount: TGLsizei, modestride: TGLint){. + dynlib: dllname, importc.} + #***** GL_IBM_raster_pos_clip *****// +const + GL_RASTER_POSITION_UNCLIPPED_IBM* = 0x00019262 + + #***** GL_IBM_texture_mirrored_repeat *****// +const + GL_MIRRORED_REPEAT_IBM* = 0x00008370 + + #***** GL_IBM_vertex_array_lists *****// +const + GL_VERTEX_ARRAY_LIST_IBM* = 0x0001929E + GL_NORMAL_ARRAY_LIST_IBM* = 0x0001929F + GL_COLOR_ARRAY_LIST_IBM* = 0x000192A0 + GL_INDEX_ARRAY_LIST_IBM* = 0x000192A1 + GL_TEXTURE_COORD_ARRAY_LIST_IBM* = 0x000192A2 + GL_EDGE_FLAG_ARRAY_LIST_IBM* = 0x000192A3 + GL_FOG_COORDINATE_ARRAY_LIST_IBM* = 0x000192A4 + GL_SECONDARY_COLOR_ARRAY_LIST_IBM* = 0x000192A5 + GL_VERTEX_ARRAY_LIST_STRIDE_IBM* = 0x000192A8 + GL_NORMAL_ARRAY_LIST_STRIDE_IBM* = 0x000192A9 + GL_COLOR_ARRAY_LIST_STRIDE_IBM* = 0x000192AA + GL_INDEX_ARRAY_LIST_STRIDE_IBM* = 0x000192AB + GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM* = 0x000192AC + GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM* = 0x000192AD + GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM* = 0x000192AE + GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM* = 0x000192AF + +proc glColorPointerListIBM*(size: TGLint, thetype: TGLenum, stride: TGLint, + pointer: PGLvoid, ptrstride: TGLint){. + dynlib: dllname, importc.} +proc glSecondaryColorPointerListIBM*(size: TGLint, thetype: TGLenum, + stride: TGLint, pointer: PGLvoid, + ptrstride: TGLint){.dynlib: dllname, importc.} +proc glEdgeFlagPointerListIBM*(stride: TGLint, pointer: PGLboolean, + ptrstride: TGLint){.dynlib: dllname, importc.} +proc glFogCoordPointerListIBM*(thetype: TGLenum, stride: TGLint, pointer: PGLvoid, + ptrstride: TGLint){.dynlib: dllname, importc.} +proc glNormalPointerListIBM*(thetype: TGLenum, stride: TGLint, pointer: PGLvoid, + ptrstride: TGLint){.dynlib: dllname, importc.} +proc glTexCoordPointerListIBM*(size: TGLint, thetype: TGLenum, stride: TGLint, + pointer: PGLvoid, ptrstride: TGLint){. + dynlib: dllname, importc.} +proc glVertexPointerListIBM*(size: TGLint, thetype: TGLenum, stride: TGLint, + pointer: PGLvoid, ptrstride: TGLint){. + dynlib: dllname, importc.} + #***** GL_MESA_resize_buffers *****// +proc glResizeBuffersMESA*(){.dynlib: dllname, importc.} + #***** GL_MESA_window_pos *****// +proc glWindowPos2dMESA*(x: TGLdouble, y: TGLdouble){.dynlib: dllname, importc.} +proc glWindowPos2fMESA*(x: TGLfloat, y: TGLfloat){.dynlib: dllname, importc.} +proc glWindowPos2iMESA*(x: TGLint, y: TGLint){.dynlib: dllname, importc.} +proc glWindowPos2sMESA*(x: TGLshort, y: TGLshort){.dynlib: dllname, importc.} +proc glWindowPos2ivMESA*(p: PGLint){.dynlib: dllname, importc.} +proc glWindowPos2svMESA*(p: PGLshort){.dynlib: dllname, importc.} +proc glWindowPos2fvMESA*(p: PGLfloat){.dynlib: dllname, importc.} +proc glWindowPos2dvMESA*(p: PGLdouble){.dynlib: dllname, importc.} +proc glWindowPos3iMESA*(x: TGLint, y: TGLint, z: TGLint){.dynlib: dllname, importc.} +proc glWindowPos3sMESA*(x: TGLshort, y: TGLshort, z: TGLshort){.dynlib: dllname, + importc.} +proc glWindowPos3fMESA*(x: TGLfloat, y: TGLfloat, z: TGLfloat){.dynlib: dllname, + importc.} +proc glWindowPos3dMESA*(x: TGLdouble, y: TGLdouble, z: TGLdouble){.dynlib: dllname, + importc.} +proc glWindowPos3ivMESA*(p: PGLint){.dynlib: dllname, importc.} +proc glWindowPos3svMESA*(p: PGLshort){.dynlib: dllname, importc.} +proc glWindowPos3fvMESA*(p: PGLfloat){.dynlib: dllname, importc.} +proc glWindowPos3dvMESA*(p: PGLdouble){.dynlib: dllname, importc.} +proc glWindowPos4iMESA*(x: TGLint, y: TGLint, z: TGLint, w: TGLint){. + dynlib: dllname, importc.} +proc glWindowPos4sMESA*(x: TGLshort, y: TGLshort, z: TGLshort, w: TGLshort){. + dynlib: dllname, importc.} +proc glWindowPos4fMESA*(x: TGLfloat, y: TGLfloat, z: TGLfloat, w: TGLfloat){. + dynlib: dllname, importc.} +proc glWindowPos4dMESA*(x: TGLdouble, y: TGLdouble, z: TGLdouble, w: TGLdouble){. + dynlib: dllname, importc.} +proc glWindowPos4ivMESA*(p: PGLint){.dynlib: dllname, importc.} +proc glWindowPos4svMESA*(p: PGLshort){.dynlib: dllname, importc.} +proc glWindowPos4fvMESA*(p: PGLfloat){.dynlib: dllname, importc.} +proc glWindowPos4dvMESA*(p: PGLdouble){.dynlib: dllname, importc.} + #***** GL_OML_interlace *****// +const + GL_INTERLACE_OML* = 0x00008980 + GL_INTERLACE_READ_OML* = 0x00008981 + + #***** GL_OML_resample *****// +const + GL_PACK_RESAMPLE_OML* = 0x00008984 + GL_UNPACK_RESAMPLE_OML* = 0x00008985 + GL_RESAMPLE_REPLICATE_OML* = 0x00008986 + GL_RESAMPLE_ZERO_FILL_OML* = 0x00008987 + GL_RESAMPLE_AVERAGE_OML* = 0x00008988 + GL_RESAMPLE_DECIMATE_OML* = 0x00008989 # GL_RESAMPLE_AVERAGE_OML { already defined } + + #***** GL_OML_subsample *****// +const + GL_FORMAT_SUBSAMPLE_24_24_OML* = 0x00008982 + GL_FORMAT_SUBSAMPLE_244_244_OML* = 0x00008983 + + #***** GL_SGIS_generate_mipmap *****// +const + GL_GENERATE_MIPMAP_SGIS* = 0x00008191 + GL_GENERATE_MIPMAP_HINT_SGIS* = 0x00008192 + + #***** GL_SGIS_multisample *****// +const + GLX_SAMPLE_BUFFERS_SGIS* = 0x000186A0 + GLX_SAMPLES_SGIS* = 0x000186A1 + GL_MULTISAMPLE_SGIS* = 0x0000809D + GL_SAMPLE_ALPHA_TO_MASK_SGIS* = 0x0000809E + GL_SAMPLE_ALPHA_TO_ONE_SGIS* = 0x0000809F + constGL_SAMPLE_MASK_SGIS* = 0x000080A0 + GL_MULTISAMPLE_BIT_EXT* = 0x20000000 + GL_1PASS_SGIS* = 0x000080A1 + GL_2PASS_0_SGIS* = 0x000080A2 + GL_2PASS_1_SGIS* = 0x000080A3 + GL_4PASS_0_SGIS* = 0x000080A4 + GL_4PASS_1_SGIS* = 0x000080A5 + GL_4PASS_2_SGIS* = 0x000080A6 + GL_4PASS_3_SGIS* = 0x000080A7 + GL_SAMPLE_BUFFERS_SGIS* = 0x000080A8 + GL_SAMPLES_SGIS* = 0x000080A9 + GL_SAMPLE_MASK_VALUE_SGIS* = 0x000080AA + GL_SAMPLE_MASK_INVERT_SGIS* = 0x000080AB + constGL_SAMPLE_PATTERN_SGIS* = 0x000080AC + +proc glSampleMaskSGIS*(value: TGLclampf, invert: TGLboolean){.dynlib: dllname, + importc.} +proc glSamplePatternSGIS*(pattern: TGLenum){.dynlib: dllname, importc.} + #***** GL_SGIS_pixel_texture *****// +const + GL_PIXEL_TEXTURE_SGIS* = 0x00008353 + GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS* = 0x00008354 + GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS* = 0x00008355 + GL_PIXEL_GROUP_COLOR_SGIS* = 0x00008356 + +proc glPixelTexGenParameteriSGIS*(pname: TGLenum, param: TGLint){.dynlib: dllname, + importc.} +proc glPixelTexGenParameterfSGIS*(pname: TGLenum, param: TGLfloat){. + dynlib: dllname, importc.} +proc glGetPixelTexGenParameterivSGIS*(pname: TGLenum, params: TGLint){. + dynlib: dllname, importc.} +proc glGetPixelTexGenParameterfvSGIS*(pname: TGLenum, params: TGLfloat){. + dynlib: dllname, importc.} + #***** GL_SGIS_texture_border_clamp *****// + # GL_CLAMP_TO_BORDER_SGIS { already defined } + #***** GL_SGIS_texture_color_mask *****// +const + GL_TEXTURE_COLOR_WRITEMASK_SGIS* = 0x000081EF + +proc glTextureColorMaskSGIS*(r: TGLboolean, g: TGLboolean, b: TGLboolean, + a: TGLboolean){.dynlib: dllname, importc.} + #***** GL_SGIS_texture_edge_clamp *****// +const + GL_CLAMP_TO_EDGE_SGIS* = 0x0000812F + + #***** GL_SGIS_texture_lod *****// +const + GL_TEXTURE_MIN_LOD_SGIS* = 0x0000813A + GL_TEXTURE_MAX_LOD_SGIS* = 0x0000813B + GL_TEXTURE_BASE_LEVEL_SGIS* = 0x0000813C + GL_TEXTURE_MAX_LEVEL_SGIS* = 0x0000813D + + #***** GL_SGIS_depth_texture *****// +const + GL_DEPTH_COMPONENT16_SGIX* = 0x000081A5 + GL_DEPTH_COMPONENT24_SGIX* = 0x000081A6 + GL_DEPTH_COMPONENT32_SGIX* = 0x000081A7 + + #***** GL_SGIX_fog_offset *****// +const + GL_FOG_OFFSET_SGIX* = 0x00008198 + GL_FOG_OFFSET_VALUE_SGIX* = 0x00008199 + + #***** GL_SGIX_interlace *****// +const + GL_INTERLACE_SGIX* = 0x00008094 + + #***** GL_SGIX_shadow_ambient *****// +const + GL_SHADOW_AMBIENT_SGIX* = 0x000080BF + + #***** GL_SGI_color_matrix *****// +const + GL_COLOR_MATRIX_SGI* = 0x000080B1 + GL_COLOR_MATRIX_STACK_DEPTH_SGI* = 0x000080B2 + GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI* = 0x000080B3 + GL_POST_COLOR_MATRIX_RED_SCALE_SGI* = 0x000080B4 + GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI* = 0x000080B5 + GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI* = 0x000080B6 + GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI* = 0x000080B7 + GL_POST_COLOR_MATRIX_RED_BIAS_SGI* = 0x000080B8 + GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI* = 0x000080B9 + GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI* = 0x000080BA + GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI* = 0x000080BB + + #***** GL_SGI_color_table *****// +const + constGL_COLOR_TABLE_SGI* = 0x000080D0 + GL_POST_CONVOLUTION_COLOR_TABLE_SGI* = 0x000080D1 + GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI* = 0x000080D2 + GL_PROXY_COLOR_TABLE_SGI* = 0x000080D3 + GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI* = 0x000080D4 + GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI* = 0x000080D5 + GL_COLOR_TABLE_SCALE_SGI* = 0x000080D6 + GL_COLOR_TABLE_BIAS_SGI* = 0x000080D7 + GL_COLOR_TABLE_FORMAT_SGI* = 0x000080D8 + GL_COLOR_TABLE_WIDTH_SGI* = 0x000080D9 + GL_COLOR_TABLE_RED_SIZE_SGI* = 0x000080DA + GL_COLOR_TABLE_GREEN_SIZE_SGI* = 0x000080DB + GL_COLOR_TABLE_BLUE_SIZE_SGI* = 0x000080DC + GL_COLOR_TABLE_ALPHA_SIZE_SGI* = 0x000080DD + GL_COLOR_TABLE_LUMINANCE_SIZE_SGI* = 0x000080DE + GL_COLOR_TABLE_INTENSITY_SIZE_SGI* = 0x000080DF + +proc glColorTableSGI*(target: TGLenum, internalformat: TGLenum, width: TGLsizei, + format: TGLenum, thetype: TGLenum, table: PGLvoid){. + dynlib: dllname, importc.} +proc glCopyColorTableSGI*(target: TGLenum, internalformat: TGLenum, x: TGLint, + y: TGLint, width: TGLsizei){.dynlib: dllname, importc.} +proc glColorTableParameterivSGI*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glColorTableParameterfvSGI*(target: TGLenum, pname: TGLenum, params: PGLfloat){. + dynlib: dllname, importc.} +proc glGetColorTableSGI*(target: TGLenum, format: TGLenum, thetype: TGLenum, + table: PGLvoid){.dynlib: dllname, importc.} +proc glGetColorTableParameterivSGI*(target: TGLenum, pname: TGLenum, + params: PGLint){.dynlib: dllname, importc.} +proc glGetColorTableParameterfvSGI*(target: TGLenum, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, importc.} + #***** GL_SGI_texture_color_table *****// +const + GL_TEXTURE_COLOR_TABLE_SGI* = 0x000080BC + GL_PROXY_TEXTURE_COLOR_TABLE_SGI* = 0x000080BD + + #***** GL_SUN_vertex *****// +proc glColor4ubVertex2fSUN*(r: TGLubyte, g: TGLubyte, b: TGLubyte, a: TGLubyte, + x: TGLfloat, y: TGLfloat){.dynlib: dllname, importc.} +proc glColor4ubVertex2fvSUN*(c: PGLubyte, v: PGLfloat){.dynlib: dllname, importc.} +proc glColor4ubVertex3fSUN*(r: TGLubyte, g: TGLubyte, b: TGLubyte, a: TGLubyte, + x: TGLfloat, y: TGLfloat, z: TGLfloat){. + dynlib: dllname, importc.} +proc glColor4ubVertex3fvSUN*(c: PGLubyte, v: PGLfloat){.dynlib: dllname, importc.} +proc glColor3fVertex3fSUN*(r: TGLfloat, g: TGLfloat, b: TGLfloat, x: TGLfloat, + y: TGLfloat, z: TGLfloat){.dynlib: dllname, importc.} +proc glColor3fVertex3fvSUN*(c: PGLfloat, v: PGLfloat){.dynlib: dllname, importc.} +proc glNormal3fVertex3fSUN*(nx: TGLfloat, ny: TGLfloat, nz: TGLfloat, x: TGLfloat, + y: TGLfloat, z: TGLfloat){.dynlib: dllname, importc.} +proc glNormal3fVertex3fvSUN*(n: PGLfloat, v: PGLfloat){.dynlib: dllname, importc.} +proc glColor4fNormal3fVertex3fSUN*(r: TGLfloat, g: TGLfloat, b: TGLfloat, + a: TGLfloat, nx: TGLfloat, ny: TGLfloat, + nz: TGLfloat, x: TGLfloat, y: TGLfloat, + z: TGLfloat){.dynlib: dllname, importc.} +proc glColor4fNormal3fVertex3fvSUN*(c: PGLfloat, n: PGLfloat, v: PGLfloat){. + dynlib: dllname, importc.} +proc glTexCoord2fVertex3fSUN*(s: TGLfloat, t: TGLfloat, x: TGLfloat, y: TGLfloat, + z: TGLfloat){.dynlib: dllname, importc.} +proc glTexCoord2fVertex3fvSUN*(tc: PGLfloat, v: PGLfloat){.dynlib: dllname, + importc.} +proc glTexCoord4fVertex4fSUN*(s: TGLfloat, t: TGLfloat, p: TGLfloat, q: TGLfloat, + x: TGLfloat, y: TGLfloat, z: TGLfloat, w: TGLfloat){. + dynlib: dllname, importc.} +proc glTexCoord4fVertex4fvSUN*(tc: PGLfloat, v: PGLfloat){.dynlib: dllname, + importc.} +proc glTexCoord2fColor4ubVertex3fSUN*(s: TGLfloat, t: TGLfloat, r: TGLubyte, + g: TGLubyte, b: TGLubyte, a: TGLubyte, + x: TGLfloat, y: TGLfloat, z: TGLfloat){. + dynlib: dllname, importc.} +proc glTexCoord2fColor4ubVertex3fvSUN*(tc: PGLfloat, c: PGLubyte, v: PGLfloat){. + dynlib: dllname, importc.} +proc glTexCoord2fColor3fVertex3fSUN*(s: TGLfloat, t: TGLfloat, r: TGLfloat, + g: TGLfloat, b: TGLfloat, x: TGLfloat, + y: TGLfloat, z: TGLfloat){.dynlib: dllname, + importc.} +proc glTexCoord2fColor3fVertex3fvSUN*(tc: PGLfloat, c: PGLfloat, v: PGLfloat){. + dynlib: dllname, importc.} +proc glTexCoord2fNormal3fVertex3fSUN*(s: TGLfloat, t: TGLfloat, nx: TGLfloat, + ny: TGLfloat, nz: TGLfloat, x: TGLfloat, + y: TGLfloat, z: TGLfloat){.dynlib: dllname, + importc.} +proc glTexCoord2fNormal3fVertex3fvSUN*(tc: PGLfloat, n: PGLfloat, v: PGLfloat){. + dynlib: dllname, importc.} +proc glTexCoord2fColor4fNormal3fVertex3fSUN*(s: TGLfloat, t: TGLfloat, r: TGLfloat, + g: TGLfloat, b: TGLfloat, a: TGLfloat, nx: TGLfloat, ny: TGLfloat, nz: TGLfloat, + x: TGLfloat, y: TGLfloat, z: TGLfloat){.dynlib: dllname, importc.} +proc glTexCoord2fColor4fNormal3fVertex3fvSUN*(tc: PGLfloat, c: PGLfloat, + n: PGLfloat, v: PGLfloat){.dynlib: dllname, importc.} +proc glTexCoord4fColor4fNormal3fVertex4fSUN*(s: TGLfloat, t: TGLfloat, p: TGLfloat, + q: TGLfloat, r: TGLfloat, g: TGLfloat, b: TGLfloat, a: TGLfloat, nx: TGLfloat, + ny: TGLfloat, nz: TGLfloat, x: TGLfloat, y: TGLfloat, z: TGLfloat, w: TGLfloat){. + dynlib: dllname, importc.} +proc glTexCoord4fColor4fNormal3fVertex4fvSUN*(tc: PGLfloat, c: PGLfloat, + n: PGLfloat, v: PGLfloat){.dynlib: dllname, importc.} +proc glReplacementCodeuiVertex3fSUN*(rc: TGLuint, x: TGLfloat, y: TGLfloat, + z: TGLfloat){.dynlib: dllname, importc.} +proc glReplacementCodeuiVertex3fvSUN*(rc: PGLuint, v: PGLfloat){. + dynlib: dllname, importc.} +proc glReplacementCodeuiColor4ubVertex3fSUN*(rc: TGLuint, r: TGLubyte, g: TGLubyte, + b: TGLubyte, a: TGLubyte, x: TGLfloat, y: TGLfloat, z: TGLfloat){. + dynlib: dllname, importc.} +proc glReplacementCodeuiColor4ubVertex3fvSUN*(rc: PGLuint, c: PGLubyte, + v: PGLfloat){.dynlib: dllname, importc.} +proc glReplacementCodeuiColor3fVertex3fSUN*(rc: TGLuint, r: TGLfloat, g: TGLfloat, + b: TGLfloat, x: TGLfloat, y: TGLfloat, z: TGLfloat){.dynlib: dllname, importc.} +proc glReplacementCodeuiColor3fVertex3fvSUN*(rc: PGLuint, c: PGLfloat, + v: PGLfloat){.dynlib: dllname, importc.} +proc glReplacementCodeuiNormal3fVertex3fSUN*(rc: TGLuint, nx: TGLfloat, + ny: TGLfloat, nz: TGLfloat, x: TGLfloat, y: TGLfloat, z: TGLfloat){. + dynlib: dllname, importc.} +proc glReplacementCodeuiNormal3fVertex3fvSUN*(rc: PGLuint, n: PGLfloat, + v: PGLfloat){.dynlib: dllname, importc.} +proc glReplacementCodeuiColor4fNormal3fVertex3fSUN*(rc: TGLuint, r: TGLfloat, + g: TGLfloat, b: TGLfloat, a: TGLfloat, nx: TGLfloat, ny: TGLfloat, nz: TGLfloat, + x: TGLfloat, y: TGLfloat, z: TGLfloat){.dynlib: dllname, importc.} +proc glReplacementCodeuiColor4fNormal3fVertex3fvSUN*(rc: PGLuint, c: PGLfloat, + n: PGLfloat, v: PGLfloat){.dynlib: dllname, importc.} +proc glReplacementCodeuiTexCoord2fVertex3fSUN*(rc: TGLuint, s: TGLfloat, + t: TGLfloat, x: TGLfloat, y: TGLfloat, z: TGLfloat){.dynlib: dllname, importc.} +proc glReplacementCodeuiTexCoord2fVertex3fvSUN*(rc: PGLuint, tc: PGLfloat, + v: PGLfloat){.dynlib: dllname, importc.} +proc glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN*(rc: TGLuint, s: TGLfloat, + t: TGLfloat, nx: TGLfloat, ny: TGLfloat, nz: TGLfloat, x: TGLfloat, y: TGLfloat, + z: TGLfloat){.dynlib: dllname, importc.} +proc glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN*(rc: PGLuint, + tc: PGLfloat, n: PGLfloat, v: PGLfloat){.dynlib: dllname, importc.} +proc glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN*(rc: TGLuint, + s: TGLfloat, t: TGLfloat, r: TGLfloat, g: TGLfloat, b: TGLfloat, a: TGLfloat, + nx: TGLfloat, ny: TGLfloat, nz: TGLfloat, x: TGLfloat, y: TGLfloat, z: TGLfloat){. + dynlib: dllname, importc.} +proc glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN*(rc: PGLuint, + tc: PGLfloat, c: PGLfloat, n: PGLfloat, v: PGLfloat){.dynlib: dllname, + importc.} + #***** GL_ARB_fragment_program *****// +const + GL_FRAGMENT_PROGRAM_ARB* = 0x00008804 # GL_PROGRAM_FORMAT_ASCII_ARB { already defined } + # GL_PROGRAM_LENGTH_ARB { already defined } + # GL_PROGRAM_FORMAT_ARB { already defined } + # GL_PROGRAM_BINDING_ARB { already defined } + # GL_PROGRAM_INSTRUCTIONS_ARB { already defined } + # GL_MAX_PROGRAM_INSTRUCTIONS_ARB { already defined } + # GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB { already defined } + # GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB { already defined } + # GL_PROGRAM_TEMPORARIES_ARB { already defined } + # GL_MAX_PROGRAM_TEMPORARIES_ARB { already defined } + # GL_PROGRAM_NATIVE_TEMPORARIES_ARB { already defined } + # GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB { already defined } + # GL_PROGRAM_PARAMETERS_ARB { already defined } + # GL_MAX_PROGRAM_PARAMETERS_ARB { already defined } + # GL_PROGRAM_NATIVE_PARAMETERS_ARB { already defined } + # GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB { already defined } + # GL_PROGRAM_ATTRIBS_ARB { already defined } + # GL_MAX_PROGRAM_ATTRIBS_ARB { already defined } + # GL_PROGRAM_NATIVE_ATTRIBS_ARB { already defined } + # GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB { already defined } + # GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB { already defined } + # GL_MAX_PROGRAM_ENV_PARAMETERS_ARB { already defined } + # GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB { already defined } + GL_PROGRAM_ALU_INSTRUCTIONS_ARB* = 0x00008805 + GL_PROGRAM_TEX_INSTRUCTIONS_ARB* = 0x00008806 + GL_PROGRAM_TEX_INDIRECTIONS_ARB* = 0x00008807 + GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB* = 0x00008808 + GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB* = 0x00008809 + GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB* = 0x0000880A + GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB* = 0x0000880B + GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB* = 0x0000880C + GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB* = 0x0000880D + GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB* = 0x0000880E + GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB* = 0x0000880F + GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB* = 0x00008810 # GL_PROGRAM_STRING_ARB { already defined } + # + # GL_PROGRAM_ERROR_POSITION_ARB { already defined } + # GL_CURRENT_MATRIX_ARB { already defined } + # + # GL_TRANSPOSE_CURRENT_MATRIX_ARB { already defined } + # + # GL_CURRENT_MATRIX_STACK_DEPTH_ARB { already defined } + # + # GL_MAX_PROGRAM_MATRICES_ARB { already defined } + # + # GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB { already defined } + GL_MAX_TEXTURE_COORDS_ARB* = 0x00008871 + GL_MAX_TEXTURE_IMAGE_UNITS_ARB* = 0x00008872 # GL_PROGRAM_ERROR_STRING_ARB { already defined } + # GL_MATRIX0_ARB { already defined } + # GL_MATRIX1_ARB { already defined } + # GL_MATRIX2_ARB { already defined } + # GL_MATRIX3_ARB { already defined } + # GL_MATRIX4_ARB { already defined } + # GL_MATRIX5_ARB { already defined } + # GL_MATRIX6_ARB { already defined } + # GL_MATRIX7_ARB { already defined } + # GL_MATRIX8_ARB { already defined } + # GL_MATRIX9_ARB { already defined } + # GL_MATRIX10_ARB { already defined } + # GL_MATRIX11_ARB { already defined } + # GL_MATRIX12_ARB { already defined } + # GL_MATRIX13_ARB { already defined } + # GL_MATRIX14_ARB { already defined } + # GL_MATRIX15_ARB { already defined } + # GL_MATRIX16_ARB { already defined } + # GL_MATRIX17_ARB { already defined } + # GL_MATRIX18_ARB { already defined } + # GL_MATRIX19_ARB { already defined } + # GL_MATRIX20_ARB { already defined } + # GL_MATRIX21_ARB { already defined } + # GL_MATRIX22_ARB { already defined } + # GL_MATRIX23_ARB { already defined } + # GL_MATRIX24_ARB { already defined } + # GL_MATRIX25_ARB { already defined } + # GL_MATRIX26_ARB { already defined } + # GL_MATRIX27_ARB { already defined } + # GL_MATRIX28_ARB { already defined } + # GL_MATRIX29_ARB { already defined } + # GL_MATRIX30_ARB { already defined } + # GL_MATRIX31_ARB { already defined } + # glProgramStringARB { already defined } + # glBindProgramARB { already defined } + # glDeleteProgramsARB { already defined } + # glGenProgramsARB { already defined } + # glProgramEnvParameter4dARB { already defined } + # glProgramEnvParameter4dvARB { already defined } + # glProgramEnvParameter4fARB { already defined } + # glProgramEnvParameter4fvARB { already defined } + # glProgramLocalParameter4dARB { already defined } + # glProgramLocalParameter4dvARB { already defined } + # glProgramLocalParameter4fARB { already defined } + # glProgramLocalParameter4fvARB { already defined } + # glGetProgramEnvParameterdvARB { already defined } + # glGetProgramEnvParameterfvARB { already defined } + # glGetProgramLocalParameterdvARB { already defined } + # glGetProgramLocalParameterfvARB { already defined } + # glGetProgramivARB { already defined } + # glGetProgramStringARB { already defined } + # glIsProgramARB { already defined } + + #***** GL_ATI_text_fragment_shader ***** +const + GL_TEXT_FRAGMENT_SHADER_ATI* = 0x00008200 #***** GL_ARB_vertex_buffer_object ***** + +const + GL_BUFFER_SIZE_ARB* = 0x00008764 + GL_BUFFER_USAGE_ARB* = 0x00008765 + GL_ARRAY_BUFFER_ARB* = 0x00008892 + GL_ELEMENT_ARRAY_BUFFER_ARB* = 0x00008893 + GL_ARRAY_BUFFER_BINDING_ARB* = 0x00008894 + GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB* = 0x00008895 + GL_VERTEX_ARRAY_BUFFER_BINDING_ARB* = 0x00008896 + GL_NORMAL_ARRAY_BUFFER_BINDING_ARB* = 0x00008897 + GL_COLOR_ARRAY_BUFFER_BINDING_ARB* = 0x00008898 + GL_INDEX_ARRAY_BUFFER_BINDING_ARB* = 0x00008899 + GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB* = 0x0000889A + GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB* = 0x0000889B + GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB* = 0x0000889C + GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB* = 0x0000889D + GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB* = 0x0000889E + GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB* = 0x0000889F + GL_READ_ONLY_ARB* = 0x000088B8 + GL_WRITE_ONLY_ARB* = 0x000088B9 + GL_READ_WRITE_ARB* = 0x000088BA + GL_BUFFER_ACCESS_ARB* = 0x000088BB + GL_BUFFER_MAPPED_ARB* = 0x000088BC + GL_BUFFER_MAP_POINTER_ARB* = 0x000088BD + GL_STREAM_DRAW_ARB* = 0x000088E0 + GL_STREAM_READ_ARB* = 0x000088E1 + GL_STREAM_COPY_ARB* = 0x000088E2 + GL_STATIC_DRAW_ARB* = 0x000088E4 + GL_STATIC_READ_ARB* = 0x000088E5 + GL_STATIC_COPY_ARB* = 0x000088E6 + GL_DYNAMIC_DRAW_ARB* = 0x000088E8 + GL_DYNAMIC_READ_ARB* = 0x000088E9 + GL_DYNAMIC_COPY_ARB* = 0x000088EA + +proc glBindBufferARB*(target: TGLenum, buffer: TGLuint){.dynlib: dllname, importc.} +proc glDeleteBuffersARB*(n: TGLsizei, buffers: PGLuint){.dynlib: dllname, importc.} +proc glGenBuffersARB*(n: TGLsizei, buffers: PGLuint){.dynlib: dllname, importc.} +proc glIsBufferARB*(buffer: TGLuint): TGLboolean{.dynlib: dllname, importc.} +proc glBufferDataARB*(target: TGLenum, size: TGLsizei, data: PGLvoid, + usage: TGLenum){.dynlib: dllname, importc.} +proc glBufferSubDataARB*(target: TGLenum, offset: TGLint, size: TGLsizei, + data: PGLvoid){.dynlib: dllname, importc.} +proc glGetBufferSubDataARB*(target: TGLenum, offset: TGLint, size: TGLsizei, + data: PGLvoid){.dynlib: dllname, importc.} +proc glMapBufferARB*(target: TGLenum, access: TGLenum): PGLvoid{.dynlib: dllname, + importc.} +proc glUnmapBufferARB*(target: TGLenum): TGLboolean{.dynlib: dllname, importc.} +proc glGetBufferParameterivARB*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glGetBufferPointervARB*(target: TGLenum, pname: TGLenum, params: PPGLvoid){. + dynlib: dllname, importc.} + #***** GL_APPLE_client_storage *****// +const + GL_UNPACK_CLIENT_STORAGE_APPLE* = 0x000085B2 + + #***** GL_APPLE_element_array *****// +const + GL_ELEMENT_ARRAY_APPLE* = 0x00008768 + GL_ELEMENT_ARRAY_TYPE_APPLE* = 0x00008769 + GL_ELEMENT_ARRAY_POINTER_APPLE* = 0x0000876A + +proc glElementPointerAPPLE*(thetype: TGLenum, pointer: PGLvoid){.dynlib: dllname, + importc.} +proc glDrawElementArrayAPPLE*(mode: TGLenum, first: TGLint, count: TGLsizei){. + dynlib: dllname, importc.} +proc glDrawRangeElementArrayAPPLE*(mode: TGLenum, start: TGLuint, theend: TGLuint, + first: TGLint, count: TGLsizei){. + dynlib: dllname, importc.} +proc glMultiDrawElementArrayAPPLE*(mode: TGLenum, first: PGLint, count: PGLsizei, + primcount: TGLsizei){.dynlib: dllname, importc.} +proc glMultiDrawRangeElementArrayAPPLE*(mode: TGLenum, start: TGLuint, + theend: TGLuint, first: PGLint, + count: PGLsizei, primcount: TGLsizei){. + dynlib: dllname, importc.} + #***** GL_APPLE_fence *****// +const + GL_DRAW_PIXELS_APPLE* = 0x00008A0A + GL_FENCE_APPLE* = 0x00008A0B + +proc glGenFencesAPPLE*(n: TGLsizei, fences: PGLuint){.dynlib: dllname, importc.} +proc glDeleteFencesAPPLE*(n: TGLsizei, fences: PGLuint){.dynlib: dllname, importc.} +proc glSetFenceAPPLE*(fence: TGLuint){.dynlib: dllname, importc.} +proc glIsFenceAPPLE*(fence: TGLuint): TGLboolean{.dynlib: dllname, importc.} +proc glTestFenceAPPLE*(fence: TGLuint): TGLboolean{.dynlib: dllname, importc.} +proc glFinishFenceAPPLE*(fence: TGLuint){.dynlib: dllname, importc.} +proc glTestObjectAPPLE*(theobject: TGLenum, name: TGLuint): TGLboolean{. + dynlib: dllname, importc.} +proc glFinishObjectAPPLE*(theobject: TGLenum, name: TGLint){.dynlib: dllname, + importc.} + #***** GL_APPLE_vertex_array_object *****// +const + GL_VERTEX_ARRAY_BINDING_APPLE* = 0x000085B5 + +proc glBindVertexArrayAPPLE*(thearray: TGLuint){.dynlib: dllname, importc.} +proc glDeleteVertexArraysAPPLE*(n: TGLsizei, arrays: PGLuint){.dynlib: dllname, + importc.} +proc glGenVertexArraysAPPLE*(n: TGLsizei, arrays: PGLuint){.dynlib: dllname, + importc.} +proc glIsVertexArrayAPPLE*(thearray: TGLuint): TGLboolean{.dynlib: dllname, + importc.} + #***** GL_APPLE_vertex_array_range *****// +const + constGL_VERTEX_ARRAY_RANGE_APPLE* = 0x0000851D + GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE* = 0x0000851E + GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_APPLE* = 0x00008520 + GL_VERTEX_ARRAY_RANGE_POINTER_APPLE* = 0x00008521 + GL_VERTEX_ARRAY_STORAGE_HINT_APPLE* = 0x0000851F + GL_STORAGE_CACHED_APPLE* = 0x000085BE + GL_STORAGE_SHARED_APPLE* = 0x000085BF + +proc glVertexArrayRangeAPPLE*(len: TGLsizei, pointer: PGLvoid){.dynlib: dllname, + importc.} +proc glFlushVertexArrayRangeAPPLE*(len: TGLsizei, pointer: PGLvoid){. + dynlib: dllname, importc.} +proc glVertexArrayParameteriAPPLE*(pname: TGLenum, param: TGLint){. + dynlib: dllname, importc.} + #***** GL_ARB_matrix_palette *****// +const + GL_MATRIX_PALETTE_ARB* = 0x00008840 + GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB* = 0x00008841 + GL_MAX_PALETTE_MATRICES_ARB* = 0x00008842 + constGL_CURRENT_PALETTE_MATRIX_ARB* = 0x00008843 + GL_MATRIX_INDEX_ARRAY_ARB* = 0x00008844 + GL_CURRENT_MATRIX_INDEX_ARB* = 0x00008845 + GL_MATRIX_INDEX_ARRAY_SIZE_ARB* = 0x00008846 + GL_MATRIX_INDEX_ARRAY_TYPE_ARB* = 0x00008847 + GL_MATRIX_INDEX_ARRAY_STRIDE_ARB* = 0x00008848 + GL_MATRIX_INDEX_ARRAY_POINTER_ARB* = 0x00008849 + +proc glCurrentPaletteMatrixARB*(index: TGLint){.dynlib: dllname, importc.} +proc glMatrixIndexubvARB*(size: TGLint, indices: PGLubyte){.dynlib: dllname, + importc.} +proc glMatrixIndexusvARB*(size: TGLint, indices: PGLushort){.dynlib: dllname, + importc.} +proc glMatrixIndexuivARB*(size: TGLint, indices: PGLuint){.dynlib: dllname, + importc.} +proc glMatrixIndexPointerARB*(size: TGLint, thetype: TGLenum, stride: TGLsizei, + pointer: PGLvoid){.dynlib: dllname, importc.} + #***** GL_NV_element_array *****// +const + GL_ELEMENT_ARRAY_TYPE_NV* = 0x00008769 + GL_ELEMENT_ARRAY_POINTER_NV* = 0x0000876A + +proc glElementPointerNV*(thetype: TGLenum, pointer: PGLvoid){.dynlib: dllname, + importc.} +proc glDrawElementArrayNV*(mode: TGLenum, first: TGLint, count: TGLsizei){. + dynlib: dllname, importc.} +proc glDrawRangeElementArrayNV*(mode: TGLenum, start: TGLuint, theend: TGLuint, + first: TGLint, count: TGLsizei){.dynlib: dllname, + importc.} +proc glMultiDrawElementArrayNV*(mode: TGLenum, first: PGLint, count: PGLsizei, + primcount: TGLsizei){.dynlib: dllname, importc.} +proc glMultiDrawRangeElementArrayNV*(mode: TGLenum, start: TGLuint, + theend: TGLuint, first: PGLint, + count: PGLsizei, primcount: TGLsizei){. + dynlib: dllname, importc.} + #***** GL_NV_float_buffer *****// +const + GL_FLOAT_R_NV* = 0x00008880 + GL_FLOAT_RG_NV* = 0x00008881 + GL_FLOAT_RGB_NV* = 0x00008882 + GL_FLOAT_RGBA_NV* = 0x00008883 + GL_FLOAT_R16_NV* = 0x00008884 + GL_FLOAT_R32_NV* = 0x00008885 + GL_FLOAT_RG16_NV* = 0x00008886 + GL_FLOAT_RG32_NV* = 0x00008887 + GL_FLOAT_RGB16_NV* = 0x00008888 + GL_FLOAT_RGB32_NV* = 0x00008889 + GL_FLOAT_RGBA16_NV* = 0x0000888A + GL_FLOAT_RGBA32_NV* = 0x0000888B + GL_TEXTURE_FLOAT_COMPONENTS_NV* = 0x0000888C + GL_FLOAT_CLEAR_COLOR_VALUE_NV* = 0x0000888D + GL_FLOAT_RGBA_MODE_NV* = 0x0000888E + + #***** GL_NV_fragment_program *****// +const + GL_FRAGMENT_PROGRAM_NV* = 0x00008870 + GL_MAX_TEXTURE_COORDS_NV* = 0x00008871 + GL_MAX_TEXTURE_IMAGE_UNITS_NV* = 0x00008872 + GL_FRAGMENT_PROGRAM_BINDING_NV* = 0x00008873 + GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV* = 0x00008868 + GL_PROGRAM_ERROR_STRING_NV* = 0x00008874 + +proc glProgramNamedParameter4fNV*(id: TGLuint, length: TGLsizei, name: PGLubyte, + x: TGLfloat, y: TGLfloat, z: TGLfloat, w: TGLfloat){. + dynlib: dllname, importc.} +proc glProgramNamedParameter4dNV*(id: TGLuint, length: TGLsizei, name: PGLubyte, + x: TGLdouble, y: TGLdouble, z: TGLdouble, + w: TGLdouble){.dynlib: dllname, importc.} +proc glGetProgramNamedParameterfvNV*(id: TGLuint, length: TGLsizei, + name: PGLubyte, params: PGLfloat){. + dynlib: dllname, importc.} +proc glGetProgramNamedParameterdvNV*(id: TGLuint, length: TGLsizei, + name: PGLubyte, params: PGLdouble){. + dynlib: dllname, importc.} + # glProgramLocalParameter4dARB { already defined } + # glProgramLocalParameter4dvARB { already defined } + # glProgramLocalParameter4fARB { already defined } + # glProgramLocalParameter4fvARB { already defined } + # glGetProgramLocalParameterdvARB { already defined } + # glGetProgramLocalParameterfvARB { already defined } + #***** GL_NV_primitive_restart *****// +const + constGL_PRIMITIVE_RESTART_NV* = 0x00008558 + constGL_PRIMITIVE_RESTART_INDEX_NV* = 0x00008559 + +proc glPrimitiveRestartNV*(){.dynlib: dllname, importc.} +proc glPrimitiveRestartIndexNV*(index: TGLuint){.dynlib: dllname, importc.} + #***** GL_NV_vertex_program2 *****// + #***** GL_NV_pixel_data_range *****// +const + GL_WRITE_PIXEL_DATA_RANGE_NV* = 0x00008878 + GL_READ_PIXEL_DATA_RANGE_NV* = 0x00008879 + GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV* = 0x0000887A + GL_READ_PIXEL_DATA_RANGE_LENGTH_NV* = 0x0000887B + GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV* = 0x0000887C + GL_READ_PIXEL_DATA_RANGE_POINTER_NV* = 0x0000887D + +proc glPixelDataRangeNV*(target: TGLenum, len: TGLsizei, pointer: PGLvoid){. + dynlib: dllname, importc.} +proc glFlushPixelDataRangeNV*(target: TGLenum){.dynlib: dllname, importc.} + # wglAllocateMemoryNV { already defined } + # wglFreeMemoryNV { already defined } + #***** GL_EXT_texture_rectangle *****// +const + GL_TEXTURE_RECTANGLE_EXT* = 0x000084F5 + GL_TEXTURE_BINDING_RECTANGLE_EXT* = 0x000084F6 + GL_PROXY_TEXTURE_RECTANGLE_EXT* = 0x000084F7 + GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT* = 0x000084F8 + + #***** GL_S3_s3tc *****// +const + GL_RGB_S3TC* = 0x000083A0 + GL_RGB4_S3TC* = 0x000083A1 + GL_RGBA_S3TC* = 0x000083A2 + GL_RGBA4_S3TC* = 0x000083A3 + + #***** GL_ATI_draw_buffers *****// +const + GL_MAX_DRAW_BUFFERS_ATI* = 0x00008824 + GL_DRAW_BUFFER0_ATI* = 0x00008825 + GL_DRAW_BUFFER1_ATI* = 0x00008826 + GL_DRAW_BUFFER2_ATI* = 0x00008827 + GL_DRAW_BUFFER3_ATI* = 0x00008828 + GL_DRAW_BUFFER4_ATI* = 0x00008829 + GL_DRAW_BUFFER5_ATI* = 0x0000882A + GL_DRAW_BUFFER6_ATI* = 0x0000882B + GL_DRAW_BUFFER7_ATI* = 0x0000882C + GL_DRAW_BUFFER8_ATI* = 0x0000882D + GL_DRAW_BUFFER9_ATI* = 0x0000882E + GL_DRAW_BUFFER10_ATI* = 0x0000882F + GL_DRAW_BUFFER11_ATI* = 0x00008830 + GL_DRAW_BUFFER12_ATI* = 0x00008831 + GL_DRAW_BUFFER13_ATI* = 0x00008832 + GL_DRAW_BUFFER14_ATI* = 0x00008833 + GL_DRAW_BUFFER15_ATI* = 0x00008834 + +proc glDrawBuffersATI*(n: TGLsizei, bufs: PGLenum){.dynlib: dllname, importc.} + #***** GL_ATI_texture_env_combine3 *****// +const + GL_MODULATE_ADD_ATI* = 0x00008744 + GL_MODULATE_SIGNED_ADD_ATI* = 0x00008745 + GL_MODULATE_SUBTRACT_ATI* = 0x00008746 + + #***** GL_ATI_texture_float *****// +const + GL_RGBA_FLOAT32_ATI* = 0x00008814 + GL_RGB_FLOAT32_ATI* = 0x00008815 + GL_ALPHA_FLOAT32_ATI* = 0x00008816 + GL_INTENSITY_FLOAT32_ATI* = 0x00008817 + GL_LUMINANCE_FLOAT32_ATI* = 0x00008818 + GL_LUMINANCE_ALPHA_FLOAT32_ATI* = 0x00008819 + GL_RGBA_FLOAT16_ATI* = 0x0000881A + GL_RGB_FLOAT16_ATI* = 0x0000881B + GL_ALPHA_FLOAT16_ATI* = 0x0000881C + GL_INTENSITY_FLOAT16_ATI* = 0x0000881D + GL_LUMINANCE_FLOAT16_ATI* = 0x0000881E + GL_LUMINANCE_ALPHA_FLOAT16_ATI* = 0x0000881F + + #***** GL_NV_texture_expand_normal *****// +const + GL_TEXTURE_UNSIGNED_REMAP_MODE_NV* = 0x0000888F + + #***** GL_NV_half_float *****// +const + GL_HALF_FLOAT_NV* = 0x0000140B + +proc glVertex2hNV*(x: TGLushort, y: TGLushort){.dynlib: dllname, importc.} +proc glVertex2hvNV*(v: PGLushort){.dynlib: dllname, importc.} +proc glVertex3hNV*(x: TGLushort, y: TGLushort, z: TGLushort){.dynlib: dllname, + importc.} +proc glVertex3hvNV*(v: PGLushort){.dynlib: dllname, importc.} +proc glVertex4hNV*(x: TGLushort, y: TGLushort, z: TGLushort, w: TGLushort){. + dynlib: dllname, importc.} +proc glVertex4hvNV*(v: PGLushort){.dynlib: dllname, importc.} +proc glNormal3hNV*(nx: TGLushort, ny: TGLushort, nz: TGLushort){.dynlib: dllname, + importc.} +proc glNormal3hvNV*(v: PGLushort){.dynlib: dllname, importc.} +proc glColor3hNV*(red: TGLushort, green: TGLushort, blue: TGLushort){. + dynlib: dllname, importc.} +proc glColor3hvNV*(v: PGLushort){.dynlib: dllname, importc.} +proc glColor4hNV*(red: TGLushort, green: TGLushort, blue: TGLushort, + alpha: TGLushort){.dynlib: dllname, importc.} +proc glColor4hvNV*(v: PGLushort){.dynlib: dllname, importc.} +proc glTexCoord1hNV*(s: TGLushort){.dynlib: dllname, importc.} +proc glTexCoord1hvNV*(v: PGLushort){.dynlib: dllname, importc.} +proc glTexCoord2hNV*(s: TGLushort, t: TGLushort){.dynlib: dllname, importc.} +proc glTexCoord2hvNV*(v: PGLushort){.dynlib: dllname, importc.} +proc glTexCoord3hNV*(s: TGLushort, t: TGLushort, r: TGLushort){.dynlib: dllname, + importc.} +proc glTexCoord3hvNV*(v: PGLushort){.dynlib: dllname, importc.} +proc glTexCoord4hNV*(s: TGLushort, t: TGLushort, r: TGLushort, q: TGLushort){. + dynlib: dllname, importc.} +proc glTexCoord4hvNV*(v: PGLushort){.dynlib: dllname, importc.} +proc glMultiTexCoord1hNV*(target: TGLenum, s: TGLushort){.dynlib: dllname, importc.} +proc glMultiTexCoord1hvNV*(target: TGLenum, v: PGLushort){.dynlib: dllname, + importc.} +proc glMultiTexCoord2hNV*(target: TGLenum, s: TGLushort, t: TGLushort){. + dynlib: dllname, importc.} +proc glMultiTexCoord2hvNV*(target: TGLenum, v: PGLushort){.dynlib: dllname, + importc.} +proc glMultiTexCoord3hNV*(target: TGLenum, s: TGLushort, t: TGLushort, r: TGLushort){. + dynlib: dllname, importc.} +proc glMultiTexCoord3hvNV*(target: TGLenum, v: PGLushort){.dynlib: dllname, + importc.} +proc glMultiTexCoord4hNV*(target: TGLenum, s: TGLushort, t: TGLushort, r: TGLushort, + q: TGLushort){.dynlib: dllname, importc.} +proc glMultiTexCoord4hvNV*(target: TGLenum, v: PGLushort){.dynlib: dllname, + importc.} +proc glFogCoordhNV*(fog: TGLushort){.dynlib: dllname, importc.} +proc glFogCoordhvNV*(fog: PGLushort){.dynlib: dllname, importc.} +proc glSecondaryColor3hNV*(red: TGLushort, green: TGLushort, blue: TGLushort){. + dynlib: dllname, importc.} +proc glSecondaryColor3hvNV*(v: PGLushort){.dynlib: dllname, importc.} +proc glVertexWeighthNV*(weight: TGLushort){.dynlib: dllname, importc.} +proc glVertexWeighthvNV*(weight: PGLushort){.dynlib: dllname, importc.} +proc glVertexAttrib1hNV*(index: TGLuint, x: TGLushort){.dynlib: dllname, importc.} +proc glVertexAttrib1hvNV*(index: TGLuint, v: PGLushort){.dynlib: dllname, importc.} +proc glVertexAttrib2hNV*(index: TGLuint, x: TGLushort, y: TGLushort){. + dynlib: dllname, importc.} +proc glVertexAttrib2hvNV*(index: TGLuint, v: PGLushort){.dynlib: dllname, importc.} +proc glVertexAttrib3hNV*(index: TGLuint, x: TGLushort, y: TGLushort, z: TGLushort){. + dynlib: dllname, importc.} +proc glVertexAttrib3hvNV*(index: TGLuint, v: PGLushort){.dynlib: dllname, importc.} +proc glVertexAttrib4hNV*(index: TGLuint, x: TGLushort, y: TGLushort, z: TGLushort, + w: TGLushort){.dynlib: dllname, importc.} +proc glVertexAttrib4hvNV*(index: TGLuint, v: PGLushort){.dynlib: dllname, importc.} +proc glVertexAttribs1hvNV*(index: TGLuint, n: TGLsizei, v: PGLushort){. + dynlib: dllname, importc.} +proc glVertexAttribs2hvNV*(index: TGLuint, n: TGLsizei, v: PGLushort){. + dynlib: dllname, importc.} +proc glVertexAttribs3hvNV*(index: TGLuint, n: TGLsizei, v: PGLushort){. + dynlib: dllname, importc.} +proc glVertexAttribs4hvNV*(index: TGLuint, n: TGLsizei, v: PGLushort){. + dynlib: dllname, importc.} + #***** GL_ATI_map_object_buffer *****// +proc glMapObjectBufferATI*(buffer: TGLuint): PGLvoid{.dynlib: dllname, importc.} +proc glUnmapObjectBufferATI*(buffer: TGLuint){.dynlib: dllname, importc.} + #***** GL_ATI_separate_stencil *****// +const + GL_KEEP* = 0x00001E00 + GL_ZERO* = 0x00000000 + GL_REPLACE* = 0x00001E01 + GL_INCR* = 0x00001E02 + GL_DECR* = 0x00001E03 + GL_INVERT* = 0x0000150A + GL_NEVER* = 0x00000200 + GL_LESS* = 0x00000201 + GL_LEQUAL* = 0x00000203 + GL_GREATER* = 0x00000204 + GL_GEQUAL* = 0x00000206 + GL_EQUAL* = 0x00000202 + GL_NOTEQUAL* = 0x00000205 + GL_ALWAYS* = 0x00000207 + GL_FRONT* = 0x00000404 + GL_BACK* = 0x00000405 + GL_FRONT_AND_BACK* = 0x00000408 + GL_STENCIL_BACK_FUNC_ATI* = 0x00008800 + GL_STENCIL_BACK_FAIL_ATI* = 0x00008801 + GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI* = 0x00008802 + GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI* = 0x00008803 + +proc glStencilOpSeparateATI*(face: TGLenum, sfail: TGLenum, dpfail: TGLenum, + dppass: TGLenum){.dynlib: dllname, importc.} +proc glStencilFuncSeparateATI*(frontfunc: TGLenum, backfunc: TGLenum, theRef: TGLint, + mask: TGLuint){.dynlib: dllname, importc.} + #***** GL_ATI_vertex_attrib_array_object *****// +proc glVertexAttribArrayObjectATI*(index: TGLuint, size: TGLint, thetype: TGLenum, + normalized: TGLboolean, stride: TGLsizei, + buffer: TGLuint, offset: TGLuint){. + dynlib: dllname, importc.} +proc glGetVertexAttribArrayObjectfvATI*(index: TGLuint, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, + importc.} +proc glGetVertexAttribArrayObjectivATI*(index: TGLuint, pname: TGLenum, + params: PGLint){.dynlib: dllname, + importc.} + #***** GL_ARB_occlusion_query *****// +const + GL_SAMPLES_PASSED_ARB* = 0x00008914 + GL_QUERY_COUNTER_BITS_ARB* = 0x00008864 + GL_CURRENT_QUERY_ARB* = 0x00008865 + GL_QUERY_RESULT_ARB* = 0x00008866 + GL_QUERY_RESULT_AVAILABLE_ARB* = 0x00008867 + +proc glGenQueriesARB*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, importc.} +proc glDeleteQueriesARB*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, importc.} +proc glIsQueryARB*(id: TGLuint): TGLboolean{.dynlib: dllname, importc.} +proc glBeginQueryARB*(target: TGLenum, id: TGLuint){.dynlib: dllname, importc.} +proc glEndQueryARB*(target: TGLenum){.dynlib: dllname, importc.} +proc glGetQueryivARB*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glGetQueryObjectivARB*(id: TGLuint, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glGetQueryObjectuivARB*(id: TGLuint, pname: TGLenum, params: PGLuint){. + dynlib: dllname, importc.} + #***** GL_ARB_shader_objects *****// +const + GL_PROGRAM_OBJECT_ARB* = 0x00008B40 + GL_OBJECT_TYPE_ARB* = 0x00008B4E + GL_OBJECT_SUBTYPE_ARB* = 0x00008B4F + GL_OBJECT_DELETE_STATUS_ARB* = 0x00008B80 + GL_OBJECT_COMPILE_STATUS_ARB* = 0x00008B81 + GL_OBJECT_LINK_STATUS_ARB* = 0x00008B82 + GL_OBJECT_VALIDATE_STATUS_ARB* = 0x00008B83 + GL_OBJECT_INFO_LOG_LENGTH_ARB* = 0x00008B84 + GL_OBJECT_ATTACHED_OBJECTS_ARB* = 0x00008B85 + GL_OBJECT_ACTIVE_UNIFORMS_ARB* = 0x00008B86 + GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB* = 0x00008B87 + GL_OBJECT_SHADER_SOURCE_LENGTH_ARB* = 0x00008B88 + GL_SHADER_OBJECT_ARB* = 0x00008B48 + GL_FLOAT* = 0x00001406 + GL_FLOAT_VEC2_ARB* = 0x00008B50 + GL_FLOAT_VEC3_ARB* = 0x00008B51 + GL_FLOAT_VEC4_ARB* = 0x00008B52 + GL_INT* = 0x00001404 + GL_INT_VEC2_ARB* = 0x00008B53 + GL_INT_VEC3_ARB* = 0x00008B54 + GL_INT_VEC4_ARB* = 0x00008B55 + GL_BOOL_ARB* = 0x00008B56 + GL_BOOL_VEC2_ARB* = 0x00008B57 + GL_BOOL_VEC3_ARB* = 0x00008B58 + GL_BOOL_VEC4_ARB* = 0x00008B59 + GL_FLOAT_MAT2_ARB* = 0x00008B5A + GL_FLOAT_MAT3_ARB* = 0x00008B5B + GL_FLOAT_MAT4_ARB* = 0x00008B5C + +proc glDeleteObjectARB*(obj: GLhandleARB){.dynlib: dllname, importc.} +proc glGetHandleARB*(pname: TGLenum): GLhandleARB{.dynlib: dllname, importc.} +proc glDetachObjectARB*(containerObj: GLhandleARB, attachedObj: GLhandleARB){. + dynlib: dllname, importc.} +proc glCreateShaderObjectARB*(shaderType: TGLenum): GLhandleARB{.dynlib: dllname, + importc.} +proc glShaderSourceARB*(shaderObj: GLhandleARB, count: TGLsizei, str: PGLvoid, + len: PGLint){.dynlib: dllname, importc.} +proc glCompileShaderARB*(shaderObj: GLhandleARB){.dynlib: dllname, importc.} +proc glCreateProgramObjectARB*(): GLhandleARB{.dynlib: dllname, importc.} +proc glAttachObjectARB*(containerObj: GLhandleARB, obj: GLhandleARB){. + dynlib: dllname, importc.} +proc glLinkProgramARB*(programObj: GLhandleARB){.dynlib: dllname, importc.} +proc glUseProgramObjectARB*(programObj: GLhandleARB){.dynlib: dllname, importc.} +proc glValidateProgramARB*(programObj: GLhandleARB){.dynlib: dllname, importc.} +proc glUniform1fARB*(location: TGLint, v0: TGLfloat){.dynlib: dllname, importc.} +proc glUniform2fARB*(location: TGLint, v0: TGLfloat, v1: TGLfloat){. + dynlib: dllname, importc.} +proc glUniform3fARB*(location: TGLint, v0: TGLfloat, v1: TGLfloat, v2: TGLfloat){. + dynlib: dllname, importc.} +proc glUniform4fARB*(location: TGLint, v0: TGLfloat, v1: TGLfloat, v2: TGLfloat, + v3: TGLfloat){.dynlib: dllname, importc.} +proc glUniform1iARB*(location: TGLint, v0: TGLint){.dynlib: dllname, importc.} +proc glUniform2iARB*(location: TGLint, v0: TGLint, v1: TGLint){.dynlib: dllname, + importc.} +proc glUniform3iARB*(location: TGLint, v0: TGLint, v1: TGLint, v2: TGLint){. + dynlib: dllname, importc.} +proc glUniform4iARB*(location: TGLint, v0: TGLint, v1: TGLint, v2: TGLint, v3: TGLint){. + dynlib: dllname, importc.} +proc glUniform1fvARB*(location: TGLint, count: TGLsizei, value: PGLfloat){. + dynlib: dllname, importc.} +proc glUniform2fvARB*(location: TGLint, count: TGLsizei, value: PGLfloat){. + dynlib: dllname, importc.} +proc glUniform3fvARB*(location: TGLint, count: TGLsizei, value: PGLfloat){. + dynlib: dllname, importc.} +proc glUniform4fvARB*(location: TGLint, count: TGLsizei, value: PGLfloat){. + dynlib: dllname, importc.} +proc glUniform1ivARB*(location: TGLint, count: TGLsizei, value: PGLint){. + dynlib: dllname, importc.} +proc glUniform2ivARB*(location: TGLint, count: TGLsizei, value: PGLint){. + dynlib: dllname, importc.} +proc glUniform3ivARB*(location: TGLint, count: TGLsizei, value: PGLint){. + dynlib: dllname, importc.} +proc glUniform4ivARB*(location: TGLint, count: TGLsizei, value: PGLint){. + dynlib: dllname, importc.} +proc glUniformMatrix2fvARB*(location: TGLint, count: TGLsizei, + transpose: TGLboolean, value: PGLfloat){. + dynlib: dllname, importc.} +proc glUniformMatrix3fvARB*(location: TGLint, count: TGLsizei, + transpose: TGLboolean, value: PGLfloat){. + dynlib: dllname, importc.} +proc glUniformMatrix4fvARB*(location: TGLint, count: TGLsizei, + transpose: TGLboolean, value: PGLfloat){. + dynlib: dllname, importc.} +proc glGetObjectParameterfvARB*(obj: GLhandleARB, pname: TGLenum, + params: PGLfloat){.dynlib: dllname, importc.} +proc glGetObjectParameterivARB*(obj: GLhandleARB, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glGetInfoLogARB*(obj: GLhandleARB, maxLength: TGLsizei, len: PGLsizei, + infoLog: PGLcharARB){.dynlib: dllname, importc.} +proc glGetAttachedObjectsARB*(containerObj: GLhandleARB, maxCount: TGLsizei, + count: PGLsizei, obj: PGLhandleARB){. + dynlib: dllname, importc.} +proc glGetUniformLocationARB*(programObj: GLhandleARB, name: PGLcharARB): TGLint{. + dynlib: dllname, importc.} +proc glGetActiveUniformARB*(programObj: GLhandleARB, index: TGLuint, + maxLength: TGLsizei, len: PGLsizei, size: PGLint, + thetype: PGLenum, name: PGLcharARB){. + dynlib: dllname, importc.} +proc glGetUniformfvARB*(programObj: GLhandleARB, location: TGLint, + params: PGLfloat){.dynlib: dllname, importc.} +proc glGetUniformivARB*(programObj: GLhandleARB, location: TGLint, params: PGLint){. + dynlib: dllname, importc.} +proc glGetShaderSourceARB*(obj: GLhandleARB, maxLength: TGLsizei, len: PGLsizei, + source: PGLcharARB){.dynlib: dllname, importc.} + +const + GL_VERTEX_SHADER_ARB* = 0x00008B31 + GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB* = 0x00008B4A + GL_MAX_VARYING_FLOATS_ARB* = 0x00008B4B # GL_MAX_VERTEX_ATTRIBS_ARB { already defined } + # GL_MAX_TEXTURE_IMAGE_UNITS_ARB { already defined } + GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB* = 0x00008B4C + GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB* = 0x00008B4D # + # GL_MAX_TEXTURE_COORDS_ARB { already defined } + # + # GL_VERTEX_PROGRAM_POINT_SIZE_ARB { already defined } + # + # GL_VERTEX_PROGRAM_TWO_SIDE_ARB { already defined } + # GL_OBJECT_TYPE_ARB { already defined } + # GL_OBJECT_SUBTYPE_ARB { already defined } + GL_OBJECT_ACTIVE_ATTRIBUTES_ARB* = 0x00008B89 + GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB* = 0x00008B8A # GL_SHADER_OBJECT_ARB { already defined } + # + # GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB { already defined } + # + # GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB { already defined } + # + # GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB { already defined } + # + # GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB { already defined } + # + # GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB { already defined } + # + # GL_CURRENT_VERTEX_ATTRIB_ARB { already defined } + # + # GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB { already defined } + # GL_FLOAT { already defined } + # GL_FLOAT_VEC2_ARB { already defined } + # GL_FLOAT_VEC3_ARB { already defined } + # GL_FLOAT_VEC4_ARB { already defined } + # GL_FLOAT_MAT2_ARB { already defined } + # GL_FLOAT_MAT3_ARB { already defined } + # GL_FLOAT_MAT4_ARB { already defined } + # glVertexAttrib1fARB { already defined } + # glVertexAttrib1sARB { already defined } + # glVertexAttrib1dARB { already defined } + # glVertexAttrib2fARB { already defined } + # glVertexAttrib2sARB { already defined } + # glVertexAttrib2dARB { already defined } + # glVertexAttrib3fARB { already defined } + # glVertexAttrib3sARB { already defined } + # glVertexAttrib3dARB { already defined } + # glVertexAttrib4fARB { already defined } + # glVertexAttrib4sARB { already defined } + # glVertexAttrib4dARB { already defined } + # glVertexAttrib4NubARB { already defined } + # glVertexAttrib1fvARB { already defined } + # glVertexAttrib1svARB { already defined } + # glVertexAttrib1dvARB { already defined } + # glVertexAttrib2fvARB { already defined } + # glVertexAttrib2svARB { already defined } + # glVertexAttrib2dvARB { already defined } + # glVertexAttrib3fvARB { already defined } + # glVertexAttrib3svARB { already defined } + # glVertexAttrib3dvARB { already defined } + # glVertexAttrib4fvARB { already defined } + # glVertexAttrib4svARB { already defined } + # glVertexAttrib4dvARB { already defined } + # glVertexAttrib4ivARB { already defined } + # glVertexAttrib4bvARB { already defined } + # glVertexAttrib4ubvARB { already defined } + # glVertexAttrib4usvARB { already defined } + # glVertexAttrib4uivARB { already defined } + # glVertexAttrib4NbvARB { already defined } + # glVertexAttrib4NsvARB { already defined } + # glVertexAttrib4NivARB { already defined } + # glVertexAttrib4NubvARB { already defined } + # glVertexAttrib4NusvARB { already defined } + # glVertexAttrib4NuivARB { already defined } + # + # glVertexAttribPointerARB { already defined } + # + # glEnableVertexAttribArrayARB { already defined } + # + # glDisableVertexAttribArrayARB { already defined } + +proc glBindAttribLocationARB*(programObj: GLhandleARB, index: TGLuint, + name: PGLcharARB){.dynlib: dllname, importc.} +proc glGetActiveAttribARB*(programObj: GLhandleARB, index: TGLuint, + maxLength: TGLsizei, len: PGLsizei, size: PGLint, + thetype: PGLenum, name: PGLcharARB){.dynlib: dllname, + importc.} +proc glGetAttribLocationARB*(programObj: GLhandleARB, name: PGLcharARB): TGLint{. + dynlib: dllname, importc.} + # glGetVertexAttribdvARB { already defined } + # glGetVertexAttribfvARB { already defined } + # glGetVertexAttribivARB { already defined } + # glGetVertexAttribPointervARB { already defined } + #***** GL_ARB_fragment_shader *****// +const + GL_FRAGMENT_SHADER_ARB* = 0x00008B30 + GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB* = 0x00008B49 # GL_MAX_TEXTURE_COORDS_ARB { already defined } + # + # GL_MAX_TEXTURE_IMAGE_UNITS_ARB { already defined } + # GL_OBJECT_TYPE_ARB { already defined } + # GL_OBJECT_SUBTYPE_ARB { already defined } + # GL_SHADER_OBJECT_ARB { already defined } + + #***** GL_ARB_shading_language_100 *****// + #***** GL_ARB_texture_non_power_of_two *****// + #***** GL_ARB_point_sprite *****// +const + GL_POINT_SPRITE_ARB* = 0x00008861 + GL_COORD_REPLACE_ARB* = 0x00008862 + + #***** GL_EXT_depth_bounds_test *****// +const + constGL_DEPTH_BOUNDS_TEST_EXT* = 0x00008890 + constGL_DEPTH_BOUNDS_EXT* = 0x00008891 + +proc glDepthBoundsEXT*(zmin: TGLclampd, zmax: TGLclampd){.dynlib: dllname, importc.} + #***** GL_EXT_texture_mirror_clamp *****// +const + GL_MIRROR_CLAMP_EXT* = 0x00008742 + GL_MIRROR_CLAMP_TO_EDGE_EXT* = 0x00008743 + GL_MIRROR_CLAMP_TO_BORDER_EXT* = 0x00008912 + + #***** GL_EXT_blend_equation_separate *****// +const + GL_BLEND_EQUATION_RGB_EXT* = 0x00008009 + GL_BLEND_EQUATION_ALPHA_EXT* = 0x0000883D + +proc glBlendEquationSeparateEXT*(modeRGB: TGLenum, modeAlpha: TGLenum){. + dynlib: dllname, importc.} + #***** GL_MESA_pack_invert *****// +const + GL_PACK_INVERT_MESA* = 0x00008758 + + #***** GL_MESA_ycbcr_texture *****// +const + GL_YCBCR_MESA* = 0x00008757 + GL_UNSIGNED_SHORT_8_8_MESA* = 0x000085BA + GL_UNSIGNED_SHORT_8_8_REV_MESA* = 0x000085BB + + #***** GL_ARB_fragment_program_shadow *****// + #***** GL_NV_fragment_program_option *****// + #***** GL_EXT_pixel_buffer_object *****// +const + GL_PIXEL_PACK_BUFFER_EXT* = 0x000088EB + GL_PIXEL_UNPACK_BUFFER_EXT* = 0x000088EC + GL_PIXEL_PACK_BUFFER_BINDING_EXT* = 0x000088ED + GL_PIXEL_UNPACK_BUFFER_BINDING_EXT* = 0x000088EF + + #***** GL_NV_fragment_program2 *****// +const + GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV* = 0x000088F4 + GL_MAX_PROGRAM_CALL_DEPTH_NV* = 0x000088F5 + GL_MAX_PROGRAM_IF_DEPTH_NV* = 0x000088F6 + GL_MAX_PROGRAM_LOOP_DEPTH_NV* = 0x000088F7 + GL_MAX_PROGRAM_LOOP_COUNT_NV* = 0x000088F8 + + #***** GL_NV_vertex_program2_option *****// + # GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV { already defined } + # GL_MAX_PROGRAM_CALL_DEPTH_NV { already defined } + #***** GL_NV_vertex_program3 *****// + # GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB { already defined } + #***** GL_ARB_draw_buffers *****// +const + GL_MAX_DRAW_BUFFERS_ARB* = 0x00008824 + GL_DRAW_BUFFER0_ARB* = 0x00008825 + GL_DRAW_BUFFER1_ARB* = 0x00008826 + GL_DRAW_BUFFER2_ARB* = 0x00008827 + GL_DRAW_BUFFER3_ARB* = 0x00008828 + GL_DRAW_BUFFER4_ARB* = 0x00008829 + GL_DRAW_BUFFER5_ARB* = 0x0000882A + GL_DRAW_BUFFER6_ARB* = 0x0000882B + GL_DRAW_BUFFER7_ARB* = 0x0000882C + GL_DRAW_BUFFER8_ARB* = 0x0000882D + GL_DRAW_BUFFER9_ARB* = 0x0000882E + GL_DRAW_BUFFER10_ARB* = 0x0000882F + GL_DRAW_BUFFER11_ARB* = 0x00008830 + GL_DRAW_BUFFER12_ARB* = 0x00008831 + GL_DRAW_BUFFER13_ARB* = 0x00008832 + GL_DRAW_BUFFER14_ARB* = 0x00008833 + GL_DRAW_BUFFER15_ARB* = 0x00008834 + +proc glDrawBuffersARB*(n: TGLsizei, bufs: PGLenum){.dynlib: dllname, importc.} + #***** GL_ARB_texture_rectangle *****// +const + GL_TEXTURE_RECTANGLE_ARB* = 0x000084F5 + GL_TEXTURE_BINDING_RECTANGLE_ARB* = 0x000084F6 + GL_PROXY_TEXTURE_RECTANGLE_ARB* = 0x000084F7 + GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB* = 0x000084F8 + + #***** GL_ARB_color_buffer_float *****// +const + GL_RGBA_FLOAT_MODE_ARB* = 0x00008820 + GL_CLAMP_VERTEX_COLOR_ARB* = 0x0000891A + GL_CLAMP_FRAGMENT_COLOR_ARB* = 0x0000891B + GL_CLAMP_READ_COLOR_ARB* = 0x0000891C + GL_FIXED_ONLY_ARB* = 0x0000891D + WGL_TYPE_RGBA_FLOAT_ARB* = 0x000021A0 + +proc glClampColorARB*(target: TGLenum, clamp: TGLenum){.dynlib: dllname, importc.} + #***** GL_ARB_half_float_pixel *****// +const + GL_HALF_FLOAT_ARB* = 0x0000140B + + #***** GL_ARB_texture_float *****// +const + GL_TEXTURE_RED_TYPE_ARB* = 0x00008C10 + GL_TEXTURE_GREEN_TYPE_ARB* = 0x00008C11 + GL_TEXTURE_BLUE_TYPE_ARB* = 0x00008C12 + GL_TEXTURE_ALPHA_TYPE_ARB* = 0x00008C13 + GL_TEXTURE_LUMINANCE_TYPE_ARB* = 0x00008C14 + GL_TEXTURE_INTENSITY_TYPE_ARB* = 0x00008C15 + GL_TEXTURE_DEPTH_TYPE_ARB* = 0x00008C16 + GL_UNSIGNED_NORMALIZED_ARB* = 0x00008C17 + GL_RGBA32F_ARB* = 0x00008814 + GL_RGB32F_ARB* = 0x00008815 + GL_ALPHA32F_ARB* = 0x00008816 + GL_INTENSITY32F_ARB* = 0x00008817 + GL_LUMINANCE32F_ARB* = 0x00008818 + GL_LUMINANCE_ALPHA32F_ARB* = 0x00008819 + GL_RGBA16F_ARB* = 0x0000881A + GL_RGB16F_ARB* = 0x0000881B + GL_ALPHA16F_ARB* = 0x0000881C + GL_INTENSITY16F_ARB* = 0x0000881D + GL_LUMINANCE16F_ARB* = 0x0000881E + GL_LUMINANCE_ALPHA16F_ARB* = 0x0000881F + + #***** GL_EXT_texture_compression_dxt1 *****// + # GL_COMPRESSED_RGB_S3TC_DXT1_EXT { already defined } + # GL_COMPRESSED_RGBA_S3TC_DXT1_EXT { already defined } + #***** GL_ARB_pixel_buffer_object *****// +const + GL_PIXEL_PACK_BUFFER_ARB* = 0x000088EB + GL_PIXEL_UNPACK_BUFFER_ARB* = 0x000088EC + GL_PIXEL_PACK_BUFFER_BINDING_ARB* = 0x000088ED + GL_PIXEL_UNPACK_BUFFER_BINDING_ARB* = 0x000088EF + + #***** GL_EXT_framebuffer_object *****// +const + GL_FRAMEBUFFER_EXT* = 0x00008D40 + GL_RENDERBUFFER_EXT* = 0x00008D41 + GL_STENCIL_INDEX_EXT* = 0x00008D45 + GL_STENCIL_INDEX1_EXT* = 0x00008D46 + GL_STENCIL_INDEX4_EXT* = 0x00008D47 + GL_STENCIL_INDEX8_EXT* = 0x00008D48 + GL_STENCIL_INDEX16_EXT* = 0x00008D49 + GL_RENDERBUFFER_WIDTH_EXT* = 0x00008D42 + GL_RENDERBUFFER_HEIGHT_EXT* = 0x00008D43 + GL_RENDERBUFFER_INTERNAL_FORMAT_EXT* = 0x00008D44 + GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT* = 0x00008CD0 + GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT* = 0x00008CD1 + GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT* = 0x00008CD2 + GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT* = 0x00008CD3 + GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT* = 0x00008CD4 + GL_COLOR_ATTACHMENT0_EXT* = 0x00008CE0 + GL_COLOR_ATTACHMENT1_EXT* = 0x00008CE1 + GL_COLOR_ATTACHMENT2_EXT* = 0x00008CE2 + GL_COLOR_ATTACHMENT3_EXT* = 0x00008CE3 + GL_COLOR_ATTACHMENT4_EXT* = 0x00008CE4 + GL_COLOR_ATTACHMENT5_EXT* = 0x00008CE5 + GL_COLOR_ATTACHMENT6_EXT* = 0x00008CE6 + GL_COLOR_ATTACHMENT7_EXT* = 0x00008CE7 + GL_COLOR_ATTACHMENT8_EXT* = 0x00008CE8 + GL_COLOR_ATTACHMENT9_EXT* = 0x00008CE9 + GL_COLOR_ATTACHMENT10_EXT* = 0x00008CEA + GL_COLOR_ATTACHMENT11_EXT* = 0x00008CEB + GL_COLOR_ATTACHMENT12_EXT* = 0x00008CEC + GL_COLOR_ATTACHMENT13_EXT* = 0x00008CED + GL_COLOR_ATTACHMENT14_EXT* = 0x00008CEE + GL_COLOR_ATTACHMENT15_EXT* = 0x00008CEF + GL_DEPTH_ATTACHMENT_EXT* = 0x00008D00 + GL_STENCIL_ATTACHMENT_EXT* = 0x00008D20 + GL_FRAMEBUFFER_COMPLETE_EXT* = 0x00008CD5 + GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT* = 0x00008CD6 + GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT* = 0x00008CD7 + GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT* = 0x00008CD8 + GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT* = 0x00008CD9 + GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT* = 0x00008CDA + GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT* = 0x00008CDB + GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT* = 0x00008CDC + GL_FRAMEBUFFER_UNSUPPORTED_EXT* = 0x00008CDD + GL_FRAMEBUFFER_STATUS_ERROR_EXT* = 0x00008CDE + GL_FRAMEBUFFER_BINDING_EXT* = 0x00008CA6 + GL_RENDERBUFFER_BINDING_EXT* = 0x00008CA7 + GL_MAX_COLOR_ATTACHMENTS_EXT* = 0x00008CDF + GL_MAX_RENDERBUFFER_SIZE_EXT* = 0x000084E8 + GL_INVALID_FRAMEBUFFER_OPERATION_EXT* = 0x00000506 + +proc glIsRenderbufferEXT*(renderbuffer: TGLuint): TGLboolean{.dynlib: dllname, + importc.} +proc glBindRenderbufferEXT*(target: TGLenum, renderbuffer: TGLuint){. + dynlib: dllname, importc.} +proc glDeleteRenderbuffersEXT*(n: TGLsizei, renderbuffers: PGLuint){. + dynlib: dllname, importc.} +proc glGenRenderbuffersEXT*(n: TGLsizei, renderbuffers: PGLuint){. + dynlib: dllname, importc.} +proc glRenderbufferStorageEXT*(target: TGLenum, internalformat: TGLenum, + width: TGLsizei, height: TGLsizei){. + dynlib: dllname, importc.} +proc glGetRenderbufferParameterivEXT*(target: TGLenum, pname: TGLenum, + params: PGLint){.dynlib: dllname, importc.} +proc glIsFramebufferEXT*(framebuffer: TGLuint): TGLboolean{.dynlib: dllname, + importc.} +proc glBindFramebufferEXT*(target: TGLenum, framebuffer: TGLuint){. + dynlib: dllname, importc.} +proc glDeleteFramebuffersEXT*(n: TGLsizei, framebuffers: PGLuint){. + dynlib: dllname, importc.} +proc glGenFramebuffersEXT*(n: TGLsizei, framebuffers: PGLuint){.dynlib: dllname, + importc.} +proc glCheckFramebufferStatusEXT*(target: TGLenum): TGLenum{.dynlib: dllname, + importc.} +proc glFramebufferTexture1DEXT*(target: TGLenum, attachment: TGLenum, + textarget: TGLenum, texture: TGLuint, level: TGLint){. + dynlib: dllname, importc.} +proc glFramebufferTexture2DEXT*(target: TGLenum, attachment: TGLenum, + textarget: TGLenum, texture: TGLuint, level: TGLint){. + dynlib: dllname, importc.} +proc glFramebufferTexture3DEXT*(target: TGLenum, attachment: TGLenum, + textarget: TGLenum, texture: TGLuint, + level: TGLint, zoffset: TGLint){.dynlib: dllname, + importc.} +proc glFramebufferRenderbufferEXT*(target: TGLenum, attachment: TGLenum, + renderbuffertarget: TGLenum, + renderbuffer: TGLuint){.dynlib: dllname, + importc.} +proc glGetFramebufferAttachmentParameterivEXT*(target: TGLenum, + attachment: TGLenum, pname: TGLenum, params: PGLint){.dynlib: dllname, importc.} +proc glGenerateMipmapEXT*(target: TGLenum){.dynlib: dllname, importc.} + #***** GL_version_1_4 *****// +const + GL_BLEND_DST_RGB* = 0x000080C8 + GL_BLEND_SRC_RGB* = 0x000080C9 + GL_BLEND_DST_ALPHA* = 0x000080CA + GL_BLEND_SRC_ALPHA* = 0x000080CB + GL_POINT_SIZE_MIN* = 0x00008126 + GL_POINT_SIZE_MAX* = 0x00008127 + GL_POINT_FADE_THRESHOLD_SIZE* = 0x00008128 + GL_POINT_DISTANCE_ATTENUATION* = 0x00008129 + GL_GENERATE_MIPMAP* = 0x00008191 + GL_GENERATE_MIPMAP_HINT* = 0x00008192 + GL_DEPTH_COMPONENT16* = 0x000081A5 + GL_DEPTH_COMPONENT24* = 0x000081A6 + GL_DEPTH_COMPONENT32* = 0x000081A7 + GL_MIRRORED_REPEAT* = 0x00008370 + GL_FOG_COORDINATE_SOURCE* = 0x00008450 + GL_FOG_COORDINATE* = 0x00008451 + GL_FRAGMENT_DEPTH* = 0x00008452 + GL_CURRENT_FOG_COORDINATE* = 0x00008453 + GL_FOG_COORDINATE_ARRAY_TYPE* = 0x00008454 + GL_FOG_COORDINATE_ARRAY_STRIDE* = 0x00008455 + GL_FOG_COORDINATE_ARRAY_POINTER* = 0x00008456 + GL_FOG_COORDINATE_ARRAY* = 0x00008457 + GL_COLOR_SUM* = 0x00008458 + GL_CURRENT_SECONDARY_COLOR* = 0x00008459 + GL_SECONDARY_COLOR_ARRAY_SIZE* = 0x0000845A + GL_SECONDARY_COLOR_ARRAY_TYPE* = 0x0000845B + GL_SECONDARY_COLOR_ARRAY_STRIDE* = 0x0000845C + GL_SECONDARY_COLOR_ARRAY_POINTER* = 0x0000845D + GL_SECONDARY_COLOR_ARRAY* = 0x0000845E + GL_MAX_TEXTURE_LOD_BIAS* = 0x000084FD + GL_TEXTURE_FILTER_CONTROL* = 0x00008500 + GL_TEXTURE_LOD_BIAS* = 0x00008501 + GL_INCR_WRAP* = 0x00008507 + GL_DECR_WRAP* = 0x00008508 + GL_TEXTURE_DEPTH_SIZE* = 0x0000884A + GL_DEPTH_TEXTURE_MODE* = 0x0000884B + GL_TEXTURE_COMPARE_MODE* = 0x0000884C + GL_TEXTURE_COMPARE_FUNC* = 0x0000884D + GL_COMPARE_R_TO_TEXTURE* = 0x0000884E + +proc glBlendFuncSeparate*(sfactorRGB: TGLenum, dfactorRGB: TGLenum, + sfactorAlpha: TGLenum, dfactorAlpha: TGLenum){. + dynlib: dllname, importc.} +proc glFogCoordf*(coord: TGLfloat){.dynlib: dllname, importc.} +proc glFogCoordfv*(coord: PGLfloat){.dynlib: dllname, importc.} +proc glFogCoordd*(coord: TGLdouble){.dynlib: dllname, importc.} +proc glFogCoorddv*(coord: PGLdouble){.dynlib: dllname, importc.} +proc glFogCoordPointer*(thetype: TGLenum, stride: TGLsizei, pointer: PGLvoid){. + dynlib: dllname, importc.} +proc glMultiDrawArrays*(mode: TGLenum, first: PGLint, count: PGLsizei, + primcount: TGLsizei){.dynlib: dllname, importc.} +proc glMultiDrawElements*(mode: TGLenum, count: PGLsizei, thetype: TGLenum, + indices: PGLvoid, primcount: TGLsizei){. + dynlib: dllname, importc.} +proc glPointParameterf*(pname: TGLenum, param: TGLfloat){.dynlib: dllname, importc.} +proc glPointParameterfv*(pname: TGLenum, params: PGLfloat){.dynlib: dllname, + importc.} +proc glPointParameteri*(pname: TGLenum, param: TGLint){.dynlib: dllname, importc.} +proc glPointParameteriv*(pname: TGLenum, params: PGLint){.dynlib: dllname, + importc.} +proc glSecondaryColor3b*(red: TGLByte, green: TGLByte, blue: TGLByte){. + dynlib: dllname, importc.} +proc glSecondaryColor3bv*(v: PGLbyte){.dynlib: dllname, importc.} +proc glSecondaryColor3d*(red: TGLdouble, green: TGLdouble, blue: TGLdouble){. + dynlib: dllname, importc.} +proc glSecondaryColor3dv*(v: PGLdouble){.dynlib: dllname, importc.} +proc glSecondaryColor3f*(red: TGLfloat, green: TGLfloat, blue: TGLfloat){. + dynlib: dllname, importc.} +proc glSecondaryColor3fv*(v: PGLfloat){.dynlib: dllname, importc.} +proc glSecondaryColor3i*(red: TGLint, green: TGLint, blue: TGLint){. + dynlib: dllname, importc.} +proc glSecondaryColor3iv*(v: PGLint){.dynlib: dllname, importc.} +proc glSecondaryColor3s*(red: TGLshort, green: TGLshort, blue: TGLshort){. + dynlib: dllname, importc.} +proc glSecondaryColor3sv*(v: PGLshort){.dynlib: dllname, importc.} +proc glSecondaryColor3ub*(red: TGLubyte, green: TGLubyte, blue: TGLubyte){. + dynlib: dllname, importc.} +proc glSecondaryColor3ubv*(v: PGLubyte){.dynlib: dllname, importc.} +proc glSecondaryColor3ui*(red: TGLuint, green: TGLuint, blue: TGLuint){. + dynlib: dllname, importc.} +proc glSecondaryColor3uiv*(v: PGLuint){.dynlib: dllname, importc.} +proc glSecondaryColor3us*(red: TGLushort, green: TGLushort, blue: TGLushort){. + dynlib: dllname, importc.} +proc glSecondaryColor3usv*(v: PGLushort){.dynlib: dllname, importc.} +proc glSecondaryColorPointer*(size: TGLint, thetype: TGLenum, stride: TGLsizei, + pointer: PGLvoid){.dynlib: dllname, importc.} +proc glWindowPos2d*(x: TGLdouble, y: TGLdouble){.dynlib: dllname, importc.} +proc glWindowPos2dv*(v: PGLdouble){.dynlib: dllname, importc.} +proc glWindowPos2f*(x: TGLfloat, y: TGLfloat){.dynlib: dllname, importc.} +proc glWindowPos2fv*(v: PGLfloat){.dynlib: dllname, importc.} +proc glWindowPos2i*(x: TGLint, y: TGLint){.dynlib: dllname, importc.} +proc glWindowPos2iv*(v: PGLint){.dynlib: dllname, importc.} +proc glWindowPos2s*(x: TGLshort, y: TGLshort){.dynlib: dllname, importc.} +proc glWindowPos2sv*(v: PGLshort){.dynlib: dllname, importc.} +proc glWindowPos3d*(x: TGLdouble, y: TGLdouble, z: TGLdouble){.dynlib: dllname, + importc.} +proc glWindowPos3dv*(v: PGLdouble){.dynlib: dllname, importc.} +proc glWindowPos3f*(x: TGLfloat, y: TGLfloat, z: TGLfloat){.dynlib: dllname, + importc.} +proc glWindowPos3fv*(v: PGLfloat){.dynlib: dllname, importc.} +proc glWindowPos3i*(x: TGLint, y: TGLint, z: TGLint){.dynlib: dllname, importc.} +proc glWindowPos3iv*(v: PGLint){.dynlib: dllname, importc.} +proc glWindowPos3s*(x: TGLshort, y: TGLshort, z: TGLshort){.dynlib: dllname, + importc.} +proc glWindowPos3sv*(v: PGLshort){.dynlib: dllname, importc.} + #***** GL_version_1_5 *****// +const + GL_BUFFER_SIZE* = 0x00008764 + GL_BUFFER_USAGE* = 0x00008765 + GL_QUERY_COUNTER_BITS* = 0x00008864 + GL_CURRENT_QUERY* = 0x00008865 + GL_QUERY_RESULT* = 0x00008866 + GL_QUERY_RESULT_AVAILABLE* = 0x00008867 + GL_ARRAY_BUFFER* = 0x00008892 + GL_ELEMENT_ARRAY_BUFFER* = 0x00008893 + GL_ARRAY_BUFFER_BINDING* = 0x00008894 + GL_ELEMENT_ARRAY_BUFFER_BINDING* = 0x00008895 + GL_VERTEX_ARRAY_BUFFER_BINDING* = 0x00008896 + GL_NORMAL_ARRAY_BUFFER_BINDING* = 0x00008897 + GL_COLOR_ARRAY_BUFFER_BINDING* = 0x00008898 + GL_INDEX_ARRAY_BUFFER_BINDING* = 0x00008899 + GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING* = 0x0000889A + GL_EDGE_FLAG_ARRAY_BUFFER_BINDING* = 0x0000889B + GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING* = 0x0000889C + GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING* = 0x0000889D + GL_WEIGHT_ARRAY_BUFFER_BINDING* = 0x0000889E + GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING* = 0x0000889F + GL_READ_ONLY* = 0x000088B8 + GL_WRITE_ONLY* = 0x000088B9 + GL_READ_WRITE* = 0x000088BA + GL_BUFFER_ACCESS* = 0x000088BB + GL_BUFFER_MAPPED* = 0x000088BC + GL_BUFFER_MAP_POINTER* = 0x000088BD + GL_STREAM_DRAW* = 0x000088E0 + GL_STREAM_READ* = 0x000088E1 + GL_STREAM_COPY* = 0x000088E2 + GL_STATIC_DRAW* = 0x000088E4 + GL_STATIC_READ* = 0x000088E5 + GL_STATIC_COPY* = 0x000088E6 + GL_DYNAMIC_DRAW* = 0x000088E8 + GL_DYNAMIC_READ* = 0x000088E9 + GL_DYNAMIC_COPY* = 0x000088EA + GL_SAMPLES_PASSED* = 0x00008914 + GL_FOG_COORD_SRC* = 0x00008450 + GL_FOG_COORD* = 0x00008451 + GL_CURRENT_FOG_COORD* = 0x00008453 + GL_FOG_COORD_ARRAY_TYPE* = 0x00008454 + GL_FOG_COORD_ARRAY_STRIDE* = 0x00008455 + GL_FOG_COORD_ARRAY_POINTER* = 0x00008456 + GL_FOG_COORD_ARRAY* = 0x00008457 + GL_FOG_COORD_ARRAY_BUFFER_BINDING* = 0x0000889D + GL_SRC0_RGB* = 0x00008580 + GL_SRC1_RGB* = 0x00008581 + GL_SRC2_RGB* = 0x00008582 + GL_SRC0_ALPHA* = 0x00008588 + GL_SRC1_ALPHA* = 0x00008589 + GL_SRC2_ALPHA* = 0x0000858A + +proc glGenQueries*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, importc.} +proc glDeleteQueries*(n: TGLsizei, ids: PGLuint){.dynlib: dllname, importc.} +proc glIsQuery*(id: TGLuint): TGLboolean{.dynlib: dllname, importc.} +proc glBeginQuery*(target: TGLenum, id: TGLuint){.dynlib: dllname, importc.} +proc glEndQuery*(target: TGLenum){.dynlib: dllname, importc.} +proc glGetQueryiv*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glGetQueryObjectiv*(id: TGLuint, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glGetQueryObjectuiv*(id: TGLuint, pname: TGLenum, params: PGLuint){. + dynlib: dllname, importc.} +proc glBindBuffer*(target: TGLenum, buffer: TGLuint){.dynlib: dllname, importc.} +proc glDeleteBuffers*(n: TGLsizei, buffers: PGLuint){.dynlib: dllname, importc.} +proc glGenBuffers*(n: TGLsizei, buffers: PGLuint){.dynlib: dllname, importc.} +proc glIsBuffer*(buffer: TGLuint): TGLboolean{.dynlib: dllname, importc.} +proc glBufferData*(target: TGLenum, size: GLsizeiptr, data: PGLvoid, + usage: TGLenum){.dynlib: dllname, importc.} +proc glBufferSubData*(target: TGLenum, offset: GLintptr, size: GLsizeiptr, + data: PGLvoid){.dynlib: dllname, importc.} +proc glGetBufferSubData*(target: TGLenum, offset: GLintptr, size: GLsizeiptr, + data: PGLvoid){.dynlib: dllname, importc.} +proc glMapBuffer*(target: TGLenum, access: TGLenum): PGLvoid{.dynlib: dllname, + importc.} +proc glUnmapBuffer*(target: TGLenum): TGLboolean{.dynlib: dllname, importc.} +proc glGetBufferParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){. + dynlib: dllname, importc.} +proc glGetBufferPointerv*(target: TGLenum, pname: TGLenum, params: PGLvoid){. + dynlib: dllname, importc.} + #***** GL_version_2_0 *****// +const + GL_BLEND_EQUATION_RGB* = 0x00008009 + GL_VERTEX_ATTRIB_ARRAY_ENABLED* = 0x00008622 + GL_VERTEX_ATTRIB_ARRAY_SIZE* = 0x00008623 + GL_VERTEX_ATTRIB_ARRAY_STRIDE* = 0x00008624 + GL_VERTEX_ATTRIB_ARRAY_TYPE* = 0x00008625 + GL_CURRENT_VERTEX_ATTRIB* = 0x00008626 + GL_VERTEX_PROGRAM_POINT_SIZE* = 0x00008642 + GL_VERTEX_PROGRAM_TWO_SIDE* = 0x00008643 + GL_VERTEX_ATTRIB_ARRAY_POINTER* = 0x00008645 + GL_STENCIL_BACK_FUNC* = 0x00008800 + GL_STENCIL_BACK_FAIL* = 0x00008801 + GL_STENCIL_BACK_PASS_DEPTH_FAIL* = 0x00008802 + GL_STENCIL_BACK_PASS_DEPTH_PASS* = 0x00008803 + GL_MAX_DRAW_BUFFERS* = 0x00008824 + GL_DRAW_BUFFER0* = 0x00008825 + GL_DRAW_BUFFER1* = 0x00008826 + GL_DRAW_BUFFER2* = 0x00008827 + GL_DRAW_BUFFER3* = 0x00008828 + GL_DRAW_BUFFER4* = 0x00008829 + GL_DRAW_BUFFER5* = 0x0000882A + GL_DRAW_BUFFER6* = 0x0000882B + GL_DRAW_BUFFER7* = 0x0000882C + GL_DRAW_BUFFER8* = 0x0000882D + GL_DRAW_BUFFER9* = 0x0000882E + GL_DRAW_BUFFER10* = 0x0000882F + GL_DRAW_BUFFER11* = 0x00008830 + GL_DRAW_BUFFER12* = 0x00008831 + GL_DRAW_BUFFER13* = 0x00008832 + GL_DRAW_BUFFER14* = 0x00008833 + GL_DRAW_BUFFER15* = 0x00008834 + GL_BLEND_EQUATION_ALPHA* = 0x0000883D + GL_POINT_SPRITE* = 0x00008861 + GL_COORD_REPLACE* = 0x00008862 + GL_MAX_VERTEX_ATTRIBS* = 0x00008869 + GL_VERTEX_ATTRIB_ARRAY_NORMALIZED* = 0x0000886A + GL_MAX_TEXTURE_COORDS* = 0x00008871 + GL_MAX_TEXTURE_IMAGE_UNITS* = 0x00008872 + GL_FRAGMENT_SHADER* = 0x00008B30 + GL_VERTEX_SHADER* = 0x00008B31 + GL_MAX_FRAGMENT_UNIFORM_COMPONENTS* = 0x00008B49 + GL_MAX_VERTEX_UNIFORM_COMPONENTS* = 0x00008B4A + GL_MAX_VARYING_FLOATS* = 0x00008B4B + GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS* = 0x00008B4C + GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS* = 0x00008B4D + GL_SHADER_TYPE* = 0x00008B4F + GL_FLOAT_VEC2* = 0x00008B50 + GL_FLOAT_VEC3* = 0x00008B51 + GL_FLOAT_VEC4* = 0x00008B52 + GL_INT_VEC2* = 0x00008B53 + GL_INT_VEC3* = 0x00008B54 + GL_INT_VEC4* = 0x00008B55 + GL_BOOL* = 0x00008B56 + GL_BOOL_VEC2* = 0x00008B57 + GL_BOOL_VEC3* = 0x00008B58 + GL_BOOL_VEC4* = 0x00008B59 + GL_FLOAT_MAT2* = 0x00008B5A + GL_FLOAT_MAT3* = 0x00008B5B + GL_FLOAT_MAT4* = 0x00008B5C + GL_SAMPLER_1D* = 0x00008B5D + GL_SAMPLER_2D* = 0x00008B5E + GL_SAMPLER_3D* = 0x00008B5F + GL_SAMPLER_CUBE* = 0x00008B60 + GL_SAMPLER_1D_SHADOW* = 0x00008B61 + GL_SAMPLER_2D_SHADOW* = 0x00008B62 + GL_DELETE_STATUS* = 0x00008B80 + GL_COMPILE_STATUS* = 0x00008B81 + GL_LINK_STATUS* = 0x00008B82 + GL_VALIDATE_STATUS* = 0x00008B83 + GL_INFO_LOG_LENGTH* = 0x00008B84 + GL_ATTACHED_SHADERS* = 0x00008B85 + GL_ACTIVE_UNIFORMS* = 0x00008B86 + GL_ACTIVE_UNIFORM_MAX_LENGTH* = 0x00008B87 + GL_SHADER_SOURCE_LENGTH* = 0x00008B88 + GL_ACTIVE_ATTRIBUTES* = 0x00008B89 + GL_ACTIVE_ATTRIBUTE_MAX_LENGTH* = 0x00008B8A + GL_FRAGMENT_SHADER_DERIVATIVE_HINT* = 0x00008B8B + GL_SHADING_LANGUAGE_VERSION* = 0x00008B8C + GL_CURRENT_PROGRAM* = 0x00008B8D + GL_POINT_SPRITE_COORD_ORIGIN* = 0x00008CA0 + GL_LOWER_LEFT* = 0x00008CA1 + GL_UPPER_LEFT* = 0x00008CA2 + GL_STENCIL_BACK_REF* = 0x00008CA3 + GL_STENCIL_BACK_VALUE_MASK* = 0x00008CA4 + GL_STENCIL_BACK_WRITEMASK* = 0x00008CA5 + +{.pop.} diff --git a/lib/base/opengl/glext.pp b/lib/base/opengl/glext.pp new file mode 100644 index 000000000..4c9fc2119 --- /dev/null +++ b/lib/base/opengl/glext.pp @@ -0,0 +1,3857 @@ +{ + + Adaption of the delphi3d.net OpenGL units to FreePascal + Sebastian Guenther (sg@freepascal.org) in 2002 + These units are free to use +} +(* +{$MACRO ON} +{$MODE Delphi} +{$IFDEF Windows} + {$DEFINE extdecl:=stdcall } +{$ELSE} + {$DEFINE extdecl:=cdecl } +{$ENDIF} *) + +unit GLext; + +(************************************************** + * OpenGL extension loading library * + * Generated by MetaGLext, written by Tom Nuydens * + * (tom@delphi3d.net -- http://www.delphi3d.net * + **************************************************) + +//*** Generated on 10/11/2002 + +interface + +uses + GL; + +// Test if the given extension name is present in the given extension string. +function glext_ExtensionSupported(const extension: String; const searchIn: String): Boolean; + +// Load the extension with the given name. +function glext_LoadExtension(ext: String): Boolean; + +type + GLcharARB = Char; + TGLcharARB = GLcharARB; + PGLcharARB = ^GLcharARB; + + GLhandleARB = Cardinal; + TGLhandleARB = GLhandleARB; + PGLhandleARB = ^GLhandleARB; + + GLintptr = Integer; + TGLintptr = GLintptr; + PGLintptr = ^GLintptr; + + GLsizeiptr = Integer; + TGLsizeiptr = GLsizeiptr; + PGLsizeiptr = ^GLsizeiptr; + + GLchar = Char; + TGLchar = GLchar; + PGLchar = Pchar; + +//***** GL_version_1_2 *****// +const + GL_UNSIGNED_BYTE_3_3_2 = $8032; + GL_UNSIGNED_SHORT_4_4_4_4 = $8033; + GL_UNSIGNED_SHORT_5_5_5_1 = $8034; + GL_UNSIGNED_INT_8_8_8_8 = $8035; + GL_UNSIGNED_INT_10_10_10_2 = $8036; + GL_RESCALE_NORMAL = $803A; + GL_UNSIGNED_BYTE_2_3_3_REV = $8362; + GL_UNSIGNED_SHORT_5_6_5 = $8363; + GL_UNSIGNED_SHORT_5_6_5_REV = $8364; + GL_UNSIGNED_SHORT_4_4_4_4_REV = $8365; + GL_UNSIGNED_SHORT_1_5_5_5_REV = $8366; + GL_UNSIGNED_INT_8_8_8_8_REV = $8367; + GL_UNSIGNED_INT_2_10_10_10_REV = $8368; + GL_BGR = $80E0; + GL_BGRA = $80E1; + GL_MAX_ELEMENTS_VERTICES = $80E8; + GL_MAX_ELEMENTS_INDICES = $80E9; + GL_CLAMP_TO_EDGE = $812F; + GL_TEXTURE_MIN_LOD = $813A; + GL_TEXTURE_MAX_LOD = $813B; + GL_TEXTURE_BASE_LEVEL = $813C; + GL_TEXTURE_MAX_LEVEL = $813D; + GL_LIGHT_MODEL_COLOR_CONTROL = $81F8; + GL_SINGLE_COLOR = $81F9; + GL_SEPARATE_SPECULAR_COLOR = $81FA; + GL_SMOOTH_POINT_SIZE_RANGE = $0B12; + GL_SMOOTH_POINT_SIZE_GRANULARITY = $0B13; + GL_SMOOTH_LINE_WIDTH_RANGE = $0B22; + GL_SMOOTH_LINE_WIDTH_GRANULARITY = $0B23; + GL_ALIASED_POINT_SIZE_RANGE = $846D; + GL_ALIASED_LINE_WIDTH_RANGE = $846E; + GL_PACK_SKIP_IMAGES = $806B; + GL_PACK_IMAGE_HEIGHT = $806C; + GL_UNPACK_SKIP_IMAGES = $806D; + GL_UNPACK_IMAGE_HEIGHT = $806E; + GL_TEXTURE_3D = $806F; + GL_PROXY_TEXTURE_3D = $8070; + GL_TEXTURE_DEPTH = $8071; + GL_TEXTURE_WRAP_R = $8072; + GL_MAX_3D_TEXTURE_SIZE = $8073; + + procedure glBlendColor(red: GLclampf; green: GLclampf; blue: GLclampf; alpha: GLclampf); external dllname; + procedure glBlendEquation(mode: GLenum); external dllname; + procedure glDrawRangeElements(mode: GLenum; start: GLuint; theend: GLuint; count: GLsizei; thetype: GLenum; const indices: PGLvoid); external dllname; + procedure glColorTable(target: GLenum; internalformat: GLenum; width: GLsizei; format: GLenum; thetype: GLenum; const table: PGLvoid); external dllname; + procedure glColorTableParameterfv(target: GLenum; pname: GLenum; const params: PGLfloat); external dllname; + procedure glColorTableParameteriv(target: GLenum; pname: GLenum; const params: PGLint); external dllname; + procedure glCopyColorTable(target: GLenum; internalformat: GLenum; x: GLint; y: GLint; width: GLsizei); external dllname; + procedure glGetColorTable(target: GLenum; format: GLenum; thetype: GLenum; table: PGLvoid); external dllname; + procedure glGetColorTableParameterfv(target: GLenum; pname: GLenum; params: PGLfloat); external dllname; + procedure glGetColorTableParameteriv(target: GLenum; pname: GLenum; params: PGLint); external dllname; + procedure glColorSubTable(target: GLenum; start: GLsizei; count: GLsizei; format: GLenum; thetype: GLenum; const data: PGLvoid); external dllname; + procedure glCopyColorSubTable(target: GLenum; start: GLsizei; x: GLint; y: GLint; width: GLsizei); external dllname; + procedure glConvolutionFilter1D(target: GLenum; internalformat: GLenum; width: GLsizei; format: GLenum; thetype: GLenum; const image: PGLvoid); external dllname; + procedure glConvolutionFilter2D(target: GLenum; internalformat: GLenum; width: GLsizei; height: GLsizei; format: GLenum; thetype: GLenum; const image: PGLvoid); external dllname; + procedure glConvolutionParameterf(target: GLenum; pname: GLenum; params: GLfloat); external dllname; + procedure glConvolutionParameterfv(target: GLenum; pname: GLenum; const params: PGLfloat); external dllname; + procedure glConvolutionParameteri(target: GLenum; pname: GLenum; params: GLint); external dllname; + procedure glConvolutionParameteriv(target: GLenum; pname: GLenum; const params: PGLint); external dllname; + procedure glCopyConvolutionFilter1D(target: GLenum; internalformat: GLenum; x: GLint; y: GLint; width: GLsizei); external dllname; + procedure glCopyConvolutionFilter2D(target: GLenum; internalformat: GLenum; x: GLint; y: GLint; width: GLsizei; height: GLsizei); external dllname; + procedure glGetConvolutionFilter(target: GLenum; format: GLenum; thetype: GLenum; image: PGLvoid); external dllname; + procedure glGetConvolutionParameterfv(target: GLenum; pname: GLenum; params: PGLfloat); external dllname; + procedure glGetConvolutionParameteriv(target: GLenum; pname: GLenum; params: PGLint); external dllname; + procedure glGetSeparableFilter(target: GLenum; format: GLenum; thetype: GLenum; row: PGLvoid; column: PGLvoid; span: PGLvoid); external dllname; + procedure glSeparableFilter2D(target: GLenum; internalformat: GLenum; width: GLsizei; height: GLsizei; format: GLenum; thetype: GLenum; const row: PGLvoid; const column: PGLvoid); external dllname; + procedure glGetHistogram(target: GLenum; reset: GLboolean; format: GLenum; thetype: GLenum; values: PGLvoid); external dllname; + procedure glGetHistogramParameterfv(target: GLenum; pname: GLenum; params: PGLfloat); external dllname; + procedure glGetHistogramParameteriv(target: GLenum; pname: GLenum; params: PGLint); external dllname; + procedure glGetMinmax(target: GLenum; reset: GLboolean; format: GLenum; thetype: GLenum; values: PGLvoid); external dllname; + procedure glGetMinmaxParameterfv(target: GLenum; pname: GLenum; params: PGLfloat); external dllname; + procedure glGetMinmaxParameteriv(target: GLenum; pname: GLenum; params: PGLint); external dllname; + procedure glHistogram(target: GLenum; width: GLsizei; internalformat: GLenum; sink: GLboolean); external dllname; + procedure glMinmax(target: GLenum; internalformat: GLenum; sink: GLboolean); external dllname; + procedure glResetHistogram(target: GLenum); external dllname; + procedure glResetMinmax(target: GLenum); external dllname; + procedure glTexImage3D(target: GLenum; level: GLint; internalformat: GLint; width: GLsizei; height: GLsizei; depth: GLsizei; border: GLint; format: GLenum; thetype: GLenum; const pixels: PGLvoid); external dllname; + procedure glTexSubImage3D(target: GLenum; level: GLint; xoffset: GLint; yoffset: GLint; zoffset: GLint; width: GLsizei; height: GLsizei; depth: GLsizei; format: GLenum; thetype: GLenum; const pixels: PGLvoid); external dllname; + procedure glCopyTexSubImage3D(target: GLenum; level: GLint; xoffset: GLint; yoffset: GLint; zoffset: GLint; x: GLint; y: GLint; width: GLsizei; height: GLsizei); external dllname; + + +//***** GL_ARB_imaging *****// +const + GL_CONSTANT_COLOR = $8001; + GL_ONE_MINUS_CONSTANT_COLOR = $8002; + GL_CONSTANT_ALPHA = $8003; + GL_ONE_MINUS_CONSTANT_ALPHA = $8004; + GL_BLEND_COLOR = $8005; + GL_FUNC_ADD = $8006; + GL_MIN = $8007; + GL_MAX = $8008; + GL_BLEND_EQUATION = $8009; + GL_FUNC_SUBTRACT = $800A; + GL_FUNC_REVERSE_SUBTRACT = $800B; + GL_CONVOLUTION_1D = $8010; + GL_CONVOLUTION_2D = $8011; + GL_SEPARABLE_2D = $8012; + GL_CONVOLUTION_BORDER_MODE = $8013; + GL_CONVOLUTION_FILTER_SCALE = $8014; + GL_CONVOLUTION_FILTER_BIAS = $8015; + GL_REDUCE = $8016; + GL_CONVOLUTION_FORMAT = $8017; + GL_CONVOLUTION_WIDTH = $8018; + GL_CONVOLUTION_HEIGHT = $8019; + GL_MAX_CONVOLUTION_WIDTH = $801A; + GL_MAX_CONVOLUTION_HEIGHT = $801B; + GL_POST_CONVOLUTION_RED_SCALE = $801C; + GL_POST_CONVOLUTION_GREEN_SCALE = $801D; + GL_POST_CONVOLUTION_BLUE_SCALE = $801E; + GL_POST_CONVOLUTION_ALPHA_SCALE = $801F; + GL_POST_CONVOLUTION_RED_BIAS = $8020; + GL_POST_CONVOLUTION_GREEN_BIAS = $8021; + GL_POST_CONVOLUTION_BLUE_BIAS = $8022; + GL_POST_CONVOLUTION_ALPHA_BIAS = $8023; + GL_HISTOGRAM = $8024; + GL_PROXY_HISTOGRAM = $8025; + GL_HISTOGRAM_WIDTH = $8026; + GL_HISTOGRAM_FORMAT = $8027; + GL_HISTOGRAM_RED_SIZE = $8028; + GL_HISTOGRAM_GREEN_SIZE = $8029; + GL_HISTOGRAM_BLUE_SIZE = $802A; + GL_HISTOGRAM_ALPHA_SIZE = $802B; + GL_HISTOGRAM_LUMINANCE_SIZE = $802C; + GL_HISTOGRAM_SINK = $802D; + GL_MINMAX = $802E; + GL_MINMAX_FORMAT = $802F; + GL_MINMAX_SINK = $8030; + GL_TABLE_TOO_LARGE = $8031; + GL_COLOR_MATRIX = $80B1; + GL_COLOR_MATRIX_STACK_DEPTH = $80B2; + GL_MAX_COLOR_MATRIX_STACK_DEPTH = $80B3; + GL_POST_COLOR_MATRIX_RED_SCALE = $80B4; + GL_POST_COLOR_MATRIX_GREEN_SCALE = $80B5; + GL_POST_COLOR_MATRIX_BLUE_SCALE = $80B6; + GL_POST_COLOR_MATRIX_ALPHA_SCALE = $80B7; + GL_POST_COLOR_MATRIX_RED_BIAS = $80B8; + GL_POST_COLOR_MATRIX_GREEN_BIAS = $80B9; + GL_POST_COLOR_MATRIX_BLUE_BIAS = $80BA; + GL_POST_COLOR_MATIX_ALPHA_BIAS = $80BB; + GL_COLOR_TABLE = $80D0; + GL_POST_CONVOLUTION_COLOR_TABLE = $80D1; + GL_POST_COLOR_MATRIX_COLOR_TABLE = $80D2; + GL_PROXY_COLOR_TABLE = $80D3; + GL_PROXY_POST_CONVOLUTION_COLOR_TABLE = $80D4; + GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE = $80D5; + GL_COLOR_TABLE_SCALE = $80D6; + GL_COLOR_TABLE_BIAS = $80D7; + GL_COLOR_TABLE_FORMAT = $80D8; + GL_COLOR_TABLE_WIDTH = $80D9; + GL_COLOR_TABLE_RED_SIZE = $80DA; + GL_COLOR_TABLE_GREEN_SIZE = $80DB; + GL_COLOR_TABLE_BLUE_SIZE = $80DC; + GL_COLOR_TABLE_ALPHA_SIZE = $80DD; + GL_COLOR_TABLE_LUMINANCE_SIZE = $80DE; + GL_COLOR_TABLE_INTENSITY_SIZE = $80DF; + GL_IGNORE_BORDER = $8150; + GL_CONSTANT_BORDER = $8151; + GL_WRAP_BORDER = $8152; + GL_REPLICATE_BORDER = $8153; + GL_CONVOLUTION_BORDER_COLOR = $8154; + +function Load_GL_ARB_imaging: Boolean; + +//***** GL_version_1_3 *****// +const + GL_TEXTURE0 = $84C0; + GL_TEXTURE1 = $84C1; + GL_TEXTURE2 = $84C2; + GL_TEXTURE3 = $84C3; + GL_TEXTURE4 = $84C4; + GL_TEXTURE5 = $84C5; + GL_TEXTURE6 = $84C6; + GL_TEXTURE7 = $84C7; + GL_TEXTURE8 = $84C8; + GL_TEXTURE9 = $84C9; + GL_TEXTURE10 = $84CA; + GL_TEXTURE11 = $84CB; + GL_TEXTURE12 = $84CC; + GL_TEXTURE13 = $84CD; + GL_TEXTURE14 = $84CE; + GL_TEXTURE15 = $84CF; + GL_TEXTURE16 = $84D0; + GL_TEXTURE17 = $84D1; + GL_TEXTURE18 = $84D2; + GL_TEXTURE19 = $84D3; + GL_TEXTURE20 = $84D4; + GL_TEXTURE21 = $84D5; + GL_TEXTURE22 = $84D6; + GL_TEXTURE23 = $84D7; + GL_TEXTURE24 = $84D8; + GL_TEXTURE25 = $84D9; + GL_TEXTURE26 = $84DA; + GL_TEXTURE27 = $84DB; + GL_TEXTURE28 = $84DC; + GL_TEXTURE29 = $84DD; + GL_TEXTURE30 = $84DE; + GL_TEXTURE31 = $84DF; + GL_ACTIVE_TEXTURE = $84E0; + GL_CLIENT_ACTIVE_TEXTURE = $84E1; + GL_MAX_TEXTURE_UNITS = $84E2; + GL_TRANSPOSE_MODELVIEW_MATRIX = $84E3; + GL_TRANSPOSE_PROJECTION_MATRIX = $84E4; + GL_TRANSPOSE_TEXTURE_MATRIX = $84E5; + GL_TRANSPOSE_COLOR_MATRIX = $84E6; + GL_MULTISAMPLE = $809D; + GL_SAMPLE_ALPHA_TO_COVERAGE = $809E; + GL_SAMPLE_ALPHA_TO_ONE = $809F; + GL_SAMPLE_COVERAGE = $80A0; + GL_SAMPLE_BUFFERS = $80A8; + GL_SAMPLES = $80A9; + GL_SAMPLE_COVERAGE_VALUE = $80AA; + GL_SAMPLE_COVERAGE_INVERT = $80AB; + GL_MULTISAMPLE_BIT = $20000000; + GL_NORMAL_MAP = $8511; + GL_REFLECTION_MAP = $8512; + GL_TEXTURE_CUBE_MAP = $8513; + GL_TEXTURE_BINDING_CUBE_MAP = $8514; + GL_TEXTURE_CUBE_MAP_POSITIVE_X = $8515; + GL_TEXTURE_CUBE_MAP_NEGATIVE_X = $8516; + GL_TEXTURE_CUBE_MAP_POSITIVE_Y = $8517; + GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = $8518; + GL_TEXTURE_CUBE_MAP_POSITIVE_Z = $8519; + GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = $851A; + GL_PROXY_TEXTURE_CUBE_MAP = $851B; + GL_MAX_CUBE_MAP_TEXTURE_SIZE = $851C; + GL_COMPRESSED_ALPHA = $84E9; + GL_COMPRESSED_LUMINANCE = $84EA; + GL_COMPRESSED_LUMINANCE_ALPHA = $84EB; + GL_COMPRESSED_INTENSITY = $84EC; + GL_COMPRESSED_RGB = $84ED; + GL_COMPRESSED_RGBA = $84EE; + GL_TEXTURE_COMPRESSION_HINT = $84EF; + GL_TEXTURE_COMPRESSED_IMAGE_SIZE = $86A0; + GL_TEXTURE_COMPRESSED = $86A1; + GL_NUM_COMPRESSED_TEXTURE_FORMATS = $86A2; + GL_COMPRESSED_TEXTURE_FORMATS = $86A3; + GL_CLAMP_TO_BORDER = $812D; + GL_CLAMP_TO_BORDER_SGIS = $812D; + GL_COMBINE = $8570; + GL_COMBINE_RGB = $8571; + GL_COMBINE_ALPHA = $8572; + GL_SOURCE0_RGB = $8580; + GL_SOURCE1_RGB = $8581; + GL_SOURCE2_RGB = $8582; + GL_SOURCE0_ALPHA = $8588; + GL_SOURCE1_ALPHA = $8589; + GL_SOURCE2_ALPHA = $858A; + GL_OPERAND0_RGB = $8590; + GL_OPERAND1_RGB = $8591; + GL_OPERAND2_RGB = $8592; + GL_OPERAND0_ALPHA = $8598; + GL_OPERAND1_ALPHA = $8599; + GL_OPERAND2_ALPHA = $859A; + GL_RGB_SCALE = $8573; + GL_ADD_SIGNED = $8574; + GL_INTERPOLATE = $8575; + GL_SUBTRACT = $84E7; + GL_CONSTANT = $8576; + GL_PRIMARY_COLOR = $8577; + GL_PREVIOUS = $8578; + GL_DOT3_RGB = $86AE; + GL_DOT3_RGBA = $86AF; + + procedure glActiveTexture(texture: GLenum); external dllname; + procedure glClientActiveTexture(texture: GLenum); external dllname; + procedure glMultiTexCoord1d(target: GLenum; s: GLdouble); external dllname; + procedure glMultiTexCoord1dv(target: GLenum; const v: PGLdouble); external dllname; + procedure glMultiTexCoord1f(target: GLenum; s: GLfloat); external dllname; + procedure glMultiTexCoord1fv(target: GLenum; const v: PGLfloat); external dllname; + procedure glMultiTexCoord1i(target: GLenum; s: GLint); external dllname; + procedure glMultiTexCoord1iv(target: GLenum; const v: PGLint); external dllname; + procedure glMultiTexCoord1s(target: GLenum; s: GLshort); external dllname; + procedure glMultiTexCoord1sv(target: GLenum; const v: PGLshort); external dllname; + procedure glMultiTexCoord2d(target: GLenum; s: GLdouble; t: GLdouble); external dllname; + procedure glMultiTexCoord2dv(target: GLenum; const v: PGLdouble); external dllname; + procedure glMultiTexCoord2f(target: GLenum; s: GLfloat; t: GLfloat); external dllname; + procedure glMultiTexCoord2fv(target: GLenum; const v: PGLfloat); external dllname; + procedure glMultiTexCoord2i(target: GLenum; s: GLint; t: GLint); external dllname; + procedure glMultiTexCoord2iv(target: GLenum; const v: PGLint); external dllname; + procedure glMultiTexCoord2s(target: GLenum; s: GLshort; t: GLshort); external dllname; + procedure glMultiTexCoord2sv(target: GLenum; const v: PGLshort); external dllname; + procedure glMultiTexCoord3d(target: GLenum; s: GLdouble; t: GLdouble; r: GLdouble); external dllname; + procedure glMultiTexCoord3dv(target: GLenum; const v: PGLdouble); external dllname; + procedure glMultiTexCoord3f(target: GLenum; s: GLfloat; t: GLfloat; r: GLfloat); external dllname; + procedure glMultiTexCoord3fv(target: GLenum; const v: PGLfloat); external dllname; + procedure glMultiTexCoord3i(target: GLenum; s: GLint; t: GLint; r: GLint); external dllname; + procedure glMultiTexCoord3iv(target: GLenum; const v: PGLint); external dllname; + procedure glMultiTexCoord3s(target: GLenum; s: GLshort; t: GLshort; r: GLshort); external dllname; + procedure glMultiTexCoord3sv(target: GLenum; const v: PGLshort); external dllname; + procedure glMultiTexCoord4d(target: GLenum; s: GLdouble; t: GLdouble; r: GLdouble; q: GLdouble); external dllname; + procedure glMultiTexCoord4dv(target: GLenum; const v: PGLdouble); external dllname; + procedure glMultiTexCoord4f(target: GLenum; s: GLfloat; t: GLfloat; r: GLfloat; q: GLfloat); external dllname; + procedure glMultiTexCoord4fv(target: GLenum; const v: PGLfloat); external dllname; + procedure glMultiTexCoord4i(target: GLenum; s: GLint; t: GLint; r: GLint; q: GLint); external dllname; + procedure glMultiTexCoord4iv(target: GLenum; const v: PGLint); external dllname; + procedure glMultiTexCoord4s(target: GLenum; s: GLshort; t: GLshort; r: GLshort; q: GLshort); external dllname; + procedure glMultiTexCoord4sv(target: GLenum; const v: PGLshort); external dllname; + procedure glLoadTransposeMatrixf(const m: PGLfloat); external dllname; + procedure glLoadTransposeMatrixd(const m: PGLdouble); external dllname; + procedure glMultTransposeMatrixf(const m: PGLfloat); external dllname; + procedure glMultTransposeMatrixd(const m: PGLdouble); external dllname; + procedure glSampleCoverage(value: GLclampf; invert: GLboolean); external dllname; + procedure glCompressedTexImage3D(target: GLenum; level: GLint; internalformat: GLenum; width: GLsizei; height: GLsizei; depth: GLsizei; border: GLint; imageSize: GLsizei; const data: PGLvoid); external dllname; + procedure glCompressedTexImage2D(target: GLenum; level: GLint; internalformat: GLenum; width: GLsizei; height: GLsizei; border: GLint; imageSize: GLsizei; const data: PGLvoid); external dllname; + procedure glCompressedTexImage1D(target: GLenum; level: GLint; internalformat: GLenum; width: GLsizei; border: GLint; imageSize: GLsizei; const data: PGLvoid); external dllname; + procedure glCompressedTexSubImage3D(target: GLenum; level: GLint; xoffset: GLint; yoffset: GLint; zoffset: GLint; width: GLsizei; height: GLsizei; depth: GLsizei; format: GLenum; imageSize: GLsizei; const data: PGLvoid); external dllname; + procedure glCompressedTexSubImage2D(target: GLenum; level: GLint; xoffset: GLint; yoffset: GLint; width: GLsizei; height: GLsizei; format: GLenum; imageSize: GLsizei; const data: PGLvoid); external dllname; + procedure glCompressedTexSubImage1D(target: GLenum; level: GLint; xoffset: GLint; width: GLsizei; format: GLenum; imageSize: GLsizei; const data: PGLvoid); external dllname; + procedure glGetCompressedTexImage(target: GLenum; level: GLint; img: PGLvoid); external dllname; + +function Load_GL_version_1_3: Boolean; + +//***** GL_ARB_multitexture *****// +const + GL_TEXTURE0_ARB = $84C0; + GL_TEXTURE1_ARB = $84C1; + GL_TEXTURE2_ARB = $84C2; + GL_TEXTURE3_ARB = $84C3; + GL_TEXTURE4_ARB = $84C4; + GL_TEXTURE5_ARB = $84C5; + GL_TEXTURE6_ARB = $84C6; + GL_TEXTURE7_ARB = $84C7; + GL_TEXTURE8_ARB = $84C8; + GL_TEXTURE9_ARB = $84C9; + GL_TEXTURE10_ARB = $84CA; + GL_TEXTURE11_ARB = $84CB; + GL_TEXTURE12_ARB = $84CC; + GL_TEXTURE13_ARB = $84CD; + GL_TEXTURE14_ARB = $84CE; + GL_TEXTURE15_ARB = $84CF; + GL_TEXTURE16_ARB = $84D0; + GL_TEXTURE17_ARB = $84D1; + GL_TEXTURE18_ARB = $84D2; + GL_TEXTURE19_ARB = $84D3; + GL_TEXTURE20_ARB = $84D4; + GL_TEXTURE21_ARB = $84D5; + GL_TEXTURE22_ARB = $84D6; + GL_TEXTURE23_ARB = $84D7; + GL_TEXTURE24_ARB = $84D8; + GL_TEXTURE25_ARB = $84D9; + GL_TEXTURE26_ARB = $84DA; + GL_TEXTURE27_ARB = $84DB; + GL_TEXTURE28_ARB = $84DC; + GL_TEXTURE29_ARB = $84DD; + GL_TEXTURE30_ARB = $84DE; + GL_TEXTURE31_ARB = $84DF; + GL_ACTIVE_TEXTURE_ARB = $84E0; + GL_CLIENT_ACTIVE_TEXTURE_ARB = $84E1; + GL_MAX_TEXTURE_UNITS_ARB = $84E2; + + procedure glActiveTextureARB(texture: GLenum); external dllname; + procedure glClientActiveTextureARB(texture: GLenum); external dllname; + procedure glMultiTexCoord1dARB(target: GLenum; s: GLdouble); external dllname; + procedure glMultiTexCoord1dvARB(target: GLenum; const v: PGLdouble); external dllname; + procedure glMultiTexCoord1fARB(target: GLenum; s: GLfloat); external dllname; + procedure glMultiTexCoord1fvARB(target: GLenum; const v: PGLfloat); external dllname; + procedure glMultiTexCoord1iARB(target: GLenum; s: GLint); external dllname; + procedure glMultiTexCoord1ivARB(target: GLenum; const v: PGLint); external dllname; + procedure glMultiTexCoord1sARB(target: GLenum; s: GLshort); external dllname; + procedure glMultiTexCoord1svARB(target: GLenum; const v: PGLshort); external dllname; + procedure glMultiTexCoord2dARB(target: GLenum; s: GLdouble; t: GLdouble); external dllname; + procedure glMultiTexCoord2dvARB(target: GLenum; const v: PGLdouble); external dllname; + procedure glMultiTexCoord2fARB(target: GLenum; s: GLfloat; t: GLfloat); external dllname; + procedure glMultiTexCoord2fvARB(target: GLenum; const v: PGLfloat); external dllname; + procedure glMultiTexCoord2iARB(target: GLenum; s: GLint; t: GLint); external dllname; + procedure glMultiTexCoord2ivARB(target: GLenum; const v: PGLint); external dllname; + procedure glMultiTexCoord2sARB(target: GLenum; s: GLshort; t: GLshort); external dllname; + procedure glMultiTexCoord2svARB(target: GLenum; const v: PGLshort); external dllname; + procedure glMultiTexCoord3dARB(target: GLenum; s: GLdouble; t: GLdouble; r: GLdouble); external dllname; + procedure glMultiTexCoord3dvARB(target: GLenum; const v: PGLdouble); external dllname; + procedure glMultiTexCoord3fARB(target: GLenum; s: GLfloat; t: GLfloat; r: GLfloat); external dllname; + procedure glMultiTexCoord3fvARB(target: GLenum; const v: PGLfloat); external dllname; + procedure glMultiTexCoord3iARB(target: GLenum; s: GLint; t: GLint; r: GLint); external dllname; + procedure glMultiTexCoord3ivARB(target: GLenum; const v: PGLint); external dllname; + procedure glMultiTexCoord3sARB(target: GLenum; s: GLshort; t: GLshort; r: GLshort); external dllname; + procedure glMultiTexCoord3svARB(target: GLenum; const v: PGLshort); external dllname; + procedure glMultiTexCoord4dARB(target: GLenum; s: GLdouble; t: GLdouble; r: GLdouble; q: GLdouble); external dllname; + procedure glMultiTexCoord4dvARB(target: GLenum; const v: PGLdouble); external dllname; + procedure glMultiTexCoord4fARB(target: GLenum; s: GLfloat; t: GLfloat; r: GLfloat; q: GLfloat); external dllname; + procedure glMultiTexCoord4fvARB(target: GLenum; const v: PGLfloat); external dllname; + procedure glMultiTexCoord4iARB(target: GLenum; s: GLint; t: GLint; r: GLint; q: GLint); external dllname; + procedure glMultiTexCoord4ivARB(target: GLenum; const v: PGLint); external dllname; + procedure glMultiTexCoord4sARB(target: GLenum; s: GLshort; t: GLshort; r: GLshort; q: GLshort); external dllname; + procedure glMultiTexCoord4svARB(target: GLenum; const v: PGLshort); external dllname; + +function Load_GL_ARB_multitexture: Boolean; + +//***** GL_ARB_transpose_matrix *****// +const + GL_TRANSPOSE_MODELVIEW_MATRIX_ARB = $84E3; + GL_TRANSPOSE_PROJECTION_MATRIX_ARB = $84E4; + GL_TRANSPOSE_TEXTURE_MATRIX_ARB = $84E5; + GL_TRANSPOSE_COLOR_MATRIX_ARB = $84E6; + + procedure glLoadTransposeMatrixfARB(m: PGLfloat); external dllname; + procedure glLoadTransposeMatrixdARB(m: PGLdouble); external dllname; + procedure glMultTransposeMatrixfARB(m: PGLfloat); external dllname; + procedure glMultTransposeMatrixdARB(m: PGLdouble); external dllname; + +function Load_GL_ARB_transpose_matrix: Boolean; + +//***** GL_ARB_multisample *****// +const + WGL_SAMPLE_BUFFERS_ARB = $2041; + WGL_SAMPLES_ARB = $2042; + GL_MULTISAMPLE_ARB = $809D; + GL_SAMPLE_ALPHA_TO_COVERAGE_ARB = $809E; + GL_SAMPLE_ALPHA_TO_ONE_ARB = $809F; + GL_SAMPLE_COVERAGE_ARB = $80A0; + GL_MULTISAMPLE_BIT_ARB = $20000000; + GL_SAMPLE_BUFFERS_ARB = $80A8; + GL_SAMPLES_ARB = $80A9; + GL_SAMPLE_COVERAGE_VALUE_ARB = $80AA; + GL_SAMPLE_COVERAGE_INVERT_ARB = $80AB; + +procedure glSampleCoverageARB(value: GLclampf; invert: GLboolean); external dllname; + +function Load_GL_ARB_multisample: Boolean; + +//***** GL_ARB_texture_env_add *****// + +function Load_GL_ARB_texture_env_add: Boolean; + + +//***** GL_ARB_texture_cube_map *****// +const + GL_NORMAL_MAP_ARB = $8511; + GL_REFLECTION_MAP_ARB = $8512; + GL_TEXTURE_CUBE_MAP_ARB = $8513; + GL_TEXTURE_BINDING_CUBE_MAP_ARB = $8514; + GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB = $8515; + GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB = $8516; + GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB = $8517; + GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB = $8518; + GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB = $8519; + GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB = $851A; + GL_PROXY_TEXTURE_CUBE_MAP_ARB = $851B; + GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB = $851C; + +function Load_GL_ARB_texture_cube_map: Boolean; + +//***** GL_ARB_depth_texture *****// +const + GL_DEPTH_COMPONENT16_ARB = $81A5; + GL_DEPTH_COMPONENT24_ARB = $81A6; + GL_DEPTH_COMPONENT32_ARB = $81A7; + GL_TEXTURE_DEPTH_SIZE_ARB = $884A; + GL_DEPTH_TEXTURE_MODE_ARB = $884B; + +function Load_GL_ARB_depth_texture: Boolean; + +//***** GL_ARB_point_parameters *****// +const + GL_POINT_SIZE_MIN_ARB = $8126; + GL_POINT_SIZE_MAX_ARB = $8127; + GL_POINT_FADE_THRESHOLD_SIZE_ARB = $8128; + GL_POINT_DISTANCE_ATTENUATION_ARB = $8129; + + procedure glPointParameterfARB(pname: GLenum; param: GLfloat); external dllname; + procedure glPointParameterfvARB(pname: GLenum; params: PGLfloat); external dllname; + +function Load_GL_ARB_point_parameters: Boolean; + +//***** GL_ARB_shadow *****// +const + GL_TEXTURE_COMPARE_MODE_ARB = $884C; + GL_TEXTURE_COMPARE_FUNC_ARB = $884D; + GL_COMPARE_R_TO_TEXTURE_ARB = $884E; + +function Load_GL_ARB_shadow: Boolean; + +//***** GL_ARB_shadow_ambient *****// +const + GL_TEXTURE_COMPARE_FAIL_VALUE_ARB = $80BF; + +function Load_GL_ARB_shadow_ambient: Boolean; + +//***** GL_ARB_texture_border_clamp *****// +const + GL_CLAMP_TO_BORDER_ARB = $812D; + +function Load_GL_ARB_texture_border_clamp: Boolean; + +//***** GL_ARB_texture_compression *****// +const + GL_COMPRESSED_ALPHA_ARB = $84E9; + GL_COMPRESSED_LUMINANCE_ARB = $84EA; + GL_COMPRESSED_LUMINANCE_ALPHA_ARB = $84EB; + GL_COMPRESSED_INTENSITY_ARB = $84EC; + GL_COMPRESSED_RGB_ARB = $84ED; + GL_COMPRESSED_RGBA_ARB = $84EE; + GL_TEXTURE_COMPRESSION_HINT_ARB = $84EF; + GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB = $86A0; + GL_TEXTURE_COMPRESSED_ARB = $86A1; + GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB = $86A2; + GL_COMPRESSED_TEXTURE_FORMATS_ARB = $86A3; + + procedure glCompressedTexImage3DARB(target: GLenum; level: GLint; internalformat: GLenum; width: GLsizei; height: GLsizei; depth: GLsizei; border: GLint; imageSize: GLsizei; const data: PGLvoid); external dllname; + procedure glCompressedTexImage2DARB(target: GLenum; level: GLint; internalformat: GLenum; width: GLsizei; height: GLsizei; border: GLint; imageSize: GLsizei; const data: PGLvoid); external dllname; + procedure glCompressedTexImage1DARB(target: GLenum; level: GLint; internalformat: GLenum; width: GLsizei; border: GLint; imageSize: GLsizei; const data: PGLvoid); external dllname; + procedure glCompressedTexSubImage3DARB(target: GLenum; level: GLint; xoffset: GLint; yoffset: GLint; zoffset: GLint; width: GLsizei; height: GLsizei; depth: GLsizei; format: GLenum; imageSize: GLsizei; const data: PGLvoid); external dllname; + procedure glCompressedTexSubImage2DARB(target: GLenum; level: GLint; xoffset: GLint; yoffset: GLint; width: GLsizei; height: GLsizei; format: GLenum; imageSize: GLsizei; const data: PGLvoid); external dllname; + procedure glCompressedTexSubImage1DARB(target: GLenum; level: GLint; xoffset: GLint; width: GLsizei; format: GLenum; imageSize: GLsizei; const data: PGLvoid); external dllname; + procedure glGetCompressedTexImageARB(target: GLenum; lod: GLint; img: PGLvoid); external dllname; + +function Load_GL_ARB_texture_compression: Boolean; + +//***** GL_ARB_texture_env_combine *****// +const + GL_COMBINE_ARB = $8570; + GL_COMBINE_RGB_ARB = $8571; + GL_COMBINE_ALPHA_ARB = $8572; + GL_SOURCE0_RGB_ARB = $8580; + GL_SOURCE1_RGB_ARB = $8581; + GL_SOURCE2_RGB_ARB = $8582; + GL_SOURCE0_ALPHA_ARB = $8588; + GL_SOURCE1_ALPHA_ARB = $8589; + GL_SOURCE2_ALPHA_ARB = $858A; + GL_OPERAND0_RGB_ARB = $8590; + GL_OPERAND1_RGB_ARB = $8591; + GL_OPERAND2_RGB_ARB = $8592; + GL_OPERAND0_ALPHA_ARB = $8598; + GL_OPERAND1_ALPHA_ARB = $8599; + GL_OPERAND2_ALPHA_ARB = $859A; + GL_RGB_SCALE_ARB = $8573; + GL_ADD_SIGNED_ARB = $8574; + GL_INTERPOLATE_ARB = $8575; + GL_SUBTRACT_ARB = $84E7; + GL_CONSTANT_ARB = $8576; + GL_PRIMARY_COLOR_ARB = $8577; + GL_PREVIOUS_ARB = $8578; + +function Load_GL_ARB_texture_env_combine: Boolean; + +//***** GL_ARB_texture_env_crossbar *****// + +function Load_GL_ARB_texture_env_crossbar: Boolean; + +//***** GL_ARB_texture_env_dot3 *****// +const + GL_DOT3_RGB_ARB = $86AE; + GL_DOT3_RGBA_ARB = $86AF; + +function Load_GL_ARB_texture_env_dot3: Boolean; + +//***** GL_ARB_texture_mirrored_repeat *****// +const + GL_MIRRORED_REPEAT_ARB = $8370; + +function Load_GL_ARB_texture_mirrored_repeat: Boolean; + +//***** GL_ARB_vertex_blend *****// +const + GL_MAX_VERTEX_UNITS_ARB = $86A4; + GL_ACTIVE_VERTEX_UNITS_ARB = $86A5; + GL_WEIGHT_SUM_UNITY_ARB = $86A6; + GL_VERTEX_BLEND_ARB = $86A7; + GL_MODELVIEW0_ARB = $1700; + GL_MODELVIEW1_ARB = $850A; + GL_MODELVIEW2_ARB = $8722; + GL_MODELVIEW3_ARB = $8723; + GL_MODELVIEW4_ARB = $8724; + GL_MODELVIEW5_ARB = $8725; + GL_MODELVIEW6_ARB = $8726; + GL_MODELVIEW7_ARB = $8727; + GL_MODELVIEW8_ARB = $8728; + GL_MODELVIEW9_ARB = $8729; + GL_MODELVIEW10_ARB = $872A; + GL_MODELVIEW11_ARB = $872B; + GL_MODELVIEW12_ARB = $872C; + GL_MODELVIEW13_ARB = $872D; + GL_MODELVIEW14_ARB = $872E; + GL_MODELVIEW15_ARB = $872F; + GL_MODELVIEW16_ARB = $8730; + GL_MODELVIEW17_ARB = $8731; + GL_MODELVIEW18_ARB = $8732; + GL_MODELVIEW19_ARB = $8733; + GL_MODELVIEW20_ARB = $8734; + GL_MODELVIEW21_ARB = $8735; + GL_MODELVIEW22_ARB = $8736; + GL_MODELVIEW23_ARB = $8737; + GL_MODELVIEW24_ARB = $8738; + GL_MODELVIEW25_ARB = $8739; + GL_MODELVIEW26_ARB = $873A; + GL_MODELVIEW27_ARB = $873B; + GL_MODELVIEW28_ARB = $873C; + GL_MODELVIEW29_ARB = $873D; + GL_MODELVIEW30_ARB = $873E; + GL_MODELVIEW31_ARB = $873F; + GL_CURRENT_WEIGHT_ARB = $86A8; + GL_WEIGHT_ARRAY_TYPE_ARB = $86A9; + GL_WEIGHT_ARRAY_STRIDE_ARB = $86AA; + GL_WEIGHT_ARRAY_SIZE_ARB = $86AB; + GL_WEIGHT_ARRAY_POINTER_ARB = $86AC; + GL_WEIGHT_ARRAY_ARB = $86AD; + + procedure glWeightbvARB(size: GLint; weights: PGLbyte); external dllname; + procedure glWeightsvARB(size: GLint; weights: PGLshort); external dllname; + procedure glWeightivARB(size: GLint; weights: PGLint); external dllname; + procedure glWeightfvARB(size: GLint; weights: PGLfloat); external dllname; + procedure glWeightdvARB(size: GLint; weights: PGLdouble); external dllname; + procedure glWeightvARB(size: GLint; weights: PGLdouble); external dllname; + procedure glWeightubvARB(size: GLint; weights: PGLubyte); external dllname; + procedure glWeightusvARB(size: GLint; weights: PGLushort); external dllname; + procedure glWeightuivARB(size: GLint; weights: PGLuint); external dllname; + procedure glWeightPointerARB(size: GLint; thetype: GLenum; stride: GLsizei; pointer: PGLvoid); external dllname; + procedure glVertexBlendARB(count: GLint); external dllname; + +function Load_GL_ARB_vertex_blend: Boolean; + +//***** GL_ARB_vertex_program *****// +const + GL_VERTEX_PROGRAM_ARB = $8620; + GL_VERTEX_PROGRAM_POINT_SIZE_ARB = $8642; + GL_VERTEX_PROGRAM_TWO_SIDE_ARB = $8643; + GL_COLOR_SUM_ARB = $8458; + GL_PROGRAM_FORMAT_ASCII_ARB = $8875; + GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB = $8622; + GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB = $8623; + GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB = $8624; + GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB = $8625; + GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB = $886A; + GL_CURRENT_VERTEX_ATTRIB_ARB = $8626; + GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB = $8645; + GL_PROGRAM_LENGTH_ARB = $8627; + GL_PROGRAM_FORMAT_ARB = $8876; + GL_PROGRAM_BINDING_ARB = $8677; + GL_PROGRAM_INSTRUCTIONS_ARB = $88A0; + GL_MAX_PROGRAM_INSTRUCTIONS_ARB = $88A1; + GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB = $88A2; + GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB = $88A3; + GL_PROGRAM_TEMPORARIES_ARB = $88A4; + GL_MAX_PROGRAM_TEMPORARIES_ARB = $88A5; + GL_PROGRAM_NATIVE_TEMPORARIES_ARB = $88A6; + GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB = $88A7; + GL_PROGRAM_PARAMETERS_ARB = $88A8; + GL_MAX_PROGRAM_PARAMETERS_ARB = $88A9; + GL_PROGRAM_NATIVE_PARAMETERS_ARB = $88AA; + GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB = $88AB; + GL_PROGRAM_ATTRIBS_ARB = $88AC; + GL_MAX_PROGRAM_ATTRIBS_ARB = $88AD; + GL_PROGRAM_NATIVE_ATTRIBS_ARB = $88AE; + GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB = $88AF; + GL_PROGRAM_ADDRESS_REGISTERS_ARB = $88B0; + GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB = $88B1; + GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB = $88B2; + GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB = $88B3; + GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB = $88B4; + GL_MAX_PROGRAM_ENV_PARAMETERS_ARB = $88B5; + GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB = $88B6; + GL_PROGRAM_STRING_ARB = $8628; + GL_PROGRAM_ERROR_POSITION_ARB = $864B; + GL_CURRENT_MATRIX_ARB = $8641; + GL_TRANSPOSE_CURRENT_MATRIX_ARB = $88B7; + GL_CURRENT_MATRIX_STACK_DEPTH_ARB = $8640; + GL_MAX_VERTEX_ATTRIBS_ARB = $8869; + GL_MAX_PROGRAM_MATRICES_ARB = $862F; + GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB = $862E; + GL_PROGRAM_ERROR_STRING_ARB = $8874; + GL_MATRIX0_ARB = $88C0; + GL_MATRIX1_ARB = $88C1; + GL_MATRIX2_ARB = $88C2; + GL_MATRIX3_ARB = $88C3; + GL_MATRIX4_ARB = $88C4; + GL_MATRIX5_ARB = $88C5; + GL_MATRIX6_ARB = $88C6; + GL_MATRIX7_ARB = $88C7; + GL_MATRIX8_ARB = $88C8; + GL_MATRIX9_ARB = $88C9; + GL_MATRIX10_ARB = $88CA; + GL_MATRIX11_ARB = $88CB; + GL_MATRIX12_ARB = $88CC; + GL_MATRIX13_ARB = $88CD; + GL_MATRIX14_ARB = $88CE; + GL_MATRIX15_ARB = $88CF; + GL_MATRIX16_ARB = $88D0; + GL_MATRIX17_ARB = $88D1; + GL_MATRIX18_ARB = $88D2; + GL_MATRIX19_ARB = $88D3; + GL_MATRIX20_ARB = $88D4; + GL_MATRIX21_ARB = $88D5; + GL_MATRIX22_ARB = $88D6; + GL_MATRIX23_ARB = $88D7; + GL_MATRIX24_ARB = $88D8; + GL_MATRIX25_ARB = $88D9; + GL_MATRIX26_ARB = $88DA; + GL_MATRIX27_ARB = $88DB; + GL_MATRIX28_ARB = $88DC; + GL_MATRIX29_ARB = $88DD; + GL_MATRIX30_ARB = $88DE; + GL_MATRIX31_ARB = $88DF; + + procedure glVertexAttrib1sARB(index: GLuint; x: GLshort); external dllname; + procedure glVertexAttrib1fARB(index: GLuint; x: GLfloat); external dllname; + procedure glVertexAttrib1dARB(index: GLuint; x: GLdouble); external dllname; + procedure glVertexAttrib2sARB(index: GLuint; x: GLshort; y: GLshort); external dllname; + procedure glVertexAttrib2fARB(index: GLuint; x: GLfloat; y: GLfloat); external dllname; + procedure glVertexAttrib2dARB(index: GLuint; x: GLdouble; y: GLdouble); external dllname; + procedure glVertexAttrib3sARB(index: GLuint; x: GLshort; y: GLshort; z: GLshort); external dllname; + procedure glVertexAttrib3fARB(index: GLuint; x: GLfloat; y: GLfloat; z: GLfloat); external dllname; + procedure glVertexAttrib3dARB(index: GLuint; x: GLdouble; y: GLdouble; z: GLdouble); external dllname; + procedure glVertexAttrib4sARB(index: GLuint; x: GLshort; y: GLshort; z: GLshort; w: GLshort); external dllname; + procedure glVertexAttrib4fARB(index: GLuint; x: GLfloat; y: GLfloat; z: GLfloat; w: GLfloat); external dllname; + procedure glVertexAttrib4dARB(index: GLuint; x: GLdouble; y: GLdouble; z: GLdouble; w: GLdouble); external dllname; + procedure glVertexAttrib4NubARB(index: GLuint; x: GLubyte; y: GLubyte; z: GLubyte; w: GLubyte); external dllname; + procedure glVertexAttrib1svARB(index: GLuint; const v: PGLshort); external dllname; + procedure glVertexAttrib1fvARB(index: GLuint; const v: PGLfloat); external dllname; + procedure glVertexAttrib1dvARB(index: GLuint; const v: PGLdouble); external dllname; + procedure glVertexAttrib2svARB(index: GLuint; const v: PGLshort); external dllname; + procedure glVertexAttrib2fvARB(index: GLuint; const v: PGLfloat); external dllname; + procedure glVertexAttrib2dvARB(index: GLuint; const v: PGLdouble); external dllname; + procedure glVertexAttrib3svARB(index: GLuint; const v: PGLshort); external dllname; + procedure glVertexAttrib3fvARB(index: GLuint; const v: PGLfloat); external dllname; + procedure glVertexAttrib3dvARB(index: GLuint; const v: PGLdouble); external dllname; + procedure glVertexAttrib4bvARB(index: GLuint; const v: PGLbyte); external dllname; + procedure glVertexAttrib4svARB(index: GLuint; const v: PGLshort); external dllname; + procedure glVertexAttrib4ivARB(index: GLuint; const v: PGLint); external dllname; + procedure glVertexAttrib4ubvARB(index: GLuint; const v: PGLubyte); external dllname; + procedure glVertexAttrib4usvARB(index: GLuint; const v: PGLushort); external dllname; + procedure glVertexAttrib4uivARB(index: GLuint; const v: PGLuint); external dllname; + procedure glVertexAttrib4fvARB(index: GLuint; const v: PGLfloat); external dllname; + procedure glVertexAttrib4dvARB(index: GLuint; const v: PGLdouble); external dllname; + procedure glVertexAttrib4NbvARB(index: GLuint; const v: PGLbyte); external dllname; + procedure glVertexAttrib4NsvARB(index: GLuint; const v: PGLshort); external dllname; + procedure glVertexAttrib4NivARB(index: GLuint; const v: PGLint); external dllname; + procedure glVertexAttrib4NubvARB(index: GLuint; const v: PGLubyte); external dllname; + procedure glVertexAttrib4NusvARB(index: GLuint; const v: PGLushort); external dllname; + procedure glVertexAttrib4NuivARB(index: GLuint; const v: PGLuint); external dllname; + procedure glVertexAttribPointerARB(index: GLuint; size: GLint; thetype: GLenum; normalized: GLboolean; stride: GLsizei; const pointer: PGLvoid); external dllname; + procedure glEnableVertexAttribArrayARB(index: GLuint); external dllname; + procedure glDisableVertexAttribArrayARB(index: GLuint); external dllname; + procedure glProgramStringARB(target: GLenum; format: GLenum; len: GLsizei; const str: PGLvoid); external dllname; + procedure glBindProgramARB(target: GLenum; theProgram: GLuint); external dllname; + procedure glDeleteProgramsARB(n: GLsizei; const programs: PGLuint); external dllname; + procedure glGenProgramsARB(n: GLsizei; programs: PGLuint); external dllname; + procedure glProgramEnvParameter4dARB(target: GLenum; index: GLuint; x: GLdouble; y: GLdouble; z: GLdouble; w: GLdouble); external dllname; + procedure glProgramEnvParameter4dvARB(target: GLenum; index: GLuint; const params: PGLdouble); external dllname; + procedure glProgramEnvParameter4fARB(target: GLenum; index: GLuint; x: GLfloat; y: GLfloat; z: GLfloat; w: GLfloat); external dllname; + procedure glProgramEnvParameter4fvARB(target: GLenum; index: GLuint; const params: PGLfloat); external dllname; + procedure glProgramLocalParameter4dARB(target: GLenum; index: GLuint; x: GLdouble; y: GLdouble; z: GLdouble; w: GLdouble); external dllname; + procedure glProgramLocalParameter4dvARB(target: GLenum; index: GLuint; const params: PGLdouble); external dllname; + procedure glProgramLocalParameter4fARB(target: GLenum; index: GLuint; x: GLfloat; y: GLfloat; z: GLfloat; w: GLfloat); external dllname; + procedure glProgramLocalParameter4fvARB(target: GLenum; index: GLuint; const params: PGLfloat); external dllname; + procedure glGetProgramEnvParameterdvARB(target: GLenum; index: GLuint; params: PGLdouble); external dllname; + procedure glGetProgramEnvParameterfvARB(target: GLenum; index: GLuint; params: PGLfloat); external dllname; + procedure glGetProgramLocalParameterdvARB(target: GLenum; index: GLuint; params: PGLdouble); external dllname; + procedure glGetProgramLocalParameterfvARB(target: GLenum; index: GLuint; params: PGLfloat); external dllname; + procedure glGetProgramivARB(target: GLenum; pname: GLenum; params: PGLint); external dllname; + procedure glGetProgramStringARB(target: GLenum; pname: GLenum; str: PGLvoid); external dllname; + procedure glGetVertexAttribdvARB(index: GLuint; pname: GLenum; params: PGLdouble); external dllname; + procedure glGetVertexAttribfvARB(index: GLuint; pname: GLenum; params: PGLfloat); external dllname; + procedure glGetVertexAttribivARB(index: GLuint; pname: GLenum; params: PGLint); external dllname; + procedure glGetVertexAttribPointervARB(index: GLuint; pname: GLenum; pointer: PGLvoid); external dllname; + function glIsProgramARB(theProgram: GLuint): GLboolean; external dllname; + +function Load_GL_ARB_vertex_program: Boolean; + +//***** GL_ARB_window_pos *****// + + procedure glWindowPos2dARB(x: GLdouble; y: GLdouble); external dllname; + procedure glWindowPos2fARB(x: GLfloat; y: GLfloat); external dllname; + procedure glWindowPos2iARB(x: GLint; y: GLint); external dllname; + procedure glWindowPos2sARB(x: GLshort; y: GLshort); external dllname; + procedure glWindowPos2dvARB(const p: PGLdouble); external dllname; + procedure glWindowPos2fvARB(const p: PGLfloat); external dllname; + procedure glWindowPos2ivARB(const p: PGLint); external dllname; + procedure glWindowPos2svARB(const p: PGLshort); external dllname; + procedure glWindowPos3dARB(x: GLdouble; y: GLdouble; z: GLdouble); external dllname; + procedure glWindowPos3fARB(x: GLfloat; y: GLfloat; z: GLfloat); external dllname; + procedure glWindowPos3iARB(x: GLint; y: GLint; z: GLint); external dllname; + procedure glWindowPos3sARB(x: GLshort; y: GLshort; z: GLshort); external dllname; + procedure glWindowPos3dvARB(const p: PGLdouble); external dllname; + procedure glWindowPos3fvARB(const p: PGLfloat); external dllname; + procedure glWindowPos3ivARB(const p: PGLint); external dllname; + procedure glWindowPos3svARB(const p: PGLshort); external dllname; + +function Load_GL_ARB_window_pos: Boolean; + +//***** GL_EXT_422_pixels *****// +const + GL_422_EXT = $80CC; + GL_422_REV_EXT = $80CD; + GL_422_AVERAGE_EXT = $80CE; + GL_422_REV_AVERAGE_EXT = $80CF; + +function Load_GL_EXT_422_pixels: Boolean; + +//***** GL_EXT_abgr *****// +const + GL_ABGR_EXT = $8000; + +function Load_GL_EXT_abgr: Boolean; + +//***** GL_EXT_bgra *****// +const + GL_BGR_EXT = $80E0; + GL_BGRA_EXT = $80E1; + +function Load_GL_EXT_bgra: Boolean; + +//***** GL_EXT_blend_color *****// +const + GL_CONSTANT_COLOR_EXT = $8001; + GL_ONE_MINUS_CONSTANT_COLOR_EXT = $8002; + GL_CONSTANT_ALPHA_EXT = $8003; + GL_ONE_MINUS_CONSTANT_ALPHA_EXT = $8004; + GL_BLEND_COLOR_EXT = $8005; + + procedure glBlendColorEXT(red: GLclampf; green: GLclampf; blue: GLclampf; alpha: GLclampf); external dllname; + +function Load_GL_EXT_blend_color: Boolean; + +//***** GL_EXT_blend_func_separate *****// +const + GL_BLEND_DST_RGB_EXT = $80C8; + GL_BLEND_SRC_RGB_EXT = $80C9; + GL_BLEND_DST_ALPHA_EXT = $80CA; + GL_BLEND_SRC_ALPHA_EXT = $80CB; + +procedure glBlendFuncSeparateEXT(sfactorRGB: GLenum; dfactorRGB: GLenum; sfactorAlpha: GLenum; dfactorAlpha: GLenum); external dllname; + +function Load_GL_EXT_blend_func_separate: Boolean; + +//***** GL_EXT_blend_logic_op *****// + +function Load_GL_EXT_blend_logic_op: Boolean; + +//***** GL_EXT_blend_minmax *****// +const + GL_FUNC_ADD_EXT = $8006; + GL_MIN_EXT = $8007; + GL_MAX_EXT = $8008; + GL_BLEND_EQUATION_EXT = $8009; + + procedure glBlendEquationEXT(mode: GLenum); external dllname; + +function Load_GL_EXT_blend_minmax: Boolean; + +//***** GL_EXT_blend_subtract *****// +const + GL_FUNC_SUBTRACT_EXT = $800A; + GL_FUNC_REVERSE_SUBTRACT_EXT = $800B; + +function Load_GL_EXT_blend_subtract: Boolean; + +//***** GL_EXT_clip_volume_hint *****// +const + GL_CLIP_VOLUME_CLIPPING_HINT_EXT = $80F0; + +function Load_GL_EXT_clip_volume_hint: Boolean; + +//***** GL_EXT_color_subtable *****// + + procedure glColorSubTableEXT(target: GLenum; start: GLsizei; count: GLsizei; format: GLenum; thetype: GLenum; const data: PGLvoid); external dllname; + procedure glCopyColorSubTableEXT(target: GLenum; start: GLsizei; x: GLint; y: GLint; width: GLsizei); external dllname; + +function Load_GL_EXT_color_subtable: Boolean; + +//***** GL_EXT_compiled_vertex_array *****// +const + GL_ARRAY_ELEMENT_LOCK_FIRST_EXT = $81A8; + GL_ARRAY_ELEMENT_LOCK_COUNT_EXT = $81A9; + + procedure glLockArraysEXT(first: GLint; count: GLsizei); external dllname; + procedure glUnlockArraysEXT(); external dllname; + +function Load_GL_EXT_compiled_vertex_array: Boolean; + +//***** GL_EXT_convolution *****// +const + GL_CONVOLUTION_1D_EXT = $8010; + GL_CONVOLUTION_2D_EXT = $8011; + GL_SEPARABLE_2D_EXT = $8012; + GL_CONVOLUTION_BORDER_MODE_EXT = $8013; + GL_CONVOLUTION_FILTER_SCALE_EXT = $8014; + GL_CONVOLUTION_FILTER_BIAS_EXT = $8015; + GL_REDUCE_EXT = $8016; + GL_CONVOLUTION_FORMAT_EXT = $8017; + GL_CONVOLUTION_WIDTH_EXT = $8018; + GL_CONVOLUTION_HEIGHT_EXT = $8019; + GL_MAX_CONVOLUTION_WIDTH_EXT = $801A; + GL_MAX_CONVOLUTION_HEIGHT_EXT = $801B; + GL_POST_CONVOLUTION_RED_SCALE_EXT = $801C; + GL_POST_CONVOLUTION_GREEN_SCALE_EXT = $801D; + GL_POST_CONVOLUTION_BLUE_SCALE_EXT = $801E; + GL_POST_CONVOLUTION_ALPHA_SCALE_EXT = $801F; + GL_POST_CONVOLUTION_RED_BIAS_EXT = $8020; + GL_POST_CONVOLUTION_GREEN_BIAS_EXT = $8021; + GL_POST_CONVOLUTION_BLUE_BIAS_EXT = $8022; + GL_POST_CONVOLUTION_ALPHA_BIAS_EXT = $8023; + + procedure glConvolutionFilter1DEXT(target: GLenum; internalformat: GLenum; width: GLsizei; format: GLenum; thetype: GLenum; const image: PGLvoid); external dllname; + procedure glConvolutionFilter2DEXT(target: GLenum; internalformat: GLenum; width: GLsizei; height: GLsizei; format: GLenum; thetype: GLenum; const image: PGLvoid); external dllname; + procedure glCopyConvolutionFilter1DEXT(target: GLenum; internalformat: GLenum; x: GLint; y: GLint; width: GLsizei); external dllname; + procedure glCopyConvolutionFilter2DEXT(target: GLenum; internalformat: GLenum; x: GLint; y: GLint; width: GLsizei; height: GLsizei); external dllname; + procedure glGetConvolutionFilterEXT(target: GLenum; format: GLenum; thetype: GLenum; image: PGLvoid); external dllname; + procedure glSeparableFilter2DEXT(target: GLenum; internalformat: GLenum; width: GLsizei; height: GLsizei; format: GLenum; thetype: GLenum; const row: PGLvoid; const column: PGLvoid); external dllname; + procedure glGetSeparableFilterEXT(target: GLenum; format: GLenum; thetype: GLenum; row: PGLvoid; column: PGLvoid; span: PGLvoid); external dllname; + procedure glConvolutionParameteriEXT(target: GLenum; pname: GLenum; param: GLint); external dllname; + procedure glConvolutionParameterivEXT(target: GLenum; pname: GLenum; const params: PGLint); external dllname; + procedure glConvolutionParameterfEXT(target: GLenum; pname: GLenum; param: GLfloat); external dllname; + procedure glConvolutionParameterfvEXT(target: GLenum; pname: GLenum; const params: PGLfloat); external dllname; + procedure glGetConvolutionParameterivEXT(target: GLenum; pname: GLenum; params: PGLint); external dllname; + procedure glGetConvolutionParameterfvEXT(target: GLenum; pname: GLenum; params: PGLfloat); external dllname; + +function Load_GL_EXT_convolution: Boolean; + +//***** GL_EXT_fog_coord *****// +const + GL_FOG_COORDINATE_SOURCE_EXT = $8450; + GL_FOG_COORDINATE_EXT = $8451; + GL_FRAGMENT_DEPTH_EXT = $8452; + GL_CURRENT_FOG_COORDINATE_EXT = $8453; + GL_FOG_COORDINATE_ARRAY_TYPE_EXT = $8454; + GL_FOG_COORDINATE_ARRAY_STRIDE_EXT = $8455; + GL_FOG_COORDINATE_ARRAY_POINTER_EXT = $8456; + GL_FOG_COORDINATE_ARRAY_EXT = $8457; + + procedure glFogCoordfEXfloat(coord: GLfloat); external dllname; + procedure glFogCoorddEXdouble(coord: GLdouble); external dllname; + procedure glFogCoordfvEXfloat(coord: GLfloat); external dllname; + procedure glFogCoorddvEXdouble(coord: GLdouble); external dllname; + procedure glFogCoordPointerEXT(thetype: GLenum; stride: GLsizei; pointer: PGLvoid); external dllname; + +function Load_GL_EXT_fog_coord: Boolean; + +//***** GL_EXT_histogram *****// +const + GL_HISTOGRAM_EXT = $8024; + GL_PROXY_HISTOGRAM_EXT = $8025; + GL_HISTOGRAM_WIDTH_EXT = $8026; + GL_HISTOGRAM_FORMAT_EXT = $8027; + GL_HISTOGRAM_RED_SIZE_EXT = $8028; + GL_HISTOGRAM_GREEN_SIZE_EXT = $8029; + GL_HISTOGRAM_BLUE_SIZE_EXT = $802A; + GL_HISTOGRAM_ALPHA_SIZE_EXT = $802B; + GL_HISTOGRAM_LUMINANCE_SIZE_EXT = $802C; + GL_HISTOGRAM_SINK_EXT = $802D; + GL_MINMAX_EXT = $802E; + GL_MINMAX_FORMAT_EXT = $802F; + GL_MINMAX_SINK_EXT = $8030; + + procedure glHistogramEXT(target: GLenum; width: GLsizei; internalformat: GLenum; sink: GLboolean); external dllname; + procedure glResetHistogramEXT(target: GLenum); external dllname; + procedure glGetHistogramEXT(target: GLenum; reset: GLboolean; format: GLenum; thetype: GLenum; values: PGLvoid); external dllname; + procedure glGetHistogramParameterivEXT(target: GLenum; pname: GLenum; params: PGLint); external dllname; + procedure glGetHistogramParameterfvEXT(target: GLenum; pname: GLenum; params: PGLfloat); external dllname; + procedure glMinmaxEXT(target: GLenum; internalformat: GLenum; sink: GLboolean); external dllname; + procedure glResetMinmaxEXT(target: GLenum); external dllname; + procedure glGetMinmaxEXT(target: GLenum; reset: GLboolean; format: GLenum; thetype: GLenum; values: PGLvoid); external dllname; + procedure glGetMinmaxParameterivEXT(target: GLenum; pname: GLenum; params: PGLint); external dllname; + procedure glGetMinmaxParameterfvEXT(target: GLenum; pname: GLenum; params: PGLfloat); external dllname; + +function Load_GL_EXT_histogram: Boolean; + +//***** GL_EXT_multi_draw_arrays *****// + + procedure glMultiDrawArraysEXT(mode: GLenum; first: PGLint; count: PGLsizei; primcount: GLsizei); external dllname; + procedure glMultiDrawElementsEXT(mode: GLenum; count: PGLsizei; thetype: GLenum; const indices: PGLvoid; primcount: GLsizei); external dllname; + +function Load_GL_EXT_multi_draw_arrays: Boolean; + +//***** GL_EXT_packed_pixels *****// +const + GL_UNSIGNED_BYTE_3_3_2_EXT = $8032; + GL_UNSIGNED_SHORT_4_4_4_4_EXT = $8033; + GL_UNSIGNED_SHORT_5_5_5_1_EXT = $8034; + GL_UNSIGNED_INT_8_8_8_8_EXT = $8035; + GL_UNSIGNED_INT_10_10_10_2_EXT = $8036; + +function Load_GL_EXT_packed_pixels: Boolean; + +//***** GL_EXT_paletted_texture *****// +const + GL_COLOR_INDEX1_EXT = $80E2; + GL_COLOR_INDEX2_EXT = $80E3; + GL_COLOR_INDEX4_EXT = $80E4; + GL_COLOR_INDEX8_EXT = $80E5; + GL_COLOR_INDEX12_EXT = $80E6; + GL_COLOR_INDEX16_EXT = $80E7; + GL_COLOR_TABLE_FORMAT_EXT = $80D8; + GL_COLOR_TABLE_WIDTH_EXT = $80D9; + GL_COLOR_TABLE_RED_SIZE_EXT = $80DA; + GL_COLOR_TABLE_GREEN_SIZE_EXT = $80DB; + GL_COLOR_TABLE_BLUE_SIZE_EXT = $80DC; + GL_COLOR_TABLE_ALPHA_SIZE_EXT = $80DD; + GL_COLOR_TABLE_LUMINANCE_SIZE_EXT = $80DE; + GL_COLOR_TABLE_INTENSITY_SIZE_EXT = $80DF; + GL_TEXTURE_INDEX_SIZE_EXT = $80ED; + GL_TEXTURE_1D = $0DE0; + GL_TEXTURE_2D = $0DE1; + GL_TEXTURE_3D_EXT = $806F; + // GL_TEXTURE_CUBE_MAP_ARB { already defined } + GL_PROXY_TEXTURE_1D = $8063; + GL_PROXY_TEXTURE_2D = $8064; + GL_PROXY_TEXTURE_3D_EXT = $8070; + // GL_PROXY_TEXTURE_CUBE_MAP_ARB { already defined } + // GL_TEXTURE_1D { already defined } + // GL_TEXTURE_2D { already defined } + // GL_TEXTURE_3D_EXT { already defined } + // GL_TEXTURE_CUBE_MAP_ARB { already defined } + + procedure glColorTableEXT(target: GLenum; internalFormat: GLenum; width: GLsizei; format: GLenum; thetype: GLenum; const data: PGLvoid); external dllname; + // glColorSubTableEXT { already defined } + procedure glGetColorTableEXT(target: GLenum; format: GLenum; thetype: GLenum; data: PGLvoid); external dllname; + procedure glGetColorTableParameterivEXT(target: GLenum; pname: GLenum; params: PGLint); external dllname; + procedure glGetColorTableParameterfvEXT(target: GLenum; pname: GLenum; params: PGLfloat); external dllname; + +function Load_GL_EXT_paletted_texture: Boolean; + +//***** GL_EXT_point_parameters *****// +const + GL_POINT_SIZE_MIN_EXT = $8126; + GL_POINT_SIZE_MAX_EXT = $8127; + GL_POINT_FADE_THRESHOLD_SIZE_EXT = $8128; + GL_DISTANCE_ATTENUATION_EXT = $8129; + + + procedure glPointParameterfEXT(pname: GLenum; param: GLfloat); external dllname; + procedure glPointParameterfvEXT(pname: GLenum; params: PGLfloat); external dllname; + +function Load_GL_EXT_point_parameters: Boolean; + +//***** GL_EXT_polygon_offset *****// +const + GL_POLYGON_OFFSET_EXT = $8037; + GL_POLYGON_OFFSET_FACTOR_EXT = $8038; + GL_POLYGON_OFFSET_BIAS_EXT = $8039; + procedure glPolygonOffsetEXT(factor: GLfloat; bias: GLfloat); external dllname; + +function Load_GL_EXT_polygon_offset: Boolean; + +//***** GL_EXT_secondary_color *****// +const + GL_COLOR_SUM_EXT = $8458; + GL_CURRENT_SECONDARY_COLOR_EXT = $8459; + GL_SECONDARY_COLOR_ARRAY_SIZE_EXT = $845A; + GL_SECONDARY_COLOR_ARRAY_TYPE_EXT = $845B; + GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT = $845C; + GL_SECONDARY_COLOR_ARRAY_POINTER_EXT = $845D; + GL_SECONDARY_COLOR_ARRAY_EXT = $845E; + procedure glSecondaryColor3bEXT(components: GLbyte); external dllname; + procedure glSecondaryColor3sEXT(components: GLshort); external dllname; + procedure glSecondaryColor3iEXT(components: GLint); external dllname; + procedure glSecondaryColor3fEXT(components: GLfloat); external dllname; + procedure glSecondaryColor3dEXT(components: GLdouble); external dllname; + procedure glSecondaryColor3ubEXT(components: GLubyte); external dllname; + procedure glSecondaryColor3usEXT(components: GLushort); external dllname; + procedure glSecondaryColor3uiEXT(components: GLuint); external dllname; + procedure glSecondaryColor3bvEXT(components: GLbyte); external dllname; + procedure glSecondaryColor3svEXT(components: GLshort); external dllname; + procedure glSecondaryColor3ivEXT(components: GLint); external dllname; + procedure glSecondaryColor3fvEXT(components: GLfloat); external dllname; + procedure glSecondaryColor3dvEXT(components: GLdouble); external dllname; + procedure glSecondaryColor3ubvEXT(components: GLubyte); external dllname; + procedure glSecondaryColor3usvEXT(components: GLushort); external dllname; + procedure glSecondaryColor3uivEXT(components: GLuint); external dllname; + procedure glSecondaryColorPointerEXT(size: GLint; thetype: GLenum; stride: GLsizei; pointer: PGLvoid); external dllname; + +function Load_GL_EXT_secondary_color: Boolean; + +//***** GL_EXT_separate_specular_color *****// +const + GL_LIGHT_MODEL_COLOR_CONTROL_EXT = $81F8; + GL_SINGLE_COLOR_EXT = $81F9; + GL_SEPARATE_SPECULAR_COLOR_EXT = $81FA; + +function Load_GL_EXT_separate_specular_color: Boolean; + +//***** GL_EXT_shadow_funcs *****// + +function Load_GL_EXT_shadow_funcs: Boolean; + +//***** GL_EXT_shared_texture_palette *****// +const + GL_SHARED_TEXTURE_PALETTE_EXT = $81FB; + +function Load_GL_EXT_shared_texture_palette: Boolean; + +//***** GL_EXT_stencil_two_side *****// +const + GL_STENCIL_TEST_TWO_SIDE_EXT = $8910; + GL_ACTIVE_STENCIL_FACE_EXT = $8911; + + procedure glActiveStencilFaceEXT(face: GLenum); external dllname; + +function Load_GL_EXT_stencil_two_side: Boolean; + +//***** GL_EXT_stencil_wrap *****// +const + GL_INCR_WRAP_EXT = $8507; + GL_DECR_WRAP_EXT = $8508; + +function Load_GL_EXT_stencil_wrap: Boolean; + +//***** GL_EXT_subtexture *****// + + procedure glTexSubImage1DEXT(target: GLenum; level: GLint; xoffset: GLint; width: GLsizei; format: GLenum; thetype: GLenum; const pixels: PGLvoid); external dllname; + procedure glTexSubImage2DEXT(target: GLenum; level: GLint; xoffset: GLint; yoffset: GLint; width: GLsizei; height: GLsizei; format: GLenum; thetype: GLenum; const pixels: PGLvoid); external dllname; + procedure glTexSubImage3DEXT(target: GLenum; level: GLint; xoffset: GLint; yoffset: GLint; zoffset: GLint; width: GLsizei; height: GLsizei; depth: GLsizei; format: GLenum; thetype: GLenum; const pixels: PGLvoid); external dllname; + +function Load_GL_EXT_subtexture: Boolean; + +//***** GL_EXT_texture3D *****// +const + GL_PACK_SKIP_IMAGES_EXT = $806B; + GL_PACK_IMAGE_HEIGHT_EXT = $806C; + GL_UNPACK_SKIP_IMAGES_EXT = $806D; + GL_UNPACK_IMAGE_HEIGHT_EXT = $806E; + // GL_TEXTURE_3D_EXT { already defined } + // GL_PROXY_TEXTURE_3D_EXT { already defined } + GL_TEXTURE_DEPTH_EXT = $8071; + GL_TEXTURE_WRAP_R_EXT = $8072; + GL_MAX_3D_TEXTURE_SIZE_EXT = $8073; + + procedure glTexImage3DEXT(target: GLenum; level: GLint; internalformat: GLenum; width: GLsizei; height: GLsizei; depth: GLsizei; border: GLint; format: GLenum; thetype: GLenum; const pixels: PGLvoid); external dllname; + +function Load_GL_EXT_texture3D: Boolean; + +//***** GL_EXT_texture_compression_s3tc *****// +const + GL_COMPRESSED_RGB_S3TC_DXT1_EXT = $83F0; + GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = $83F1; + GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = $83F2; + GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = $83F3; + +function Load_GL_EXT_texture_compression_s3tc: Boolean; + +//***** GL_EXT_texture_env_add *****// + +function Load_GL_EXT_texture_env_add: Boolean; + +//***** GL_EXT_texture_env_combine *****// +const + GL_COMBINE_EXT = $8570; + GL_COMBINE_RGB_EXT = $8571; + GL_COMBINE_ALPHA_EXT = $8572; + GL_SOURCE0_RGB_EXT = $8580; + GL_SOURCE1_RGB_EXT = $8581; + GL_SOURCE2_RGB_EXT = $8582; + GL_SOURCE0_ALPHA_EXT = $8588; + GL_SOURCE1_ALPHA_EXT = $8589; + GL_SOURCE2_ALPHA_EXT = $858A; + GL_OPERAND0_RGB_EXT = $8590; + GL_OPERAND1_RGB_EXT = $8591; + GL_OPERAND2_RGB_EXT = $8592; + GL_OPERAND0_ALPHA_EXT = $8598; + GL_OPERAND1_ALPHA_EXT = $8599; + GL_OPERAND2_ALPHA_EXT = $859A; + GL_RGB_SCALE_EXT = $8573; + GL_ADD_SIGNED_EXT = $8574; + GL_INTERPOLATE_EXT = $8575; + GL_CONSTANT_EXT = $8576; + GL_PRIMARY_COLOR_EXT = $8577; + GL_PREVIOUS_EXT = $8578; + +function Load_GL_EXT_texture_env_combine: Boolean; + +//***** GL_EXT_texture_env_dot3 *****// +const + GL_DOT3_RGB_EXT = $8740; + GL_DOT3_RGBA_EXT = $8741; + +function Load_GL_EXT_texture_env_dot3: Boolean; + +//***** GL_EXT_texture_filter_anisotropic *****// +const + GL_TEXTURE_MAX_ANISOTROPY_EXT = $84FE; + GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT = $84FF; + +function Load_GL_EXT_texture_filter_anisotropic: Boolean; + +//***** GL_EXT_texture_lod_bias *****// +const + GL_TEXTURE_FILTER_CONTROL_EXT = $8500; + GL_TEXTURE_LOD_BIAS_EXT = $8501; + GL_MAX_TEXTURE_LOD_BIAS_EXT = $84FD; + +function Load_GL_EXT_texture_lod_bias: Boolean; + +//***** GL_EXT_texture_object *****// +const + GL_TEXTURE_PRIORITY_EXT = $8066; + GL_TEXTURE_RESIDENT_EXT = $8067; + GL_TEXTURE_1D_BINDING_EXT = $8068; + GL_TEXTURE_2D_BINDING_EXT = $8069; + GL_TEXTURE_3D_BINDING_EXT = $806A; + + procedure glGenTexturesEXT(n: GLsizei; textures: PGLuint); external dllname; + procedure glDeleteTexturesEXT(n: GLsizei; const textures: PGLuint); external dllname; + procedure glBindTextureEXT(target: GLenum; texture: GLuint); external dllname; + procedure glPrioritizeTexturesEXT(n: GLsizei; const textures: PGLuint; const priorities: PGLclampf); external dllname; + function glAreTexturesResidentEXT(n: GLsizei; const textures: PGLuint; residences: PGLboolean): GLboolean; external dllname; + function glIsTextureEXT(texture: GLuint): GLboolean; external dllname; + +function Load_GL_EXT_texture_object: Boolean; + +//***** GL_EXT_vertex_array *****// +const + GL_VERTEX_ARRAY_EXT = $8074; + GL_NORMAL_ARRAY_EXT = $8075; + GL_COLOR_ARRAY_EXT = $8076; + GL_INDEX_ARRAY_EXT = $8077; + GL_TEXTURE_COORD_ARRAY_EXT = $8078; + GL_EDGE_FLAG_ARRAY_EXT = $8079; + GL_DOUBLE_EXT = $140A; + GL_VERTEX_ARRAY_SIZE_EXT = $807A; + GL_VERTEX_ARRAY_TYPE_EXT = $807B; + GL_VERTEX_ARRAY_STRIDE_EXT = $807C; + GL_VERTEX_ARRAY_COUNT_EXT = $807D; + GL_NORMAL_ARRAY_TYPE_EXT = $807E; + GL_NORMAL_ARRAY_STRIDE_EXT = $807F; + GL_NORMAL_ARRAY_COUNT_EXT = $8080; + GL_COLOR_ARRAY_SIZE_EXT = $8081; + GL_COLOR_ARRAY_TYPE_EXT = $8082; + GL_COLOR_ARRAY_STRIDE_EXT = $8083; + GL_COLOR_ARRAY_COUNT_EXT = $8084; + GL_INDEX_ARRAY_TYPE_EXT = $8085; + GL_INDEX_ARRAY_STRIDE_EXT = $8086; + GL_INDEX_ARRAY_COUNT_EXT = $8087; + GL_TEXTURE_COORD_ARRAY_SIZE_EXT = $8088; + GL_TEXTURE_COORD_ARRAY_TYPE_EXT = $8089; + GL_TEXTURE_COORD_ARRAY_STRIDE_EXT = $808A; + GL_TEXTURE_COORD_ARRAY_COUNT_EXT = $808B; + GL_EDGE_FLAG_ARRAY_STRIDE_EXT = $808C; + GL_EDGE_FLAG_ARRAY_COUNT_EXT = $808D; + GL_VERTEX_ARRAY_POINTER_EXT = $808E; + GL_NORMAL_ARRAY_POINTER_EXT = $808F; + GL_COLOR_ARRAY_POINTER_EXT = $8090; + GL_INDEX_ARRAY_POINTER_EXT = $8091; + GL_TEXTURE_COORD_ARRAY_POINTER_EXT = $8092; + GL_EDGE_FLAG_ARRAY_POINTER_EXT = $8093; + + procedure glArrayElementEXT(i: GLint); external dllname; + procedure glDrawArraysEXT(mode: GLenum; first: GLint; count: GLsizei); external dllname; + procedure glVertexPointerEXT(size: GLint; thetype: GLenum; stride: GLsizei; count: GLsizei; const pointer: PGLvoid); external dllname; + procedure glNormalPointerEXT(thetype: GLenum; stride: GLsizei; count: GLsizei; const pointer: PGLvoid); external dllname; + procedure glColorPointerEXT(size: GLint; thetype: GLenum; stride: GLsizei; count: GLsizei; const pointer: PGLvoid); external dllname; + procedure glIndexPointerEXT(thetype: GLenum; stride: GLsizei; count: GLsizei; const pointer: PGLvoid); external dllname; + procedure glTexCoordPointerEXT(size: GLint; thetype: GLenum; stride: GLsizei; count: GLsizei; const pointer: PGLvoid); external dllname; + procedure glEdgeFlagPointerEXT(stride: GLsizei; count: GLsizei; const pointer: PGLboolean); external dllname; + procedure glGetPointervEXT(pname: GLenum; params: PGLvoid); external dllname; + +function Load_GL_EXT_vertex_array: Boolean; + +//***** GL_EXT_vertex_shader *****// +const + GL_VERTEX_SHADER_EXT = $8780; + GL_VARIANT_VALUE_EXT = $87E4; + GL_VARIANT_DATATYPE_EXT = $87E5; + GL_VARIANT_ARRAY_STRIDE_EXT = $87E6; + GL_VARIANT_ARRAY_TYPE_EXT = $87E7; + GL_VARIANT_ARRAY_EXT = $87E8; + GL_VARIANT_ARRAY_POINTER_EXT = $87E9; + GL_INVARIANT_VALUE_EXT = $87EA; + GL_INVARIANT_DATATYPE_EXT = $87EB; + GL_LOCAL_CONSTANT_VALUE_EXT = $87EC; + GL_LOCAL_CONSTANT_DATATYPE_EXT = $87ED; + GL_OP_INDEX_EXT = $8782; + GL_OP_NEGATE_EXT = $8783; + GL_OP_DOT3_EXT = $8784; + GL_OP_DOT4_EXT = $8785; + GL_OP_MUL_EXT = $8786; + GL_OP_ADD_EXT = $8787; + GL_OP_MADD_EXT = $8788; + GL_OP_FRAC_EXT = $8789; + GL_OP_MAX_EXT = $878A; + GL_OP_MIN_EXT = $878B; + GL_OP_SET_GE_EXT = $878C; + GL_OP_SET_LT_EXT = $878D; + GL_OP_CLAMP_EXT = $878E; + GL_OP_FLOOR_EXT = $878F; + GL_OP_ROUND_EXT = $8790; + GL_OP_EXP_BASE_2_EXT = $8791; + GL_OP_LOG_BASE_2_EXT = $8792; + GL_OP_POWER_EXT = $8793; + GL_OP_RECIP_EXT = $8794; + GL_OP_RECIP_SQRT_EXT = $8795; + GL_OP_SUB_EXT = $8796; + GL_OP_CROSS_PRODUCT_EXT = $8797; + GL_OP_MULTIPLY_MATRIX_EXT = $8798; + GL_OP_MOV_EXT = $8799; + GL_OUTPUT_VERTEX_EXT = $879A; + GL_OUTPUT_COLOR0_EXT = $879B; + GL_OUTPUT_COLOR1_EXT = $879C; + GL_OUTPUT_TEXTURE_COORD0_EXT = $879D; + GL_OUTPUT_TEXTURE_COORD1_EXT = $879E; + GL_OUTPUT_TEXTURE_COORD2_EXT = $879F; + GL_OUTPUT_TEXTURE_COORD3_EXT = $87A0; + GL_OUTPUT_TEXTURE_COORD4_EXT = $87A1; + GL_OUTPUT_TEXTURE_COORD5_EXT = $87A2; + GL_OUTPUT_TEXTURE_COORD6_EXT = $87A3; + GL_OUTPUT_TEXTURE_COORD7_EXT = $87A4; + GL_OUTPUT_TEXTURE_COORD8_EXT = $87A5; + GL_OUTPUT_TEXTURE_COORD9_EXT = $87A6; + GL_OUTPUT_TEXTURE_COORD10_EXT = $87A7; + GL_OUTPUT_TEXTURE_COORD11_EXT = $87A8; + GL_OUTPUT_TEXTURE_COORD12_EXT = $87A9; + GL_OUTPUT_TEXTURE_COORD13_EXT = $87AA; + GL_OUTPUT_TEXTURE_COORD14_EXT = $87AB; + GL_OUTPUT_TEXTURE_COORD15_EXT = $87AC; + GL_OUTPUT_TEXTURE_COORD16_EXT = $87AD; + GL_OUTPUT_TEXTURE_COORD17_EXT = $87AE; + GL_OUTPUT_TEXTURE_COORD18_EXT = $87AF; + GL_OUTPUT_TEXTURE_COORD19_EXT = $87B0; + GL_OUTPUT_TEXTURE_COORD20_EXT = $87B1; + GL_OUTPUT_TEXTURE_COORD21_EXT = $87B2; + GL_OUTPUT_TEXTURE_COORD22_EXT = $87B3; + GL_OUTPUT_TEXTURE_COORD23_EXT = $87B4; + GL_OUTPUT_TEXTURE_COORD24_EXT = $87B5; + GL_OUTPUT_TEXTURE_COORD25_EXT = $87B6; + GL_OUTPUT_TEXTURE_COORD26_EXT = $87B7; + GL_OUTPUT_TEXTURE_COORD27_EXT = $87B8; + GL_OUTPUT_TEXTURE_COORD28_EXT = $87B9; + GL_OUTPUT_TEXTURE_COORD29_EXT = $87BA; + GL_OUTPUT_TEXTURE_COORD30_EXT = $87BB; + GL_OUTPUT_TEXTURE_COORD31_EXT = $87BC; + GL_OUTPUT_FOG_EXT = $87BD; + GL_SCALAR_EXT = $87BE; + GL_VECTOR_EXT = $87BF; + GL_MATRIX_EXT = $87C0; + GL_VARIANT_EXT = $87C1; + GL_INVARIANT_EXT = $87C2; + GL_LOCAL_CONSTANT_EXT = $87C3; + GL_LOCAL_EXT = $87C4; + GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT = $87C5; + GL_MAX_VERTEX_SHADER_VARIANTS_EXT = $87C6; + GL_MAX_VERTEX_SHADER_INVARIANTS_EXT = $87C7; + GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT = $87C8; + GL_MAX_VERTEX_SHADER_LOCALS_EXT = $87C9; + GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT = $87CA; + GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT = $87CB; + GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT = $87CC; + GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT = $87CD; + GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT = $87CE; + GL_VERTEX_SHADER_INSTRUCTIONS_EXT = $87CF; + GL_VERTEX_SHADER_VARIANTS_EXT = $87D0; + GL_VERTEX_SHADER_INVARIANTS_EXT = $87D1; + GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT = $87D2; + GL_VERTEX_SHADER_LOCALS_EXT = $87D3; + GL_VERTEX_SHADER_BINDING_EXT = $8781; + GL_VERTEX_SHADER_OPTIMIZED_EXT = $87D4; + GL_X_EXT = $87D5; + GL_Y_EXT = $87D6; + GL_Z_EXT = $87D7; + GL_W_EXT = $87D8; + GL_NEGATIVE_X_EXT = $87D9; + GL_NEGATIVE_Y_EXT = $87DA; + GL_NEGATIVE_Z_EXT = $87DB; + GL_NEGATIVE_W_EXT = $87DC; + GL_ZERO_EXT = $87DD; + GL_ONE_EXT = $87DE; + GL_NEGATIVE_ONE_EXT = $87DF; + GL_NORMALIZED_RANGE_EXT = $87E0; + GL_FULL_RANGE_EXT = $87E1; + GL_CURRENT_VERTEX_EXT = $87E2; + GL_MVP_MATRIX_EXT = $87E3; + + procedure glBeginVertexShaderEXT(); external dllname; + procedure glEndVertexShaderEXT(); external dllname; + procedure glBindVertexShaderEXT(id: GLuint); external dllname; + function glGenVertexShadersEXT(range: GLuint): GLuint; external dllname; + procedure glDeleteVertexShaderEXT(id: GLuint); external dllname; + procedure glShaderOp1EXT(op: GLenum; res: GLuint; arg1: GLuint); external dllname; + procedure glShaderOp2EXT(op: GLenum; res: GLuint; arg1: GLuint; arg2: GLuint); external dllname; + procedure glShaderOp3EXT(op: GLenum; res: GLuint; arg1: GLuint; arg2: GLuint; arg3: GLuint); external dllname; + procedure glSwizzleEXT(res: GLuint; theIn: GLuint; outX: GLenum; outY: GLenum; outZ: GLenum; outW: GLenum); external dllname; + procedure glWriteMaskEXT(res: GLuint; theIn: GLuint; outX: GLenum; outY: GLenum; outZ: GLenum; outW: GLenum); external dllname; + procedure glInsertComponentEXT(res: GLuint; src: GLuint; num: GLuint); external dllname; + procedure glExtractComponentEXT(res: GLuint; src: GLuint; num: GLuint); external dllname; + function glGenSymbolsEXT(datatype: GLenum; storagetype: GLenum; range: GLenum; components: GLuint): GLuint; external dllname; + procedure glSetInvariantEXT(id: GLuint; thetype: GLenum; addr: PGLvoid); external dllname; + procedure glSetLocalConstantEXT(id: GLuint; thetype: GLenum; addr: PGLvoid); external dllname; + procedure glVariantbvEXT(id: GLuint; addr: PGLbyte); external dllname; + procedure glVariantsvEXT(id: GLuint; addr: PGLshort); external dllname; + procedure glVariantivEXT(id: GLuint; addr: PGLint); external dllname; + procedure glVariantfvEXT(id: GLuint; addr: PGLfloat); external dllname; + procedure glVariantdvEXT(id: GLuint; addr: PGLdouble); external dllname; + procedure glVariantubvEXT(id: GLuint; addr: PGLubyte); external dllname; + procedure glVariantusvEXT(id: GLuint; addr: PGLushort); external dllname; + procedure glVariantuivEXT(id: GLuint; addr: PGLuint); external dllname; + procedure glVariantPointerEXT(id: GLuint; thetype: GLenum; stride: GLuint; addr: PGLvoid); external dllname; + procedure glEnableVariantClientStateEXT(id: GLuint); external dllname; + procedure glDisableVariantClientStateEXT(id: GLuint); external dllname; + function glBindLightParameterEXT(light: GLenum; value: GLenum): GLuint; external dllname; + function glBindMaterialParameterEXT(face: GLenum; value: GLenum): GLuint; external dllname; + function glBindTexGenParameterEXT(theunit: GLenum; coord: GLenum; value: GLenum): GLuint; external dllname; + function glBindTextureUnitParameterEXT(theunit: GLenum; value: GLenum): GLuint; external dllname; + function glBindParameterEXT(value: GLenum): GLuint; external dllname; + function glIsVariantEnabledEXT(id: GLuint; cap: GLenum): GLboolean; external dllname; + procedure glGetVariantBooleanvEXT(id: GLuint; value: GLenum; data: PGLboolean); external dllname; + procedure glGetVariantIntegervEXT(id: GLuint; value: GLenum; data: PGLint); external dllname; + procedure glGetVariantFloatvEXT(id: GLuint; value: GLenum; data: PGLfloat); external dllname; + procedure glGetVariantPointervEXT(id: GLuint; value: GLenum; data: PGLvoid); external dllname; + procedure glGetInvariantBooleanvEXT(id: GLuint; value: GLenum; data: PGLboolean); external dllname; + procedure glGetInvariantIntegervEXT(id: GLuint; value: GLenum; data: PGLint); external dllname; + procedure glGetInvariantFloatvEXT(id: GLuint; value: GLenum; data: PGLfloat); external dllname; + procedure glGetLocalConstantBooleanvEXT(id: GLuint; value: GLenum; data: PGLboolean); external dllname; + procedure glGetLocalConstantIntegervEXT(id: GLuint; value: GLenum; data: PGLint); external dllname; + procedure glGetLocalConstantFloatvEXT(id: GLuint; value: GLenum; data: PGLfloat); external dllname; + +function Load_GL_EXT_vertex_shader: Boolean; + +//***** GL_EXT_vertex_weighting *****// +const + GL_VERTEX_WEIGHTING_EXT = $8509; + GL_MODELVIEW0_EXT = $1700; + GL_MODELVIEW1_EXT = $850A; + GL_MODELVIEW0_MATRIX_EXT = $0BA6; + GL_MODELVIEW1_MATRIX_EXT = $8506; + GL_CURRENT_VERTEX_WEIGHT_EXT = $850B; + GL_VERTEX_WEIGHT_ARRAY_EXT = $850C; + GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT = $850D; + GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT = $850E; + GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT = $850F; + GL_MODELVIEW0_STACK_DEPTH_EXT = $0BA3; + GL_MODELVIEW1_STACK_DEPTH_EXT = $8502; + GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT = $8510; + + procedure glVertexWeightfEXT(weight: GLfloat); external dllname; + procedure glVertexWeightfvEXT(weight: PGLfloat); external dllname; + procedure glVertexWeightPointerEXT(size: GLint; thetype: GLenum; stride: GLsizei; pointer: PGLvoid); external dllname; + +function Load_GL_EXT_vertex_weighting: Boolean; + +//***** GL_HP_occlusion_test *****// +const + GL_OCCLUSION_TEST_HP = $8165; + GL_OCCLUSION_TEST_RESULT_HP = $8166; + +function Load_GL_HP_occlusion_test: Boolean; + +//***** GL_NV_blend_square *****// + +function Load_GL_NV_blend_square: Boolean; + +//***** GL_NV_copy_depth_to_color *****// +const + GL_DEPTH_STENCIL_TO_RGBA_NV = $886E; + GL_DEPTH_STENCIL_TO_BGRA_NV = $886F; + +function Load_GL_NV_copy_depth_to_color: Boolean; + +//***** GL_NV_depth_clamp *****// +const + GL_DEPTH_CLAMP_NV = $864F; + +function Load_GL_NV_depth_clamp: Boolean; + +//***** GL_NV_evaluators *****// +const + GL_EVAL_2D_NV = $86C0; + GL_EVAL_TRIANGULAR_2D_NV = $86C1; + GL_MAP_TESSELLATION_NV = $86C2; + GL_MAP_ATTRIB_U_ORDER_NV = $86C3; + GL_MAP_ATTRIB_V_ORDER_NV = $86C4; + GL_EVAL_FRACTIONAL_TESSELLATION_NV = $86C5; + GL_EVAL_VERTEX_ATTRIB0_NV = $86C6; + GL_EVAL_VERTEX_ATTRIB1_NV = $86C7; + GL_EVAL_VERTEX_ATTRIB2_NV = $86C8; + GL_EVAL_VERTEX_ATTRIB3_NV = $86C9; + GL_EVAL_VERTEX_ATTRIB4_NV = $86CA; + GL_EVAL_VERTEX_ATTRIB5_NV = $86CB; + GL_EVAL_VERTEX_ATTRIB6_NV = $86CC; + GL_EVAL_VERTEX_ATTRIB7_NV = $86CD; + GL_EVAL_VERTEX_ATTRIB8_NV = $86CE; + GL_EVAL_VERTEX_ATTRIB9_NV = $86CF; + GL_EVAL_VERTEX_ATTRIB10_NV = $86D0; + GL_EVAL_VERTEX_ATTRIB11_NV = $86D1; + GL_EVAL_VERTEX_ATTRIB12_NV = $86D2; + GL_EVAL_VERTEX_ATTRIB13_NV = $86D3; + GL_EVAL_VERTEX_ATTRIB14_NV = $86D4; + GL_EVAL_VERTEX_ATTRIB15_NV = $86D5; + GL_MAX_MAP_TESSELLATION_NV = $86D6; + GL_MAX_RATIONAL_EVAL_ORDER_NV = $86D7; + + procedure glMapControlPointsNV(target: GLenum; index: GLuint; thetype: GLenum; ustride: GLsizei; vstride: GLsizei; uorder: GLint; vorder: GLint; thepacked: GLboolean; const points: PGLvoid); external dllname; + procedure glMapParameterivNV(target: GLenum; pname: GLenum; const params: PGLint); external dllname; + procedure glMapParameterfvNV(target: GLenum; pname: GLenum; const params: PGLfloat); external dllname; + procedure glGetMapControlPointsNV(target: GLenum; index: GLuint; thetype: GLenum; ustride: GLsizei; vstride: GLsizei; thepacked: GLboolean; points: PGLvoid); external dllname; + procedure glGetMapParameterivNV(target: GLenum; pname: GLenum; params: PGLint); external dllname; + procedure glGetMapParameterfvNV(target: GLenum; pname: GLenum; params: PGLfloat); external dllname; + procedure glGetMapAttribParameterivNV(target: GLenum; index: GLuint; pname: GLenum; params: PGLint); external dllname; + procedure glGetMapAttribParameterfvNV(target: GLenum; index: GLuint; pname: GLenum; params: PGLfloat); external dllname; + procedure glEvalMapsNV(target: GLenum; mode: GLenum); external dllname; + +function Load_GL_NV_evaluators: Boolean; + +//***** GL_NV_fence *****// +const + GL_ALL_COMPLETED_NV = $84F2; + GL_FENCE_STATUS_NV = $84F3; + GL_FENCE_CONDITION_NV = $84F4; + + procedure glGenFencesNV(n: GLsizei; fences: PGLuint); external dllname; + procedure glDeleteFencesNV(n: GLsizei; const fences: PGLuint); external dllname; + procedure glSetFenceNV(fence: GLuint; condition: GLenum); external dllname; + function glTestFenceNV(fence: GLuint): GLboolean; external dllname; + procedure glFinishFenceNV(fence: GLuint); external dllname; + function glIsFenceNV(fence: GLuint): GLboolean; external dllname; + procedure glGetFenceivNV(fence: GLuint; pname: GLenum; params: PGLint); external dllname; + +function Load_GL_NV_fence: Boolean; + +//***** GL_NV_fog_distance *****// +const + GL_FOG_DISTANCE_MODE_NV = $855A; + GL_EYE_RADIAL_NV = $855B; + GL_EYE_PLANE_ABSOLUTE_NV = $855C; + +function Load_GL_NV_fog_distance: Boolean; + +//***** GL_NV_light_max_exponent *****// +const + GL_MAX_SHININESS_NV = $8504; + GL_MAX_SPOT_EXPONENT_NV = $8505; + +function Load_GL_NV_light_max_exponent: Boolean; + +//***** GL_NV_multisample_filter_hint *****// +const + GL_MULTISAMPLE_FILTER_HINT_NV = $8534; + +function Load_GL_NV_multisample_filter_hint: Boolean; + +//***** GL_NV_occlusion_query *****// + // GL_OCCLUSION_TEST_HP { already defined } + // GL_OCCLUSION_TEST_RESULT_HP { already defined } +const + GL_PIXEL_COUNTER_BITS_NV = $8864; + GL_CURRENT_OCCLUSION_QUERY_ID_NV = $8865; + GL_PIXEL_COUNT_NV = $8866; + GL_PIXEL_COUNT_AVAILABLE_NV = $8867; + + procedure glGenOcclusionQueriesNV(n: GLsizei; ids: PGLuint); external dllname; + procedure glDeleteOcclusionQueriesNV(n: GLsizei; const ids: PGLuint); external dllname; + function glIsOcclusionQueryNV(id: GLuint): GLboolean; external dllname; + procedure glBeginOcclusionQueryNV(id: GLuint); external dllname; + procedure glEndOcclusionQueryNV(); external dllname; + procedure glGetOcclusionQueryivNV(id: GLuint; pname: GLenum; params: PGLint); external dllname; + procedure glGetOcclusionQueryuivNV(id: GLuint; pname: GLenum; params: PGLuint); external dllname; + +function Load_GL_NV_occlusion_query: Boolean; + +//***** GL_NV_packed_depth_stencil *****// +const + GL_DEPTH_STENCIL_NV = $84F9; + GL_UNSIGNED_INT_24_8_NV = $84FA; + +function Load_GL_NV_packed_depth_stencil: Boolean; + +//***** GL_NV_point_sprite *****// +const + GL_POINT_SPRITE_NV = $8861; + GL_COORD_REPLACE_NV = $8862; + GL_POINT_SPRITE_R_MODE_NV = $8863; + + procedure glPointParameteriNV(pname: GLenum; param: GLint); external dllname; + procedure glPointParameterivNV(pname: GLenum; const params: PGLint); external dllname; + +function Load_GL_NV_point_sprite: Boolean; + +//***** GL_NV_register_combiners *****// +const + GL_REGISTER_COMBINERS_NV = $8522; + GL_COMBINER0_NV = $8550; + GL_COMBINER1_NV = $8551; + GL_COMBINER2_NV = $8552; + GL_COMBINER3_NV = $8553; + GL_COMBINER4_NV = $8554; + GL_COMBINER5_NV = $8555; + GL_COMBINER6_NV = $8556; + GL_COMBINER7_NV = $8557; + GL_VARIABLE_A_NV = $8523; + GL_VARIABLE_B_NV = $8524; + GL_VARIABLE_C_NV = $8525; + GL_VARIABLE_D_NV = $8526; + GL_VARIABLE_E_NV = $8527; + GL_VARIABLE_F_NV = $8528; + GL_VARIABLE_G_NV = $8529; + GL_CONSTANT_COLOR0_NV = $852A; + GL_CONSTANT_COLOR1_NV = $852B; + GL_PRIMARY_COLOR_NV = $852C; + GL_SECONDARY_COLOR_NV = $852D; + GL_SPARE0_NV = $852E; + GL_SPARE1_NV = $852F; + GL_UNSIGNED_IDENTITY_NV = $8536; + GL_UNSIGNED_INVERT_NV = $8537; + GL_EXPAND_NORMAL_NV = $8538; + GL_EXPAND_NEGATE_NV = $8539; + GL_HALF_BIAS_NORMAL_NV = $853A; + GL_HALF_BIAS_NEGATE_NV = $853B; + GL_SIGNED_IDENTITY_NV = $853C; + GL_SIGNED_NEGATE_NV = $853D; + GL_E_TIMES_F_NV = $8531; + GL_SPARE0_PLUS_SECONDARY_COLOR_NV = $8532; + GL_SCALE_BY_TWO_NV = $853E; + GL_SCALE_BY_FOUR_NV = $853F; + GL_SCALE_BY_ONE_HALF_NV = $8540; + GL_BIAS_BY_NEGATIVE_ONE_HALF_NV = $8541; + GL_DISCARD_NV = $8530; + GL_COMBINER_INPUT_NV = $8542; + GL_COMBINER_MAPPING_NV = $8543; + GL_COMBINER_COMPONENT_USAGE_NV = $8544; + GL_COMBINER_AB_DOT_PRODUCT_NV = $8545; + GL_COMBINER_CD_DOT_PRODUCT_NV = $8546; + GL_COMBINER_MUX_SUM_NV = $8547; + GL_COMBINER_SCALE_NV = $8548; + GL_COMBINER_BIAS_NV = $8549; + GL_COMBINER_AB_OUTPUT_NV = $854A; + GL_COMBINER_CD_OUTPUT_NV = $854B; + GL_COMBINER_SUM_OUTPUT_NV = $854C; + GL_NUM_GENERAL_COMBINERS_NV = $854E; + GL_COLOR_SUM_CLAMP_NV = $854F; + GL_MAX_GENERAL_COMBINERS_NV = $854D; + + procedure glCombinerParameterfvNV(pname: GLenum; const params: PGLfloat); external dllname; + procedure glCombinerParameterivNV(pname: GLenum; const params: PGLint); external dllname; + procedure glCombinerParameterfNV(pname: GLenum; param: GLfloat); external dllname; + procedure glCombinerParameteriNV(pname: GLenum; param: GLint); external dllname; + procedure glCombinerInputNV(stage: GLenum; portion: GLenum; variable: GLenum; input: GLenum; mapping: GLenum; componentUsage: GLenum); external dllname; + procedure glCombinerOutputNV(stage: GLenum; portion: GLenum; abOutput: GLenum; cdOutput: GLenum; sumOutput: GLenum; scale: GLenum; bias: GLenum; abDotProduct: GLboolean; cdDotProduct: GLboolean; muxSum: GLboolean); external dllname; + procedure glFinalCombinerInputNV(variable: GLenum; input: GLenum; mapping: GLenum; componentUsage: GLenum); external dllname; + procedure glGetCombinerInputParameterfvNV(stage: GLenum; portion: GLenum; variable: GLenum; pname: GLenum; params: PGLfloat); external dllname; + procedure glGetCombinerInputParameterivNV(stage: GLenum; portion: GLenum; variable: GLenum; pname: GLenum; params: PGLint); external dllname; + procedure glGetCombinerOutputParameterfvNV(stage: GLenum; portion: GLenum; pname: GLenum; params: PGLfloat); external dllname; + procedure glGetCombinerOutputParameterivNV(stage: GLenum; portion: GLenum; pname: GLenum; params: PGLint); external dllname; + procedure glGetFinalCombinerInputParameterfvNV(variable: GLenum; pname: GLenum; params: PGLfloat); external dllname; + procedure glGetFinalCombinerInputParameterivNV(variable: GLenum; pname: GLenum; params: PGLint); external dllname; + +function Load_GL_NV_register_combiners: Boolean; + +//***** GL_NV_register_combiners2 *****// +const + GL_PER_STAGE_CONSTANTS_NV = $8535; + + procedure glCombinerStageParameterfvNV(stage: GLenum; pname: GLenum; const params: PGLfloat); external dllname; + procedure glGetCombinerStageParameterfvNV(stage: GLenum; pname: GLenum; params: PGLfloat); external dllname; + +function Load_GL_NV_register_combiners2: Boolean; + +//***** GL_NV_texgen_emboss *****// +const + GL_EMBOSS_MAP_NV = $855F; + GL_EMBOSS_LIGHT_NV = $855D; + GL_EMBOSS_CONSTANT_NV = $855E; + +function Load_GL_NV_texgen_emboss: Boolean; + +//***** GL_NV_texgen_reflection *****// +const + GL_NORMAL_MAP_NV = $8511; + GL_REFLECTION_MAP_NV = $8512; + +function Load_GL_NV_texgen_reflection: Boolean; + +//***** GL_NV_texture_compression_vtc *****// + // GL_COMPRESSED_RGB_S3TC_DXT1_EXT { already defined } + // GL_COMPRESSED_RGBA_S3TC_DXT1_EXT { already defined } + // GL_COMPRESSED_RGBA_S3TC_DXT3_EXT { already defined } + // GL_COMPRESSED_RGBA_S3TC_DXT5_EXT { already defined } + +function Load_GL_NV_texture_compression_vtc: Boolean; + +//***** GL_NV_texture_env_combine4 *****// +const + GL_COMBINE4_NV = $8503; + GL_SOURCE3_RGB_NV = $8583; + GL_SOURCE3_ALPHA_NV = $858B; + GL_OPERAND3_RGB_NV = $8593; + GL_OPERAND3_ALPHA_NV = $859B; + +function Load_GL_NV_texture_env_combine4: Boolean; + +//***** GL_NV_texture_rectangle *****// +const + GL_TEXTURE_RECTANGLE_NV = $84F5; + GL_TEXTURE_BINDING_RECTANGLE_NV = $84F6; + GL_PROXY_TEXTURE_RECTANGLE_NV = $84F7; + GL_MAX_RECTANGLE_TEXTURE_SIZE_NV = $84F8; + +function Load_GL_NV_texture_rectangle: Boolean; + +//***** GL_NV_texture_shader *****// +const + GL_TEXTURE_SHADER_NV = $86DE; + GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV = $86D9; + GL_SHADER_OPERATION_NV = $86DF; + GL_CULL_MODES_NV = $86E0; + GL_OFFSET_TEXTURE_MATRIX_NV = $86E1; + GL_OFFSET_TEXTURE_SCALE_NV = $86E2; + GL_OFFSET_TEXTURE_BIAS_NV = $86E3; + GL_PREVIOUS_TEXTURE_INPUT_NV = $86E4; + GL_CONST_EYE_NV = $86E5; + GL_SHADER_CONSISTENT_NV = $86DD; + GL_PASS_THROUGH_NV = $86E6; + GL_CULL_FRAGMENT_NV = $86E7; + GL_OFFSET_TEXTURE_2D_NV = $86E8; + GL_OFFSET_TEXTURE_RECTANGLE_NV = $864C; + GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV = $864D; + GL_DEPENDENT_AR_TEXTURE_2D_NV = $86E9; + GL_DEPENDENT_GB_TEXTURE_2D_NV = $86EA; + GL_DOT_PRODUCT_NV = $86EC; + GL_DOT_PRODUCT_DEPTH_REPLACE_NV = $86ED; + GL_DOT_PRODUCT_TEXTURE_2D_NV = $86EE; + GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV = $864E; + GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV = $86F0; + GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV = $86F1; + GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV = $86F2; + GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV = $86F3; + GL_HILO_NV = $86F4; + GL_DSDT_NV = $86F5; + GL_DSDT_MAG_NV = $86F6; + GL_DSDT_MAG_VIB_NV = $86F7; + GL_UNSIGNED_INT_S8_S8_8_8_NV = $86DA; + GL_UNSIGNED_INT_8_8_S8_S8_REV_NV = $86DB; + GL_SIGNED_RGBA_NV = $86FB; + GL_SIGNED_RGBA8_NV = $86FC; + GL_SIGNED_RGB_NV = $86FE; + GL_SIGNED_RGB8_NV = $86FF; + GL_SIGNED_LUMINANCE_NV = $8701; + GL_SIGNED_LUMINANCE8_NV = $8702; + GL_SIGNED_LUMINANCE_ALPHA_NV = $8703; + GL_SIGNED_LUMINANCE8_ALPHA8_NV = $8704; + GL_SIGNED_ALPHA_NV = $8705; + GL_SIGNED_ALPHA8_NV = $8706; + GL_SIGNED_INTENSITY_NV = $8707; + GL_SIGNED_INTENSITY8_NV = $8708; + GL_SIGNED_RGB_UNSIGNED_ALPHA_NV = $870C; + GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV = $870D; + GL_HILO16_NV = $86F8; + GL_SIGNED_HILO_NV = $86F9; + GL_SIGNED_HILO16_NV = $86FA; + GL_DSDT8_NV = $8709; + GL_DSDT8_MAG8_NV = $870A; + GL_DSDT_MAG_INTENSITY_NV = $86DC; + GL_DSDT8_MAG8_INTENSITY8_NV = $870B; + GL_HI_SCALE_NV = $870E; + GL_LO_SCALE_NV = $870F; + GL_DS_SCALE_NV = $8710; + GL_DT_SCALE_NV = $8711; + GL_MAGNITUDE_SCALE_NV = $8712; + GL_VIBRANCE_SCALE_NV = $8713; + GL_HI_BIAS_NV = $8714; + GL_LO_BIAS_NV = $8715; + GL_DS_BIAS_NV = $8716; + GL_DT_BIAS_NV = $8717; + GL_MAGNITUDE_BIAS_NV = $8718; + GL_VIBRANCE_BIAS_NV = $8719; + GL_TEXTURE_BORDER_VALUES_NV = $871A; + GL_TEXTURE_HI_SIZE_NV = $871B; + GL_TEXTURE_LO_SIZE_NV = $871C; + GL_TEXTURE_DS_SIZE_NV = $871D; + GL_TEXTURE_DT_SIZE_NV = $871E; + GL_TEXTURE_MAG_SIZE_NV = $871F; + +function Load_GL_NV_texture_shader: Boolean; + +//***** GL_NV_texture_shader2 *****// +const + GL_DOT_PRODUCT_TEXTURE_3D_NV = $86EF; + // GL_HILO_NV { already defined } + // GL_DSDT_NV { already defined } + // GL_DSDT_MAG_NV { already defined } + // GL_DSDT_MAG_VIB_NV { already defined } + // GL_UNSIGNED_INT_S8_S8_8_8_NV { already defined } + // GL_UNSIGNED_INT_8_8_S8_S8_REV_NV { already defined } + // GL_SIGNED_RGBA_NV { already defined } + // GL_SIGNED_RGBA8_NV { already defined } + // GL_SIGNED_RGB_NV { already defined } + // GL_SIGNED_RGB8_NV { already defined } + // GL_SIGNED_LUMINANCE_NV { already defined } + // GL_SIGNED_LUMINANCE8_NV { already defined } + // GL_SIGNED_LUMINANCE_ALPHA_NV { already defined } + // GL_SIGNED_LUMINANCE8_ALPHA8_NV { already defined } + // GL_SIGNED_ALPHA_NV { already defined } + // GL_SIGNED_ALPHA8_NV { already defined } + // GL_SIGNED_INTENSITY_NV { already defined } + // GL_SIGNED_INTENSITY8_NV { already defined } + // GL_SIGNED_RGB_UNSIGNED_ALPHA_NV { already defined } + // GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV { already defined } + // GL_HILO16_NV { already defined } + // GL_SIGNED_HILO_NV { already defined } + // GL_SIGNED_HILO16_NV { already defined } + // GL_DSDT8_NV { already defined } + // GL_DSDT8_MAG8_NV { already defined } + // GL_DSDT_MAG_INTENSITY_NV { already defined } + // GL_DSDT8_MAG8_INTENSITY8_NV { already defined } + +function Load_GL_NV_texture_shader2: Boolean; + +//***** GL_NV_texture_shader3 *****// +const + GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV = $8850; + GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV = $8851; + GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV = $8852; + GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV = $8853; + GL_OFFSET_HILO_TEXTURE_2D_NV = $8854; + GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV = $8855; + GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV = $8856; + GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV = $8857; + GL_DEPENDENT_HILO_TEXTURE_2D_NV = $8858; + GL_DEPENDENT_RGB_TEXTURE_3D_NV = $8859; + GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV = $885A; + GL_DOT_PRODUCT_PASS_THROUGH_NV = $885B; + GL_DOT_PRODUCT_TEXTURE_1D_NV = $885C; + GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV = $885D; + GL_HILO8_NV = $885E; + GL_SIGNED_HILO8_NV = $885F; + GL_FORCE_BLUE_TO_ONE_NV = $8860; + +function Load_GL_NV_texture_shader3: Boolean; + +//***** GL_NV_vertex_array_range *****// +const + GL_VERTEX_ARRAY_RANGE_NV = $851D; + GL_VERTEX_ARRAY_RANGE_LENGTH_NV = $851E; + GL_VERTEX_ARRAY_RANGE_VALID_NV = $851F; + GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV = $8520; + GL_VERTEX_ARRAY_RANGE_POINTER_NV = $8521; + + procedure glVertexArrayRangeNV(length: GLsizei; pointer: PGLvoid); external dllname; + procedure glFlushVertexArrayRangeNV(); external dllname; + + +function Load_GL_NV_vertex_array_range: Boolean; + +//***** GL_NV_vertex_array_range2 *****// +const + GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV = $8533; + +function Load_GL_NV_vertex_array_range2: Boolean; + +//***** GL_NV_vertex_program *****// +const + GL_VERTEX_PROGRAM_NV = $8620; + GL_VERTEX_PROGRAM_POINT_SIZE_NV = $8642; + GL_VERTEX_PROGRAM_TWO_SIDE_NV = $8643; + GL_VERTEX_STATE_PROGRAM_NV = $8621; + GL_ATTRIB_ARRAY_SIZE_NV = $8623; + GL_ATTRIB_ARRAY_STRIDE_NV = $8624; + GL_ATTRIB_ARRAY_TYPE_NV = $8625; + GL_CURRENT_ATTRIB_NV = $8626; + GL_PROGRAM_PARAMETER_NV = $8644; + GL_ATTRIB_ARRAY_POINTER_NV = $8645; + GL_PROGRAM_TARGET_NV = $8646; + GL_PROGRAM_LENGTH_NV = $8627; + GL_PROGRAM_RESIDENT_NV = $8647; + GL_PROGRAM_STRING_NV = $8628; + GL_TRACK_MATRIX_NV = $8648; + GL_TRACK_MATRIX_TRANSFORM_NV = $8649; + GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV = $862E; + GL_MAX_TRACK_MATRICES_NV = $862F; + GL_CURRENT_MATRIX_STACK_DEPTH_NV = $8640; + GL_CURRENT_MATRIX_NV = $8641; + GL_VERTEX_PROGRAM_BINDING_NV = $864A; + GL_PROGRAM_ERROR_POSITION_NV = $864B; + GL_MODELVIEW_PROJECTION_NV = $8629; + GL_MATRIX0_NV = $8630; + GL_MATRIX1_NV = $8631; + GL_MATRIX2_NV = $8632; + GL_MATRIX3_NV = $8633; + GL_MATRIX4_NV = $8634; + GL_MATRIX5_NV = $8635; + GL_MATRIX6_NV = $8636; + GL_MATRIX7_NV = $8637; + GL_IDENTITY_NV = $862A; + GL_INVERSE_NV = $862B; + GL_TRANSPOSE_NV = $862C; + GL_INVERSE_TRANSPOSE_NV = $862D; + GL_VERTEX_ATTRIB_ARRAY0_NV = $8650; + GL_VERTEX_ATTRIB_ARRAY1_NV = $8651; + GL_VERTEX_ATTRIB_ARRAY2_NV = $8652; + GL_VERTEX_ATTRIB_ARRAY3_NV = $8653; + GL_VERTEX_ATTRIB_ARRAY4_NV = $8654; + GL_VERTEX_ATTRIB_ARRAY5_NV = $8655; + GL_VERTEX_ATTRIB_ARRAY6_NV = $8656; + GL_VERTEX_ATTRIB_ARRAY7_NV = $8657; + GL_VERTEX_ATTRIB_ARRAY8_NV = $8658; + GL_VERTEX_ATTRIB_ARRAY9_NV = $8659; + GL_VERTEX_ATTRIB_ARRAY10_NV = $865A; + GL_VERTEX_ATTRIB_ARRAY11_NV = $865B; + GL_VERTEX_ATTRIB_ARRAY12_NV = $865C; + GL_VERTEX_ATTRIB_ARRAY13_NV = $865D; + GL_VERTEX_ATTRIB_ARRAY14_NV = $865E; + GL_VERTEX_ATTRIB_ARRAY15_NV = $865F; + GL_MAP1_VERTEX_ATTRIB0_4_NV = $8660; + GL_MAP1_VERTEX_ATTRIB1_4_NV = $8661; + GL_MAP1_VERTEX_ATTRIB2_4_NV = $8662; + GL_MAP1_VERTEX_ATTRIB3_4_NV = $8663; + GL_MAP1_VERTEX_ATTRIB4_4_NV = $8664; + GL_MAP1_VERTEX_ATTRIB5_4_NV = $8665; + GL_MAP1_VERTEX_ATTRIB6_4_NV = $8666; + GL_MAP1_VERTEX_ATTRIB7_4_NV = $8667; + GL_MAP1_VERTEX_ATTRIB8_4_NV = $8668; + GL_MAP1_VERTEX_ATTRIB9_4_NV = $8669; + GL_MAP1_VERTEX_ATTRIB10_4_NV = $866A; + GL_MAP1_VERTEX_ATTRIB11_4_NV = $866B; + GL_MAP1_VERTEX_ATTRIB12_4_NV = $866C; + GL_MAP1_VERTEX_ATTRIB13_4_NV = $866D; + GL_MAP1_VERTEX_ATTRIB14_4_NV = $866E; + GL_MAP1_VERTEX_ATTRIB15_4_NV = $866F; + GL_MAP2_VERTEX_ATTRIB0_4_NV = $8670; + GL_MAP2_VERTEX_ATTRIB1_4_NV = $8671; + GL_MAP2_VERTEX_ATTRIB2_4_NV = $8672; + GL_MAP2_VERTEX_ATTRIB3_4_NV = $8673; + GL_MAP2_VERTEX_ATTRIB4_4_NV = $8674; + GL_MAP2_VERTEX_ATTRIB5_4_NV = $8675; + GL_MAP2_VERTEX_ATTRIB6_4_NV = $8676; + GL_MAP2_VERTEX_ATTRIB7_4_NV = $8677; + GL_MAP2_VERTEX_ATTRIB8_4_NV = $8678; + GL_MAP2_VERTEX_ATTRIB9_4_NV = $8679; + GL_MAP2_VERTEX_ATTRIB10_4_NV = $867A; + GL_MAP2_VERTEX_ATTRIB11_4_NV = $867B; + GL_MAP2_VERTEX_ATTRIB12_4_NV = $867C; + GL_MAP2_VERTEX_ATTRIB13_4_NV = $867D; + GL_MAP2_VERTEX_ATTRIB14_4_NV = $867E; + GL_MAP2_VERTEX_ATTRIB15_4_NV = $867F; + + procedure glBindProgramNV(target: GLenum; id: GLuint); external dllname; + procedure glDeleteProgramsNV(n: GLsizei; const ids: PGLuint); external dllname; + procedure glExecuteProgramNV(target: GLenum; id: GLuint; const params: PGLfloat); external dllname; + procedure glGenProgramsNV(n: GLsizei; ids: PGLuint); external dllname; + function glAreProgramsResidentNV(n: GLsizei; const ids: PGLuint; residences: PGLboolean): GLboolean; external dllname; + procedure glRequestResidentProgramsNV(n: GLsizei; ids: PGLuint); external dllname; + procedure glGetProgramParameterfvNV(target: GLenum; index: GLuint; pname: GLenum; params: PGLfloat); external dllname; + procedure glGetProgramParameterdvNV(target: GLenum; index: GLuint; pname: GLenum; params: PGLdouble); external dllname; + procedure glGetProgramivNV(id: GLuint; pname: GLenum; params: PGLint); external dllname; + procedure glGetProgramStringNV(id: GLuint; pname: GLenum; theProgram: PGLubyte); external dllname; + procedure glGetTrackMatrixivNV(target: GLenum; address: GLuint; pname: GLenum; params: PGLint); external dllname; + procedure glGetVertexAttribdvNV(index: GLuint; pname: GLenum; params: PGLdouble); external dllname; + procedure glGetVertexAttribfvNV(index: GLuint; pname: GLenum; params: PGLfloat); external dllname; + procedure glGetVertexAttribivNV(index: GLuint; pname: GLenum; params: PGLint); external dllname; + procedure glGetVertexAttribPointervNV(index: GLuint; pname: GLenum; pointer: PGLvoid); external dllname; + function glIsProgramNV(id: GLuint): GLboolean; external dllname; + procedure glLoadProgramNV(target: GLenum; id: GLuint; len: GLsizei; const theProgram: PGLubyte); external dllname; + procedure glProgramParameter4fNV(target: GLenum; index: GLuint; x: GLfloat; y: GLfloat; z: GLfloat; w: GLfloat); external dllname; + procedure glProgramParameter4fvNV(target: GLenum; index: GLuint; const params: PGLfloat); external dllname; + procedure glProgramParameters4dvNV(target: GLenum; index: GLuint; num: GLuint; const params: PGLdouble); external dllname; + procedure glProgramParameters4fvNV(target: GLenum; index: GLuint; num: GLuint; const params: PGLfloat); external dllname; + procedure glTrackMatrixNV(target: GLenum; address: GLuint; matrix: GLenum; transform: GLenum); external dllname; + procedure glVertexAttribPointerNV(index: GLuint; size: GLint; thetype: GLenum; stride: GLsizei; const pointer: PGLvoid); external dllname; + procedure glVertexAttrib1sNV(index: GLuint; x: GLshort); external dllname; + procedure glVertexAttrib1fNV(index: GLuint; x: GLfloat); external dllname; + procedure glVertexAttrib1dNV(index: GLuint; x: GLdouble); external dllname; + procedure glVertexAttrib2sNV(index: GLuint; x: GLshort; y: GLshort); external dllname; + procedure glVertexAttrib2fNV(index: GLuint; x: GLfloat; y: GLfloat); external dllname; + procedure glVertexAttrib2dNV(index: GLuint; x: GLdouble; y: GLdouble); external dllname; + procedure glVertexAttrib3sNV(index: GLuint; x: GLshort; y: GLshort; z: GLshort); external dllname; + procedure glVertexAttrib3fNV(index: GLuint; x: GLfloat; y: GLfloat; z: GLfloat); external dllname; + procedure glVertexAttrib3dNV(index: GLuint; x: GLdouble; y: GLdouble; z: GLdouble); external dllname; + procedure glVertexAttrib4sNV(index: GLuint; x: GLshort; y: GLshort; z: GLshort; w: GLshort); external dllname; + procedure glVertexAttrib4fNV(index: GLuint; x: GLfloat; y: GLfloat; z: GLfloat; w: GLfloat); external dllname; + procedure glVertexAttrib4dNV(index: GLuint; x: GLdouble; y: GLdouble; z: GLdouble; w: GLdouble); external dllname; + procedure glVertexAttrib4ubNV(index: GLuint; x: GLubyte; y: GLubyte; z: GLubyte; w: GLubyte); external dllname; + procedure glVertexAttrib1svNV(index: GLuint; const v: PGLshort); external dllname; + procedure glVertexAttrib1fvNV(index: GLuint; const v: PGLfloat); external dllname; + procedure glVertexAttrib1dvNV(index: GLuint; const v: PGLdouble); external dllname; + procedure glVertexAttrib2svNV(index: GLuint; const v: PGLshort); external dllname; + procedure glVertexAttrib2fvNV(index: GLuint; const v: PGLfloat); external dllname; + procedure glVertexAttrib2dvNV(index: GLuint; const v: PGLdouble); external dllname; + procedure glVertexAttrib3svNV(index: GLuint; const v: PGLshort); external dllname; + procedure glVertexAttrib3fvNV(index: GLuint; const v: PGLfloat); external dllname; + procedure glVertexAttrib3dvNV(index: GLuint; const v: PGLdouble); external dllname; + procedure glVertexAttrib4svNV(index: GLuint; const v: PGLshort); external dllname; + procedure glVertexAttrib4fvNV(index: GLuint; const v: PGLfloat); external dllname; + procedure glVertexAttrib4dvNV(index: GLuint; const v: PGLdouble); external dllname; + procedure glVertexAttrib4ubvNV(index: GLuint; const v: PGLubyte); external dllname; + procedure glVertexAttribs1svNV(index: GLuint; n: GLsizei; const v: PGLshort); external dllname; + procedure glVertexAttribs1fvNV(index: GLuint; n: GLsizei; const v: PGLfloat); external dllname; + procedure glVertexAttribs1dvNV(index: GLuint; n: GLsizei; const v: PGLdouble); external dllname; + procedure glVertexAttribs2svNV(index: GLuint; n: GLsizei; const v: PGLshort); external dllname; + procedure glVertexAttribs2fvNV(index: GLuint; n: GLsizei; const v: PGLfloat); external dllname; + procedure glVertexAttribs2dvNV(index: GLuint; n: GLsizei; const v: PGLdouble); external dllname; + procedure glVertexAttribs3svNV(index: GLuint; n: GLsizei; const v: PGLshort); external dllname; + procedure glVertexAttribs3fvNV(index: GLuint; n: GLsizei; const v: PGLfloat); external dllname; + procedure glVertexAttribs3dvNV(index: GLuint; n: GLsizei; const v: PGLdouble); external dllname; + procedure glVertexAttribs4svNV(index: GLuint; n: GLsizei; const v: PGLshort); external dllname; + procedure glVertexAttribs4fvNV(index: GLuint; n: GLsizei; const v: PGLfloat); external dllname; + procedure glVertexAttribs4dvNV(index: GLuint; n: GLsizei; const v: PGLdouble); external dllname; + procedure glVertexAttribs4ubvNV(index: GLuint; n: GLsizei; const v: PGLubyte); external dllname; + +function Load_GL_NV_vertex_program: Boolean; + +//***** GL_NV_vertex_program1_1 *****// + +function Load_GL_NV_vertex_program1_1: Boolean; + +//***** GL_ATI_element_array *****// +const + GL_ELEMENT_ARRAY_ATI = $8768; + GL_ELEMENT_ARRAY_TYPE_ATI = $8769; + GL_ELEMENT_ARRAY_POINTER_ATI = $876A; + + procedure glElementPointerATI(thetype: GLenum; const pointer: PGLvoid); external dllname; + procedure glDrawElementArrayATI(mode: GLenum; count: GLsizei); external dllname; + procedure glDrawRangeElementArrayATI(mode: GLenum; start: GLuint; theend: GLuint; count: GLsizei); external dllname; + +function Load_GL_ATI_element_array: Boolean; + +//***** GL_ATI_envmap_bumpmap *****// +const + GL_BUMP_ROT_MATRIX_ATI = $8775; + GL_BUMP_ROT_MATRIX_SIZE_ATI = $8776; + GL_BUMP_NUM_TEX_UNITS_ATI = $8777; + GL_BUMP_TEX_UNITS_ATI = $8778; + GL_DUDV_ATI = $8779; + GL_DU8DV8_ATI = $877A; + GL_BUMP_ENVMAP_ATI = $877B; + GL_BUMP_TARGET_ATI = $877C; + + procedure glTexBumpParameterivATI(pname: GLenum; param: PGLint); external dllname; + procedure glTexBumpParameterfvATI(pname: GLenum; param: PGLfloat); external dllname; + procedure glGetTexBumpParameterivATI(pname: GLenum; param: PGLint); external dllname; + procedure glGetTexBumpParameterfvATI(pname: GLenum; param: PGLfloat); external dllname; + +function Load_GL_ATI_envmap_bumpmap: Boolean; + +//***** GL_ATI_fragment_shader *****// +const + GL_FRAGMENT_SHADER_ATI = $8920; + GL_REG_0_ATI = $8921; + GL_REG_1_ATI = $8922; + GL_REG_2_ATI = $8923; + GL_REG_3_ATI = $8924; + GL_REG_4_ATI = $8925; + GL_REG_5_ATI = $8926; + GL_CON_0_ATI = $8941; + GL_CON_1_ATI = $8942; + GL_CON_2_ATI = $8943; + GL_CON_3_ATI = $8944; + GL_CON_4_ATI = $8945; + GL_CON_5_ATI = $8946; + GL_CON_6_ATI = $8947; + GL_CON_7_ATI = $8948; + GL_MOV_ATI = $8961; + GL_ADD_ATI = $8963; + GL_MUL_ATI = $8964; + GL_SUB_ATI = $8965; + GL_DOT3_ATI = $8966; + GL_DOT4_ATI = $8967; + GL_MAD_ATI = $8968; + GL_LERP_ATI = $8969; + GL_CND_ATI = $896A; + GL_CND0_ATI = $896B; + GL_DOT2_ADD_ATI = $896C; + GL_SECONDARY_INTERPOLATOR_ATI = $896D; + GL_SWIZZLE_STR_ATI = $8976; + GL_SWIZZLE_STQ_ATI = $8977; + GL_SWIZZLE_STR_DR_ATI = $8978; + GL_SWIZZLE_STQ_DQ_ATI = $8979; + GL_RED_BIT_ATI = $0001; + GL_GREEN_BIT_ATI = $0002; + GL_BLUE_BIT_ATI = $0004; + GL_2X_BIT_ATI = $0001; + GL_4X_BIT_ATI = $0002; + GL_8X_BIT_ATI = $0004; + GL_HALF_BIT_ATI = $0008; + GL_QUARTER_BIT_ATI = $0010; + GL_EIGHTH_BIT_ATI = $0020; + GL_SATURATE_BIT_ATI = $0040; + // GL_2X_BIT_ATI { already defined } + GL_COMP_BIT_ATI = $0002; + GL_NEGATE_BIT_ATI = $0004; + GL_BIAS_BIT_ATI = $0008; + + function glGenFragmentShadersATI(range: GLuint): GLuint; external dllname; + procedure glBindFragmentShaderATI(id: GLuint); external dllname; + procedure glDeleteFragmentShaderATI(id: GLuint); external dllname; + procedure glBeginFragmentShaderATI(); external dllname; + procedure glEndFragmentShaderATI(); external dllname; + procedure glPassTexCoordATI(dst: GLuint; coord: GLuint; swizzle: GLenum); external dllname; + procedure glSampleMapATI(dst: GLuint; interp: GLuint; swizzle: GLenum); external dllname; + procedure glColorFragmentOp1ATI(op: GLenum; dst: GLuint; dstMask: GLuint; dstMod: GLuint; arg1: GLuint; arg1Rep: GLuint; arg1Mod: GLuint); external dllname; + procedure glColorFragmentOp2ATI(op: GLenum; dst: GLuint; dstMask: GLuint; dstMod: GLuint; arg1: GLuint; arg1Rep: GLuint; arg1Mod: GLuint; arg2: GLuint; arg2Rep: GLuint; arg2Mod: GLuint); external dllname; + procedure glColorFragmentOp3ATI(op: GLenum; dst: GLuint; dstMask: GLuint; dstMod: GLuint; arg1: GLuint; arg1Rep: GLuint; arg1Mod: GLuint; arg2: GLuint; arg2Rep: GLuint; arg2Mod: GLuint; arg3: GLuint; arg3Rep: GLuint; arg3Mod: GLuint); external dllname; + procedure glAlphaFragmentOp1ATI(op: GLenum; dst: GLuint; dstMod: GLuint; arg1: GLuint; arg1Rep: GLuint; arg1Mod: GLuint); external dllname; + procedure glAlphaFragmentOp2ATI(op: GLenum; dst: GLuint; dstMod: GLuint; arg1: GLuint; arg1Rep: GLuint; arg1Mod: GLuint; arg2: GLuint; arg2Rep: GLuint; arg2Mod: GLuint); external dllname; + procedure glAlphaFragmentOp3ATI(op: GLenum; dst: GLuint; dstMod: GLuint; arg1: GLuint; arg1Rep: GLuint; arg1Mod: GLuint; arg2: GLuint; arg2Rep: GLuint; arg2Mod: GLuint; arg3: GLuint; arg3Rep: GLuint; arg3Mod: GLuint); external dllname; + procedure glSetFragmentShaderConstantATI(dst: GLuint; const value: PGLfloat); external dllname; + +function Load_GL_ATI_fragment_shader: Boolean; + +//***** GL_ATI_pn_triangles *****// +const + GL_PN_TRIANGLES_ATI = $87F0; + GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI = $87F1; + GL_PN_TRIANGLES_POINT_MODE_ATI = $87F2; + GL_PN_TRIANGLES_NORMAL_MODE_ATI = $87F3; + GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI = $87F4; + GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI = $87F5; + GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI = $87F6; + GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI = $87F7; + GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI = $87F8; + + procedure glPNTrianglesiATI(pname: GLenum; param: GLint); external dllname; + procedure glPNTrianglesfATI(pname: GLenum; param: GLfloat); external dllname; + +function Load_GL_ATI_pn_triangles: Boolean; + +//***** GL_ATI_texture_mirror_once *****// +const + GL_MIRROR_CLAMP_ATI = $8742; + GL_MIRROR_CLAMP_TO_EDGE_ATI = $8743; + +function Load_GL_ATI_texture_mirror_once: Boolean; + +//***** GL_ATI_vertex_array_object *****// +const + GL_STATIC_ATI = $8760; + GL_DYNAMIC_ATI = $8761; + GL_PRESERVE_ATI = $8762; + GL_DISCARD_ATI = $8763; + GL_OBJECT_BUFFER_SIZE_ATI = $8764; + GL_OBJECT_BUFFER_USAGE_ATI = $8765; + GL_ARRAY_OBJECT_BUFFER_ATI = $8766; + GL_ARRAY_OBJECT_OFFSET_ATI = $8767; + + function glNewObjectBufferATI(size: GLsizei; const pointer: PGLvoid; usage: GLenum): GLuint; external dllname; + function glIsObjectBufferATI(buffer: GLuint): GLboolean; external dllname; + procedure glUpdateObjectBufferATI(buffer: GLuint; offset: GLuint; size: GLsizei; const pointer: PGLvoid; preserve: GLenum); external dllname; + procedure glGetObjectBufferfvATI(buffer: GLuint; pname: GLenum; params: PGLfloat); external dllname; + procedure glGetObjectBufferivATI(buffer: GLuint; pname: GLenum; params: PGLint); external dllname; + procedure glDeleteObjectBufferATI(buffer: GLuint); external dllname; + procedure glArrayObjectATI(thearray: GLenum; size: GLint; thetype: GLenum; stride: GLsizei; buffer: GLuint; offset: GLuint); external dllname; + procedure glGetArrayObjectfvATI(thearray: GLenum; pname: GLenum; params: PGLfloat); external dllname; + procedure glGetArrayObjectivATI(thearray: GLenum; pname: GLenum; params: PGLint); external dllname; + procedure glVariantArrayObjectATI(id: GLuint; thetype: GLenum; stride: GLsizei; buffer: GLuint; offset: GLuint); external dllname; + procedure glGetVariantArrayObjectfvATI(id: GLuint; pname: GLenum; params: PGLfloat); external dllname; + procedure glGetVariantArrayObjectivATI(id: GLuint; pname: GLenum; params: PGLint); external dllname; + +function Load_GL_ATI_vertex_array_object: Boolean; + +//***** GL_ATI_vertex_streams *****// +const + GL_MAX_VERTEX_STREAMS_ATI = $876B; + GL_VERTEX_STREAM0_ATI = $876C; + GL_VERTEX_STREAM1_ATI = $876D; + GL_VERTEX_STREAM2_ATI = $876E; + GL_VERTEX_STREAM3_ATI = $876F; + GL_VERTEX_STREAM4_ATI = $8770; + GL_VERTEX_STREAM5_ATI = $8771; + GL_VERTEX_STREAM6_ATI = $8772; + GL_VERTEX_STREAM7_ATI = $8773; + GL_VERTEX_SOURCE_ATI = $8774; + + procedure glVertexStream1s(stream: GLenum; coords: GLshort); external dllname; + procedure glVertexStream1i(stream: GLenum; coords: GLint); external dllname; + procedure glVertexStream1f(stream: GLenum; coords: GLfloat); external dllname; + procedure glVertexStream1d(stream: GLenum; coords: GLdouble); external dllname; + procedure glVertexStream1sv(stream: GLenum; coords: GLshort); external dllname; + procedure glVertexStream1iv(stream: GLenum; coords: GLint); external dllname; + procedure glVertexStream1fv(stream: GLenum; coords: GLfloat); external dllname; + procedure glVertexStream1dv(stream: GLenum; coords: GLdouble); external dllname; + procedure glVertexStream2s(stream: GLenum; coords: GLshort); external dllname; + procedure glVertexStream2i(stream: GLenum; coords: GLint); external dllname; + procedure glVertexStream2f(stream: GLenum; coords: GLfloat); external dllname; + procedure glVertexStream2d(stream: GLenum; coords: GLdouble); external dllname; + procedure glVertexStream2sv(stream: GLenum; coords: GLshort); external dllname; + procedure glVertexStream2iv(stream: GLenum; coords: GLint); external dllname; + procedure glVertexStream2fv(stream: GLenum; coords: GLfloat); external dllname; + procedure glVertexStream2dv(stream: GLenum; coords: GLdouble); external dllname; + procedure glVertexStream3s(stream: GLenum; coords: GLshort); external dllname; + procedure glVertexStream3i(stream: GLenum; coords: GLint); external dllname; + procedure glVertexStream3f(stream: GLenum; coords: GLfloat); external dllname; + procedure glVertexStream3d(stream: GLenum; coords: GLdouble); external dllname; + procedure glVertexStream3sv(stream: GLenum; coords: GLshort); external dllname; + procedure glVertexStream3iv(stream: GLenum; coords: GLint); external dllname; + procedure glVertexStream3fv(stream: GLenum; coords: GLfloat); external dllname; + procedure glVertexStream3dv(stream: GLenum; coords: GLdouble); external dllname; + procedure glVertexStream4s(stream: GLenum; coords: GLshort); external dllname; + procedure glVertexStream4i(stream: GLenum; coords: GLint); external dllname; + procedure glVertexStream4f(stream: GLenum; coords: GLfloat); external dllname; + procedure glVertexStream4d(stream: GLenum; coords: GLdouble); external dllname; + procedure glVertexStream4sv(stream: GLenum; coords: GLshort); external dllname; + procedure glVertexStream4iv(stream: GLenum; coords: GLint); external dllname; + procedure glVertexStream4fv(stream: GLenum; coords: GLfloat); external dllname; + procedure glVertexStream4dv(stream: GLenum; coords: GLdouble); external dllname; + procedure glNormalStream3b(stream: GLenum; coords: GLbyte); external dllname; + procedure glNormalStream3s(stream: GLenum; coords: GLshort); external dllname; + procedure glNormalStream3i(stream: GLenum; coords: GLint); external dllname; + procedure glNormalStream3f(stream: GLenum; coords: GLfloat); external dllname; + procedure glNormalStream3d(stream: GLenum; coords: GLdouble); external dllname; + procedure glNormalStream3bv(stream: GLenum; coords: GLbyte); external dllname; + procedure glNormalStream3sv(stream: GLenum; coords: GLshort); external dllname; + procedure glNormalStream3iv(stream: GLenum; coords: GLint); external dllname; + procedure glNormalStream3fv(stream: GLenum; coords: GLfloat); external dllname; + procedure glNormalStream3dv(stream: GLenum; coords: GLdouble); external dllname; + procedure glClientActiveVertexStream(stream: GLenum); external dllname; + procedure glVertexBlendEnvi(pname: GLenum; param: GLint); external dllname; + procedure glVertexBlendEnvf(pname: GLenum; param: GLfloat); external dllname; + +function Load_GL_ATI_vertex_streams: Boolean; + +//***** GL_3DFX_texture_compression_FXT1 *****// +const + GL_COMPRESSED_RGB_FXT1_3DFX = $86B0; + GL_COMPRESSED_RGBA_FXT1_3DFX = $86B1; + +function Load_GL_3DFX_texture_compression_FXT1: Boolean; + +//***** GL_IBM_cull_vertex *****// +const + GL_CULL_VERTEX_IBM = $1928A; + +function Load_GL_IBM_cull_vertex: Boolean; + +//***** GL_IBM_multimode_draw_arrays *****// + + procedure glMultiModeDrawArraysIBM(mode: PGLenum; first: PGLint; count: PGLsizei; primcount: GLsizei; modestride: GLint); external dllname; + procedure glMultiModeDrawElementsIBM(mode: PGLenum; count: PGLsizei; thetype: GLenum; const indices: PGLvoid; primcount: GLsizei; modestride: GLint); external dllname; + +function Load_GL_IBM_multimode_draw_arrays: Boolean; + +//***** GL_IBM_raster_pos_clip *****// +const + GL_RASTER_POSITION_UNCLIPPED_IBM = $19262; + +function Load_GL_IBM_raster_pos_clip: Boolean; + +//***** GL_IBM_texture_mirrored_repeat *****// +const + GL_MIRRORED_REPEAT_IBM = $8370; + +function Load_GL_IBM_texture_mirrored_repeat: Boolean; + +//***** GL_IBM_vertex_array_lists *****// +const + GL_VERTEX_ARRAY_LIST_IBM = $1929E; + GL_NORMAL_ARRAY_LIST_IBM = $1929F; + GL_COLOR_ARRAY_LIST_IBM = $192A0; + GL_INDEX_ARRAY_LIST_IBM = $192A1; + GL_TEXTURE_COORD_ARRAY_LIST_IBM = $192A2; + GL_EDGE_FLAG_ARRAY_LIST_IBM = $192A3; + GL_FOG_COORDINATE_ARRAY_LIST_IBM = $192A4; + GL_SECONDARY_COLOR_ARRAY_LIST_IBM = $192A5; + GL_VERTEX_ARRAY_LIST_STRIDE_IBM = $192A8; + GL_NORMAL_ARRAY_LIST_STRIDE_IBM = $192A9; + GL_COLOR_ARRAY_LIST_STRIDE_IBM = $192AA; + GL_INDEX_ARRAY_LIST_STRIDE_IBM = $192AB; + GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM = $192AC; + GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM = $192AD; + GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM = $192AE; + GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM = $192AF; + + procedure glColorPointerListIBM(size: GLint; thetype: GLenum; stride: GLint; const pointer: PGLvoid; ptrstride: GLint); external dllname; + procedure glSecondaryColorPointerListIBM(size: GLint; thetype: GLenum; stride: GLint; const pointer: PGLvoid; ptrstride: GLint); external dllname; + procedure glEdgeFlagPointerListIBM(stride: GLint; const pointer: PGLboolean; ptrstride: GLint); external dllname; + procedure glFogCoordPointerListIBM(thetype: GLenum; stride: GLint; const pointer: PGLvoid; ptrstride: GLint); external dllname; + procedure glNormalPointerListIBM(thetype: GLenum; stride: GLint; const pointer: PGLvoid; ptrstride: GLint); external dllname; + procedure glTexCoordPointerListIBM(size: GLint; thetype: GLenum; stride: GLint; const pointer: PGLvoid; ptrstride: GLint); external dllname; + procedure glVertexPointerListIBM(size: GLint; thetype: GLenum; stride: GLint; const pointer: PGLvoid; ptrstride: GLint); external dllname; + +function Load_GL_IBM_vertex_array_lists: Boolean; + +//***** GL_MESA_resize_buffers *****// + procedure glResizeBuffersMESA(); external dllname; + +function Load_GL_MESA_resize_buffers: Boolean; + +//***** GL_MESA_window_pos *****// + + procedure glWindowPos2dMESA(x: GLdouble; y: GLdouble); external dllname; + procedure glWindowPos2fMESA(x: GLfloat; y: GLfloat); external dllname; + procedure glWindowPos2iMESA(x: GLint; y: GLint); external dllname; + procedure glWindowPos2sMESA(x: GLshort; y: GLshort); external dllname; + procedure glWindowPos2ivMESA(const p: PGLint); external dllname; + procedure glWindowPos2svMESA(const p: PGLshort); external dllname; + procedure glWindowPos2fvMESA(const p: PGLfloat); external dllname; + procedure glWindowPos2dvMESA(const p: PGLdouble); external dllname; + procedure glWindowPos3iMESA(x: GLint; y: GLint; z: GLint); external dllname; + procedure glWindowPos3sMESA(x: GLshort; y: GLshort; z: GLshort); external dllname; + procedure glWindowPos3fMESA(x: GLfloat; y: GLfloat; z: GLfloat); external dllname; + procedure glWindowPos3dMESA(x: GLdouble; y: GLdouble; z: GLdouble); external dllname; + procedure glWindowPos3ivMESA(const p: PGLint); external dllname; + procedure glWindowPos3svMESA(const p: PGLshort); external dllname; + procedure glWindowPos3fvMESA(const p: PGLfloat); external dllname; + procedure glWindowPos3dvMESA(const p: PGLdouble); external dllname; + procedure glWindowPos4iMESA(x: GLint; y: GLint; z: GLint; w: GLint); external dllname; + procedure glWindowPos4sMESA(x: GLshort; y: GLshort; z: GLshort; w: GLshort); external dllname; + procedure glWindowPos4fMESA(x: GLfloat; y: GLfloat; z: GLfloat; w: GLfloat); external dllname; + procedure glWindowPos4dMESA(x: GLdouble; y: GLdouble; z: GLdouble; w: GLdouble); external dllname; + procedure glWindowPos4ivMESA(const p: PGLint); external dllname; + procedure glWindowPos4svMESA(const p: PGLshort); external dllname; + procedure glWindowPos4fvMESA(const p: PGLfloat); external dllname; + procedure glWindowPos4dvMESA(const p: PGLdouble); external dllname; + +function Load_GL_MESA_window_pos: Boolean; + +//***** GL_OML_interlace *****// +const + GL_INTERLACE_OML = $8980; + GL_INTERLACE_READ_OML = $8981; + +function Load_GL_OML_interlace: Boolean; + +//***** GL_OML_resample *****// +const + GL_PACK_RESAMPLE_OML = $8984; + GL_UNPACK_RESAMPLE_OML = $8985; + GL_RESAMPLE_REPLICATE_OML = $8986; + GL_RESAMPLE_ZERO_FILL_OML = $8987; + GL_RESAMPLE_AVERAGE_OML = $8988; + GL_RESAMPLE_DECIMATE_OML = $8989; + // GL_RESAMPLE_AVERAGE_OML { already defined } + +function Load_GL_OML_resample: Boolean; + +//***** GL_OML_subsample *****// +const + GL_FORMAT_SUBSAMPLE_24_24_OML = $8982; + GL_FORMAT_SUBSAMPLE_244_244_OML = $8983; + +function Load_GL_OML_subsample: Boolean; + +//***** GL_SGIS_generate_mipmap *****// +const + GL_GENERATE_MIPMAP_SGIS = $8191; + GL_GENERATE_MIPMAP_HINT_SGIS = $8192; + +function Load_GL_SGIS_generate_mipmap: Boolean; + +//***** GL_SGIS_multisample *****// +const + GLX_SAMPLE_BUFFERS_SGIS = $186A0; + GLX_SAMPLES_SGIS = $186A1; + GL_MULTISAMPLE_SGIS = $809D; + GL_SAMPLE_ALPHA_TO_MASK_SGIS = $809E; + GL_SAMPLE_ALPHA_TO_ONE_SGIS = $809F; + GL_SAMPLE_MASK_SGIS = $80A0; + GL_MULTISAMPLE_BIT_EXT = $20000000; + GL_1PASS_SGIS = $80A1; + GL_2PASS_0_SGIS = $80A2; + GL_2PASS_1_SGIS = $80A3; + GL_4PASS_0_SGIS = $80A4; + GL_4PASS_1_SGIS = $80A5; + GL_4PASS_2_SGIS = $80A6; + GL_4PASS_3_SGIS = $80A7; + GL_SAMPLE_BUFFERS_SGIS = $80A8; + GL_SAMPLES_SGIS = $80A9; + GL_SAMPLE_MASK_VALUE_SGIS = $80AA; + GL_SAMPLE_MASK_INVERT_SGIS = $80AB; + GL_SAMPLE_PATTERN_SGIS = $80AC; + procedure glSampleMaskSGIS(value: GLclampf; invert: GLboolean); external dllname; + procedure glSamplePatternSGIS(pattern: GLenum); external dllname; + +function Load_GL_SGIS_multisample: Boolean; + +//***** GL_SGIS_pixel_texture *****// +const + GL_PIXEL_TEXTURE_SGIS = $8353; + GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS = $8354; + GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS = $8355; + GL_PIXEL_GROUP_COLOR_SGIS = $8356; + procedure glPixelTexGenParameteriSGIS(pname: GLenum; param: GLint); external dllname; + procedure glPixelTexGenParameterfSGIS(pname: GLenum; param: GLfloat); external dllname; + procedure glGetPixelTexGenParameterivSGIS(pname: GLenum; params: GLint); external dllname; + procedure glGetPixelTexGenParameterfvSGIS(pname: GLenum; params: GLfloat); external dllname; + +function Load_GL_SGIS_pixel_texture: Boolean; + +//***** GL_SGIS_texture_border_clamp *****// + // GL_CLAMP_TO_BORDER_SGIS { already defined } + +function Load_GL_SGIS_texture_border_clamp: Boolean; + +//***** GL_SGIS_texture_color_mask *****// +const + GL_TEXTURE_COLOR_WRITEMASK_SGIS = $81EF; + + procedure glTextureColorMaskSGIS(r: GLboolean; g: GLboolean; b: GLboolean; a: GLboolean); external dllname; + +function Load_GL_SGIS_texture_color_mask: Boolean; + +//***** GL_SGIS_texture_edge_clamp *****// +const + GL_CLAMP_TO_EDGE_SGIS = $812F; + +function Load_GL_SGIS_texture_edge_clamp: Boolean; + +//***** GL_SGIS_texture_lod *****// +const + GL_TEXTURE_MIN_LOD_SGIS = $813A; + GL_TEXTURE_MAX_LOD_SGIS = $813B; + GL_TEXTURE_BASE_LEVEL_SGIS = $813C; + GL_TEXTURE_MAX_LEVEL_SGIS = $813D; + +function Load_GL_SGIS_texture_lod: Boolean; + +//***** GL_SGIS_depth_texture *****// +const + GL_DEPTH_COMPONENT16_SGIX = $81A5; + GL_DEPTH_COMPONENT24_SGIX = $81A6; + GL_DEPTH_COMPONENT32_SGIX = $81A7; + +function Load_GL_SGIS_depth_texture: Boolean; + +//***** GL_SGIX_fog_offset *****// +const + GL_FOG_OFFSET_SGIX = $8198; + GL_FOG_OFFSET_VALUE_SGIX = $8199; + +function Load_GL_SGIX_fog_offset: Boolean; + +//***** GL_SGIX_interlace *****// +const + GL_INTERLACE_SGIX = $8094; + +function Load_GL_SGIX_interlace: Boolean; + +//***** GL_SGIX_shadow_ambient *****// +const + GL_SHADOW_AMBIENT_SGIX = $80BF; + +function Load_GL_SGIX_shadow_ambient: Boolean; + +//***** GL_SGI_color_matrix *****// +const + GL_COLOR_MATRIX_SGI = $80B1; + GL_COLOR_MATRIX_STACK_DEPTH_SGI = $80B2; + GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI = $80B3; + GL_POST_COLOR_MATRIX_RED_SCALE_SGI = $80B4; + GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI = $80B5; + GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI = $80B6; + GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI = $80B7; + GL_POST_COLOR_MATRIX_RED_BIAS_SGI = $80B8; + GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI = $80B9; + GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI = $80BA; + GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI = $80BB; + +function Load_GL_SGI_color_matrix: Boolean; + +//***** GL_SGI_color_table *****// +const + GL_COLOR_TABLE_SGI = $80D0; + GL_POST_CONVOLUTION_COLOR_TABLE_SGI = $80D1; + GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI = $80D2; + GL_PROXY_COLOR_TABLE_SGI = $80D3; + GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI = $80D4; + GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI = $80D5; + GL_COLOR_TABLE_SCALE_SGI = $80D6; + GL_COLOR_TABLE_BIAS_SGI = $80D7; + GL_COLOR_TABLE_FORMAT_SGI = $80D8; + GL_COLOR_TABLE_WIDTH_SGI = $80D9; + GL_COLOR_TABLE_RED_SIZE_SGI = $80DA; + GL_COLOR_TABLE_GREEN_SIZE_SGI = $80DB; + GL_COLOR_TABLE_BLUE_SIZE_SGI = $80DC; + GL_COLOR_TABLE_ALPHA_SIZE_SGI = $80DD; + GL_COLOR_TABLE_LUMINANCE_SIZE_SGI = $80DE; + GL_COLOR_TABLE_INTENSITY_SIZE_SGI = $80DF; + + procedure glColorTableSGI(target: GLenum; internalformat: GLenum; width: GLsizei; format: GLenum; thetype: GLenum; const table: PGLvoid); external dllname; + procedure glCopyColorTableSGI(target: GLenum; internalformat: GLenum; x: GLint; y: GLint; width: GLsizei); external dllname; + procedure glColorTableParameterivSGI(target: GLenum; pname: GLenum; const params: PGLint); external dllname; + procedure glColorTableParameterfvSGI(target: GLenum; pname: GLenum; const params: PGLfloat); external dllname; + procedure glGetColorTableSGI(target: GLenum; format: GLenum; thetype: GLenum; table: PGLvoid); external dllname; + procedure glGetColorTableParameterivSGI(target: GLenum; pname: GLenum; params: PGLint); external dllname; + procedure glGetColorTableParameterfvSGI(target: GLenum; pname: GLenum; params: PGLfloat); external dllname; + +function Load_GL_SGI_color_table: Boolean; + +//***** GL_SGI_texture_color_table *****// +const + GL_TEXTURE_COLOR_TABLE_SGI = $80BC; + GL_PROXY_TEXTURE_COLOR_TABLE_SGI = $80BD; + +function Load_GL_SGI_texture_color_table: Boolean; + +//***** GL_SUN_vertex *****// + + procedure glColor4ubVertex2fSUN(r: GLubyte; g: GLubyte; b: GLubyte; a: GLubyte; x: GLfloat; y: GLfloat); external dllname; + procedure glColor4ubVertex2fvSUN(const c: PGLubyte; const v: PGLfloat); external dllname; + procedure glColor4ubVertex3fSUN(r: GLubyte; g: GLubyte; b: GLubyte; a: GLubyte; x: GLfloat; y: GLfloat; z: GLfloat); external dllname; + procedure glColor4ubVertex3fvSUN(const c: PGLubyte; const v: PGLfloat); external dllname; + procedure glColor3fVertex3fSUN(r: GLfloat; g: GLfloat; b: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat); external dllname; + procedure glColor3fVertex3fvSUN(const c: PGLfloat; const v: PGLfloat); external dllname; + procedure glNormal3fVertex3fSUN(nx: GLfloat; ny: GLfloat; nz: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat); external dllname; + procedure glNormal3fVertex3fvSUN(const n: PGLfloat; const v: PGLfloat); external dllname; + procedure glColor4fNormal3fVertex3fSUN(r: GLfloat; g: GLfloat; b: GLfloat; a: GLfloat; nx: GLfloat; ny: GLfloat; nz: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat); external dllname; + procedure glColor4fNormal3fVertex3fvSUN(const c: PGLfloat; const n: PGLfloat; const v: PGLfloat); external dllname; + procedure glTexCoord2fVertex3fSUN(s: GLfloat; t: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat); external dllname; + procedure glTexCoord2fVertex3fvSUN(const tc: PGLfloat; const v: PGLfloat); external dllname; + procedure glTexCoord4fVertex4fSUN(s: GLfloat; t: GLfloat; p: GLfloat; q: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat; w: GLfloat); external dllname; + procedure glTexCoord4fVertex4fvSUN(const tc: PGLfloat; const v: PGLfloat); external dllname; + procedure glTexCoord2fColor4ubVertex3fSUN(s: GLfloat; t: GLfloat; r: GLubyte; g: GLubyte; b: GLubyte; a: GLubyte; x: GLfloat; y: GLfloat; z: GLfloat); external dllname; + procedure glTexCoord2fColor4ubVertex3fvSUN(const tc: PGLfloat; const c: PGLubyte; const v: PGLfloat); external dllname; + procedure glTexCoord2fColor3fVertex3fSUN(s: GLfloat; t: GLfloat; r: GLfloat; g: GLfloat; b: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat); external dllname; + procedure glTexCoord2fColor3fVertex3fvSUN(const tc: PGLfloat; const c: PGLfloat; const v: PGLfloat); external dllname; + procedure glTexCoord2fNormal3fVertex3fSUN(s: GLfloat; t: GLfloat; nx: GLfloat; ny: GLfloat; nz: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat); external dllname; + procedure glTexCoord2fNormal3fVertex3fvSUN(const tc: PGLfloat; const n: PGLfloat; const v: PGLfloat); external dllname; + procedure glTexCoord2fColor4fNormal3fVertex3fSUN(s: GLfloat; t: GLfloat; r: GLfloat; g: GLfloat; b: GLfloat; a: GLfloat; nx: GLfloat; ny: GLfloat; nz: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat); external dllname; + procedure glTexCoord2fColor4fNormal3fVertex3fvSUN(const tc: PGLfloat; const c: PGLfloat; const n: PGLfloat; const v: PGLfloat); external dllname; + procedure glTexCoord4fColor4fNormal3fVertex4fSUN(s: GLfloat; t: GLfloat; p: GLfloat; q: GLfloat; r: GLfloat; g: GLfloat; b: GLfloat; a: GLfloat; nx: GLfloat; ny: GLfloat; nz: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat; w: GLfloat); external dllname; + procedure glTexCoord4fColor4fNormal3fVertex4fvSUN(const tc: PGLfloat; const c: PGLfloat; const n: PGLfloat; const v: PGLfloat); external dllname; + procedure glReplacementCodeuiVertex3fSUN(rc: GLuint; x: GLfloat; y: GLfloat; z: GLfloat); external dllname; + procedure glReplacementCodeuiVertex3fvSUN(const rc: PGLuint; const v: PGLfloat); external dllname; + procedure glReplacementCodeuiColor4ubVertex3fSUN(rc: GLuint; r: GLubyte; g: GLubyte; b: GLubyte; a: GLubyte; x: GLfloat; y: GLfloat; z: GLfloat); external dllname; + procedure glReplacementCodeuiColor4ubVertex3fvSUN(const rc: PGLuint; const c: PGLubyte; const v: PGLfloat); external dllname; + procedure glReplacementCodeuiColor3fVertex3fSUN(rc: GLuint; r: GLfloat; g: GLfloat; b: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat); external dllname; + procedure glReplacementCodeuiColor3fVertex3fvSUN(const rc: PGLuint; const c: PGLfloat; const v: PGLfloat); external dllname; + procedure glReplacementCodeuiNormal3fVertex3fSUN(rc: GLuint; nx: GLfloat; ny: GLfloat; nz: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat); external dllname; + procedure glReplacementCodeuiNormal3fVertex3fvSUN(const rc: PGLuint; const n: PGLfloat; const v: PGLfloat); external dllname; + procedure glReplacementCodeuiColor4fNormal3fVertex3fSUN(rc: GLuint; r: GLfloat; g: GLfloat; b: GLfloat; a: GLfloat; nx: GLfloat; ny: GLfloat; nz: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat); external dllname; + procedure glReplacementCodeuiColor4fNormal3fVertex3fvSUN(const rc: PGLuint; const c: PGLfloat; const n: PGLfloat; const v: PGLfloat); external dllname; + procedure glReplacementCodeuiTexCoord2fVertex3fSUN(rc: GLuint; s: GLfloat; t: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat); external dllname; + procedure glReplacementCodeuiTexCoord2fVertex3fvSUN(const rc: PGLuint; const tc: PGLfloat; const v: PGLfloat); external dllname; + procedure glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN(rc: GLuint; s: GLfloat; t: GLfloat; nx: GLfloat; ny: GLfloat; nz: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat); external dllname; + procedure glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN(const rc: PGLuint; const tc: PGLfloat; const n: PGLfloat; const v: PGLfloat); external dllname; + procedure glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN(rc: GLuint; s: GLfloat; t: GLfloat; r: GLfloat; g: GLfloat; b: GLfloat; a: GLfloat; nx: GLfloat; ny: GLfloat; nz: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat); external dllname; + procedure glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN(const rc: PGLuint; const tc: PGLfloat; const c: PGLfloat; const n: PGLfloat; const v: PGLfloat); external dllname; + +function Load_GL_SUN_vertex: Boolean; + +//***** GL_ARB_fragment_program *****// +const + GL_FRAGMENT_PROGRAM_ARB = $8804; + // GL_PROGRAM_FORMAT_ASCII_ARB { already defined } + // GL_PROGRAM_LENGTH_ARB { already defined } + // GL_PROGRAM_FORMAT_ARB { already defined } + // GL_PROGRAM_BINDING_ARB { already defined } + // GL_PROGRAM_INSTRUCTIONS_ARB { already defined } + // GL_MAX_PROGRAM_INSTRUCTIONS_ARB { already defined } + // GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB { already defined } + // GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB { already defined } + // GL_PROGRAM_TEMPORARIES_ARB { already defined } + // GL_MAX_PROGRAM_TEMPORARIES_ARB { already defined } + // GL_PROGRAM_NATIVE_TEMPORARIES_ARB { already defined } + // GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB { already defined } + // GL_PROGRAM_PARAMETERS_ARB { already defined } + // GL_MAX_PROGRAM_PARAMETERS_ARB { already defined } + // GL_PROGRAM_NATIVE_PARAMETERS_ARB { already defined } + // GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB { already defined } + // GL_PROGRAM_ATTRIBS_ARB { already defined } + // GL_MAX_PROGRAM_ATTRIBS_ARB { already defined } + // GL_PROGRAM_NATIVE_ATTRIBS_ARB { already defined } + // GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB { already defined } + // GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB { already defined } + // GL_MAX_PROGRAM_ENV_PARAMETERS_ARB { already defined } + // GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB { already defined } + GL_PROGRAM_ALU_INSTRUCTIONS_ARB = $8805; + GL_PROGRAM_TEX_INSTRUCTIONS_ARB = $8806; + GL_PROGRAM_TEX_INDIRECTIONS_ARB = $8807; + GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB = $8808; + GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB = $8809; + GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB = $880A; + GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB = $880B; + GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB = $880C; + GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB = $880D; + GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB = $880E; + GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB = $880F; + GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB = $8810; + // GL_PROGRAM_STRING_ARB { already defined } + // GL_PROGRAM_ERROR_POSITION_ARB { already defined } + // GL_CURRENT_MATRIX_ARB { already defined } + // GL_TRANSPOSE_CURRENT_MATRIX_ARB { already defined } + // GL_CURRENT_MATRIX_STACK_DEPTH_ARB { already defined } + // GL_MAX_PROGRAM_MATRICES_ARB { already defined } + // GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB { already defined } + GL_MAX_TEXTURE_COORDS_ARB = $8871; + GL_MAX_TEXTURE_IMAGE_UNITS_ARB = $8872; + // GL_PROGRAM_ERROR_STRING_ARB { already defined } + // GL_MATRIX0_ARB { already defined } + // GL_MATRIX1_ARB { already defined } + // GL_MATRIX2_ARB { already defined } + // GL_MATRIX3_ARB { already defined } + // GL_MATRIX4_ARB { already defined } + // GL_MATRIX5_ARB { already defined } + // GL_MATRIX6_ARB { already defined } + // GL_MATRIX7_ARB { already defined } + // GL_MATRIX8_ARB { already defined } + // GL_MATRIX9_ARB { already defined } + // GL_MATRIX10_ARB { already defined } + // GL_MATRIX11_ARB { already defined } + // GL_MATRIX12_ARB { already defined } + // GL_MATRIX13_ARB { already defined } + // GL_MATRIX14_ARB { already defined } + // GL_MATRIX15_ARB { already defined } + // GL_MATRIX16_ARB { already defined } + // GL_MATRIX17_ARB { already defined } + // GL_MATRIX18_ARB { already defined } + // GL_MATRIX19_ARB { already defined } + // GL_MATRIX20_ARB { already defined } + // GL_MATRIX21_ARB { already defined } + // GL_MATRIX22_ARB { already defined } + // GL_MATRIX23_ARB { already defined } + // GL_MATRIX24_ARB { already defined } + // GL_MATRIX25_ARB { already defined } + // GL_MATRIX26_ARB { already defined } + // GL_MATRIX27_ARB { already defined } + // GL_MATRIX28_ARB { already defined } + // GL_MATRIX29_ARB { already defined } + // GL_MATRIX30_ARB { already defined } + // GL_MATRIX31_ARB { already defined } + // glProgramStringARB { already defined } + // glBindProgramARB { already defined } + // glDeleteProgramsARB { already defined } + // glGenProgramsARB { already defined } + // glProgramEnvParameter4dARB { already defined } + // glProgramEnvParameter4dvARB { already defined } + // glProgramEnvParameter4fARB { already defined } + // glProgramEnvParameter4fvARB { already defined } + // glProgramLocalParameter4dARB { already defined } + // glProgramLocalParameter4dvARB { already defined } + // glProgramLocalParameter4fARB { already defined } + // glProgramLocalParameter4fvARB { already defined } + // glGetProgramEnvParameterdvARB { already defined } + // glGetProgramEnvParameterfvARB { already defined } + // glGetProgramLocalParameterdvARB { already defined } + // glGetProgramLocalParameterfvARB { already defined } + // glGetProgramivARB { already defined } + // glGetProgramStringARB { already defined } + // glIsProgramARB { already defined } + +function Load_GL_ARB_fragment_program: Boolean; + +{***** GL_ATI_text_fragment_shader *****} +const + GL_TEXT_FRAGMENT_SHADER_ATI = $8200; + +{***** GL_ARB_vertex_buffer_object *****} +const + GL_BUFFER_SIZE_ARB = $8764; + GL_BUFFER_USAGE_ARB = $8765; + GL_ARRAY_BUFFER_ARB = $8892; + GL_ELEMENT_ARRAY_BUFFER_ARB = $8893; + GL_ARRAY_BUFFER_BINDING_ARB = $8894; + GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB = $8895; + GL_VERTEX_ARRAY_BUFFER_BINDING_ARB = $8896; + GL_NORMAL_ARRAY_BUFFER_BINDING_ARB = $8897; + GL_COLOR_ARRAY_BUFFER_BINDING_ARB = $8898; + GL_INDEX_ARRAY_BUFFER_BINDING_ARB = $8899; + GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB = $889A; + GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB = $889B; + GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB = $889C; + GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB = $889D; + GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB = $889E; + GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB = $889F; + GL_READ_ONLY_ARB = $88B8; + GL_WRITE_ONLY_ARB = $88B9; + GL_READ_WRITE_ARB = $88BA; + GL_BUFFER_ACCESS_ARB = $88BB; + GL_BUFFER_MAPPED_ARB = $88BC; + GL_BUFFER_MAP_POINTER_ARB = $88BD; + GL_STREAM_DRAW_ARB = $88E0; + GL_STREAM_READ_ARB = $88E1; + GL_STREAM_COPY_ARB = $88E2; + GL_STATIC_DRAW_ARB = $88E4; + GL_STATIC_READ_ARB = $88E5; + GL_STATIC_COPY_ARB = $88E6; + GL_DYNAMIC_DRAW_ARB = $88E8; + GL_DYNAMIC_READ_ARB = $88E9; + GL_DYNAMIC_COPY_ARB = $88EA; + + + procedure glBindBufferARB(target : GLenum; buffer: GLuint); external dllname; + procedure glDeleteBuffersARB(n : GLsizei; buffers : PGLuint); external dllname; + procedure glGenBuffersARB(n : GLsizei; buffers : PGLuint); external dllname; + function glIsBufferARB (buffer : GLuint) :GLboolean; external dllname; + procedure glBufferDataARB(target : GLenum; size:GLsizei; data:PGLvoid;usage: GLenum); external dllname; + procedure glBufferSubDataARB(target : GLenum; offset :GLint; size : GLsizei; data: PGLvoid); external dllname; + procedure glGetBufferSubDataARB(target : GLenum; offset :GLint; size : GLsizei; data: PGLvoid); external dllname; + function glMapBufferARB (target :GLenum; access: GLenum) : PGLvoid; external dllname; + function glUnmapBufferARB (target :GLenum) :GLboolean; external dllname; + procedure glGetBufferParameterivARB(target:GLenum; pname:GLenum; params:PGLint); external dllname; + procedure glGetBufferPointervARB(target: GLenum; pname:GLenum; params: PPGLvoid); external dllname; + function Load_GL_ARB_vertex_buffer_object: boolean; + +function Load_GL_ATI_text_fragment_shader: Boolean; + +//***** GL_APPLE_client_storage *****// +const + GL_UNPACK_CLIENT_STORAGE_APPLE = $85B2; + +function Load_GL_APPLE_client_storage: Boolean; + +//***** GL_APPLE_element_array *****// +const + GL_ELEMENT_ARRAY_APPLE = $8768; + GL_ELEMENT_ARRAY_TYPE_APPLE = $8769; + GL_ELEMENT_ARRAY_POINTER_APPLE = $876A; + procedure glElementPointerAPPLE(thetype: GLenum; const pointer: PGLvoid); external dllname; + procedure glDrawElementArrayAPPLE(mode: GLenum; first: GLint; count: GLsizei); external dllname; + procedure glDrawRangeElementArrayAPPLE(mode: GLenum; start: GLuint; theend: GLuint; first: GLint; count: GLsizei); external dllname; + procedure glMultiDrawElementArrayAPPLE(mode: GLenum; const first: PGLint; const count: PGLsizei; primcount: GLsizei); external dllname; + procedure glMultiDrawRangeElementArrayAPPLE(mode: GLenum; start: GLuint; theend: GLuint; const first: PGLint; const count: PGLsizei; primcount: GLsizei); external dllname; + +function Load_GL_APPLE_element_array: Boolean; + +//***** GL_APPLE_fence *****// +const + GL_DRAW_PIXELS_APPLE = $8A0A; + GL_FENCE_APPLE = $8A0B; + + procedure glGenFencesAPPLE(n: GLsizei; fences: PGLuint); external dllname; + procedure glDeleteFencesAPPLE(n: GLsizei; const fences: PGLuint); external dllname; + procedure glSetFenceAPPLE(fence: GLuint); external dllname; + function glIsFenceAPPLE(fence: GLuint): GLboolean; external dllname; + function glTestFenceAPPLE(fence: GLuint): GLboolean; external dllname; + procedure glFinishFenceAPPLE(fence: GLuint); external dllname; + function glTestObjectAPPLE(theobject: GLenum; name: GLuint): GLboolean; external dllname; + procedure glFinishObjectAPPLE(theobject: GLenum; name: GLint); external dllname; + +function Load_GL_APPLE_fence: Boolean; + +//***** GL_APPLE_vertex_array_object *****// +const + GL_VERTEX_ARRAY_BINDING_APPLE = $85B5; + procedure glBindVertexArrayAPPLE(thearray: GLuint); external dllname; + procedure glDeleteVertexArraysAPPLE(n: GLsizei; const arrays: PGLuint); external dllname; + procedure glGenVertexArraysAPPLE(n: GLsizei; const arrays: PGLuint); external dllname; + function glIsVertexArrayAPPLE(thearray: GLuint): GLboolean; external dllname; + +function Load_GL_APPLE_vertex_array_object: Boolean; + +//***** GL_APPLE_vertex_array_range *****// +const + GL_VERTEX_ARRAY_RANGE_APPLE = $851D; + GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE = $851E; + GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_APPLE = $8520; + GL_VERTEX_ARRAY_RANGE_POINTER_APPLE = $8521; + GL_VERTEX_ARRAY_STORAGE_HINT_APPLE = $851F; + GL_STORAGE_CACHED_APPLE = $85BE; + GL_STORAGE_SHARED_APPLE = $85BF; + + procedure glVertexArrayRangeAPPLE(length: GLsizei; pointer: PGLvoid); external dllname; + procedure glFlushVertexArrayRangeAPPLE(length: GLsizei; pointer: PGLvoid); external dllname; + procedure glVertexArrayParameteriAPPLE(pname: GLenum; param: GLint); external dllname; + +function Load_GL_APPLE_vertex_array_range: Boolean; + +//***** GL_ARB_matrix_palette *****// +const + GL_MATRIX_PALETTE_ARB = $8840; + GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB = $8841; + GL_MAX_PALETTE_MATRICES_ARB = $8842; + GL_CURRENT_PALETTE_MATRIX_ARB = $8843; + GL_MATRIX_INDEX_ARRAY_ARB = $8844; + GL_CURRENT_MATRIX_INDEX_ARB = $8845; + GL_MATRIX_INDEX_ARRAY_SIZE_ARB = $8846; + GL_MATRIX_INDEX_ARRAY_TYPE_ARB = $8847; + GL_MATRIX_INDEX_ARRAY_STRIDE_ARB = $8848; + GL_MATRIX_INDEX_ARRAY_POINTER_ARB = $8849; + + procedure glCurrentPaletteMatrixARB(index: GLint); external dllname; + procedure glMatrixIndexubvARB(size: GLint; indices: PGLubyte); external dllname; + procedure glMatrixIndexusvARB(size: GLint; indices: PGLushort); external dllname; + procedure glMatrixIndexuivARB(size: GLint; indices: PGLuint); external dllname; + procedure glMatrixIndexPointerARB(size: GLint; thetype: GLenum; stride: GLsizei; pointer: PGLvoid); external dllname; + +function Load_GL_ARB_matrix_palette: Boolean; + +//***** GL_NV_element_array *****// +const + GL_ELEMENT_ARRAY_TYPE_NV = $8769; + GL_ELEMENT_ARRAY_POINTER_NV = $876A; + + procedure glElementPointerNV(thetype: GLenum; const pointer: PGLvoid); external dllname; + procedure glDrawElementArrayNV(mode: GLenum; first: GLint; count: GLsizei); external dllname; + procedure glDrawRangeElementArrayNV(mode: GLenum; start: GLuint; theend: GLuint; first: GLint; count: GLsizei); external dllname; + procedure glMultiDrawElementArrayNV(mode: GLenum; const first: PGLint; const count: PGLsizei; primcount: GLsizei); external dllname; + procedure glMultiDrawRangeElementArrayNV(mode: GLenum; start: GLuint; theend: GLuint; const first: PGLint; const count: PGLsizei; primcount: GLsizei); external dllname; + +function Load_GL_NV_element_array: Boolean; + +//***** GL_NV_float_buffer *****// +const + GL_FLOAT_R_NV = $8880; + GL_FLOAT_RG_NV = $8881; + GL_FLOAT_RGB_NV = $8882; + GL_FLOAT_RGBA_NV = $8883; + GL_FLOAT_R16_NV = $8884; + GL_FLOAT_R32_NV = $8885; + GL_FLOAT_RG16_NV = $8886; + GL_FLOAT_RG32_NV = $8887; + GL_FLOAT_RGB16_NV = $8888; + GL_FLOAT_RGB32_NV = $8889; + GL_FLOAT_RGBA16_NV = $888A; + GL_FLOAT_RGBA32_NV = $888B; + GL_TEXTURE_FLOAT_COMPONENTS_NV = $888C; + GL_FLOAT_CLEAR_COLOR_VALUE_NV = $888D; + GL_FLOAT_RGBA_MODE_NV = $888E; + +function Load_GL_NV_float_buffer: Boolean; + +//***** GL_NV_fragment_program *****// +const + GL_FRAGMENT_PROGRAM_NV = $8870; + GL_MAX_TEXTURE_COORDS_NV = $8871; + GL_MAX_TEXTURE_IMAGE_UNITS_NV = $8872; + GL_FRAGMENT_PROGRAM_BINDING_NV = $8873; + GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV = $8868; + GL_PROGRAM_ERROR_STRING_NV = $8874; + + procedure glProgramNamedParameter4fNV(id: GLuint; len: GLsizei; const name: PGLubyte; x: GLfloat; y: GLfloat; z: GLfloat; w: GLfloat); external dllname; + procedure glProgramNamedParameter4dNV(id: GLuint; len: GLsizei; const name: PGLubyte; x: GLdouble; y: GLdouble; z: GLdouble; w: GLdouble); external dllname; + procedure glGetProgramNamedParameterfvNV(id: GLuint; len: GLsizei; const name: PGLubyte; params: PGLfloat); external dllname; + procedure glGetProgramNamedParameterdvNV(id: GLuint; len: GLsizei; const name: PGLubyte; params: PGLdouble); external dllname; + // glProgramLocalParameter4dARB { already defined } + // glProgramLocalParameter4dvARB { already defined } + // glProgramLocalParameter4fARB { already defined } + // glProgramLocalParameter4fvARB { already defined } + // glGetProgramLocalParameterdvARB { already defined } + // glGetProgramLocalParameterfvARB { already defined } + +function Load_GL_NV_fragment_program: Boolean; + +//***** GL_NV_primitive_restart *****// +const + GL_PRIMITIVE_RESTART_NV = $8558; + GL_PRIMITIVE_RESTART_INDEX_NV = $8559; + + procedure glPrimitiveRestartNV(); external dllname; + procedure glPrimitiveRestartIndexNV(index: GLuint); external dllname; + +function Load_GL_NV_primitive_restart: Boolean; + +//***** GL_NV_vertex_program2 *****// + +function Load_GL_NV_vertex_program2: Boolean; + + +//***** GL_NV_pixel_data_range *****// +const + GL_WRITE_PIXEL_DATA_RANGE_NV = $8878; + GL_READ_PIXEL_DATA_RANGE_NV = $8879; + GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV = $887A; + GL_READ_PIXEL_DATA_RANGE_LENGTH_NV = $887B; + GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV = $887C; + GL_READ_PIXEL_DATA_RANGE_POINTER_NV = $887D; + + procedure glPixelDataRangeNV(target: GLenum; length: GLsizei; pointer: PGLvoid); external dllname; + procedure glFlushPixelDataRangeNV(target: GLenum); external dllname; + // wglAllocateMemoryNV { already defined } + // wglFreeMemoryNV { already defined } + +function Load_GL_NV_pixel_data_range: Boolean; + +//***** GL_EXT_texture_rectangle *****// +const + GL_TEXTURE_RECTANGLE_EXT = $84F5; + GL_TEXTURE_BINDING_RECTANGLE_EXT = $84F6; + GL_PROXY_TEXTURE_RECTANGLE_EXT = $84F7; + GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT = $84F8; + +function Load_GL_EXT_texture_rectangle: Boolean; + +//***** GL_S3_s3tc *****// +const + GL_RGB_S3TC = $83A0; + GL_RGB4_S3TC = $83A1; + GL_RGBA_S3TC = $83A2; + GL_RGBA4_S3TC = $83A3; + +function Load_GL_S3_s3tc: Boolean; + +//***** GL_ATI_draw_buffers *****// +const + GL_MAX_DRAW_BUFFERS_ATI = $8824; + GL_DRAW_BUFFER0_ATI = $8825; + GL_DRAW_BUFFER1_ATI = $8826; + GL_DRAW_BUFFER2_ATI = $8827; + GL_DRAW_BUFFER3_ATI = $8828; + GL_DRAW_BUFFER4_ATI = $8829; + GL_DRAW_BUFFER5_ATI = $882A; + GL_DRAW_BUFFER6_ATI = $882B; + GL_DRAW_BUFFER7_ATI = $882C; + GL_DRAW_BUFFER8_ATI = $882D; + GL_DRAW_BUFFER9_ATI = $882E; + GL_DRAW_BUFFER10_ATI = $882F; + GL_DRAW_BUFFER11_ATI = $8830; + GL_DRAW_BUFFER12_ATI = $8831; + GL_DRAW_BUFFER13_ATI = $8832; + GL_DRAW_BUFFER14_ATI = $8833; + GL_DRAW_BUFFER15_ATI = $8834; + + procedure glDrawBuffersATI(n: GLsizei; const bufs: PGLenum); external dllname; + +function Load_GL_ATI_draw_buffers: Boolean; + + +//***** GL_ATI_texture_env_combine3 *****// +const + GL_MODULATE_ADD_ATI = $8744; + GL_MODULATE_SIGNED_ADD_ATI = $8745; + GL_MODULATE_SUBTRACT_ATI = $8746; + +function Load_GL_ATI_texture_env_combine3: Boolean; + +//***** GL_ATI_texture_float *****// +const + GL_RGBA_FLOAT32_ATI = $8814; + GL_RGB_FLOAT32_ATI = $8815; + GL_ALPHA_FLOAT32_ATI = $8816; + GL_INTENSITY_FLOAT32_ATI = $8817; + GL_LUMINANCE_FLOAT32_ATI = $8818; + GL_LUMINANCE_ALPHA_FLOAT32_ATI = $8819; + GL_RGBA_FLOAT16_ATI = $881A; + GL_RGB_FLOAT16_ATI = $881B; + GL_ALPHA_FLOAT16_ATI = $881C; + GL_INTENSITY_FLOAT16_ATI = $881D; + GL_LUMINANCE_FLOAT16_ATI = $881E; + GL_LUMINANCE_ALPHA_FLOAT16_ATI = $881F; + +function Load_GL_ATI_texture_float: Boolean; + +//***** GL_NV_texture_expand_normal *****// +const + GL_TEXTURE_UNSIGNED_REMAP_MODE_NV = $888F; + +function Load_GL_NV_texture_expand_normal: Boolean; + +//***** GL_NV_half_float *****// +const + GL_HALF_FLOAT_NV = $140B; + + procedure glVertex2hNV(x: GLushort; y: GLushort); external dllname; + procedure glVertex2hvNV(const v: PGLushort); external dllname; + procedure glVertex3hNV(x: GLushort; y: GLushort; z: GLushort); external dllname; + procedure glVertex3hvNV(const v: PGLushort); external dllname; + procedure glVertex4hNV(x: GLushort; y: GLushort; z: GLushort; w: GLushort); external dllname; + procedure glVertex4hvNV(const v: PGLushort); external dllname; + procedure glNormal3hNV(nx: GLushort; ny: GLushort; nz: GLushort); external dllname; + procedure glNormal3hvNV(const v: PGLushort); external dllname; + procedure glColor3hNV(red: GLushort; green: GLushort; blue: GLushort); external dllname; + procedure glColor3hvNV(const v: PGLushort); external dllname; + procedure glColor4hNV(red: GLushort; green: GLushort; blue: GLushort; alpha: GLushort); external dllname; + procedure glColor4hvNV(const v: PGLushort); external dllname; + procedure glTexCoord1hNV(s: GLushort); external dllname; + procedure glTexCoord1hvNV(const v: PGLushort); external dllname; + procedure glTexCoord2hNV(s: GLushort; t: GLushort); external dllname; + procedure glTexCoord2hvNV(const v: PGLushort); external dllname; + procedure glTexCoord3hNV(s: GLushort; t: GLushort; r: GLushort); external dllname; + procedure glTexCoord3hvNV(const v: PGLushort); external dllname; + procedure glTexCoord4hNV(s: GLushort; t: GLushort; r: GLushort; q: GLushort); external dllname; + procedure glTexCoord4hvNV(const v: PGLushort); external dllname; + procedure glMultiTexCoord1hNV(target: GLenum; s: GLushort); external dllname; + procedure glMultiTexCoord1hvNV(target: GLenum; const v: PGLushort); external dllname; + procedure glMultiTexCoord2hNV(target: GLenum; s: GLushort; t: GLushort); external dllname; + procedure glMultiTexCoord2hvNV(target: GLenum; const v: PGLushort); external dllname; + procedure glMultiTexCoord3hNV(target: GLenum; s: GLushort; t: GLushort; r: GLushort); external dllname; + procedure glMultiTexCoord3hvNV(target: GLenum; const v: PGLushort); external dllname; + procedure glMultiTexCoord4hNV(target: GLenum; s: GLushort; t: GLushort; r: GLushort; q: GLushort); external dllname; + procedure glMultiTexCoord4hvNV(target: GLenum; const v: PGLushort); external dllname; + procedure glFogCoordhNV(fog: GLushort); external dllname; + procedure glFogCoordhvNV(const fog: PGLushort); external dllname; + procedure glSecondaryColor3hNV(red: GLushort; green: GLushort; blue: GLushort); external dllname; + procedure glSecondaryColor3hvNV(const v: PGLushort); external dllname; + procedure glVertexWeighthNV(weight: GLushort); external dllname; + procedure glVertexWeighthvNV(const weight: PGLushort); external dllname; + procedure glVertexAttrib1hNV(index: GLuint; x: GLushort); external dllname; + procedure glVertexAttrib1hvNV(index: GLuint; const v: PGLushort); external dllname; + procedure glVertexAttrib2hNV(index: GLuint; x: GLushort; y: GLushort); external dllname; + procedure glVertexAttrib2hvNV(index: GLuint; const v: PGLushort); external dllname; + procedure glVertexAttrib3hNV(index: GLuint; x: GLushort; y: GLushort; z: GLushort); external dllname; + procedure glVertexAttrib3hvNV(index: GLuint; const v: PGLushort); external dllname; + procedure glVertexAttrib4hNV(index: GLuint; x: GLushort; y: GLushort; z: GLushort; w: GLushort); external dllname; + procedure glVertexAttrib4hvNV(index: GLuint; const v: PGLushort); external dllname; + procedure glVertexAttribs1hvNV(index: GLuint; n: GLsizei; const v: PGLushort); external dllname; + procedure glVertexAttribs2hvNV(index: GLuint; n: GLsizei; const v: PGLushort); external dllname; + procedure glVertexAttribs3hvNV(index: GLuint; n: GLsizei; const v: PGLushort); external dllname; + procedure glVertexAttribs4hvNV(index: GLuint; n: GLsizei; const v: PGLushort); external dllname; + +function Load_GL_NV_half_float: Boolean; + +//***** GL_ATI_map_object_buffer *****// + + function glMapObjectBufferATI(buffer: GLuint): PGLvoid; external dllname; + procedure glUnmapObjectBufferATI(buffer: GLuint); external dllname; + +function Load_GL_ATI_map_object_buffer: Boolean; + +//***** GL_ATI_separate_stencil *****// +const + GL_KEEP = $1E00; + GL_ZERO = $0000; + GL_REPLACE = $1E01; + GL_INCR = $1E02; + GL_DECR = $1E03; + GL_INVERT = $150A; + GL_NEVER = $0200; + GL_LESS = $0201; + GL_LEQUAL = $0203; + GL_GREATER = $0204; + GL_GEQUAL = $0206; + GL_EQUAL = $0202; + GL_NOTEQUAL = $0205; + GL_ALWAYS = $0207; + GL_FRONT = $0404; + GL_BACK = $0405; + GL_FRONT_AND_BACK = $0408; + GL_STENCIL_BACK_FUNC_ATI = $8800; + GL_STENCIL_BACK_FAIL_ATI = $8801; + GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI = $8802; + GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI = $8803; + + procedure glStencilOpSeparateATI(face: GLenum; sfail: GLenum; dpfail: GLenum; dppass: GLenum); external dllname; + procedure glStencilFuncSeparateATI(frontfunc: GLenum; backfunc: GLenum; ref: GLint; mask: GLuint); external dllname; + +function Load_GL_ATI_separate_stencil: Boolean; + +//***** GL_ATI_vertex_attrib_array_object *****// + + procedure glVertexAttribArrayObjectATI(index: GLuint; size: GLint; thetype: GLenum; normalized: GLboolean; stride: GLsizei; buffer: GLuint; offset: GLuint); external dllname; + procedure glGetVertexAttribArrayObjectfvATI(index: GLuint; pname: GLenum; params: PGLfloat); external dllname; + procedure glGetVertexAttribArrayObjectivATI(index: GLuint; pname: GLenum; params: PGLint); external dllname; + +function Load_GL_ATI_vertex_attrib_array_object: Boolean; + +//***** GL_ARB_occlusion_query *****// +const + GL_SAMPLES_PASSED_ARB = $8914; + GL_QUERY_COUNTER_BITS_ARB = $8864; + GL_CURRENT_QUERY_ARB = $8865; + GL_QUERY_RESULT_ARB = $8866; + GL_QUERY_RESULT_AVAILABLE_ARB = $8867; + + procedure glGenQueriesARB(n: GLsizei; ids: PGLuint); external dllname; + procedure glDeleteQueriesARB(n: GLsizei; const ids: PGLuint); external dllname; + function glIsQueryARB(id: GLuint): GLboolean; external dllname; + procedure glBeginQueryARB(target: GLenum; id: GLuint); external dllname; + procedure glEndQueryARB(target: GLenum); external dllname; + procedure glGetQueryivARB(target: GLenum; pname: GLenum; params: PGLint); external dllname; + procedure glGetQueryObjectivARB(id: GLuint; pname: GLenum; params: PGLint); external dllname; + procedure glGetQueryObjectuivARB(id: GLuint; pname: GLenum; params: PGLuint); external dllname; + +function Load_GL_ARB_occlusion_query: Boolean; + +//***** GL_ARB_shader_objects *****// +const + GL_PROGRAM_OBJECT_ARB = $8B40; + GL_OBJECT_TYPE_ARB = $8B4E; + GL_OBJECT_SUBTYPE_ARB = $8B4F; + GL_OBJECT_DELETE_STATUS_ARB = $8B80; + GL_OBJECT_COMPILE_STATUS_ARB = $8B81; + GL_OBJECT_LINK_STATUS_ARB = $8B82; + GL_OBJECT_VALIDATE_STATUS_ARB = $8B83; + GL_OBJECT_INFO_LOG_LENGTH_ARB = $8B84; + GL_OBJECT_ATTACHED_OBJECTS_ARB = $8B85; + GL_OBJECT_ACTIVE_UNIFORMS_ARB = $8B86; + GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB = $8B87; + GL_OBJECT_SHADER_SOURCE_LENGTH_ARB = $8B88; + GL_SHADER_OBJECT_ARB = $8B48; + GL_FLOAT = $1406; + GL_FLOAT_VEC2_ARB = $8B50; + GL_FLOAT_VEC3_ARB = $8B51; + GL_FLOAT_VEC4_ARB = $8B52; + GL_INT = $1404; + GL_INT_VEC2_ARB = $8B53; + GL_INT_VEC3_ARB = $8B54; + GL_INT_VEC4_ARB = $8B55; + GL_BOOL_ARB = $8B56; + GL_BOOL_VEC2_ARB = $8B57; + GL_BOOL_VEC3_ARB = $8B58; + GL_BOOL_VEC4_ARB = $8B59; + GL_FLOAT_MAT2_ARB = $8B5A; + GL_FLOAT_MAT3_ARB = $8B5B; + GL_FLOAT_MAT4_ARB = $8B5C; + + procedure glDeleteObjectARB(obj: GLhandleARB); external dllname; + function glGetHandleARB(pname: GLenum): GLhandleARB; external dllname; + procedure glDetachObjectARB(containerObj: GLhandleARB; attachedObj: GLhandleARB); external dllname; + function glCreateShaderObjectARB(shaderType: GLenum): GLhandleARB; external dllname; + procedure glShaderSourceARB(shaderObj: GLhandleARB; count: GLsizei; const str: PGLvoid; const length: PGLint); external dllname; + procedure glCompileShaderARB(shaderObj: GLhandleARB); external dllname; + function glCreateProgramObjectARB(): GLhandleARB; external dllname; + procedure glAttachObjectARB(containerObj: GLhandleARB; obj: GLhandleARB); external dllname; + procedure glLinkProgramARB(programObj: GLhandleARB); external dllname; + procedure glUseProgramObjectARB(programObj: GLhandleARB); external dllname; + procedure glValidateProgramARB(programObj: GLhandleARB); external dllname; + procedure glUniform1fARB(location: GLint; v0: GLfloat); external dllname; + procedure glUniform2fARB(location: GLint; v0: GLfloat; v1: GLfloat); external dllname; + procedure glUniform3fARB(location: GLint; v0: GLfloat; v1: GLfloat; v2: GLfloat); external dllname; + procedure glUniform4fARB(location: GLint; v0: GLfloat; v1: GLfloat; v2: GLfloat; v3: GLfloat); external dllname; + procedure glUniform1iARB(location: GLint; v0: GLint); external dllname; + procedure glUniform2iARB(location: GLint; v0: GLint; v1: GLint); external dllname; + procedure glUniform3iARB(location: GLint; v0: GLint; v1: GLint; v2: GLint); external dllname; + procedure glUniform4iARB(location: GLint; v0: GLint; v1: GLint; v2: GLint; v3: GLint); external dllname; + procedure glUniform1fvARB(location: GLint; count: GLsizei; value: PGLfloat); external dllname; + procedure glUniform2fvARB(location: GLint; count: GLsizei; value: PGLfloat); external dllname; + procedure glUniform3fvARB(location: GLint; count: GLsizei; value: PGLfloat); external dllname; + procedure glUniform4fvARB(location: GLint; count: GLsizei; value: PGLfloat); external dllname; + procedure glUniform1ivARB(location: GLint; count: GLsizei; value: PGLint); external dllname; + procedure glUniform2ivARB(location: GLint; count: GLsizei; value: PGLint); external dllname; + procedure glUniform3ivARB(location: GLint; count: GLsizei; value: PGLint); external dllname; + procedure glUniform4ivARB(location: GLint; count: GLsizei; value: PGLint); external dllname; + procedure glUniformMatrix2fvARB(location: GLint; count: GLsizei; transpose: GLboolean; value: PGLfloat); external dllname; + procedure glUniformMatrix3fvARB(location: GLint; count: GLsizei; transpose: GLboolean; value: PGLfloat); external dllname; + procedure glUniformMatrix4fvARB(location: GLint; count: GLsizei; transpose: GLboolean; value: PGLfloat); external dllname; + procedure glGetObjectParameterfvARB(obj: GLhandleARB; pname: GLenum; params: PGLfloat); external dllname; + procedure glGetObjectParameterivARB(obj: GLhandleARB; pname: GLenum; params: PGLint); external dllname; + procedure glGetInfoLogARB(obj: GLhandleARB; maxLength: GLsizei; length: PGLsizei; infoLog: PGLcharARB); external dllname; + procedure glGetAttachedObjectsARB(containerObj: GLhandleARB; maxCount: GLsizei; count: PGLsizei; obj: PGLhandleARB); external dllname; + function glGetUniformLocationARB(programObj: GLhandleARB; const name: PGLcharARB): GLint; external dllname; + procedure glGetActiveUniformARB(programObj: GLhandleARB; index: GLuint; maxLength: GLsizei; length: PGLsizei; size: PGLint; thetype: PGLenum; name: PGLcharARB); external dllname; + procedure glGetUniformfvARB(programObj: GLhandleARB; location: GLint; params: PGLfloat); external dllname; + procedure glGetUniformivARB(programObj: GLhandleARB; location: GLint; params: PGLint); external dllname; + procedure glGetShaderSourceARB(obj: GLhandleARB; maxLength: GLsizei; length: PGLsizei; source: PGLcharARB); external dllname; + +function Load_GL_ARB_shader_objects: Boolean; + +//***** GL_ARB_vertex_shader *****// +const + GL_VERTEX_SHADER_ARB = $8B31; + GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB = $8B4A; + GL_MAX_VARYING_FLOATS_ARB = $8B4B; + // GL_MAX_VERTEX_ATTRIBS_ARB { already defined } + // GL_MAX_TEXTURE_IMAGE_UNITS_ARB { already defined } + GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB = $8B4C; + GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB = $8B4D; + // GL_MAX_TEXTURE_COORDS_ARB { already defined } + // GL_VERTEX_PROGRAM_POINT_SIZE_ARB { already defined } + // GL_VERTEX_PROGRAM_TWO_SIDE_ARB { already defined } + // GL_OBJECT_TYPE_ARB { already defined } + // GL_OBJECT_SUBTYPE_ARB { already defined } + GL_OBJECT_ACTIVE_ATTRIBUTES_ARB = $8B89; + GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB = $8B8A; + // GL_SHADER_OBJECT_ARB { already defined } + // GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB { already defined } + // GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB { already defined } + // GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB { already defined } + // GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB { already defined } + // GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB { already defined } + // GL_CURRENT_VERTEX_ATTRIB_ARB { already defined } + // GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB { already defined } + // GL_FLOAT { already defined } + // GL_FLOAT_VEC2_ARB { already defined } + // GL_FLOAT_VEC3_ARB { already defined } + // GL_FLOAT_VEC4_ARB { already defined } + // GL_FLOAT_MAT2_ARB { already defined } + // GL_FLOAT_MAT3_ARB { already defined } + // GL_FLOAT_MAT4_ARB { already defined } + // glVertexAttrib1fARB { already defined } + // glVertexAttrib1sARB { already defined } + // glVertexAttrib1dARB { already defined } + // glVertexAttrib2fARB { already defined } + // glVertexAttrib2sARB { already defined } + // glVertexAttrib2dARB { already defined } + // glVertexAttrib3fARB { already defined } + // glVertexAttrib3sARB { already defined } + // glVertexAttrib3dARB { already defined } + // glVertexAttrib4fARB { already defined } + // glVertexAttrib4sARB { already defined } + // glVertexAttrib4dARB { already defined } + // glVertexAttrib4NubARB { already defined } + // glVertexAttrib1fvARB { already defined } + // glVertexAttrib1svARB { already defined } + // glVertexAttrib1dvARB { already defined } + // glVertexAttrib2fvARB { already defined } + // glVertexAttrib2svARB { already defined } + // glVertexAttrib2dvARB { already defined } + // glVertexAttrib3fvARB { already defined } + // glVertexAttrib3svARB { already defined } + // glVertexAttrib3dvARB { already defined } + // glVertexAttrib4fvARB { already defined } + // glVertexAttrib4svARB { already defined } + // glVertexAttrib4dvARB { already defined } + // glVertexAttrib4ivARB { already defined } + // glVertexAttrib4bvARB { already defined } + // glVertexAttrib4ubvARB { already defined } + // glVertexAttrib4usvARB { already defined } + // glVertexAttrib4uivARB { already defined } + // glVertexAttrib4NbvARB { already defined } + // glVertexAttrib4NsvARB { already defined } + // glVertexAttrib4NivARB { already defined } + // glVertexAttrib4NubvARB { already defined } + // glVertexAttrib4NusvARB { already defined } + // glVertexAttrib4NuivARB { already defined } + // glVertexAttribPointerARB { already defined } + // glEnableVertexAttribArrayARB { already defined } + // glDisableVertexAttribArrayARB { already defined } + + procedure glBindAttribLocationARB(programObj: GLhandleARB; index: GLuint; const name: PGLcharARB); external dllname; + procedure glGetActiveAttribARB(programObj: GLhandleARB; index: GLuint; maxLength: GLsizei; length: PGLsizei; size: PGLint; thetype: PGLenum; name: PGLcharARB); external dllname; + function glGetAttribLocationARB(programObj: GLhandleARB; const name: PGLcharARB): GLint; external dllname; + // glGetVertexAttribdvARB { already defined } + // glGetVertexAttribfvARB { already defined } + // glGetVertexAttribivARB { already defined } + // glGetVertexAttribPointervARB { already defined } + +function Load_GL_ARB_vertex_shader: Boolean; + +//***** GL_ARB_fragment_shader *****// +const + GL_FRAGMENT_SHADER_ARB = $8B30; + GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB = $8B49; + // GL_MAX_TEXTURE_COORDS_ARB { already defined } + // GL_MAX_TEXTURE_IMAGE_UNITS_ARB { already defined } + // GL_OBJECT_TYPE_ARB { already defined } + // GL_OBJECT_SUBTYPE_ARB { already defined } + // GL_SHADER_OBJECT_ARB { already defined } + +function Load_GL_ARB_fragment_shader: Boolean; + +//***** GL_ARB_shading_language_100 *****// + +function Load_GL_ARB_shading_language_100: Boolean; + +//***** GL_ARB_texture_non_power_of_two *****// + +function Load_GL_ARB_texture_non_power_of_two: Boolean; + +//***** GL_ARB_point_sprite *****// +const + GL_POINT_SPRITE_ARB = $8861; + GL_COORD_REPLACE_ARB = $8862; + +function Load_GL_ARB_point_sprite: Boolean; + +//***** GL_EXT_depth_bounds_test *****// +const + GL_DEPTH_BOUNDS_TEST_EXT = $8890; + GL_DEPTH_BOUNDS_EXT = $8891; + + procedure glDepthBoundsEXT(zmin: GLclampd; zmax: GLclampd); external dllname; + +function Load_GL_EXT_depth_bounds_test: Boolean; + +//***** GL_EXT_texture_mirror_clamp *****// +const + GL_MIRROR_CLAMP_EXT = $8742; + GL_MIRROR_CLAMP_TO_EDGE_EXT = $8743; + GL_MIRROR_CLAMP_TO_BORDER_EXT = $8912; + +function Load_GL_EXT_texture_mirror_clamp: Boolean; + +//***** GL_EXT_blend_equation_separate *****// +const + GL_BLEND_EQUATION_RGB_EXT = $8009; + GL_BLEND_EQUATION_ALPHA_EXT = $883D; + + procedure glBlendEquationSeparateEXT(modeRGB: GLenum; modeAlpha: GLenum); external dllname; + +function Load_GL_EXT_blend_equation_separate: Boolean; + +//***** GL_MESA_pack_invert *****// +const + GL_PACK_INVERT_MESA = $8758; + +function Load_GL_MESA_pack_invert: Boolean; + +//***** GL_MESA_ycbcr_texture *****// +const + GL_YCBCR_MESA = $8757; + GL_UNSIGNED_SHORT_8_8_MESA = $85BA; + GL_UNSIGNED_SHORT_8_8_REV_MESA = $85BB; + +function Load_GL_MESA_ycbcr_texture: Boolean; + +//***** GL_ARB_fragment_program_shadow *****// + +function Load_GL_ARB_fragment_program_shadow: Boolean; + +//***** GL_NV_fragment_program_option *****// + +function Load_GL_NV_fragment_program_option: Boolean; + +//***** GL_EXT_pixel_buffer_object *****// +const + GL_PIXEL_PACK_BUFFER_EXT = $88EB; + GL_PIXEL_UNPACK_BUFFER_EXT = $88EC; + GL_PIXEL_PACK_BUFFER_BINDING_EXT = $88ED; + GL_PIXEL_UNPACK_BUFFER_BINDING_EXT = $88EF; + +function Load_GL_EXT_pixel_buffer_object: Boolean; + +//***** GL_NV_fragment_program2 *****// +const + GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV = $88F4; + GL_MAX_PROGRAM_CALL_DEPTH_NV = $88F5; + GL_MAX_PROGRAM_IF_DEPTH_NV = $88F6; + GL_MAX_PROGRAM_LOOP_DEPTH_NV = $88F7; + GL_MAX_PROGRAM_LOOP_COUNT_NV = $88F8; + +function Load_GL_NV_fragment_program2: Boolean; + +//***** GL_NV_vertex_program2_option *****// + // GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV { already defined } + // GL_MAX_PROGRAM_CALL_DEPTH_NV { already defined } + +function Load_GL_NV_vertex_program2_option: Boolean; + +//***** GL_NV_vertex_program3 *****// + // GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB { already defined } + +function Load_GL_NV_vertex_program3: Boolean; + +//***** GL_ARB_draw_buffers *****// +const + GL_MAX_DRAW_BUFFERS_ARB = $8824; + GL_DRAW_BUFFER0_ARB = $8825; + GL_DRAW_BUFFER1_ARB = $8826; + GL_DRAW_BUFFER2_ARB = $8827; + GL_DRAW_BUFFER3_ARB = $8828; + GL_DRAW_BUFFER4_ARB = $8829; + GL_DRAW_BUFFER5_ARB = $882A; + GL_DRAW_BUFFER6_ARB = $882B; + GL_DRAW_BUFFER7_ARB = $882C; + GL_DRAW_BUFFER8_ARB = $882D; + GL_DRAW_BUFFER9_ARB = $882E; + GL_DRAW_BUFFER10_ARB = $882F; + GL_DRAW_BUFFER11_ARB = $8830; + GL_DRAW_BUFFER12_ARB = $8831; + GL_DRAW_BUFFER13_ARB = $8832; + GL_DRAW_BUFFER14_ARB = $8833; + GL_DRAW_BUFFER15_ARB = $8834; + + procedure glDrawBuffersARB(n: GLsizei; const bufs: PGLenum); external dllname; + +function Load_GL_ARB_draw_buffers: Boolean; + +//***** GL_ARB_texture_rectangle *****// +const + GL_TEXTURE_RECTANGLE_ARB = $84F5; + GL_TEXTURE_BINDING_RECTANGLE_ARB = $84F6; + GL_PROXY_TEXTURE_RECTANGLE_ARB = $84F7; + GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB = $84F8; + +function Load_GL_ARB_texture_rectangle: Boolean; + +//***** GL_ARB_color_buffer_float *****// +const + GL_RGBA_FLOAT_MODE_ARB = $8820; + GL_CLAMP_VERTEX_COLOR_ARB = $891A; + GL_CLAMP_FRAGMENT_COLOR_ARB = $891B; + GL_CLAMP_READ_COLOR_ARB = $891C; + GL_FIXED_ONLY_ARB = $891D; + WGL_TYPE_RGBA_FLOAT_ARB = $21A0; + + procedure glClampColorARB(target: GLenum; clamp: GLenum); external dllname; + +function Load_GL_ARB_color_buffer_float: Boolean; + +//***** GL_ARB_half_float_pixel *****// +const + GL_HALF_FLOAT_ARB = $140B; + +function Load_GL_ARB_half_float_pixel: Boolean; + +//***** GL_ARB_texture_float *****// +const + GL_TEXTURE_RED_TYPE_ARB = $8C10; + GL_TEXTURE_GREEN_TYPE_ARB = $8C11; + GL_TEXTURE_BLUE_TYPE_ARB = $8C12; + GL_TEXTURE_ALPHA_TYPE_ARB = $8C13; + GL_TEXTURE_LUMINANCE_TYPE_ARB = $8C14; + GL_TEXTURE_INTENSITY_TYPE_ARB = $8C15; + GL_TEXTURE_DEPTH_TYPE_ARB = $8C16; + GL_UNSIGNED_NORMALIZED_ARB = $8C17; + GL_RGBA32F_ARB = $8814; + GL_RGB32F_ARB = $8815; + GL_ALPHA32F_ARB = $8816; + GL_INTENSITY32F_ARB = $8817; + GL_LUMINANCE32F_ARB = $8818; + GL_LUMINANCE_ALPHA32F_ARB = $8819; + GL_RGBA16F_ARB = $881A; + GL_RGB16F_ARB = $881B; + GL_ALPHA16F_ARB = $881C; + GL_INTENSITY16F_ARB = $881D; + GL_LUMINANCE16F_ARB = $881E; + GL_LUMINANCE_ALPHA16F_ARB = $881F; + +function Load_GL_ARB_texture_float: Boolean; + +//***** GL_EXT_texture_compression_dxt1 *****// + // GL_COMPRESSED_RGB_S3TC_DXT1_EXT { already defined } + // GL_COMPRESSED_RGBA_S3TC_DXT1_EXT { already defined } + +function Load_GL_EXT_texture_compression_dxt1: Boolean; + +//***** GL_ARB_pixel_buffer_object *****// +const + GL_PIXEL_PACK_BUFFER_ARB = $88EB; + GL_PIXEL_UNPACK_BUFFER_ARB = $88EC; + GL_PIXEL_PACK_BUFFER_BINDING_ARB = $88ED; + GL_PIXEL_UNPACK_BUFFER_BINDING_ARB = $88EF; + +function Load_GL_ARB_pixel_buffer_object: Boolean; + +//***** GL_EXT_framebuffer_object *****// +const + GL_FRAMEBUFFER_EXT = $8D40; + GL_RENDERBUFFER_EXT = $8D41; + GL_STENCIL_INDEX_EXT = $8D45; + GL_STENCIL_INDEX1_EXT = $8D46; + GL_STENCIL_INDEX4_EXT = $8D47; + GL_STENCIL_INDEX8_EXT = $8D48; + GL_STENCIL_INDEX16_EXT = $8D49; + GL_RENDERBUFFER_WIDTH_EXT = $8D42; + GL_RENDERBUFFER_HEIGHT_EXT = $8D43; + GL_RENDERBUFFER_INTERNAL_FORMAT_EXT = $8D44; + GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT = $8CD0; + GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT = $8CD1; + GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT = $8CD2; + GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT = $8CD3; + GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT = $8CD4; + GL_COLOR_ATTACHMENT0_EXT = $8CE0; + GL_COLOR_ATTACHMENT1_EXT = $8CE1; + GL_COLOR_ATTACHMENT2_EXT = $8CE2; + GL_COLOR_ATTACHMENT3_EXT = $8CE3; + GL_COLOR_ATTACHMENT4_EXT = $8CE4; + GL_COLOR_ATTACHMENT5_EXT = $8CE5; + GL_COLOR_ATTACHMENT6_EXT = $8CE6; + GL_COLOR_ATTACHMENT7_EXT = $8CE7; + GL_COLOR_ATTACHMENT8_EXT = $8CE8; + GL_COLOR_ATTACHMENT9_EXT = $8CE9; + GL_COLOR_ATTACHMENT10_EXT = $8CEA; + GL_COLOR_ATTACHMENT11_EXT = $8CEB; + GL_COLOR_ATTACHMENT12_EXT = $8CEC; + GL_COLOR_ATTACHMENT13_EXT = $8CED; + GL_COLOR_ATTACHMENT14_EXT = $8CEE; + GL_COLOR_ATTACHMENT15_EXT = $8CEF; + GL_DEPTH_ATTACHMENT_EXT = $8D00; + GL_STENCIL_ATTACHMENT_EXT = $8D20; + GL_FRAMEBUFFER_COMPLETE_EXT = $8CD5; + GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT = $8CD6; + GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT = $8CD7; + GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT = $8CD8; + GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT = $8CD9; + GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT = $8CDA; + GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT = $8CDB; + GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT = $8CDC; + GL_FRAMEBUFFER_UNSUPPORTED_EXT = $8CDD; + GL_FRAMEBUFFER_STATUS_ERROR_EXT = $8CDE; + GL_FRAMEBUFFER_BINDING_EXT = $8CA6; + GL_RENDERBUFFER_BINDING_EXT = $8CA7; + GL_MAX_COLOR_ATTACHMENTS_EXT = $8CDF; + GL_MAX_RENDERBUFFER_SIZE_EXT = $84E8; + GL_INVALID_FRAMEBUFFER_OPERATION_EXT = $0506; + + function glIsRenderbufferEXT(renderbuffer: GLuint): GLboolean; external dllname; + procedure glBindRenderbufferEXT(target: GLenum; renderbuffer: GLuint); external dllname; + procedure glDeleteRenderbuffersEXT(n: GLsizei; const renderbuffers: PGLuint); external dllname; + procedure glGenRenderbuffersEXT(n: GLsizei; renderbuffers: PGLuint); external dllname; + procedure glRenderbufferStorageEXT(target: GLenum; internalformat: GLenum; width: GLsizei; height: GLsizei); external dllname; + procedure glGetRenderbufferParameterivEXT(target: GLenum; pname: GLenum; params: PGLint); external dllname; + function glIsFramebufferEXT(framebuffer: GLuint): GLboolean; external dllname; + procedure glBindFramebufferEXT(target: GLenum; framebuffer: GLuint); external dllname; + procedure glDeleteFramebuffersEXT(n: GLsizei; const framebuffers: PGLuint); external dllname; + procedure glGenFramebuffersEXT(n: GLsizei; framebuffers: PGLuint); external dllname; + function glCheckFramebufferStatusEXT(target: GLenum): GLenum; external dllname; + procedure glFramebufferTexture1DEXT(target: GLenum; attachment: GLenum; textarget: GLenum; texture: GLuint; level: GLint); external dllname; + procedure glFramebufferTexture2DEXT(target: GLenum; attachment: GLenum; textarget: GLenum; texture: GLuint; level: GLint); external dllname; + procedure glFramebufferTexture3DEXT(target: GLenum; attachment: GLenum; textarget: GLenum; texture: GLuint; level: GLint; zoffset: GLint); external dllname; + procedure glFramebufferRenderbufferEXT(target: GLenum; attachment: GLenum; renderbuffertarget: GLenum; renderbuffer: GLuint); external dllname; + procedure glGetFramebufferAttachmentParameterivEXT(target: GLenum; attachment: GLenum; pname: GLenum; params: PGLint); external dllname; + procedure glGenerateMipmapEXT(target: GLenum); external dllname; + +function Load_GL_EXT_framebuffer_object: Boolean; + +//***** GL_version_1_4 *****// +const + GL_BLEND_DST_RGB = $80C8; + GL_BLEND_SRC_RGB = $80C9; + GL_BLEND_DST_ALPHA = $80CA; + GL_BLEND_SRC_ALPHA = $80CB; + GL_POINT_SIZE_MIN = $8126; + GL_POINT_SIZE_MAX = $8127; + GL_POINT_FADE_THRESHOLD_SIZE = $8128; + GL_POINT_DISTANCE_ATTENUATION = $8129; + GL_GENERATE_MIPMAP = $8191; + GL_GENERATE_MIPMAP_HINT = $8192; + GL_DEPTH_COMPONENT16 = $81A5; + GL_DEPTH_COMPONENT24 = $81A6; + GL_DEPTH_COMPONENT32 = $81A7; + GL_MIRRORED_REPEAT = $8370; + GL_FOG_COORDINATE_SOURCE = $8450; + GL_FOG_COORDINATE = $8451; + GL_FRAGMENT_DEPTH = $8452; + GL_CURRENT_FOG_COORDINATE = $8453; + GL_FOG_COORDINATE_ARRAY_TYPE = $8454; + GL_FOG_COORDINATE_ARRAY_STRIDE = $8455; + GL_FOG_COORDINATE_ARRAY_POINTER = $8456; + GL_FOG_COORDINATE_ARRAY = $8457; + GL_COLOR_SUM = $8458; + GL_CURRENT_SECONDARY_COLOR = $8459; + GL_SECONDARY_COLOR_ARRAY_SIZE = $845A; + GL_SECONDARY_COLOR_ARRAY_TYPE = $845B; + GL_SECONDARY_COLOR_ARRAY_STRIDE = $845C; + GL_SECONDARY_COLOR_ARRAY_POINTER = $845D; + GL_SECONDARY_COLOR_ARRAY = $845E; + GL_MAX_TEXTURE_LOD_BIAS = $84FD; + GL_TEXTURE_FILTER_CONTROL = $8500; + GL_TEXTURE_LOD_BIAS = $8501; + GL_INCR_WRAP = $8507; + GL_DECR_WRAP = $8508; + GL_TEXTURE_DEPTH_SIZE = $884A; + GL_DEPTH_TEXTURE_MODE = $884B; + GL_TEXTURE_COMPARE_MODE = $884C; + GL_TEXTURE_COMPARE_FUNC = $884D; + GL_COMPARE_R_TO_TEXTURE = $884E; + + procedure glBlendFuncSeparate(sfactorRGB: GLenum; dfactorRGB: GLenum; sfactorAlpha: GLenum; dfactorAlpha: GLenum); external dllname; + procedure glFogCoordf(coord: GLfloat); external dllname; + procedure glFogCoordfv(const coord: PGLfloat); external dllname; + procedure glFogCoordd(coord: GLdouble); external dllname; + procedure glFogCoorddv(const coord: PGLdouble); external dllname; + procedure glFogCoordPointer(thetype: GLenum; stride: GLsizei; const pointer: PGLvoid); external dllname; + procedure glMultiDrawArrays(mode: GLenum; first: PGLint; count: PGLsizei; primcount: GLsizei); external dllname; + procedure glMultiDrawElements(mode: GLenum; const count: PGLsizei; thetype: GLenum; const indices: PGLvoid; primcount: GLsizei); external dllname; + procedure glPointParameterf(pname: GLenum; param: GLfloat); external dllname; + procedure glPointParameterfv(pname: GLenum; const params: PGLfloat); external dllname; + procedure glPointParameteri(pname: GLenum; param: GLint); external dllname; + procedure glPointParameteriv(pname: GLenum; const params: PGLint); external dllname; + procedure glSecondaryColor3b(red: GLbyte; green: GLbyte; blue: GLbyte); external dllname; + procedure glSecondaryColor3bv(const v: PGLbyte); external dllname; + procedure glSecondaryColor3d(red: GLdouble; green: GLdouble; blue: GLdouble); external dllname; + procedure glSecondaryColor3dv(const v: PGLdouble); external dllname; + procedure glSecondaryColor3f(red: GLfloat; green: GLfloat; blue: GLfloat); external dllname; + procedure glSecondaryColor3fv(const v: PGLfloat); external dllname; + procedure glSecondaryColor3i(red: GLint; green: GLint; blue: GLint); external dllname; + procedure glSecondaryColor3iv(const v: PGLint); external dllname; + procedure glSecondaryColor3s(red: GLshort; green: GLshort; blue: GLshort); external dllname; + procedure glSecondaryColor3sv(const v: PGLshort); external dllname; + procedure glSecondaryColor3ub(red: GLubyte; green: GLubyte; blue: GLubyte); external dllname; + procedure glSecondaryColor3ubv(const v: PGLubyte); external dllname; + procedure glSecondaryColor3ui(red: GLuint; green: GLuint; blue: GLuint); external dllname; + procedure glSecondaryColor3uiv(const v: PGLuint); external dllname; + procedure glSecondaryColor3us(red: GLushort; green: GLushort; blue: GLushort); external dllname; + procedure glSecondaryColor3usv(const v: PGLushort); external dllname; + procedure glSecondaryColorPointer(size: GLint; thetype: GLenum; stride: GLsizei; const pointer: PGLvoid); external dllname; + procedure glWindowPos2d(x: GLdouble; y: GLdouble); external dllname; + procedure glWindowPos2dv(const v: PGLdouble); external dllname; + procedure glWindowPos2f(x: GLfloat; y: GLfloat); external dllname; + procedure glWindowPos2fv(const v: PGLfloat); external dllname; + procedure glWindowPos2i(x: GLint; y: GLint); external dllname; + procedure glWindowPos2iv(const v: PGLint); external dllname; + procedure glWindowPos2s(x: GLshort; y: GLshort); external dllname; + procedure glWindowPos2sv(const v: PGLshort); external dllname; + procedure glWindowPos3d(x: GLdouble; y: GLdouble; z: GLdouble); external dllname; + procedure glWindowPos3dv(const v: PGLdouble); external dllname; + procedure glWindowPos3f(x: GLfloat; y: GLfloat; z: GLfloat); external dllname; + procedure glWindowPos3fv(const v: PGLfloat); external dllname; + procedure glWindowPos3i(x: GLint; y: GLint; z: GLint); external dllname; + procedure glWindowPos3iv(const v: PGLint); external dllname; + procedure glWindowPos3s(x: GLshort; y: GLshort; z: GLshort); external dllname; + procedure glWindowPos3sv(const v: PGLshort); external dllname; + +function Load_GL_version_1_4: Boolean; + +//***** GL_version_1_5 *****// +const + GL_BUFFER_SIZE = $8764; + GL_BUFFER_USAGE = $8765; + GL_QUERY_COUNTER_BITS = $8864; + GL_CURRENT_QUERY = $8865; + GL_QUERY_RESULT = $8866; + GL_QUERY_RESULT_AVAILABLE = $8867; + GL_ARRAY_BUFFER = $8892; + GL_ELEMENT_ARRAY_BUFFER = $8893; + GL_ARRAY_BUFFER_BINDING = $8894; + GL_ELEMENT_ARRAY_BUFFER_BINDING = $8895; + GL_VERTEX_ARRAY_BUFFER_BINDING = $8896; + GL_NORMAL_ARRAY_BUFFER_BINDING = $8897; + GL_COLOR_ARRAY_BUFFER_BINDING = $8898; + GL_INDEX_ARRAY_BUFFER_BINDING = $8899; + GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING = $889A; + GL_EDGE_FLAG_ARRAY_BUFFER_BINDING = $889B; + GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING = $889C; + GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING = $889D; + GL_WEIGHT_ARRAY_BUFFER_BINDING = $889E; + GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = $889F; + GL_READ_ONLY = $88B8; + GL_WRITE_ONLY = $88B9; + GL_READ_WRITE = $88BA; + GL_BUFFER_ACCESS = $88BB; + GL_BUFFER_MAPPED = $88BC; + GL_BUFFER_MAP_POINTER = $88BD; + GL_STREAM_DRAW = $88E0; + GL_STREAM_READ = $88E1; + GL_STREAM_COPY = $88E2; + GL_STATIC_DRAW = $88E4; + GL_STATIC_READ = $88E5; + GL_STATIC_COPY = $88E6; + GL_DYNAMIC_DRAW = $88E8; + GL_DYNAMIC_READ = $88E9; + GL_DYNAMIC_COPY = $88EA; + GL_SAMPLES_PASSED = $8914; + GL_FOG_COORD_SRC = $8450; + GL_FOG_COORD = $8451; + GL_CURRENT_FOG_COORD = $8453; + GL_FOG_COORD_ARRAY_TYPE = $8454; + GL_FOG_COORD_ARRAY_STRIDE = $8455; + GL_FOG_COORD_ARRAY_POINTER = $8456; + GL_FOG_COORD_ARRAY = $8457; + GL_FOG_COORD_ARRAY_BUFFER_BINDING = $889D; + GL_SRC0_RGB = $8580; + GL_SRC1_RGB = $8581; + GL_SRC2_RGB = $8582; + GL_SRC0_ALPHA = $8588; + GL_SRC1_ALPHA = $8589; + GL_SRC2_ALPHA = $858A; + + procedure glGenQueries(n: GLsizei; ids: PGLuint); external dllname; + procedure glDeleteQueries(n: GLsizei; const ids: PGLuint); external dllname; + function glIsQuery(id: GLuint): GLboolean; external dllname; + procedure glBeginQuery(target: GLenum; id: GLuint); external dllname; + procedure glEndQuery(target: GLenum); external dllname; + procedure glGetQueryiv(target: GLenum; pname: GLenum; params: PGLint); external dllname; + procedure glGetQueryObjectiv(id: GLuint; pname: GLenum; params: PGLint); external dllname; + procedure glGetQueryObjectuiv(id: GLuint; pname: GLenum; params: PGLuint); external dllname; + procedure glBindBuffer(target: GLenum; buffer: GLuint); external dllname; + procedure glDeleteBuffers(n: GLsizei; const buffers: PGLuint); external dllname; + procedure glGenBuffers(n: GLsizei; buffers: PGLuint); external dllname; + function glIsBuffer(buffer: GLuint): GLboolean; external dllname; + procedure glBufferData(target: GLenum; size: GLsizeiptr; const data: PGLvoid; usage: GLenum); external dllname; + procedure glBufferSubData(target: GLenum; offset: GLintptr; size: GLsizeiptr; const data: PGLvoid); external dllname; + procedure glGetBufferSubData(target: GLenum; offset: GLintptr; size: GLsizeiptr; data: PGLvoid); external dllname; + function glMapBuffer(target: GLenum; access: GLenum): PGLvoid; external dllname; + function glUnmapBuffer(target: GLenum): GLboolean; external dllname; + procedure glGetBufferParameteriv(target: GLenum; pname: GLenum; params: PGLint); external dllname; + procedure glGetBufferPointerv(target: GLenum; pname: GLenum; params: PGLvoid); external dllname; + +function Load_GL_version_1_5: Boolean; + +//***** GL_version_2_0 *****// +const + GL_BLEND_EQUATION_RGB = $8009; + GL_VERTEX_ATTRIB_ARRAY_ENABLED = $8622; + GL_VERTEX_ATTRIB_ARRAY_SIZE = $8623; + GL_VERTEX_ATTRIB_ARRAY_STRIDE = $8624; + GL_VERTEX_ATTRIB_ARRAY_TYPE = $8625; + GL_CURRENT_VERTEX_ATTRIB = $8626; + GL_VERTEX_PROGRAM_POINT_SIZE = $8642; + GL_VERTEX_PROGRAM_TWO_SIDE = $8643; + GL_VERTEX_ATTRIB_ARRAY_POINTER = $8645; + GL_STENCIL_BACK_FUNC = $8800; + GL_STENCIL_BACK_FAIL = $8801; + GL_STENCIL_BACK_PASS_DEPTH_FAIL = $8802; + GL_STENCIL_BACK_PASS_DEPTH_PASS = $8803; + GL_MAX_DRAW_BUFFERS = $8824; + GL_DRAW_BUFFER0 = $8825; + GL_DRAW_BUFFER1 = $8826; + GL_DRAW_BUFFER2 = $8827; + GL_DRAW_BUFFER3 = $8828; + GL_DRAW_BUFFER4 = $8829; + GL_DRAW_BUFFER5 = $882A; + GL_DRAW_BUFFER6 = $882B; + GL_DRAW_BUFFER7 = $882C; + GL_DRAW_BUFFER8 = $882D; + GL_DRAW_BUFFER9 = $882E; + GL_DRAW_BUFFER10 = $882F; + GL_DRAW_BUFFER11 = $8830; + GL_DRAW_BUFFER12 = $8831; + GL_DRAW_BUFFER13 = $8832; + GL_DRAW_BUFFER14 = $8833; + GL_DRAW_BUFFER15 = $8834; + GL_BLEND_EQUATION_ALPHA = $883D; + GL_POINT_SPRITE = $8861; + GL_COORD_REPLACE = $8862; + GL_MAX_VERTEX_ATTRIBS = $8869; + GL_VERTEX_ATTRIB_ARRAY_NORMALIZED = $886A; + GL_MAX_TEXTURE_COORDS = $8871; + GL_MAX_TEXTURE_IMAGE_UNITS = $8872; + GL_FRAGMENT_SHADER = $8B30; + GL_VERTEX_SHADER = $8B31; + GL_MAX_FRAGMENT_UNIFORM_COMPONENTS = $8B49; + GL_MAX_VERTEX_UNIFORM_COMPONENTS = $8B4A; + GL_MAX_VARYING_FLOATS = $8B4B; + GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS = $8B4C; + GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS = $8B4D; + GL_SHADER_TYPE = $8B4F; + GL_FLOAT_VEC2 = $8B50; + GL_FLOAT_VEC3 = $8B51; + GL_FLOAT_VEC4 = $8B52; + GL_INT_VEC2 = $8B53; + GL_INT_VEC3 = $8B54; + GL_INT_VEC4 = $8B55; + GL_BOOL = $8B56; + GL_BOOL_VEC2 = $8B57; + GL_BOOL_VEC3 = $8B58; + GL_BOOL_VEC4 = $8B59; + GL_FLOAT_MAT2 = $8B5A; + GL_FLOAT_MAT3 = $8B5B; + GL_FLOAT_MAT4 = $8B5C; + GL_SAMPLER_1D = $8B5D; + GL_SAMPLER_2D = $8B5E; + GL_SAMPLER_3D = $8B5F; + GL_SAMPLER_CUBE = $8B60; + GL_SAMPLER_1D_SHADOW = $8B61; + GL_SAMPLER_2D_SHADOW = $8B62; + GL_DELETE_STATUS = $8B80; + GL_COMPILE_STATUS = $8B81; + GL_LINK_STATUS = $8B82; + GL_VALIDATE_STATUS = $8B83; + GL_INFO_LOG_LENGTH = $8B84; + GL_ATTACHED_SHADERS = $8B85; + GL_ACTIVE_UNIFORMS = $8B86; + GL_ACTIVE_UNIFORM_MAX_LENGTH = $8B87; + GL_SHADER_SOURCE_LENGTH = $8B88; + GL_ACTIVE_ATTRIBUTES = $8B89; + GL_ACTIVE_ATTRIBUTE_MAX_LENGTH = $8B8A; + GL_FRAGMENT_SHADER_DERIVATIVE_HINT = $8B8B; + GL_SHADING_LANGUAGE_VERSION = $8B8C; + GL_CURRENT_PROGRAM = $8B8D; + GL_POINT_SPRITE_COORD_ORIGIN = $8CA0; + GL_LOWER_LEFT = $8CA1; + GL_UPPER_LEFT = $8CA2; + GL_STENCIL_BACK_REF = $8CA3; + GL_STENCIL_BACK_VALUE_MASK = $8CA4; + GL_STENCIL_BACK_WRITEMASK = $8CA5; + + procedure glBlendEquationSeparate(modeRGB: GLenum; modeAlpha: GLenum); external dllname; + procedure glDrawBuffers(n: GLsizei; const bufs: PGLenum); external dllname; + procedure glStencilOpSeparate(face: GLenum; sfail: GLenum; dpfail: GLenum; dppass: GLenum); external dllname; + procedure glStencilFuncSeparate(frontfunc: GLenum; backfunc: GLenum; ref: GLint; mask: GLuint); external dllname; + procedure glStencilMaskSeparate(face: GLenum; mask: GLuint); external dllname; + procedure glAttachShader(theProgram: GLuint; shader: GLuint); external dllname; + procedure glBindAttribLocation(theProgram: GLuint; index: GLuint; const name: PGLchar); external dllname; + procedure glCompileShader(shader: GLuint); external dllname; + function glCreateProgram(): GLuint; external dllname; + function glCreateShader(thetype: GLenum): GLuint; external dllname; + procedure glDeleteProgram(theProgram: GLuint); external dllname; + procedure glDeleteShader(shader: GLuint); external dllname; + procedure glDetachShader(theProgram: GLuint; shader: GLuint); external dllname; + procedure glDisableVertexAttribArray(index: GLuint); external dllname; + procedure glEnableVertexAttribArray(index: GLuint); external dllname; + procedure glGetActiveAttrib(theProgram: GLuint; index: GLuint; bufSize: GLsizei; length: PGLsizei; size: PGLint; thetype: PGLenum; name: PGLchar); external dllname; + procedure glGetActiveUniform(theProgram: GLuint; index: GLuint; bufSize: GLsizei; length: PGLsizei; size: PGLint; thetype: PGLenum; name: PGLchar); external dllname; + procedure glGetAttachedShaders(theProgram: GLuint; maxCount: GLsizei; count: PGLsizei; obj: PGLuint); external dllname; + function glGetAttribLocation(theProgram: GLuint; const name: PGLchar): GLint; external dllname; + procedure glGetProgramiv(theProgram: GLuint; pname: GLenum; params: PGLint); external dllname; + procedure glGetProgramInfoLog(theProgram: GLuint; bufSize: GLsizei; length: PGLsizei; infoLog: PGLchar); external dllname; + procedure glGetShaderiv(shader: GLuint; pname: GLenum; params: PGLint); external dllname; + procedure glGetShaderInfoLog(shader: GLuint; bufSize: GLsizei; length: PGLsizei; infoLog: PGLchar); external dllname; + procedure glGetShaderSource(shader: GLuint; bufSize: GLsizei; length: PGLsizei; source: PGLchar); external dllname; + function glGetUniformLocation(theProgram: GLuint; const name: PGLchar): GLint; external dllname; + procedure glGetUniformfv(theProgram: GLuint; location: GLint; params: PGLfloat); external dllname; + procedure glGetUniformiv(theProgram: GLuint; location: GLint; params: PGLint); external dllname; + procedure glGetVertexAttribdv(index: GLuint; pname: GLenum; params: PGLdouble); external dllname; + procedure glGetVertexAttribfv(index: GLuint; pname: GLenum; params: PGLfloat); external dllname; + procedure glGetVertexAttribiv(index: GLuint; pname: GLenum; params: PGLint); external dllname; + procedure glGetVertexAttribPointerv(index: GLuint; pname: GLenum; pointer: PGLvoid); external dllname; + function glIsProgram(theProgram: GLuint): GLboolean; external dllname; + function glIsShader(shader: GLuint): GLboolean; external dllname; + procedure glLinkProgram(theProgram: GLuint); external dllname; + procedure glShaderSource(shader: GLuint; count: GLsizei; const str: PGLchar; const length: PGLint); external dllname; + procedure glUseProgram(theProgram: GLuint); external dllname; + procedure glUniform1f(location: GLint; v0: GLfloat); external dllname; + procedure glUniform2f(location: GLint; v0: GLfloat; v1: GLfloat); external dllname; + procedure glUniform3f(location: GLint; v0: GLfloat; v1: GLfloat; v2: GLfloat); external dllname; + procedure glUniform4f(location: GLint; v0: GLfloat; v1: GLfloat; v2: GLfloat; v3: GLfloat); external dllname; + procedure glUniform1i(location: GLint; v0: GLint); external dllname; + procedure glUniform2i(location: GLint; v0: GLint; v1: GLint); external dllname; + procedure glUniform3i(location: GLint; v0: GLint; v1: GLint; v2: GLint); external dllname; + procedure glUniform4i(location: GLint; v0: GLint; v1: GLint; v2: GLint; v3: GLint); external dllname; + procedure glUniform1fv(location: GLint; count: GLsizei; const value: PGLfloat); external dllname; + procedure glUniform2fv(location: GLint; count: GLsizei; const value: PGLfloat); external dllname; + procedure glUniform3fv(location: GLint; count: GLsizei; const value: PGLfloat); external dllname; + procedure glUniform4fv(location: GLint; count: GLsizei; const value: PGLfloat); external dllname; + procedure glUniform1iv(location: GLint; count: GLsizei; const value: PGLint); external dllname; + procedure glUniform2iv(location: GLint; count: GLsizei; const value: PGLint); external dllname; + procedure glUniform3iv(location: GLint; count: GLsizei; const value: PGLint); external dllname; + procedure glUniform4iv(location: GLint; count: GLsizei; const value: PGLint); external dllname; + procedure glUniformMatrix2fv(location: GLint; count: GLsizei; transpose: GLboolean; const value: PGLfloat); external dllname; + procedure glUniformMatrix3fv(location: GLint; count: GLsizei; transpose: GLboolean; const value: PGLfloat); external dllname; + procedure glUniformMatrix4fv(location: GLint; count: GLsizei; transpose: GLboolean; const value: PGLfloat); external dllname; + procedure glValidateProgram(theProgram: GLuint); external dllname; + procedure glVertexAttrib1d(index: GLuint; x: GLdouble); external dllname; + procedure glVertexAttrib1dv(index: GLuint; const v: PGLdouble); external dllname; + procedure glVertexAttrib1f(index: GLuint; x: GLfloat); external dllname; + procedure glVertexAttrib1fv(index: GLuint; const v: PGLfloat); external dllname; + procedure glVertexAttrib1s(index: GLuint; x: GLshort); external dllname; + procedure glVertexAttrib1sv(index: GLuint; const v: PGLshort); external dllname; + procedure glVertexAttrib2d(index: GLuint; x: GLdouble; y: GLdouble); external dllname; + procedure glVertexAttrib2dv(index: GLuint; const v: PGLdouble); external dllname; + procedure glVertexAttrib2f(index: GLuint; x: GLfloat; y: GLfloat); external dllname; + procedure glVertexAttrib2fv(index: GLuint; const v: PGLfloat); external dllname; + procedure glVertexAttrib2s(index: GLuint; x: GLshort; y: GLshort); external dllname; + procedure glVertexAttrib2sv(index: GLuint; const v: PGLshort); external dllname; + procedure glVertexAttrib3d(index: GLuint; x: GLdouble; y: GLdouble; z: GLdouble); external dllname; + procedure glVertexAttrib3dv(index: GLuint; const v: PGLdouble); external dllname; + procedure glVertexAttrib3f(index: GLuint; x: GLfloat; y: GLfloat; z: GLfloat); external dllname; + procedure glVertexAttrib3fv(index: GLuint; const v: PGLfloat); external dllname; + procedure glVertexAttrib3s(index: GLuint; x: GLshort; y: GLshort; z: GLshort); external dllname; + procedure glVertexAttrib3sv(index: GLuint; const v: PGLshort); external dllname; + procedure glVertexAttrib4Nbv(index: GLuint; const v: PGLbyte); external dllname; + procedure glVertexAttrib4Niv(index: GLuint; const v: PGLint); external dllname; + procedure glVertexAttrib4Nsv(index: GLuint; const v: PGLshort); external dllname; + procedure glVertexAttrib4Nub(index: GLuint; x: GLubyte; y: GLubyte; z: GLubyte; w: GLubyte); external dllname; + procedure glVertexAttrib4Nubv(index: GLuint; const v: PGLubyte); external dllname; + procedure glVertexAttrib4Nuiv(index: GLuint; const v: PGLuint); external dllname; + procedure glVertexAttrib4Nusv(index: GLuint; const v: PGLushort); external dllname; + procedure glVertexAttrib4bv(index: GLuint; const v: PGLbyte); external dllname; + procedure glVertexAttrib4d(index: GLuint; x: GLdouble; y: GLdouble; z: GLdouble; w: GLdouble); external dllname; + procedure glVertexAttrib4dv(index: GLuint; const v: PGLdouble); external dllname; + procedure glVertexAttrib4f(index: GLuint; x: GLfloat; y: GLfloat; z: GLfloat; w: GLfloat); external dllname; + procedure glVertexAttrib4fv(index: GLuint; const v: PGLfloat); external dllname; + procedure glVertexAttrib4iv(index: GLuint; const v: PGLint); external dllname; + procedure glVertexAttrib4s(index: GLuint; x: GLshort; y: GLshort; z: GLshort; w: GLshort); external dllname; + procedure glVertexAttrib4sv(index: GLuint; const v: PGLshort); external dllname; + procedure glVertexAttrib4ubv(index: GLuint; const v: PGLubyte); external dllname; + procedure glVertexAttrib4uiv(index: GLuint; const v: PGLuint); external dllname; + procedure glVertexAttrib4usv(index: GLuint; const v: PGLushort); external dllname; + procedure glVertexAttribPointer(index: GLuint; size: GLint; thetype: GLenum; normalized: GLboolean; stride: GLsizei; const pointer: PGLvoid); external dllname; + + +implementation +end. diff --git a/lib/base/opengl/glu.nim b/lib/base/opengl/glu.nim new file mode 100644 index 000000000..297f4d354 --- /dev/null +++ b/lib/base/opengl/glu.nim @@ -0,0 +1,311 @@ +# +# +# Adaption of the delphi3d.net OpenGL units to FreePascal +# Sebastian Guenther (sg@freepascal.org) in 2002 +# These units are free to use +#****************************************************************************** +# Converted to Delphi by Tom Nuydens (tom@delphi3d.net) +# For the latest updates, visit Delphi3D: http://www.delphi3d.net +#****************************************************************************** + +import + GL + +when defined(windows): + const dllname = "glu32.dll" +elif defined(macosx): + const dllname = "/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib" +else: + const dllname = "libGLU.so.1" + +type + TViewPortArray* = array[0..3, TGLint] + T16dArray* = array[0..15, TGLdouble] + TCallBack* = proc () + T3dArray* = array[0..2, TGLdouble] + T4pArray* = array[0..3, Pointer] + T4fArray* = array[0..3, TGLfloat] + PPointer* = ptr Pointer + +type + GLUnurbs*{.final.} = object + PGLUnurbs* = ptr GLUnurbs + GLUquadric*{.final.} = object + PGLUquadric* = ptr GLUquadric + GLUtesselator*{.final.} = object + PGLUtesselator* = ptr GLUtesselator # backwards compatibility: + GLUnurbsObj* = GLUnurbs + PGLUnurbsObj* = PGLUnurbs + GLUquadricObj* = GLUquadric + PGLUquadricObj* = PGLUquadric + GLUtesselatorObj* = GLUtesselator + PGLUtesselatorObj* = PGLUtesselator + GLUtriangulatorObj* = GLUtesselator + PGLUtriangulatorObj* = PGLUtesselator + TGLUnurbs* = GLUnurbs + TGLUquadric* = GLUquadric + TGLUtesselator* = GLUtesselator + TGLUnurbsObj* = GLUnurbsObj + TGLUquadricObj* = GLUquadricObj + TGLUtesselatorObj* = GLUtesselatorObj + TGLUtriangulatorObj* = GLUtriangulatorObj + +proc gluErrorString*(errCode: TGLenum): cstring{.dynlib: dllname, importc.} +proc gluErrorUnicodeStringEXT*(errCode: TGLenum): ptr int16{.dynlib: dllname, + importc.} +proc gluGetString*(name: TGLenum): cstring{.dynlib: dllname, importc.} +proc gluOrtho2D*(left, right, bottom, top: TGLdouble){.dynlib: dllname, importc.} +proc gluPerspective*(fovy, aspect, zNear, zFar: TGLdouble){.dynlib: dllname, + importc.} +proc gluPickMatrix*(x, y, width, height: TGLdouble, viewport: var TViewPortArray){. + dynlib: dllname, importc.} +proc gluLookAt*(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz: TGLdouble){. + dynlib: dllname, importc.} +proc gluProject*(objx, objy, objz: TGLdouble, + modelMatrix, projMatrix: var T16dArray, + viewport: var TViewPortArray, winx, winy, winz: PGLdouble): int{. + dynlib: dllname, importc.} +proc gluUnProject*(winx, winy, winz: TGLdouble, + modelMatrix, projMatrix: var T16dArray, + viewport: var TViewPortArray, objx, objy, objz: PGLdouble): int{. + dynlib: dllname, importc.} +proc gluScaleImage*(format: TGLenum, widthin, heightin: TGLint, typein: TGLenum, + datain: Pointer, widthout, heightout: TGLint, + typeout: TGLenum, dataout: Pointer): int{.dynlib: dllname, + importc.} +proc gluBuild1DMipmaps*(target: TGLenum, components, width: TGLint, + format, atype: TGLenum, data: Pointer): int{. + dynlib: dllname, importc.} +proc gluBuild2DMipmaps*(target: TGLenum, components, width, height: TGLint, + format, atype: TGLenum, data: Pointer): int{. + dynlib: dllname, importc.} +proc gluNewQuadric*(): PGLUquadric{.dynlib: dllname, importc.} +proc gluDeleteQuadric*(state: PGLUquadric){.dynlib: dllname, importc.} +proc gluQuadricNormals*(quadObject: PGLUquadric, normals: TGLenum){. + dynlib: dllname, importc.} +proc gluQuadricTexture*(quadObject: PGLUquadric, textureCoords: TGLboolean){. + dynlib: dllname, importc.} +proc gluQuadricOrientation*(quadObject: PGLUquadric, orientation: TGLenum){. + dynlib: dllname, importc.} +proc gluQuadricDrawStyle*(quadObject: PGLUquadric, drawStyle: TGLenum){. + dynlib: dllname, importc.} +proc gluCylinder*(qobj: PGLUquadric, baseRadius, topRadius, height: TGLdouble, + slices, stacks: TGLint){.dynlib: dllname, importc.} +proc gluDisk*(qobj: PGLUquadric, innerRadius, outerRadius: TGLdouble, + slices, loops: TGLint){.dynlib: dllname, importc.} +proc gluPartialDisk*(qobj: PGLUquadric, innerRadius, outerRadius: TGLdouble, + slices, loops: TGLint, startAngle, sweepAngle: TGLdouble){. + dynlib: dllname, importc.} +proc gluSphere*(qobj: PGLuquadric, radius: TGLdouble, slices, stacks: TGLint){. + dynlib: dllname, importc.} +proc gluQuadricCallback*(qobj: PGLUquadric, which: TGLenum, fn: TCallBack){. + dynlib: dllname, importc.} +proc gluNewTess*(): PGLUtesselator{.dynlib: dllname, importc.} +proc gluDeleteTess*(tess: PGLUtesselator){.dynlib: dllname, importc.} +proc gluTessBeginPolygon*(tess: PGLUtesselator, polygon_data: Pointer){. + dynlib: dllname, importc.} +proc gluTessBeginContour*(tess: PGLUtesselator){.dynlib: dllname, importc.} +proc gluTessVertex*(tess: PGLUtesselator, coords: var T3dArray, data: Pointer){. + dynlib: dllname, importc.} +proc gluTessEndContour*(tess: PGLUtesselator){.dynlib: dllname, importc.} +proc gluTessEndPolygon*(tess: PGLUtesselator){.dynlib: dllname, importc.} +proc gluTessProperty*(tess: PGLUtesselator, which: TGLenum, value: TGLdouble){. + dynlib: dllname, importc.} +proc gluTessNormal*(tess: PGLUtesselator, x, y, z: TGLdouble){.dynlib: dllname, + importc.} +proc gluTessCallback*(tess: PGLUtesselator, which: TGLenum, fn: TCallBack){. + dynlib: dllname, importc.} +proc gluGetTessProperty*(tess: PGLUtesselator, which: TGLenum, value: PGLdouble){. + dynlib: dllname, importc.} +proc gluNewNurbsRenderer*(): PGLUnurbs{.dynlib: dllname, importc.} +proc gluDeleteNurbsRenderer*(nobj: PGLUnurbs){.dynlib: dllname, importc.} +proc gluBeginSurface*(nobj: PGLUnurbs){.dynlib: dllname, importc.} +proc gluBeginCurve*(nobj: PGLUnurbs){.dynlib: dllname, importc.} +proc gluEndCurve*(nobj: PGLUnurbs){.dynlib: dllname, importc.} +proc gluEndSurface*(nobj: PGLUnurbs){.dynlib: dllname, importc.} +proc gluBeginTrim*(nobj: PGLUnurbs){.dynlib: dllname, importc.} +proc gluEndTrim*(nobj: PGLUnurbs){.dynlib: dllname, importc.} +proc gluPwlCurve*(nobj: PGLUnurbs, count: TGLint, aarray: PGLfloat, + stride: TGLint, atype: TGLenum){.dynlib: dllname, importc.} +proc gluNurbsCurve*(nobj: PGLUnurbs, nknots: TGLint, knot: PGLfloat, + stride: TGLint, ctlarray: PGLfloat, order: TGLint, + atype: TGLenum){.dynlib: dllname, importc.} +proc gluNurbsSurface*(nobj: PGLUnurbs, sknot_count: TGLint, sknot: PGLfloat, + tknot_count: TGLint, tknot: PGLfloat, + s_stride, t_stride: TGLint, ctlarray: PGLfloat, + sorder, torder: TGLint, atype: TGLenum){.dynlib: dllname, + importc.} +proc gluLoadSamplingMatrices*(nobj: PGLUnurbs, + modelMatrix, projMatrix: var T16dArray, + viewport: var TViewPortArray){.dynlib: dllname, + importc.} +proc gluNurbsProperty*(nobj: PGLUnurbs, aproperty: TGLenum, value: TGLfloat){. + dynlib: dllname, importc.} +proc gluGetNurbsProperty*(nobj: PGLUnurbs, aproperty: TGLenum, value: PGLfloat){. + dynlib: dllname, importc.} +proc gluNurbsCallback*(nobj: PGLUnurbs, which: TGLenum, fn: TCallBack){. + dynlib: dllname, importc.} + #*** Callback function prototypes *** +type # gluQuadricCallback + GLUquadricErrorProc* = proc (p: TGLenum) # gluTessCallback + GLUtessBeginProc* = proc (p: TGLenum) + GLUtessEdgeFlagProc* = proc (p: TGLboolean) + GLUtessVertexProc* = proc (p: Pointer) + GLUtessEndProc* = proc () + GLUtessErrorProc* = proc (p: TGLenum) + GLUtessCombineProc* = proc (p1: var T3dArray, p2: T4pArray, p3: T4fArray, + p4: PPointer) + GLUtessBeginDataProc* = proc (p1: TGLenum, p2: Pointer) + GLUtessEdgeFlagDataProc* = proc (p1: TGLboolean, p2: Pointer) + GLUtessVertexDataProc* = proc (p1, p2: Pointer) + GLUtessEndDataProc* = proc (p: Pointer) + GLUtessErrorDataProc* = proc (p1: TGLenum, p2: Pointer) + GLUtessCombineDataProc* = proc (p1: var T3dArray, p2: var T4pArray, + p3: var T4fArray, p4: PPointer, p5: Pointer) # + # gluNurbsCallback + GLUnurbsErrorProc* = proc (p: TGLenum) #*** Generic constants ****/ + +const # Version + GLU_VERSION_1_1* = 1 + GLU_VERSION_1_2* = 1 # Errors: (return value 0 = no error) + GLU_INVALID_ENUM* = 100900 + GLU_INVALID_VALUE* = 100901 + GLU_OUT_OF_MEMORY* = 100902 + GLU_INCOMPATIBLE_GL_VERSION* = 100903 # StringName + GLU_VERSION* = 100800 + GLU_EXTENSIONS* = 100801 # Boolean + GLU_TRUE* = GL_TRUE + GLU_FALSE* = GL_FALSE #*** Quadric constants ****/ + # QuadricNormal + GLU_SMOOTH* = 100000 + GLU_FLAT* = 100001 + GLU_NONE* = 100002 # QuadricDrawStyle + GLU_POINT* = 100010 + GLU_LINE* = 100011 + GLU_FILL* = 100012 + GLU_SILHOUETTE* = 100013 # QuadricOrientation + GLU_OUTSIDE* = 100020 + GLU_INSIDE* = 100021 # Callback types: + # GLU_ERROR = 100103; + #*** Tesselation constants ****/ + GLU_TESS_MAX_COORD* = 1.00000e+150 # TessProperty + GLU_TESS_WINDING_RULE* = 100140 + GLU_TESS_BOUNDARY_ONLY* = 100141 + GLU_TESS_TOLERANCE* = 100142 # TessWinding + GLU_TESS_WINDING_ODD* = 100130 + GLU_TESS_WINDING_NONZERO* = 100131 + GLU_TESS_WINDING_POSITIVE* = 100132 + GLU_TESS_WINDING_NEGATIVE* = 100133 + GLU_TESS_WINDING_ABS_GEQ_TWO* = 100134 # TessCallback + GLU_TESS_BEGIN* = 100100 # void (CALLBACK*)(TGLenum type) + constGLU_TESS_VERTEX* = 100101 # void (CALLBACK*)(void *data) + GLU_TESS_END* = 100102 # void (CALLBACK*)(void) + GLU_TESS_ERROR* = 100103 # void (CALLBACK*)(TGLenum errno) + GLU_TESS_EDGE_FLAG* = 100104 # void (CALLBACK*)(TGLboolean boundaryEdge) + GLU_TESS_COMBINE* = 100105 # void (CALLBACK*)(TGLdouble coords[3], + # void *data[4], + # TGLfloat weight[4], + # void **dataOut) + GLU_TESS_BEGIN_DATA* = 100106 # void (CALLBACK*)(TGLenum type, + # void *polygon_data) + GLU_TESS_VERTEX_DATA* = 100107 # void (CALLBACK*)(void *data, + # void *polygon_data) + GLU_TESS_END_DATA* = 100108 # void (CALLBACK*)(void *polygon_data) + GLU_TESS_ERROR_DATA* = 100109 # void (CALLBACK*)(TGLenum errno, + # void *polygon_data) + GLU_TESS_EDGE_FLAG_DATA* = 100110 # void (CALLBACK*)(TGLboolean boundaryEdge, + # void *polygon_data) + GLU_TESS_COMBINE_DATA* = 100111 # void (CALLBACK*)(TGLdouble coords[3], + # void *data[4], + # TGLfloat weight[4], + # void **dataOut, + # void *polygon_data) + # TessError + GLU_TESS_ERROR1* = 100151 + GLU_TESS_ERROR2* = 100152 + GLU_TESS_ERROR3* = 100153 + GLU_TESS_ERROR4* = 100154 + GLU_TESS_ERROR5* = 100155 + GLU_TESS_ERROR6* = 100156 + GLU_TESS_ERROR7* = 100157 + GLU_TESS_ERROR8* = 100158 + GLU_TESS_MISSING_BEGIN_POLYGON* = GLU_TESS_ERROR1 + GLU_TESS_MISSING_BEGIN_CONTOUR* = GLU_TESS_ERROR2 + GLU_TESS_MISSING_END_POLYGON* = GLU_TESS_ERROR3 + GLU_TESS_MISSING_END_CONTOUR* = GLU_TESS_ERROR4 + GLU_TESS_COORD_TOO_LARGE* = GLU_TESS_ERROR5 + GLU_TESS_NEED_COMBINE_CALLBACK* = GLU_TESS_ERROR6 #*** NURBS constants ****/ + # NurbsProperty + GLU_AUTO_LOAD_MATRIX* = 100200 + GLU_CULLING* = 100201 + GLU_SAMPLING_TOLERANCE* = 100203 + GLU_DISPLAY_MODE* = 100204 + GLU_PARAMETRIC_TOLERANCE* = 100202 + GLU_SAMPLING_METHOD* = 100205 + GLU_U_STEP* = 100206 + GLU_V_STEP* = 100207 # NurbsSampling + GLU_PATH_LENGTH* = 100215 + GLU_PARAMETRIC_ERROR* = 100216 + GLU_DOMAIN_DISTANCE* = 100217 # NurbsTrim + GLU_MAP1_TRIM_2* = 100210 + GLU_MAP1_TRIM_3* = 100211 # NurbsDisplay + # GLU_FILL = 100012; + GLU_OUTLINE_POLYGON* = 100240 + GLU_OUTLINE_PATCH* = 100241 # NurbsCallback + # GLU_ERROR = 100103; + # NurbsErrors + GLU_NURBS_ERROR1* = 100251 + GLU_NURBS_ERROR2* = 100252 + GLU_NURBS_ERROR3* = 100253 + GLU_NURBS_ERROR4* = 100254 + GLU_NURBS_ERROR5* = 100255 + GLU_NURBS_ERROR6* = 100256 + GLU_NURBS_ERROR7* = 100257 + GLU_NURBS_ERROR8* = 100258 + GLU_NURBS_ERROR9* = 100259 + GLU_NURBS_ERROR10* = 100260 + GLU_NURBS_ERROR11* = 100261 + GLU_NURBS_ERROR12* = 100262 + GLU_NURBS_ERROR13* = 100263 + GLU_NURBS_ERROR14* = 100264 + GLU_NURBS_ERROR15* = 100265 + GLU_NURBS_ERROR16* = 100266 + GLU_NURBS_ERROR17* = 100267 + GLU_NURBS_ERROR18* = 100268 + GLU_NURBS_ERROR19* = 100269 + GLU_NURBS_ERROR20* = 100270 + GLU_NURBS_ERROR21* = 100271 + GLU_NURBS_ERROR22* = 100272 + GLU_NURBS_ERROR23* = 100273 + GLU_NURBS_ERROR24* = 100274 + GLU_NURBS_ERROR25* = 100275 + GLU_NURBS_ERROR26* = 100276 + GLU_NURBS_ERROR27* = 100277 + GLU_NURBS_ERROR28* = 100278 + GLU_NURBS_ERROR29* = 100279 + GLU_NURBS_ERROR30* = 100280 + GLU_NURBS_ERROR31* = 100281 + GLU_NURBS_ERROR32* = 100282 + GLU_NURBS_ERROR33* = 100283 + GLU_NURBS_ERROR34* = 100284 + GLU_NURBS_ERROR35* = 100285 + GLU_NURBS_ERROR36* = 100286 + GLU_NURBS_ERROR37* = 100287 #*** Backwards compatibility for old tesselator ****/ + +proc gluBeginPolygon*(tess: PGLUtesselator){.dynlib: dllname, importc.} +proc gluNextContour*(tess: PGLUtesselator, atype: TGLenum){.dynlib: dllname, + importc.} +proc gluEndPolygon*(tess: PGLUtesselator){.dynlib: dllname, importc.} +const # Contours types -- obsolete! + GLU_CW* = 100120 + GLU_CCW* = 100121 + GLU_INTERIOR* = 100122 + GLU_EXTERIOR* = 100123 + GLU_UNKNOWN* = 100124 # Names without "TESS_" prefix + GLU_BEGIN* = GLU_TESS_BEGIN + GLU_VERTEX* = constGLU_TESS_VERTEX + GLU_END* = GLU_TESS_END + GLU_ERROR* = GLU_TESS_ERROR + GLU_EDGE_FLAG* = GLU_TESS_EDGE_FLAG + +# implementation diff --git a/lib/base/opengl/glu.pp b/lib/base/opengl/glu.pp new file mode 100644 index 000000000..1594085ed --- /dev/null +++ b/lib/base/opengl/glu.pp @@ -0,0 +1,368 @@ +{ + + Adaption of the delphi3d.net OpenGL units to FreePascal + Sebastian Guenther (sg@freepascal.org) in 2002 + These units are free to use +} + +{*++ BUILD Version: 0004 // Increment this if a change has global effects + +Copyright (c) 1985-95, Microsoft Corporation + +Module Name: + + glu.h + +Abstract: + + Procedure declarations, constant definitions and macros for the OpenGL + Utility Library. + +--*} + +{* +** Copyright 1991-1993, Silicon Graphics, Inc. +** All Rights Reserved. +** +** This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; +** the contents of this file may not be disclosed to third parties, copied or +** duplicated in any form, in whole or in part, without the prior written +** permission of Silicon Graphics, Inc. +** +** RESTRICTED RIGHTS LEGEND: +** Use, duplication or disclosure by the Government is subject to restrictions +** as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data +** and Computer Software clause at DFARS 252.227-7013, and/or in similar or +** successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished - +** rights reserved under the Copyright Laws of the United States. +*} + +{* +** Return the error string associated with a particular error code. +** This will return 0 for an invalid error code. +** +** The generic function prototype that can be compiled for ANSI or Unicode +** is defined as follows: +** +** LPCTSTR APIENTRY gluErrorStringWIN (GLenum errCode); +*} + +{******************************************************************************} +{ Converted to Delphi by Tom Nuydens (tom@delphi3d.net) } +{ For the latest updates, visit Delphi3D: http://www.delphi3d.net } +{******************************************************************************} + +unit GLu; + +interface + +uses + GL; + +const + dllname = 'glu32.dll'; + dylibname = '/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib'; + libname = 'libGLU.so.1'; + +type + TViewPortArray = array [0..3] of GLint; + T16dArray = array [0..15] of GLdouble; + TCallBack = procedure; + T3dArray = array [0..2] of GLdouble; + T4pArray = array [0..3] of Pointer; + T4fArray = array [0..3] of GLfloat; + PPointer = ^Pointer; + +type + GLUnurbs = record end; PGLUnurbs = ^GLUnurbs; + GLUquadric = record end; PGLUquadric = ^GLUquadric; + GLUtesselator = record end; PGLUtesselator = ^GLUtesselator; + + // backwards compatibility: + GLUnurbsObj = GLUnurbs; PGLUnurbsObj = PGLUnurbs; + GLUquadricObj = GLUquadric; PGLUquadricObj = PGLUquadric; + GLUtesselatorObj = GLUtesselator; PGLUtesselatorObj = PGLUtesselator; + GLUtriangulatorObj = GLUtesselator; PGLUtriangulatorObj = PGLUtesselator; + + TGLUnurbs = GLUnurbs; + TGLUquadric = GLUquadric; + TGLUtesselator = GLUtesselator; + + TGLUnurbsObj = GLUnurbsObj; + TGLUquadricObj = GLUquadricObj; + TGLUtesselatorObj = GLUtesselatorObj; + TGLUtriangulatorObj = GLUtriangulatorObj; + + + function gluErrorString(errCode: GLenum): PChar; external dllname; + function gluErrorUnicodeStringEXT(errCode: GLenum): PWideChar; external dllname; + function gluGetString(name: GLenum): PChar; external dllname; + procedure gluOrtho2D(left,right, bottom, top: GLdouble); external dllname; + procedure gluPerspective(fovy, aspect, zNear, zFar: GLdouble); external dllname; + procedure gluPickMatrix(x, y, width, height: GLdouble; var viewport: TViewPortArray); external dllname; + procedure gluLookAt(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz: GLdouble); external dllname; + function gluProject(objx, objy, objz: GLdouble; var modelMatrix, projMatrix: T16dArray; var viewport: TViewPortArray; winx, winy, winz: PGLdouble): Integer; external dllname; + function gluUnProject(winx, winy, winz: GLdouble; var modelMatrix, projMatrix: T16dArray; var viewport: TViewPortArray; objx, objy, objz: PGLdouble): Integer; external dllname; + function gluScaleImage(format: GLenum; widthin, heightin: GLint; typein: GLenum; const datain: Pointer; widthout, heightout: GLint; typeout: GLenum; dataout: Pointer): Integer; external dllname; + function gluBuild1DMipmaps(target: GLenum; components, width: GLint; format, atype: GLenum; const data: Pointer): Integer; external dllname; + function gluBuild2DMipmaps(target: GLenum; components, width, height: GLint; format, atype: GLenum; const data: Pointer): Integer; external dllname; + + + function gluNewQuadric: PGLUquadric; external dllname; + procedure gluDeleteQuadric(state: PGLUquadric); external dllname; + procedure gluQuadricNormals(quadObject: PGLUquadric; normals: GLenum); external dllname; + procedure gluQuadricTexture(quadObject: PGLUquadric; textureCoords: GLboolean); external dllname; + procedure gluQuadricOrientation(quadObject: PGLUquadric; orientation: GLenum); external dllname; + procedure gluQuadricDrawStyle(quadObject: PGLUquadric; drawStyle: GLenum); external dllname; + procedure gluCylinder(qobj: PGLUquadric; baseRadius, topRadius, height: GLdouble; slices, stacks: GLint); external dllname; + procedure gluDisk(qobj: PGLUquadric; innerRadius, outerRadius: GLdouble; slices, loops: GLint); external dllname; + procedure gluPartialDisk(qobj: PGLUquadric; innerRadius, outerRadius: GLdouble; slices, loops: GLint; startAngle, sweepAngle: GLdouble); external dllname; + procedure gluSphere(qobj: PGLuquadric; radius: GLdouble; slices, stacks: GLint); external dllname; + procedure gluQuadricCallback(qobj: PGLUquadric; which: GLenum; fn: TCallBack); external dllname; + function gluNewTess: PGLUtesselator; external dllname; + procedure gluDeleteTess(tess: PGLUtesselator); external dllname; + procedure gluTessBeginPolygon(tess: PGLUtesselator; polygon_data: Pointer); external dllname; + procedure gluTessBeginContour(tess: PGLUtesselator); external dllname; + procedure gluTessVertex(tess: PGLUtesselator; var coords: T3dArray; data: Pointer); external dllname; + procedure gluTessEndContour(tess: PGLUtesselator); external dllname; + procedure gluTessEndPolygon(tess: PGLUtesselator); external dllname; + procedure gluTessProperty(tess: PGLUtesselator; which: GLenum; value: GLdouble); external dllname; + procedure gluTessNormal(tess: PGLUtesselator; x, y, z: GLdouble); external dllname; + procedure gluTessCallback(tess: PGLUtesselator; which: GLenum;fn: TCallBack); external dllname; + procedure gluGetTessProperty(tess: PGLUtesselator; which: GLenum; value: PGLdouble); external dllname; + function gluNewNurbsRenderer: PGLUnurbs; external dllname; + procedure gluDeleteNurbsRenderer(nobj: PGLUnurbs); external dllname; + procedure gluBeginSurface(nobj: PGLUnurbs); external dllname; + procedure gluBeginCurve(nobj: PGLUnurbs); external dllname; + procedure gluEndCurve(nobj: PGLUnurbs); external dllname; + procedure gluEndSurface(nobj: PGLUnurbs); external dllname; + procedure gluBeginTrim(nobj: PGLUnurbs); external dllname; + procedure gluEndTrim(nobj: PGLUnurbs); external dllname; + procedure gluPwlCurve(nobj: PGLUnurbs; count: GLint; aarray: PGLfloat; stride: GLint; atype: GLenum); external dllname; + procedure gluNurbsCurve(nobj: PGLUnurbs; nknots: GLint; knot: PGLfloat; stride: GLint; ctlarray: PGLfloat; order: GLint; atype: GLenum); external dllname; + procedure gluNurbsSurface(nobj: PGLUnurbs; sknot_count: GLint; sknot: PGLfloat; tknot_count: GLint; tknot: PGLfloat; s_stride, t_stride: GLint; ctlarray: PGLfloat; sorder, torder: GLint; atype: GLenum); external dllname; + procedure gluLoadSamplingMatrices(nobj: PGLUnurbs; var modelMatrix, projMatrix: T16dArray; var viewport: TViewPortArray); external dllname; + procedure gluNurbsProperty(nobj: PGLUnurbs; aproperty: GLenum; value: GLfloat); external dllname; + procedure gluGetNurbsProperty(nobj: PGLUnurbs; aproperty: GLenum; value: PGLfloat); external dllname; + procedure gluNurbsCallback(nobj: PGLUnurbs; which: GLenum; fn: TCallBack); external dllname; + +(**** Callback function prototypes ****) + +type + // gluQuadricCallback + GLUquadricErrorProc = procedure(p: GLenum); + + // gluTessCallback + GLUtessBeginProc = procedure(p: GLenum); + GLUtessEdgeFlagProc = procedure(p: GLboolean); + GLUtessVertexProc = procedure(p: Pointer); + GLUtessEndProc = procedure; + GLUtessErrorProc = procedure(p: GLenum); + GLUtessCombineProc = procedure(var p1: T3dArray; p2: T4pArray; p3: T4fArray; p4: PPointer); + GLUtessBeginDataProc = procedure(p1: GLenum; p2: Pointer); + GLUtessEdgeFlagDataProc = procedure(p1: GLboolean; p2: Pointer); + GLUtessVertexDataProc = procedure(p1, p2: Pointer); + GLUtessEndDataProc = procedure(p: Pointer); + GLUtessErrorDataProc = procedure(p1: GLenum; p2: Pointer); + GLUtessCombineDataProc = procedure(var p1: T3dArray; var p2: T4pArray; var p3: T4fArray; + p4: PPointer; p5: Pointer); + + // gluNurbsCallback + GLUnurbsErrorProc = procedure(p: GLenum); + + +//*** Generic constants ****/ + +const + // Version + GLU_VERSION_1_1 = 1; + GLU_VERSION_1_2 = 1; + + // Errors: (return value 0 = no error) + GLU_INVALID_ENUM = 100900; + GLU_INVALID_VALUE = 100901; + GLU_OUT_OF_MEMORY = 100902; + GLU_INCOMPATIBLE_GL_VERSION = 100903; + + // StringName + GLU_VERSION = 100800; + GLU_EXTENSIONS = 100801; + + // Boolean + GLU_TRUE = GL_TRUE; + GLU_FALSE = GL_FALSE; + + + //*** Quadric constants ****/ + + // QuadricNormal + GLU_SMOOTH = 100000; + GLU_FLAT = 100001; + GLU_NONE = 100002; + + // QuadricDrawStyle + GLU_POINT = 100010; + GLU_LINE = 100011; + GLU_FILL = 100012; + GLU_SILHOUETTE = 100013; + + // QuadricOrientation + GLU_OUTSIDE = 100020; + GLU_INSIDE = 100021; + + // Callback types: + // GLU_ERROR = 100103; + + + //*** Tesselation constants ****/ + + GLU_TESS_MAX_COORD = 1.0e150; + + // TessProperty + GLU_TESS_WINDING_RULE = 100140; + GLU_TESS_BOUNDARY_ONLY = 100141; + GLU_TESS_TOLERANCE = 100142; + + // TessWinding + GLU_TESS_WINDING_ODD = 100130; + GLU_TESS_WINDING_NONZERO = 100131; + GLU_TESS_WINDING_POSITIVE = 100132; + GLU_TESS_WINDING_NEGATIVE = 100133; + GLU_TESS_WINDING_ABS_GEQ_TWO = 100134; + + // TessCallback + GLU_TESS_BEGIN = 100100; // void (CALLBACK*)(GLenum type) + GLU_TESS_VERTEX = 100101; // void (CALLBACK*)(void *data) + GLU_TESS_END = 100102; // void (CALLBACK*)(void) + GLU_TESS_ERROR = 100103; // void (CALLBACK*)(GLenum errno) + GLU_TESS_EDGE_FLAG = 100104; // void (CALLBACK*)(GLboolean boundaryEdge) + GLU_TESS_COMBINE = 100105; { void (CALLBACK*)(GLdouble coords[3], + void *data[4], + GLfloat weight[4], + void **dataOut) } + GLU_TESS_BEGIN_DATA = 100106; { void (CALLBACK*)(GLenum type, + void *polygon_data) } + GLU_TESS_VERTEX_DATA = 100107; { void (CALLBACK*)(void *data, + void *polygon_data) } + GLU_TESS_END_DATA = 100108; // void (CALLBACK*)(void *polygon_data) + GLU_TESS_ERROR_DATA = 100109; { void (CALLBACK*)(GLenum errno, + void *polygon_data) } + GLU_TESS_EDGE_FLAG_DATA = 100110; { void (CALLBACK*)(GLboolean boundaryEdge, + void *polygon_data) } + GLU_TESS_COMBINE_DATA = 100111; { void (CALLBACK*)(GLdouble coords[3], + void *data[4], + GLfloat weight[4], + void **dataOut, + void *polygon_data) } + + // TessError + GLU_TESS_ERROR1 = 100151; + GLU_TESS_ERROR2 = 100152; + GLU_TESS_ERROR3 = 100153; + GLU_TESS_ERROR4 = 100154; + GLU_TESS_ERROR5 = 100155; + GLU_TESS_ERROR6 = 100156; + GLU_TESS_ERROR7 = 100157; + GLU_TESS_ERROR8 = 100158; + + GLU_TESS_MISSING_BEGIN_POLYGON = GLU_TESS_ERROR1; + GLU_TESS_MISSING_BEGIN_CONTOUR = GLU_TESS_ERROR2; + GLU_TESS_MISSING_END_POLYGON = GLU_TESS_ERROR3; + GLU_TESS_MISSING_END_CONTOUR = GLU_TESS_ERROR4; + GLU_TESS_COORD_TOO_LARGE = GLU_TESS_ERROR5; + GLU_TESS_NEED_COMBINE_CALLBACK = GLU_TESS_ERROR6; + + //*** NURBS constants ****/ + + // NurbsProperty + GLU_AUTO_LOAD_MATRIX = 100200; + GLU_CULLING = 100201; + GLU_SAMPLING_TOLERANCE = 100203; + GLU_DISPLAY_MODE = 100204; + GLU_PARAMETRIC_TOLERANCE = 100202; + GLU_SAMPLING_METHOD = 100205; + GLU_U_STEP = 100206; + GLU_V_STEP = 100207; + + // NurbsSampling + GLU_PATH_LENGTH = 100215; + GLU_PARAMETRIC_ERROR = 100216; + GLU_DOMAIN_DISTANCE = 100217; + + + // NurbsTrim + GLU_MAP1_TRIM_2 = 100210; + GLU_MAP1_TRIM_3 = 100211; + + // NurbsDisplay + // GLU_FILL = 100012; + GLU_OUTLINE_POLYGON = 100240; + GLU_OUTLINE_PATCH = 100241; + + // NurbsCallback + // GLU_ERROR = 100103; + + // NurbsErrors + GLU_NURBS_ERROR1 = 100251; + GLU_NURBS_ERROR2 = 100252; + GLU_NURBS_ERROR3 = 100253; + GLU_NURBS_ERROR4 = 100254; + GLU_NURBS_ERROR5 = 100255; + GLU_NURBS_ERROR6 = 100256; + GLU_NURBS_ERROR7 = 100257; + GLU_NURBS_ERROR8 = 100258; + GLU_NURBS_ERROR9 = 100259; + GLU_NURBS_ERROR10 = 100260; + GLU_NURBS_ERROR11 = 100261; + GLU_NURBS_ERROR12 = 100262; + GLU_NURBS_ERROR13 = 100263; + GLU_NURBS_ERROR14 = 100264; + GLU_NURBS_ERROR15 = 100265; + GLU_NURBS_ERROR16 = 100266; + GLU_NURBS_ERROR17 = 100267; + GLU_NURBS_ERROR18 = 100268; + GLU_NURBS_ERROR19 = 100269; + GLU_NURBS_ERROR20 = 100270; + GLU_NURBS_ERROR21 = 100271; + GLU_NURBS_ERROR22 = 100272; + GLU_NURBS_ERROR23 = 100273; + GLU_NURBS_ERROR24 = 100274; + GLU_NURBS_ERROR25 = 100275; + GLU_NURBS_ERROR26 = 100276; + GLU_NURBS_ERROR27 = 100277; + GLU_NURBS_ERROR28 = 100278; + GLU_NURBS_ERROR29 = 100279; + GLU_NURBS_ERROR30 = 100280; + GLU_NURBS_ERROR31 = 100281; + GLU_NURBS_ERROR32 = 100282; + GLU_NURBS_ERROR33 = 100283; + GLU_NURBS_ERROR34 = 100284; + GLU_NURBS_ERROR35 = 100285; + GLU_NURBS_ERROR36 = 100286; + GLU_NURBS_ERROR37 = 100287; + +//*** Backwards compatibility for old tesselator ****/ + + + procedure gluBeginPolygon(tess: PGLUtesselator); external dllname; + procedure gluNextContour(tess: PGLUtesselator; atype: GLenum); external dllname; + procedure gluEndPolygon(tess: PGLUtesselator); external dllname; + +const + // Contours types -- obsolete! + GLU_CW = 100120; + GLU_CCW = 100121; + GLU_INTERIOR = 100122; + GLU_EXTERIOR = 100123; + GLU_UNKNOWN = 100124; + + // Names without "TESS_" prefix + GLU_BEGIN = GLU_TESS_BEGIN; + GLU_VERTEX = GLU_TESS_VERTEX; + GLU_END = GLU_TESS_END; + GLU_ERROR = GLU_TESS_ERROR; + GLU_EDGE_FLAG = GLU_TESS_EDGE_FLAG; + +implementation + +end. diff --git a/lib/base/opengl/glut.nim b/lib/base/opengl/glut.nim new file mode 100644 index 000000000..55ee18bda --- /dev/null +++ b/lib/base/opengl/glut.nim @@ -0,0 +1,378 @@ +# +# +# Adaption of the delphi3d.net OpenGL units to FreePascal +# Sebastian Guenther (sg@freepascal.org) in 2002 +# These units are free to use +# + +# Copyright (c) Mark J. Kilgard, 1994, 1995, 1996. +# This program is freely distributable without licensing fees and is +# provided without guarantee or warrantee expressed or implied. This +# program is -not- in the public domain. +#****************************************************************************** +# Converted to Delphi by Tom Nuydens (tom@delphi3d.net) +# Contributions by Igor Karpov (glygrik@hotbox.ru) +# For the latest updates, visit Delphi3D: http://www.delphi3d.net +#****************************************************************************** + +import + GL + +when defined(windows): + const dllname = "glut32.dll" +elif defined(macosx): + const dllname = "/System/Library/Frameworks/GLUT.framework/GLUT" +else: + const dllname = "libglut.so.3" + +type + PInteger* = ptr int + PPChar* = ptr cstring + TGlutVoidCallback* = proc (){.cdecl.} + TGlut1IntCallback* = proc (value: cint){.cdecl.} + TGlut2IntCallback* = proc (v1, v2: cint){.cdecl.} + TGlut3IntCallback* = proc (v1, v2, v3: cint){.cdecl.} + TGlut4IntCallback* = proc (v1, v2, v3, v4: cint){.cdecl.} + TGlut1Char2IntCallback* = proc (c: int8, v1, v2: cint){.cdecl.} + TGlut1UInt3IntCallback* = proc (u, v1, v2, v3: cint){.cdecl.} + +const + GLUT_API_VERSION* = 3 + GLUT_XLIB_IMPLEMENTATION* = 12 # Display mode bit masks. + GLUT_RGB* = 0 + GLUT_RGBA* = GLUT_RGB + GLUT_INDEX* = 1 + GLUT_SINGLE* = 0 + GLUT_DOUBLE* = 2 + GLUT_ACCUM* = 4 + GLUT_ALPHA* = 8 + GLUT_DEPTH* = 16 + GLUT_STENCIL* = 32 + GLUT_MULTISAMPLE* = 128 + GLUT_STEREO* = 256 + GLUT_LUMINANCE* = 512 # Mouse buttons. + GLUT_LEFT_BUTTON* = 0 + GLUT_MIDDLE_BUTTON* = 1 + GLUT_RIGHT_BUTTON* = 2 # Mouse button state. + GLUT_DOWN* = 0 + GLUT_UP* = 1 # function keys + GLUT_KEY_F1* = 1 + GLUT_KEY_F2* = 2 + GLUT_KEY_F3* = 3 + GLUT_KEY_F4* = 4 + GLUT_KEY_F5* = 5 + GLUT_KEY_F6* = 6 + GLUT_KEY_F7* = 7 + GLUT_KEY_F8* = 8 + GLUT_KEY_F9* = 9 + GLUT_KEY_F10* = 10 + GLUT_KEY_F11* = 11 + GLUT_KEY_F12* = 12 # directional keys + GLUT_KEY_LEFT* = 100 + GLUT_KEY_UP* = 101 + GLUT_KEY_RIGHT* = 102 + GLUT_KEY_DOWN* = 103 + GLUT_KEY_PAGE_UP* = 104 + GLUT_KEY_PAGE_DOWN* = 105 + GLUT_KEY_HOME* = 106 + GLUT_KEY_END* = 107 + GLUT_KEY_INSERT* = 108 # Entry/exit state. + GLUT_LEFT* = 0 + GLUT_ENTERED* = 1 # Menu usage state. + GLUT_MENU_NOT_IN_USE* = 0 + GLUT_MENU_IN_USE* = 1 # Visibility state. + GLUT_NOT_VISIBLE* = 0 + GLUT_VISIBLE* = 1 # Window status state. + GLUT_HIDDEN* = 0 + GLUT_FULLY_RETAINED* = 1 + GLUT_PARTIALLY_RETAINED* = 2 + GLUT_FULLY_COVERED* = 3 # Color index component selection values. + GLUT_RED* = 0 + GLUT_GREEN* = 1 + GLUT_BLUE* = 2 # Layers for use. + GLUT_NORMAL* = 0 + GLUT_OVERLAY* = 1 + +when defined(Windows): + const # Stroke font constants (use these in GLUT program). + GLUT_STROKE_ROMAN* = cast[Pointer](0) + GLUT_STROKE_MONO_ROMAN* = cast[Pointer](1) # Bitmap font constants (use these in GLUT program). + GLUT_BITMAP_9_BY_15* = cast[Pointer](2) + GLUT_BITMAP_8_BY_13* = cast[Pointer](3) + GLUT_BITMAP_TIMES_ROMAN_10* = cast[Pointer](4) + GLUT_BITMAP_TIMES_ROMAN_24* = cast[Pointer](5) + GLUT_BITMAP_HELVETICA_10* = cast[Pointer](6) + GLUT_BITMAP_HELVETICA_12* = cast[Pointer](7) + GLUT_BITMAP_HELVETICA_18* = cast[Pointer](8) +else: + var # Stroke font constants (use these in GLUT program). + GLUT_STROKE_ROMAN*: Pointer + GLUT_STROKE_MONO_ROMAN*: Pointer # Bitmap font constants (use these in GLUT program). + GLUT_BITMAP_9_BY_15*: Pointer + GLUT_BITMAP_8_BY_13*: Pointer + GLUT_BITMAP_TIMES_ROMAN_10*: Pointer + GLUT_BITMAP_TIMES_ROMAN_24*: Pointer + GLUT_BITMAP_HELVETICA_10*: Pointer + GLUT_BITMAP_HELVETICA_12*: Pointer + GLUT_BITMAP_HELVETICA_18*: Pointer +const # glutGet parameters. + GLUT_WINDOW_X* = 100 + GLUT_WINDOW_Y* = 101 + GLUT_WINDOW_WIDTH* = 102 + GLUT_WINDOW_HEIGHT* = 103 + GLUT_WINDOW_BUFFER_SIZE* = 104 + GLUT_WINDOW_STENCIL_SIZE* = 105 + GLUT_WINDOW_DEPTH_SIZE* = 106 + GLUT_WINDOW_RED_SIZE* = 107 + GLUT_WINDOW_GREEN_SIZE* = 108 + GLUT_WINDOW_BLUE_SIZE* = 109 + GLUT_WINDOW_ALPHA_SIZE* = 110 + GLUT_WINDOW_ACCUM_RED_SIZE* = 111 + GLUT_WINDOW_ACCUM_GREEN_SIZE* = 112 + GLUT_WINDOW_ACCUM_BLUE_SIZE* = 113 + GLUT_WINDOW_ACCUM_ALPHA_SIZE* = 114 + GLUT_WINDOW_DOUBLEBUFFER* = 115 + GLUT_WINDOW_RGBA* = 116 + GLUT_WINDOW_PARENT* = 117 + GLUT_WINDOW_NUM_CHILDREN* = 118 + GLUT_WINDOW_COLORMAP_SIZE* = 119 + GLUT_WINDOW_NUM_SAMPLES* = 120 + GLUT_WINDOW_STEREO* = 121 + GLUT_WINDOW_CURSOR* = 122 + GLUT_SCREEN_WIDTH* = 200 + GLUT_SCREEN_HEIGHT* = 201 + GLUT_SCREEN_WIDTH_MM* = 202 + GLUT_SCREEN_HEIGHT_MM* = 203 + GLUT_MENU_NUM_ITEMS* = 300 + GLUT_DISPLAY_MODE_POSSIBLE* = 400 + GLUT_INIT_WINDOW_X* = 500 + GLUT_INIT_WINDOW_Y* = 501 + GLUT_INIT_WINDOW_WIDTH* = 502 + GLUT_INIT_WINDOW_HEIGHT* = 503 + constGLUT_INIT_DISPLAY_MODE* = 504 + GLUT_ELAPSED_TIME* = 700 + GLUT_WINDOW_FORMAT_ID* = 123 # glutDeviceGet parameters. + GLUT_HAS_KEYBOARD* = 600 + GLUT_HAS_MOUSE* = 601 + GLUT_HAS_SPACEBALL* = 602 + GLUT_HAS_DIAL_AND_BUTTON_BOX* = 603 + GLUT_HAS_TABLET* = 604 + GLUT_NUM_MOUSE_BUTTONS* = 605 + GLUT_NUM_SPACEBALL_BUTTONS* = 606 + GLUT_NUM_BUTTON_BOX_BUTTONS* = 607 + GLUT_NUM_DIALS* = 608 + GLUT_NUM_TABLET_BUTTONS* = 609 + GLUT_DEVICE_IGNORE_KEY_REPEAT* = 610 + GLUT_DEVICE_KEY_REPEAT* = 611 + GLUT_HAS_JOYSTICK* = 612 + GLUT_OWNS_JOYSTICK* = 613 + GLUT_JOYSTICK_BUTTONS* = 614 + GLUT_JOYSTICK_AXES* = 615 + GLUT_JOYSTICK_POLL_RATE* = 616 # glutLayerGet parameters. + GLUT_OVERLAY_POSSIBLE* = 800 + GLUT_LAYER_IN_USE* = 801 + GLUT_HAS_OVERLAY* = 802 + GLUT_TRANSPARENT_INDEX* = 803 + GLUT_NORMAL_DAMAGED* = 804 + GLUT_OVERLAY_DAMAGED* = 805 # glutVideoResizeGet parameters. + GLUT_VIDEO_RESIZE_POSSIBLE* = 900 + GLUT_VIDEO_RESIZE_IN_USE* = 901 + GLUT_VIDEO_RESIZE_X_DELTA* = 902 + GLUT_VIDEO_RESIZE_Y_DELTA* = 903 + GLUT_VIDEO_RESIZE_WIDTH_DELTA* = 904 + GLUT_VIDEO_RESIZE_HEIGHT_DELTA* = 905 + GLUT_VIDEO_RESIZE_X* = 906 + GLUT_VIDEO_RESIZE_Y* = 907 + GLUT_VIDEO_RESIZE_WIDTH* = 908 + GLUT_VIDEO_RESIZE_HEIGHT* = 909 # glutGetModifiers return mask. + GLUT_ACTIVE_SHIFT* = 1 + GLUT_ACTIVE_CTRL* = 2 + GLUT_ACTIVE_ALT* = 4 # glutSetCursor parameters. + # Basic arrows. + GLUT_CURSOR_RIGHT_ARROW* = 0 + GLUT_CURSOR_LEFT_ARROW* = 1 # Symbolic cursor shapes. + GLUT_CURSOR_INFO* = 2 + GLUT_CURSOR_DESTROY* = 3 + GLUT_CURSOR_HELP* = 4 + GLUT_CURSOR_CYCLE* = 5 + GLUT_CURSOR_SPRAY* = 6 + GLUT_CURSOR_WAIT* = 7 + GLUT_CURSOR_TEXT* = 8 + GLUT_CURSOR_CROSSHAIR* = 9 # Directional cursors. + GLUT_CURSOR_UP_DOWN* = 10 + GLUT_CURSOR_LEFT_RIGHT* = 11 # Sizing cursors. + GLUT_CURSOR_TOP_SIDE* = 12 + GLUT_CURSOR_BOTTOM_SIDE* = 13 + GLUT_CURSOR_LEFT_SIDE* = 14 + GLUT_CURSOR_RIGHT_SIDE* = 15 + GLUT_CURSOR_TOP_LEFT_CORNER* = 16 + GLUT_CURSOR_TOP_RIGHT_CORNER* = 17 + GLUT_CURSOR_BOTTOM_RIGHT_CORNER* = 18 + GLUT_CURSOR_BOTTOM_LEFT_CORNER* = 19 # Inherit from parent window. + GLUT_CURSOR_INHERIT* = 100 # Blank cursor. + GLUT_CURSOR_NONE* = 101 # Fullscreen crosshair (if available). + GLUT_CURSOR_FULL_CROSSHAIR* = 102 # GLUT device control sub-API. + # glutSetKeyRepeat modes. + GLUT_KEY_REPEAT_OFF* = 0 + GLUT_KEY_REPEAT_ON* = 1 + GLUT_KEY_REPEAT_DEFAULT* = 2 # Joystick button masks. + GLUT_JOYSTICK_BUTTON_A* = 1 + GLUT_JOYSTICK_BUTTON_B* = 2 + GLUT_JOYSTICK_BUTTON_C* = 4 + GLUT_JOYSTICK_BUTTON_D* = 8 # GLUT game mode sub-API. + # glutGameModeGet. + GLUT_GAME_MODE_ACTIVE* = 0 + GLUT_GAME_MODE_POSSIBLE* = 1 + GLUT_GAME_MODE_WIDTH* = 2 + GLUT_GAME_MODE_HEIGHT* = 3 + GLUT_GAME_MODE_PIXEL_DEPTH* = 4 + GLUT_GAME_MODE_REFRESH_RATE* = 5 + GLUT_GAME_MODE_DISPLAY_CHANGED* = 6 # GLUT initialization sub-API. + +proc glutInit*(argcp: PInteger, argv: PPChar){.dynlib: dllname, importc.} +proc glutInitDisplayMode*(mode: int16){.dynlib: dllname, importc.} +proc glutInitDisplayString*(str: cstring){.dynlib: dllname, importc.} +proc glutInitWindowPosition*(x, y: int){.dynlib: dllname, importc.} +proc glutInitWindowSize*(width, height: int){.dynlib: dllname, importc.} +proc glutMainLoop*(){.dynlib: dllname, importc.} + # GLUT window sub-API. +proc glutCreateWindow*(title: cstring): int{.dynlib: dllname, importc.} +proc glutCreateSubWindow*(win, x, y, width, height: int): int{.dynlib: dllname, + importc.} +proc glutDestroyWindow*(win: int){.dynlib: dllname, importc.} +proc glutPostRedisplay*(){.dynlib: dllname, importc.} +proc glutPostWindowRedisplay*(win: int){.dynlib: dllname, importc.} +proc glutSwapBuffers*(){.dynlib: dllname, importc.} +proc glutGetWindow*(): int{.dynlib: dllname, importc.} +proc glutSetWindow*(win: int){.dynlib: dllname, importc.} +proc glutSetWindowTitle*(title: cstring){.dynlib: dllname, importc.} +proc glutSetIconTitle*(title: cstring){.dynlib: dllname, importc.} +proc glutPositionWindow*(x, y: int){.dynlib: dllname, importc.} +proc glutReshapeWindow*(width, height: int){.dynlib: dllname, importc.} +proc glutPopWindow*(){.dynlib: dllname, importc.} +proc glutPushWindow*(){.dynlib: dllname, importc.} +proc glutIconifyWindow*(){.dynlib: dllname, importc.} +proc glutShowWindow*(){.dynlib: dllname, importc.} +proc glutHideWindow*(){.dynlib: dllname, importc.} +proc glutFullScreen*(){.dynlib: dllname, importc.} +proc glutSetCursor*(cursor: int){.dynlib: dllname, importc.} +proc glutWarpPointer*(x, y: int){.dynlib: dllname, importc.} + # GLUT overlay sub-API. +proc glutEstablishOverlay*(){.dynlib: dllname, importc.} +proc glutRemoveOverlay*(){.dynlib: dllname, importc.} +proc glutUseLayer*(layer: TGLenum){.dynlib: dllname, importc.} +proc glutPostOverlayRedisplay*(){.dynlib: dllname, importc.} +proc glutPostWindowOverlayRedisplay*(win: int){.dynlib: dllname, importc.} +proc glutShowOverlay*(){.dynlib: dllname, importc.} +proc glutHideOverlay*(){.dynlib: dllname, importc.} + # GLUT menu sub-API. +proc glutCreateMenu*(callback: TGlut1IntCallback): int{.dynlib: dllname, importc.} +proc glutDestroyMenu*(menu: int){.dynlib: dllname, importc.} +proc glutGetMenu*(): int{.dynlib: dllname, importc.} +proc glutSetMenu*(menu: int){.dynlib: dllname, importc.} +proc glutAddMenuEntry*(caption: cstring, value: int){.dynlib: dllname, importc.} +proc glutAddSubMenu*(caption: cstring, submenu: int){.dynlib: dllname, importc.} +proc glutChangeToMenuEntry*(item: int, caption: cstring, value: int){. + dynlib: dllname, importc.} +proc glutChangeToSubMenu*(item: int, caption: cstring, submenu: int){. + dynlib: dllname, importc.} +proc glutRemoveMenuItem*(item: int){.dynlib: dllname, importc.} +proc glutAttachMenu*(button: int){.dynlib: dllname, importc.} +proc glutDetachMenu*(button: int){.dynlib: dllname, importc.} + # GLUT window callback sub-API. +proc glutDisplayFunc*(f: TGlutVoidCallback){.dynlib: dllname, importc.} +proc glutReshapeFunc*(f: TGlut2IntCallback){.dynlib: dllname, importc.} +proc glutKeyboardFunc*(f: TGlut1Char2IntCallback){.dynlib: dllname, importc.} +proc glutMouseFunc*(f: TGlut4IntCallback){.dynlib: dllname, importc.} +proc glutMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname, importc.} +proc glutPassiveMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname, importc.} +proc glutEntryFunc*(f: TGlut1IntCallback){.dynlib: dllname, importc.} +proc glutVisibilityFunc*(f: TGlut1IntCallback){.dynlib: dllname, importc.} +proc glutIdleFunc*(f: TGlutVoidCallback){.dynlib: dllname, importc.} +proc glutTimerFunc*(millis: int16, f: TGlut1IntCallback, value: int){. + dynlib: dllname, importc.} +proc glutMenuStateFunc*(f: TGlut1IntCallback){.dynlib: dllname, importc.} +proc glutSpecialFunc*(f: TGlut3IntCallback){.dynlib: dllname, importc.} +proc glutSpaceballMotionFunc*(f: TGlut3IntCallback){.dynlib: dllname, importc.} +proc glutSpaceballRotateFunc*(f: TGlut3IntCallback){.dynlib: dllname, importc.} +proc glutSpaceballButtonFunc*(f: TGlut2IntCallback){.dynlib: dllname, importc.} +proc glutButtonBoxFunc*(f: TGlut2IntCallback){.dynlib: dllname, importc.} +proc glutDialsFunc*(f: TGlut2IntCallback){.dynlib: dllname, importc.} +proc glutTabletMotionFunc*(f: TGlut2IntCallback){.dynlib: dllname, importc.} +proc glutTabletButtonFunc*(f: TGlut4IntCallback){.dynlib: dllname, importc.} +proc glutMenuStatusFunc*(f: TGlut3IntCallback){.dynlib: dllname, importc.} +proc glutOverlayDisplayFunc*(f: TGlutVoidCallback){.dynlib: dllname, importc.} +proc glutWindowStatusFunc*(f: TGlut1IntCallback){.dynlib: dllname, importc.} +proc glutKeyboardUpFunc*(f: TGlut1Char2IntCallback){.dynlib: dllname, importc.} +proc glutSpecialUpFunc*(f: TGlut3IntCallback){.dynlib: dllname, importc.} +proc glutJoystickFunc*(f: TGlut1UInt3IntCallback, pollInterval: int){. + dynlib: dllname, importc.} + # GLUT color index sub-API. +proc glutSetColor*(cell: int, red, green, blue: TGLfloat){.dynlib: dllname, + importc.} +proc glutGetColor*(ndx, component: int): TGLfloat{.dynlib: dllname, importc.} +proc glutCopyColormap*(win: int){.dynlib: dllname, importc.} + # GLUT state retrieval sub-API. +proc glutGet*(t: TGLenum): int{.dynlib: dllname, importc.} +proc glutDeviceGet*(t: TGLenum): int{.dynlib: dllname, importc.} + # GLUT extension support sub-API +proc glutExtensionSupported*(name: cstring): int{.dynlib: dllname, importc.} +proc glutGetModifiers*(): int{.dynlib: dllname, importc.} +proc glutLayerGet*(t: TGLenum): int{.dynlib: dllname, importc.} + # GLUT font sub-API +proc glutBitmapCharacter*(font: pointer, character: int){.dynlib: dllname, + importc.} +proc glutBitmapWidth*(font: pointer, character: int): int{.dynlib: dllname, + importc.} +proc glutStrokeCharacter*(font: pointer, character: int){.dynlib: dllname, + importc.} +proc glutStrokeWidth*(font: pointer, character: int): int{.dynlib: dllname, + importc.} +proc glutBitmapLength*(font: pointer, str: cstring): int{.dynlib: dllname, + importc.} +proc glutStrokeLength*(font: pointer, str: cstring): int{.dynlib: dllname, + importc.} + # GLUT pre-built models sub-API +proc glutWireSphere*(radius: TGLdouble, slices, stacks: TGLint){.dynlib: dllname, + importc.} +proc glutSolidSphere*(radius: TGLdouble, slices, stacks: TGLint){.dynlib: dllname, + importc.} +proc glutWireCone*(base, height: TGLdouble, slices, stacks: TGLint){. + dynlib: dllname, importc.} +proc glutSolidCone*(base, height: TGLdouble, slices, stacks: TGLint){. + dynlib: dllname, importc.} +proc glutWireCube*(size: TGLdouble){.dynlib: dllname, importc.} +proc glutSolidCube*(size: TGLdouble){.dynlib: dllname, importc.} +proc glutWireTorus*(innerRadius, outerRadius: TGLdouble, sides, rings: TGLint){. + dynlib: dllname, importc.} +proc glutSolidTorus*(innerRadius, outerRadius: TGLdouble, sides, rings: TGLint){. + dynlib: dllname, importc.} +proc glutWireDodecahedron*(){.dynlib: dllname, importc.} +proc glutSolidDodecahedron*(){.dynlib: dllname, importc.} +proc glutWireTeapot*(size: TGLdouble){.dynlib: dllname, importc.} +proc glutSolidTeapot*(size: TGLdouble){.dynlib: dllname, importc.} +proc glutWireOctahedron*(){.dynlib: dllname, importc.} +proc glutSolidOctahedron*(){.dynlib: dllname, importc.} +proc glutWireTetrahedron*(){.dynlib: dllname, importc.} +proc glutSolidTetrahedron*(){.dynlib: dllname, importc.} +proc glutWireIcosahedron*(){.dynlib: dllname, importc.} +proc glutSolidIcosahedron*(){.dynlib: dllname, importc.} + # GLUT video resize sub-API. +proc glutVideoResizeGet*(param: TGLenum): int{.dynlib: dllname, importc.} +proc glutSetupVideoResizing*(){.dynlib: dllname, importc.} +proc glutStopVideoResizing*(){.dynlib: dllname, importc.} +proc glutVideoResize*(x, y, width, height: int){.dynlib: dllname, importc.} +proc glutVideoPan*(x, y, width, height: int){.dynlib: dllname, importc.} + # GLUT debugging sub-API. +proc glutReportErrors*(){.dynlib: dllname, importc.} + # GLUT device control sub-API. +proc glutIgnoreKeyRepeat*(ignore: int){.dynlib: dllname, importc.} +proc glutSetKeyRepeat*(repeatMode: int){.dynlib: dllname, importc.} +proc glutForceJoystickFunc*(){.dynlib: dllname, importc.} + # GLUT game mode sub-API. + #example glutGameModeString('1280x1024:32@75'); +proc glutGameModeString*(AString: cstring){.dynlib: dllname, importc.} +proc glutEnterGameMode*(): int{.dynlib: dllname, importc.} +proc glutLeaveGameMode*(){.dynlib: dllname, importc.} +proc glutGameModeGet*(mode: TGLenum): int{.dynlib: dllname, importc.} +# implementation diff --git a/lib/base/opengl/glut.pp b/lib/base/opengl/glut.pp new file mode 100644 index 000000000..3a6e7d9fc --- /dev/null +++ b/lib/base/opengl/glut.pp @@ -0,0 +1,436 @@ +{ + + Adaption of the delphi3d.net OpenGL units to FreePascal + Sebastian Guenther (sg@freepascal.org) in 2002 + These units are free to use +} + +unit Glut; + +// Copyright (c) Mark J. Kilgard, 1994, 1995, 1996. */ + +(* This program is freely distributable without licensing fees and is + provided without guarantee or warrantee expressed or implied. This + program is -not- in the public domain. *) + +{******************************************************************************} +{ Converted to Delphi by Tom Nuydens (tom@delphi3d.net) } +{ Contributions by Igor Karpov (glygrik@hotbox.ru) } +{ For the latest updates, visit Delphi3D: http://www.delphi3d.net } +{******************************************************************************} + +interface + +uses + GL; + +const + dllname = 'glut32.dll'; + dynlibname = '/System/Library/Frameworks/GLUT.framework/GLUT'; + libname = 'libglut.so.3'; + +type + PInteger = ^Integer; + PPChar = ^PChar; + TGlutVoidCallback = procedure; cdecl; + TGlut1IntCallback = procedure(value: Integer); cdecl; + TGlut2IntCallback = procedure(v1, v2: Integer); cdecl; + TGlut3IntCallback = procedure(v1, v2, v3: Integer); cdecl; + TGlut4IntCallback = procedure(v1, v2, v3, v4: Integer); cdecl; + TGlut1Char2IntCallback = procedure(c: Byte; v1, v2: Integer); cdecl; + TGlut1UInt3IntCallback = procedure(u: Cardinal; v1, v2, v3: Integer); cdecl; + +const + GLUT_API_VERSION = 3; + GLUT_XLIB_IMPLEMENTATION = 12; + // Display mode bit masks. + GLUT_RGB = 0; + GLUT_RGBA = GLUT_RGB; + GLUT_INDEX = 1; + GLUT_SINGLE = 0; + GLUT_DOUBLE = 2; + GLUT_ACCUM = 4; + GLUT_ALPHA = 8; + GLUT_DEPTH = 16; + GLUT_STENCIL = 32; + GLUT_MULTISAMPLE = 128; + GLUT_STEREO = 256; + GLUT_LUMINANCE = 512; + + // Mouse buttons. + GLUT_LEFT_BUTTON = 0; + GLUT_MIDDLE_BUTTON = 1; + GLUT_RIGHT_BUTTON = 2; + + // Mouse button state. + GLUT_DOWN = 0; + GLUT_UP = 1; + + // function keys + GLUT_KEY_F1 = 1; + GLUT_KEY_F2 = 2; + GLUT_KEY_F3 = 3; + GLUT_KEY_F4 = 4; + GLUT_KEY_F5 = 5; + GLUT_KEY_F6 = 6; + GLUT_KEY_F7 = 7; + GLUT_KEY_F8 = 8; + GLUT_KEY_F9 = 9; + GLUT_KEY_F10 = 10; + GLUT_KEY_F11 = 11; + GLUT_KEY_F12 = 12; + // directional keys + GLUT_KEY_LEFT = 100; + GLUT_KEY_UP = 101; + GLUT_KEY_RIGHT = 102; + GLUT_KEY_DOWN = 103; + GLUT_KEY_PAGE_UP = 104; + GLUT_KEY_PAGE_DOWN = 105; + GLUT_KEY_HOME = 106; + GLUT_KEY_END = 107; + GLUT_KEY_INSERT = 108; + + // Entry/exit state. + GLUT_LEFT = 0; + GLUT_ENTERED = 1; + + // Menu usage state. + GLUT_MENU_NOT_IN_USE = 0; + GLUT_MENU_IN_USE = 1; + + // Visibility state. + GLUT_NOT_VISIBLE = 0; + GLUT_VISIBLE = 1; + + // Window status state. + GLUT_HIDDEN = 0; + GLUT_FULLY_RETAINED = 1; + GLUT_PARTIALLY_RETAINED = 2; + GLUT_FULLY_COVERED = 3; + + // Color index component selection values. + GLUT_RED = 0; + GLUT_GREEN = 1; + GLUT_BLUE = 2; + + // Layers for use. + GLUT_NORMAL = 0; + GLUT_OVERLAY = 1; + +{$ifdef Windows} +const + // Stroke font constants (use these in GLUT program). + GLUT_STROKE_ROMAN = Pointer(0); + GLUT_STROKE_MONO_ROMAN = Pointer(1); + + // Bitmap font constants (use these in GLUT program). + GLUT_BITMAP_9_BY_15 = Pointer(2); + GLUT_BITMAP_8_BY_13 = Pointer(3); + GLUT_BITMAP_TIMES_ROMAN_10 = Pointer(4); + GLUT_BITMAP_TIMES_ROMAN_24 = Pointer(5); + GLUT_BITMAP_HELVETICA_10 = Pointer(6); + GLUT_BITMAP_HELVETICA_12 = Pointer(7); + GLUT_BITMAP_HELVETICA_18 = Pointer(8); +{$else Windows} +var + // Stroke font constants (use these in GLUT program). + GLUT_STROKE_ROMAN : Pointer; + GLUT_STROKE_MONO_ROMAN : Pointer; + + // Bitmap font constants (use these in GLUT program). + GLUT_BITMAP_9_BY_15 : Pointer; + GLUT_BITMAP_8_BY_13 : Pointer; + GLUT_BITMAP_TIMES_ROMAN_10 : Pointer; + GLUT_BITMAP_TIMES_ROMAN_24 : Pointer; + GLUT_BITMAP_HELVETICA_10 : Pointer; + GLUT_BITMAP_HELVETICA_12 : Pointer; + GLUT_BITMAP_HELVETICA_18 : Pointer; +{$endif Windows} +const + // glutGet parameters. + GLUT_WINDOW_X = 100; + GLUT_WINDOW_Y = 101; + GLUT_WINDOW_WIDTH = 102; + GLUT_WINDOW_HEIGHT = 103; + GLUT_WINDOW_BUFFER_SIZE = 104; + GLUT_WINDOW_STENCIL_SIZE = 105; + GLUT_WINDOW_DEPTH_SIZE = 106; + GLUT_WINDOW_RED_SIZE = 107; + GLUT_WINDOW_GREEN_SIZE = 108; + GLUT_WINDOW_BLUE_SIZE = 109; + GLUT_WINDOW_ALPHA_SIZE = 110; + GLUT_WINDOW_ACCUM_RED_SIZE = 111; + GLUT_WINDOW_ACCUM_GREEN_SIZE = 112; + GLUT_WINDOW_ACCUM_BLUE_SIZE = 113; + GLUT_WINDOW_ACCUM_ALPHA_SIZE = 114; + GLUT_WINDOW_DOUBLEBUFFER = 115; + GLUT_WINDOW_RGBA = 116; + GLUT_WINDOW_PARENT = 117; + GLUT_WINDOW_NUM_CHILDREN = 118; + GLUT_WINDOW_COLORMAP_SIZE = 119; + GLUT_WINDOW_NUM_SAMPLES = 120; + GLUT_WINDOW_STEREO = 121; + GLUT_WINDOW_CURSOR = 122; + GLUT_SCREEN_WIDTH = 200; + GLUT_SCREEN_HEIGHT = 201; + GLUT_SCREEN_WIDTH_MM = 202; + GLUT_SCREEN_HEIGHT_MM = 203; + GLUT_MENU_NUM_ITEMS = 300; + GLUT_DISPLAY_MODE_POSSIBLE = 400; + GLUT_INIT_WINDOW_X = 500; + GLUT_INIT_WINDOW_Y = 501; + GLUT_INIT_WINDOW_WIDTH = 502; + GLUT_INIT_WINDOW_HEIGHT = 503; + GLUT_INIT_DISPLAY_MODE = 504; + GLUT_ELAPSED_TIME = 700; + GLUT_WINDOW_FORMAT_ID = 123; + + // glutDeviceGet parameters. + GLUT_HAS_KEYBOARD = 600; + GLUT_HAS_MOUSE = 601; + GLUT_HAS_SPACEBALL = 602; + GLUT_HAS_DIAL_AND_BUTTON_BOX = 603; + GLUT_HAS_TABLET = 604; + GLUT_NUM_MOUSE_BUTTONS = 605; + GLUT_NUM_SPACEBALL_BUTTONS = 606; + GLUT_NUM_BUTTON_BOX_BUTTONS = 607; + GLUT_NUM_DIALS = 608; + GLUT_NUM_TABLET_BUTTONS = 609; + GLUT_DEVICE_IGNORE_KEY_REPEAT = 610; + GLUT_DEVICE_KEY_REPEAT = 611; + GLUT_HAS_JOYSTICK = 612; + GLUT_OWNS_JOYSTICK = 613; + GLUT_JOYSTICK_BUTTONS = 614; + GLUT_JOYSTICK_AXES = 615; + GLUT_JOYSTICK_POLL_RATE = 616; + + + // glutLayerGet parameters. + GLUT_OVERLAY_POSSIBLE = 800; + GLUT_LAYER_IN_USE = 801; + GLUT_HAS_OVERLAY = 802; + GLUT_TRANSPARENT_INDEX = 803; + GLUT_NORMAL_DAMAGED = 804; + GLUT_OVERLAY_DAMAGED = 805; + + // glutVideoResizeGet parameters. + GLUT_VIDEO_RESIZE_POSSIBLE = 900; + GLUT_VIDEO_RESIZE_IN_USE = 901; + GLUT_VIDEO_RESIZE_X_DELTA = 902; + GLUT_VIDEO_RESIZE_Y_DELTA = 903; + GLUT_VIDEO_RESIZE_WIDTH_DELTA = 904; + GLUT_VIDEO_RESIZE_HEIGHT_DELTA = 905; + GLUT_VIDEO_RESIZE_X = 906; + GLUT_VIDEO_RESIZE_Y = 907; + GLUT_VIDEO_RESIZE_WIDTH = 908; + GLUT_VIDEO_RESIZE_HEIGHT = 909; + + // glutGetModifiers return mask. + GLUT_ACTIVE_SHIFT = 1; + GLUT_ACTIVE_CTRL = 2; + GLUT_ACTIVE_ALT = 4; + + // glutSetCursor parameters. + // Basic arrows. + GLUT_CURSOR_RIGHT_ARROW = 0; + GLUT_CURSOR_LEFT_ARROW = 1; + // Symbolic cursor shapes. + GLUT_CURSOR_INFO = 2; + GLUT_CURSOR_DESTROY = 3; + GLUT_CURSOR_HELP = 4; + GLUT_CURSOR_CYCLE = 5; + GLUT_CURSOR_SPRAY = 6; + GLUT_CURSOR_WAIT = 7; + GLUT_CURSOR_TEXT = 8; + GLUT_CURSOR_CROSSHAIR = 9; + // Directional cursors. + GLUT_CURSOR_UP_DOWN = 10; + GLUT_CURSOR_LEFT_RIGHT = 11; + // Sizing cursors. + GLUT_CURSOR_TOP_SIDE = 12; + GLUT_CURSOR_BOTTOM_SIDE = 13; + GLUT_CURSOR_LEFT_SIDE = 14; + GLUT_CURSOR_RIGHT_SIDE = 15; + GLUT_CURSOR_TOP_LEFT_CORNER = 16; + GLUT_CURSOR_TOP_RIGHT_CORNER = 17; + GLUT_CURSOR_BOTTOM_RIGHT_CORNER = 18; + GLUT_CURSOR_BOTTOM_LEFT_CORNER = 19; + // Inherit from parent window. + GLUT_CURSOR_INHERIT = 100; + // Blank cursor. + GLUT_CURSOR_NONE = 101; + // Fullscreen crosshair (if available). + GLUT_CURSOR_FULL_CROSSHAIR = 102; + + // GLUT device control sub-API. + // glutSetKeyRepeat modes. + GLUT_KEY_REPEAT_OFF = 0; + GLUT_KEY_REPEAT_ON = 1; + GLUT_KEY_REPEAT_DEFAULT = 2; + +// Joystick button masks. + GLUT_JOYSTICK_BUTTON_A = 1; + GLUT_JOYSTICK_BUTTON_B = 2; + GLUT_JOYSTICK_BUTTON_C = 4; + GLUT_JOYSTICK_BUTTON_D = 8; + + // GLUT game mode sub-API. + // glutGameModeGet. + GLUT_GAME_MODE_ACTIVE = 0; + GLUT_GAME_MODE_POSSIBLE = 1; + GLUT_GAME_MODE_WIDTH = 2; + GLUT_GAME_MODE_HEIGHT = 3; + GLUT_GAME_MODE_PIXEL_DEPTH = 4; + GLUT_GAME_MODE_REFRESH_RATE = 5; + GLUT_GAME_MODE_DISPLAY_CHANGED = 6; + + +// GLUT initialization sub-API. + procedure glutInit(argcp: PInteger; argv: PPChar); external dllname; + procedure glutInitDisplayMode(mode: Word); external dllname; + procedure glutInitDisplayString(const str: PChar); external dllname; + procedure glutInitWindowPosition(x, y: Integer); external dllname; + procedure glutInitWindowSize(width, height: Integer); external dllname; + procedure glutMainLoop; external dllname; + +// GLUT window sub-API. + function glutCreateWindow(const title: PChar): Integer; external dllname; + function glutCreateSubWindow(win, x, y, width, height: Integer): Integer; external dllname; + procedure glutDestroyWindow(win: Integer); external dllname; + procedure glutPostRedisplay; external dllname; + procedure glutPostWindowRedisplay(win: Integer); external dllname; + procedure glutSwapBuffers; external dllname; + function glutGetWindow: Integer; external dllname; + procedure glutSetWindow(win: Integer); external dllname; + procedure glutSetWindowTitle(const title: PChar); external dllname; + procedure glutSetIconTitle(const title: PChar); external dllname; + procedure glutPositionWindow(x, y: Integer); external dllname; + procedure glutReshapeWindow(width, height: Integer); external dllname; + procedure glutPopWindow; external dllname; + procedure glutPushWindow; external dllname; + procedure glutIconifyWindow; external dllname; + procedure glutShowWindow; external dllname; + procedure glutHideWindow; external dllname; + procedure glutFullScreen; external dllname; + procedure glutSetCursor(cursor: Integer); external dllname; + procedure glutWarpPointer(x, y: Integer); external dllname; + +// GLUT overlay sub-API. + procedure glutEstablishOverlay; external dllname; + procedure glutRemoveOverlay; external dllname; + procedure glutUseLayer(layer: GLenum); external dllname; + procedure glutPostOverlayRedisplay; external dllname; + procedure glutPostWindowOverlayRedisplay(win: Integer); external dllname; + procedure glutShowOverlay; external dllname; + procedure glutHideOverlay; external dllname; + +// GLUT menu sub-API. + function glutCreateMenu(callback: TGlut1IntCallback): Integer; external dllname; + procedure glutDestroyMenu(menu: Integer); external dllname; + function glutGetMenu: Integer; external dllname; + procedure glutSetMenu(menu: Integer); external dllname; + procedure glutAddMenuEntry(const caption: PChar; value: Integer); external dllname; + procedure glutAddSubMenu(const caption: PChar; submenu: Integer); external dllname; + procedure glutChangeToMenuEntry(item: Integer; const caption: PChar; value: Integer); external dllname; + procedure glutChangeToSubMenu(item: Integer; const caption: PChar; submenu: Integer); external dllname; + procedure glutRemoveMenuItem(item: Integer); external dllname; + procedure glutAttachMenu(button: Integer); external dllname; + procedure glutDetachMenu(button: Integer); external dllname; + +// GLUT window callback sub-API. + procedure glutDisplayFunc(f: TGlutVoidCallback); external dllname; + procedure glutReshapeFunc(f: TGlut2IntCallback); external dllname; + procedure glutKeyboardFunc(f: TGlut1Char2IntCallback); external dllname; + procedure glutMouseFunc(f: TGlut4IntCallback); external dllname; + procedure glutMotionFunc(f: TGlut2IntCallback); external dllname; + procedure glutPassiveMotionFunc(f: TGlut2IntCallback); external dllname; + procedure glutEntryFunc(f: TGlut1IntCallback); external dllname; + procedure glutVisibilityFunc(f: TGlut1IntCallback); external dllname; + procedure glutIdleFunc(f: TGlutVoidCallback); external dllname; + procedure glutTimerFunc(millis: Word; f: TGlut1IntCallback; value: Integer); external dllname; + procedure glutMenuStateFunc(f: TGlut1IntCallback); external dllname; + procedure glutSpecialFunc(f: TGlut3IntCallback); external dllname; + procedure glutSpaceballMotionFunc(f: TGlut3IntCallback); external dllname; + procedure glutSpaceballRotateFunc(f: TGlut3IntCallback); external dllname; + procedure glutSpaceballButtonFunc(f: TGlut2IntCallback); external dllname; + procedure glutButtonBoxFunc(f: TGlut2IntCallback); external dllname; + procedure glutDialsFunc(f: TGlut2IntCallback); external dllname; + procedure glutTabletMotionFunc(f: TGlut2IntCallback); external dllname; + procedure glutTabletButtonFunc(f: TGlut4IntCallback); external dllname; + procedure glutMenuStatusFunc(f: TGlut3IntCallback); external dllname; + procedure glutOverlayDisplayFunc(f:TGlutVoidCallback); external dllname; + procedure glutWindowStatusFunc(f: TGlut1IntCallback); external dllname; + procedure glutKeyboardUpFunc(f: TGlut1Char2IntCallback); external dllname; + procedure glutSpecialUpFunc(f: TGlut3IntCallback); external dllname; + procedure glutJoystickFunc(f: TGlut1UInt3IntCallback; pollInterval: Integer); external dllname; + +// GLUT color index sub-API. + procedure glutSetColor(cell: Integer; red, green, blue: GLfloat); external dllname; + function glutGetColor(ndx, component: Integer): GLfloat; external dllname; + procedure glutCopyColormap(win: Integer); external dllname; + +// GLUT state retrieval sub-API. + function glutGet(t: GLenum): Integer; external dllname; + function glutDeviceGet(t: GLenum): Integer; external dllname; + +// GLUT extension support sub-API + function glutExtensionSupported(const name: PChar): Integer; external dllname; + function glutGetModifiers: Integer; external dllname; + function glutLayerGet(t: GLenum): Integer; external dllname; + +// GLUT font sub-API + procedure glutBitmapCharacter(font : pointer; character: Integer); external dllname; + function glutBitmapWidth(font : pointer; character: Integer): Integer; external dllname; + procedure glutStrokeCharacter(font : pointer; character: Integer); external dllname; + function glutStrokeWidth(font : pointer; character: Integer): Integer; external dllname; + function glutBitmapLength(font: pointer; const str: PChar): Integer; external dllname; + function glutStrokeLength(font: pointer; const str: PChar): Integer; external dllname; + +// GLUT pre-built models sub-API + procedure glutWireSphere(radius: GLdouble; slices, stacks: GLint); external dllname; + procedure glutSolidSphere(radius: GLdouble; slices, stacks: GLint); external dllname; + procedure glutWireCone(base, height: GLdouble; slices, stacks: GLint); external dllname; + procedure glutSolidCone(base, height: GLdouble; slices, stacks: GLint); external dllname; + procedure glutWireCube(size: GLdouble); external dllname; + procedure glutSolidCube(size: GLdouble); external dllname; + procedure glutWireTorus(innerRadius, outerRadius: GLdouble; sides, rings: GLint); external dllname; + procedure glutSolidTorus(innerRadius, outerRadius: GLdouble; sides, rings: GLint); external dllname; + procedure glutWireDodecahedron; external dllname; + procedure glutSolidDodecahedron; external dllname; + procedure glutWireTeapot(size: GLdouble); external dllname; + procedure glutSolidTeapot(size: GLdouble); external dllname; + procedure glutWireOctahedron; external dllname; + procedure glutSolidOctahedron; external dllname; + procedure glutWireTetrahedron; external dllname; + procedure glutSolidTetrahedron; external dllname; + procedure glutWireIcosahedron; external dllname; + procedure glutSolidIcosahedron; external dllname; + +// GLUT video resize sub-API. + function glutVideoResizeGet(param: GLenum): Integer; external dllname; + procedure glutSetupVideoResizing; external dllname; + procedure glutStopVideoResizing; external dllname; + procedure glutVideoResize(x, y, width, height: Integer); external dllname; + procedure glutVideoPan(x, y, width, height: Integer); external dllname; + +// GLUT debugging sub-API. + procedure glutReportErrors; external dllname; + +// GLUT device control sub-API. + + procedure glutIgnoreKeyRepeat(ignore: Integer); external dllname; + procedure glutSetKeyRepeat(repeatMode: Integer); external dllname; + procedure glutForceJoystickFunc; external dllname; + +// GLUT game mode sub-API. + + //example glutGameModeString('1280x1024:32@75'); + procedure glutGameModeString (const AString : PChar); external dllname; + function glutEnterGameMode : integer; external dllname; + procedure glutLeaveGameMode; external dllname; + function glutGameModeGet (mode : GLenum) : integer; external dllname; + + +implementation + +end. diff --git a/lib/base/opengl/glx.nim b/lib/base/opengl/glx.nim new file mode 100644 index 000000000..a967acfc6 --- /dev/null +++ b/lib/base/opengl/glx.nim @@ -0,0 +1,148 @@ +# +# +# Translation of the Mesa GLX headers for FreePascal +# Copyright (C) 1999 Sebastian Guenther +# +# +# Mesa 3-D graphics library +# Version: 3.0 +# Copyright (C) 1995-1998 Brian Paul +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public +# License along with this library; if not, write to the Free +# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# + +import + X, XLib, XUtil, gl + +when defined(windows): + const dllname = "GL.dll" +elif defined(macosx): + const dllname = "/usr/X11R6/lib/libGL.dylib" +else: + const dllname = "libGL.so" + +const + GLX_USE_GL* = 1 + GLX_BUFFER_SIZE* = 2 + GLX_LEVEL* = 3 + GLX_RGBA* = 4 + GLX_DOUBLEBUFFER* = 5 + GLX_STEREO* = 6 + GLX_AUX_BUFFERS* = 7 + GLX_RED_SIZE* = 8 + GLX_GREEN_SIZE* = 9 + GLX_BLUE_SIZE* = 10 + GLX_ALPHA_SIZE* = 11 + GLX_DEPTH_SIZE* = 12 + GLX_STENCIL_SIZE* = 13 + GLX_ACCUM_RED_SIZE* = 14 + GLX_ACCUM_GREEN_SIZE* = 15 + GLX_ACCUM_BLUE_SIZE* = 16 + GLX_ACCUM_ALPHA_SIZE* = 17 # GLX_EXT_visual_info extension + GLX_X_VISUAL_TYPE_EXT* = 0x00000022 + GLX_TRANSPARENT_TYPE_EXT* = 0x00000023 + GLX_TRANSPARENT_INDEX_VALUE_EXT* = 0x00000024 + GLX_TRANSPARENT_RED_VALUE_EXT* = 0x00000025 + GLX_TRANSPARENT_GREEN_VALUE_EXT* = 0x00000026 + GLX_TRANSPARENT_BLUE_VALUE_EXT* = 0x00000027 + GLX_TRANSPARENT_ALPHA_VALUE_EXT* = 0x00000028 # Error codes returned by glXGetConfig: + GLX_BAD_SCREEN* = 1 + GLX_BAD_ATTRIBUTE* = 2 + GLX_NO_EXTENSION* = 3 + GLX_BAD_VISUAL* = 4 + GLX_BAD_CONTEXT* = 5 + GLX_BAD_VALUE* = 6 + GLX_BAD_ENUM* = 7 # GLX 1.1 and later: + GLX_VENDOR* = 1 + GLX_VERSION* = 2 + GLX_EXTENSIONS* = 3 # GLX_visual_info extension + GLX_TRUE_COLOR_EXT* = 0x00008002 + GLX_DIRECT_COLOR_EXT* = 0x00008003 + GLX_PSEUDO_COLOR_EXT* = 0x00008004 + GLX_STATIC_COLOR_EXT* = 0x00008005 + GLX_GRAY_SCALE_EXT* = 0x00008006 + GLX_STATIC_GRAY_EXT* = 0x00008007 + GLX_NONE_EXT* = 0x00008000 + GLX_TRANSPARENT_RGB_EXT* = 0x00008008 + GLX_TRANSPARENT_INDEX_EXT* = 0x00008009 + +type # From XLib: + XPixmap* = TXID + XFont* = TXID + XColormap* = TXID + GLXContext* = Pointer + GLXPixmap* = TXID + GLXDrawable* = TXID + GLXContextID* = TXID + TXPixmap* = XPixmap + TXFont* = XFont + TXColormap* = XColormap + TGLXContext* = GLXContext + TGLXPixmap* = GLXPixmap + TGLXDrawable* = GLXDrawable + TGLXContextID* = GLXContextID + +proc glXChooseVisual*(dpy: PDisplay, screen: int, attribList: ptr int32): PXVisualInfo{. + cdecl, dynlib: dllname, importc.} +proc glXCreateContext*(dpy: PDisplay, vis: PXVisualInfo, shareList: GLXContext, + direct: bool): GLXContext{.cdecl, dynlib: dllname, + importc.} +proc glXDestroyContext*(dpy: PDisplay, ctx: GLXContext){.cdecl, dynlib: dllname, + importc.} +proc glXMakeCurrent*(dpy: PDisplay, drawable: GLXDrawable, ctx: GLXContext): bool{. + cdecl, dynlib: dllname, importc.} +proc glXCopyContext*(dpy: PDisplay, src, dst: GLXContext, mask: int32){.cdecl, + dynlib: dllname, importc.} +proc glXSwapBuffers*(dpy: PDisplay, drawable: GLXDrawable){.cdecl, + dynlib: dllname, importc.} +proc glXCreateGLXPixmap*(dpy: PDisplay, visual: PXVisualInfo, pixmap: XPixmap): GLXPixmap{. + cdecl, dynlib: dllname, importc.} +proc glXDestroyGLXPixmap*(dpy: PDisplay, pixmap: GLXPixmap){.cdecl, + dynlib: dllname, importc.} +proc glXQueryExtension*(dpy: PDisplay, errorb, event: var int): bool{.cdecl, + dynlib: dllname, importc.} +proc glXQueryVersion*(dpy: PDisplay, maj, min: var int): bool{.cdecl, + dynlib: dllname, importc.} +proc glXIsDirect*(dpy: PDisplay, ctx: GLXContext): bool{.cdecl, dynlib: dllname, + importc.} +proc glXGetConfig*(dpy: PDisplay, visual: PXVisualInfo, attrib: int, + value: var int): int{.cdecl, dynlib: dllname, importc.} +proc glXGetCurrentContext*(): GLXContext{.cdecl, dynlib: dllname, importc.} +proc glXGetCurrentDrawable*(): GLXDrawable{.cdecl, dynlib: dllname, importc.} +proc glXWaitGL*(){.cdecl, dynlib: dllname, importc.} +proc glXWaitX*(){.cdecl, dynlib: dllname, importc.} +proc glXUseXFont*(font: XFont, first, count, list: int){.cdecl, dynlib: dllname, + importc.} + # GLX 1.1 and later +proc glXQueryExtensionsString*(dpy: PDisplay, screen: int): cstring{.cdecl, + dynlib: dllname, importc.} +proc glXQueryServerString*(dpy: PDisplay, screen, name: int): cstring{.cdecl, + dynlib: dllname, importc.} +proc glXGetClientString*(dpy: PDisplay, name: int): cstring{.cdecl, + dynlib: dllname, importc.} + # Mesa GLX Extensions +proc glXCreateGLXPixmapMESA*(dpy: PDisplay, visual: PXVisualInfo, + pixmap: XPixmap, cmap: XColormap): GLXPixmap{. + cdecl, dynlib: dllname, importc.} +proc glXReleaseBufferMESA*(dpy: PDisplay, d: GLXDrawable): bool{.cdecl, + dynlib: dllname, importc.} +proc glXCopySubBufferMESA*(dpy: PDisplay, drawbale: GLXDrawable, + x, y, width, height: int){.cdecl, dynlib: dllname, + importc.} +proc glXGetVideoSyncSGI*(counter: var int32): int{.cdecl, dynlib: dllname, + importc.} +proc glXWaitVideoSyncSGI*(divisor, remainder: int, count: var int32): int{. + cdecl, dynlib: dllname, importc.} +# implementation diff --git a/lib/base/opengl/glx.pp b/lib/base/opengl/glx.pp new file mode 100644 index 000000000..2b8c1eed7 --- /dev/null +++ b/lib/base/opengl/glx.pp @@ -0,0 +1,156 @@ +{ + + Translation of the Mesa GLX headers for FreePascal + Copyright (C) 1999 Sebastian Guenther + + + Mesa 3-D graphics library + Version: 3.0 + Copyright (C) 1995-1998 Brian Paul + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +} + +unit GLX; + +interface + +{$IFDEF Unix} + uses + X, XLib, XUtil, gl; + {$DEFINE HasGLX} // Activate GLX stuff +{$ELSE} + {$MESSAGE Unsupported platform.} +{$ENDIF} + +{$IFNDEF HasGLX} + {$MESSAGE GLX not present on this platform.} +{$ENDIF} + +const + dylibname = '/usr/X11R6/lib/libGL.dylib'; + +// ======================================================= +// GLX consts, types and functions +// ======================================================= + +// Tokens for glXChooseVisual and glXGetConfig: +const + GLX_USE_GL = 1; + GLX_BUFFER_SIZE = 2; + GLX_LEVEL = 3; + GLX_RGBA = 4; + GLX_DOUBLEBUFFER = 5; + GLX_STEREO = 6; + GLX_AUX_BUFFERS = 7; + GLX_RED_SIZE = 8; + GLX_GREEN_SIZE = 9; + GLX_BLUE_SIZE = 10; + GLX_ALPHA_SIZE = 11; + GLX_DEPTH_SIZE = 12; + GLX_STENCIL_SIZE = 13; + GLX_ACCUM_RED_SIZE = 14; + GLX_ACCUM_GREEN_SIZE = 15; + GLX_ACCUM_BLUE_SIZE = 16; + GLX_ACCUM_ALPHA_SIZE = 17; + + // GLX_EXT_visual_info extension + GLX_X_VISUAL_TYPE_EXT = $22; + GLX_TRANSPARENT_TYPE_EXT = $23; + GLX_TRANSPARENT_INDEX_VALUE_EXT = $24; + GLX_TRANSPARENT_RED_VALUE_EXT = $25; + GLX_TRANSPARENT_GREEN_VALUE_EXT = $26; + GLX_TRANSPARENT_BLUE_VALUE_EXT = $27; + GLX_TRANSPARENT_ALPHA_VALUE_EXT = $28; + + + // Error codes returned by glXGetConfig: + GLX_BAD_SCREEN = 1; + GLX_BAD_ATTRIBUTE = 2; + GLX_NO_EXTENSION = 3; + GLX_BAD_VISUAL = 4; + GLX_BAD_CONTEXT = 5; + GLX_BAD_VALUE = 6; + GLX_BAD_ENUM = 7; + + // GLX 1.1 and later: + GLX_VENDOR = 1; + GLX_VERSION = 2; + GLX_EXTENSIONS = 3; + + // GLX_visual_info extension + GLX_TRUE_COLOR_EXT = $8002; + GLX_DIRECT_COLOR_EXT = $8003; + GLX_PSEUDO_COLOR_EXT = $8004; + GLX_STATIC_COLOR_EXT = $8005; + GLX_GRAY_SCALE_EXT = $8006; + GLX_STATIC_GRAY_EXT = $8007; + GLX_NONE_EXT = $8000; + GLX_TRANSPARENT_RGB_EXT = $8008; + GLX_TRANSPARENT_INDEX_EXT = $8009; + +type + // From XLib: + XPixmap = TXID; + XFont = TXID; + XColormap = TXID; + + GLXContext = Pointer; + GLXPixmap = TXID; + GLXDrawable = TXID; + GLXContextID = TXID; + + TXPixmap = XPixmap; + TXFont = XFont; + TXColormap = XColormap; + + TGLXContext = GLXContext; + TGLXPixmap = GLXPixmap; + TGLXDrawable = GLXDrawable; + TGLXContextID = GLXContextID; + +function glXChooseVisual(dpy: PDisplay; screen: Integer; attribList: PInteger): PXVisualInfo; cdecl; external dllname; +function glXCreateContext(dpy: PDisplay; vis: PXVisualInfo; shareList: GLXContext; direct: Boolean): GLXContext; cdecl; external dllname; +procedure glXDestroyContext(dpy: PDisplay; ctx: GLXContext); cdecl; external dllname; +function glXMakeCurrent(dpy: PDisplay; drawable: GLXDrawable; ctx: GLXContext): Boolean; cdecl; external dllname; +procedure glXCopyContext(dpy: PDisplay; src, dst: GLXContext; mask: LongWord); cdecl; external dllname; +procedure glXSwapBuffers(dpy: PDisplay; drawable: GLXDrawable); cdecl; external dllname; +function glXCreateGLXPixmap(dpy: PDisplay; visual: PXVisualInfo; pixmap: XPixmap): GLXPixmap; cdecl; external dllname; +procedure glXDestroyGLXPixmap(dpy: PDisplay; pixmap: GLXPixmap); cdecl; external dllname; +function glXQueryExtension(dpy: PDisplay; var errorb, event: Integer): Boolean; cdecl; external dllname; +function glXQueryVersion(dpy: PDisplay; var maj, min: Integer): Boolean; cdecl; external dllname; +function glXIsDirect(dpy: PDisplay; ctx: GLXContext): Boolean; cdecl; external dllname; +function glXGetConfig(dpy: PDisplay; visual: PXVisualInfo; attrib: Integer; var value: Integer): Integer; cdecl; external dllname; +function glXGetCurrentContext: GLXContext; cdecl; external dllname; +function glXGetCurrentDrawable: GLXDrawable; cdecl; external dllname; +procedure glXWaitGL; cdecl; external dllname; +procedure glXWaitX; cdecl; external dllname; +procedure glXUseXFont(font: XFont; first, count, list: Integer); cdecl; external dllname; + +// GLX 1.1 and later +function glXQueryExtensionsString(dpy: PDisplay; screen: Integer): PChar; cdecl; external dllname; +function glXQueryServerString(dpy: PDisplay; screen, name: Integer): PChar; cdecl; external dllname; +function glXGetClientString(dpy: PDisplay; name: Integer): PChar; cdecl; external dllname; + +// Mesa GLX Extensions +function glXCreateGLXPixmapMESA(dpy: PDisplay; visual: PXVisualInfo; pixmap: XPixmap; cmap: XColormap): GLXPixmap; cdecl; external dllname; +function glXReleaseBufferMESA(dpy: PDisplay; d: GLXDrawable): Boolean; cdecl; external dllname; +procedure glXCopySubBufferMESA(dpy: PDisplay; drawbale: GLXDrawable; x, y, width, height: Integer); cdecl; external dllname; +function glXGetVideoSyncSGI(var counter: LongWord): Integer; cdecl; external dllname; +function glXWaitVideoSyncSGI(divisor, remainder: Integer; var count: LongWord): Integer; cdecl; external dllname; + +implementation + +end. diff --git a/lib/base/opengl/wingl.nim b/lib/base/opengl/wingl.nim new file mode 100644 index 000000000..2cebf8622 --- /dev/null +++ b/lib/base/opengl/wingl.nim @@ -0,0 +1,348 @@ + +import + gl, windows + +proc wglGetExtensionsStringARB*(hdc: HDC): cstring{.dynlib: dllname, importc.} + +const + WGL_FRONT_COLOR_BUFFER_BIT_ARB* = 0x00000001 + WGL_BACK_COLOR_BUFFER_BIT_ARB* = 0x00000002 + WGL_DEPTH_BUFFER_BIT_ARB* = 0x00000004 + WGL_STENCIL_BUFFER_BIT_ARB* = 0x00000008 + +proc WinChoosePixelFormat*(DC: HDC, p2: PPixelFormatDescriptor): int{. + dynlib: "gdi32", importc: "ChoosePixelFormat".} +proc wglCreateBufferRegionARB*(hDC: HDC, iLayerPlane: TGLint, uType: TGLuint): THandle{. + dynlib: dllname, importc.} +proc wglDeleteBufferRegionARB*(hRegion: THandle){.dynlib: dllname, importc.} +proc wglSaveBufferRegionARB*(hRegion: THandle, x: TGLint, y: TGLint, + width: TGLint, height: TGLint): BOOL{. + dynlib: dllname, importc.} +proc wglRestoreBufferRegionARB*(hRegion: THandle, x: TGLint, y: TGLint, + width: TGLint, height: TGLint, xSrc: TGLint, + ySrc: TGLint): BOOL{.dynlib: dllname, importc.} +proc wglAllocateMemoryNV*(size: TGLsizei, readFrequency: TGLfloat, + writeFrequency: TGLfloat, priority: TGLfloat): PGLvoid{. + dynlib: dllname, importc.} +proc wglFreeMemoryNV*(pointer: PGLvoid){.dynlib: dllname, importc.} +const + WGL_IMAGE_BUFFER_MIN_ACCESS_I3D* = 0x00000001 + WGL_IMAGE_BUFFER_LOCK_I3D* = 0x00000002 + +proc wglCreateImageBufferI3D*(hDC: HDC, dwSize: DWORD, uFlags: UINT): PGLvoid{. + dynlib: dllname, importc.} +proc wglDestroyImageBufferI3D*(hDC: HDC, pAddress: PGLvoid): BOOL{. + dynlib: dllname, importc.} +proc wglAssociateImageBufferEventsI3D*(hdc: HDC, pEvent: PHandle, + pAddress: PGLvoid, pSize: PDWORD, + count: UINT): BOOL{.dynlib: dllname, + importc.} +proc wglReleaseImageBufferEventsI3D*(hdc: HDC, pAddress: PGLvoid, count: UINT): BOOL{. + dynlib: dllname, importc.} +proc wglEnableFrameLockI3D*(): BOOL{.dynlib: dllname, importc.} +proc wglDisableFrameLockI3D*(): BOOL{.dynlib: dllname, importc.} +proc wglIsEnabledFrameLockI3D*(pFlag: PBOOL): BOOL{.dynlib: dllname, importc.} +proc wglQueryFrameLockMasterI3D*(pFlag: PBOOL): BOOL{.dynlib: dllname, importc.} +proc wglGetFrameUsageI3D*(pUsage: PGLfloat): BOOL{.dynlib: dllname, importc.} +proc wglBeginFrameTrackingI3D*(): BOOL{.dynlib: dllname, importc.} +proc wglEndFrameTrackingI3D*(): BOOL{.dynlib: dllname, importc.} +proc wglQueryFrameTrackingI3D*(pFrameCount: PDWORD, pMissedFrames: PDWORD, + pLastMissedUsage: PGLfloat): BOOL{. + dynlib: dllname, importc.} +const + WGL_NUMBER_PIXEL_FORMATS_ARB* = 0x00002000 + WGL_DRAW_TO_WINDOW_ARB* = 0x00002001 + WGL_DRAW_TO_BITMAP_ARB* = 0x00002002 + WGL_ACCELERATION_ARB* = 0x00002003 + WGL_NEED_PALETTE_ARB* = 0x00002004 + WGL_NEED_SYSTEM_PALETTE_ARB* = 0x00002005 + WGL_SWAP_LAYER_BUFFERS_ARB* = 0x00002006 + WGL_SWAP_METHOD_ARB* = 0x00002007 + WGL_NUMBER_OVERLAYS_ARB* = 0x00002008 + WGL_NUMBER_UNDERLAYS_ARB* = 0x00002009 + WGL_TRANSPARENT_ARB* = 0x0000200A + WGL_TRANSPARENT_RED_VALUE_ARB* = 0x00002037 + WGL_TRANSPARENT_GREEN_VALUE_ARB* = 0x00002038 + WGL_TRANSPARENT_BLUE_VALUE_ARB* = 0x00002039 + WGL_TRANSPARENT_ALPHA_VALUE_ARB* = 0x0000203A + WGL_TRANSPARENT_INDEX_VALUE_ARB* = 0x0000203B + WGL_SHARE_DEPTH_ARB* = 0x0000200C + WGL_SHARE_STENCIL_ARB* = 0x0000200D + WGL_SHARE_ACCUM_ARB* = 0x0000200E + WGL_SUPPORT_GDI_ARB* = 0x0000200F + WGL_SUPPORT_OPENGL_ARB* = 0x00002010 + WGL_DOUBLE_BUFFER_ARB* = 0x00002011 + WGL_STEREO_ARB* = 0x00002012 + WGL_PIXEL_TYPE_ARB* = 0x00002013 + WGL_COLOR_BITS_ARB* = 0x00002014 + WGL_RED_BITS_ARB* = 0x00002015 + WGL_RED_SHIFT_ARB* = 0x00002016 + WGL_GREEN_BITS_ARB* = 0x00002017 + WGL_GREEN_SHIFT_ARB* = 0x00002018 + WGL_BLUE_BITS_ARB* = 0x00002019 + WGL_BLUE_SHIFT_ARB* = 0x0000201A + WGL_ALPHA_BITS_ARB* = 0x0000201B + WGL_ALPHA_SHIFT_ARB* = 0x0000201C + WGL_ACCUM_BITS_ARB* = 0x0000201D + WGL_ACCUM_RED_BITS_ARB* = 0x0000201E + WGL_ACCUM_GREEN_BITS_ARB* = 0x0000201F + WGL_ACCUM_BLUE_BITS_ARB* = 0x00002020 + WGL_ACCUM_ALPHA_BITS_ARB* = 0x00002021 + WGL_DEPTH_BITS_ARB* = 0x00002022 + WGL_STENCIL_BITS_ARB* = 0x00002023 + WGL_AUX_BUFFERS_ARB* = 0x00002024 + WGL_NO_ACCELERATION_ARB* = 0x00002025 + WGL_GENERIC_ACCELERATION_ARB* = 0x00002026 + WGL_FULL_ACCELERATION_ARB* = 0x00002027 + WGL_SWAP_EXCHANGE_ARB* = 0x00002028 + WGL_SWAP_COPY_ARB* = 0x00002029 + WGL_SWAP_UNDEFINED_ARB* = 0x0000202A + WGL_TYPE_RGBA_ARB* = 0x0000202B + WGL_TYPE_COLORINDEX_ARB* = 0x0000202C + +proc wglGetPixelFormatAttribivARB*(hdc: HDC, iPixelFormat: TGLint, + iLayerPlane: TGLint, nAttributes: TGLuint, + piAttributes: PGLint, piValues: PGLint): BOOL{. + dynlib: dllname, importc.} +proc wglGetPixelFormatAttribfvARB*(hdc: HDC, iPixelFormat: TGLint, + iLayerPlane: TGLint, nAttributes: TGLuint, + piAttributes: PGLint, pfValues: PGLfloat): BOOL{. + dynlib: dllname, importc.} +proc wglChoosePixelFormatARB*(hdc: HDC, piAttribIList: PGLint, + pfAttribFList: PGLfloat, nMaxFormats: TGLuint, + piFormats: PGLint, nNumFormats: PGLuint): BOOL{. + dynlib: dllname, importc.} +const + WGL_ERROR_INVALID_PIXEL_TYPE_ARB* = 0x00002043 + WGL_ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB* = 0x00002054 + +proc wglMakeContextCurrentARB*(hDrawDC: HDC, hReadDC: HDC, hglrc: HGLRC): BOOL{. + dynlib: dllname, importc.} +proc wglGetCurrentReadDCARB*(): HDC{.dynlib: dllname, importc.} +const + WGL_DRAW_TO_PBUFFER_ARB* = 0x0000202D # WGL_DRAW_TO_PBUFFER_ARB { already defined } + WGL_MAX_PBUFFER_PIXELS_ARB* = 0x0000202E + WGL_MAX_PBUFFER_WIDTH_ARB* = 0x0000202F + WGL_MAX_PBUFFER_HEIGHT_ARB* = 0x00002030 + WGL_PBUFFER_LARGEST_ARB* = 0x00002033 + WGL_PBUFFER_WIDTH_ARB* = 0x00002034 + WGL_PBUFFER_HEIGHT_ARB* = 0x00002035 + WGL_PBUFFER_LOST_ARB* = 0x00002036 + +proc wglCreatePbufferARB*(hDC: HDC, iPixelFormat: TGLint, iWidth: TGLint, + iHeight: TGLint, piAttribList: PGLint): THandle{. + dynlib: dllname, importc.} +proc wglGetPbufferDCARB*(hPbuffer: THandle): HDC{.dynlib: dllname, importc.} +proc wglReleasePbufferDCARB*(hPbuffer: THandle, hDC: HDC): TGLint{. + dynlib: dllname, importc.} +proc wglDestroyPbufferARB*(hPbuffer: THandle): BOOL{.dynlib: dllname, importc.} +proc wglQueryPbufferARB*(hPbuffer: THandle, iAttribute: TGLint, piValue: PGLint): BOOL{. + dynlib: dllname, importc.} +proc wglSwapIntervalEXT*(interval: TGLint): BOOL{.dynlib: dllname, importc.} +proc wglGetSwapIntervalEXT*(): TGLint{.dynlib: dllname, importc.} +const + WGL_BIND_TO_TEXTURE_RGB_ARB* = 0x00002070 + WGL_BIND_TO_TEXTURE_RGBA_ARB* = 0x00002071 + WGL_TEXTURE_FORMAT_ARB* = 0x00002072 + WGL_TEXTURE_TARGET_ARB* = 0x00002073 + WGL_MIPMAP_TEXTURE_ARB* = 0x00002074 + WGL_TEXTURE_RGB_ARB* = 0x00002075 + WGL_TEXTURE_RGBA_ARB* = 0x00002076 + WGL_NO_TEXTURE_ARB* = 0x00002077 + WGL_TEXTURE_CUBE_MAP_ARB* = 0x00002078 + WGL_TEXTURE_1D_ARB* = 0x00002079 + WGL_TEXTURE_2D_ARB* = 0x0000207A # WGL_NO_TEXTURE_ARB { already defined } + WGL_MIPMAP_LEVEL_ARB* = 0x0000207B + WGL_CUBE_MAP_FACE_ARB* = 0x0000207C + WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB* = 0x0000207D + WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB* = 0x0000207E + WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB* = 0x0000207F + WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB* = 0x00002080 + WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB* = 0x00002081 + WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB* = 0x00002082 + WGL_FRONT_LEFT_ARB* = 0x00002083 + WGL_FRONT_RIGHT_ARB* = 0x00002084 + WGL_BACK_LEFT_ARB* = 0x00002085 + WGL_BACK_RIGHT_ARB* = 0x00002086 + WGL_AUX0_ARB* = 0x00002087 + WGL_AUX1_ARB* = 0x00002088 + WGL_AUX2_ARB* = 0x00002089 + WGL_AUX3_ARB* = 0x0000208A + WGL_AUX4_ARB* = 0x0000208B + WGL_AUX5_ARB* = 0x0000208C + WGL_AUX6_ARB* = 0x0000208D + WGL_AUX7_ARB* = 0x0000208E + WGL_AUX8_ARB* = 0x0000208F + WGL_AUX9_ARB* = 0x00002090 + +proc wglBindTexImageARB*(hPbuffer: THandle, iBuffer: TGLint): BOOL{. + dynlib: dllname, importc.} +proc wglReleaseTexImageARB*(hPbuffer: THandle, iBuffer: TGLint): BOOL{. + dynlib: dllname, importc.} +proc wglSetPbufferAttribARB*(hPbuffer: THandle, piAttribList: PGLint): BOOL{. + dynlib: dllname, importc.} +proc wglGetExtensionsStringEXT*(): cstring{.dynlib: dllname, importc.} +proc wglMakeContextCurrentEXT*(hDrawDC: HDC, hReadDC: HDC, hglrc: HGLRC): BOOL{. + dynlib: dllname, importc.} +proc wglGetCurrentReadDCEXT*(): HDC{.dynlib: dllname, importc.} +const + WGL_DRAW_TO_PBUFFER_EXT* = 0x0000202D + WGL_MAX_PBUFFER_PIXELS_EXT* = 0x0000202E + WGL_MAX_PBUFFER_WIDTH_EXT* = 0x0000202F + WGL_MAX_PBUFFER_HEIGHT_EXT* = 0x00002030 + WGL_OPTIMAL_PBUFFER_WIDTH_EXT* = 0x00002031 + WGL_OPTIMAL_PBUFFER_HEIGHT_EXT* = 0x00002032 + WGL_PBUFFER_LARGEST_EXT* = 0x00002033 + WGL_PBUFFER_WIDTH_EXT* = 0x00002034 + WGL_PBUFFER_HEIGHT_EXT* = 0x00002035 + +proc wglCreatePbufferEXT*(hDC: HDC, iPixelFormat: TGLint, iWidth: TGLint, + iHeight: TGLint, piAttribList: PGLint): THandle{. + dynlib: dllname, importc.} +proc wglGetPbufferDCEXT*(hPbuffer: THandle): HDC{.dynlib: dllname, importc.} +proc wglReleasePbufferDCEXT*(hPbuffer: THandle, hDC: HDC): TGLint{. + dynlib: dllname, importc.} +proc wglDestroyPbufferEXT*(hPbuffer: THandle): BOOL{.dynlib: dllname, importc.} +proc wglQueryPbufferEXT*(hPbuffer: THandle, iAttribute: TGLint, piValue: PGLint): BOOL{. + dynlib: dllname, importc.} +const + WGL_NUMBER_PIXEL_FORMATS_EXT* = 0x00002000 + WGL_DRAW_TO_WINDOW_EXT* = 0x00002001 + WGL_DRAW_TO_BITMAP_EXT* = 0x00002002 + WGL_ACCELERATION_EXT* = 0x00002003 + WGL_NEED_PALETTE_EXT* = 0x00002004 + WGL_NEED_SYSTEM_PALETTE_EXT* = 0x00002005 + WGL_SWAP_LAYER_BUFFERS_EXT* = 0x00002006 + WGL_SWAP_METHOD_EXT* = 0x00002007 + WGL_NUMBER_OVERLAYS_EXT* = 0x00002008 + WGL_NUMBER_UNDERLAYS_EXT* = 0x00002009 + WGL_TRANSPARENT_EXT* = 0x0000200A + WGL_TRANSPARENT_VALUE_EXT* = 0x0000200B + WGL_SHARE_DEPTH_EXT* = 0x0000200C + WGL_SHARE_STENCIL_EXT* = 0x0000200D + WGL_SHARE_ACCUM_EXT* = 0x0000200E + WGL_SUPPORT_GDI_EXT* = 0x0000200F + WGL_SUPPORT_OPENGL_EXT* = 0x00002010 + WGL_DOUBLE_BUFFER_EXT* = 0x00002011 + WGL_STEREO_EXT* = 0x00002012 + WGL_PIXEL_TYPE_EXT* = 0x00002013 + WGL_COLOR_BITS_EXT* = 0x00002014 + WGL_RED_BITS_EXT* = 0x00002015 + WGL_RED_SHIFT_EXT* = 0x00002016 + WGL_GREEN_BITS_EXT* = 0x00002017 + WGL_GREEN_SHIFT_EXT* = 0x00002018 + WGL_BLUE_BITS_EXT* = 0x00002019 + WGL_BLUE_SHIFT_EXT* = 0x0000201A + WGL_ALPHA_BITS_EXT* = 0x0000201B + WGL_ALPHA_SHIFT_EXT* = 0x0000201C + WGL_ACCUM_BITS_EXT* = 0x0000201D + WGL_ACCUM_RED_BITS_EXT* = 0x0000201E + WGL_ACCUM_GREEN_BITS_EXT* = 0x0000201F + WGL_ACCUM_BLUE_BITS_EXT* = 0x00002020 + WGL_ACCUM_ALPHA_BITS_EXT* = 0x00002021 + WGL_DEPTH_BITS_EXT* = 0x00002022 + WGL_STENCIL_BITS_EXT* = 0x00002023 + WGL_AUX_BUFFERS_EXT* = 0x00002024 + WGL_NO_ACCELERATION_EXT* = 0x00002025 + WGL_GENERIC_ACCELERATION_EXT* = 0x00002026 + WGL_FULL_ACCELERATION_EXT* = 0x00002027 + WGL_SWAP_EXCHANGE_EXT* = 0x00002028 + WGL_SWAP_COPY_EXT* = 0x00002029 + WGL_SWAP_UNDEFINED_EXT* = 0x0000202A + WGL_TYPE_RGBA_EXT* = 0x0000202B + WGL_TYPE_COLORINDEX_EXT* = 0x0000202C + +proc wglGetPixelFormatAttribivEXT*(hdc: HDC, iPixelFormat: TGLint, + iLayerPlane: TGLint, nAttributes: TGLuint, + piAttributes: PGLint, piValues: PGLint): BOOL{. + dynlib: dllname, importc.} +proc wglGetPixelFormatAttribfvEXT*(hdc: HDC, iPixelFormat: TGLint, + iLayerPlane: TGLint, nAttributes: TGLuint, + piAttributes: PGLint, pfValues: PGLfloat): BOOL{. + dynlib: dllname, importc.} +proc wglChoosePixelFormatEXT*(hdc: HDC, piAttribIList: PGLint, + pfAttribFList: PGLfloat, nMaxFormats: TGLuint, + piFormats: PGLint, nNumFormats: PGLuint): BOOL{. + dynlib: dllname, importc.} +const + WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D* = 0x00002050 + WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D* = 0x00002051 + WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D* = 0x00002052 + WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D* = 0x00002053 + +proc wglGetDigitalVideoParametersI3D*(hDC: HDC, iAttribute: TGLint, + piValue: PGLint): BOOL{.dynlib: dllname, + importc.} +proc wglSetDigitalVideoParametersI3D*(hDC: HDC, iAttribute: TGLint, + piValue: PGLint): BOOL{.dynlib: dllname, + importc.} +const + WGL_GAMMA_TABLE_SIZE_I3D* = 0x0000204E + WGL_GAMMA_EXCLUDE_DESKTOP_I3D* = 0x0000204F + +proc wglGetGammaTableParametersI3D*(hDC: HDC, iAttribute: TGLint, + piValue: PGLint): BOOL{.dynlib: dllname, + importc.} +proc wglSetGammaTableParametersI3D*(hDC: HDC, iAttribute: TGLint, + piValue: PGLint): BOOL{.dynlib: dllname, + importc.} +proc wglGetGammaTableI3D*(hDC: HDC, iEntries: TGLint, puRed: PGLUSHORT, + puGreen: PGLUSHORT, puBlue: PGLUSHORT): BOOL{. + dynlib: dllname, importc.} +proc wglSetGammaTableI3D*(hDC: HDC, iEntries: TGLint, puRed: PGLUSHORT, + puGreen: PGLUSHORT, puBlue: PGLUSHORT): BOOL{. + dynlib: dllname, importc.} +const + WGL_GENLOCK_SOURCE_MULTIVIEW_I3D* = 0x00002044 + WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D* = 0x00002045 + WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D* = 0x00002046 + WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D* = 0x00002047 + WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D* = 0x00002048 + WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D* = 0x00002049 + WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D* = 0x0000204A + WGL_GENLOCK_SOURCE_EDGE_RISING_I3D* = 0x0000204B + WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D* = 0x0000204C + WGL_FLOAT_COMPONENTS_NV* = 0x000020B0 + WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV* = 0x000020B1 + WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV* = 0x000020B2 + WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV* = 0x000020B3 + WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV* = 0x000020B4 + WGL_TEXTURE_FLOAT_R_NV* = 0x000020B5 + WGL_TEXTURE_FLOAT_RG_NV* = 0x000020B6 + WGL_TEXTURE_FLOAT_RGB_NV* = 0x000020B7 + WGL_TEXTURE_FLOAT_RGBA_NV* = 0x000020B8 + +proc wglEnableGenlockI3D*(hDC: HDC): BOOL{.dynlib: dllname, importc.} +proc wglDisableGenlockI3D*(hDC: HDC): BOOL{.dynlib: dllname, importc.} +proc wglIsEnabledGenlockI3D*(hDC: HDC, pFlag: PBOOL): BOOL{.dynlib: dllname, + importc.} +proc wglGenlockSourceI3D*(hDC: HDC, uSource: TGLuint): BOOL{.dynlib: dllname, + importc.} +proc wglGetGenlockSourceI3D*(hDC: HDC, uSource: PGLUINT): BOOL{.dynlib: dllname, + importc.} +proc wglGenlockSourceEdgeI3D*(hDC: HDC, uEdge: TGLuint): BOOL{.dynlib: dllname, + importc.} +proc wglGetGenlockSourceEdgeI3D*(hDC: HDC, uEdge: PGLUINT): BOOL{. + dynlib: dllname, importc.} +proc wglGenlockSampleRateI3D*(hDC: HDC, uRate: TGLuint): BOOL{.dynlib: dllname, + importc.} +proc wglGetGenlockSampleRateI3D*(hDC: HDC, uRate: PGLUINT): BOOL{. + dynlib: dllname, importc.} +proc wglGenlockSourceDelayI3D*(hDC: HDC, uDelay: TGLuint): BOOL{. + dynlib: dllname, importc.} +proc wglGetGenlockSourceDelayI3D*(hDC: HDC, uDelay: PGLUINT): BOOL{. + dynlib: dllname, importc.} +proc wglQueryGenlockMaxSourceDelayI3D*(hDC: HDC, uMaxLineDelay: PGLUINT, + uMaxPixelDelay: PGLUINT): BOOL{. + dynlib: dllname, importc.} +const + WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV* = 0x000020A0 + WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV* = 0x000020A1 + WGL_TEXTURE_RECTANGLE_NV* = 0x000020A2 + +const + WGL_RGBA_FLOAT_MODE_ATI* = 0x00008820 + WGL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI* = 0x00008835 + WGL_TYPE_RGBA_FLOAT_ATI* = 0x000021A0 + +# implementation diff --git a/lib/base/opengl/wingl.pp b/lib/base/opengl/wingl.pp new file mode 100644 index 000000000..70be6674e --- /dev/null +++ b/lib/base/opengl/wingl.pp @@ -0,0 +1,313 @@ +unit wingl; + +interface + +uses gl; + +function wglGetExtensionsStringARB(hdc: HDC): Pchar; external dllname; + +function Load_WGL_ARB_extensions_string: Boolean; external dllname; + +const + WGL_FRONT_COLOR_BUFFER_BIT_ARB = $0001; + WGL_BACK_COLOR_BUFFER_BIT_ARB = $0002; + WGL_DEPTH_BUFFER_BIT_ARB = $0004; + WGL_STENCIL_BUFFER_BIT_ARB = $0008; + +function WinChoosePixelFormat(DC: HDC; p2: PPixelFormatDescriptor): Integer; external dllname; external 'gdi32' name 'ChoosePixelFormat'; + +function wglCreateBufferRegionARB(hDC: HDC; iLayerPlane: TGLint; uType: TGLuint): THandle; external dllname; +procedure wglDeleteBufferRegionARB(hRegion: THandle); external dllname; +function wglSaveBufferRegionARB(hRegion: THandle; x: TGLint; y: TGLint; width: TGLint; height: TGLint): BOOL; external dllname; +function wglRestoreBufferRegionARB(hRegion: THandle; x: TGLint; y: TGLint; width: TGLint; height: TGLint; xSrc: TGLint; ySrc: TGLint): BOOL; external dllname; + + function wglAllocateMemoryNV(size: TGLsizei; readFrequency: TGLfloat; writeFrequency: TGLfloat; priority: TGLfloat): PGLvoid; external dllname; + procedure wglFreeMemoryNV(pointer: PGLvoid); external dllname; + +const + WGL_IMAGE_BUFFER_MIN_ACCESS_I3D = $0001; + WGL_IMAGE_BUFFER_LOCK_I3D = $0002; + + function wglCreateImageBufferI3D(hDC: HDC; dwSize: DWORD; uFlags: UINT): PGLvoid; external dllname; + function wglDestroyImageBufferI3D(hDC: HDC; pAddress: PGLvoid): BOOL; external dllname; + function wglAssociateImageBufferEventsI3D(hdc: HDC; pEvent: PHandle; pAddress: PGLvoid; pSize: PDWORD; count: UINT): BOOL; external dllname; + function wglReleaseImageBufferEventsI3D(hdc: HDC; pAddress: PGLvoid; count: UINT): BOOL; external dllname; + + function wglEnableFrameLockI3D(): BOOL; external dllname; + function wglDisableFrameLockI3D(): BOOL; external dllname; + function wglIsEnabledFrameLockI3D(pFlag: PBOOL): BOOL; external dllname; + function wglQueryFrameLockMasterI3D(pFlag: PBOOL): BOOL; external dllname; + + function wglGetFrameUsageI3D(pUsage: PGLfloat): BOOL; external dllname; + function wglBeginFrameTrackingI3D(): BOOL; external dllname; + function wglEndFrameTrackingI3D(): BOOL; external dllname; + function wglQueryFrameTrackingI3D(pFrameCount: PDWORD; pMissedFrames: PDWORD; pLastMissedUsage: PGLfloat): BOOL; external dllname; + +const + WGL_NUMBER_PIXEL_FORMATS_ARB = $2000; + WGL_DRAW_TO_WINDOW_ARB = $2001; + WGL_DRAW_TO_BITMAP_ARB = $2002; + WGL_ACCELERATION_ARB = $2003; + WGL_NEED_PALETTE_ARB = $2004; + WGL_NEED_SYSTEM_PALETTE_ARB = $2005; + WGL_SWAP_LAYER_BUFFERS_ARB = $2006; + WGL_SWAP_METHOD_ARB = $2007; + WGL_NUMBER_OVERLAYS_ARB = $2008; + WGL_NUMBER_UNDERLAYS_ARB = $2009; + WGL_TRANSPARENT_ARB = $200A; + WGL_TRANSPARENT_RED_VALUE_ARB = $2037; + WGL_TRANSPARENT_GREEN_VALUE_ARB = $2038; + WGL_TRANSPARENT_BLUE_VALUE_ARB = $2039; + WGL_TRANSPARENT_ALPHA_VALUE_ARB = $203A; + WGL_TRANSPARENT_INDEX_VALUE_ARB = $203B; + WGL_SHARE_DEPTH_ARB = $200C; + WGL_SHARE_STENCIL_ARB = $200D; + WGL_SHARE_ACCUM_ARB = $200E; + WGL_SUPPORT_GDI_ARB = $200F; + WGL_SUPPORT_OPENGL_ARB = $2010; + WGL_DOUBLE_BUFFER_ARB = $2011; + WGL_STEREO_ARB = $2012; + WGL_PIXEL_TYPE_ARB = $2013; + WGL_COLOR_BITS_ARB = $2014; + WGL_RED_BITS_ARB = $2015; + WGL_RED_SHIFT_ARB = $2016; + WGL_GREEN_BITS_ARB = $2017; + WGL_GREEN_SHIFT_ARB = $2018; + WGL_BLUE_BITS_ARB = $2019; + WGL_BLUE_SHIFT_ARB = $201A; + WGL_ALPHA_BITS_ARB = $201B; + WGL_ALPHA_SHIFT_ARB = $201C; + WGL_ACCUM_BITS_ARB = $201D; + WGL_ACCUM_RED_BITS_ARB = $201E; + WGL_ACCUM_GREEN_BITS_ARB = $201F; + WGL_ACCUM_BLUE_BITS_ARB = $2020; + WGL_ACCUM_ALPHA_BITS_ARB = $2021; + WGL_DEPTH_BITS_ARB = $2022; + WGL_STENCIL_BITS_ARB = $2023; + WGL_AUX_BUFFERS_ARB = $2024; + WGL_NO_ACCELERATION_ARB = $2025; + WGL_GENERIC_ACCELERATION_ARB = $2026; + WGL_FULL_ACCELERATION_ARB = $2027; + WGL_SWAP_EXCHANGE_ARB = $2028; + WGL_SWAP_COPY_ARB = $2029; + WGL_SWAP_UNDEFINED_ARB = $202A; + WGL_TYPE_RGBA_ARB = $202B; + WGL_TYPE_COLORINDEX_ARB = $202C; + + function wglGetPixelFormatAttribivARB(hdc: HDC; iPixelFormat: TGLint; iLayerPlane: TGLint; nAttributes: TGLuint; const piAttributes: PGLint; piValues: PGLint): BOOL; external dllname; + function wglGetPixelFormatAttribfvARB(hdc: HDC; iPixelFormat: TGLint; iLayerPlane: TGLint; nAttributes: TGLuint; const piAttributes: PGLint; pfValues: PGLfloat): BOOL; external dllname; + function wglChoosePixelFormatARB(hdc: HDC; const piAttribIList: PGLint; const pfAttribFList: PGLfloat; nMaxFormats: TGLuint; piFormats: PGLint; nNumFormats: PGLuint): BOOL; external dllname; + + +const + WGL_ERROR_INVALID_PIXEL_TYPE_ARB = $2043; + WGL_ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB = $2054; + + function wglMakeContextCurrentARB(hDrawDC: HDC; hReadDC: HDC; hglrc: HGLRC): BOOL; external dllname; + function wglGetCurrentReadDCARB(): HDC; external dllname; + +function Load_WGL_ARB_make_current_read: Boolean; + +const + WGL_DRAW_TO_PBUFFER_ARB = $202D; + // WGL_DRAW_TO_PBUFFER_ARB { already defined } + WGL_MAX_PBUFFER_PIXELS_ARB = $202E; + WGL_MAX_PBUFFER_WIDTH_ARB = $202F; + WGL_MAX_PBUFFER_HEIGHT_ARB = $2030; + WGL_PBUFFER_LARGEST_ARB = $2033; + WGL_PBUFFER_WIDTH_ARB = $2034; + WGL_PBUFFER_HEIGHT_ARB = $2035; + WGL_PBUFFER_LOST_ARB = $2036; + + function wglCreatePbufferARB(hDC: HDC; iPixelFormat: TGLint; iWidth: TGLint; iHeight: TGLint; const piAttribList: PGLint): THandle; external dllname; + function wglGetPbufferDCARB(hPbuffer: THandle): HDC; external dllname; + function wglReleasePbufferDCARB(hPbuffer: THandle; hDC: HDC): TGLint; external dllname; + function wglDestroyPbufferARB(hPbuffer: THandle): BOOL; external dllname; + function wglQueryPbufferARB(hPbuffer: THandle; iAttribute: TGLint; piValue: PGLint): BOOL; external dllname; + + + function wglSwapIntervalEXT(interval: TGLint): BOOL; external dllname; + function wglGetSwapIntervalEXT(): TGLint; external dllname; + +const + WGL_BIND_TO_TEXTURE_RGB_ARB = $2070; + WGL_BIND_TO_TEXTURE_RGBA_ARB = $2071; + WGL_TEXTURE_FORMAT_ARB = $2072; + WGL_TEXTURE_TARGET_ARB = $2073; + WGL_MIPMAP_TEXTURE_ARB = $2074; + WGL_TEXTURE_RGB_ARB = $2075; + WGL_TEXTURE_RGBA_ARB = $2076; + WGL_NO_TEXTURE_ARB = $2077; + WGL_TEXTURE_CUBE_MAP_ARB = $2078; + WGL_TEXTURE_1D_ARB = $2079; + WGL_TEXTURE_2D_ARB = $207A; + // WGL_NO_TEXTURE_ARB { already defined } + WGL_MIPMAP_LEVEL_ARB = $207B; + WGL_CUBE_MAP_FACE_ARB = $207C; + WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB = $207D; + WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB = $207E; + WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB = $207F; + WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB = $2080; + WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB = $2081; + WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB = $2082; + WGL_FRONT_LEFT_ARB = $2083; + WGL_FRONT_RIGHT_ARB = $2084; + WGL_BACK_LEFT_ARB = $2085; + WGL_BACK_RIGHT_ARB = $2086; + WGL_AUX0_ARB = $2087; + WGL_AUX1_ARB = $2088; + WGL_AUX2_ARB = $2089; + WGL_AUX3_ARB = $208A; + WGL_AUX4_ARB = $208B; + WGL_AUX5_ARB = $208C; + WGL_AUX6_ARB = $208D; + WGL_AUX7_ARB = $208E; + WGL_AUX8_ARB = $208F; + WGL_AUX9_ARB = $2090; + + function wglBindTexImageARB(hPbuffer: THandle; iBuffer: TGLint): BOOL; external dllname; + function wglReleaseTexImageARB(hPbuffer: THandle; iBuffer: TGLint): BOOL; external dllname; + function wglSetPbufferAttribARB(hPbuffer: THandle; const piAttribList: PGLint): BOOL; external dllname; + + + function wglGetExtensionsStringEXT(): Pchar; external dllname; + + function wglMakeContextCurrentEXT(hDrawDC: HDC; hReadDC: HDC; hglrc: HGLRC): BOOL; external dllname; + function wglGetCurrentReadDCEXT(): HDC; external dllname; + +const + WGL_DRAW_TO_PBUFFER_EXT = $202D; + WGL_MAX_PBUFFER_PIXELS_EXT = $202E; + WGL_MAX_PBUFFER_WIDTH_EXT = $202F; + WGL_MAX_PBUFFER_HEIGHT_EXT = $2030; + WGL_OPTIMAL_PBUFFER_WIDTH_EXT = $2031; + WGL_OPTIMAL_PBUFFER_HEIGHT_EXT = $2032; + WGL_PBUFFER_LARGEST_EXT = $2033; + WGL_PBUFFER_WIDTH_EXT = $2034; + WGL_PBUFFER_HEIGHT_EXT = $2035; + + function wglCreatePbufferEXT(hDC: HDC; iPixelFormat: TGLint; iWidth: TGLint; iHeight: TGLint; const piAttribList: PGLint): THandle; external dllname; + function wglGetPbufferDCEXT(hPbuffer: THandle): HDC; external dllname; + function wglReleasePbufferDCEXT(hPbuffer: THandle; hDC: HDC): TGLint; external dllname; + function wglDestroyPbufferEXT(hPbuffer: THandle): BOOL; external dllname; + function wglQueryPbufferEXT(hPbuffer: THandle; iAttribute: TGLint; piValue: PGLint): BOOL; external dllname; + +const + WGL_NUMBER_PIXEL_FORMATS_EXT = $2000; + WGL_DRAW_TO_WINDOW_EXT = $2001; + WGL_DRAW_TO_BITMAP_EXT = $2002; + WGL_ACCELERATION_EXT = $2003; + WGL_NEED_PALETTE_EXT = $2004; + WGL_NEED_SYSTEM_PALETTE_EXT = $2005; + WGL_SWAP_LAYER_BUFFERS_EXT = $2006; + WGL_SWAP_METHOD_EXT = $2007; + WGL_NUMBER_OVERLAYS_EXT = $2008; + WGL_NUMBER_UNDERLAYS_EXT = $2009; + WGL_TRANSPARENT_EXT = $200A; + WGL_TRANSPARENT_VALUE_EXT = $200B; + WGL_SHARE_DEPTH_EXT = $200C; + WGL_SHARE_STENCIL_EXT = $200D; + WGL_SHARE_ACCUM_EXT = $200E; + WGL_SUPPORT_GDI_EXT = $200F; + WGL_SUPPORT_OPENGL_EXT = $2010; + WGL_DOUBLE_BUFFER_EXT = $2011; + WGL_STEREO_EXT = $2012; + WGL_PIXEL_TYPE_EXT = $2013; + WGL_COLOR_BITS_EXT = $2014; + WGL_RED_BITS_EXT = $2015; + WGL_RED_SHIFT_EXT = $2016; + WGL_GREEN_BITS_EXT = $2017; + WGL_GREEN_SHIFT_EXT = $2018; + WGL_BLUE_BITS_EXT = $2019; + WGL_BLUE_SHIFT_EXT = $201A; + WGL_ALPHA_BITS_EXT = $201B; + WGL_ALPHA_SHIFT_EXT = $201C; + WGL_ACCUM_BITS_EXT = $201D; + WGL_ACCUM_RED_BITS_EXT = $201E; + WGL_ACCUM_GREEN_BITS_EXT = $201F; + WGL_ACCUM_BLUE_BITS_EXT = $2020; + WGL_ACCUM_ALPHA_BITS_EXT = $2021; + WGL_DEPTH_BITS_EXT = $2022; + WGL_STENCIL_BITS_EXT = $2023; + WGL_AUX_BUFFERS_EXT = $2024; + WGL_NO_ACCELERATION_EXT = $2025; + WGL_GENERIC_ACCELERATION_EXT = $2026; + WGL_FULL_ACCELERATION_EXT = $2027; + WGL_SWAP_EXCHANGE_EXT = $2028; + WGL_SWAP_COPY_EXT = $2029; + WGL_SWAP_UNDEFINED_EXT = $202A; + WGL_TYPE_RGBA_EXT = $202B; + WGL_TYPE_COLORINDEX_EXT = $202C; + + function wglGetPixelFormatAttribivEXT(hdc: HDC; iPixelFormat: TGLint; iLayerPlane: TGLint; nAttributes: TGLuint; piAttributes: PGLint; piValues: PGLint): BOOL; external dllname; + function wglGetPixelFormatAttribfvEXT(hdc: HDC; iPixelFormat: TGLint; iLayerPlane: TGLint; nAttributes: TGLuint; piAttributes: PGLint; pfValues: PGLfloat): BOOL; external dllname; + function wglChoosePixelFormatEXT(hdc: HDC; const piAttribIList: PGLint; const pfAttribFList: PGLfloat; nMaxFormats: TGLuint; piFormats: PGLint; nNumFormats: PGLuint): BOOL; external dllname; + + +const + WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D = $2050; + WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D = $2051; + WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D = $2052; + WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D = $2053; + + function wglGetDigitalVideoParametersI3D(hDC: HDC; iAttribute: TGLint; piValue: PGLint): BOOL; external dllname; + function wglSetDigitalVideoParametersI3D(hDC: HDC; iAttribute: TGLint; const piValue: PGLint): BOOL; external dllname; + + +const + WGL_GAMMA_TABLE_SIZE_I3D = $204E; + WGL_GAMMA_EXCLUDE_DESKTOP_I3D = $204F; + + function wglGetGammaTableParametersI3D(hDC: HDC; iAttribute: TGLint; piValue: PGLint): BOOL; external dllname; + function wglSetGammaTableParametersI3D(hDC: HDC; iAttribute: TGLint; const piValue: PGLint): BOOL; external dllname; + function wglGetGammaTableI3D(hDC: HDC; iEntries: TGLint; puRed: PGLUSHORT; puGreen: PGLUSHORT; puBlue: PGLUSHORT): BOOL; external dllname; + function wglSetGammaTableI3D(hDC: HDC; iEntries: TGLint; const puRed: PGLUSHORT; const puGreen: PGLUSHORT; const puBlue: PGLUSHORT): BOOL; external dllname; + +const + WGL_GENLOCK_SOURCE_MULTIVIEW_I3D = $2044; + WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D = $2045; + WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D = $2046; + WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D = $2047; + WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D = $2048; + WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D = $2049; + WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D = $204A; + WGL_GENLOCK_SOURCE_EDGE_RISING_I3D = $204B; + WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D = $204C; + + WGL_FLOAT_COMPONENTS_NV = $20B0; + WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV = $20B1; + WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV = $20B2; + WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV = $20B3; + WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV = $20B4; + WGL_TEXTURE_FLOAT_R_NV = $20B5; + WGL_TEXTURE_FLOAT_RG_NV = $20B6; + WGL_TEXTURE_FLOAT_RGB_NV = $20B7; + WGL_TEXTURE_FLOAT_RGBA_NV = $20B8; + + function wglEnableGenlockI3D(hDC: HDC): BOOL; external dllname; + function wglDisableGenlockI3D(hDC: HDC): BOOL; external dllname; + function wglIsEnabledGenlockI3D(hDC: HDC; pFlag: PBOOL): BOOL; external dllname; + function wglGenlockSourceI3D(hDC: HDC; uSource: TGLuint): BOOL; external dllname; + function wglGetGenlockSourceI3D(hDC: HDC; uSource: PGLUINT): BOOL; external dllname; + function wglGenlockSourceEdgeI3D(hDC: HDC; uEdge: TGLuint): BOOL; external dllname; + function wglGetGenlockSourceEdgeI3D(hDC: HDC; uEdge: PGLUINT): BOOL; external dllname; + function wglGenlockSampleRateI3D(hDC: HDC; uRate: TGLuint): BOOL; external dllname; + function wglGetGenlockSampleRateI3D(hDC: HDC; uRate: PGLUINT): BOOL; external dllname; + function wglGenlockSourceDelayI3D(hDC: HDC; uDelay: TGLuint): BOOL; external dllname; + function wglGetGenlockSourceDelayI3D(hDC: HDC; uDelay: PGLUINT): BOOL; external dllname; + function wglQueryGenlockMaxSourceDelayI3D(hDC: HDC; uMaxLineDelay: PGLUINT; uMaxPixelDelay: PGLUINT): BOOL; external dllname; + +const + WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV = $20A0; + WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV = $20A1; + WGL_TEXTURE_RECTANGLE_NV = $20A2; + + +const + WGL_RGBA_FLOAT_MODE_ATI = $8820; + WGL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI = $8835; + WGL_TYPE_RGBA_FLOAT_ATI = $21A0; + +implementation + +end. diff --git a/lib/base/sdl/sdl.nim b/lib/base/sdl/sdl.nim new file mode 100644 index 000000000..2c83c4893 --- /dev/null +++ b/lib/base/sdl/sdl.nim @@ -0,0 +1,2521 @@ + +#****************************************************************************** +# +# JEDI-SDL : Pascal units for SDL - Simple DirectMedia Layer +# Conversion of the Simple DirectMedia Layer Headers +# +# Portions created by Sam Lantinga <slouken@devolution.com> are +# Copyright (C) 1997-2004 Sam Lantinga +# 5635-34 Springhouse Dr. +# Pleasanton, CA 94588 (USA) +# +# All Rights Reserved. +# +# The original files are : SDL.h +# SDL_main.h +# SDL_types.h +# SDL_rwops.h +# SDL_timer.h +# SDL_audio.h +# SDL_cdrom.h +# SDL_joystick.h +# SDL_mouse.h +# SDL_keyboard.h +# SDL_events.h +# SDL_video.h +# SDL_byteorder.h +# SDL_version.h +# SDL_active.h +# SDL_thread.h +# SDL_mutex .h +# SDL_getenv.h +# SDL_loadso.h +# +# The initial developer of this Pascal code was : +# Dominique Louis <Dominique@SavageSoftware.com.au> +# +# Portions created by Dominique Louis are +# Copyright (C) 2000 - 2004 Dominique Louis. +# +# +# Contributor(s) +# -------------- +# Tom Jones <tigertomjones@gmx.de> His Project inspired this conversion +# Matthias Thoma <ma.thoma@gmx.de> +# +# Obtained through: +# Joint Endeavour of Delphi Innovators ( Project JEDI ) +# +# You may retrieve the latest version of this file at the Project +# JEDI home page, located at http://delphi-jedi.org +# +# The contents of this file are used with permission, subject to +# the Mozilla Public License Version 1.1 (the "License"); you may +# not use this file except in compliance with the License. You may +# obtain a copy of the License at +# http://www.mozilla.org/MPL/MPL-1.1.html +# +# Software distributed under the License is distributed on an +# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# Description +# ----------- +# +# +# +# +# +# +# +# Requires +# -------- +# The SDL Runtime libraris on Win32 : SDL.dll on Linux : libSDL.so +# They are available from... +# http://www.libsdl.org . +# +# Programming Notes +# ----------------- +# +# +# +# +# Revision History +# ---------------- +# May 08 2001 - DL : Added Keyboard State Array ( See demos for how to +# use ) +# PKeyStateArr = ^TKeyStateArr; +# TKeyStateArr = array[0..65000] of UInt8; +# As most games will need it. +# +# April 02 2001 - DL : Added SDL_getenv.h definitions and tested version +# 1.2.0 compatability. +# +# March 13 2001 - MT : Added Linux compatibility. +# +# March 10 2001 - MT : Added externalsyms for DEFINES +# Changed the license header +# +# March 09 2001 - MT : Added Kylix Ifdefs/Deleted the uses mmsystem +# +# March 01 2001 - DL : Update conversion of version 1.1.8 +# +# July 22 2001 - DL : Added TUInt8Array and PUIntArray after suggestions +# from Matthias Thoma and Eric Grange. +# +# October 12 2001 - DL : Various changes as suggested by Matthias Thoma and +# David Acklam +# +# October 24 2001 - DL : Added FreePascal support as per suggestions from +# Dean Ellis. +# +# October 27 2001 - DL : Added SDL_BUTTON macro +# +# November 08 2001 - DL : Bug fix as pointed out by Puthoon. +# +# November 29 2001 - DL : Bug fix of SDL_SetGammaRamp as pointed out by Simon +# Rushton. +# +# November 30 2001 - DL : SDL_NOFRAME added as pointed out by Simon Rushton. +# +# December 11 2001 - DL : Added $WEAKPACKAGEUNIT ON to facilitate useage in +# Components +# +# January 05 2002 - DL : Added SDL_Swap32 function as suggested by Matthias +# Thoma and also made sure the _getenv from +# MSVCRT.DLL uses the right calling convention +# +# January 25 2002 - DL : Updated conversion of SDL_AddTimer & +# SDL_RemoveTimer as per suggestions from Matthias +# Thoma. +# +# January 27 2002 - DL : Commented out exported function putenv and getenv +# So that developers get used to using SDL_putenv +# SDL_getenv, as they are more portable +# +# March 05 2002 - DL : Added FreeAnNil procedure for Delphi 4 users. +# +# October 23 2002 - DL : Added Delphi 3 Define of Win32. +# If you intend to you Delphi 3... +# ( which is officially unsupported ) make sure you +# remove references to $EXTERNALSYM in this and other +# SDL files. +# +# November 29 2002 - DL : Fixed bug in Declaration of SDL_GetRGBA that was +# pointed out by Todd Lang +# +# April 03 2003 - DL : Added jedi-sdl.inc include file to support more +# Pascal compilers. Initial support is now included +# for GnuPascal, VirtualPascal, TMT and obviously +# continue support for Delphi Kylix and FreePascal. +# +# April 08 2003 - MK : Aka Mr Kroket - Added Better FPC support +# +# April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added +# better TMT Pascal support and under instruction +# from Prof. Abimbola Olowofoyeku (The African Chief), +# I have added better Gnu Pascal support +# +# April 30 2003 - DL : under instruction from David Mears AKA +# Jason Siletto, I have added FPC Linux support. +# This was compiled with fpc 1.1, so remember to set +# include file path. ie. -Fi/usr/share/fpcsrc/rtl/* +# +# +# +# Revision 1.31 2007/05/29 21:30:48 savage +# Changes as suggested by Almindor for 64bit compatibility. +# +# Revision 1.30 2007/05/29 19:31:03 savage +# Fix to TSDL_Overlay structure - thanks David Pethes (aka imcold) +# +# Revision 1.29 2007/05/20 20:29:11 savage +# Initial Changes to Handle 64 Bits +# +# Revision 1.26 2007/02/11 13:38:04 savage +# Added Nintendo DS support - Thanks Dean. +# +# Revision 1.25 2006/12/02 00:12:52 savage +# Updated to latest version +# +# Revision 1.24 2006/05/18 21:10:04 savage +# Added 1.2.10 Changes +# +# Revision 1.23 2005/12/04 23:17:52 drellis +# Added declaration of SInt8 and PSInt8 +# +# Revision 1.22 2005/05/24 21:59:03 savage +# Re-arranged uses clause to work on Win32 and Linux, Thanks again Michalis. +# +# Revision 1.21 2005/05/22 18:42:31 savage +# Changes as suggested by Michalis Kamburelis. Thanks again. +# +# Revision 1.20 2005/04/10 11:48:33 savage +# Changes as suggested by Michalis, thanks. +# +# Revision 1.19 2005/01/05 01:47:06 savage +# Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively. +# +# Revision 1.18 2005/01/04 23:14:41 savage +# Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively. +# +# Revision 1.17 2005/01/03 18:40:59 savage +# Updated Version number to reflect latest one +# +# Revision 1.16 2005/01/01 02:02:06 savage +# Updated to v1.2.8 +# +# Revision 1.15 2004/12/24 18:57:11 savage +# forgot to apply Michalis Kamburelis' patch to the implementation section. now fixed +# +# Revision 1.14 2004/12/23 23:42:18 savage +# Applied Patches supplied by Michalis Kamburelis ( THANKS! ), for greater FreePascal compatability. +# +# Revision 1.13 2004/09/30 22:31:59 savage +# Updated with slightly different header comments +# +# Revision 1.12 2004/09/12 21:52:58 savage +# Slight changes to fix some issues with the sdl classes. +# +# Revision 1.11 2004/08/14 22:54:30 savage +# Updated so that Library name defines are correctly defined for MacOS X. +# +# Revision 1.10 2004/07/20 23:57:33 savage +# Thanks to Paul Toth for spotting an error in the SDL Audio Convertion structures. +# In TSDL_AudioCVT the filters variable should point to and array of pointers and not what I had there previously. +# +# Revision 1.9 2004/07/03 22:07:22 savage +# Added Bitwise Manipulation Functions for TSDL_VideoInfo struct. +# +# Revision 1.8 2004/05/10 14:10:03 savage +# Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ). +# +# Revision 1.7 2004/04/13 09:32:08 savage +# Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary. +# +# Revision 1.6 2004/04/01 20:53:23 savage +# Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site. +# +# Revision 1.5 2004/02/22 15:32:10 savage +# SDL_GetEnv Fix so it also works on FPC/Linux. Thanks to Rodrigo for pointing this out. +# +# Revision 1.4 2004/02/21 23:24:29 savage +# SDL_GetEnv Fix so that it is not define twice for FPC. Thanks to Rene Hugentobler for pointing out this bug, +# +# Revision 1.3 2004/02/18 22:35:51 savage +# Brought sdl.pas up to 1.2.7 compatability +# Thus... +# Added SDL_GL_STEREO, +# SDL_GL_MULTISAMPLEBUFFERS, +# SDL_GL_MULTISAMPLESAMPLES +# +# Add DLL/Shared object functions +# function SDL_LoadObject( const sofile : PChar ) : Pointer; +# +# function SDL_LoadFunction( handle : Pointer; const name : PChar ) : Pointer; +# +# procedure SDL_UnloadObject( handle : Pointer ); +# +# Added function to create RWops from const memory: SDL_RWFromConstMem() +# function SDL_RWFromConstMem(const mem: Pointer; size: Integer) : PSDL_RWops; +# +# Ported SDL_cpuinfo.h so Now you can test for Specific CPU types. +# +# Revision 1.2 2004/02/17 21:37:12 savage +# Tidying up of units +# +# Revision 1.1 2004/02/05 00:08:20 savage +# Module 1.0 release +# +# + +# +when defined(windows): + const SDLLibName = "SDL.dll" +elif defined(macosx): + const SDLLibName = "libSDL-1.2.0.dylib" +else: + const SDLLibName = "libSDL.so" + +const + SDL_MAJOR_VERSION* = 1'i8 + SDL_MINOR_VERSION* = 2'i8 + SDL_PATCHLEVEL* = 11'i8 # SDL.h constants + SDL_INIT_TIMER* = 0x00000001 + SDL_INIT_AUDIO* = 0x00000010 + SDL_INIT_VIDEO* = 0x00000020 + SDL_INIT_CDROM* = 0x00000100 + SDL_INIT_JOYSTICK* = 0x00000200 + SDL_INIT_NOPARACHUTE* = 0x00100000 # Don't catch fatal signals + SDL_INIT_EVENTTHREAD* = 0x01000000 # Not supported on all OS's + SDL_INIT_EVERYTHING* = 0x0000FFFF # SDL_error.h constants + ERR_MAX_STRLEN* = 128 + ERR_MAX_ARGS* = 5 # SDL_types.h constants + SDL_PRESSED* = 0x00000001 + SDL_RELEASED* = 0x00000000 # SDL_timer.h constants + # This is the OS scheduler timeslice, in milliseconds + SDL_TIMESLICE* = 10 # This is the maximum resolution of the SDL timer on all platforms + TIMER_RESOLUTION* = 10 # Experimentally determined + # SDL_audio.h constants + AUDIO_U8* = 0x00000008 # Unsigned 8-bit samples + AUDIO_S8* = 0x00008008 # Signed 8-bit samples + AUDIO_U16LSB* = 0x00000010 # Unsigned 16-bit samples + AUDIO_S16LSB* = 0x00008010 # Signed 16-bit samples + AUDIO_U16MSB* = 0x00001010 # As above, but big-endian byte order + AUDIO_S16MSB* = 0x00009010 # As above, but big-endian byte order + AUDIO_U16* = AUDIO_U16LSB + AUDIO_S16* = AUDIO_S16LSB # SDL_cdrom.h constants + # The maximum number of CD-ROM tracks on a disk + SDL_MAX_TRACKS* = 99 # The types of CD-ROM track possible + SDL_AUDIO_TRACK* = 0x00000000 + SDL_DATA_TRACK* = 0x00000004 # Conversion functions from frames to Minute/Second/Frames and vice versa + CD_FPS* = 75 # SDL_byteorder.h constants + # The two types of endianness + SDL_LIL_ENDIAN* = 1234 + SDL_BIG_ENDIAN* = 4321 + +when cpuEndian == littleEndian: + const + SDL_BYTEORDER* = SDL_LIL_ENDIAN # Native audio byte ordering + AUDIO_U16SYS* = AUDIO_U16LSB + AUDIO_S16SYS* = AUDIO_S16LSB +else: + const + SDL_BYTEORDER* = SDL_BIG_ENDIAN # Native audio byte ordering + AUDIO_U16SYS* = AUDIO_U16MSB + AUDIO_S16SYS* = AUDIO_S16MSB +const + SDL_MIX_MAXVOLUME* = 128 # SDL_joystick.h constants + MAX_JOYSTICKS* = 2 # only 2 are supported in the multimedia API + MAX_AXES* = 6 # each joystick can have up to 6 axes + MAX_BUTTONS* = 32 # and 32 buttons + AXIS_MIN* = - 32768 # minimum value for axis coordinate + AXIS_MAX* = 32767 # maximum value for axis coordinate + JOY_AXIS_THRESHOLD* = (toFloat((AXIS_MAX) - (AXIS_MIN)) / 100.0) # 1% motion + SDL_HAT_CENTERED* = 0x00000000 + SDL_HAT_UP* = 0x00000001 + SDL_HAT_RIGHT* = 0x00000002 + SDL_HAT_DOWN* = 0x00000004 + SDL_HAT_LEFT* = 0x00000008 + SDL_HAT_RIGHTUP* = SDL_HAT_RIGHT or SDL_HAT_UP + SDL_HAT_RIGHTDOWN* = SDL_HAT_RIGHT or SDL_HAT_DOWN + SDL_HAT_LEFTUP* = SDL_HAT_LEFT or SDL_HAT_UP + SDL_HAT_LEFTDOWN* = SDL_HAT_LEFT or SDL_HAT_DOWN # SDL_events.h constants + +type + TSDL_EventKind* = enum # kind of an SDL event + SDL_NOEVENT = 0, # Unused (do not remove) + SDL_ACTIVEEVENT = 1, # Application loses/gains visibility + SDL_KEYDOWN = 2, # Keys pressed + SDL_KEYUP = 3, # Keys released + SDL_MOUSEMOTION = 4, # Mouse moved + SDL_MOUSEBUTTONDOWN = 5, # Mouse button pressed + SDL_MOUSEBUTTONUP = 6, # Mouse button released + SDL_JOYAXISMOTION = 7, # Joystick axis motion + SDL_JOYBALLMOTION = 8, # Joystick trackball motion + SDL_JOYHATMOTION = 9, # Joystick hat position change + SDL_JOYBUTTONDOWN = 10, # Joystick button pressed + SDL_JOYBUTTONUP = 11, # Joystick button released + SDL_QUITEV = 12, # User-requested quit ( Changed due to procedure conflict ) + SDL_SYSWMEVENT = 13, # System specific event + SDL_EVENT_RESERVEDA = 14, # Reserved for future use.. + SDL_EVENT_RESERVED = 15, # Reserved for future use.. + SDL_VIDEORESIZE = 16, # User resized video mode + SDL_VIDEOEXPOSE = 17, # Screen needs to be redrawn + SDL_EVENT_RESERVED2 = 18, # Reserved for future use.. + SDL_EVENT_RESERVED3 = 19, # Reserved for future use.. + SDL_EVENT_RESERVED4 = 20, # Reserved for future use.. + SDL_EVENT_RESERVED5 = 21, # Reserved for future use.. + SDL_EVENT_RESERVED6 = 22, # Reserved for future use.. + SDL_EVENT_RESERVED7 = 23, # Reserved for future use.. + # Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use + SDL_USEREVENT = 24 # This last event is only for bounding internal arrays + # It is the number of bits in the event mask datatype -- UInt32 + +const + SDL_NUMEVENTS* = 32 + SDL_ALLEVENTS* = 0xFFFFFFFF + SDL_ACTIVEEVENTMASK* = 1 shl ord(SDL_ACTIVEEVENT) + SDL_KEYDOWNMASK* = 1 shl ord(SDL_KEYDOWN) + SDL_KEYUPMASK* = 1 shl ord(SDL_KEYUP) + SDL_MOUSEMOTIONMASK* = 1 shl ord(SDL_MOUSEMOTION) + SDL_MOUSEBUTTONDOWNMASK* = 1 shl ord(SDL_MOUSEBUTTONDOWN) + SDL_MOUSEBUTTONUPMASK* = 1 shl ord(SDL_MOUSEBUTTONUP) + SDL_MOUSEEVENTMASK* = 1 shl ord(SDL_MOUSEMOTION) or 1 shl ord(SDL_MOUSEBUTTONDOWN) or + 1 shl ord(SDL_MOUSEBUTTONUP) + SDL_JOYAXISMOTIONMASK* = 1 shl ord(SDL_JOYAXISMOTION) + SDL_JOYBALLMOTIONMASK* = 1 shl ord(SDL_JOYBALLMOTION) + SDL_JOYHATMOTIONMASK* = 1 shl ord(SDL_JOYHATMOTION) + SDL_JOYBUTTONDOWNMASK* = 1 shl ord(SDL_JOYBUTTONDOWN) + SDL_JOYBUTTONUPMASK* = 1 shl ord(SDL_JOYBUTTONUP) + SDL_JOYEVENTMASK* = 1 shl ord(SDL_JOYAXISMOTION) or 1 shl ord(SDL_JOYBALLMOTION) or + 1 shl ord(SDL_JOYHATMOTION) or 1 shl ord(SDL_JOYBUTTONDOWN) or + 1 shl ord(SDL_JOYBUTTONUP) + SDL_VIDEORESIZEMASK* = 1 shl ord(SDL_VIDEORESIZE) + SDL_QUITMASK* = 1 shl ord(SDL_QUITEV) + SDL_SYSWMEVENTMASK* = 1 shl ord(SDL_SYSWMEVENT) + SDL_QUERY* = - 1 + SDL_IGNORE* = 0 + SDL_DISABLE* = 0 + SDL_ENABLE* = 1 #SDL_keyboard.h constants + # This is the mask which refers to all hotkey bindings + SDL_ALL_HOTKEYS* = 0xFFFFFFFF # Enable/Disable keyboard repeat. Keyboard repeat defaults to off. + # 'delay' is the initial delay in ms between the time when a key is + # pressed, and keyboard repeat begins. + # 'interval' is the time in ms between keyboard repeat events. + SDL_DEFAULT_REPEAT_DELAY* = 500 + SDL_DEFAULT_REPEAT_INTERVAL* = 30 # The keyboard syms have been cleverly chosen to map to ASCII + SDLK_UNKNOWN* = 0 + SDLK_FIRST* = 0 + SDLK_BACKSPACE* = 8 + SDLK_TAB* = 9 + SDLK_CLEAR* = 12 + SDLK_RETURN* = 13 + SDLK_PAUSE* = 19 + SDLK_ESCAPE* = 27 + SDLK_SPACE* = 32 + SDLK_EXCLAIM* = 33 + SDLK_QUOTEDBL* = 34 + SDLK_HASH* = 35 + SDLK_DOLLAR* = 36 + SDLK_AMPERSAND* = 38 + SDLK_QUOTE* = 39 + SDLK_LEFTPAREN* = 40 + SDLK_RIGHTPAREN* = 41 + SDLK_ASTERISK* = 42 + SDLK_PLUS* = 43 + SDLK_COMMA* = 44 + SDLK_MINUS* = 45 + SDLK_PERIOD* = 46 + SDLK_SLASH* = 47 + SDLK_0* = 48 + SDLK_1* = 49 + SDLK_2* = 50 + SDLK_3* = 51 + SDLK_4* = 52 + SDLK_5* = 53 + SDLK_6* = 54 + SDLK_7* = 55 + SDLK_8* = 56 + SDLK_9* = 57 + SDLK_COLON* = 58 + SDLK_SEMICOLON* = 59 + SDLK_LESS* = 60 + SDLK_EQUALS* = 61 + SDLK_GREATER* = 62 + SDLK_QUESTION* = 63 + SDLK_AT* = 64 # Skip uppercase letters + SDLK_LEFTBRACKET* = 91 + SDLK_BACKSLASH* = 92 + SDLK_RIGHTBRACKET* = 93 + SDLK_CARET* = 94 + SDLK_UNDERSCORE* = 95 + SDLK_BACKQUOTE* = 96 + SDLK_a* = 97 + SDLK_b* = 98 + SDLK_c* = 99 + SDLK_d* = 100 + SDLK_e* = 101 + SDLK_f* = 102 + SDLK_g* = 103 + SDLK_h* = 104 + SDLK_i* = 105 + SDLK_j* = 106 + SDLK_k* = 107 + SDLK_l* = 108 + SDLK_m* = 109 + SDLK_n* = 110 + SDLK_o* = 111 + SDLK_p* = 112 + SDLK_q* = 113 + SDLK_r* = 114 + SDLK_s* = 115 + SDLK_t* = 116 + SDLK_u* = 117 + SDLK_v* = 118 + SDLK_w* = 119 + SDLK_x* = 120 + SDLK_y* = 121 + SDLK_z* = 122 + SDLK_DELETE* = 127 # End of ASCII mapped keysyms + # International keyboard syms + SDLK_WORLD_0* = 160 # 0xA0 + SDLK_WORLD_1* = 161 + SDLK_WORLD_2* = 162 + SDLK_WORLD_3* = 163 + SDLK_WORLD_4* = 164 + SDLK_WORLD_5* = 165 + SDLK_WORLD_6* = 166 + SDLK_WORLD_7* = 167 + SDLK_WORLD_8* = 168 + SDLK_WORLD_9* = 169 + SDLK_WORLD_10* = 170 + SDLK_WORLD_11* = 171 + SDLK_WORLD_12* = 172 + SDLK_WORLD_13* = 173 + SDLK_WORLD_14* = 174 + SDLK_WORLD_15* = 175 + SDLK_WORLD_16* = 176 + SDLK_WORLD_17* = 177 + SDLK_WORLD_18* = 178 + SDLK_WORLD_19* = 179 + SDLK_WORLD_20* = 180 + SDLK_WORLD_21* = 181 + SDLK_WORLD_22* = 182 + SDLK_WORLD_23* = 183 + SDLK_WORLD_24* = 184 + SDLK_WORLD_25* = 185 + SDLK_WORLD_26* = 186 + SDLK_WORLD_27* = 187 + SDLK_WORLD_28* = 188 + SDLK_WORLD_29* = 189 + SDLK_WORLD_30* = 190 + SDLK_WORLD_31* = 191 + SDLK_WORLD_32* = 192 + SDLK_WORLD_33* = 193 + SDLK_WORLD_34* = 194 + SDLK_WORLD_35* = 195 + SDLK_WORLD_36* = 196 + SDLK_WORLD_37* = 197 + SDLK_WORLD_38* = 198 + SDLK_WORLD_39* = 199 + SDLK_WORLD_40* = 200 + SDLK_WORLD_41* = 201 + SDLK_WORLD_42* = 202 + SDLK_WORLD_43* = 203 + SDLK_WORLD_44* = 204 + SDLK_WORLD_45* = 205 + SDLK_WORLD_46* = 206 + SDLK_WORLD_47* = 207 + SDLK_WORLD_48* = 208 + SDLK_WORLD_49* = 209 + SDLK_WORLD_50* = 210 + SDLK_WORLD_51* = 211 + SDLK_WORLD_52* = 212 + SDLK_WORLD_53* = 213 + SDLK_WORLD_54* = 214 + SDLK_WORLD_55* = 215 + SDLK_WORLD_56* = 216 + SDLK_WORLD_57* = 217 + SDLK_WORLD_58* = 218 + SDLK_WORLD_59* = 219 + SDLK_WORLD_60* = 220 + SDLK_WORLD_61* = 221 + SDLK_WORLD_62* = 222 + SDLK_WORLD_63* = 223 + SDLK_WORLD_64* = 224 + SDLK_WORLD_65* = 225 + SDLK_WORLD_66* = 226 + SDLK_WORLD_67* = 227 + SDLK_WORLD_68* = 228 + SDLK_WORLD_69* = 229 + SDLK_WORLD_70* = 230 + SDLK_WORLD_71* = 231 + SDLK_WORLD_72* = 232 + SDLK_WORLD_73* = 233 + SDLK_WORLD_74* = 234 + SDLK_WORLD_75* = 235 + SDLK_WORLD_76* = 236 + SDLK_WORLD_77* = 237 + SDLK_WORLD_78* = 238 + SDLK_WORLD_79* = 239 + SDLK_WORLD_80* = 240 + SDLK_WORLD_81* = 241 + SDLK_WORLD_82* = 242 + SDLK_WORLD_83* = 243 + SDLK_WORLD_84* = 244 + SDLK_WORLD_85* = 245 + SDLK_WORLD_86* = 246 + SDLK_WORLD_87* = 247 + SDLK_WORLD_88* = 248 + SDLK_WORLD_89* = 249 + SDLK_WORLD_90* = 250 + SDLK_WORLD_91* = 251 + SDLK_WORLD_92* = 252 + SDLK_WORLD_93* = 253 + SDLK_WORLD_94* = 254 + SDLK_WORLD_95* = 255 # 0xFF + # Numeric keypad + SDLK_KP0* = 256 + SDLK_KP1* = 257 + SDLK_KP2* = 258 + SDLK_KP3* = 259 + SDLK_KP4* = 260 + SDLK_KP5* = 261 + SDLK_KP6* = 262 + SDLK_KP7* = 263 + SDLK_KP8* = 264 + SDLK_KP9* = 265 + SDLK_KP_PERIOD* = 266 + SDLK_KP_DIVIDE* = 267 + SDLK_KP_MULTIPLY* = 268 + SDLK_KP_MINUS* = 269 + SDLK_KP_PLUS* = 270 + SDLK_KP_ENTER* = 271 + SDLK_KP_EQUALS* = 272 # Arrows + Home/End pad + SDLK_UP* = 273 + SDLK_DOWN* = 274 + SDLK_RIGHT* = 275 + SDLK_LEFT* = 276 + SDLK_INSERT* = 277 + SDLK_HOME* = 278 + SDLK_END* = 279 + SDLK_PAGEUP* = 280 + SDLK_PAGEDOWN* = 281 # Function keys + SDLK_F1* = 282 + SDLK_F2* = 283 + SDLK_F3* = 284 + SDLK_F4* = 285 + SDLK_F5* = 286 + SDLK_F6* = 287 + SDLK_F7* = 288 + SDLK_F8* = 289 + SDLK_F9* = 290 + SDLK_F10* = 291 + SDLK_F11* = 292 + SDLK_F12* = 293 + SDLK_F13* = 294 + SDLK_F14* = 295 + SDLK_F15* = 296 # Key state modifier keys + SDLK_NUMLOCK* = 300 + SDLK_CAPSLOCK* = 301 + SDLK_SCROLLOCK* = 302 + SDLK_RSHIFT* = 303 + SDLK_LSHIFT* = 304 + SDLK_RCTRL* = 305 + SDLK_LCTRL* = 306 + SDLK_RALT* = 307 + SDLK_LALT* = 308 + SDLK_RMETA* = 309 + SDLK_LMETA* = 310 + SDLK_LSUPER* = 311 # Left "Windows" key + SDLK_RSUPER* = 312 # Right "Windows" key + SDLK_MODE* = 313 # "Alt Gr" key + SDLK_COMPOSE* = 314 # Multi-key compose key + # Miscellaneous function keys + SDLK_HELP* = 315 + SDLK_PRINT* = 316 + SDLK_SYSREQ* = 317 + SDLK_BREAK* = 318 + SDLK_MENU* = 319 + SDLK_POWER* = 320 # Power Macintosh power key + SDLK_EURO* = 321 # Some european keyboards + SDLK_GP2X_UP* = 0 + SDLK_GP2X_UPLEFT* = 1 + SDLK_GP2X_LEFT* = 2 + SDLK_GP2X_DOWNLEFT* = 3 + SDLK_GP2X_DOWN* = 4 + SDLK_GP2X_DOWNRIGHT* = 5 + SDLK_GP2X_RIGHT* = 6 + SDLK_GP2X_UPRIGHT* = 7 + SDLK_GP2X_START* = 8 + SDLK_GP2X_SELECT* = 9 + SDLK_GP2X_L* = 10 + SDLK_GP2X_R* = 11 + SDLK_GP2X_A* = 12 + SDLK_GP2X_B* = 13 + SDLK_GP2X_Y* = 14 + SDLK_GP2X_X* = 15 + SDLK_GP2X_VOLUP* = 16 + SDLK_GP2X_VOLDOWN* = 17 + SDLK_GP2X_CLICK* = 18 + +const # Enumeration of valid key mods (possibly OR'd together) + KMOD_NONE* = 0x00000000 + KMOD_LSHIFT* = 0x00000001 + KMOD_RSHIFT* = 0x00000002 + KMOD_LCTRL* = 0x00000040 + KMOD_RCTRL* = 0x00000080 + KMOD_LALT* = 0x00000100 + KMOD_RALT* = 0x00000200 + KMOD_LMETA* = 0x00000400 + KMOD_RMETA* = 0x00000800 + KMOD_NUM* = 0x00001000 + KMOD_CAPS* = 0x00002000 + KMOD_MODE* = 44000 + KMOD_RESERVED* = 0x00008000 + KMOD_CTRL* = (KMOD_LCTRL or KMOD_RCTRL) + KMOD_SHIFT* = (KMOD_LSHIFT or KMOD_RSHIFT) + KMOD_ALT* = (KMOD_LALT or KMOD_RALT) + KMOD_META* = (KMOD_LMETA or KMOD_RMETA) #SDL_video.h constants + # Transparency definitions: These define alpha as the opacity of a surface */ + SDL_ALPHA_OPAQUE* = 255 + SDL_ALPHA_TRANSPARENT* = 0 # These are the currently supported flags for the SDL_surface + # Available for SDL_CreateRGBSurface() or SDL_SetVideoMode() + SDL_SWSURFACE* = 0x00000000 # Surface is in system memory + SDL_HWSURFACE* = 0x00000001 # Surface is in video memory + SDL_ASYNCBLIT* = 0x00000004 # Use asynchronous blits if possible + # Available for SDL_SetVideoMode() + SDL_ANYFORMAT* = 0x10000000 # Allow any video depth/pixel-format + SDL_HWPALETTE* = 0x20000000 # Surface has exclusive palette + SDL_DOUBLEBUF* = 0x40000000 # Set up double-buffered video mode + SDL_FULLSCREEN* = 0x80000000 # Surface is a full screen display + SDL_OPENGL* = 0x00000002 # Create an OpenGL rendering context + SDL_OPENGLBLIT* = 0x00000002 # Create an OpenGL rendering context + SDL_RESIZABLE* = 0x00000010 # This video mode may be resized + SDL_NOFRAME* = 0x00000020 # No window caption or edge frame + # Used internally (read-only) + SDL_HWACCEL* = 0x00000100 # Blit uses hardware acceleration + SDL_SRCCOLORKEY* = 0x00001000 # Blit uses a source color key + SDL_RLEACCELOK* = 0x00002000 # Private flag + SDL_RLEACCEL* = 0x00004000 # Colorkey blit is RLE accelerated + SDL_SRCALPHA* = 0x00010000 # Blit uses source alpha blending + SDL_SRCCLIPPING* = 0x00100000 # Blit uses source clipping + SDL_PREALLOC* = 0x01000000 # Surface uses preallocated memory + # The most common video overlay formats. + # For an explanation of these pixel formats, see: + # http://www.webartz.com/fourcc/indexyuv.htm + # + # For information on the relationship between color spaces, see: + # + # http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html + SDL_YV12_OVERLAY* = 0x32315659 # Planar mode: Y + V + U (3 planes) + SDL_IYUV_OVERLAY* = 0x56555949 # Planar mode: Y + U + V (3 planes) + SDL_YUY2_OVERLAY* = 0x32595559 # Packed mode: Y0+U0+Y1+V0 (1 plane) + SDL_UYVY_OVERLAY* = 0x59565955 # Packed mode: U0+Y0+V0+Y1 (1 plane) + SDL_YVYU_OVERLAY* = 0x55595659 # Packed mode: Y0+V0+Y1+U0 (1 plane) + # flags for SDL_SetPalette() + SDL_LOGPAL* = 0x00000001 + SDL_PHYSPAL* = 0x00000002 #SDL_mouse.h constants + # Used as a mask when testing buttons in buttonstate + # Button 1: Left mouse button + # Button 2: Middle mouse button + # Button 3: Right mouse button + # Button 4: Mouse Wheel Up + # Button 5: Mouse Wheel Down + # + SDL_BUTTON_LEFT* = 1 + SDL_BUTTON_MIDDLE* = 2 + SDL_BUTTON_RIGHT* = 3 + SDL_BUTTON_WHEELUP* = 4 + SDL_BUTTON_WHEELDOWN* = 5 + SDL_BUTTON_LMASK* = SDL_PRESSED shl (SDL_BUTTON_LEFT - 1) + SDL_BUTTON_MMASK* = SDL_PRESSED shl (SDL_BUTTON_MIDDLE - 1) + SDL_BUTTON_RMask* = SDL_PRESSED shl (SDL_BUTTON_RIGHT - 1) # SDL_active.h constants + # The available application states + SDL_APPMOUSEFOCUS* = 0x00000001 # The app has mouse coverage + SDL_APPINPUTFOCUS* = 0x00000002 # The app has input focus + SDL_APPACTIVE* = 0x00000004 # The application is active + # SDL_mutex.h constants + # Synchronization functions which can time out return this value + # they time out. + SDL_MUTEX_TIMEDOUT* = 1 # This is the timeout value which corresponds to never time out + SDL_MUTEX_MAXWAIT* = not int(0) + SDL_GRAB_QUERY* = - 1 + SDL_GRAB_OFF* = 0 + SDL_GRAB_ON* = 1 #SDL_GRAB_FULLSCREEN // Used internally + +type + THandle* = int #SDL_types.h types + # Basic data types + TSDL_Bool* = enum + SDL_FALSE, SDL_TRUE + PUInt8Array* = ptr TUInt8Array + PUInt8* = ptr UInt8 + PPUInt8* = ptr PUInt8 + UInt8* = int8 + TUInt8Array* = array[0..high(int) shr 1, UInt8] + PUInt16* = ptr UInt16 + UInt16* = int16 + PSInt8* = ptr SInt8 + SInt8* = int8 + PSInt16* = ptr SInt16 + SInt16* = int16 + PUInt32* = ptr UInt32 + UInt32* = int + SInt32* = int + PInt* = ptr int + PShortInt* = ptr int8 + PUInt64* = ptr UInt64 + UInt64*{.final.} = object + hi*: UInt32 + lo*: UInt32 + + PSInt64* = ptr SInt64 + SInt64*{.final.} = object + hi*: UInt32 + lo*: UInt32 + + TSDL_GrabMode* = int # SDL_error.h types + TSDL_errorcode* = enum + SDL_ENOMEM, SDL_EFREAD, SDL_EFWRITE, SDL_EFSEEK, SDL_LASTERROR + SDL_errorcode* = TSDL_errorcode + TArg*{.final.} = object + buf*: array[0..ERR_MAX_STRLEN - 1, int8] + + PSDL_error* = ptr TSDL_error + TSDL_error*{.final.} = object # This is a numeric value corresponding to the current error + # SDL_rwops.h types + # This is the read/write operation structure -- very basic + # some helper types to handle the unions + # "packed" is only guessed + error*: int # This is a key used to index into a language hashtable containing + # internationalized versions of the SDL error messages. If the key + # is not in the hashtable, or no hashtable is available, the key is + # used directly as an error message format string. + key*: array[0..ERR_MAX_STRLEN - 1, int8] # These are the arguments for the error functions + argc*: int + args*: array[0..ERR_MAX_ARGS - 1, TArg] + + TStdio*{.final.} = object + autoclose*: int # FILE * is only defined in Kylix so we use a simple Pointer + fp*: Pointer + + TMem*{.final.} = object + base*: PUInt8 + here*: PUInt8 + stop*: PUInt8 + + TUnknown*{.final.} = object # first declare the pointer type + data1*: Pointer + + PSDL_RWops* = ptr TSDL_RWops # now the pointer to function types + TSeek* = proc (context: PSDL_RWops, offset: int, whence: int): int{.cdecl.} + TRead* = proc (context: PSDL_RWops, thePtr: Pointer, size: int, maxnum: int): int{. + cdecl.} + TWrite* = proc (context: PSDL_RWops, thePtr: Pointer, size: int, num: int): int{. + cdecl.} + TClose* = proc (context: PSDL_RWops): int{.cdecl.} # the variant record itself + trange010 = range[0..2] + TSDL_RWops*{.final.} = object + seek*: TSeek + read*: TRead + write*: TWrite + closeFile*: TClose # a keyword as name is not allowed + # be warned! structure alignment may arise at this point + case theType*: trange010 + of trange010(0): + stdio*: TStdio + of trange010(1): + mem*: TMem + of trange010(2): + unknown*: TUnknown + + + SDL_RWops* = TSDL_RWops # SDL_timer.h types + # Function prototype for the timer callback function + TSDL_TimerCallback* = proc (interval: UInt32): UInt32{.cdecl.} # New timer API, supports multiple timers + # Written by Stephane Peter + # <megastep@lokigames.com> + # Function prototype for the new timer callback function. + # The callback function is passed the current timer interval and returns + # the next timer interval. If the returned value is the same as the one + # passed in, the periodic alarm continues, otherwise a new alarm is + # scheduled. If the callback returns 0, the periodic alarm is cancelled. + TSDL_NewTimerCallback* = proc (interval: UInt32, param: Pointer): UInt32{. + cdecl.} # Definition of the timer ID type + PSDL_TimerID* = ptr TSDL_TimerID + TSDL_TimerID*{.final.} = object + interval*: UInt32 + callback*: TSDL_NewTimerCallback + param*: Pointer + last_alarm*: UInt32 + next*: PSDL_TimerID + + TSDL_AudioSpecCallback* = proc (userdata: Pointer, stream: PUInt8, length: int){. + cdecl.} # SDL_audio.h types + # The calculated values in this structure are calculated by SDL_OpenAudio() + PSDL_AudioSpec* = ptr TSDL_AudioSpec + TSDL_AudioSpec*{.final.} = object # A structure to hold a set of audio conversion filters and buffers + freq*: int # DSP frequency -- samples per second + format*: UInt16 # Audio data format + channels*: UInt8 # Number of channels: 1 mono, 2 stereo + silence*: UInt8 # Audio buffer silence value (calculated) + samples*: UInt16 # Audio buffer size in samples + padding*: UInt16 # Necessary for some compile environments + size*: UInt32 # Audio buffer size in bytes (calculated) + # This function is called when the audio device needs more data. + # 'stream' is a pointer to the audio data buffer + # 'len' is the length of that buffer in bytes. + # Once the callback returns, the buffer will no longer be valid. + # Stereo samples are stored in a LRLRLR ordering. + callback*: TSDL_AudioSpecCallback + userdata*: Pointer + + PSDL_AudioCVT* = ptr TSDL_AudioCVT + PSDL_AudioCVTFilter* = ptr TSDL_AudioCVTFilter + TSDL_AudioCVTFilter*{.final.} = object + cvt*: PSDL_AudioCVT + format*: UInt16 + + PSDL_AudioCVTFilterArray* = ptr TSDL_AudioCVTFilterArray + TSDL_AudioCVTFilterArray* = array[0..9, PSDL_AudioCVTFilter] + TSDL_AudioCVT*{.final.} = object + needed*: int # Set to 1 if conversion possible + src_format*: UInt16 # Source audio format + dst_format*: UInt16 # Target audio format + rate_incr*: float64 # Rate conversion increment + buf*: PUInt8 # Buffer to hold entire audio data + length*: int # Length of original audio buffer + len_cvt*: int # Length of converted audio buffer + len_mult*: int # buffer must be len*len_mult big + len_ratio*: float64 # Given len, final size is len*len_ratio + filters*: TSDL_AudioCVTFilterArray + filter_index*: int # Current audio conversion function + + TSDL_Audiostatus* = enum # SDL_cdrom.h types + SDL_AUDIO_STOPPED, SDL_AUDIO_PLAYING, SDL_AUDIO_PAUSED + TSDL_CDStatus* = enum + CD_ERROR, CD_TRAYEMPTY, CD_STOPPED, CD_PLAYING, CD_PAUSED + PSDL_CDTrack* = ptr TSDL_CDTrack + TSDL_CDTrack*{.final.} = object # This structure is only current as of the last call to SDL_CDStatus() + id*: UInt8 # Track number + theType*: UInt8 # Data or audio track + unused*: UInt16 + len*: UInt32 # Length, in frames, of this track + offset*: UInt32 # Offset, in frames, from start of disk + + PSDL_CD* = ptr TSDL_CD + TSDL_CD*{.final.} = object #SDL_joystick.h types + id*: int # Private drive identifier + status*: TSDL_CDStatus # Current drive status + # The rest of this structure is only valid if there's a CD in drive + numtracks*: int # Number of tracks on disk + cur_track*: int # Current track position + cur_frame*: int # Current frame offset within current track + track*: array[0..SDL_MAX_TRACKS, TSDL_CDTrack] + + PTransAxis* = ptr TTransAxis + TTransAxis*{.final.} = object # The private structure used to keep track of a joystick + offset*: int + scale*: float32 + + PJoystick_hwdata* = ptr TJoystick_hwdata + TJoystick_hwdata*{.final.} = object # joystick ID + id*: int # values used to translate device-specific coordinates into SDL-standard ranges + transaxis*: array[0..5, TTransAxis] + + PBallDelta* = ptr TBallDelta + TBallDelta*{.final.} = object # Current ball motion deltas + # The SDL joystick structure + dx*: int + dy*: int + + PSDL_Joystick* = ptr TSDL_Joystick + TSDL_Joystick*{.final.} = object # SDL_verion.h types + index*: UInt8 # Device index + name*: cstring # Joystick name - system dependent + naxes*: int # Number of axis controls on the joystick + axes*: PUInt16 # Current axis states + nhats*: int # Number of hats on the joystick + hats*: PUInt8 # Current hat states + nballs*: int # Number of trackballs on the joystick + balls*: PBallDelta # Current ball motion deltas + nbuttons*: int # Number of buttons on the joystick + buttons*: PUInt8 # Current button states + hwdata*: PJoystick_hwdata # Driver dependent information + ref_count*: int # Reference count for multiple opens + + PSDL_version* = ptr TSDL_version + TSDL_version*{.final.} = object # SDL_keyboard.h types + major*: UInt8 + minor*: UInt8 + patch*: UInt8 + + TSDLKey* = int32 + TSDLMod* = int32 + PSDL_KeySym* = ptr TSDL_KeySym + TSDL_KeySym*{.final.} = object # SDL_events.h types + #Checks the event queue for messages and optionally returns them. + # If 'action' is SDL_ADDEVENT, up to 'numevents' events will be added to + # the back of the event queue. + # If 'action' is SDL_PEEKEVENT, up to 'numevents' events at the front + # of the event queue, matching 'mask', will be returned and will not + # be removed from the queue. + # If 'action' is SDL_GETEVENT, up to 'numevents' events at the front + # of the event queue, matching 'mask', will be returned and will be + # removed from the queue. + # This function returns the number of events actually stored, or -1 + # if there was an error. This function is thread-safe. + scancode*: UInt8 # hardware specific scancode + sym*: TSDLKey # SDL virtual keysym + modifier*: TSDLMod # current key modifiers + unicode*: UInt16 # translated character + + TSDL_EventAction* = enum # Application visibility event structure + SDL_ADDEVENT, SDL_PEEKEVENT, SDL_GETEVENT + TSDL_ActiveEvent*{.final.} = object # SDL_ACTIVEEVENT + # Keyboard event structure + gain*: UInt8 # Whether given states were gained or lost (1/0) + state*: UInt8 # A mask of the focus states + + TSDL_KeyboardEvent*{.final.} = object # SDL_KEYDOWN or SDL_KEYUP + # Mouse motion event structure + which*: UInt8 # The keyboard device index + state*: UInt8 # SDL_PRESSED or SDL_RELEASED + keysym*: TSDL_KeySym + + TSDL_MouseMotionEvent*{.final.} = object # SDL_MOUSEMOTION + # Mouse button event structure + which*: UInt8 # The mouse device index + state*: UInt8 # The current button state + x*, y*: UInt16 # The X/Y coordinates of the mouse + xrel*: SInt16 # The relative motion in the X direction + yrel*: SInt16 # The relative motion in the Y direction + + TSDL_MouseButtonEvent*{.final.} = object # SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP + # Joystick axis motion event structure + which*: UInt8 # The mouse device index + button*: UInt8 # The mouse button index + state*: UInt8 # SDL_PRESSED or SDL_RELEASED + x*: UInt16 # The X coordinates of the mouse at press time + y*: UInt16 # The Y coordinates of the mouse at press time + + TSDL_JoyAxisEvent*{.final.} = object # SDL_JOYAXISMOTION + # Joystick trackball motion event structure + which*: UInt8 # The joystick device index + axis*: UInt8 # The joystick axis index + value*: SInt16 # The axis value (range: -32768 to 32767) + + TSDL_JoyBallEvent*{.final.} = object # SDL_JOYAVBALLMOTION + # Joystick hat position change event structure + which*: UInt8 # The joystick device index + ball*: UInt8 # The joystick trackball index + xrel*: SInt16 # The relative motion in the X direction + yrel*: SInt16 # The relative motion in the Y direction + + TSDL_JoyHatEvent*{.final.} = object # SDL_JOYHATMOTION */ + # Joystick button event structure + which*: UInt8 # The joystick device index */ + hat*: UInt8 # The joystick hat index */ + value*: UInt8 # The hat position value: + # 8 1 2 + # 7 0 3 + # 6 5 4 + # Note that zero means the POV is centered. + + TSDL_JoyButtonEvent*{.final.} = object # SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP + # The "window resized" event + # When you get this event, you are responsible for setting a new video + # mode with the new width and height. + which*: UInt8 # The joystick device index + button*: UInt8 # The joystick button index + state*: UInt8 # SDL_PRESSED or SDL_RELEASED + + TSDL_ResizeEvent*{.final.} = object # SDL_VIDEORESIZE + # A user-defined event type + w*: int # New width + h*: int # New height + + PSDL_UserEvent* = ptr TSDL_UserEvent + TSDL_UserEvent*{.final.} = object # SDL_USEREVENT through SDL_NUMEVENTS-1 + code*: int # User defined event code */ + data1*: Pointer # User defined data pointer */ + data2*: Pointer # User defined data pointer */ + + +when defined(Unix): + type #These are the various supported subsystems under UNIX + TSDL_SysWm* = enum + SDL_SYSWM_X11 +# The windows custom event structure + +when defined(WINDOWS): + type + PSDL_SysWMmsg* = ptr TSDL_SysWMmsg + TSDL_SysWMmsg*{.final.} = object + version*: TSDL_version + hwnd*: THandle # The window for the message + msg*: int # The type of message + w_Param*: int32 # WORD message parameter + lParam*: int32 # LONG message parameter + +elif defined(Unix): + type # The Linux custom event structure + PSDL_SysWMmsg* = ptr TSDL_SysWMmsg + TSDL_SysWMmsg*{.final.} = object + version*: TSDL_version + subsystem*: TSDL_SysWm + when false: + event*: TXEvent +else: + type # The generic custom event structure + PSDL_SysWMmsg* = ptr TSDL_SysWMmsg + TSDL_SysWMmsg*{.final.} = object + version*: TSDL_version + data*: int + +# The Windows custom window manager information structure + +when defined(WINDOWS): + type + PSDL_SysWMinfo* = ptr TSDL_SysWMinfo + TSDL_SysWMinfo*{.final.} = object + version*: TSDL_version + window*: THandle # The display window + +elif defined(Unix): + type + TX11*{.final.} = object + when false: + display*: PDisplay # The X11 display + window*: TWindow # The X11 display window + # These locking functions should be called around + # any X11 functions using the display variable. + # They lock the event thread, so should not be + # called around event functions or from event filters. + lock_func*: Pointer + unlock_func*: Pointer # Introduced in SDL 1.0.2 + fswindow*: TWindow # The X11 fullscreen window + wmwindow*: TWindow # The X11 managed input window + + type + PSDL_SysWMinfo* = ptr TSDL_SysWMinfo + TSDL_SysWMinfo*{.final.} = object + version*: TSDL_version + subsystem*: TSDL_SysWm + X11*: TX11 +else: + type # The generic custom window manager information structure + PSDL_SysWMinfo* = ptr TSDL_SysWMinfo + TSDL_SysWMinfo*{.final.} = object + version*: TSDL_version + data*: int + +type + PSDL_SysWMEvent* = ptr TSDL_SysWMEvent + TSDL_SysWMEvent*{.final.} = object + msg*: PSDL_SysWMmsg + + PSDL_Event* = ptr TSDL_Event + TSDL_Event*{.final.} = object # This function sets up a filter to process all events before they + # change internal state and are posted to the internal event queue. + # + # The filter is protypted as: + case theType*: TSDL_EventKind # SDL_NOEVENT, SDL_QUITEV: (); + of SDL_ACTIVEEVENT: + active*: TSDL_ActiveEvent + of SDL_KEYDOWN, SDL_KEYUP: + key*: TSDL_KeyboardEvent + of SDL_MOUSEMOTION: + motion*: TSDL_MouseMotionEvent + of SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP: + button*: TSDL_MouseButtonEvent + of SDL_JOYAXISMOTION: + jaxis*: TSDL_JoyAxisEvent + of SDL_JOYBALLMOTION: + jball*: TSDL_JoyBallEvent + of SDL_JOYHATMOTION: + jhat*: TSDL_JoyHatEvent + of SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP: + jbutton*: TSDL_JoyButtonEvent + of SDL_VIDEORESIZE: + resize*: TSDL_ResizeEvent + of SDL_USEREVENT: + user*: TSDL_UserEvent + of SDL_SYSWMEVENT: + syswm*: TSDL_SysWMEvent + else: + nil + + TSDL_EventFilter* = proc (event: PSDL_Event): int{.cdecl.} # SDL_video.h types + # Useful data types + PPSDL_Rect* = ptr PSDL_Rect + PSDL_Rect* = ptr TSDL_Rect + TSDL_Rect*{.final.} = object + x*, y*: SInt16 + w*, h*: UInt16 + + SDL_Rect* = TSDL_Rect + PSDL_Color* = ptr TSDL_Color + TSDL_Color*{.final.} = object + r*: UInt8 + g*: UInt8 + b*: UInt8 + unused*: UInt8 + + PSDL_ColorArray* = ptr TSDL_ColorArray + TSDL_ColorArray* = array[0..65000, TSDL_Color] + PSDL_Palette* = ptr TSDL_Palette + TSDL_Palette*{.final.} = object # Everything in the pixel format structure is read-only + ncolors*: int + colors*: PSDL_ColorArray + + PSDL_PixelFormat* = ptr TSDL_PixelFormat + TSDL_PixelFormat*{.final.} = object # The structure passed to the low level blit functions + palette*: PSDL_Palette + BitsPerPixel*: UInt8 + BytesPerPixel*: UInt8 + Rloss*: UInt8 + Gloss*: UInt8 + Bloss*: UInt8 + Aloss*: UInt8 + Rshift*: UInt8 + Gshift*: UInt8 + Bshift*: UInt8 + Ashift*: UInt8 + RMask*: UInt32 + GMask*: UInt32 + BMask*: UInt32 + AMask*: UInt32 + colorkey*: UInt32 # RGB color key information + alpha*: UInt8 # Alpha value information (per-surface alpha) + + PSDL_BlitInfo* = ptr TSDL_BlitInfo + TSDL_BlitInfo*{.final.} = object # typedef for private surface blitting functions + s_pixels*: PUInt8 + s_width*: int + s_height*: int + s_skip*: int + d_pixels*: PUInt8 + d_width*: int + d_height*: int + d_skip*: int + aux_data*: Pointer + src*: PSDL_PixelFormat + table*: PUInt8 + dst*: PSDL_PixelFormat + + PSDL_Surface* = ptr TSDL_Surface + TSDL_Blit* = proc (src: PSDL_Surface, srcrect: PSDL_Rect, dst: PSDL_Surface, + dstrect: PSDL_Rect): int{.cdecl.} + TSDL_Surface*{.final.} = object # Useful for determining the video hardware capabilities + flags*: UInt32 # Read-only + format*: PSDL_PixelFormat # Read-only + w*, h*: int # Read-only + pitch*: UInt16 # Read-only + pixels*: Pointer # Read-write + offset*: int # Private + hwdata*: Pointer #TPrivate_hwdata; Hardware-specific surface info + # clipping information: + clip_rect*: TSDL_Rect # Read-only + unused1*: UInt32 # for binary compatibility + # Allow recursive locks + locked*: UInt32 # Private + # info for fast blit mapping to other surfaces + Blitmap*: Pointer # PSDL_BlitMap; // Private + # format version, bumped at every change to invalidate blit maps + format_version*: int # Private + refcount*: int + + PSDL_VideoInfo* = ptr TSDL_VideoInfo + TSDL_VideoInfo*{.final.} = object # The YUV hardware video overlay + hw_available*: UInt8 # Hardware and WindowManager flags in first 2 bits ( see below ) + #hw_available: 1; // Can you create hardware surfaces + # wm_available: 1; // Can you talk to a window manager? + # UnusedBits1: 6; + blit_hw*: UInt8 # Blit Hardware flags. See below for which bits do what + #UnusedBits2: 1; + # blit_hw: 1; // Flag:UInt32 Accelerated blits HW --> HW + # blit_hw_CC: 1; // Flag:UInt32 Accelerated blits with Colorkey + # blit_hw_A: 1; // Flag:UInt32 Accelerated blits with Alpha + # blit_sw: 1; // Flag:UInt32 Accelerated blits SW --> HW + # blit_sw_CC: 1; // Flag:UInt32 Accelerated blits with Colorkey + # blit_sw_A: 1; // Flag:UInt32 Accelerated blits with Alpha + # blit_fill: 1; // Flag:UInt32 Accelerated color fill + UnusedBits3*: UInt8 # Unused at this point + video_mem*: UInt32 # The total amount of video memory (in K) + vfmt*: PSDL_PixelFormat # Value: The format of the video surface + current_w*: SInt32 # Value: The current video mode width + current_h*: SInt32 # Value: The current video mode height + + PSDL_Overlay* = ptr TSDL_Overlay + TSDL_Overlay*{.final.} = object # Public enumeration for setting the OpenGL window attributes. + format*: UInt32 # Overlay format + w*, h*: int # Width and height of overlay + planes*: int # Number of planes in the overlay. Usually either 1 or 3 + pitches*: PUInt16 # An array of pitches, one for each plane. Pitch is the length of a row in bytes. + pixels*: PPUInt8 # An array of pointers to the data of each plane. The overlay should be locked before these pointers are used. + hw_overlay*: UInt32 # This will be set to 1 if the overlay is hardware accelerated. + + TSDL_GLAttr* = enum + SDL_GL_RED_SIZE, SDL_GL_GREEN_SIZE, SDL_GL_BLUE_SIZE, SDL_GL_ALPHA_SIZE, + SDL_GL_BUFFER_SIZE, SDL_GL_DOUBLEBUFFER, SDL_GL_DEPTH_SIZE, + SDL_GL_STENCIL_SIZE, SDL_GL_ACCUM_RED_SIZE, SDL_GL_ACCUM_GREEN_SIZE, + SDL_GL_ACCUM_BLUE_SIZE, SDL_GL_ACCUM_ALPHA_SIZE, SDL_GL_STEREO, + SDL_GL_MULTISAMPLEBUFFERS, SDL_GL_MULTISAMPLESAMPLES, + SDL_GL_ACCELERATED_VISUAL, SDL_GL_SWAP_CONTROL + PSDL_Cursor* = ptr TSDL_Cursor + TSDL_Cursor*{.final.} = object # SDL_mutex.h types + area*: TSDL_Rect # The area of the mouse cursor + hot_x*, hot_y*: SInt16 # The "tip" of the cursor + data*: PUInt8 # B/W cursor data + mask*: PUInt8 # B/W cursor mask + save*: array[1..2, PUInt8] # Place to save cursor area + wm_cursor*: Pointer # Window-manager cursor + + +type + PSDL_Mutex* = ptr TSDL_Mutex + TSDL_Mutex*{.final.} = object + PSDL_semaphore* = ptr TSDL_semaphore + TSDL_semaphore*{.final.} = object + PSDL_Sem* = ptr TSDL_Sem + TSDL_Sem* = TSDL_Semaphore + PSDL_Cond* = ptr TSDL_Cond + TSDL_Cond*{.final.} = object # SDL_thread.h types + +when defined(WINDOWS): + type + TSYS_ThreadHandle* = THandle +when defined(Unix): + type + TSYS_ThreadHandle* = pointer +type # This is the system-independent thread info structure + PSDL_Thread* = ptr TSDL_Thread + TSDL_Thread*{.final.} = object # Helper Types + # Keyboard State Array ( See demos for how to use ) + threadid*: UInt32 + handle*: TSYS_ThreadHandle + status*: int + errbuf*: TSDL_Error + data*: Pointer + + PKeyStateArr* = ptr TKeyStateArr + TKeyStateArr* = array[0..65000, UInt8] # Types required so we don't need to use Windows.pas + PInteger* = ptr int + PByte* = ptr int8 + PWord* = ptr int16 + PLongWord* = ptr int32 # General arrays + PByteArray* = ptr TByteArray + TByteArray* = array[0..32767, int8] + PWordArray* = ptr TWordArray + TWordArray* = array[0..16383, int16] # Generic procedure pointer + TProcedure* = proc () #------------------------------------------------------------------------------ + # initialization + #------------------------------------------------------------------------------ + # This function loads the SDL dynamically linked library and initializes + # the subsystems specified by 'flags' (and those satisfying dependencies) + # Unless the SDL_INIT_NOPARACHUTE flag is set, it will install cleanup + # signal handlers for some commonly ignored fatal signals (like SIGSEGV) + +proc SDL_Init*(flags: UInt32): int{.cdecl, importc, dynlib: SDLLibName.} + # This function initializes specific SDL subsystems +proc SDL_InitSubSystem*(flags: UInt32): int{.cdecl, importc, dynlib: SDLLibName.} + # This function cleans up specific SDL subsystems +proc SDL_QuitSubSystem*(flags: UInt32){.cdecl, importc, dynlib: SDLLibName.} + # This function returns mask of the specified subsystems which have + # been initialized. + # If 'flags' is 0, it returns a mask of all initialized subsystems. +proc SDL_WasInit*(flags: UInt32): UInt32{.cdecl, importc, dynlib: SDLLibName.} + # This function cleans up all initialized subsystems and unloads the + # dynamically linked library. You should call it upon all exit conditions. +proc SDL_Quit*(){.cdecl, importc, dynlib: SDLLibName.} +when defined(WINDOWS): + # This should be called from your WinMain() function, if any + proc SDL_RegisterApp*(name: cstring, style: UInt32, h_Inst: Pointer): int{. + cdecl, importc, dynlib: SDLLibName.} +#------------------------------------------------------------------------------ +# types +#------------------------------------------------------------------------------ +# The number of elements in a table + +proc SDL_TableSize*(table: cstring): int + #------------------------------------------------------------------------------ + # error-handling + #------------------------------------------------------------------------------ + # Public functions +proc SDL_GetError*(): cstring{.cdecl, importc, dynlib: SDLLibName.} +proc SDL_SetError*(fmt: cstring){.cdecl, importc, dynlib: SDLLibName.} +proc SDL_ClearError*(){.cdecl, importc, dynlib: SDLLibName.} +when not(defined(WINDOWS)): + proc SDL_Error*(Code: TSDL_errorcode){.cdecl, importc, dynlib: SDLLibName.} +# Private error message function - used internally + +proc SDL_OutOfMemory*() + #------------------------------------------------------------------------------ + # io handling + #------------------------------------------------------------------------------ + # Functions to create SDL_RWops structures from various data sources +proc SDL_RWFromFile*(filename, mode: cstring): PSDL_RWops{.cdecl, + importc, dynlib: SDLLibName.} +proc SDL_FreeRW*(area: PSDL_RWops){.cdecl, importc, dynlib: SDLLibName.} + #fp is FILE *fp ??? +proc SDL_RWFromFP*(fp: Pointer, autoclose: int): PSDL_RWops{.cdecl, + importc, dynlib: SDLLibName.} +proc SDL_RWFromMem*(mem: Pointer, size: int): PSDL_RWops{.cdecl, + importc, dynlib: SDLLibName.} +proc SDL_RWFromConstMem*(mem: Pointer, size: int): PSDL_RWops{.cdecl, + importc, dynlib: SDLLibName.} +proc SDL_AllocRW*(): PSDL_RWops{.cdecl, importc, dynlib: SDLLibName.} +proc SDL_RWSeek*(context: PSDL_RWops, offset: int, whence: int): int +proc SDL_RWTell*(context: PSDL_RWops): int +proc SDL_RWRead*(context: PSDL_RWops, theptr: Pointer, size: int, n: int): int +proc SDL_RWWrite*(context: PSDL_RWops, theptr: Pointer, size: int, n: int): int +proc SDL_RWClose*(context: PSDL_RWops): int + #------------------------------------------------------------------------------ + # time-handling + #------------------------------------------------------------------------------ + # Get the number of milliseconds since the SDL library initialization. + # Note that this value wraps if the program runs for more than ~49 days. +proc SDL_GetTicks*(): UInt32{.cdecl, importc, dynlib: SDLLibName.} + # Wait a specified number of milliseconds before returning +proc SDL_Delay*(msec: UInt32){.cdecl, importc, dynlib: SDLLibName.} + # Add a new timer to the pool of timers already running. + # Returns a timer ID, or NULL when an error occurs. +proc SDL_AddTimer*(interval: UInt32, callback: TSDL_NewTimerCallback, + param: Pointer): PSDL_TimerID{.cdecl, importc, dynlib: SDLLibName.} + # Remove one of the multiple timers knowing its ID. + # Returns a boolean value indicating success. +proc SDL_RemoveTimer*(t: PSDL_TimerID): TSDL_Bool{.cdecl, importc, dynlib: SDLLibName.} +proc SDL_SetTimer*(interval: UInt32, callback: TSDL_TimerCallback): int{.cdecl, + importc, dynlib: SDLLibName.} + #------------------------------------------------------------------------------ + # audio-routines + #------------------------------------------------------------------------------ + # These functions are used internally, and should not be used unless you + # have a specific need to specify the audio driver you want to use. + # You should normally use SDL_Init() or SDL_InitSubSystem(). +proc SDL_AudioInit*(driver_name: cstring): int{.cdecl, importc, dynlib: SDLLibName.} +proc SDL_AudioQuit*(){.cdecl, importc, dynlib: SDLLibName.} + # This function fills the given character buffer with the name of the + # current audio driver, and returns a Pointer to it if the audio driver has + # been initialized. It returns NULL if no driver has been initialized. +proc SDL_AudioDriverName*(namebuf: cstring, maxlen: int): cstring{.cdecl, + importc, dynlib: SDLLibName.} + # This function opens the audio device with the desired parameters, and + # returns 0 if successful, placing the actual hardware parameters in the + # structure pointed to by 'obtained'. If 'obtained' is NULL, the audio + # data passed to the callback function will be guaranteed to be in the + # requested format, and will be automatically converted to the hardware + # audio format if necessary. This function returns -1 if it failed + # to open the audio device, or couldn't set up the audio thread. + # + # When filling in the desired audio spec structure, + # 'desired->freq' should be the desired audio frequency in samples-per-second. + # 'desired->format' should be the desired audio format. + # 'desired->samples' is the desired size of the audio buffer, in samples. + # This number should be a power of two, and may be adjusted by the audio + # driver to a value more suitable for the hardware. Good values seem to + # range between 512 and 8096 inclusive, depending on the application and + # CPU speed. Smaller values yield faster response time, but can lead + # to underflow if the application is doing heavy processing and cannot + # fill the audio buffer in time. A stereo sample consists of both right + # and left channels in LR ordering. + # Note that the number of samples is directly related to time by the + # following formula: ms = (samples*1000)/freq + # 'desired->size' is the size in bytes of the audio buffer, and is + # calculated by SDL_OpenAudio(). + # 'desired->silence' is the value used to set the buffer to silence, + # and is calculated by SDL_OpenAudio(). + # 'desired->callback' should be set to a function that will be called + # when the audio device is ready for more data. It is passed a pointer + # to the audio buffer, and the length in bytes of the audio buffer. + # This function usually runs in a separate thread, and so you should + # protect data structures that it accesses by calling SDL_LockAudio() + # and SDL_UnlockAudio() in your code. + # 'desired->userdata' is passed as the first parameter to your callback + # function. + # + # The audio device starts out playing silence when it's opened, and should + # be enabled for playing by calling SDL_PauseAudio(0) when you are ready + # for your audio callback function to be called. Since the audio driver + # may modify the requested size of the audio buffer, you should allocate + # any local mixing buffers after you open the audio device. +proc SDL_OpenAudio*(desired, obtained: PSDL_AudioSpec): int{.cdecl, + importc, dynlib: SDLLibName.} + # Get the current audio state: +proc SDL_GetAudioStatus*(): TSDL_Audiostatus{.cdecl, importc, dynlib: SDLLibName.} + # This function pauses and unpauses the audio callback processing. + # It should be called with a parameter of 0 after opening the audio + # device to start playing sound. This is so you can safely initialize + # data for your callback function after opening the audio device. + # Silence will be written to the audio device during the pause. +proc SDL_PauseAudio*(pause_on: int){.cdecl, importc, dynlib: SDLLibName.} + # This function loads a WAVE from the data source, automatically freeing + # that source if 'freesrc' is non-zero. For example, to load a WAVE file, + # you could do: + # SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...); + # + # If this function succeeds, it returns the given SDL_AudioSpec, + # filled with the audio data format of the wave data, and sets + # 'audio_buf' to a malloc()'d buffer containing the audio data, + # and sets 'audio_len' to the length of that audio buffer, in bytes. + # You need to free the audio buffer with SDL_FreeWAV() when you are + # done with it. + # + # This function returns NULL and sets the SDL error message if the + # wave file cannot be opened, uses an unknown data format, or is + # corrupt. Currently raw and MS-ADPCM WAVE files are supported. +proc SDL_LoadWAV_RW*(src: PSDL_RWops, freesrc: int, spec: PSDL_AudioSpec, + audio_buf: PUInt8, audiolen: PUInt32): PSDL_AudioSpec{. + cdecl, importc, dynlib: SDLLibName.} + # Compatibility convenience function -- loads a WAV from a file +proc SDL_LoadWAV*(filename: cstring, spec: PSDL_AudioSpec, audio_buf: PUInt8, + audiolen: PUInt32): PSDL_AudioSpec + # This function frees data previously allocated with SDL_LoadWAV_RW() +proc SDL_FreeWAV*(audio_buf: PUInt8){.cdecl, importc, dynlib: SDLLibName.} + # This function takes a source format and rate and a destination format + # and rate, and initializes the 'cvt' structure with information needed + # by SDL_ConvertAudio() to convert a buffer of audio data from one format + # to the other. + # This function returns 0, or -1 if there was an error. +proc SDL_BuildAudioCVT*(cvt: PSDL_AudioCVT, src_format: UInt16, + src_channels: UInt8, src_rate: int, dst_format: UInt16, + dst_channels: UInt8, dst_rate: int): int{.cdecl, + importc, dynlib: SDLLibName.} + # Once you have initialized the 'cvt' structure using SDL_BuildAudioCVT(), + # created an audio buffer cvt->buf, and filled it with cvt->len bytes of + # audio data in the source format, this function will convert it in-place + # to the desired format. + # The data conversion may expand the size of the audio data, so the buffer + # cvt->buf should be allocated after the cvt structure is initialized by + # SDL_BuildAudioCVT(), and should be cvt->len*cvt->len_mult bytes long. +proc SDL_ConvertAudio*(cvt: PSDL_AudioCVT): int{.cdecl, importc, dynlib: SDLLibName.} + # This takes two audio buffers of the playing audio format and mixes + # them, performing addition, volume adjustment, and overflow clipping. + # The volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME + # for full audio volume. Note this does not change hardware volume. + # This is provided for convenience -- you can mix your own audio data. +proc SDL_MixAudio*(dst, src: PUInt8, length: UInt32, volume: int){.cdecl, + importc, dynlib: SDLLibName.} + # The lock manipulated by these functions protects the callback function. + # During a LockAudio/UnlockAudio pair, you can be guaranteed that the + # callback function is not running. Do not call these from the callback + # function or you will cause deadlock. +proc SDL_LockAudio*(){.cdecl, importc, dynlib: SDLLibName.} +proc SDL_UnlockAudio*(){.cdecl, importc, dynlib: SDLLibName.} + # This function shuts down audio processing and closes the audio device. +proc SDL_CloseAudio*(){.cdecl, importc, dynlib: SDLLibName.} + #------------------------------------------------------------------------------ + # CD-routines + #------------------------------------------------------------------------------ + # Returns the number of CD-ROM drives on the system, or -1 if + # SDL_Init() has not been called with the SDL_INIT_CDROM flag. +proc SDL_CDNumDrives*(): int{.cdecl, importc, dynlib: SDLLibName.} + # Returns a human-readable, system-dependent identifier for the CD-ROM. + # Example: + # "/dev/cdrom" + # "E:" + # "/dev/disk/ide/1/master" +proc SDL_CDName*(drive: int): cstring{.cdecl, importc, dynlib: SDLLibName.} + # Opens a CD-ROM drive for access. It returns a drive handle on success, + # or NULL if the drive was invalid or busy. This newly opened CD-ROM + # becomes the default CD used when other CD functions are passed a NULL + # CD-ROM handle. + # Drives are numbered starting with 0. Drive 0 is the system default CD-ROM. +proc SDL_CDOpen*(drive: int): PSDL_CD{.cdecl, importc, dynlib: SDLLibName.} + # This function returns the current status of the given drive. + # If the drive has a CD in it, the table of contents of the CD and current + # play position of the CD will be stored in the SDL_CD structure. +proc SDL_CDStatus*(cdrom: PSDL_CD): TSDL_CDStatus{.cdecl, importc, dynlib: SDLLibName.} + # Play the given CD starting at 'start_track' and 'start_frame' for 'ntracks' + # tracks and 'nframes' frames. If both 'ntrack' and 'nframe' are 0, play + # until the end of the CD. This function will skip data tracks. + # This function should only be called after calling SDL_CDStatus() to + # get track information about the CD. + # + # For example: + # // Play entire CD: + # if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) then + # SDL_CDPlayTracks(cdrom, 0, 0, 0, 0); + # // Play last track: + # if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) then + # begin + # SDL_CDPlayTracks(cdrom, cdrom->numtracks-1, 0, 0, 0); + # end; + # + # // Play first and second track and 10 seconds of third track: + # if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) + # SDL_CDPlayTracks(cdrom, 0, 0, 2, 10); + # + # This function returns 0, or -1 if there was an error. +proc SDL_CDPlayTracks*(cdrom: PSDL_CD, start_track: int, start_frame: int, + ntracks: int, nframes: int): int{.cdecl, + importc, dynlib: SDLLibName.} + # Play the given CD starting at 'start' frame for 'length' frames. + # It returns 0, or -1 if there was an error. +proc SDL_CDPlay*(cdrom: PSDL_CD, start: int, len: int): int{.cdecl, + importc, dynlib: SDLLibName.} + # Pause play -- returns 0, or -1 on error +proc SDL_CDPause*(cdrom: PSDL_CD): int{.cdecl, importc, dynlib: SDLLibName.} + # Resume play -- returns 0, or -1 on error +proc SDL_CDResume*(cdrom: PSDL_CD): int{.cdecl, importc, dynlib: SDLLibName.} + # Stop play -- returns 0, or -1 on error +proc SDL_CDStop*(cdrom: PSDL_CD): int{.cdecl, importc, dynlib: SDLLibName.} + # Eject CD-ROM -- returns 0, or -1 on error +proc SDL_CDEject*(cdrom: PSDL_CD): int{.cdecl, importc, dynlib: SDLLibName.} + # Closes the handle for the CD-ROM drive +proc SDL_CDClose*(cdrom: PSDL_CD){.cdecl, importc, dynlib: SDLLibName.} + # Given a status, returns true if there's a disk in the drive +proc SDL_CDInDrive*(status: TSDL_CDStatus): bool + # Conversion functions from frames to Minute/Second/Frames and vice versa +proc FRAMES_TO_MSF*(frames: int, M: var int, S: var int, F: var int) +proc MSF_TO_FRAMES*(M: int, S: int, F: int): int + #------------------------------------------------------------------------------ + # JoyStick-routines + #------------------------------------------------------------------------------ + # Count the number of joysticks attached to the system +proc SDL_NumJoysticks*(): int{.cdecl, importc, dynlib: SDLLibName.} + # Get the implementation dependent name of a joystick. + # This can be called before any joysticks are opened. + # If no name can be found, this function returns NULL. +proc SDL_JoystickName*(index: int): cstring{.cdecl, importc, dynlib: SDLLibName.} + # Open a joystick for use - the index passed as an argument refers to + # the N'th joystick on the system. This index is the value which will + # identify this joystick in future joystick events. + # + # This function returns a joystick identifier, or NULL if an error occurred. +proc SDL_JoystickOpen*(index: int): PSDL_Joystick{.cdecl, importc, dynlib: SDLLibName.} + # Returns 1 if the joystick has been opened, or 0 if it has not. +proc SDL_JoystickOpened*(index: int): int{.cdecl, importc, dynlib: SDLLibName.} + # Get the device index of an opened joystick. +proc SDL_JoystickIndex*(joystick: PSDL_Joystick): int{.cdecl, importc, dynlib: SDLLibName.} + # Get the number of general axis controls on a joystick +proc SDL_JoystickNumAxes*(joystick: PSDL_Joystick): int{.cdecl, + importc, dynlib: SDLLibName.} + # Get the number of trackballs on a joystick + # Joystick trackballs have only relative motion events associated + # with them and their state cannot be polled. +proc SDL_JoystickNumBalls*(joystick: PSDL_Joystick): int{.cdecl, + importc, dynlib: SDLLibName.} + # Get the number of POV hats on a joystick +proc SDL_JoystickNumHats*(joystick: PSDL_Joystick): int{.cdecl, + importc, dynlib: SDLLibName.} + # Get the number of buttons on a joystick +proc SDL_JoystickNumButtons*(joystick: PSDL_Joystick): int{.cdecl, + importc, dynlib: SDLLibName.} + # Update the current state of the open joysticks. + # This is called automatically by the event loop if any joystick + # events are enabled. +proc SDL_JoystickUpdate*(){.cdecl, importc, dynlib: SDLLibName.} + # Enable/disable joystick event polling. + # If joystick events are disabled, you must call SDL_JoystickUpdate() + # yourself and check the state of the joystick when you want joystick + # information. + # The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE. +proc SDL_JoystickEventState*(state: int): int{.cdecl, importc, dynlib: SDLLibName.} + # Get the current state of an axis control on a joystick + # The state is a value ranging from -32768 to 32767. + # The axis indices start at index 0. +proc SDL_JoystickGetAxis*(joystick: PSDL_Joystick, axis: int): SInt16{.cdecl, + importc, dynlib: SDLLibName.} + # The hat indices start at index 0. +proc SDL_JoystickGetHat*(joystick: PSDL_Joystick, hat: int): UInt8{.cdecl, + importc, dynlib: SDLLibName.} + # Get the ball axis change since the last poll + # This returns 0, or -1 if you passed it invalid parameters. + # The ball indices start at index 0. +proc SDL_JoystickGetBall*(joystick: PSDL_Joystick, ball: int, dx: var int, + dy: var int): int{.cdecl, importc, dynlib: SDLLibName.} + # Get the current state of a button on a joystick + # The button indices start at index 0. +proc SDL_JoystickGetButton*(joystick: PSDL_Joystick, Button: int): UInt8{.cdecl, + importc, dynlib: SDLLibName.} + # Close a joystick previously opened with SDL_JoystickOpen() +proc SDL_JoystickClose*(joystick: PSDL_Joystick){.cdecl, importc, dynlib: SDLLibName.} + #------------------------------------------------------------------------------ + # event-handling + #------------------------------------------------------------------------------ + # Pumps the event loop, gathering events from the input devices. + # This function updates the event queue and internal input device state. + # This should only be run in the thread that sets the video mode. +proc SDL_PumpEvents*(){.cdecl, importc, dynlib: SDLLibName.} + # Checks the event queue for messages and optionally returns them. + # If 'action' is SDL_ADDEVENT, up to 'numevents' events will be added to + # the back of the event queue. + # If 'action' is SDL_PEEKEVENT, up to 'numevents' events at the front + # of the event queue, matching 'mask', will be returned and will not + # be removed from the queue. + # If 'action' is SDL_GETEVENT, up to 'numevents' events at the front + # of the event queue, matching 'mask', will be returned and will be + # removed from the queue. + # This function returns the number of events actually stored, or -1 + # if there was an error. This function is thread-safe. +proc SDL_PeepEvents*(events: PSDL_Event, numevents: int, + action: TSDL_eventaction, mask: UInt32): int{.cdecl, + importc, dynlib: SDLLibName.} + # Polls for currently pending events, and returns 1 if there are any pending + # events, or 0 if there are none available. If 'event' is not NULL, the next + # event is removed from the queue and stored in that area. +proc SDL_PollEvent*(event: PSDL_Event): int{.cdecl, importc, dynlib: SDLLibName.} + # Waits indefinitely for the next available event, returning 1, or 0 if there + # was an error while waiting for events. If 'event' is not NULL, the next + # event is removed from the queue and stored in that area. +proc SDL_WaitEvent*(event: PSDL_Event): int{.cdecl, importc, dynlib: SDLLibName.} +proc SDL_PushEvent*(event: PSDL_Event): int{.cdecl, importc, dynlib: SDLLibName.} + # If the filter returns 1, then the event will be added to the internal queue. + # If it returns 0, then the event will be dropped from the queue, but the + # internal state will still be updated. This allows selective filtering of + # dynamically arriving events. + # + # WARNING: Be very careful of what you do in the event filter function, as + # it may run in a different thread! + # + # There is one caveat when dealing with the SDL_QUITEVENT event type. The + # event filter is only called when the window manager desires to close the + # application window. If the event filter returns 1, then the window will + # be closed, otherwise the window will remain open if possible. + # If the quit event is generated by an interrupt signal, it will bypass the + # internal queue and be delivered to the application at the next event poll. +proc SDL_SetEventFilter*(filter: TSDL_EventFilter){.cdecl, importc, dynlib: SDLLibName.} + # Return the current event filter - can be used to "chain" filters. + # If there is no event filter set, this function returns NULL. +proc SDL_GetEventFilter*(): TSDL_EventFilter{.cdecl, importc, dynlib: SDLLibName.} + # This function allows you to set the state of processing certain events. + # If 'state' is set to SDL_IGNORE, that event will be automatically dropped + # from the event queue and will not event be filtered. + # If 'state' is set to SDL_ENABLE, that event will be processed normally. + # If 'state' is set to SDL_QUERY, SDL_EventState() will return the + # current processing state of the specified event. +proc SDL_EventState*(theType: UInt8, state: int): UInt8{.cdecl, + importc, dynlib: SDLLibName.} + #------------------------------------------------------------------------------ + # Version Routines + #------------------------------------------------------------------------------ + # This macro can be used to fill a version structure with the compile-time + # version of the SDL library. +proc SDL_VERSION*(X: var TSDL_Version) + # This macro turns the version numbers into a numeric value: + # (1,2,3) -> (1203) + # This assumes that there will never be more than 100 patchlevels +proc SDL_VERSIONNUM*(X, Y, Z: int): int + # This is the version number macro for the current SDL version +proc SDL_COMPILEDVERSION*(): int + # This macro will evaluate to true if compiled with SDL at least X.Y.Z +proc SDL_VERSION_ATLEAST*(X: int, Y: int, Z: int): bool + # This function gets the version of the dynamically linked SDL library. + # it should NOT be used to fill a version structure, instead you should + # use the SDL_Version() macro. +proc SDL_Linked_Version*(): PSDL_version{.cdecl, importc, dynlib: SDLLibName.} + #------------------------------------------------------------------------------ + # video + #------------------------------------------------------------------------------ + # These functions are used internally, and should not be used unless you + # have a specific need to specify the video driver you want to use. + # You should normally use SDL_Init() or SDL_InitSubSystem(). + # + # SDL_VideoInit() initializes the video subsystem -- sets up a connection + # to the window manager, etc, and determines the current video mode and + # pixel format, but does not initialize a window or graphics mode. + # Note that event handling is activated by this routine. + # + # If you use both sound and video in your application, you need to call + # SDL_Init() before opening the sound device, otherwise under Win32 DirectX, + # you won't be able to set full-screen display modes. +proc SDL_VideoInit*(driver_name: cstring, flags: UInt32): int{.cdecl, + importc, dynlib: SDLLibName.} +proc SDL_VideoQuit*(){.cdecl, importc, dynlib: SDLLibName.} + # This function fills the given character buffer with the name of the + # video driver, and returns a pointer to it if the video driver has + # been initialized. It returns NULL if no driver has been initialized. +proc SDL_VideoDriverName*(namebuf: cstring, maxlen: int): cstring{.cdecl, + importc, dynlib: SDLLibName.} + # This function returns a pointer to the current display surface. + # If SDL is doing format conversion on the display surface, this + # function returns the publicly visible surface, not the real video + # surface. +proc SDL_GetVideoSurface*(): PSDL_Surface{.cdecl, importc, dynlib: SDLLibName.} + # This function returns a read-only pointer to information about the + # video hardware. If this is called before SDL_SetVideoMode(), the 'vfmt' + # member of the returned structure will contain the pixel format of the + # "best" video mode. +proc SDL_GetVideoInfo*(): PSDL_VideoInfo{.cdecl, importc, dynlib: SDLLibName.} + # Check to see if a particular video mode is supported. + # It returns 0 if the requested mode is not supported under any bit depth, + # or returns the bits-per-pixel of the closest available mode with the + # given width and height. If this bits-per-pixel is different from the + # one used when setting the video mode, SDL_SetVideoMode() will succeed, + # but will emulate the requested bits-per-pixel with a shadow surface. + # + # The arguments to SDL_VideoModeOK() are the same ones you would pass to + # SDL_SetVideoMode() +proc SDL_VideoModeOK*(width, height, bpp: int, flags: UInt32): int{.cdecl, + importc, importc, dynlib: SDLLibName.} + # Return a pointer to an array of available screen dimensions for the + # given format and video flags, sorted largest to smallest. Returns + # NULL if there are no dimensions available for a particular format, + # or (SDL_Rect **)-1 if any dimension is okay for the given format. + # + # if 'format' is NULL, the mode list will be for the format given + # by SDL_GetVideoInfo( ) - > vfmt +proc SDL_ListModes*(format: PSDL_PixelFormat, flags: UInt32): PPSDL_Rect{.cdecl, + importc, dynlib: SDLLibName.} + # Set up a video mode with the specified width, height and bits-per-pixel. + # + # If 'bpp' is 0, it is treated as the current display bits per pixel. + # + # If SDL_ANYFORMAT is set in 'flags', the SDL library will try to set the + # requested bits-per-pixel, but will return whatever video pixel format is + # available. The default is to emulate the requested pixel format if it + # is not natively available. + # + # If SDL_HWSURFACE is set in 'flags', the video surface will be placed in + # video memory, if possible, and you may have to call SDL_LockSurface() + # in order to access the raw framebuffer. Otherwise, the video surface + # will be created in system memory. + # + # If SDL_ASYNCBLIT is set in 'flags', SDL will try to perform rectangle + # updates asynchronously, but you must always lock before accessing pixels. + # SDL will wait for updates to complete before returning from the lock. + # + # If SDL_HWPALETTE is set in 'flags', the SDL library will guarantee + # that the colors set by SDL_SetColors() will be the colors you get. + # Otherwise, in 8-bit mode, SDL_SetColors() may not be able to set all + # of the colors exactly the way they are requested, and you should look + # at the video surface structure to determine the actual palette. + # If SDL cannot guarantee that the colors you request can be set, + # i.e. if the colormap is shared, then the video surface may be created + # under emulation in system memory, overriding the SDL_HWSURFACE flag. + # + # If SDL_FULLSCREEN is set in 'flags', the SDL library will try to set + # a fullscreen video mode. The default is to create a windowed mode + # if the current graphics system has a window manager. + # If the SDL library is able to set a fullscreen video mode, this flag + # will be set in the surface that is returned. + # + # If SDL_DOUBLEBUF is set in 'flags', the SDL library will try to set up + # two surfaces in video memory and swap between them when you call + # SDL_Flip(). This is usually slower than the normal single-buffering + # scheme, but prevents "tearing" artifacts caused by modifying video + # memory while the monitor is refreshing. It should only be used by + # applications that redraw the entire screen on every update. + # + # This function returns the video framebuffer surface, or NULL if it fails. +proc SDL_SetVideoMode*(width, height, bpp: int, flags: UInt32): PSDL_Surface{. + cdecl, importc, dynlib: SDLLibName.} + # Makes sure the given list of rectangles is updated on the given screen. + # If 'x', 'y', 'w' and 'h' are all 0, SDL_UpdateRect will update the entire + # screen. + # These functions should not be called while 'screen' is locked. +proc SDL_UpdateRects*(screen: PSDL_Surface, numrects: int, rects: PSDL_Rect){. + cdecl, importc, dynlib: SDLLibName.} +proc SDL_UpdateRect*(screen: PSDL_Surface, x, y: SInt32, w, h: UInt32){.cdecl, + importc, dynlib: SDLLibName.} + # On hardware that supports double-buffering, this function sets up a flip + # and returns. The hardware will wait for vertical retrace, and then swap + # video buffers before the next video surface blit or lock will return. + # On hardware that doesn not support double-buffering, this is equivalent + # to calling SDL_UpdateRect(screen, 0, 0, 0, 0); + # The SDL_DOUBLEBUF flag must have been passed to SDL_SetVideoMode() when + # setting the video mode for this function to perform hardware flipping. + # This function returns 0 if successful, or -1 if there was an error. +proc SDL_Flip*(screen: PSDL_Surface): int{.cdecl, importc, dynlib: SDLLibName.} + # Set the gamma correction for each of the color channels. + # The gamma values range (approximately) between 0.1 and 10.0 + # + # If this function isn't supported directly by the hardware, it will + # be emulated using gamma ramps, if available. If successful, this + # function returns 0, otherwise it returns -1. +proc SDL_SetGamma*(redgamma: float32, greengamma: float32, bluegamma: float32): int{. + cdecl, importc, dynlib: SDLLibName.} + # Set the gamma translation table for the red, green, and blue channels + # of the video hardware. Each table is an array of 256 16-bit quantities, + # representing a mapping between the input and output for that channel. + # The input is the index into the array, and the output is the 16-bit + # gamma value at that index, scaled to the output color precision. + # + # You may pass NULL for any of the channels to leave it unchanged. + # If the call succeeds, it will return 0. If the display driver or + # hardware does not support gamma translation, or otherwise fails, + # this function will return -1. +proc SDL_SetGammaRamp*(redtable: PUInt16, greentable: PUInt16, + bluetable: PUInt16): int{.cdecl, importc, dynlib: SDLLibName.} + # Retrieve the current values of the gamma translation tables. + # + # You must pass in valid pointers to arrays of 256 16-bit quantities. + # Any of the pointers may be NULL to ignore that channel. + # If the call succeeds, it will return 0. If the display driver or + # hardware does not support gamma translation, or otherwise fails, + # this function will return -1. +proc SDL_GetGammaRamp*(redtable: PUInt16, greentable: PUInt16, + bluetable: PUInt16): int{.cdecl, importc, dynlib: SDLLibName.} + # Sets a portion of the colormap for the given 8-bit surface. If 'surface' + # is not a palettized surface, this function does nothing, returning 0. + # If all of the colors were set as passed to SDL_SetColors(), it will + # return 1. If not all the color entries were set exactly as given, + # it will return 0, and you should look at the surface palette to + # determine the actual color palette. + # + # When 'surface' is the surface associated with the current display, the + # display colormap will be updated with the requested colors. If + # SDL_HWPALETTE was set in SDL_SetVideoMode() flags, SDL_SetColors() + # will always return 1, and the palette is guaranteed to be set the way + # you desire, even if the window colormap has to be warped or run under + # emulation. +proc SDL_SetColors*(surface: PSDL_Surface, colors: PSDL_Color, firstcolor: int, + ncolors: int): int{.cdecl, importc, dynlib: SDLLibName.} + # Sets a portion of the colormap for a given 8-bit surface. + # 'flags' is one or both of: + # SDL_LOGPAL -- set logical palette, which controls how blits are mapped + # to/from the surface, + # SDL_PHYSPAL -- set physical palette, which controls how pixels look on + # the screen + # Only screens have physical palettes. Separate change of physical/logical + # palettes is only possible if the screen has SDL_HWPALETTE set. + # + # The return value is 1 if all colours could be set as requested, and 0 + # otherwise. + # + # SDL_SetColors() is equivalent to calling this function with + # flags = (SDL_LOGPAL or SDL_PHYSPAL). +proc SDL_SetPalette*(surface: PSDL_Surface, flags: int, colors: PSDL_Color, + firstcolor: int, ncolors: int): int{.cdecl, + importc, dynlib: SDLLibName.} + # Maps an RGB triple to an opaque pixel value for a given pixel format +proc SDL_MapRGB*(format: PSDL_PixelFormat, r: UInt8, g: UInt8, b: UInt8): UInt32{. + cdecl, importc, dynlib: SDLLibName.} + # Maps an RGBA quadruple to a pixel value for a given pixel format +proc SDL_MapRGBA*(format: PSDL_PixelFormat, r: UInt8, g: UInt8, b: UInt8, + a: UInt8): UInt32{.cdecl, importc, dynlib: SDLLibName.} + # Maps a pixel value into the RGB components for a given pixel format +proc SDL_GetRGB*(pixel: UInt32, fmt: PSDL_PixelFormat, r: PUInt8, g: PUInt8, + b: PUInt8){.cdecl, importc, dynlib: SDLLibName.} + # Maps a pixel value into the RGBA components for a given pixel format +proc SDL_GetRGBA*(pixel: UInt32, fmt: PSDL_PixelFormat, r: PUInt8, g: PUInt8, + b: PUInt8, a: PUInt8){.cdecl, importc, dynlib: SDLLibName.} + # Allocate and free an RGB surface (must be called after SDL_SetVideoMode) + # If the depth is 4 or 8 bits, an empty palette is allocated for the surface. + # If the depth is greater than 8 bits, the pixel format is set using the + # flags '[RGB]mask'. + # If the function runs out of memory, it will return NULL. + # + # The 'flags' tell what kind of surface to create. + # SDL_SWSURFACE means that the surface should be created in system memory. + # SDL_HWSURFACE means that the surface should be created in video memory, + # with the same format as the display surface. This is useful for surfaces + # that will not change much, to take advantage of hardware acceleration + # when being blitted to the display surface. + # SDL_ASYNCBLIT means that SDL will try to perform asynchronous blits with + # this surface, but you must always lock it before accessing the pixels. + # SDL will wait for current blits to finish before returning from the lock. + # SDL_SRCCOLORKEY indicates that the surface will be used for colorkey blits. + # If the hardware supports acceleration of colorkey blits between + # two surfaces in video memory, SDL will try to place the surface in + # video memory. If this isn't possible or if there is no hardware + # acceleration available, the surface will be placed in system memory. + # SDL_SRCALPHA means that the surface will be used for alpha blits and + # if the hardware supports hardware acceleration of alpha blits between + # two surfaces in video memory, to place the surface in video memory + # if possible, otherwise it will be placed in system memory. + # If the surface is created in video memory, blits will be _much_ faster, + # but the surface format must be identical to the video surface format, + # and the only way to access the pixels member of the surface is to use + # the SDL_LockSurface() and SDL_UnlockSurface() calls. + # If the requested surface actually resides in video memory, SDL_HWSURFACE + # will be set in the flags member of the returned surface. If for some + # reason the surface could not be placed in video memory, it will not have + # the SDL_HWSURFACE flag set, and will be created in system memory instead. +proc SDL_AllocSurface*(flags: UInt32, width, height, depth: int, + RMask, GMask, BMask, AMask: UInt32): PSDL_Surface +proc SDL_CreateRGBSurface*(flags: UInt32, width, height, depth: int, + RMask, GMask, BMask, AMask: UInt32): PSDL_Surface{. + cdecl, importc, dynlib: SDLLibName.} +proc SDL_CreateRGBSurfaceFrom*(pixels: Pointer, + width, height, depth, pitch: int, + RMask, GMask, BMask, AMask: UInt32): PSDL_Surface{. + cdecl, importc, dynlib: SDLLibName.} +proc SDL_FreeSurface*(surface: PSDL_Surface){.cdecl, importc, dynlib: SDLLibName.} +proc SDL_MustLock*(Surface: PSDL_Surface): bool + # SDL_LockSurface() sets up a surface for directly accessing the pixels. + # Between calls to SDL_LockSurface()/SDL_UnlockSurface(), you can write + # to and read from 'surface->pixels', using the pixel format stored in + # 'surface->format'. Once you are done accessing the surface, you should + # use SDL_UnlockSurface() to release it. + # + # Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates + # to 0, then you can read and write to the surface at any time, and the + # pixel format of the surface will not change. In particular, if the + # SDL_HWSURFACE flag is not given when calling SDL_SetVideoMode(), you + # will not need to lock the display surface before accessing it. + # + # No operating system or library calls should be made between lock/unlock + # pairs, as critical system locks may be held during this time. + # + # SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked. +proc SDL_LockSurface*(surface: PSDL_Surface): int{.cdecl, importc, dynlib: SDLLibName.} +proc SDL_UnlockSurface*(surface: PSDL_Surface){.cdecl, importc, dynlib: SDLLibName.} + # Load a surface from a seekable SDL data source (memory or file.) + # If 'freesrc' is non-zero, the source will be closed after being read. + # Returns the new surface, or NULL if there was an error. + # The new surface should be freed with SDL_FreeSurface(). +proc SDL_LoadBMP_RW*(src: PSDL_RWops, freesrc: int): PSDL_Surface{.cdecl, + importc, dynlib: SDLLibName.} + # Convenience macro -- load a surface from a file +proc SDL_LoadBMP*(filename: cstring): PSDL_Surface + # Save a surface to a seekable SDL data source (memory or file.) + # If 'freedst' is non-zero, the source will be closed after being written. + # Returns 0 if successful or -1 if there was an error. +proc SDL_SaveBMP_RW*(surface: PSDL_Surface, dst: PSDL_RWops, freedst: int): int{. + cdecl, importc, dynlib: SDLLibName.} + # Convenience macro -- save a surface to a file +proc SDL_SaveBMP*(surface: PSDL_Surface, filename: cstring): int + # Sets the color key (transparent pixel) in a blittable surface. + # If 'flag' is SDL_SRCCOLORKEY (optionally OR'd with SDL_RLEACCEL), + # 'key' will be the transparent pixel in the source image of a blit. + # SDL_RLEACCEL requests RLE acceleration for the surface if present, + # and removes RLE acceleration if absent. + # If 'flag' is 0, this function clears any current color key. + # This function returns 0, or -1 if there was an error. +proc SDL_SetColorKey*(surface: PSDL_Surface, flag, key: UInt32): int{.cdecl, + importc, dynlib: SDLLibName.} + # This function sets the alpha value for the entire surface, as opposed to + # using the alpha component of each pixel. This value measures the range + # of transparency of the surface, 0 being completely transparent to 255 + # being completely opaque. An 'alpha' value of 255 causes blits to be + # opaque, the source pixels copied to the destination (the default). Note + # that per-surface alpha can be combined with colorkey transparency. + # + # If 'flag' is 0, alpha blending is disabled for the surface. + # If 'flag' is SDL_SRCALPHA, alpha blending is enabled for the surface. + # OR:ing the flag with SDL_RLEACCEL requests RLE acceleration for the + # surface; if SDL_RLEACCEL is not specified, the RLE accel will be removed. +proc SDL_SetAlpha*(surface: PSDL_Surface, flag: UInt32, alpha: UInt8): int{. + cdecl, importc, dynlib: SDLLibName.} + # Sets the clipping rectangle for the destination surface in a blit. + # + # If the clip rectangle is NULL, clipping will be disabled. + # If the clip rectangle doesn't intersect the surface, the function will + # return SDL_FALSE and blits will be completely clipped. Otherwise the + # function returns SDL_TRUE and blits to the surface will be clipped to + # the intersection of the surface area and the clipping rectangle. + # + # Note that blits are automatically clipped to the edges of the source + # and destination surfaces. +proc SDL_SetClipRect*(surface: PSDL_Surface, rect: PSDL_Rect){.cdecl, + importc, dynlib: SDLLibName.} + # Gets the clipping rectangle for the destination surface in a blit. + # 'rect' must be a pointer to a valid rectangle which will be filled + # with the correct values. +proc SDL_GetClipRect*(surface: PSDL_Surface, rect: PSDL_Rect){.cdecl, + importc, dynlib: SDLLibName.} + # Creates a new surface of the specified format, and then copies and maps + # the given surface to it so the blit of the converted surface will be as + # fast as possible. If this function fails, it returns NULL. + # + # The 'flags' parameter is passed to SDL_CreateRGBSurface() and has those + # semantics. You can also pass SDL_RLEACCEL in the flags parameter and + # SDL will try to RLE accelerate colorkey and alpha blits in the resulting + # surface. + # + # This function is used internally by SDL_DisplayFormat(). +proc SDL_ConvertSurface*(src: PSDL_Surface, fmt: PSDL_PixelFormat, flags: UInt32): PSDL_Surface{. + cdecl, importc, dynlib: SDLLibName.} + # + # This performs a fast blit from the source surface to the destination + # surface. It assumes that the source and destination rectangles are + # the same size. If either 'srcrect' or 'dstrect' are NULL, the entire + # surface (src or dst) is copied. The final blit rectangles are saved + # in 'srcrect' and 'dstrect' after all clipping is performed. + # If the blit is successful, it returns 0, otherwise it returns -1. + # + # The blit function should not be called on a locked surface. + # + # The blit semantics for surfaces with and without alpha and colorkey + # are defined as follows: + # + # RGBA->RGB: + # SDL_SRCALPHA set: + # alpha-blend (using alpha-channel). + # SDL_SRCCOLORKEY ignored. + # SDL_SRCALPHA not set: + # copy RGB. + # if SDL_SRCCOLORKEY set, only copy the pixels matching the + # RGB values of the source colour key, ignoring alpha in the + # comparison. + # + # RGB->RGBA: + # SDL_SRCALPHA set: + # alpha-blend (using the source per-surface alpha value); + # set destination alpha to opaque. + # SDL_SRCALPHA not set: + # copy RGB, set destination alpha to opaque. + # both: + # if SDL_SRCCOLORKEY set, only copy the pixels matching the + # source colour key. + # + # RGBA->RGBA: + # SDL_SRCALPHA set: + # alpha-blend (using the source alpha channel) the RGB values; + # leave destination alpha untouched. [Note: is this correct?] + # SDL_SRCCOLORKEY ignored. + # SDL_SRCALPHA not set: + # copy all of RGBA to the destination. + # if SDL_SRCCOLORKEY set, only copy the pixels matching the + # RGB values of the source colour key, ignoring alpha in the + # comparison. + # + # RGB->RGB: + # SDL_SRCALPHA set: + # alpha-blend (using the source per-surface alpha value). + # SDL_SRCALPHA not set: + # copy RGB. + # both: + # if SDL_SRCCOLORKEY set, only copy the pixels matching the + # source colour key. + # + # If either of the surfaces were in video memory, and the blit returns -2, + # the video memory was lost, so it should be reloaded with artwork and + # re-blitted: + # while ( SDL_BlitSurface(image, imgrect, screen, dstrect) = -2 ) do + # begin + # while ( SDL_LockSurface(image) < 0 ) do + # Sleep(10); + # -- Write image pixels to image->pixels -- + # SDL_UnlockSurface(image); + # end; + # + # This happens under DirectX 5.0 when the system switches away from your + # fullscreen application. The lock will also fail until you have access + # to the video memory again. + # You should call SDL_BlitSurface() unless you know exactly how SDL + # blitting works internally and how to use the other blit functions. +proc SDL_BlitSurface*(src: PSDL_Surface, srcrect: PSDL_Rect, dst: PSDL_Surface, + dstrect: PSDL_Rect): int + # This is the public blit function, SDL_BlitSurface(), and it performs + # rectangle validation and clipping before passing it to SDL_LowerBlit() +proc SDL_UpperBlit*(src: PSDL_Surface, srcrect: PSDL_Rect, dst: PSDL_Surface, + dstrect: PSDL_Rect): int{.cdecl, importc, dynlib: SDLLibName.} + # This is a semi-private blit function and it performs low-level surface + # blitting only. +proc SDL_LowerBlit*(src: PSDL_Surface, srcrect: PSDL_Rect, dst: PSDL_Surface, + dstrect: PSDL_Rect): int{.cdecl, importc, dynlib: SDLLibName.} + # This function performs a fast fill of the given rectangle with 'color' + # The given rectangle is clipped to the destination surface clip area + # and the final fill rectangle is saved in the passed in pointer. + # If 'dstrect' is NULL, the whole surface will be filled with 'color' + # The color should be a pixel of the format used by the surface, and + # can be generated by the SDL_MapRGB() function. + # This function returns 0 on success, or -1 on error. +proc SDL_FillRect*(dst: PSDL_Surface, dstrect: PSDL_Rect, color: UInt32): int{. + cdecl, importc, dynlib: SDLLibName.} + # This function takes a surface and copies it to a new surface of the + # pixel format and colors of the video framebuffer, suitable for fast + # blitting onto the display surface. It calls SDL_ConvertSurface() + # + # If you want to take advantage of hardware colorkey or alpha blit + # acceleration, you should set the colorkey and alpha value before + # calling this function. + # + # If the conversion fails or runs out of memory, it returns NULL +proc SDL_DisplayFormat*(surface: PSDL_Surface): PSDL_Surface{.cdecl, + importc, dynlib: SDLLibName.} + # This function takes a surface and copies it to a new surface of the + # pixel format and colors of the video framebuffer (if possible), + # suitable for fast alpha blitting onto the display surface. + # The new surface will always have an alpha channel. + # + # If you want to take advantage of hardware colorkey or alpha blit + # acceleration, you should set the colorkey and alpha value before + # calling this function. + # + # If the conversion fails or runs out of memory, it returns NULL +proc SDL_DisplayFormatAlpha*(surface: PSDL_Surface): PSDL_Surface{.cdecl, + importc, dynlib: SDLLibName.} + #* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + #* YUV video surface overlay functions */ + #* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + # This function creates a video output overlay + # Calling the returned surface an overlay is something of a misnomer because + # the contents of the display surface underneath the area where the overlay + # is shown is undefined - it may be overwritten with the converted YUV data. +proc SDL_CreateYUVOverlay*(width: int, height: int, format: UInt32, + display: PSDL_Surface): PSDL_Overlay{.cdecl, + importc, dynlib: SDLLibName.} + # Lock an overlay for direct access, and unlock it when you are done +proc SDL_LockYUVOverlay*(Overlay: PSDL_Overlay): int{.cdecl, importc, dynlib: SDLLibName.} +proc SDL_UnlockYUVOverlay*(Overlay: PSDL_Overlay){.cdecl, importc, dynlib: SDLLibName.} + # Blit a video overlay to the display surface. + # The contents of the video surface underneath the blit destination are + # not defined. + # The width and height of the destination rectangle may be different from + # that of the overlay, but currently only 2x scaling is supported. +proc SDL_DisplayYUVOverlay*(Overlay: PSDL_Overlay, dstrect: PSDL_Rect): int{. + cdecl, importc, dynlib: SDLLibName.} + # Free a video overlay +proc SDL_FreeYUVOverlay*(Overlay: PSDL_Overlay){.cdecl, importc, dynlib: SDLLibName.} + #------------------------------------------------------------------------------ + # OpenGL Routines + #------------------------------------------------------------------------------ + # Dynamically load a GL driver, if SDL is built with dynamic GL. + # + # SDL links normally with the OpenGL library on your system by default, + # but you can compile it to dynamically load the GL driver at runtime. + # If you do this, you need to retrieve all of the GL functions used in + # your program from the dynamic library using SDL_GL_GetProcAddress(). + # + # This is disabled in default builds of SDL. +proc SDL_GL_LoadLibrary*(filename: cstring): int{.cdecl, importc, dynlib: SDLLibName.} + # Get the address of a GL function (for extension functions) +proc SDL_GL_GetProcAddress*(procname: cstring): Pointer{.cdecl, + importc, dynlib: SDLLibName.} + # Set an attribute of the OpenGL subsystem before intialization. +proc SDL_GL_SetAttribute*(attr: TSDL_GLAttr, value: int): int{.cdecl, + importc, dynlib: SDLLibName.} + # Get an attribute of the OpenGL subsystem from the windowing + # interface, such as glX. This is of course different from getting + # the values from SDL's internal OpenGL subsystem, which only + # stores the values you request before initialization. + # + # Developers should track the values they pass into SDL_GL_SetAttribute + # themselves if they want to retrieve these values. +proc SDL_GL_GetAttribute*(attr: TSDL_GLAttr, value: var int): int{.cdecl, + importc, dynlib: SDLLibName.} + # Swap the OpenGL buffers, if double-buffering is supported. +proc SDL_GL_SwapBuffers*(){.cdecl, importc, dynlib: SDLLibName.} + # Internal functions that should not be called unless you have read + # and understood the source code for these functions. +proc SDL_GL_UpdateRects*(numrects: int, rects: PSDL_Rect){.cdecl, + importc, dynlib: SDLLibName.} +proc SDL_GL_Lock*(){.cdecl, importc, dynlib: SDLLibName.} +proc SDL_GL_Unlock*(){.cdecl, importc, dynlib: SDLLibName.} + #* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + #* These functions allow interaction with the window manager, if any. * + #* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + # Sets/Gets the title and icon text of the display window +proc SDL_WM_GetCaption*(title: var cstring, icon: var cstring){.cdecl, + importc, dynlib: SDLLibName.} +proc SDL_WM_SetCaption*(title: cstring, icon: cstring){.cdecl, + importc, dynlib: SDLLibName.} + # Sets the icon for the display window. + # This function must be called before the first call to SDL_SetVideoMode(). + # It takes an icon surface, and a mask in MSB format. + # If 'mask' is NULL, the entire icon surface will be used as the icon. +proc SDL_WM_SetIcon*(icon: PSDL_Surface, mask: UInt8){.cdecl, importc, dynlib: SDLLibName.} + # This function iconifies the window, and returns 1 if it succeeded. + # If the function succeeds, it generates an SDL_APPACTIVE loss event. + # This function is a noop and returns 0 in non-windowed environments. +proc SDL_WM_IconifyWindow*(): int{.cdecl, importc, dynlib: SDLLibName.} + # Toggle fullscreen mode without changing the contents of the screen. + # If the display surface does not require locking before accessing + # the pixel information, then the memory pointers will not change. + # + # If this function was able to toggle fullscreen mode (change from + # running in a window to fullscreen, or vice-versa), it will return 1. + # If it is not implemented, or fails, it returns 0. + # + # The next call to SDL_SetVideoMode() will set the mode fullscreen + # attribute based on the flags parameter - if SDL_FULLSCREEN is not + # set, then the display will be windowed by default where supported. + # + # This is currently only implemented in the X11 video driver. +proc SDL_WM_ToggleFullScreen*(surface: PSDL_Surface): int{.cdecl, + importc, dynlib: SDLLibName.} + # Grabbing means that the mouse is confined to the application window, + # and nearly all keyboard input is passed directly to the application, + # and not interpreted by a window manager, if any. +proc SDL_WM_GrabInput*(mode: TSDL_GrabMode): TSDL_GrabMode{.cdecl, + importc, dynlib: SDLLibName.} + #------------------------------------------------------------------------------ + # mouse-routines + #------------------------------------------------------------------------------ + # Retrieve the current state of the mouse. + # The current button state is returned as a button bitmask, which can + # be tested using the SDL_BUTTON(X) macros, and x and y are set to the + # current mouse cursor position. You can pass NULL for either x or y. +proc SDL_GetMouseState*(x: var int, y: var int): UInt8{.cdecl, + importc, dynlib: SDLLibName.} + # Retrieve the current state of the mouse. + # The current button state is returned as a button bitmask, which can + # be tested using the SDL_BUTTON(X) macros, and x and y are set to the + # mouse deltas since the last call to SDL_GetRelativeMouseState(). +proc SDL_GetRelativeMouseState*(x: var int, y: var int): UInt8{.cdecl, + importc, dynlib: SDLLibName.} + # Set the position of the mouse cursor (generates a mouse motion event) +proc SDL_WarpMouse*(x, y: UInt16){.cdecl, importc, dynlib: SDLLibName.} + # Create a cursor using the specified data and mask (in MSB format). + # The cursor width must be a multiple of 8 bits. + # + # The cursor is created in black and white according to the following: + # data mask resulting pixel on screen + # 0 1 White + # 1 1 Black + # 0 0 Transparent + # 1 0 Inverted color if possible, black if not. + # + # Cursors created with this function must be freed with SDL_FreeCursor(). +proc SDL_CreateCursor*(data, mask: PUInt8, w, h, hot_x, hot_y: int): PSDL_Cursor{. + cdecl, importc, dynlib: SDLLibName.} + # Set the currently active cursor to the specified one. + # If the cursor is currently visible, the change will be immediately + # represented on the display. +proc SDL_SetCursor*(cursor: PSDL_Cursor){.cdecl, importc, dynlib: SDLLibName.} + # Returns the currently active cursor. +proc SDL_GetCursor*(): PSDL_Cursor{.cdecl, importc, dynlib: SDLLibName.} + # Deallocates a cursor created with SDL_CreateCursor(). +proc SDL_FreeCursor*(cursor: PSDL_Cursor){.cdecl, importc, dynlib: SDLLibName.} + # Toggle whether or not the cursor is shown on the screen. + # The cursor start off displayed, but can be turned off. + # SDL_ShowCursor() returns 1 if the cursor was being displayed + # before the call, or 0 if it was not. You can query the current + # state by passing a 'toggle' value of -1. +proc SDL_ShowCursor*(toggle: int): int{.cdecl, importc, dynlib: SDLLibName.} +proc SDL_BUTTON*(Button: int): int + #------------------------------------------------------------------------------ + # Keyboard-routines + #------------------------------------------------------------------------------ + # Enable/Disable UNICODE translation of keyboard input. + # This translation has some overhead, so translation defaults off. + # If 'enable' is 1, translation is enabled. + # If 'enable' is 0, translation is disabled. + # If 'enable' is -1, the translation state is not changed. + # It returns the previous state of keyboard translation. +proc SDL_EnableUNICODE*(enable: int): int{.cdecl, importc, dynlib: SDLLibName.} + # If 'delay' is set to 0, keyboard repeat is disabled. +proc SDL_EnableKeyRepeat*(delay: int, interval: int): int{.cdecl, + importc, dynlib: SDLLibName.} +proc SDL_GetKeyRepeat*(delay: PInteger, interval: PInteger){.cdecl, + importc, dynlib: SDLLibName.} + # Get a snapshot of the current state of the keyboard. + # Returns an array of keystates, indexed by the SDLK_* syms. + # Used: + # + # UInt8 *keystate = SDL_GetKeyState(NULL); + # if ( keystate[SDLK_RETURN] ) ... <RETURN> is pressed +proc SDL_GetKeyState*(numkeys: PInt): PUInt8{.cdecl, importc, dynlib: SDLLibName.} + # Get the current key modifier state +proc SDL_GetModState*(): TSDLMod{.cdecl, importc, dynlib: SDLLibName.} + # Set the current key modifier state + # This does not change the keyboard state, only the key modifier flags. +proc SDL_SetModState*(modstate: TSDLMod){.cdecl, importc, dynlib: SDLLibName.} + # Get the name of an SDL virtual keysym +proc SDL_GetKeyName*(key: TSDLKey): cstring{.cdecl, importc, dynlib: SDLLibName.} + #------------------------------------------------------------------------------ + # Active Routines + #------------------------------------------------------------------------------ + # This function returns the current state of the application, which is a + # bitwise combination of SDL_APPMOUSEFOCUS, SDL_APPINPUTFOCUS, and + # SDL_APPACTIVE. If SDL_APPACTIVE is set, then the user is able to + # see your application, otherwise it has been iconified or disabled. +proc SDL_GetAppState*(): UInt8{.cdecl, importc, dynlib: SDLLibName.} + # Mutex functions + # Create a mutex, initialized unlocked +proc SDL_CreateMutex*(): PSDL_Mutex{.cdecl, importc, dynlib: SDLLibName.} + # Lock the mutex (Returns 0, or -1 on error) +proc SDL_mutexP*(mutex: PSDL_mutex): int{.cdecl, importc, dynlib: SDLLibName.} +proc SDL_LockMutex*(mutex: PSDL_mutex): int + # Unlock the mutex (Returns 0, or -1 on error) +proc SDL_mutexV*(mutex: PSDL_mutex): int{.cdecl, importc, dynlib: SDLLibName.} +proc SDL_UnlockMutex*(mutex: PSDL_mutex): int + # Destroy a mutex +proc SDL_DestroyMutex*(mutex: PSDL_mutex){.cdecl, importc, dynlib: SDLLibName.} + # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + # Semaphore functions + # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + # Create a semaphore, initialized with value, returns NULL on failure. +proc SDL_CreateSemaphore*(initial_value: UInt32): PSDL_Sem{.cdecl, + importc, dynlib: SDLLibName.} + # Destroy a semaphore +proc SDL_DestroySemaphore*(sem: PSDL_sem){.cdecl, importc, dynlib: SDLLibName.} + # This function suspends the calling thread until the semaphore pointed + # to by sem has a positive count. It then atomically decreases the semaphore + # count. +proc SDL_SemWait*(sem: PSDL_sem): int{.cdecl, importc, dynlib: SDLLibName.} + # Non-blocking variant of SDL_SemWait(), returns 0 if the wait succeeds, + # SDL_MUTEX_TIMEDOUT if the wait would block, and -1 on error. +proc SDL_SemTryWait*(sem: PSDL_sem): int{.cdecl, importc, dynlib: SDLLibName.} + # Variant of SDL_SemWait() with a timeout in milliseconds, returns 0 if + # the wait succeeds, SDL_MUTEX_TIMEDOUT if the wait does not succeed in + # the allotted time, and -1 on error. + # On some platforms this function is implemented by looping with a delay + # of 1 ms, and so should be avoided if possible. +proc SDL_SemWaitTimeout*(sem: PSDL_sem, ms: UInt32): int{.cdecl, + importc, dynlib: SDLLibName.} + # Atomically increases the semaphore's count (not blocking), returns 0, + # or -1 on error. +proc SDL_SemPost*(sem: PSDL_sem): int{.cdecl, importc, dynlib: SDLLibName.} + # Returns the current count of the semaphore +proc SDL_SemValue*(sem: PSDL_sem): UInt32{.cdecl, importc, dynlib: SDLLibName.} + # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + # Condition variable functions + # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + # Create a condition variable +proc SDL_CreateCond*(): PSDL_Cond{.cdecl, importc, dynlib: SDLLibName.} + # Destroy a condition variable +proc SDL_DestroyCond*(cond: PSDL_Cond){.cdecl, importc, dynlib: SDLLibName.} + # Restart one of the threads that are waiting on the condition variable, + # returns 0 or -1 on error. +proc SDL_CondSignal*(cond: PSDL_cond): int{.cdecl, importc, dynlib: SDLLibName.} + # Restart all threads that are waiting on the condition variable, + # returns 0 or -1 on error. +proc SDL_CondBroadcast*(cond: PSDL_cond): int{.cdecl, importc, dynlib: SDLLibName.} + # Wait on the condition variable, unlocking the provided mutex. + # The mutex must be locked before entering this function! + # Returns 0 when it is signaled, or -1 on error. +proc SDL_CondWait*(cond: PSDL_cond, mut: PSDL_mutex): int{.cdecl, + importc, dynlib: SDLLibName.} + # Waits for at most 'ms' milliseconds, and returns 0 if the condition + # variable is signaled, SDL_MUTEX_TIMEDOUT if the condition is not + # signaled in the allotted time, and -1 on error. + # On some platforms this function is implemented by looping with a delay + # of 1 ms, and so should be avoided if possible. +proc SDL_CondWaitTimeout*(cond: PSDL_cond, mut: PSDL_mutex, ms: UInt32): int{. + cdecl, importc, dynlib: SDLLibName.} + # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + # Condition variable functions + # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + # Create a thread +proc SDL_CreateThread*(fn: PInt, data: Pointer): PSDL_Thread{.cdecl, + importc, dynlib: SDLLibName.} + # Get the 32-bit thread identifier for the current thread +proc SDL_ThreadID*(): UInt32{.cdecl, importc, dynlib: SDLLibName.} + # Get the 32-bit thread identifier for the specified thread, + # equivalent to SDL_ThreadID() if the specified thread is NULL. +proc SDL_GetThreadID*(thread: PSDL_Thread): UInt32{.cdecl, importc, dynlib: SDLLibName.} + # Wait for a thread to finish. + # The return code for the thread function is placed in the area + # pointed to by 'status', if 'status' is not NULL. +proc SDL_WaitThread*(thread: PSDL_Thread, status: var int){.cdecl, + importc, dynlib: SDLLibName.} + # Forcefully kill a thread without worrying about its state +proc SDL_KillThread*(thread: PSDL_Thread){.cdecl, importc, dynlib: SDLLibName.} + #------------------------------------------------------------------------------ + # Get Environment Routines + #------------------------------------------------------------------------------ + #* + # * This function gives you custom hooks into the window manager information. + # * It fills the structure pointed to by 'info' with custom information and + # * returns 1 if the function is implemented. If it's not implemented, or + # * the version member of the 'info' structure is invalid, it returns 0. + # * +proc SDL_GetWMInfo*(info: PSDL_SysWMinfo): int{.cdecl, importc, dynlib: SDLLibName.} + #------------------------------------------------------------------------------ + #SDL_loadso.h + #* This function dynamically loads a shared object and returns a pointer + # * to the object handle (or NULL if there was an error). + # * The 'sofile' parameter is a system dependent name of the object file. + # * +proc SDL_LoadObject*(sofile: cstring): Pointer{.cdecl, importc, dynlib: SDLLibName.} + #* Given an object handle, this function looks up the address of the + # * named function in the shared object and returns it. This address + # * is no longer valid after calling SDL_UnloadObject(). + # * +proc SDL_LoadFunction*(handle: Pointer, name: cstring): Pointer{.cdecl, + importc, dynlib: SDLLibName.} + #* Unload a shared object from memory * +proc SDL_UnloadObject*(handle: Pointer){.cdecl, importc, dynlib: SDLLibName.} + #------------------------------------------------------------------------------ +proc SDL_Swap32*(D: Uint32): Uint32 + # Bitwise Checking functions +proc IsBitOn*(value: int, bit: int8): bool +proc TurnBitOn*(value: int, bit: int8): int +proc TurnBitOff*(value: int, bit: int8): int +# implementation + +proc SDL_TABLESIZE(table: cstring): int = + Result = SizeOf(table) div SizeOf(table[0]) + +proc SDL_OutOfMemory() = + when not(defined(WINDOWS)): SDL_Error(SDL_ENOMEM) + +proc SDL_RWSeek(context: PSDL_RWops, offset: int, whence: int): int = + Result = context.seek(context, offset, whence) + +proc SDL_RWTell(context: PSDL_RWops): int = + Result = context.seek(context, 0, 1) + +proc SDL_RWRead(context: PSDL_RWops, theptr: Pointer, size: int, n: int): int = + Result = context.read(context, theptr, size, n) + +proc SDL_RWWrite(context: PSDL_RWops, theptr: Pointer, size: int, n: int): int = + Result = context.write(context, theptr, size, n) + +proc SDL_RWClose(context: PSDL_RWops): int = + Result = context.closeFile(context) + +proc SDL_LoadWAV(filename: cstring, spec: PSDL_AudioSpec, audio_buf: PUInt8, + audiolen: PUInt32): PSDL_AudioSpec = + Result = SDL_LoadWAV_RW(SDL_RWFromFile(filename, "rb"), 1, spec, audio_buf, + audiolen) + +proc SDL_CDInDrive(status: TSDL_CDStatus): bool = + Result = ord(status) > ord(CD_ERROR) + +proc FRAMES_TO_MSF(frames: int, M: var int, S: var int, F: var int) = + var value: int + value = frames + F = value mod CD_FPS + value = value div CD_FPS + S = value mod 60 + value = value div 60 + M = value + +proc MSF_TO_FRAMES(M: int, S: int, F: int): int = + Result = M * 60 * CD_FPS + S * CD_FPS + F + +proc SDL_VERSION(X: var TSDL_Version) = + X.major = SDL_MAJOR_VERSION + X.minor = SDL_MINOR_VERSION + X.patch = SDL_PATCHLEVEL + +proc SDL_VERSIONNUM(X, Y, Z: int): int = + Result = X * 1000 + Y * 100 + Z + +proc SDL_COMPILEDVERSION(): int = + Result = SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) + +proc SDL_VERSION_ATLEAST(X, Y, Z: int): bool = + Result = (SDL_COMPILEDVERSION() >= SDL_VERSIONNUM(X, Y, Z)) + +proc SDL_LoadBMP(filename: cstring): PSDL_Surface = + Result = SDL_LoadBMP_RW(SDL_RWFromFile(filename, "rb"), 1) + +proc SDL_SaveBMP(surface: PSDL_Surface, filename: cstring): int = + Result = SDL_SaveBMP_RW(surface, SDL_RWFromFile(filename, "wb"), 1) + +proc SDL_BlitSurface(src: PSDL_Surface, srcrect: PSDL_Rect, dst: PSDL_Surface, + dstrect: PSDL_Rect): int = + Result = SDL_UpperBlit(src, srcrect, dst, dstrect) + +proc SDL_AllocSurface(flags: UInt32, width, height, depth: int, + RMask, GMask, BMask, AMask: UInt32): PSDL_Surface = + Result = SDL_CreateRGBSurface(flags, width, height, depth, RMask, GMask, + BMask, AMask) + +proc SDL_MustLock(Surface: PSDL_Surface): bool = + Result = ((surface^ .offset != 0) or + ((surface^ .flags and (SDL_HWSURFACE or SDL_ASYNCBLIT or SDL_RLEACCEL)) != + 0)) + +proc SDL_LockMutex(mutex: PSDL_mutex): int = + Result = SDL_mutexP(mutex) + +proc SDL_UnlockMutex(mutex: PSDL_mutex): int = + Result = SDL_mutexV(mutex) + +proc SDL_BUTTON(Button: int): int = + Result = SDL_PRESSED shl (Button - 1) + +proc SDL_Swap32(D: Uint32): Uint32 = + Result = ((D shl 24) or ((D shl 8) and 0x00FF0000) or + ((D shr 8) and 0x0000FF00) or (D shr 24)) + +proc IsBitOn(value: int, bit: int8): bool = + result = ((value and (1 shl ze(bit))) != 0) + +proc TurnBitOn(value: int, bit: int8): int = + result = (value or (1 shl ze(bit))) + +proc TurnBitOff(value: int, bit: int8): int = + result = (value and not (1 shl ze(bit))) diff --git a/lib/base/sdl/sdl_gfx.nim b/lib/base/sdl/sdl_gfx.nim new file mode 100644 index 000000000..8ae8eca0b --- /dev/null +++ b/lib/base/sdl/sdl_gfx.nim @@ -0,0 +1,421 @@ + +# +# $Id: sdl_gfx.pas,v 1.3 2007/05/29 21:31:04 savage Exp $ +# +# +# +# $Log: sdl_gfx.pas,v $ +# Revision 1.3 2007/05/29 21:31:04 savage +# Changes as suggested by Almindor for 64bit compatibility. +# +# Revision 1.2 2007/05/20 20:30:18 savage +# Initial Changes to Handle 64 Bits +# +# Revision 1.1 2005/01/03 19:08:32 savage +# Header for the SDL_Gfx library. +# +# +# +# + +import + sdl + +when defined(windows): + const SDLgfxLibName = "SDL_gfx.dll" +elif defined(macosx): + const SDLgfxLibName = "libSDL_gfx.dylib" +else: + const SDLgfxLibName = "libSDL_gfx.so" + +const # Some rates in Hz + FPS_UPPER_LIMIT* = 200 + FPS_LOWER_LIMIT* = 1 + FPS_DEFAULT* = 30 # ---- Defines + SMOOTHING_OFF* = 0 + SMOOTHING_ON* = 1 + +type + PFPSmanager* = ptr TFPSmanager + TFPSmanager*{.final.} = object # ---- Structures + framecount*: Uint32 + rateticks*: float32 + lastticks*: Uint32 + rate*: Uint32 + + PColorRGBA* = ptr TColorRGBA + TColorRGBA*{.final.} = object + r*: Uint8 + g*: Uint8 + b*: Uint8 + a*: Uint8 + + PColorY* = ptr TColorY + TColorY*{.final.} = object # + # + # SDL_framerate: framerate manager + # + # LGPL (c) A. Schiffler + # + # + y*: Uint8 + + +proc SDL_initFramerate*(manager: PFPSmanager){.cdecl, importc, dynlib: SDLgfxLibName.} +proc SDL_setFramerate*(manager: PFPSmanager, rate: int): int{.cdecl, + importc, dynlib: SDLgfxLibName.} +proc SDL_getFramerate*(manager: PFPSmanager): int{.cdecl, importc, dynlib: SDLgfxLibName.} +proc SDL_framerateDelay*(manager: PFPSmanager){.cdecl, importc, dynlib: SDLgfxLibName.} + # + # + # SDL_gfxPrimitives: graphics primitives for SDL + # + # LGPL (c) A. Schiffler + # + # + # Note: all ___Color routines expect the color to be in format 0xRRGGBBAA + # Pixel +proc pixelColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, color: Uint32): int{. + cdecl, importc, dynlib: SDLgfxLibName.} +proc pixelRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, r: Uint8, g: Uint8, + b: Uint8, a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.} + # Horizontal line +proc hlineColor*(dst: PSDL_Surface, x1: Sint16, x2: Sint16, y: Sint16, + color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.} +proc hlineRGBA*(dst: PSDL_Surface, x1: Sint16, x2: Sint16, y: Sint16, r: Uint8, + g: Uint8, b: Uint8, a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.} + # Vertical line +proc vlineColor*(dst: PSDL_Surface, x: Sint16, y1: Sint16, y2: Sint16, + color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.} +proc vlineRGBA*(dst: PSDL_Surface, x: Sint16, y1: Sint16, y2: Sint16, r: Uint8, + g: Uint8, b: Uint8, a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.} + # Rectangle +proc rectangleColor*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, + y2: Sint16, color: Uint32): int{.cdecl, + importc, dynlib: SDLgfxLibName.} +proc rectangleRGBA*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, + y2: Sint16, r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{. + cdecl, importc, dynlib: SDLgfxLibName.} + # Filled rectangle (Box) +proc boxColor*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, + y2: Sint16, color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.} +proc boxRGBA*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, y2: Sint16, + r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl, + importc, dynlib: SDLgfxLibName.} + # Line +proc lineColor*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, + y2: Sint16, color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.} +proc lineRGBA*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, + y2: Sint16, r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl, + importc, dynlib: SDLgfxLibName.} + # AA Line +proc aalineColor*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, + y2: Sint16, color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.} +proc aalineRGBA*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, + y2: Sint16, r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{. + cdecl, importc, dynlib: SDLgfxLibName.} + # Circle +proc circleColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, r: Sint16, + color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.} +proc circleRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rad: Sint16, r: Uint8, + g: Uint8, b: Uint8, a: Uint8): int{.cdecl, + importc, dynlib: SDLgfxLibName.} + # AA Circle +proc aacircleColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, r: Sint16, + color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.} +proc aacircleRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rad: Sint16, + r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl, + importc, dynlib: SDLgfxLibName.} + # Filled Circle +proc filledCircleColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, r: Sint16, + color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.} +proc filledCircleRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rad: Sint16, + r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl, + importc, dynlib: SDLgfxLibName.} + # Ellipse +proc ellipseColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, rx: Sint16, + ry: Sint16, color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.} +proc ellipseRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rx: Sint16, + ry: Sint16, r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{. + cdecl, importc, dynlib: SDLgfxLibName.} + # AA Ellipse +proc aaellipseColor*(dst: PSDL_Surface, xc: Sint16, yc: Sint16, rx: Sint16, + ry: Sint16, color: Uint32): int{.cdecl, + importc, dynlib: SDLgfxLibName.} +proc aaellipseRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rx: Sint16, + ry: Sint16, r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{. + cdecl, importc, dynlib: SDLgfxLibName.} + # Filled Ellipse +proc filledEllipseColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, rx: Sint16, + ry: Sint16, color: Uint32): int{.cdecl, + importc, dynlib: SDLgfxLibName.} +proc filledEllipseRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rx: Sint16, + ry: Sint16, r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{. + cdecl, importc, dynlib: SDLgfxLibName.} + # Pie +proc pieColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, rad: Sint16, + start: Sint16, finish: Sint16, color: Uint32): int{.cdecl, + importc, dynlib: SDLgfxLibName.} +proc pieRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rad: Sint16, + start: Sint16, finish: Sint16, r: Uint8, g: Uint8, b: Uint8, + a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.} + # Filled Pie +proc filledPieColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, rad: Sint16, + start: Sint16, finish: Sint16, color: Uint32): int{.cdecl, + importc, dynlib: SDLgfxLibName.} +proc filledPieRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, rad: Sint16, + start: Sint16, finish: Sint16, r: Uint8, g: Uint8, b: Uint8, + a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.} + # Trigon +proc trigonColor*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, + y2: Sint16, x3: Sint16, y3: Sint16, color: Uint32): int{. + cdecl, importc, dynlib: SDLgfxLibName.} +proc trigonRGBA*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, + y2: Sint16, x3: Sint16, y3: Sint16, r: Uint8, g: Uint8, + b: Uint8, a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.} + # AA-Trigon +proc aatrigonColor*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, + y2: Sint16, x3: Sint16, y3: Sint16, color: Uint32): int{. + cdecl, importc, dynlib: SDLgfxLibName.} +proc aatrigonRGBA*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, + y2: Sint16, x3: Sint16, y3: Sint16, r: Uint8, g: Uint8, + b: Uint8, a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.} + # Filled Trigon +proc filledTrigonColor*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, + y2: Sint16, x3: Sint16, y3: Sint16, color: Uint32): int{. + cdecl, importc, dynlib: SDLgfxLibName.} +proc filledTrigonRGBA*(dst: PSDL_Surface, x1: Sint16, y1: Sint16, x2: Sint16, + y2: Sint16, x3: Sint16, y3: Sint16, r: Uint8, g: Uint8, + b: Uint8, a: Uint8): int{.cdecl, importc, dynlib: SDLgfxLibName.} + # Polygon +proc polygonColor*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int, + color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.} +proc polygonRGBA*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int, r: Uint8, + g: Uint8, b: Uint8, a: Uint8): int{.cdecl, + importc, dynlib: SDLgfxLibName.} + # AA-Polygon +proc aapolygonColor*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int, + color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.} +proc aapolygonRGBA*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int, + r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl, + importc, dynlib: SDLgfxLibName.} + # Filled Polygon +proc filledPolygonColor*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int, + color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.} +proc filledPolygonRGBA*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int, + r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl, + importc, dynlib: SDLgfxLibName.} + # Bezier + # s = number of steps +proc bezierColor*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int, s: int, + color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.} +proc bezierRGBA*(dst: PSDL_Surface, vx: PSint16, vy: PSint16, n: int, s: int, + r: Uint8, g: Uint8, b: Uint8, a: Uint8): int{.cdecl, + importc, dynlib: SDLgfxLibName.} + # Characters/Strings +proc characterColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, c: char, + color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.} +proc characterRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, c: char, r: Uint8, + g: Uint8, b: Uint8, a: Uint8): int{.cdecl, + importc, dynlib: SDLgfxLibName.} +proc stringColor*(dst: PSDL_Surface, x: Sint16, y: Sint16, c: cstring, + color: Uint32): int{.cdecl, importc, dynlib: SDLgfxLibName.} +proc stringRGBA*(dst: PSDL_Surface, x: Sint16, y: Sint16, c: cstring, r: Uint8, + g: Uint8, b: Uint8, a: Uint8): int{.cdecl, + importc, dynlib: SDLgfxLibName.} +proc gfxPrimitivesSetFont*(fontdata: Pointer, cw: int, ch: int){.cdecl, + importc, dynlib: SDLgfxLibName.} + # + # + # SDL_imageFilter - bytes-image "filter" routines + # (uses inline x86 MMX optimizations if available) + # + # LGPL (c) A. Schiffler + # + # + # Comments: + # 1.) MMX functions work best if all data blocks are aligned on a 32 bytes boundary. + # 2.) Data that is not within an 8 byte boundary is processed using the C routine. + # 3.) Convolution routines do not have C routines at this time. + # Detect MMX capability in CPU +proc SDL_imageFilterMMXdetect*(): int{.cdecl, importc, dynlib: SDLgfxLibName.} + # Force use of MMX off (or turn possible use back on) +proc SDL_imageFilterMMXoff*(){.cdecl, importc, dynlib: SDLgfxLibName.} +proc SDL_imageFilterMMXon*(){.cdecl, importc, dynlib: SDLgfxLibName.} + # + # All routines return: + # 0 OK + # -1 Error (internal error, parameter error) + # + # SDL_imageFilterAdd: D = saturation255(S1 + S2) +proc SDL_imageFilterAdd*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{. + cdecl, importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterMean: D = S1/2 + S2/2 +proc SDL_imageFilterMean*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{. + cdecl, importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterSub: D = saturation0(S1 - S2) +proc SDL_imageFilterSub*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{. + cdecl, importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterAbsDiff: D = | S1 - S2 | +proc SDL_imageFilterAbsDiff*(Src1: cstring, Src2: cstring, Dest: cstring, + len: int): int{.cdecl, importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterMult: D = saturation(S1 * S2) +proc SDL_imageFilterMult*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{. + cdecl, importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterMultNor: D = S1 * S2 (non-MMX) +proc SDL_imageFilterMultNor*(Src1: cstring, Src2: cstring, Dest: cstring, + len: int): int{.cdecl, importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterMultDivby2: D = saturation255(S1/2 * S2) +proc SDL_imageFilterMultDivby2*(Src1: cstring, Src2: cstring, Dest: cstring, + len: int): int{.cdecl, importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterMultDivby4: D = saturation255(S1/2 * S2/2) +proc SDL_imageFilterMultDivby4*(Src1: cstring, Src2: cstring, Dest: cstring, + len: int): int{.cdecl, importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterBitAnd: D = S1 & S2 +proc SDL_imageFilterBitAnd*(Src1: cstring, Src2: cstring, Dest: cstring, + len: int): int{.cdecl, importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterBitOr: D = S1 | S2 +proc SDL_imageFilterBitOr*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{. + cdecl, importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterDiv: D = S1 / S2 (non-MMX) +proc SDL_imageFilterDiv*(Src1: cstring, Src2: cstring, Dest: cstring, len: int): int{. + cdecl, importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterBitNegation: D = !S +proc SDL_imageFilterBitNegation*(Src1: cstring, Dest: cstring, len: int): int{. + cdecl, importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterAddByte: D = saturation255(S + C) +proc SDL_imageFilterAddByte*(Src1: cstring, Dest: cstring, len: int, C: char): int{. + cdecl, importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterAddUint: D = saturation255(S + (uint)C) +proc SDL_imageFilterAddUint*(Src1: cstring, Dest: cstring, len: int, C: int): int{. + cdecl, importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterAddByteToHalf: D = saturation255(S/2 + C) +proc SDL_imageFilterAddByteToHalf*(Src1: cstring, Dest: cstring, len: int, + C: char): int{.cdecl, importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterSubByte: D = saturation0(S - C) +proc SDL_imageFilterSubByte*(Src1: cstring, Dest: cstring, len: int, C: char): int{. + cdecl, importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterSubUint: D = saturation0(S - (uint)C) +proc SDL_imageFilterSubUint*(Src1: cstring, Dest: cstring, len: int, C: int): int{. + cdecl, importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterShiftRight: D = saturation0(S >> N) +proc SDL_imageFilterShiftRight*(Src1: cstring, Dest: cstring, len: int, N: char): int{. + cdecl, importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterShiftRightUint: D = saturation0((uint)S >> N) +proc SDL_imageFilterShiftRightUint*(Src1: cstring, Dest: cstring, len: int, + N: char): int{.cdecl, importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterMultByByte: D = saturation255(S * C) +proc SDL_imageFilterMultByByte*(Src1: cstring, Dest: cstring, len: int, C: char): int{. + cdecl, importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterShiftRightAndMultByByte: D = saturation255((S >> N) * C) +proc SDL_imageFilterShiftRightAndMultByByte*(Src1: cstring, Dest: cstring, + len: int, N: char, C: char): int{.cdecl, importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterShiftLeftByte: D = (S << N) +proc SDL_imageFilterShiftLeftByte*(Src1: cstring, Dest: cstring, len: int, + N: char): int{.cdecl, importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterShiftLeftUint: D = ((uint)S << N) +proc SDL_imageFilterShiftLeftUint*(Src1: cstring, Dest: cstring, len: int, + N: char): int{.cdecl, importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterShiftLeft: D = saturation255(S << N) +proc SDL_imageFilterShiftLeft*(Src1: cstring, Dest: cstring, len: int, N: char): int{. + cdecl, importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterBinarizeUsingThreshold: D = S >= T ? 255:0 +proc SDL_imageFilterBinarizeUsingThreshold*(Src1: cstring, Dest: cstring, + len: int, T: char): int{.cdecl, importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterClipToRange: D = (S >= Tmin) & (S <= Tmax) 255:0 +proc SDL_imageFilterClipToRange*(Src1: cstring, Dest: cstring, len: int, + Tmin: int8, Tmax: int8): int{.cdecl, + importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterNormalizeLinear: D = saturation255((Nmax - Nmin)/(Cmax - Cmin)*(S - Cmin) + Nmin) +proc SDL_imageFilterNormalizeLinear*(Src1: cstring, Dest: cstring, len: int, + Cmin: int, Cmax: int, Nmin: int, Nmax: int): int{. + cdecl, importc, dynlib: SDLgfxLibName.} + # !!! NO C-ROUTINE FOR THESE FUNCTIONS YET !!! + # SDL_imageFilterConvolveKernel3x3Divide: Dij = saturation0and255( ... ) +proc SDL_imageFilterConvolveKernel3x3Divide*(Src: cstring, Dest: cstring, + rows: int, columns: int, Kernel: PShortInt, Divisor: int8): int{.cdecl, + importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterConvolveKernel5x5Divide: Dij = saturation0and255( ... ) +proc SDL_imageFilterConvolveKernel5x5Divide*(Src: cstring, Dest: cstring, + rows: int, columns: int, Kernel: PShortInt, Divisor: int8): int{.cdecl, + importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterConvolveKernel7x7Divide: Dij = saturation0and255( ... ) +proc SDL_imageFilterConvolveKernel7x7Divide*(Src: cstring, Dest: cstring, + rows: int, columns: int, Kernel: PShortInt, Divisor: int8): int{.cdecl, + importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterConvolveKernel9x9Divide: Dij = saturation0and255( ... ) +proc SDL_imageFilterConvolveKernel9x9Divide*(Src: cstring, Dest: cstring, + rows: int, columns: int, Kernel: PShortInt, Divisor: int8): int{.cdecl, + importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterConvolveKernel3x3ShiftRight: Dij = saturation0and255( ... ) +proc SDL_imageFilterConvolveKernel3x3ShiftRight*(Src: cstring, Dest: cstring, + rows: int, columns: int, Kernel: PShortInt, NRightShift: char): int{.cdecl, + importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterConvolveKernel5x5ShiftRight: Dij = saturation0and255( ... ) +proc SDL_imageFilterConvolveKernel5x5ShiftRight*(Src: cstring, Dest: cstring, + rows: int, columns: int, Kernel: PShortInt, NRightShift: char): int{.cdecl, + importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterConvolveKernel7x7ShiftRight: Dij = saturation0and255( ... ) +proc SDL_imageFilterConvolveKernel7x7ShiftRight*(Src: cstring, Dest: cstring, + rows: int, columns: int, Kernel: PShortInt, NRightShift: char): int{.cdecl, + importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterConvolveKernel9x9ShiftRight: Dij = saturation0and255( ... ) +proc SDL_imageFilterConvolveKernel9x9ShiftRight*(Src: cstring, Dest: cstring, + rows: int, columns: int, Kernel: PShortInt, NRightShift: char): int{.cdecl, + importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterSobelX: Dij = saturation255( ... ) +proc SDL_imageFilterSobelX*(Src: cstring, Dest: cstring, rows: int, columns: int): int{. + cdecl, importc, dynlib: SDLgfxLibName.} + # SDL_imageFilterSobelXShiftRight: Dij = saturation255( ... ) +proc SDL_imageFilterSobelXShiftRight*(Src: cstring, Dest: cstring, rows: int, + columns: int, NRightShift: char): int{. + cdecl, importc, dynlib: SDLgfxLibName.} + # Align/restore stack to 32 byte boundary -- Functionality untested! -- +proc SDL_imageFilterAlignStack*(){.cdecl, importc, dynlib: SDLgfxLibName.} +proc SDL_imageFilterRestoreStack*(){.cdecl, importc, dynlib: SDLgfxLibName.} + # + # + # SDL_rotozoom - rotozoomer + # + # LGPL (c) A. Schiffler + # + # + # + # + # rotozoomSurface() + # + # Rotates and zoomes a 32bit or 8bit 'src' surface to newly created 'dst' surface. + # 'angle' is the rotation in degrees. 'zoom' a scaling factor. If 'smooth' is 1 + # then the destination 32bit surface is anti-aliased. If the surface is not 8bit + # or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly. + # + # +proc rotozoomSurface*(src: PSDL_Surface, angle: float64, zoom: float64, + smooth: int): PSDL_Surface{.cdecl, importc, dynlib: SDLgfxLibName.} +proc rotozoomSurfaceXY*(src: PSDL_Surface, angle: float64, zoomx: float64, + zoomy: float64, smooth: int): PSDL_Surface{.cdecl, + importc, dynlib: SDLgfxLibName.} + # Returns the size of the target surface for a rotozoomSurface() call +proc rotozoomSurfaceSize*(width: int, height: int, angle: float64, + zoom: float64, dstwidth: var int, dstheight: var int){. + cdecl, importc, dynlib: SDLgfxLibName.} +proc rotozoomSurfaceSizeXY*(width: int, height: int, angle: float64, + zoomx: float64, zoomy: float64, dstwidth: var int, + dstheight: var int){.cdecl, importc, dynlib: SDLgfxLibName.} + # + # + # zoomSurface() + # + # Zoomes a 32bit or 8bit 'src' surface to newly created 'dst' surface. + # 'zoomx' and 'zoomy' are scaling factors for width and height. If 'smooth' is 1 + # then the destination 32bit surface is anti-aliased. If the surface is not 8bit + # or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly. + # + # +proc zoomSurface*(src: PSDL_Surface, zoomx: float64, zoomy: float64, smooth: int): PSDL_Surface{. + cdecl, importc, dynlib: SDLgfxLibName.} + # Returns the size of the target surface for a zoomSurface() call +proc zoomSurfaceSize*(width: int, height: int, zoomx: float64, zoomy: float64, + dstwidth: var int, dstheight: var int){.cdecl, + importc, dynlib: SDLgfxLibName.} +# implementation diff --git a/lib/base/sdl/sdl_image.nim b/lib/base/sdl/sdl_image.nim new file mode 100644 index 000000000..a15afd575 --- /dev/null +++ b/lib/base/sdl/sdl_image.nim @@ -0,0 +1,227 @@ + +# +# $Id: sdl_image.pas,v 1.14 2007/05/29 21:31:13 savage Exp $ +# +# +#****************************************************************************** +# +# Borland Delphi SDL_Image - An example image loading library for use +# with SDL +# Conversion of the Simple DirectMedia Layer Image Headers +# +# Portions created by Sam Lantinga <slouken@devolution.com> are +# Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga +# 5635-34 Springhouse Dr. +# Pleasanton, CA 94588 (USA) +# +# All Rights Reserved. +# +# The original files are : SDL_image.h +# +# The initial developer of this Pascal code was : +# Matthias Thoma <ma.thoma@gmx.de> +# +# Portions created by Matthias Thoma are +# Copyright (C) 2000 - 2001 Matthias Thoma. +# +# +# Contributor(s) +# -------------- +# Dominique Louis <Dominique@SavageSoftware.com.au> +# +# Obtained through: +# Joint Endeavour of Delphi Innovators ( Project JEDI ) +# +# You may retrieve the latest version of this file at the Project +# JEDI home page, located at http://delphi-jedi.org +# +# The contents of this file are used with permission, subject to +# the Mozilla Public License Version 1.1 (the "License"); you may +# not use this file except in compliance with the License. You may +# obtain a copy of the License at +# http://www.mozilla.org/MPL/MPL-1.1.html +# +# Software distributed under the License is distributed on an +# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# Description +# ----------- +# A simple library to load images of various formats as SDL surfaces +# +# Requires +# -------- +# SDL.pas in your search path. +# +# Programming Notes +# ----------------- +# See the Aliens Demo on how to make use of this libaray +# +# Revision History +# ---------------- +# April 02 2001 - MT : Initial Translation +# +# May 08 2001 - DL : Added ExternalSym derectives and copyright header +# +# April 03 2003 - DL : Added jedi-sdl.inc include file to support more +# Pascal compilers. Initial support is now included +# for GnuPascal, VirtualPascal, TMT and obviously +# continue support for Delphi Kylix and FreePascal. +# +# April 08 2003 - MK : Aka Mr Kroket - Added Better FPC support +# +# April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added +# better TMT Pascal support and under instruction +# from Prof. Abimbola Olowofoyeku (The African Chief), +# I have added better Gnu Pascal support +# +# April 30 2003 - DL : under instruction from David Mears AKA +# Jason Siletto, I have added FPC Linux support. +# This was compiled with fpc 1.1, so remember to set +# include file path. ie. -Fi/usr/share/fpcsrc/rtl/* +# +# +# $Log: sdl_image.pas,v $ +# Revision 1.14 2007/05/29 21:31:13 savage +# Changes as suggested by Almindor for 64bit compatibility. +# +# Revision 1.13 2007/05/20 20:30:54 savage +# Initial Changes to Handle 64 Bits +# +# Revision 1.12 2006/12/02 00:14:40 savage +# Updated to latest version +# +# Revision 1.11 2005/04/10 18:22:59 savage +# Changes as suggested by Michalis, thanks. +# +# Revision 1.10 2005/04/10 11:48:33 savage +# Changes as suggested by Michalis, thanks. +# +# Revision 1.9 2005/01/05 01:47:07 savage +# Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively. +# +# Revision 1.8 2005/01/04 23:14:44 savage +# Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively. +# +# Revision 1.7 2005/01/01 02:03:12 savage +# Updated to v1.2.4 +# +# Revision 1.6 2004/08/14 22:54:30 savage +# Updated so that Library name defines are correctly defined for MacOS X. +# +# Revision 1.5 2004/05/10 14:10:04 savage +# Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ). +# +# Revision 1.4 2004/04/13 09:32:08 savage +# Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary. +# +# Revision 1.3 2004/04/01 20:53:23 savage +# Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site. +# +# Revision 1.2 2004/03/30 20:23:28 savage +# Tidied up use of UNIX compiler directive. +# +# Revision 1.1 2004/02/14 23:35:42 savage +# version 1 of sdl_image, sdl_mixer and smpeg. +# +# +# +#****************************************************************************** + +import + sdl + +when defined(windows): + const SDL_ImageLibName = "SDL_Image.dll" +elif defined(macosx): + const SDL_ImageLibName = "libSDL_image-1.2.0.dylib" +else: + const SDL_ImageLibName = "libSDL_image.so" + +const + SDL_IMAGE_MAJOR_VERSION* = 1'i8 + SDL_IMAGE_MINOR_VERSION* = 2'i8 + SDL_IMAGE_PATCHLEVEL* = 5'i8 + +# This macro can be used to fill a version structure with the compile-time +# version of the SDL_image library. + +proc SDL_IMAGE_VERSION*(X: var TSDL_Version) + # This function gets the version of the dynamically linked SDL_image library. + # it should NOT be used to fill a version structure, instead you should + # use the SDL_IMAGE_VERSION() macro. + # +proc IMG_Linked_Version*(): PSDL_version{.importc, dynlib: SDL_ImageLibName.} + # Load an image from an SDL data source. + # The 'type' may be one of: "BMP", "GIF", "PNG", etc. + # + # If the image format supports a transparent pixel, SDL will set the + # colorkey for the surface. You can enable RLE acceleration on the + # surface afterwards by calling: + # SDL_SetColorKey(image, SDL_RLEACCEL, image.format.colorkey); + # +proc IMG_LoadTyped_RW*(src: PSDL_RWops, freesrc: int, theType: cstring): PSDL_Surface{. + cdecl, importc, dynlib: SDL_ImageLibName.} + # Convenience functions +proc IMG_Load*(theFile: cstring): PSDL_Surface{.cdecl, importc, dynlib: SDL_ImageLibName.} +proc IMG_Load_RW*(src: PSDL_RWops, freesrc: int): PSDL_Surface{.cdecl, + importc, dynlib: SDL_ImageLibName.} + # Invert the alpha of a surface for use with OpenGL + # This function is now a no-op, and only provided for backwards compatibility. +proc IMG_InvertAlpha*(theOn: int): int{.cdecl, importc, dynlib: SDL_ImageLibName.} + # Functions to detect a file type, given a seekable source +proc IMG_isBMP*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.} +proc IMG_isGIF*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.} +proc IMG_isJPG*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.} +proc IMG_isLBM*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.} +proc IMG_isPCX*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.} +proc IMG_isPNG*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.} +proc IMG_isPNM*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.} +proc IMG_isTIF*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.} +proc IMG_isXCF*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.} +proc IMG_isXPM*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.} +proc IMG_isXV*(src: PSDL_RWops): int{.cdecl, importc, dynlib: SDL_ImageLibName.} + # Individual loading functions +proc IMG_LoadBMP_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl, + importc, dynlib: SDL_ImageLibName.} +proc IMG_LoadGIF_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl, + importc, dynlib: SDL_ImageLibName.} +proc IMG_LoadJPG_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl, + importc, dynlib: SDL_ImageLibName.} +proc IMG_LoadLBM_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl, + importc, dynlib: SDL_ImageLibName.} +proc IMG_LoadPCX_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl, + importc, dynlib: SDL_ImageLibName.} +proc IMG_LoadPNM_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl, + importc, dynlib: SDL_ImageLibName.} +proc IMG_LoadPNG_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl, + importc, dynlib: SDL_ImageLibName.} +proc IMG_LoadTGA_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl, + importc, dynlib: SDL_ImageLibName.} +proc IMG_LoadTIF_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl, + importc, dynlib: SDL_ImageLibName.} +proc IMG_LoadXCF_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl, + importc, dynlib: SDL_ImageLibName.} +proc IMG_LoadXPM_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl, + importc, dynlib: SDL_ImageLibName.} +proc IMG_LoadXV_RW*(src: PSDL_RWops): PSDL_Surface{.cdecl, + importc, dynlib: SDL_ImageLibName.} +proc IMG_ReadXPMFromArray*(xpm: cstringArray): PSDL_Surface{.cdecl, + importc, dynlib: SDL_ImageLibName.} + # Error Macros + # We'll use SDL for reporting errors +proc IMG_SetError*(fmt: cstring) +proc IMG_GetError*(): cstring +# implementation + +proc SDL_IMAGE_VERSION(X: var TSDL_Version) = + X.major = SDL_IMAGE_MAJOR_VERSION + X.minor = SDL_IMAGE_MINOR_VERSION + X.patch = SDL_IMAGE_PATCHLEVEL + +proc IMG_SetError(fmt: cstring) = + SDL_SetError(fmt) + +proc IMG_GetError(): cstring = + result = SDL_GetError() diff --git a/lib/base/sdl/sdl_mixer.nim b/lib/base/sdl/sdl_mixer.nim new file mode 100644 index 000000000..b5dd91dfa --- /dev/null +++ b/lib/base/sdl/sdl_mixer.nim @@ -0,0 +1,742 @@ + +#****************************************************************************** +# +# $Id: sdl_mixer.pas,v 1.18 2007/05/29 21:31:44 savage Exp $ +# +# +# +# Borland Delphi SDL_Mixer - Simple DirectMedia Layer Mixer Library +# Conversion of the Simple DirectMedia Layer Headers +# +# Portions created by Sam Lantinga <slouken@devolution.com> are +# Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga +# 5635-34 Springhouse Dr. +# Pleasanton, CA 94588 (USA) +# +# All Rights Reserved. +# +# The original files are : SDL_mixer.h +# music_cmd.h +# wavestream.h +# timidity.h +# playmidi.h +# music_ogg.h +# mikmod.h +# +# The initial developer of this Pascal code was : +# Dominqiue Louis <Dominique@SavageSoftware.com.au> +# +# Portions created by Dominqiue Louis are +# Copyright (C) 2000 - 2001 Dominqiue Louis. +# +# +# Contributor(s) +# -------------- +# Matthias Thoma <ma.thoma@gmx.de> +# +# Obtained through: +# Joint Endeavour of Delphi Innovators ( Project JEDI ) +# +# You may retrieve the latest version of this file at the Project +# JEDI home page, located at http://delphi-jedi.org +# +# The contents of this file are used with permission, subject to +# the Mozilla Public License Version 1.1 (the "License"); you may +# not use this file except in compliance with the License. You may +# obtain a copy of the License at +# http://www.mozilla.org/MPL/MPL-1.1.html +# +# Software distributed under the License is distributed on an +# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# Description +# ----------- +# +# +# +# +# +# +# +# Requires +# -------- +# SDL.pas & SMPEG.pas somewhere within your search path. +# +# Programming Notes +# ----------------- +# See the Aliens Demo to see how this library is used +# +# Revision History +# ---------------- +# April 02 2001 - DL : Initial Translation +# +# February 02 2002 - DL : Update to version 1.2.1 +# +# April 03 2003 - DL : Added jedi-sdl.inc include file to support more +# Pascal compilers. Initial support is now included +# for GnuPascal, VirtualPascal, TMT and obviously +# continue support for Delphi Kylix and FreePascal. +# +# April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added +# better TMT Pascal support and under instruction +# from Prof. Abimbola Olowofoyeku (The African Chief), +# I have added better Gnu Pascal support +# +# April 30 2003 - DL : under instruction from David Mears AKA +# Jason Siletto, I have added FPC Linux support. +# This was compiled with fpc 1.1, so remember to set +# include file path. ie. -Fi/usr/share/fpcsrc/rtl/* +# +# +# $Log: sdl_mixer.pas,v $ +# Revision 1.18 2007/05/29 21:31:44 savage +# Changes as suggested by Almindor for 64bit compatibility. +# +# Revision 1.17 2007/05/20 20:31:17 savage +# Initial Changes to Handle 64 Bits +# +# Revision 1.16 2006/12/02 00:16:17 savage +# Updated to latest version +# +# Revision 1.15 2005/04/10 11:48:33 savage +# Changes as suggested by Michalis, thanks. +# +# Revision 1.14 2005/02/24 20:20:07 savage +# Changed definition of MusicType and added GetMusicType function +# +# Revision 1.13 2005/01/05 01:47:09 savage +# Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively. +# +# Revision 1.12 2005/01/04 23:14:56 savage +# Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively. +# +# Revision 1.11 2005/01/01 02:05:19 savage +# Updated to v1.2.6 +# +# Revision 1.10 2004/09/12 21:45:17 savage +# Robert Reed spotted that Mix_SetMusicPosition was missing from the conversion, so this has now been added. +# +# Revision 1.9 2004/08/27 21:48:24 savage +# IFDEFed out Smpeg support on MacOS X +# +# Revision 1.8 2004/08/14 22:54:30 savage +# Updated so that Library name defines are correctly defined for MacOS X. +# +# Revision 1.7 2004/05/10 14:10:04 savage +# Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ). +# +# Revision 1.6 2004/04/13 09:32:08 savage +# Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary. +# +# Revision 1.5 2004/04/01 20:53:23 savage +# Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site. +# +# Revision 1.4 2004/03/31 22:20:02 savage +# Windows unit not used in this file, so it was removed to keep the code tidy. +# +# Revision 1.3 2004/03/31 10:05:08 savage +# Better defines for Endianess under FreePascal and Borland compilers. +# +# Revision 1.2 2004/03/30 20:23:28 savage +# Tidied up use of UNIX compiler directive. +# +# Revision 1.1 2004/02/14 23:35:42 savage +# version 1 of sdl_image, sdl_mixer and smpeg. +# +# +# +#****************************************************************************** + +import + sdl, smpeg + +when defined(windows): + const SDL_MixerLibName = "SDL_mixer.dll" +elif defined(macosx): + const SDL_MixerLibName = "libSDL_mixer-1.2.0.dylib" +else: + const SDL_MixerLibName = "libSDL_mixer.so" + +const + SDL_MIXER_MAJOR_VERSION* = 1'i8 + SDL_MIXER_MINOR_VERSION* = 2'i8 + SDL_MIXER_PATCHLEVEL* = 7'i8 # Backwards compatibility + MIX_MAJOR_VERSION* = SDL_MIXER_MAJOR_VERSION + MIX_MINOR_VERSION* = SDL_MIXER_MINOR_VERSION + MIX_PATCHLEVEL* = SDL_MIXER_PATCHLEVEL # SDL_Mixer.h constants + # The default mixer has 8 simultaneous mixing channels + MIX_CHANNELS* = 8 # Good default values for a PC soundcard + MIX_DEFAULT_FREQUENCY* = 22050 + +when defined(IA32): + const + MIX_DEFAULT_FORMAT* = AUDIO_S16LSB +else: + const + MIX_DEFAULT_FORMAT* = AUDIO_S16MSB +const + MIX_DEFAULT_CHANNELS* = 2 + MIX_MAX_VOLUME* = 128 # Volume of a chunk + PATH_MAX* = 255 # mikmod.h constants + #* + # * Library version + # * + LIBMIKMOD_VERSION_MAJOR* = 3 + LIBMIKMOD_VERSION_MINOR* = 1 + LIBMIKMOD_REVISION* = 8 + LIBMIKMOD_VERSION* = ((LIBMIKMOD_VERSION_MAJOR shl 16) or + (LIBMIKMOD_VERSION_MINOR shl 8) or (LIBMIKMOD_REVISION)) + +type #music_cmd.h types + PMusicCMD* = ptr TMusicCMD + TMusicCMD*{.final.} = object #wavestream.h types + filename*: array[0..PATH_MAX - 1, char] + cmd*: array[0..PATH_MAX - 1, char] + pid*: TSYS_ThreadHandle + + PWAVStream* = ptr TWAVStream + TWAVStream*{.final.} = object #playmidi.h types + wavefp*: Pointer + start*: int32 + stop*: int32 + cvt*: TSDL_AudioCVT + + PMidiEvent* = ptr TMidiEvent + TMidiEvent*{.final.} = object + time*: int32 + channel*: uint8 + type_*: uint8 + a*: uint8 + b*: uint8 + + PMidiSong* = ptr TMidiSong + TMidiSong*{.final.} = object #music_ogg.h types + samples*: int32 + events*: PMidiEvent + + POGG_Music* = ptr TOGG_Music + TOGG_Music*{.final.} = object # mikmod.h types + #* + # * Error codes + # * + playing*: int + volume*: int #vf: OggVorbis_File; + section*: int + cvt*: TSDL_AudioCVT + len_available*: int + snd_available*: PUint8 + + TErrorEnum* = enum + MMERR_OPENING_FILE, MMERR_OUT_OF_MEMORY, MMERR_DYNAMIC_LINKING, + MMERR_SAMPLE_TOO_BIG, MMERR_OUT_OF_HANDLES, MMERR_UNKNOWN_WAVE_TYPE, + MMERR_LOADING_PATTERN, MMERR_LOADING_TRACK, MMERR_LOADING_HEADER, + MMERR_LOADING_SAMPLEINFO, MMERR_NOT_A_MODULE, MMERR_NOT_A_STREAM, + MMERR_MED_SYNTHSAMPLES, MMERR_ITPACK_INVALID_DATA, MMERR_DETECTING_DEVICE, + MMERR_INVALID_DEVICE, MMERR_INITIALIZING_MIXER, MMERR_OPENING_AUDIO, + MMERR_8BIT_ONLY, MMERR_16BIT_ONLY, MMERR_STEREO_ONLY, MMERR_ULAW, + MMERR_NON_BLOCK, MMERR_AF_AUDIO_PORT, MMERR_AIX_CONFIG_INIT, + MMERR_AIX_CONFIG_CONTROL, MMERR_AIX_CONFIG_START, MMERR_GUS_SETTINGS, + MMERR_GUS_RESET, MMERR_GUS_TIMER, MMERR_HP_SETSAMPLESIZE, MMERR_HP_SETSPEED, + MMERR_HP_CHANNELS, MMERR_HP_AUDIO_OUTPUT, MMERR_HP_AUDIO_DESC, + MMERR_HP_BUFFERSIZE, MMERR_OSS_SETFRAGMENT, MMERR_OSS_SETSAMPLESIZE, + MMERR_OSS_SETSTEREO, MMERR_OSS_SETSPEED, MMERR_SGI_SPEED, MMERR_SGI_16BIT, + MMERR_SGI_8BIT, MMERR_SGI_STEREO, MMERR_SGI_MONO, MMERR_SUN_INIT, + MMERR_OS2_MIXSETUP, MMERR_OS2_SEMAPHORE, MMERR_OS2_TIMER, MMERR_OS2_THREAD, + MMERR_DS_PRIORITY, MMERR_DS_BUFFER, MMERR_DS_FORMAT, MMERR_DS_NOTIFY, + MMERR_DS_EVENT, MMERR_DS_THREAD, MMERR_DS_UPDATE, MMERR_WINMM_HANDLE, + MMERR_WINMM_ALLOCATED, MMERR_WINMM_DEVICEID, MMERR_WINMM_FORMAT, + MMERR_WINMM_UNKNOWN, MMERR_MAC_SPEED, MMERR_MAC_START, MMERR_MAX + PMODULE* = ptr TMODULE + TMODULE*{.final.} = object + PUNIMOD* = ptr TUNIMOD + TUNIMOD* = TMODULE #SDL_mixer.h types + # The internal format for an audio chunk + PMix_Chunk* = ptr TMix_Chunk + TMix_Chunk*{.final.} = object + allocated*: int + abuf*: PUint8 + alen*: Uint32 + volume*: Uint8 # Per-sample volume, 0-128 + + Mix_Chunk* = TMix_Chunk # The different fading types supported + TMix_Fading* = enum + MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN + Mix_Fading* = TMix_Fading + TMix_MusicType* = enum + MUS_NONE, MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG, MUS_MP3 + Mix_MusicType* = TMix_MusicType # + # TMusicUnion = record + # case XXX: Byte of + # 0 : ( cmd : PMusicCMD ); + # 1 : ( wave : PWAVStream ); + # 2 : ( module : PUNIMOD ); + # 3 : ( midi : TMidiSong ); + # 4 : ( ogg : POGG_music ); + # {$IFNDEF DARWIN} + # 5 : ( mp3 : PSMPEG ); + # {$ENDIF} + # end; + PMix_Music* = ptr TMix_Music + TMix_Music*{.final.} = object # The internal format for a music chunk interpreted via mikmod + type_*: TMix_MusicType # other fields are not aviable + # data : TMusicUnion; + # fading : TMix_Fading; + # fade_volume : integer; + # fade_step : integer; + # fade_steps : integer; + # error : integer; + + TMixFunction* = proc (udata: Pointer, stream: PUint8, length: int): Pointer{. + cdecl.} # This macro can be used to fill a version structure with the compile-time + # version of the SDL_mixer library. + +proc SDL_MIXER_VERSION*(X: var TSDL_Version) + # This function gets the version of the dynamically linked SDL_mixer library. + # It should NOT be used to fill a version structure, instead you should use the + # SDL_MIXER_VERSION() macro. +proc Mix_Linked_Version*(): PSDL_version{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Open the mixer with a certain audio format +proc Mix_OpenAudio*(frequency: int, format: Uint16, channels: int, + chunksize: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Dynamically change the number of channels managed by the mixer. + # If decreasing the number of channels, the upper channels are + # stopped. + # This function returns the new number of allocated channels. + # +proc Mix_AllocateChannels*(numchannels: int): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} + # Find out what the actual audio device parameters are. + # This function returns 1 if the audio has been opened, 0 otherwise. + # +proc Mix_QuerySpec*(frequency: var int, format: var Uint16, channels: var int): int{. + cdecl, importc, dynlib: SDL_MixerLibName.} + # Load a wave file or a music (.mod .s3m .it .xm) file +proc Mix_LoadWAV_RW*(src: PSDL_RWops, freesrc: int): PMix_Chunk{.cdecl, + importc, dynlib: SDL_MixerLibName.} +proc Mix_LoadWAV*(filename: cstring): PMix_Chunk +proc Mix_LoadMUS*(filename: cstring): PMix_Music{.cdecl, + importc, dynlib: SDL_MixerLibName.} + ##if 0 { This hasn't been hooked into music.c yet } + #{ Load a music file from an SDL_RWop object (MikMod-specific currently) + # Matt Campbell (matt@campbellhome.dhs.org) April 2000 } + #function Mix_LoadMUS_RW(SDL_RWops *rw) : PMix_Music; cdecl; + ##endif + # Load a wave file of the mixer format from a memory buffer +proc Mix_QuickLoad_WAV*(mem: PUint8): PMix_Chunk{.cdecl, + importc, dynlib: SDL_MixerLibName.} + # Free an audio chunk previously loaded +proc Mix_FreeChunk*(chunk: PMix_Chunk){.cdecl, importc, dynlib: SDL_MixerLibName.} +proc Mix_FreeMusic*(music: PMix_Music){.cdecl, importc, dynlib: SDL_MixerLibName.} + # Find out the music format of a mixer music, or the currently playing + # music, if 'music' is NULL. +proc Mix_GetMusicType*(music: PMix_Music): TMix_MusicType{.cdecl, + importc, dynlib: SDL_MixerLibName.} + # Set a function that is called after all mixing is performed. + # This can be used to provide real-time visual display of the audio stream + # or add a custom mixer filter for the stream data. + # +proc Mix_SetPostMix*(mix_func: TMixFunction, arg: Pointer){.cdecl, + importc, dynlib: SDL_MixerLibName.} + # Add your own music player or additional mixer function. + # If 'mix_func' is NULL, the default music player is re-enabled. + # +proc Mix_HookMusic*(mix_func: TMixFunction, arg: Pointer){.cdecl, + importc, dynlib: SDL_MixerLibName.} + # Add your own callback when the music has finished playing. + # +proc Mix_HookMusicFinished*(music_finished: Pointer){.cdecl, + importc, dynlib: SDL_MixerLibName.} + # Get a pointer to the user data for the current music hook +proc Mix_GetMusicHookData*(): Pointer{.cdecl, importc, dynlib: SDL_MixerLibName.} + #* Add your own callback when a channel has finished playing. NULL + # * to disable callback.* +type + TChannel_finished* = proc (channel: int){.cdecl.} + +proc Mix_ChannelFinished*(channel_finished: TChannel_finished){.cdecl, + importc, dynlib: SDL_MixerLibName.} +const + MIX_CHANNEL_POST* = - 2 + # This is the format of a special effect callback: + # myeffect(int chan, void *stream, int len, void *udata); + # + # (chan) is the channel number that your effect is affecting. (stream) is + # the buffer of data to work upon. (len) is the size of (stream), and + # (udata) is a user-defined bit of data, which you pass as the last arg of + # Mix_RegisterEffect(), and is passed back unmolested to your callback. + # Your effect changes the contents of (stream) based on whatever parameters + # are significant, or just leaves it be, if you prefer. You can do whatever + # you like to the buffer, though, and it will continue in its changed state + # down the mixing pipeline, through any other effect functions, then finally + # to be mixed with the rest of the channels and music for the final output + # stream. + # + +type + TMix_EffectFunc* = proc (chan: int, stream: Pointer, length: int, + udata: Pointer): Pointer{.cdecl.} + # * This is a callback that signifies that a channel has finished all its + # * loops and has completed playback. This gets called if the buffer + # * plays out normally, or if you call Mix_HaltChannel(), implicitly stop + # * a channel via Mix_AllocateChannels(), or unregister a callback while + # * it's still playing. + TMix_EffectDone* = proc (chan: int, udata: Pointer): Pointer{.cdecl.} + #* Register a special effect function. At mixing time, the channel data is + # * copied into a buffer and passed through each registered effect function. + # * After it passes through all the functions, it is mixed into the final + # * output stream. The copy to buffer is performed once, then each effect + # * function performs on the output of the previous effect. Understand that + # * this extra copy to a buffer is not performed if there are no effects + # * registered for a given chunk, which saves CPU cycles, and any given + # * effect will be extra cycles, too, so it is crucial that your code run + # * fast. Also note that the data that your function is given is in the + # * format of the sound device, and not the format you gave to Mix_OpenAudio(), + # * although they may in reality be the same. This is an unfortunate but + # * necessary speed concern. Use Mix_QuerySpec() to determine if you can + # * handle the data before you register your effect, and take appropriate + # * actions. + # * You may also specify a callback (Mix_EffectDone_t) that is called when + # * the channel finishes playing. This gives you a more fine-grained control + # * than Mix_ChannelFinished(), in case you need to free effect-specific + # * resources, etc. If you don't need this, you can specify NULL. + # * You may set the callbacks before or after calling Mix_PlayChannel(). + # * Things like Mix_SetPanning() are just internal special effect functions, + # * so if you are using that, you've already incurred the overhead of a copy + # * to a separate buffer, and that these effects will be in the queue with + # * any functions you've registered. The list of registered effects for a + # * channel is reset when a chunk finishes playing, so you need to explicitly + # * set them with each call to Mix_PlayChannel*(). + # * You may also register a special effect function that is to be run after + # * final mixing occurs. The rules for these callbacks are identical to those + # * in Mix_RegisterEffect, but they are run after all the channels and the + # * music have been mixed into a single stream, whereas channel-specific + # * effects run on a given channel before any other mixing occurs. These + # * global effect callbacks are call "posteffects". Posteffects only have + # * their Mix_EffectDone_t function called when they are unregistered (since + # * the main output stream is never "done" in the same sense as a channel). + # * You must unregister them manually when you've had enough. Your callback + # * will be told that the channel being mixed is (MIX_CHANNEL_POST) if the + # * processing is considered a posteffect. + # * + # * After all these effects have finished processing, the callback registered + # * through Mix_SetPostMix() runs, and then the stream goes to the audio + # * device. + # * + # * returns zero if error (no such channel), nonzero if added. + # * Error messages can be retrieved from Mix_GetError(). + # * + +proc Mix_RegisterEffect*(chan: int, f: TMix_EffectFunc, d: TMix_EffectDone, + arg: Pointer): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + #* You may not need to call this explicitly, unless you need to stop an + # * effect from processing in the middle of a chunk's playback. + # * Posteffects are never implicitly unregistered as they are for channels, + # * but they may be explicitly unregistered through this function by + # * specifying MIX_CHANNEL_POST for a channel. + # * returns zero if error (no such channel or effect), nonzero if removed. + # * Error messages can be retrieved from Mix_GetError(). + # * +proc Mix_UnregisterEffect*(channel: int, f: TMix_EffectFunc): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} + #* You may not need to call this explicitly, unless you need to stop all + # * effects from processing in the middle of a chunk's playback. Note that + # * this will also shut off some internal effect processing, since + # * Mix_SetPanning( ) and others may use this API under the hood.This is + # * called internally when a channel completes playback. + # * Posteffects are never implicitly unregistered as they are for channels, + # * but they may be explicitly unregistered through this function by + # * specifying MIX_CHANNEL_POST for a channel. + # * returns zero if error( no such channel ), nonzero if all effects removed. + # * Error messages can be retrieved from Mix_GetError( ). + # * +proc Mix_UnregisterAllEffects*(channel: int): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} +const + MIX_EFFECTSMAXSPEED* = "MIX_EFFECTSMAXSPEED" + # * These are the internally - defined mixing effects.They use the same API that + # * effects defined in the application use, but are provided here as a + # * convenience.Some effects can reduce their quality or use more memory in + # * the name of speed; to enable this, make sure the environment variable + # * MIX_EFFECTSMAXSPEED( see above ) is defined before you call + # * Mix_OpenAudio( ). + # * + #* set the panning of a channel.The left and right channels are specified + # * as integers between 0 and 255, quietest to loudest, respectively. + # * + # * Technically, this is just individual volume control for a sample with + # * two( stereo )channels, so it can be used for more than just panning. + # * if you want real panning, call it like this : + # * + # * Mix_SetPanning( channel, left, 255 - left ); + # * + # * ...which isn't so hard. + # * + # * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and + # * the panning will be done to the final mixed stream before passing it on + # * to the audio device. + # * + # * This uses the Mix_RegisterEffect( )API internally, and returns without + # * registering the effect function if the audio device is not configured + # * for stereo output.Setting both( left ) and ( right ) to 255 causes this + # * effect to be unregistered, since that is the data's normal state. + # * + # * returns zero if error( no such channel or Mix_RegisterEffect( )fails ), + # * nonzero if panning effect enabled.Note that an audio device in mono + # * mode is a no - op, but this call will return successful in that case . + # * Error messages can be retrieved from Mix_GetError( ). + # * + +proc Mix_SetPanning*(channel: int, left: Uint8, right: Uint8): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} + # * set the position ofa channel.( angle ) is an integer from 0 to 360, that + # * specifies the location of the sound in relation to the listener.( angle ) + # * will be reduced as neccesary( 540 becomes 180 degrees, -100 becomes 260 ). + # * Angle 0 is due north, and rotates clockwise as the value increases. + # * for efficiency, the precision of this effect may be limited( angles 1 + # * through 7 might all produce the same effect, 8 through 15 are equal, etc ). + # * ( distance ) is an integer between 0 and 255 that specifies the space + # * between the sound and the listener.The larger the number, the further + # * away the sound is .Using 255 does not guarantee that the channel will be + # * culled from the mixing process or be completely silent.For efficiency, + # * the precision of this effect may be limited( distance 0 through 5 might + # * all produce the same effect, 6 through 10 are equal, etc ).Setting( angle ) + # * and ( distance ) to 0 unregisters this effect, since the data would be + # * unchanged. + # * + # * if you need more precise positional audio, consider using OpenAL for + # * spatialized effects instead of SDL_mixer.This is only meant to be a + # * basic effect for simple "3D" games. + # * + # * if the audio device is configured for mono output, then you won't get + # * any effectiveness from the angle; however, distance attenuation on the + # * channel will still occur.While this effect will function with stereo + # * voices, it makes more sense to use voices with only one channel of sound, + # * so when they are mixed through this effect, the positioning will sound + # * correct.You can convert them to mono through SDL before giving them to + # * the mixer in the first place if you like. + # * + # * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and + # * the positioning will be done to the final mixed stream before passing it + # * on to the audio device. + # * + # * This is a convenience wrapper over Mix_SetDistance( ) and Mix_SetPanning( ). + # * + # * returns zero if error( no such channel or Mix_RegisterEffect( )fails ), + # * nonzero if position effect is enabled. + # * Error messages can be retrieved from Mix_GetError( ). + # * +proc Mix_SetPosition*(channel: int, angle: Sint16, distance: Uint8): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} + #* set the "distance" of a channel.( distance ) is an integer from 0 to 255 + # * that specifies the location of the sound in relation to the listener. + # * Distance 0 is overlapping the listener, and 255 is as far away as possible + # * A distance of 255 does not guarantee silence; in such a case , you might + # * want to try changing the chunk's volume, or just cull the sample from the + # * mixing process with Mix_HaltChannel( ). + # * for efficiency, the precision of this effect may be limited( distances 1 + # * through 7 might all produce the same effect, 8 through 15 are equal, etc ). + # * ( distance ) is an integer between 0 and 255 that specifies the space + # * between the sound and the listener.The larger the number, the further + # * away the sound is . + # * Setting( distance ) to 0 unregisters this effect, since the data would be + # * unchanged. + # * if you need more precise positional audio, consider using OpenAL for + # * spatialized effects instead of SDL_mixer.This is only meant to be a + # * basic effect for simple "3D" games. + # * + # * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and + # * the distance attenuation will be done to the final mixed stream before + # * passing it on to the audio device. + # * + # * This uses the Mix_RegisterEffect( )API internally. + # * + # * returns zero if error( no such channel or Mix_RegisterEffect( )fails ), + # * nonzero if position effect is enabled. + # * Error messages can be retrieved from Mix_GetError( ). + # * +proc Mix_SetDistance*(channel: int, distance: Uint8): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} + # * + # * !!! FIXME : Haven't implemented, since the effect goes past the + # * end of the sound buffer.Will have to think about this. + # * - -ryan. + # * / + # { if 0 + # { * Causes an echo effect to be mixed into a sound.( echo ) is the amount + # * of echo to mix.0 is no echo, 255 is infinite( and probably not + # * what you want ). + # * + # * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and + # * the reverbing will be done to the final mixed stream before passing it on + # * to the audio device. + # * + # * This uses the Mix_RegisterEffect( )API internally.If you specify an echo + # * of zero, the effect is unregistered, as the data is already in that state. + # * + # * returns zero if error( no such channel or Mix_RegisterEffect( )fails ), + # * nonzero if reversing effect is enabled. + # * Error messages can be retrieved from Mix_GetError( ). + # * + # extern no_parse_DECLSPEC int Mix_SetReverb( int channel, Uint8 echo ); + # #E ndif + # * Causes a channel to reverse its stereo.This is handy if the user has his + # * speakers hooked up backwards, or you would like to have a minor bit of + # * psychedelia in your sound code. : )Calling this function with ( flip ) + # * set to non - zero reverses the chunks's usual channels. If (flip) is zero, + # * the effect is unregistered. + # * + # * This uses the Mix_RegisterEffect( )API internally, and thus is probably + # * more CPU intensive than having the user just plug in his speakers + # * correctly.Mix_SetReverseStereo( )returns without registering the effect + # * function if the audio device is not configured for stereo output. + # * + # * if you specify MIX_CHANNEL_POST for ( channel ), then this the effect is used + # * on the final mixed stream before sending it on to the audio device( a + # * posteffect ). + # * + # * returns zero if error( no such channel or Mix_RegisterEffect( )fails ), + # * nonzero if reversing effect is enabled.Note that an audio device in mono + # * mode is a no - op, but this call will return successful in that case . + # * Error messages can be retrieved from Mix_GetError( ). + # * +proc Mix_SetReverseStereo*(channel: int, flip: int): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} + # end of effects API. - -ryan. * + # Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate + # them dynamically to the next sample if requested with a -1 value below. + # Returns the number of reserved channels. + # +proc Mix_ReserveChannels*(num: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Channel grouping functions + # Attach a tag to a channel. A tag can be assigned to several mixer + # channels, to form groups of channels. + # If 'tag' is -1, the tag is removed (actually -1 is the tag used to + # represent the group of all the channels). + # Returns true if everything was OK. + # +proc Mix_GroupChannel*(which: int, tag: int): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} + # Assign several consecutive channels to a group +proc Mix_GroupChannels*(`from`: int, `to`: int, tag: int): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} + # Finds the first available channel in a group of channels +proc Mix_GroupAvailable*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Returns the number of channels in a group. This is also a subtle + # way to get the total number of channels when 'tag' is -1 + # +proc Mix_GroupCount*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Finds the "oldest" sample playing in a group of channels +proc Mix_GroupOldest*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Finds the "most recent" (i.e. last) sample playing in a group of channels +proc Mix_GroupNewer*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # The same as above, but the sound is played at most 'ticks' milliseconds +proc Mix_PlayChannelTimed*(channel: int, chunk: PMix_Chunk, loops: int, + ticks: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Play an audio chunk on a specific channel. + # If the specified channel is -1, play on the first free channel. + # If 'loops' is greater than zero, loop the sound that many times. + # If 'loops' is -1, loop inifinitely (~65000 times). + # Returns which channel was used to play the sound. + # +proc Mix_PlayChannel*(channel: int, chunk: PMix_Chunk, loops: int): int +proc Mix_PlayMusic*(music: PMix_Music, loops: int): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} + # Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions +proc Mix_FadeInMusic*(music: PMix_Music, loops: int, ms: int): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} +proc Mix_FadeInChannelTimed*(channel: int, chunk: PMix_Chunk, loops: int, + ms: int, ticks: int): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} +proc Mix_FadeInChannel*(channel: int, chunk: PMix_Chunk, loops: int, ms: int): int + # Set the volume in the range of 0-128 of a specific channel or chunk. + # If the specified channel is -1, set volume for all channels. + # Returns the original volume. + # If the specified volume is -1, just return the current volume. + # +proc Mix_Volume*(channel: int, volume: int): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} +proc Mix_VolumeChunk*(chunk: PMix_Chunk, volume: int): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} +proc Mix_VolumeMusic*(volume: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Halt playing of a particular channel +proc Mix_HaltChannel*(channel: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} +proc Mix_HaltGroup*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} +proc Mix_HaltMusic*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Change the expiration delay for a particular channel. + # The sample will stop playing after the 'ticks' milliseconds have elapsed, + # or remove the expiration if 'ticks' is -1 + # +proc Mix_ExpireChannel*(channel: int, ticks: int): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} + # Halt a channel, fading it out progressively till it's silent + # The ms parameter indicates the number of milliseconds the fading + # will take. + # +proc Mix_FadeOutChannel*(which: int, ms: int): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} +proc Mix_FadeOutGroup*(tag: int, ms: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} +proc Mix_FadeOutMusic*(ms: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Query the fading status of a channel +proc Mix_FadingMusic*(): TMix_Fading{.cdecl, importc, dynlib: SDL_MixerLibName.} +proc Mix_FadingChannel*(which: int): TMix_Fading{.cdecl, + importc, dynlib: SDL_MixerLibName.} + # Pause/Resume a particular channel +proc Mix_Pause*(channel: int){.cdecl, importc, dynlib: SDL_MixerLibName.} +proc Mix_Resume*(channel: int){.cdecl, importc, dynlib: SDL_MixerLibName.} +proc Mix_Paused*(channel: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Pause/Resume the music stream +proc Mix_PauseMusic*(){.cdecl, importc, dynlib: SDL_MixerLibName.} +proc Mix_ResumeMusic*(){.cdecl, importc, dynlib: SDL_MixerLibName.} +proc Mix_RewindMusic*(){.cdecl, importc, dynlib: SDL_MixerLibName.} +proc Mix_PausedMusic*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Set the current position in the music stream. + # This returns 0 if successful, or -1 if it failed or isn't implemented. + # This function is only implemented for MOD music formats (set pattern + # order number) and for OGG music (set position in seconds), at the + # moment. + # +proc Mix_SetMusicPosition*(position: float64): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} + # Check the status of a specific channel. + # If the specified channel is -1, check all channels. + # +proc Mix_Playing*(channel: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} +proc Mix_PlayingMusic*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Stop music and set external music playback command +proc Mix_SetMusicCMD*(command: cstring): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Synchro value is set by MikMod from modules while playing +proc Mix_SetSynchroValue*(value: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} +proc Mix_GetSynchroValue*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # + # Get the Mix_Chunk currently associated with a mixer channel + # Returns nil if it's an invalid channel, or there's no chunk associated. + # +proc Mix_GetChunk*(channel: int): PMix_Chunk{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Close the mixer, halting all playing audio +proc Mix_CloseAudio*(){.cdecl, importc, dynlib: SDL_MixerLibName.} + # We'll use SDL for reporting errors +proc Mix_SetError*(fmt: cstring) +proc Mix_GetError*(): cstring +# implementation + +proc SDL_MIXER_VERSION(X: var TSDL_version) = + X.major = SDL_MIXER_MAJOR_VERSION + X.minor = SDL_MIXER_MINOR_VERSION + X.patch = SDL_MIXER_PATCHLEVEL + +proc Mix_LoadWAV(filename: cstring): PMix_Chunk = + result = Mix_LoadWAV_RW(SDL_RWFromFile(filename, "rb"), 1) + +proc Mix_PlayChannel(channel: int, chunk: PMix_Chunk, loops: int): int = + result = Mix_PlayChannelTimed(channel, chunk, loops, - 1) + +proc Mix_FadeInChannel(channel: int, chunk: PMix_Chunk, loops: int, ms: int): int = + result = Mix_FadeInChannelTimed(channel, chunk, loops, ms, - 1) + +proc Mix_SetError(fmt: cstring) = + SDL_SetError(fmt) + +proc Mix_GetError(): cstring = + result = SDL_GetError() diff --git a/lib/base/sdl/sdl_mixer_nosmpeg.nim b/lib/base/sdl/sdl_mixer_nosmpeg.nim new file mode 100644 index 000000000..6282b5edc --- /dev/null +++ b/lib/base/sdl/sdl_mixer_nosmpeg.nim @@ -0,0 +1,572 @@ + +#****************************************************************************** +# Copy of SDL_Mixer without smpeg dependency and mp3 support +#****************************************************************************** + +import + sdl + +when defined(windows): + const SDL_MixerLibName = "SDL_mixer.dll" +elif defined(macosx): + const SDL_MixerLibName = "libSDL_mixer-1.2.0.dylib" +else: + const SDL_MixerLibName = "libSDL_mixer.so" + +const + SDL_MIXER_MAJOR_VERSION* = 1'i8 + SDL_MIXER_MINOR_VERSION* = 2'i8 + SDL_MIXER_PATCHLEVEL* = 7'i8 # Backwards compatibility + MIX_MAJOR_VERSION* = SDL_MIXER_MAJOR_VERSION + MIX_MINOR_VERSION* = SDL_MIXER_MINOR_VERSION + MIX_PATCHLEVEL* = SDL_MIXER_PATCHLEVEL # SDL_Mixer.h constants + # The default mixer has 8 simultaneous mixing channels + MIX_CHANNELS* = 8 # Good default values for a PC soundcard + MIX_DEFAULT_FREQUENCY* = 22050 + +when defined(IA32): + const + MIX_DEFAULT_FORMAT* = AUDIO_S16LSB +else: + const + MIX_DEFAULT_FORMAT* = AUDIO_S16MSB +const + MIX_DEFAULT_CHANNELS* = 2 + MIX_MAX_VOLUME* = 128 # Volume of a chunk + PATH_MAX* = 255 # mikmod.h constants + #* + # * Library version + # * + LIBMIKMOD_VERSION_MAJOR* = 3 + LIBMIKMOD_VERSION_MINOR* = 1 + LIBMIKMOD_REVISION* = 8 + LIBMIKMOD_VERSION* = ((LIBMIKMOD_VERSION_MAJOR shl 16) or + (LIBMIKMOD_VERSION_MINOR shl 8) or (LIBMIKMOD_REVISION)) + +type #music_cmd.h types + PMusicCMD* = ptr TMusicCMD + TMusicCMD*{.final.} = object #wavestream.h types + filename*: array[0..PATH_MAX - 1, char] + cmd*: array[0..PATH_MAX - 1, char] + pid*: TSYS_ThreadHandle + + PWAVStream* = ptr TWAVStream + TWAVStream*{.final.} = object #playmidi.h types + wavefp*: Pointer + start*: int32 + stop*: int32 + cvt*: TSDL_AudioCVT + + PMidiEvent* = ptr TMidiEvent + TMidiEvent*{.final.} = object + time*: int32 + channel*: uint8 + type_*: uint8 + a*: uint8 + b*: uint8 + + PMidiSong* = ptr TMidiSong + TMidiSong*{.final.} = object #music_ogg.h types + samples*: int32 + events*: PMidiEvent + + POGG_Music* = ptr TOGG_Music + TOGG_Music*{.final.} = object # mikmod.h types + #* + # * Error codes + # * + playing*: int + volume*: int #vf: OggVorbis_File; + section*: int + cvt*: TSDL_AudioCVT + len_available*: int + snd_available*: PUint8 + + TErrorEnum* = enum + MMERR_OPENING_FILE, MMERR_OUT_OF_MEMORY, MMERR_DYNAMIC_LINKING, + MMERR_SAMPLE_TOO_BIG, MMERR_OUT_OF_HANDLES, MMERR_UNKNOWN_WAVE_TYPE, + MMERR_LOADING_PATTERN, MMERR_LOADING_TRACK, MMERR_LOADING_HEADER, + MMERR_LOADING_SAMPLEINFO, MMERR_NOT_A_MODULE, MMERR_NOT_A_STREAM, + MMERR_MED_SYNTHSAMPLES, MMERR_ITPACK_INVALID_DATA, MMERR_DETECTING_DEVICE, + MMERR_INVALID_DEVICE, MMERR_INITIALIZING_MIXER, MMERR_OPENING_AUDIO, + MMERR_8BIT_ONLY, MMERR_16BIT_ONLY, MMERR_STEREO_ONLY, MMERR_ULAW, + MMERR_NON_BLOCK, MMERR_AF_AUDIO_PORT, MMERR_AIX_CONFIG_INIT, + MMERR_AIX_CONFIG_CONTROL, MMERR_AIX_CONFIG_START, MMERR_GUS_SETTINGS, + MMERR_GUS_RESET, MMERR_GUS_TIMER, MMERR_HP_SETSAMPLESIZE, MMERR_HP_SETSPEED, + MMERR_HP_CHANNELS, MMERR_HP_AUDIO_OUTPUT, MMERR_HP_AUDIO_DESC, + MMERR_HP_BUFFERSIZE, MMERR_OSS_SETFRAGMENT, MMERR_OSS_SETSAMPLESIZE, + MMERR_OSS_SETSTEREO, MMERR_OSS_SETSPEED, MMERR_SGI_SPEED, MMERR_SGI_16BIT, + MMERR_SGI_8BIT, MMERR_SGI_STEREO, MMERR_SGI_MONO, MMERR_SUN_INIT, + MMERR_OS2_MIXSETUP, MMERR_OS2_SEMAPHORE, MMERR_OS2_TIMER, MMERR_OS2_THREAD, + MMERR_DS_PRIORITY, MMERR_DS_BUFFER, MMERR_DS_FORMAT, MMERR_DS_NOTIFY, + MMERR_DS_EVENT, MMERR_DS_THREAD, MMERR_DS_UPDATE, MMERR_WINMM_HANDLE, + MMERR_WINMM_ALLOCATED, MMERR_WINMM_DEVICEID, MMERR_WINMM_FORMAT, + MMERR_WINMM_UNKNOWN, MMERR_MAC_SPEED, MMERR_MAC_START, MMERR_MAX + PMODULE* = ptr TMODULE + TMODULE*{.final.} = object + PUNIMOD* = ptr TUNIMOD + TUNIMOD* = TMODULE #SDL_mixer.h types + # The internal format for an audio chunk + PMix_Chunk* = ptr TMix_Chunk + TMix_Chunk*{.final.} = object + allocated*: int + abuf*: PUint8 + alen*: Uint32 + volume*: Uint8 # Per-sample volume, 0-128 + + Mix_Chunk* = TMix_Chunk # The different fading types supported + TMix_Fading* = enum + MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN + Mix_Fading* = TMix_Fading + TMix_MusicType* = enum + MUS_NONE, MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG + PMix_Music* = ptr TMix_Music + TMix_Music*{.final.} = object + type_*: TMix_MusicType + + TMixFunction* = proc (udata: Pointer, stream: PUint8, length: int): Pointer{. + cdecl.} # This macro can be used to fill a version structure with the compile-time + # version of the SDL_mixer library. + +proc SDL_MIXER_VERSION*(X: var TSDL_Version) + # This function gets the version of the dynamically linked SDL_mixer library. + # It should NOT be used to fill a version structure, instead you should use the + # SDL_MIXER_VERSION() macro. +proc Mix_Linked_Version*(): PSDL_version{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Open the mixer with a certain audio format +proc Mix_OpenAudio*(frequency: int, format: Uint16, channels: int, + chunksize: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Dynamically change the number of channels managed by the mixer. + # If decreasing the number of channels, the upper channels are + # stopped. + # This function returns the new number of allocated channels. + # +proc Mix_AllocateChannels*(numchannels: int): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} + # Find out what the actual audio device parameters are. + # This function returns 1 if the audio has been opened, 0 otherwise. + # +proc Mix_QuerySpec*(frequency: var int, format: var Uint16, channels: var int): int{. + cdecl, importc, dynlib: SDL_MixerLibName.} + # Load a wave file or a music (.mod .s3m .it .xm) file +proc Mix_LoadWAV_RW*(src: PSDL_RWops, freesrc: int): PMix_Chunk{.cdecl, + importc, dynlib: SDL_MixerLibName.} +proc Mix_LoadWAV*(filename: cstring): PMix_Chunk +proc Mix_LoadMUS*(filename: cstring): PMix_Music{.cdecl, + importc, dynlib: SDL_MixerLibName.} + # Load a wave file of the mixer format from a memory buffer +proc Mix_QuickLoad_WAV*(mem: PUint8): PMix_Chunk{.cdecl, + importc, dynlib: SDL_MixerLibName.} + # Free an audio chunk previously loaded +proc Mix_FreeChunk*(chunk: PMix_Chunk){.cdecl, importc, dynlib: SDL_MixerLibName.} +proc Mix_FreeMusic*(music: PMix_Music){.cdecl, importc, dynlib: SDL_MixerLibName.} + # Find out the music format of a mixer music, or the currently playing + # music, if 'music' is NULL. +proc Mix_GetMusicType*(music: PMix_Music): TMix_MusicType{.cdecl, + importc, dynlib: SDL_MixerLibName.} + # Set a function that is called after all mixing is performed. + # This can be used to provide real-time visual display of the audio stream + # or add a custom mixer filter for the stream data. + # +proc Mix_SetPostMix*(mix_func: TMixFunction, arg: Pointer){.cdecl, + importc, dynlib: SDL_MixerLibName.} + # Add your own music player or additional mixer function. + # If 'mix_func' is NULL, the default music player is re-enabled. + # +proc Mix_HookMusic*(mix_func: TMixFunction, arg: Pointer){.cdecl, + importc, dynlib: SDL_MixerLibName.} + # Add your own callback when the music has finished playing. + # +proc Mix_HookMusicFinished*(music_finished: Pointer){.cdecl, + importc, dynlib: SDL_MixerLibName.} + # Get a pointer to the user data for the current music hook +proc Mix_GetMusicHookData*(): Pointer{.cdecl, importc, dynlib: SDL_MixerLibName.} + #* Add your own callback when a channel has finished playing. NULL + # * to disable callback.* +type + TChannel_finished* = proc (channel: int){.cdecl.} + +proc Mix_ChannelFinished*(channel_finished: TChannel_finished){.cdecl, + importc, dynlib: SDL_MixerLibName.} +const + MIX_CHANNEL_POST* = - 2 #* This is the format of a special effect callback: + # * + # * myeffect(int chan, void *stream, int len, void *udata); + # * + # * (chan) is the channel number that your effect is affecting. (stream) is + # * the buffer of data to work upon. (len) is the size of (stream), and + # * (udata) is a user-defined bit of data, which you pass as the last arg of + # * Mix_RegisterEffect(), and is passed back unmolested to your callback. + # * Your effect changes the contents of (stream) based on whatever parameters + # * are significant, or just leaves it be, if you prefer. You can do whatever + # * you like to the buffer, though, and it will continue in its changed state + # * down the mixing pipeline, through any other effect functions, then finally + # * to be mixed with the rest of the channels and music for the final output + # * stream. + # * + +type + TMix_EffectFunc* = proc (chan: int, stream: Pointer, length: int, + udata: Pointer): Pointer{.cdecl.} + # * This is a callback that signifies that a channel has finished all its + # * loops and has completed playback. This gets called if the buffer + # * plays out normally, or if you call Mix_HaltChannel(), implicitly stop + # * a channel via Mix_AllocateChannels(), or unregister a callback while + # * it's still playing. + TMix_EffectDone* = proc (chan: int, udata: Pointer): Pointer{.cdecl.} + #* Register a special effect function. At mixing time, the channel data is + # * copied into a buffer and passed through each registered effect function. + # * After it passes through all the functions, it is mixed into the final + # * output stream. The copy to buffer is performed once, then each effect + # * function performs on the output of the previous effect. Understand that + # * this extra copy to a buffer is not performed if there are no effects + # * registered for a given chunk, which saves CPU cycles, and any given + # * effect will be extra cycles, too, so it is crucial that your code run + # * fast. Also note that the data that your function is given is in the + # * format of the sound device, and not the format you gave to Mix_OpenAudio(), + # * although they may in reality be the same. This is an unfortunate but + # * necessary speed concern. Use Mix_QuerySpec() to determine if you can + # * handle the data before you register your effect, and take appropriate + # * actions. + # * You may also specify a callback (Mix_EffectDone_t) that is called when + # * the channel finishes playing. This gives you a more fine-grained control + # * than Mix_ChannelFinished(), in case you need to free effect-specific + # * resources, etc. If you don't need this, you can specify NULL. + # * You may set the callbacks before or after calling Mix_PlayChannel(). + # * Things like Mix_SetPanning() are just internal special effect functions, + # * so if you are using that, you've already incurred the overhead of a copy + # * to a separate buffer, and that these effects will be in the queue with + # * any functions you've registered. The list of registered effects for a + # * channel is reset when a chunk finishes playing, so you need to explicitly + # * set them with each call to Mix_PlayChannel*(). + # * You may also register a special effect function that is to be run after + # * final mixing occurs. The rules for these callbacks are identical to those + # * in Mix_RegisterEffect, but they are run after all the channels and the + # * music have been mixed into a single stream, whereas channel-specific + # * effects run on a given channel before any other mixing occurs. These + # * global effect callbacks are call "posteffects". Posteffects only have + # * their Mix_EffectDone_t function called when they are unregistered (since + # * the main output stream is never "done" in the same sense as a channel). + # * You must unregister them manually when you've had enough. Your callback + # * will be told that the channel being mixed is (MIX_CHANNEL_POST) if the + # * processing is considered a posteffect. + # * + # * After all these effects have finished processing, the callback registered + # * through Mix_SetPostMix() runs, and then the stream goes to the audio + # * device. + # * + # * returns zero if error (no such channel), nonzero if added. + # * Error messages can be retrieved from Mix_GetError(). + +proc Mix_RegisterEffect*(chan: int, f: TMix_EffectFunc, d: TMix_EffectDone, + arg: Pointer): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + #* You may not need to call this explicitly, unless you need to stop an + # * effect from processing in the middle of a chunk's playback. + # * Posteffects are never implicitly unregistered as they are for channels, + # * but they may be explicitly unregistered through this function by + # * specifying MIX_CHANNEL_POST for a channel. + # * returns zero if error (no such channel or effect), nonzero if removed. + # * Error messages can be retrieved from Mix_GetError(). + # * +proc Mix_UnregisterEffect*(channel: int, f: TMix_EffectFunc): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} + #* You may not need to call this explicitly, unless you need to stop all + # * effects from processing in the middle of a chunk's playback. Note that + # * this will also shut off some internal effect processing, since + # * Mix_SetPanning( ) and others may use this API under the hood.This is + # * called internally when a channel completes playback. + # * Posteffects are never implicitly unregistered as they are for channels, + # * but they may be explicitly unregistered through this function by + # * specifying MIX_CHANNEL_POST for a channel. + # * returns zero if error( no such channel ), nonzero if all effects removed. + # * Error messages can be retrieved from Mix_GetError( ). + # * +proc Mix_UnregisterAllEffects*(channel: int): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} +const + MIX_EFFECTSMAXSPEED* = "MIX_EFFECTSMAXSPEED" + # * These are the internally - defined mixing effects.They use the same API that + # * effects defined in the application use, but are provided here as a + # * convenience.Some effects can reduce their quality or use more memory in + # * the name of speed; to enable this, make sure the environment variable + # * MIX_EFFECTSMAXSPEED( see above ) is defined before you call + # * Mix_OpenAudio( ). + # * + #* set the panning of a channel.The left and right channels are specified + # * as integers between 0 and 255, quietest to loudest, respectively. + # * + # * Technically, this is just individual volume control for a sample with + # * two( stereo )channels, so it can be used for more than just panning. + # * if you want real panning, call it like this : + # * + # * Mix_SetPanning( channel, left, 255 - left ); + # * + # * ...which isn't so hard. + # * + # * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and + # * the panning will be done to the final mixed stream before passing it on + # * to the audio device. + # * + # * This uses the Mix_RegisterEffect( )API internally, and returns without + # * registering the effect function if the audio device is not configured + # * for stereo output.Setting both( left ) and ( right ) to 255 causes this + # * effect to be unregistered, since that is the data's normal state. + # * + # * returns zero if error( no such channel or Mix_RegisterEffect( )fails ), + # * nonzero if panning effect enabled.Note that an audio device in mono + # * mode is a no - op, but this call will return successful in that case . + # * Error messages can be retrieved from Mix_GetError( ). + + +proc Mix_SetPanning*(channel: int, left: Uint8, right: Uint8): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} + # * set the position ofa channel.( angle ) is an integer from 0 to 360, that + # * specifies the location of the sound in relation to the listener.( angle ) + # * will be reduced as neccesary( 540 becomes 180 degrees, -100 becomes 260 ). + # * Angle 0 is due north, and rotates clockwise as the value increases. + # * for efficiency, the precision of this effect may be limited( angles 1 + # * through 7 might all produce the same effect, 8 through 15 are equal, etc ). + # * ( distance ) is an integer between 0 and 255 that specifies the space + # * between the sound and the listener.The larger the number, the further + # * away the sound is .Using 255 does not guarantee that the channel will be + # * culled from the mixing process or be completely silent.For efficiency, + # * the precision of this effect may be limited( distance 0 through 5 might + # * all produce the same effect, 6 through 10 are equal, etc ).Setting( angle ) + # * and ( distance ) to 0 unregisters this effect, since the data would be + # * unchanged. + # * + # * if you need more precise positional audio, consider using OpenAL for + # * spatialized effects instead of SDL_mixer.This is only meant to be a + # * basic effect for simple "3D" games. + # * + # * if the audio device is configured for mono output, then you won't get + # * any effectiveness from the angle; however, distance attenuation on the + # * channel will still occur.While this effect will function with stereo + # * voices, it makes more sense to use voices with only one channel of sound, + # * so when they are mixed through this effect, the positioning will sound + # * correct.You can convert them to mono through SDL before giving them to + # * the mixer in the first place if you like. + # * + # * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and + # * the positioning will be done to the final mixed stream before passing it + # * on to the audio device. + # * + # * This is a convenience wrapper over Mix_SetDistance( ) and Mix_SetPanning( ). + # * + # * returns zero if error( no such channel or Mix_RegisterEffect( )fails ), + # * nonzero if position effect is enabled. + # * Error messages can be retrieved from Mix_GetError( ). + # * +proc Mix_SetPosition*(channel: int, angle: Sint16, distance: Uint8): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} + #* set the "distance" of a channel.( distance ) is an integer from 0 to 255 + # * that specifies the location of the sound in relation to the listener. + # * Distance 0 is overlapping the listener, and 255 is as far away as possible + # * A distance of 255 does not guarantee silence; in such a case , you might + # * want to try changing the chunk's volume, or just cull the sample from the + # * mixing process with Mix_HaltChannel( ). + # * for efficiency, the precision of this effect may be limited( distances 1 + # * through 7 might all produce the same effect, 8 through 15 are equal, etc ). + # * ( distance ) is an integer between 0 and 255 that specifies the space + # * between the sound and the listener.The larger the number, the further + # * away the sound is . + # * Setting( distance ) to 0 unregisters this effect, since the data would be + # * unchanged. + # * if you need more precise positional audio, consider using OpenAL for + # * spatialized effects instead of SDL_mixer.This is only meant to be a + # * basic effect for simple "3D" games. + # * + # * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and + # * the distance attenuation will be done to the final mixed stream before + # * passing it on to the audio device. + # * + # * This uses the Mix_RegisterEffect( )API internally. + # * + # * returns zero if error( no such channel or Mix_RegisterEffect( )fails ), + # * nonzero if position effect is enabled. + # * Error messages can be retrieved from Mix_GetError( ). + # * +proc Mix_SetDistance*(channel: int, distance: Uint8): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} + # * + # * !!! FIXME : Haven't implemented, since the effect goes past the + # * end of the sound buffer.Will have to think about this. + # * - -ryan. + # * / + # { if 0 + # { * Causes an echo effect to be mixed into a sound.( echo ) is the amount + # * of echo to mix.0 is no echo, 255 is infinite( and probably not + # * what you want ). + # * + # * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and + # * the reverbing will be done to the final mixed stream before passing it on + # * to the audio device. + # * + # * This uses the Mix_RegisterEffect( )API internally.If you specify an echo + # * of zero, the effect is unregistered, as the data is already in that state. + # * + # * returns zero if error( no such channel or Mix_RegisterEffect( )fails ), + # * nonzero if reversing effect is enabled. + # * Error messages can be retrieved from Mix_GetError( ). + # * + # extern no_parse_DECLSPEC int Mix_SetReverb( int channel, Uint8 echo ); + # #E ndif + # * Causes a channel to reverse its stereo.This is handy if the user has his + # * speakers hooked up backwards, or you would like to have a minor bit of + # * psychedelia in your sound code. : )Calling this function with ( flip ) + # * set to non - zero reverses the chunks's usual channels. If (flip) is zero, + # * the effect is unregistered. + # * + # * This uses the Mix_RegisterEffect( )API internally, and thus is probably + # * more CPU intensive than having the user just plug in his speakers + # * correctly.Mix_SetReverseStereo( )returns without registering the effect + # * function if the audio device is not configured for stereo output. + # * + # * if you specify MIX_CHANNEL_POST for ( channel ), then this the effect is used + # * on the final mixed stream before sending it on to the audio device( a + # * posteffect ). + # * + # * returns zero if error( no such channel or Mix_RegisterEffect( )fails ), + # * nonzero if reversing effect is enabled.Note that an audio device in mono + # * mode is a no - op, but this call will return successful in that case . + # * Error messages can be retrieved from Mix_GetError( ). + # * +proc Mix_SetReverseStereo*(channel: int, flip: int): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} + # end of effects API. - -ryan. * + # Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate + # them dynamically to the next sample if requested with a -1 value below. + # Returns the number of reserved channels. + # +proc Mix_ReserveChannels*(num: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Channel grouping functions + # Attach a tag to a channel. A tag can be assigned to several mixer + # channels, to form groups of channels. + # If 'tag' is -1, the tag is removed (actually -1 is the tag used to + # represent the group of all the channels). + # Returns true if everything was OK. + # +proc Mix_GroupChannel*(which: int, tag: int): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} + # Assign several consecutive channels to a group +proc Mix_GroupChannels*(`from`: int, `to`: int, tag: int): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} + # Finds the first available channel in a group of channels +proc Mix_GroupAvailable*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Returns the number of channels in a group. This is also a subtle + # way to get the total number of channels when 'tag' is -1 + # +proc Mix_GroupCount*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Finds the "oldest" sample playing in a group of channels +proc Mix_GroupOldest*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Finds the "most recent" (i.e. last) sample playing in a group of channels +proc Mix_GroupNewer*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # The same as above, but the sound is played at most 'ticks' milliseconds +proc Mix_PlayChannelTimed*(channel: int, chunk: PMix_Chunk, loops: int, + ticks: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Play an audio chunk on a specific channel. + # If the specified channel is -1, play on the first free channel. + # If 'loops' is greater than zero, loop the sound that many times. + # If 'loops' is -1, loop inifinitely (~65000 times). + # Returns which channel was used to play the sound. + # +proc Mix_PlayChannel*(channel: int, chunk: PMix_Chunk, loops: int): int +proc Mix_PlayMusic*(music: PMix_Music, loops: int): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} + # Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions +proc Mix_FadeInMusic*(music: PMix_Music, loops: int, ms: int): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} +proc Mix_FadeInChannelTimed*(channel: int, chunk: PMix_Chunk, loops: int, + ms: int, ticks: int): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} +proc Mix_FadeInChannel*(channel: int, chunk: PMix_Chunk, loops: int, ms: int): int + # Set the volume in the range of 0-128 of a specific channel or chunk. + # If the specified channel is -1, set volume for all channels. + # Returns the original volume. + # If the specified volume is -1, just return the current volume. + # +proc Mix_Volume*(channel: int, volume: int): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} +proc Mix_VolumeChunk*(chunk: PMix_Chunk, volume: int): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} +proc Mix_VolumeMusic*(volume: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Halt playing of a particular channel +proc Mix_HaltChannel*(channel: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} +proc Mix_HaltGroup*(tag: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} +proc Mix_HaltMusic*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Change the expiration delay for a particular channel. + # The sample will stop playing after the 'ticks' milliseconds have elapsed, + # or remove the expiration if 'ticks' is -1 + # +proc Mix_ExpireChannel*(channel: int, ticks: int): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} + # Halt a channel, fading it out progressively till it's silent + # The ms parameter indicates the number of milliseconds the fading + # will take. + # +proc Mix_FadeOutChannel*(which: int, ms: int): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} +proc Mix_FadeOutGroup*(tag: int, ms: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} +proc Mix_FadeOutMusic*(ms: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Query the fading status of a channel +proc Mix_FadingMusic*(): TMix_Fading{.cdecl, importc, dynlib: SDL_MixerLibName.} +proc Mix_FadingChannel*(which: int): TMix_Fading{.cdecl, + importc, dynlib: SDL_MixerLibName.} + # Pause/Resume a particular channel +proc Mix_Pause*(channel: int){.cdecl, importc, dynlib: SDL_MixerLibName.} +proc Mix_Resume*(channel: int){.cdecl, importc, dynlib: SDL_MixerLibName.} +proc Mix_Paused*(channel: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Pause/Resume the music stream +proc Mix_PauseMusic*(){.cdecl, importc, dynlib: SDL_MixerLibName.} +proc Mix_ResumeMusic*(){.cdecl, importc, dynlib: SDL_MixerLibName.} +proc Mix_RewindMusic*(){.cdecl, importc, dynlib: SDL_MixerLibName.} +proc Mix_PausedMusic*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Set the current position in the music stream. + # This returns 0 if successful, or -1 if it failed or isn't implemented. + # This function is only implemented for MOD music formats (set pattern + # order number) and for OGG music (set position in seconds), at the + # moment. + # +proc Mix_SetMusicPosition*(position: float64): int{.cdecl, + importc, dynlib: SDL_MixerLibName.} + # Check the status of a specific channel. + # If the specified channel is -1, check all channels. + # +proc Mix_Playing*(channel: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} +proc Mix_PlayingMusic*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Stop music and set external music playback command +proc Mix_SetMusicCMD*(command: cstring): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Synchro value is set by MikMod from modules while playing +proc Mix_SetSynchroValue*(value: int): int{.cdecl, importc, dynlib: SDL_MixerLibName.} +proc Mix_GetSynchroValue*(): int{.cdecl, importc, dynlib: SDL_MixerLibName.} + # + # Get the Mix_Chunk currently associated with a mixer channel + # Returns nil if it's an invalid channel, or there's no chunk associated. + # +proc Mix_GetChunk*(channel: int): PMix_Chunk{.cdecl, importc, dynlib: SDL_MixerLibName.} + # Close the mixer, halting all playing audio +proc Mix_CloseAudio*(){.cdecl, importc, dynlib: SDL_MixerLibName.} + # We'll use SDL for reporting errors +proc Mix_SetError*(fmt: cstring) +proc Mix_GetError*(): cstring +# implementation + +proc SDL_MIXER_VERSION(X: var TSDL_version) = + X.major = SDL_MIXER_MAJOR_VERSION + X.minor = SDL_MIXER_MINOR_VERSION + X.patch = SDL_MIXER_PATCHLEVEL + +proc Mix_LoadWAV(filename: cstring): PMix_Chunk = + result = Mix_LoadWAV_RW(SDL_RWFromFile(filename, "rb"), 1) + +proc Mix_PlayChannel(channel: int, chunk: PMix_Chunk, loops: int): int = + result = Mix_PlayChannelTimed(channel, chunk, loops, - 1) + +proc Mix_FadeInChannel(channel: int, chunk: PMix_Chunk, loops: int, ms: int): int = + result = Mix_FadeInChannelTimed(channel, chunk, loops, ms, - 1) + +proc Mix_SetError(fmt: cstring) = + SDL_SetError(fmt) + +proc Mix_GetError(): cstring = + result = SDL_GetError() diff --git a/lib/base/sdl/sdl_net.nim b/lib/base/sdl/sdl_net.nim new file mode 100644 index 000000000..f27a674ae --- /dev/null +++ b/lib/base/sdl/sdl_net.nim @@ -0,0 +1,431 @@ + +#****************************************************************************** +# +# $Id: sdl_net.pas,v 1.7 2005/01/01 02:14:21 savage Exp $ +# +# +# +# Borland Delphi SDL_Net - A x-platform network library for use with SDL. +# Conversion of the Simple DirectMedia Layer Network Headers +# +# Portions created by Sam Lantinga <slouken@devolution.com> are +# Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga +# 5635-34 Springhouse Dr. +# Pleasanton, CA 94588 (USA) +# +# All Rights Reserved. +# +# The original files are : SDL_net.h +# +# The initial developer of this Pascal code was : +# Dominqiue Louis <Dominique@SavageSoftware.com.au> +# +# Portions created by Dominqiue Louis are +# Copyright (C) 2000 - 2001 Dominqiue Louis. +# +# +# Contributor(s) +# -------------- +# Matthias Thoma <ma.thoma@gmx.de> +# +# Obtained through: +# Joint Endeavour of Delphi Innovators ( Project JEDI ) +# +# You may retrieve the latest version of this file at the Project +# JEDI home page, located at http://delphi-jedi.org +# +# The contents of this file are used with permission, subject to +# the Mozilla Public License Version 1.1 (the "License"); you may +# not use this file except in compliance with the License. You may +# obtain a copy of the License at +# http://www.mozilla.org/MPL/MPL-1.1.html +# +# Software distributed under the License is distributed on an +# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# Description +# ----------- +# +# +# +# +# +# +# +# Requires +# -------- +# SDL.pas somehere in your search path +# +# Programming Notes +# ----------------- +# +# +# +# +# Revision History +# ---------------- +# April 09 2001 - DL : Initial Translation +# +# April 03 2003 - DL : Added jedi-sdl.inc include file to support more +# Pascal compilers. Initial support is now included +# for GnuPascal, VirtualPascal, TMT and obviously +# continue support for Delphi Kylix and FreePascal. +# +# April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added +# better TMT Pascal support and under instruction +# from Prof. Abimbola Olowofoyeku (The African Chief), +# I have added better Gnu Pascal support +# +# April 30 2003 - DL : under instruction from David Mears AKA +# Jason Siletto, I have added FPC Linux support. +# This was compiled with fpc 1.1, so remember to set +# include file path. ie. -Fi/usr/share/fpcsrc/rtl/* +# +# +# $Log: sdl_net.pas,v $ +# Revision 1.7 2005/01/01 02:14:21 savage +# Updated to v1.2.5 +# +# Revision 1.6 2004/08/14 22:54:30 savage +# Updated so that Library name defines are correctly defined for MacOS X. +# +# Revision 1.5 2004/05/10 14:10:04 savage +# Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ). +# +# Revision 1.4 2004/04/13 09:32:08 savage +# Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary. +# +# Revision 1.3 2004/04/01 20:53:23 savage +# Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site. +# +# Revision 1.2 2004/03/30 20:23:28 savage +# Tidied up use of UNIX compiler directive. +# +# Revision 1.1 2004/02/16 22:16:40 savage +# v1.0 changes +# +# +# +#****************************************************************************** + +import + sdl + +when defined(windows): + const SDLNetLibName = "SDL_net.dll" +elif defined(macosx): + const SDLNetLibName = "libSDL_net.dylib" +else: + const SDLNetLibName = "libSDL_net.so" + +const #* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL * + SDL_NET_MAJOR_VERSION* = 1'i8 + SDL_NET_MINOR_VERSION* = 2'i8 + SDL_NET_PATCHLEVEL* = 5'i8 # SDL_Net.h constants + #* Resolve a host name and port to an IP address in network form. + # If the function succeeds, it will return 0. + # If the host couldn't be resolved, the host portion of the returned + # address will be INADDR_NONE, and the function will return -1. + # If 'host' is NULL, the resolved host will be set to INADDR_ANY. + # * + INADDR_ANY* = 0x00000000 + INADDR_NONE* = 0xFFFFFFFF #*********************************************************************** + #* UDP network API * + #*********************************************************************** + #* The maximum channels on a a UDP socket * + SDLNET_MAX_UDPCHANNELS* = 32 #* The maximum addresses bound to a single UDP socket channel * + SDLNET_MAX_UDPADDRESSES* = 4 + +type # SDL_net.h types + #*********************************************************************** + #* IPv4 hostname resolution API * + #*********************************************************************** + PIPAddress* = ptr TIPAddress + TIPAddress*{.final.} = object #* TCP network API + host*: Uint32 # 32-bit IPv4 host address */ + port*: Uint16 # 16-bit protocol port */ + + PTCPSocket* = ptr TTCPSocket + TTCPSocket*{.final.} = object #*********************************************************************** + #* UDP network API * + #*********************************************************************** + ready*: int + channel*: int + remoteAddress*: TIPaddress + localAddress*: TIPaddress + sflag*: int + + PUDP_Channel* = ptr TUDP_Channel + TUDP_Channel*{.final.} = object + numbound*: int + address*: array[0..SDLNET_MAX_UDPADDRESSES - 1, TIPAddress] + + PUDPSocket* = ptr TUDPSocket + TUDPSocket*{.final.} = object + ready*: int + channel*: int + address*: TIPAddress + binding*: array[0..SDLNET_MAX_UDPCHANNELS - 1, TUDP_Channel] + + PUDPpacket* = ptr TUDPpacket + PPUDPpacket* = ptr PUDPpacket + TUDPpacket*{.final.} = object #*********************************************************************** + #* Hooks for checking sockets for available data * + #*********************************************************************** + channel*: int #* The src/dst channel of the packet * + data*: PUint8 #* The packet data * + length*: int #* The length of the packet data * + maxlen*: int #* The size of the data buffer * + status*: int #* packet status after sending * + address*: TIPAddress #* The source/dest address of an incoming/outgoing packet * + + PSDLNet_Socket* = ptr TSDLNet_Socket + TSDLNet_Socket*{.final.} = object + ready*: int + channel*: int + + PSDLNet_SocketSet* = ptr TSDLNet_SocketSet + TSDLNet_SocketSet*{.final.} = object #* Any network socket can be safely cast to this socket type * + numsockets*: int + maxsockets*: int + sockets*: PSDLNet_Socket + + PSDLNet_GenericSocket* = ptr TSDLNet_GenericSocket + TSDLNet_GenericSocket*{.final.} = object # This macro can be used to fill a version structure with the compile-time + # version of the SDL_net library. + ready*: int + + +proc SDL_NET_VERSION*(X: var TSDL_version) + #* Initialize/Cleanup the network API + # SDL must be initialized before calls to functions in this library, + # because this library uses utility functions from the SDL library. + #* +proc SDLNet_Init*(): int{.cdecl, importc, dynlib: SDLNetLibName.} +proc SDLNet_Quit*(){.cdecl, importc, dynlib: SDLNetLibName.} + #* Resolve a host name and port to an IP address in network form. + # If the function succeeds, it will return 0. + # If the host couldn't be resolved, the host portion of the returned + # address will be INADDR_NONE, and the function will return -1. + # If 'host' is NULL, the resolved host will be set to INADDR_ANY. + # * +proc SDLNet_ResolveHost*(address: var TIPaddress, host: cstring, port: Uint16): int{. + cdecl, importc, dynlib: SDLNetLibName.} + #* Resolve an ip address to a host name in canonical form. + # If the ip couldn't be resolved, this function returns NULL, + # otherwise a pointer to a static buffer containing the hostname + # is returned. Note that this function is not thread-safe. + #* +proc SDLNet_ResolveIP*(ip: var TIPaddress): cstring{.cdecl, + importc, dynlib: SDLNetLibName.} + #*********************************************************************** + #* TCP network API * + #*********************************************************************** + #* Open a TCP network socket + # If ip.host is INADDR_NONE, this creates a local server socket on the + # given port, otherwise a TCP connection to the remote host and port is + # attempted. The address passed in should already be swapped to network + # byte order (addresses returned from SDLNet_ResolveHost() are already + # in the correct form). + # The newly created socket is returned, or NULL if there was an error. + #* +proc SDLNet_TCP_Open*(ip: var TIPaddress): PTCPSocket{.cdecl, + importc, dynlib: SDLNetLibName.} + #* Accept an incoming connection on the given server socket. + # The newly created socket is returned, or NULL if there was an error. + #* +proc SDLNet_TCP_Accept*(server: PTCPsocket): PTCPSocket{.cdecl, + importc, dynlib: SDLNetLibName.} + #* Get the IP address of the remote system associated with the socket. + # If the socket is a server socket, this function returns NULL. + #* +proc SDLNet_TCP_GetPeerAddress*(sock: PTCPsocket): PIPAddress{.cdecl, + importc, dynlib: SDLNetLibName.} + #* Send 'len' bytes of 'data' over the non-server socket 'sock' + # This function returns the actual amount of data sent. If the return value + # is less than the amount of data sent, then either the remote connection was + # closed, or an unknown socket error occurred. + #* +proc SDLNet_TCP_Send*(sock: PTCPsocket, data: Pointer, length: int): int{.cdecl, + importc, dynlib: SDLNetLibName.} + #* Receive up to 'maxlen' bytes of data over the non-server socket 'sock', + # and store them in the buffer pointed to by 'data'. + # This function returns the actual amount of data received. If the return + # value is less than or equal to zero, then either the remote connection was + # closed, or an unknown socket error occurred. + #* +proc SDLNet_TCP_Recv*(sock: PTCPsocket, data: Pointer, maxlen: int): int{.cdecl, + importc, dynlib: SDLNetLibName.} + #* Close a TCP network socket * +proc SDLNet_TCP_Close*(sock: PTCPsocket){.cdecl, importc, dynlib: SDLNetLibName.} + #*********************************************************************** + #* UDP network API * + #*********************************************************************** + #* Allocate/resize/free a single UDP packet 'size' bytes long. + # The new packet is returned, or NULL if the function ran out of memory. + # * +proc SDLNet_AllocPacket*(size: int): PUDPpacket{.cdecl, importc, dynlib: SDLNetLibName.} +proc SDLNet_ResizePacket*(packet: PUDPpacket, newsize: int): int{.cdecl, + importc, dynlib: SDLNetLibName.} +proc SDLNet_FreePacket*(packet: PUDPpacket){.cdecl, importc, dynlib: SDLNetLibName.} + #* Allocate/Free a UDP packet vector (array of packets) of 'howmany' packets, + # each 'size' bytes long. + # A pointer to the first packet in the array is returned, or NULL if the + # function ran out of memory. + # * +proc SDLNet_AllocPacketV*(howmany: int, size: int): PUDPpacket{.cdecl, + importc, dynlib: SDLNetLibName.} +proc SDLNet_FreePacketV*(packetV: PUDPpacket){.cdecl, importc, dynlib: SDLNetLibName.} + #* Open a UDP network socket + # If 'port' is non-zero, the UDP socket is bound to a local port. + # This allows other systems to send to this socket via a known port. + #* +proc SDLNet_UDP_Open*(port: Uint16): PUDPsocket{.cdecl, importc, dynlib: SDLNetLibName.} + #* Bind the address 'address' to the requested channel on the UDP socket. + # If the channel is -1, then the first unbound channel will be bound with + # the given address as it's primary address. + # If the channel is already bound, this new address will be added to the + # list of valid source addresses for packets arriving on the channel. + # If the channel is not already bound, then the address becomes the primary + # address, to which all outbound packets on the channel are sent. + # This function returns the channel which was bound, or -1 on error. + #* +proc SDLNet_UDP_Bind*(sock: PUDPsocket, channel: int, address: var TIPaddress): int{. + cdecl, importc, dynlib: SDLNetLibName.} + #* Unbind all addresses from the given channel * +proc SDLNet_UDP_Unbind*(sock: PUDPsocket, channel: int){.cdecl, + importc, dynlib: SDLNetLibName.} + #* Get the primary IP address of the remote system associated with the + # socket and channel. If the channel is -1, then the primary IP port + # of the UDP socket is returned -- this is only meaningful for sockets + # opened with a specific port. + # If the channel is not bound and not -1, this function returns NULL. + # * +proc SDLNet_UDP_GetPeerAddress*(sock: PUDPsocket, channel: int): PIPAddress{. + cdecl, importc, dynlib: SDLNetLibName.} + #* Send a vector of packets to the the channels specified within the packet. + # If the channel specified in the packet is -1, the packet will be sent to + # the address in the 'src' member of the packet. + # Each packet will be updated with the status of the packet after it has + # been sent, -1 if the packet send failed. + # This function returns the number of packets sent. + #* +proc SDLNet_UDP_SendV*(sock: PUDPsocket, packets: PPUDPpacket, npackets: int): int{. + cdecl, importc, dynlib: SDLNetLibName.} + #* Send a single packet to the specified channel. + # If the channel specified in the packet is -1, the packet will be sent to + # the address in the 'src' member of the packet. + # The packet will be updated with the status of the packet after it has + # been sent. + # This function returns 1 if the packet was sent, or 0 on error. + #* +proc SDLNet_UDP_Send*(sock: PUDPsocket, channel: int, packet: PUDPpacket): int{. + cdecl, importc, dynlib: SDLNetLibName.} + #* Receive a vector of pending packets from the UDP socket. + # The returned packets contain the source address and the channel they arrived + # on. If they did not arrive on a bound channel, the the channel will be set + # to -1. + # The channels are checked in highest to lowest order, so if an address is + # bound to multiple channels, the highest channel with the source address + # bound will be returned. + # This function returns the number of packets read from the network, or -1 + # on error. This function does not block, so can return 0 packets pending. + #* +proc SDLNet_UDP_RecvV*(sock: PUDPsocket, packets: PPUDPpacket): int{.cdecl, + importc, dynlib: SDLNetLibName.} + #* Receive a single packet from the UDP socket. + # The returned packet contains the source address and the channel it arrived + # on. If it did not arrive on a bound channel, the the channel will be set + # to -1. + # The channels are checked in highest to lowest order, so if an address is + # bound to multiple channels, the highest channel with the source address + # bound will be returned. + # This function returns the number of packets read from the network, or -1 + # on error. This function does not block, so can return 0 packets pending. + #* +proc SDLNet_UDP_Recv*(sock: PUDPsocket, packet: PUDPpacket): int{.cdecl, + importc, dynlib: SDLNetLibName.} + #* Close a UDP network socket * +proc SDLNet_UDP_Close*(sock: PUDPsocket){.cdecl, importc, dynlib: SDLNetLibName.} + #*********************************************************************** + #* Hooks for checking sockets for available data * + #*********************************************************************** + #* Allocate a socket set for use with SDLNet_CheckSockets() + # This returns a socket set for up to 'maxsockets' sockets, or NULL if + # the function ran out of memory. + # * +proc SDLNet_AllocSocketSet*(maxsockets: int): PSDLNet_SocketSet{.cdecl, + importc, dynlib: SDLNetLibName.} + #* Add a socket to a set of sockets to be checked for available data * +proc SDLNet_AddSocket*(theSet: PSDLNet_SocketSet, sock: PSDLNet_GenericSocket): int{. + cdecl, importc, dynlib: SDLNetLibName.} +proc SDLNet_TCP_AddSocket*(theSet: PSDLNet_SocketSet, sock: PTCPSocket): int +proc SDLNet_UDP_AddSocket*(theSet: PSDLNet_SocketSet, sock: PUDPSocket): int + #* Remove a socket from a set of sockets to be checked for available data * +proc SDLNet_DelSocket*(theSet: PSDLNet_SocketSet, sock: PSDLNet_GenericSocket): int{. + cdecl, importc, dynlib: SDLNetLibName.} +proc SDLNet_TCP_DelSocket*(theSet: PSDLNet_SocketSet, sock: PTCPSocket): int + # SDLNet_DelSocket(set, (SDLNet_GenericSocket)sock) +proc SDLNet_UDP_DelSocket*(theSet: PSDLNet_SocketSet, sock: PUDPSocket): int + #SDLNet_DelSocket(set, (SDLNet_GenericSocket)sock) + #* This function checks to see if data is available for reading on the + # given set of sockets. If 'timeout' is 0, it performs a quick poll, + # otherwise the function returns when either data is available for + # reading, or the timeout in milliseconds has elapsed, which ever occurs + # first. This function returns the number of sockets ready for reading, + # or -1 if there was an error with the select() system call. + #* +proc SDLNet_CheckSockets*(theSet: PSDLNet_SocketSet, timeout: Sint32): int{. + cdecl, importc, dynlib: SDLNetLibName.} + #* After calling SDLNet_CheckSockets(), you can use this function on a + # socket that was in the socket set, to find out if data is available + # for reading. + #* +proc SDLNet_SocketReady*(sock: PSDLNet_GenericSocket): bool + #* Free a set of sockets allocated by SDL_NetAllocSocketSet() * +proc SDLNet_FreeSocketSet*(theSet: PSDLNet_SocketSet){.cdecl, + importc, dynlib: SDLNetLibName.} + #*********************************************************************** + #* Platform-independent data conversion functions * + #*********************************************************************** + #* Write a 16/32 bit value to network packet buffer * +proc SDLNet_Write16*(value: Uint16, area: Pointer){.cdecl, importc, dynlib: SDLNetLibName.} +proc SDLNet_Write32*(value: Uint32, area: Pointer){.cdecl, importc, dynlib: SDLNetLibName.} + #* Read a 16/32 bit value from network packet buffer * +proc SDLNet_Read16*(area: Pointer): Uint16{.cdecl, importc, dynlib: SDLNetLibName.} +proc SDLNet_Read32*(area: Pointer): Uint32{.cdecl, importc, dynlib: SDLNetLibName.} + #*********************************************************************** + #* Error reporting functions * + #*********************************************************************** + #* We'll use SDL's functions for error reporting * +proc SDLNet_SetError*(fmt: cstring) +proc SDLNet_GetError*(): cstring +# implementation + +proc SDL_NET_VERSION(X: var TSDL_version) = + X.major = SDL_NET_MAJOR_VERSION + X.minor = SDL_NET_MINOR_VERSION + X.patch = SDL_NET_PATCHLEVEL + +proc SDLNet_TCP_AddSocket(theSet: PSDLNet_SocketSet, sock: PTCPSocket): int = + result = SDLNet_AddSocket(theSet, cast[PSDLNet_GenericSocket](sock)) + +proc SDLNet_UDP_AddSocket(theSet: PSDLNet_SocketSet, sock: PUDPSocket): int = + result = SDLNet_AddSocket(theSet, cast[PSDLNet_GenericSocket](sock)) + +proc SDLNet_TCP_DelSocket(theSet: PSDLNet_SocketSet, sock: PTCPSocket): int = + result = SDLNet_DelSocket(theSet, cast[PSDLNet_GenericSocket](sock)) + +proc SDLNet_UDP_DelSocket(theSet: PSDLNet_SocketSet, sock: PUDPSocket): int = + result = SDLNet_DelSocket(theSet, cast[PSDLNet_GenericSocket](sock)) + +proc SDLNet_SocketReady(sock: PSDLNet_GenericSocket): bool = + result = ((sock != nil) and (sock.ready == 1)) + +proc SDLNet_SetError(fmt: cstring) = + SDL_SetError(fmt) + +proc SDLNet_GetError(): cstring = + result = SDL_GetError() diff --git a/lib/base/sdl/sdl_ttf.nim b/lib/base/sdl/sdl_ttf.nim new file mode 100644 index 000000000..724c2f634 --- /dev/null +++ b/lib/base/sdl/sdl_ttf.nim @@ -0,0 +1,346 @@ + +# +# $Id: sdl_ttf.pas,v 1.18 2007/06/01 11:16:33 savage Exp $ +# +# +#****************************************************************************** +# +# JEDI-SDL : Pascal units for SDL - Simple DirectMedia Layer +# Conversion of the Simple DirectMedia Layer Headers +# +# Portions created by Sam Lantinga <slouken@devolution.com> are +# Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga +# 5635-34 Springhouse Dr. +# Pleasanton, CA 94588 (USA) +# +# All Rights Reserved. +# +# The original files are : SDL_ttf.h +# +# The initial developer of this Pascal code was : +# Dominqiue Louis <Dominique@SavageSoftware.com.au> +# +# Portions created by Dominqiue Louis are +# Copyright (C) 2000 - 2001 Dominqiue Louis. +# +# +# Contributor(s) +# -------------- +# Tom Jones <tigertomjones@gmx.de> His Project inspired this conversion +# +# Obtained through: +# Joint Endeavour of Delphi Innovators ( Project JEDI ) +# +# You may retrieve the latest version of this file at the Project +# JEDI home page, located at http://delphi-jedi.org +# +# The contents of this file are used with permission, subject to +# the Mozilla Public License Version 1.1 (the "License"); you may +# not use this file except in compliance with the License. You may +# obtain a copy of the License at +# http://www.mozilla.org/MPL/MPL-1.1.html +# +# Software distributed under the License is distributed on an +# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# Description +# ----------- +# +# +# +# +# +# +# +# Requires +# -------- +# The SDL Runtime libraris on Win32 : SDL.dll on Linux : libSDL.so +# They are available from... +# http://www.libsdl.org . +# +# Programming Notes +# ----------------- +# +# +# +# +# Revision History +# ---------------- +# December 08 2002 - DL : Fixed definition of TTF_RenderUnicode_Solid +# +# April 03 2003 - DL : Added jedi-sdl.inc include file to support more +# Pascal compilers. Initial support is now included +# for GnuPascal, VirtualPascal, TMT and obviously +# continue support for Delphi Kylix and FreePascal. +# +# April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added +# better TMT Pascal support and under instruction +# from Prof. Abimbola Olowofoyeku (The African Chief), +# I have added better Gnu Pascal support +# +# April 30 2003 - DL : under instruction from David Mears AKA +# Jason Siletto, I have added FPC Linux support. +# This was compiled with fpc 1.1, so remember to set +# include file path. ie. -Fi/usr/share/fpcsrc/rtl/* +# +# +# $Log: sdl_ttf.pas,v $ +# Revision 1.18 2007/06/01 11:16:33 savage +# Added IFDEF UNIX for Workaround. +# +# Revision 1.17 2007/06/01 08:38:21 savage +# Added TTF_RenderText_Solid workaround as suggested by Michalis Kamburelis +# +# Revision 1.16 2007/05/29 21:32:14 savage +# Changes as suggested by Almindor for 64bit compatibility. +# +# Revision 1.15 2007/05/20 20:32:45 savage +# Initial Changes to Handle 64 Bits +# +# Revision 1.14 2006/12/02 00:19:01 savage +# Updated to latest version +# +# Revision 1.13 2005/04/10 11:48:33 savage +# Changes as suggested by Michalis, thanks. +# +# Revision 1.12 2005/01/05 01:47:14 savage +# Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively. +# +# Revision 1.11 2005/01/04 23:14:57 savage +# Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively. +# +# Revision 1.10 2005/01/02 19:07:32 savage +# Slight bug fix to use LongInt instead of Long ( Thanks Michalis Kamburelis ) +# +# Revision 1.9 2005/01/01 02:15:20 savage +# Updated to v2.0.7 +# +# Revision 1.8 2004/10/07 21:02:32 savage +# Fix for FPC +# +# Revision 1.7 2004/09/30 22:39:50 savage +# Added a true type font class which contains a wrap text function. +# Changed the sdl_ttf.pas header to reflect the future of jedi-sdl. +# +# Revision 1.6 2004/08/14 22:54:30 savage +# Updated so that Library name defines are correctly defined for MacOS X. +# +# Revision 1.5 2004/05/10 14:10:04 savage +# Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ). +# +# Revision 1.4 2004/04/13 09:32:08 savage +# Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary. +# +# Revision 1.3 2004/04/01 20:53:24 savage +# Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site. +# +# Revision 1.2 2004/03/30 20:23:28 savage +# Tidied up use of UNIX compiler directive. +# +# Revision 1.1 2004/02/16 22:16:40 savage +# v1.0 changes +# +# +# +#****************************************************************************** +# +# Define this to workaround a known bug in some freetype versions. +# The error manifests as TTF_RenderGlyph_Solid returning nil (error) +# and error message (in SDL_Error) is +# "Failed loading DPMSDisable: /usr/lib/libX11.so.6: undefined symbol: DPMSDisable" +# See [http://lists.libsdl.org/pipermail/sdl-libsdl.org/2007-March/060459.html] +# + +import sdl + +when defined(windows): + const SDLttfLibName = "SDL_ttf.dll" +elif defined(macosx): + const SDLttfLibName = "libSDL_ttf-2.0.0.dylib" +else: + const SDLttfLibName = "libSDL_ttf.so" + +const + SDL_TTF_MAJOR_VERSION* = 2'i8 + SDL_TTF_MINOR_VERSION* = 0'i8 + SDL_TTF_PATCHLEVEL* = 8'i8 # Backwards compatibility + TTF_MAJOR_VERSION* = SDL_TTF_MAJOR_VERSION + TTF_MINOR_VERSION* = SDL_TTF_MINOR_VERSION + TTF_PATCHLEVEL* = SDL_TTF_PATCHLEVEL #* + # Set and retrieve the font style + # This font style is implemented by modifying the font glyphs, and + # doesn't reflect any inherent properties of the truetype font file. + #* + TTF_STYLE_NORMAL* = 0x00000000 + TTF_STYLE_BOLD* = 0x00000001 + TTF_STYLE_ITALIC* = 0x00000002 + TTF_STYLE_UNDERLINE* = 0x00000004 # ZERO WIDTH NO-BREAKSPACE (Unicode byte order mark) + UNICODE_BOM_NATIVE* = 0x0000FEFF + UNICODE_BOM_SWAPPED* = 0x0000FFFE + +type + PTTF_Font* = ptr TTTF_font + TTTF_Font*{.final.} = object # This macro can be used to fill a version structure with the compile-time + # version of the SDL_ttf library. + +proc SDL_TTF_VERSION*(X: var TSDL_version) + # This function gets the version of the dynamically linked SDL_ttf library. + # It should NOT be used to fill a version structure, instead you should use the + # SDL_TTF_VERSION() macro. +proc TTF_Linked_Version*(): PSDL_version{.cdecl, importc, dynlib: SDLttfLibName.} + # This function tells the library whether UNICODE text is generally + # byteswapped. A UNICODE BOM character in a string will override + # this setting for the remainder of that string. + # +proc TTF_ByteSwappedUNICODE*(swapped: int){.cdecl, importc, dynlib: SDLttfLibName.} + #returns 0 on succes, -1 if error occurs +proc TTF_Init*(): int{.cdecl, importc, dynlib: SDLttfLibName.} + # + # Open a font file and create a font of the specified point size. + # Some .fon fonts will have several sizes embedded in the file, so the + # point size becomes the index of choosing which size. If the value + # is too high, the last indexed size will be the default. + # +proc TTF_OpenFont*(filename: cstring, ptsize: int): PTTF_Font{.cdecl, + importc, dynlib: SDLttfLibName.} +proc TTF_OpenFontIndex*(filename: cstring, ptsize: int, index: int32): PTTF_Font{. + cdecl, importc, dynlib: SDLttfLibName.} +proc TTF_OpenFontRW*(src: PSDL_RWops, freesrc: int, ptsize: int): PTTF_Font{. + cdecl, importc, dynlib: SDLttfLibName.} +proc TTF_OpenFontIndexRW*(src: PSDL_RWops, freesrc: int, ptsize: int, + index: int32): PTTF_Font{.cdecl, importc, dynlib: SDLttfLibName.} +proc TTF_GetFontStyle*(font: PTTF_Font): int{.cdecl, importc, dynlib: SDLttfLibName.} +proc TTF_SetFontStyle*(font: PTTF_Font, style: int){.cdecl, + importc, dynlib: SDLttfLibName.} + # Get the total height of the font - usually equal to point size +proc TTF_FontHeight*(font: PTTF_Font): int{.cdecl, importc, dynlib: SDLttfLibName.} + # Get the offset from the baseline to the top of the font + # This is a positive value, relative to the baseline. + # +proc TTF_FontAscent*(font: PTTF_Font): int{.cdecl, importc, dynlib: SDLttfLibName.} + # Get the offset from the baseline to the bottom of the font + # This is a negative value, relative to the baseline. + # +proc TTF_FontDescent*(font: PTTF_Font): int{.cdecl, importc, dynlib: SDLttfLibName.} + # Get the recommended spacing between lines of text for this font +proc TTF_FontLineSkip*(font: PTTF_Font): int{.cdecl, importc, dynlib: SDLttfLibName.} + # Get the number of faces of the font +proc TTF_FontFaces*(font: PTTF_Font): int32{.cdecl, importc, dynlib: SDLttfLibName.} + # Get the font face attributes, if any +proc TTF_FontFaceIsFixedWidth*(font: PTTF_Font): int{.cdecl, + importc, dynlib: SDLttfLibName.} +proc TTF_FontFaceFamilyName*(font: PTTF_Font): cstring{.cdecl, + importc, dynlib: SDLttfLibName.} +proc TTF_FontFaceStyleName*(font: PTTF_Font): cstring{.cdecl, + importc, dynlib: SDLttfLibName.} + # Get the metrics (dimensions) of a glyph +proc TTF_GlyphMetrics*(font: PTTF_Font, ch: Uint16, minx: var int, + maxx: var int, miny: var int, maxy: var int, + advance: var int): int{.cdecl, importc, dynlib: SDLttfLibName.} + # Get the dimensions of a rendered string of text +proc TTF_SizeText*(font: PTTF_Font, text: cstring, w: var int, y: var int): int{. + cdecl, importc, dynlib: SDLttfLibName.} +proc TTF_SizeUTF8*(font: PTTF_Font, text: cstring, w: var int, y: var int): int{. + cdecl, importc, dynlib: SDLttfLibName.} +proc TTF_SizeUNICODE*(font: PTTF_Font, text: PUint16, w: var int, y: var int): int{. + cdecl, importc, dynlib: SDLttfLibName.} + # Create an 8-bit palettized surface and render the given text at + # fast quality with the given font and color. The 0 pixel is the + # colorkey, giving a transparent background, and the 1 pixel is set + # to the text color. + # This function returns the new surface, or NULL if there was an error. + # +proc TTF_RenderUTF8_Solid*(font: PTTF_Font, text: cstring, fg: TSDL_Color): PSDL_Surface{. + cdecl, importc, dynlib: SDLttfLibName.} +proc TTF_RenderUNICODE_Solid*(font: PTTF_Font, text: PUint16, fg: TSDL_Color): PSDL_Surface{. + cdecl, importc, dynlib: SDLttfLibName.} + # + #Create an 8-bit palettized surface and render the given glyph at + # fast quality with the given font and color. The 0 pixel is the + # colorkey, giving a transparent background, and the 1 pixel is set + # to the text color. The glyph is rendered without any padding or + # centering in the X direction, and aligned normally in the Y direction. + # This function returns the new surface, or NULL if there was an error. + # +proc TTF_RenderGlyph_Solid*(font: PTTF_Font, ch: Uint16, fg: TSDL_Color): PSDL_Surface{. + cdecl, importc, dynlib: SDLttfLibName.} + # Create an 8-bit palettized surface and render the given text at + # high quality with the given font and colors. The 0 pixel is background, + # while other pixels have varying degrees of the foreground color. + # This function returns the new surface, or NULL if there was an error. + # +proc TTF_RenderText_Shaded*(font: PTTF_Font, text: cstring, fg: TSDL_Color, + bg: TSDL_Color): PSDL_Surface{.cdecl, + importc, dynlib: SDLttfLibName.} +proc TTF_RenderUTF8_Shaded*(font: PTTF_Font, text: cstring, fg: TSDL_Color, + bg: TSDL_Color): PSDL_Surface{.cdecl, + importc, dynlib: SDLttfLibName.} +proc TTF_RenderUNICODE_Shaded*(font: PTTF_Font, text: PUint16, fg: TSDL_Color, + bg: TSDL_Color): PSDL_Surface{.cdecl, + importc, dynlib: SDLttfLibName.} + # Create an 8-bit palettized surface and render the given glyph at + # high quality with the given font and colors. The 0 pixel is background, + # while other pixels have varying degrees of the foreground color. + # The glyph is rendered without any padding or centering in the X + # direction, and aligned normally in the Y direction. + # This function returns the new surface, or NULL if there was an error. + # +proc TTF_RenderGlyph_Shaded*(font: PTTF_Font, ch: Uint16, fg: TSDL_Color, + bg: TSDL_Color): PSDL_Surface{.cdecl, + importc, dynlib: SDLttfLibName.} + # Create a 32-bit ARGB surface and render the given text at high quality, + # using alpha blending to dither the font with the given color. + # This function returns the new surface, or NULL if there was an error. + # +proc TTF_RenderText_Blended*(font: PTTF_Font, text: cstring, fg: TSDL_Color): PSDL_Surface{. + cdecl, importc, dynlib: SDLttfLibName.} +proc TTF_RenderUTF8_Blended*(font: PTTF_Font, text: cstring, fg: TSDL_Color): PSDL_Surface{. + cdecl, importc, dynlib: SDLttfLibName.} +proc TTF_RenderUNICODE_Blended*(font: PTTF_Font, text: PUint16, fg: TSDL_Color): PSDL_Surface{. + cdecl, importc, dynlib: SDLttfLibName.} + # Create a 32-bit ARGB surface and render the given glyph at high quality, + # using alpha blending to dither the font with the given color. + # The glyph is rendered without any padding or centering in the X + # direction, and aligned normally in the Y direction. + # This function returns the new surface, or NULL if there was an error. + # +proc TTF_RenderGlyph_Blended*(font: PTTF_Font, ch: Uint16, fg: TSDL_Color): PSDL_Surface{. + cdecl, importc, dynlib: SDLttfLibName.} + # For compatibility with previous versions, here are the old functions + ##define TTF_RenderText(font, text, fg, bg) + # TTF_RenderText_Shaded(font, text, fg, bg) + ##define TTF_RenderUTF8(font, text, fg, bg) + # TTF_RenderUTF8_Shaded(font, text, fg, bg) + ##define TTF_RenderUNICODE(font, text, fg, bg) + # TTF_RenderUNICODE_Shaded(font, text, fg, bg) + # Close an opened font file +proc TTF_CloseFont*(font: PTTF_Font){.cdecl, importc, dynlib: SDLttfLibName.} + #De-initialize TTF engine +proc TTF_Quit*(){.cdecl, importc, dynlib: SDLttfLibName.} + # Check if the TTF engine is initialized +proc TTF_WasInit*(): int{.cdecl, importc, dynlib: SDLttfLibName.} + # We'll use SDL for reporting errors +proc TTF_SetError*(fmt: cstring) +proc TTF_GetError*(): cstring +# implementation + +proc SDL_TTF_VERSION(X: var TSDL_version) = + X.major = SDL_TTF_MAJOR_VERSION + X.minor = SDL_TTF_MINOR_VERSION + X.patch = SDL_TTF_PATCHLEVEL + +proc TTF_SetError(fmt: cstring) = + SDL_SetError(fmt) + +proc TTF_GetError(): cstring = + result = SDL_GetError() + +when not(defined(Workaround_TTF_RenderText_Solid)): + proc TTF_RenderText_Solid*(font: PTTF_Font, text: cstring, fg: TSDL_Color): PSDL_Surface{. + cdecl, importc, dynlib: SDLttfLibName.} +else: + proc TTF_RenderText_Solid(font: PTTF_Font, text: cstring, fg: TSDL_Color): PSDL_Surface = + var Black: TSDL_Color # initialized to zero + Result = TTF_RenderText_Shaded(font, text, fg, Black) diff --git a/lib/base/sdl/sdlutils.pas b/lib/base/sdl/sdlutils.pas new file mode 100644 index 000000000..e4206e935 --- /dev/null +++ b/lib/base/sdl/sdlutils.pas @@ -0,0 +1,4354 @@ +unit sdlutils; +{ + $Id: sdlutils.pas,v 1.5 2006/11/19 18:56:44 savage Exp $ + +} +{******************************************************************************} +{ } +{ Borland Delphi SDL - Simple DirectMedia Layer } +{ SDL Utility functions } +{ } +{ } +{ The initial developer of this Pascal code was : } +{ Tom Jones <tigertomjones@gmx.de> } +{ } +{ Portions created by Tom Jones are } +{ Copyright (C) 2000 - 2001 Tom Jones. } +{ } +{ } +{ Contributor(s) } +{ -------------- } +{ Dominique Louis <Dominique@SavageSoftware.com.au> } +{ Róbert Kisnémeth <mikrobi@freemail.hu> } +{ } +{ Obtained through: } +{ Joint Endeavour of Delphi Innovators ( Project JEDI ) } +{ } +{ You may retrieve the latest version of this file at the Project } +{ JEDI home page, located at http://delphi-jedi.org } +{ } +{ The contents of this file are used with permission, subject to } +{ the Mozilla Public License Version 1.1 (the "License"); you may } +{ not use this file except in compliance with the License. You may } +{ obtain a copy of the License at } +{ http://www.mozilla.org/MPL/MPL-1.1.html } +{ } +{ Software distributed under the License is distributed on an } +{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or } +{ implied. See the License for the specific language governing } +{ rights and limitations under the License. } +{ } +{ Description } +{ ----------- } +{ Helper functions... } +{ } +{ } +{ Requires } +{ -------- } +{ SDL.dll on Windows platforms } +{ libSDL-1.1.so.0 on Linux platform } +{ } +{ Programming Notes } +{ ----------------- } +{ } +{ } +{ } +{ } +{ Revision History } +{ ---------------- } +{ 2000 - TJ : Initial creation } +{ } +{ July 13 2001 - DL : Added PutPixel and GetPixel routines. } +{ } +{ Sept 14 2001 - RK : Added flipping routines. } +{ } +{ Sept 19 2001 - RK : Added PutPixel & line drawing & blitting with ADD } +{ effect. Fixed a bug in SDL_PutPixel & SDL_GetPixel } +{ Added PSDLRect() } +{ Sept 22 2001 - DL : Removed need for Windows.pas by defining types here} +{ Also removed by poor attempt or a dialog box } +{ } +{ Sept 25 2001 - RK : Added PixelTest, NewPutPixel, SubPixel, SubLine, } +{ SubSurface, MonoSurface & TexturedSurface } +{ } +{ Sept 26 2001 - DL : Made change so that it refers to native Pascal } +{ types rather that Windows types. This makes it more} +{ portable to Linix. } +{ } +{ Sept 27 2001 - RK : SDLUtils now can be compiled with FreePascal } +{ } +{ Oct 27 2001 - JF : Added ScrollY function } +{ } +{ Jan 21 2002 - RK : Added SDL_ZoomSurface and SDL_WarpSurface } +{ } +{ Mar 28 2002 - JF : Added SDL_RotateSurface } +{ } +{ May 13 2002 - RK : Improved SDL_FillRectAdd & SDL_FillRectSub } +{ } +{ May 27 2002 - YS : GradientFillRect function } +{ } +{ May 30 2002 - RK : Added SDL_2xBlit, SDL_Scanline2xBlit } +{ & SDL_50Scanline2xBlit } +{ } +{ June 12 2002 - RK : Added SDL_PixelTestSurfaceVsRect } +{ } +{ June 12 2002 - JF : Updated SDL_PixelTestSurfaceVsRect } +{ } +{ November 9 2002 - JF : Added Jason's boolean Surface functions } +{ } +{ December 10 2002 - DE : Added Dean's SDL_ClipLine function } +{ } +{ April 26 2003 - SS : Incorporated JF's changes to SDL_ClipLine } +{ Fixed SDL_ClipLine bug for non-zero cliprect x, y } +{ Added overloaded SDL_DrawLine for dashed lines } +{ } +{******************************************************************************} +{ + $Log: sdlutils.pas,v $ + Revision 1.5 2006/11/19 18:56:44 savage + Removed Hints and Warnings. + + Revision 1.4 2004/06/02 19:38:53 savage + Changes to SDL_GradientFillRect as suggested by + Ángel Eduardo García Hernández. Many thanks. + + Revision 1.3 2004/05/29 23:11:54 savage + Changes to SDL_ScaleSurfaceRect as suggested by + Ángel Eduardo García Hernández to fix a colour issue with the function. Many thanks. + + Revision 1.2 2004/02/14 00:23:39 savage + As UNIX is defined in jedi-sdl.inc this will be used to check linux compatability as well. Units have been changed to reflect this change. + + Revision 1.1 2004/02/05 00:08:20 savage + Module 1.0 release + + +} + +interface + +uses + sdl; + +type + TGradientStyle = ( gsHorizontal, gsVertical ); + +// Pixel procedures +function SDL_PixelTest( SrcSurface1 : PSDL_Surface; SrcRect1 : PSDL_Rect; SrcSurface2 : + PSDL_Surface; SrcRect2 : PSDL_Rect; Left1, Top1, Left2, Top2 : integer ) : Boolean; + +function SDL_GetPixel( SrcSurface : PSDL_Surface; x : integer; y : integer ) : Uint32; + +procedure SDL_PutPixel( DstSurface : PSDL_Surface; x : integer; y : integer; pixel : + Uint32 ); + +procedure SDL_AddPixel( DstSurface : PSDL_Surface; x : cardinal; y : cardinal; Color : + cardinal ); + +procedure SDL_SubPixel( DstSurface : PSDL_Surface; x : cardinal; y : cardinal; Color : + cardinal ); + +// Line procedures +procedure SDL_DrawLine( DstSurface : PSDL_Surface; x1, y1, x2, y2 : integer; Color : + cardinal ); overload; + +procedure SDL_DrawLine( DstSurface : PSDL_Surface; x1, y1, x2, y2 : integer; Color : + cardinal; DashLength, DashSpace : byte ); overload; + +procedure SDL_AddLine( DstSurface : PSDL_Surface; x1, y1, x2, y2 : integer; Color : + cardinal ); + +procedure SDL_SubLine( DstSurface : PSDL_Surface; x1, y1, x2, y2 : integer; Color : + cardinal ); + +// Surface procedures +procedure SDL_AddSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; + DestSurface : PSDL_Surface; DestRect : PSDL_Rect ); + +procedure SDL_SubSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; + DestSurface : PSDL_Surface; DestRect : PSDL_Rect ); + +procedure SDL_MonoSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; + DestSurface : PSDL_Surface; DestRect : PSDL_Rect; Color : cardinal ); + +procedure SDL_TexturedSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; + DestSurface : PSDL_Surface; DestRect : PSDL_Rect; Texture : PSDL_Surface; + TextureRect : PSDL_Rect ); + +procedure SDL_ZoomSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; DstSurface : PSDL_Surface; DstRect : PSDL_Rect ); + +procedure SDL_WarpSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; DstSurface : PSDL_Surface; UL, UR, LR, LL : PPoint ); + +// Flip procedures +procedure SDL_FlipRectH( DstSurface : PSDL_Surface; Rect : PSDL_Rect ); + +procedure SDL_FlipRectV( DstSurface : PSDL_Surface; Rect : PSDL_Rect ); + +function PSDLRect( aLeft, aTop, aWidth, aHeight : integer ) : PSDL_Rect; + +function SDLRect( aLeft, aTop, aWidth, aHeight : integer ) : TSDL_Rect; overload; + +function SDLRect( aRect : TRect ) : TSDL_Rect; overload; + +function SDL_ScaleSurfaceRect( SrcSurface : PSDL_Surface; SrcX1, SrcY1, SrcW, SrcH, + Width, Height : integer ) : PSDL_Surface; + +procedure SDL_ScrollY( DstSurface : PSDL_Surface; DifY : integer ); + +procedure SDL_ScrollX( DstSurface : PSDL_Surface; DifX : integer ); + +procedure SDL_RotateDeg( DstSurface, SrcSurface : PSDL_Surface; SrcRect : + PSDL_Rect; DestX, DestY, OffsetX, OffsetY : Integer; Angle : Integer ); + +procedure SDL_RotateRad( DstSurface, SrcSurface : PSDL_Surface; SrcRect : + PSDL_Rect; DestX, DestY, OffsetX, OffsetY : Integer; Angle : Single ); + +function ValidateSurfaceRect( DstSurface : PSDL_Surface; dstrect : PSDL_Rect ) : TSDL_Rect; + +// Fill Rect routine +procedure SDL_FillRectAdd( DstSurface : PSDL_Surface; dstrect : PSDL_Rect; color : UInt32 ); + +procedure SDL_FillRectSub( DstSurface : PSDL_Surface; dstrect : PSDL_Rect; color : UInt32 ); + +procedure SDL_GradientFillRect( DstSurface : PSDL_Surface; const Rect : PSDL_Rect; const StartColor, EndColor : TSDL_Color; const Style : TGradientStyle ); + +// NOTE for All SDL_2xblit... function : the dest surface must be 2x of the source surface! +procedure SDL_2xBlit( Src, Dest : PSDL_Surface ); + +procedure SDL_Scanline2xBlit( Src, Dest : PSDL_Surface ); + +procedure SDL_50Scanline2xBlit( Src, Dest : PSDL_Surface ); + +// +function SDL_PixelTestSurfaceVsRect( SrcSurface1 : PSDL_Surface; SrcRect1 : + PSDL_Rect; SrcRect2 : PSDL_Rect; Left1, Top1, Left2, Top2 : integer ) : + boolean; + +// Jason's boolean Surface functions +procedure SDL_ORSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; + DestSurface : PSDL_Surface; DestRect : PSDL_Rect ); + +procedure SDL_ANDSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; + DestSurface : PSDL_Surface; DestRect : PSDL_Rect ); + + +procedure SDL_GTSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; + DestSurface : PSDL_Surface; DestRect : PSDL_Rect ); + +procedure SDL_LTSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; + DestSurface : PSDL_Surface; DestRect : PSDL_Rect ); + +function SDL_ClipLine( var x1, y1, x2, y2 : Integer; ClipRect : PSDL_Rect ) : boolean; + +implementation + +uses + Math; + +function SDL_PixelTest( SrcSurface1 : PSDL_Surface; SrcRect1 : PSDL_Rect; SrcSurface2 : + PSDL_Surface; SrcRect2 : PSDL_Rect; Left1, Top1, Left2, Top2 : integer ) : boolean; +var + Src_Rect1, Src_Rect2 : TSDL_Rect; + right1, bottom1 : integer; + right2, bottom2 : integer; + Scan1Start, Scan2Start, ScanWidth, ScanHeight : cardinal; + Mod1, Mod2 : cardinal; + Addr1, Addr2 : cardinal; + BPP : cardinal; + Pitch1, Pitch2 : cardinal; + TransparentColor1, TransparentColor2 : cardinal; + tx, ty : cardinal; + StartTick : cardinal; + Color1, Color2 : cardinal; +begin + Result := false; + if SrcRect1 = nil then + begin + with Src_Rect1 do + begin + x := 0; + y := 0; + w := SrcSurface1.w; + h := SrcSurface1.h; + end; + end + else + Src_Rect1 := SrcRect1^; + if SrcRect2 = nil then + begin + with Src_Rect2 do + begin + x := 0; + y := 0; + w := SrcSurface2.w; + h := SrcSurface2.h; + end; + end + else + Src_Rect2 := SrcRect2^; + with Src_Rect1 do + begin + Right1 := Left1 + w; + Bottom1 := Top1 + h; + end; + with Src_Rect2 do + begin + Right2 := Left2 + w; + Bottom2 := Top2 + h; + end; + if ( Left1 >= Right2 ) or ( Right1 <= Left2 ) or ( Top1 >= Bottom2 ) or ( Bottom1 <= + Top2 ) then + exit; + if Left1 <= Left2 then + begin + // 1. left, 2. right + Scan1Start := Src_Rect1.x + Left2 - Left1; + Scan2Start := Src_Rect2.x; + ScanWidth := Right1 - Left2; + with Src_Rect2 do + if ScanWidth > w then + ScanWidth := w; + end + else + begin + // 1. right, 2. left + Scan1Start := Src_Rect1.x; + Scan2Start := Src_Rect2.x + Left1 - Left2; + ScanWidth := Right2 - Left1; + with Src_Rect1 do + if ScanWidth > w then + ScanWidth := w; + end; + with SrcSurface1^ do + begin + Pitch1 := Pitch; + Addr1 := cardinal( Pixels ); + inc( Addr1, Pitch1 * UInt32( Src_Rect1.y ) ); + with format^ do + begin + BPP := BytesPerPixel; + TransparentColor1 := colorkey; + end; + end; + with SrcSurface2^ do + begin + TransparentColor2 := format.colorkey; + Pitch2 := Pitch; + Addr2 := cardinal( Pixels ); + inc( Addr2, Pitch2 * UInt32( Src_Rect2.y ) ); + end; + Mod1 := Pitch1 - ( ScanWidth * BPP ); + Mod2 := Pitch2 - ( ScanWidth * BPP ); + inc( Addr1, BPP * Scan1Start ); + inc( Addr2, BPP * Scan2Start ); + if Top1 <= Top2 then + begin + // 1. up, 2. down + ScanHeight := Bottom1 - Top2; + if ScanHeight > Src_Rect2.h then + ScanHeight := Src_Rect2.h; + inc( Addr1, Pitch1 * UInt32( Top2 - Top1 ) ); + end + else + begin + // 1. down, 2. up + ScanHeight := Bottom2 - Top1; + if ScanHeight > Src_Rect1.h then + ScanHeight := Src_Rect1.h; + inc( Addr2, Pitch2 * UInt32( Top1 - Top2 ) ); + end; + case BPP of + 1 : + for ty := 1 to ScanHeight do + begin + for tx := 1 to ScanWidth do + begin + if ( PByte( Addr1 )^ <> TransparentColor1 ) and ( PByte( Addr2 )^ <> + TransparentColor2 ) then + begin + Result := true; + exit; + end; + inc( Addr1 ); + inc( Addr2 ); + end; + inc( Addr1, Mod1 ); + inc( Addr2, Mod2 ); + end; + 2 : + for ty := 1 to ScanHeight do + begin + for tx := 1 to ScanWidth do + begin + if ( PWord( Addr1 )^ <> TransparentColor1 ) and ( PWord( Addr2 )^ <> + TransparentColor2 ) then + begin + Result := true; + exit; + end; + inc( Addr1, 2 ); + inc( Addr2, 2 ); + end; + inc( Addr1, Mod1 ); + inc( Addr2, Mod2 ); + end; + 3 : + for ty := 1 to ScanHeight do + begin + for tx := 1 to ScanWidth do + begin + Color1 := PLongWord( Addr1 )^ and $00FFFFFF; + Color2 := PLongWord( Addr2 )^ and $00FFFFFF; + if ( Color1 <> TransparentColor1 ) and ( Color2 <> TransparentColor2 ) + then + begin + Result := true; + exit; + end; + inc( Addr1, 3 ); + inc( Addr2, 3 ); + end; + inc( Addr1, Mod1 ); + inc( Addr2, Mod2 ); + end; + 4 : + for ty := 1 to ScanHeight do + begin + for tx := 1 to ScanWidth do + begin + if ( PLongWord( Addr1 )^ <> TransparentColor1 ) and ( PLongWord( Addr2 )^ <> + TransparentColor2 ) then + begin + Result := true; + exit; + end; + inc( Addr1, 4 ); + inc( Addr2, 4 ); + end; + inc( Addr1, Mod1 ); + inc( Addr2, Mod2 ); + end; + end; +end; + +procedure SDL_AddPixel( DstSurface : PSDL_Surface; x : cardinal; y : cardinal; Color : + cardinal ); +var + SrcColor : cardinal; + Addr : cardinal; + R, G, B : cardinal; +begin + if Color = 0 then + exit; + with DstSurface^ do + begin + Addr := cardinal( Pixels ) + y * Pitch + x * format.BytesPerPixel; + SrcColor := PUInt32( Addr )^; + case format.BitsPerPixel of + 8 : + begin + R := SrcColor and $E0 + Color and $E0; + G := SrcColor and $1C + Color and $1C; + B := SrcColor and $03 + Color and $03; + if R > $E0 then + R := $E0; + if G > $1C then + G := $1C; + if B > $03 then + B := $03; + PUInt8( Addr )^ := R or G or B; + end; + 15 : + begin + R := SrcColor and $7C00 + Color and $7C00; + G := SrcColor and $03E0 + Color and $03E0; + B := SrcColor and $001F + Color and $001F; + if R > $7C00 then + R := $7C00; + if G > $03E0 then + G := $03E0; + if B > $001F then + B := $001F; + PUInt16( Addr )^ := R or G or B; + end; + 16 : + begin + R := SrcColor and $F800 + Color and $F800; + G := SrcColor and $07C0 + Color and $07C0; + B := SrcColor and $001F + Color and $001F; + if R > $F800 then + R := $F800; + if G > $07C0 then + G := $07C0; + if B > $001F then + B := $001F; + PUInt16( Addr )^ := R or G or B; + end; + 24 : + begin + R := SrcColor and $00FF0000 + Color and $00FF0000; + G := SrcColor and $0000FF00 + Color and $0000FF00; + B := SrcColor and $000000FF + Color and $000000FF; + if R > $FF0000 then + R := $FF0000; + if G > $00FF00 then + G := $00FF00; + if B > $0000FF then + B := $0000FF; + PUInt32( Addr )^ := SrcColor and $FF000000 or R or G or B; + end; + 32 : + begin + R := SrcColor and $00FF0000 + Color and $00FF0000; + G := SrcColor and $0000FF00 + Color and $0000FF00; + B := SrcColor and $000000FF + Color and $000000FF; + if R > $FF0000 then + R := $FF0000; + if G > $00FF00 then + G := $00FF00; + if B > $0000FF then + B := $0000FF; + PUInt32( Addr )^ := R or G or B; + end; + end; + end; +end; + +procedure SDL_SubPixel( DstSurface : PSDL_Surface; x : cardinal; y : cardinal; Color : + cardinal ); +var + SrcColor : cardinal; + Addr : cardinal; + R, G, B : cardinal; +begin + if Color = 0 then + exit; + with DstSurface^ do + begin + Addr := cardinal( Pixels ) + y * Pitch + x * format.BytesPerPixel; + SrcColor := PUInt32( Addr )^; + case format.BitsPerPixel of + 8 : + begin + R := SrcColor and $E0 - Color and $E0; + G := SrcColor and $1C - Color and $1C; + B := SrcColor and $03 - Color and $03; + if R > $E0 then + R := 0; + if G > $1C then + G := 0; + if B > $03 then + B := 0; + PUInt8( Addr )^ := R or G or B; + end; + 15 : + begin + R := SrcColor and $7C00 - Color and $7C00; + G := SrcColor and $03E0 - Color and $03E0; + B := SrcColor and $001F - Color and $001F; + if R > $7C00 then + R := 0; + if G > $03E0 then + G := 0; + if B > $001F then + B := 0; + PUInt16( Addr )^ := R or G or B; + end; + 16 : + begin + R := SrcColor and $F800 - Color and $F800; + G := SrcColor and $07C0 - Color and $07C0; + B := SrcColor and $001F - Color and $001F; + if R > $F800 then + R := 0; + if G > $07C0 then + G := 0; + if B > $001F then + B := 0; + PUInt16( Addr )^ := R or G or B; + end; + 24 : + begin + R := SrcColor and $00FF0000 - Color and $00FF0000; + G := SrcColor and $0000FF00 - Color and $0000FF00; + B := SrcColor and $000000FF - Color and $000000FF; + if R > $FF0000 then + R := 0; + if G > $00FF00 then + G := 0; + if B > $0000FF then + B := 0; + PUInt32( Addr )^ := SrcColor and $FF000000 or R or G or B; + end; + 32 : + begin + R := SrcColor and $00FF0000 - Color and $00FF0000; + G := SrcColor and $0000FF00 - Color and $0000FF00; + B := SrcColor and $000000FF - Color and $000000FF; + if R > $FF0000 then + R := 0; + if G > $00FF00 then + G := 0; + if B > $0000FF then + B := 0; + PUInt32( Addr )^ := R or G or B; + end; + end; + end; +end; +// This procedure works on 8, 15, 16, 24 and 32 bits color depth surfaces. +// In 8 bit color depth mode the procedure works with the default packed +// palette (RRRGGGBB). It handles all clipping. + +procedure SDL_AddSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; + DestSurface : PSDL_Surface; DestRect : PSDL_Rect ); +var + R, G, B, Pixel1, Pixel2, TransparentColor : cardinal; + Src, Dest : TSDL_Rect; + Diff : integer; + SrcAddr, DestAddr : cardinal; + WorkX, WorkY : word; + SrcMod, DestMod : cardinal; + Bits : cardinal; +begin + if ( SrcSurface = nil ) or ( DestSurface = nil ) then + exit; // Remove this to make it faster + if ( SrcSurface.Format.BitsPerPixel <> DestSurface.Format.BitsPerPixel ) then + exit; // Remove this to make it faster + if SrcRect = nil then + begin + with Src do + begin + x := 0; + y := 0; + w := SrcSurface.w; + h := SrcSurface.h; + end; + end + else + Src := SrcRect^; + if DestRect = nil then + begin + Dest.x := 0; + Dest.y := 0; + end + else + Dest := DestRect^; + Dest.w := Src.w; + Dest.h := Src.h; + with DestSurface.Clip_Rect do + begin + // Source's right side is greater than the dest.cliprect + if Dest.x + Src.w > x + w then + begin + smallint( Src.w ) := x + w - Dest.x; + smallint( Dest.w ) := x + w - Dest.x; + if smallint( Dest.w ) < 1 then + exit; + end; + // Source's bottom side is greater than the dest.clip + if Dest.y + Src.h > y + h then + begin + smallint( Src.h ) := y + h - Dest.y; + smallint( Dest.h ) := y + h - Dest.y; + if smallint( Dest.h ) < 1 then + exit; + end; + // Source's left side is less than the dest.clip + if Dest.x < x then + begin + Diff := x - Dest.x; + Src.x := Src.x + Diff; + smallint( Src.w ) := smallint( Src.w ) - Diff; + Dest.x := x; + smallint( Dest.w ) := smallint( Dest.w ) - Diff; + if smallint( Dest.w ) < 1 then + exit; + end; + // Source's Top side is less than the dest.clip + if Dest.y < y then + begin + Diff := y - Dest.y; + Src.y := Src.y + Diff; + smallint( Src.h ) := smallint( Src.h ) - Diff; + Dest.y := y; + smallint( Dest.h ) := smallint( Dest.h ) - Diff; + if smallint( Dest.h ) < 1 then + exit; + end; + end; + with SrcSurface^ do + begin + SrcAddr := cardinal( Pixels ) + UInt32( Src.y ) * Pitch + UInt32( Src.x ) * + Format.BytesPerPixel; + SrcMod := Pitch - Src.w * Format.BytesPerPixel; + TransparentColor := Format.colorkey; + end; + with DestSurface^ do + begin + DestAddr := cardinal( Pixels ) + UInt32( Dest.y ) * Pitch + UInt32( Dest.x ) * + Format.BytesPerPixel; + DestMod := Pitch - Dest.w * Format.BytesPerPixel; + Bits := Format.BitsPerPixel; + end; + SDL_LockSurface( SrcSurface ); + SDL_LockSurface( DestSurface ); + WorkY := Src.h; + case bits of + 8 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt8( SrcAddr )^; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt8( DestAddr )^; + if Pixel2 > 0 then + begin + R := Pixel1 and $E0 + Pixel2 and $E0; + G := Pixel1 and $1C + Pixel2 and $1C; + B := Pixel1 and $03 + Pixel2 and $03; + if R > $E0 then + R := $E0; + if G > $1C then + G := $1C; + if B > $03 then + B := $03; + PUInt8( DestAddr )^ := R or G or B; + end + else + PUInt8( DestAddr )^ := Pixel1; + end; + inc( SrcAddr ); + inc( DestAddr ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + 15 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt16( SrcAddr )^; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt16( DestAddr )^; + if Pixel2 > 0 then + begin + R := Pixel1 and $7C00 + Pixel2 and $7C00; + G := Pixel1 and $03E0 + Pixel2 and $03E0; + B := Pixel1 and $001F + Pixel2 and $001F; + if R > $7C00 then + R := $7C00; + if G > $03E0 then + G := $03E0; + if B > $001F then + B := $001F; + PUInt16( DestAddr )^ := R or G or B; + end + else + PUInt16( DestAddr )^ := Pixel1; + end; + inc( SrcAddr, 2 ); + inc( DestAddr, 2 ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + 16 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt16( SrcAddr )^; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt16( DestAddr )^; + if Pixel2 > 0 then + begin + R := Pixel1 and $F800 + Pixel2 and $F800; + G := Pixel1 and $07E0 + Pixel2 and $07E0; + B := Pixel1 and $001F + Pixel2 and $001F; + if R > $F800 then + R := $F800; + if G > $07E0 then + G := $07E0; + if B > $001F then + B := $001F; + PUInt16( DestAddr )^ := R or G or B; + end + else + PUInt16( DestAddr )^ := Pixel1; + end; + inc( SrcAddr, 2 ); + inc( DestAddr, 2 ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + 24 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt32( SrcAddr )^ and $00FFFFFF; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt32( DestAddr )^ and $00FFFFFF; + if Pixel2 > 0 then + begin + R := Pixel1 and $FF0000 + Pixel2 and $FF0000; + G := Pixel1 and $00FF00 + Pixel2 and $00FF00; + B := Pixel1 and $0000FF + Pixel2 and $0000FF; + if R > $FF0000 then + R := $FF0000; + if G > $00FF00 then + G := $00FF00; + if B > $0000FF then + B := $0000FF; + PUInt32( DestAddr )^ := PUInt32( DestAddr )^ and $FF000000 or ( R or G or B ); + end + else + PUInt32( DestAddr )^ := PUInt32( DestAddr )^ and $FF000000 or Pixel1; + end; + inc( SrcAddr, 3 ); + inc( DestAddr, 3 ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + 32 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt32( SrcAddr )^; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt32( DestAddr )^; + if Pixel2 > 0 then + begin + R := Pixel1 and $FF0000 + Pixel2 and $FF0000; + G := Pixel1 and $00FF00 + Pixel2 and $00FF00; + B := Pixel1 and $0000FF + Pixel2 and $0000FF; + if R > $FF0000 then + R := $FF0000; + if G > $00FF00 then + G := $00FF00; + if B > $0000FF then + B := $0000FF; + PUInt32( DestAddr )^ := R or G or B; + end + else + PUInt32( DestAddr )^ := Pixel1; + end; + inc( SrcAddr, 4 ); + inc( DestAddr, 4 ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + end; + SDL_UnlockSurface( SrcSurface ); + SDL_UnlockSurface( DestSurface ); +end; + +procedure SDL_SubSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; + DestSurface : PSDL_Surface; DestRect : PSDL_Rect ); +var + R, G, B, Pixel1, Pixel2, TransparentColor : cardinal; + Src, Dest : TSDL_Rect; + Diff : integer; + SrcAddr, DestAddr : cardinal; + _ebx, _esi, _edi, _esp : cardinal; + WorkX, WorkY : word; + SrcMod, DestMod : cardinal; + Bits : cardinal; +begin + if ( SrcSurface = nil ) or ( DestSurface = nil ) then + exit; // Remove this to make it faster + if ( SrcSurface.Format.BitsPerPixel <> DestSurface.Format.BitsPerPixel ) then + exit; // Remove this to make it faster + if SrcRect = nil then + begin + with Src do + begin + x := 0; + y := 0; + w := SrcSurface.w; + h := SrcSurface.h; + end; + end + else + Src := SrcRect^; + if DestRect = nil then + begin + Dest.x := 0; + Dest.y := 0; + end + else + Dest := DestRect^; + Dest.w := Src.w; + Dest.h := Src.h; + with DestSurface.Clip_Rect do + begin + // Source's right side is greater than the dest.cliprect + if Dest.x + Src.w > x + w then + begin + smallint( Src.w ) := x + w - Dest.x; + smallint( Dest.w ) := x + w - Dest.x; + if smallint( Dest.w ) < 1 then + exit; + end; + // Source's bottom side is greater than the dest.clip + if Dest.y + Src.h > y + h then + begin + smallint( Src.h ) := y + h - Dest.y; + smallint( Dest.h ) := y + h - Dest.y; + if smallint( Dest.h ) < 1 then + exit; + end; + // Source's left side is less than the dest.clip + if Dest.x < x then + begin + Diff := x - Dest.x; + Src.x := Src.x + Diff; + smallint( Src.w ) := smallint( Src.w ) - Diff; + Dest.x := x; + smallint( Dest.w ) := smallint( Dest.w ) - Diff; + if smallint( Dest.w ) < 1 then + exit; + end; + // Source's Top side is less than the dest.clip + if Dest.y < y then + begin + Diff := y - Dest.y; + Src.y := Src.y + Diff; + smallint( Src.h ) := smallint( Src.h ) - Diff; + Dest.y := y; + smallint( Dest.h ) := smallint( Dest.h ) - Diff; + if smallint( Dest.h ) < 1 then + exit; + end; + end; + with SrcSurface^ do + begin + SrcAddr := cardinal( Pixels ) + UInt32( Src.y ) * Pitch + UInt32( Src.x ) * + Format.BytesPerPixel; + SrcMod := Pitch - Src.w * Format.BytesPerPixel; + TransparentColor := Format.colorkey; + end; + with DestSurface^ do + begin + DestAddr := cardinal( Pixels ) + UInt32( Dest.y ) * Pitch + UInt32( Dest.x ) * + Format.BytesPerPixel; + DestMod := Pitch - Dest.w * Format.BytesPerPixel; + Bits := DestSurface.Format.BitsPerPixel; + end; + SDL_LockSurface( SrcSurface ); + SDL_LockSurface( DestSurface ); + WorkY := Src.h; + case bits of + 8 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt8( SrcAddr )^; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt8( DestAddr )^; + if Pixel2 > 0 then + begin + R := Pixel2 and $E0 - Pixel1 and $E0; + G := Pixel2 and $1C - Pixel1 and $1C; + B := Pixel2 and $03 - Pixel1 and $03; + if R > $E0 then + R := 0; + if G > $1C then + G := 0; + if B > $03 then + B := 0; + PUInt8( DestAddr )^ := R or G or B; + end; + end; + inc( SrcAddr ); + inc( DestAddr ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + 15 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt16( SrcAddr )^; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt16( DestAddr )^; + if Pixel2 > 0 then + begin + R := Pixel2 and $7C00 - Pixel1 and $7C00; + G := Pixel2 and $03E0 - Pixel1 and $03E0; + B := Pixel2 and $001F - Pixel1 and $001F; + if R > $7C00 then + R := 0; + if G > $03E0 then + G := 0; + if B > $001F then + B := 0; + PUInt16( DestAddr )^ := R or G or B; + end; + end; + inc( SrcAddr, 2 ); + inc( DestAddr, 2 ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + 16 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt16( SrcAddr )^; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt16( DestAddr )^; + if Pixel2 > 0 then + begin + R := Pixel2 and $F800 - Pixel1 and $F800; + G := Pixel2 and $07E0 - Pixel1 and $07E0; + B := Pixel2 and $001F - Pixel1 and $001F; + if R > $F800 then + R := 0; + if G > $07E0 then + G := 0; + if B > $001F then + B := 0; + PUInt16( DestAddr )^ := R or G or B; + end; + end; + inc( SrcAddr, 2 ); + inc( DestAddr, 2 ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + 24 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt32( SrcAddr )^ and $00FFFFFF; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt32( DestAddr )^ and $00FFFFFF; + if Pixel2 > 0 then + begin + R := Pixel2 and $FF0000 - Pixel1 and $FF0000; + G := Pixel2 and $00FF00 - Pixel1 and $00FF00; + B := Pixel2 and $0000FF - Pixel1 and $0000FF; + if R > $FF0000 then + R := 0; + if G > $00FF00 then + G := 0; + if B > $0000FF then + B := 0; + PUInt32( DestAddr )^ := PUInt32( DestAddr )^ and $FF000000 or ( R or G or B ); + end; + end; + inc( SrcAddr, 3 ); + inc( DestAddr, 3 ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + 32 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt32( SrcAddr )^; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt32( DestAddr )^; + if Pixel2 > 0 then + begin + R := Pixel2 and $FF0000 - Pixel1 and $FF0000; + G := Pixel2 and $00FF00 - Pixel1 and $00FF00; + B := Pixel2 and $0000FF - Pixel1 and $0000FF; + if R > $FF0000 then + R := 0; + if G > $00FF00 then + G := 0; + if B > $0000FF then + B := 0; + PUInt32( DestAddr )^ := R or G or B; + end + else + PUInt32( DestAddr )^ := Pixel2; + end; + inc( SrcAddr, 4 ); + inc( DestAddr, 4 ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + end; + SDL_UnlockSurface( SrcSurface ); + SDL_UnlockSurface( DestSurface ); +end; + +procedure SDL_MonoSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; + DestSurface : PSDL_Surface; DestRect : PSDL_Rect; Color : cardinal ); +var + Src, Dest : TSDL_Rect; + Diff : integer; + SrcAddr, DestAddr : cardinal; + _ebx, _esi, _edi, _esp : cardinal; + WorkX, WorkY : word; + SrcMod, DestMod : cardinal; + TransparentColor, SrcColor : cardinal; + BPP : cardinal; +begin + if ( SrcSurface = nil ) or ( DestSurface = nil ) then + exit; // Remove this to make it faster + if ( SrcSurface.Format.BitsPerPixel <> DestSurface.Format.BitsPerPixel ) then + exit; // Remove this to make it faster + if SrcRect = nil then + begin + with Src do + begin + x := 0; + y := 0; + w := SrcSurface.w; + h := SrcSurface.h; + end; + end + else + Src := SrcRect^; + if DestRect = nil then + begin + Dest.x := 0; + Dest.y := 0; + end + else + Dest := DestRect^; + Dest.w := Src.w; + Dest.h := Src.h; + with DestSurface.Clip_Rect do + begin + // Source's right side is greater than the dest.cliprect + if Dest.x + Src.w > x + w then + begin + smallint( Src.w ) := x + w - Dest.x; + smallint( Dest.w ) := x + w - Dest.x; + if smallint( Dest.w ) < 1 then + exit; + end; + // Source's bottom side is greater than the dest.clip + if Dest.y + Src.h > y + h then + begin + smallint( Src.h ) := y + h - Dest.y; + smallint( Dest.h ) := y + h - Dest.y; + if smallint( Dest.h ) < 1 then + exit; + end; + // Source's left side is less than the dest.clip + if Dest.x < x then + begin + Diff := x - Dest.x; + Src.x := Src.x + Diff; + smallint( Src.w ) := smallint( Src.w ) - Diff; + Dest.x := x; + smallint( Dest.w ) := smallint( Dest.w ) - Diff; + if smallint( Dest.w ) < 1 then + exit; + end; + // Source's Top side is less than the dest.clip + if Dest.y < y then + begin + Diff := y - Dest.y; + Src.y := Src.y + Diff; + smallint( Src.h ) := smallint( Src.h ) - Diff; + Dest.y := y; + smallint( Dest.h ) := smallint( Dest.h ) - Diff; + if smallint( Dest.h ) < 1 then + exit; + end; + end; + with SrcSurface^ do + begin + SrcAddr := cardinal( Pixels ) + UInt32( Src.y ) * Pitch + UInt32( Src.x ) * + Format.BytesPerPixel; + SrcMod := Pitch - Src.w * Format.BytesPerPixel; + TransparentColor := Format.colorkey; + end; + with DestSurface^ do + begin + DestAddr := cardinal( Pixels ) + UInt32( Dest.y ) * Pitch + UInt32( Dest.x ) * + Format.BytesPerPixel; + DestMod := Pitch - Dest.w * Format.BytesPerPixel; + BPP := DestSurface.Format.BytesPerPixel; + end; + SDL_LockSurface( SrcSurface ); + SDL_LockSurface( DestSurface ); + WorkY := Src.h; + case BPP of + 1 : + begin + repeat + WorkX := Src.w; + repeat + SrcColor := PUInt8( SrcAddr )^; + if SrcColor <> TransparentColor then + PUInt8( DestAddr )^ := SrcColor; + inc( SrcAddr ); + inc( DestAddr ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + 2 : + begin + repeat + WorkX := Src.w; + repeat + SrcColor := PUInt16( SrcAddr )^; + if SrcColor <> TransparentColor then + PUInt16( DestAddr )^ := SrcColor; + inc( SrcAddr ); + inc( DestAddr ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + 3 : + begin + repeat + WorkX := Src.w; + repeat + SrcColor := PUInt32( SrcAddr )^ and $FFFFFF; + if SrcColor <> TransparentColor then + PUInt32( DestAddr )^ := ( PUInt32( DestAddr )^ and $FFFFFF ) or SrcColor; + inc( SrcAddr ); + inc( DestAddr ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + 4 : + begin + repeat + WorkX := Src.w; + repeat + SrcColor := PUInt32( SrcAddr )^; + if SrcColor <> TransparentColor then + PUInt32( DestAddr )^ := SrcColor; + inc( SrcAddr ); + inc( DestAddr ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + end; + SDL_UnlockSurface( SrcSurface ); + SDL_UnlockSurface( DestSurface ); +end; +// TextureRect.w and TextureRect.h are not used. +// The TextureSurface's size MUST larger than the drawing rectangle!!! + +procedure SDL_TexturedSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; + DestSurface : PSDL_Surface; DestRect : PSDL_Rect; Texture : PSDL_Surface; + TextureRect : PSDL_Rect ); +var + Src, Dest : TSDL_Rect; + Diff : integer; + SrcAddr, DestAddr, TextAddr : cardinal; + _ebx, _esi, _edi, _esp : cardinal; + WorkX, WorkY : word; + SrcMod, DestMod, TextMod : cardinal; + SrcColor, TransparentColor, TextureColor : cardinal; + BPP : cardinal; +begin + if ( SrcSurface = nil ) or ( DestSurface = nil ) then + exit; // Remove this to make it faster + if ( SrcSurface.Format.BitsPerPixel <> DestSurface.Format.BitsPerPixel ) then + exit; // Remove this to make it faster + if SrcRect = nil then + begin + with Src do + begin + x := 0; + y := 0; + w := SrcSurface.w; + h := SrcSurface.h; + end; + end + else + Src := SrcRect^; + if DestRect = nil then + begin + Dest.x := 0; + Dest.y := 0; + end + else + Dest := DestRect^; + Dest.w := Src.w; + Dest.h := Src.h; + with DestSurface.Clip_Rect do + begin + // Source's right side is greater than the dest.cliprect + if Dest.x + Src.w > x + w then + begin + smallint( Src.w ) := x + w - Dest.x; + smallint( Dest.w ) := x + w - Dest.x; + if smallint( Dest.w ) < 1 then + exit; + end; + // Source's bottom side is greater than the dest.clip + if Dest.y + Src.h > y + h then + begin + smallint( Src.h ) := y + h - Dest.y; + smallint( Dest.h ) := y + h - Dest.y; + if smallint( Dest.h ) < 1 then + exit; + end; + // Source's left side is less than the dest.clip + if Dest.x < x then + begin + Diff := x - Dest.x; + Src.x := Src.x + Diff; + smallint( Src.w ) := smallint( Src.w ) - Diff; + Dest.x := x; + smallint( Dest.w ) := smallint( Dest.w ) - Diff; + if smallint( Dest.w ) < 1 then + exit; + end; + // Source's Top side is less than the dest.clip + if Dest.y < y then + begin + Diff := y - Dest.y; + Src.y := Src.y + Diff; + smallint( Src.h ) := smallint( Src.h ) - Diff; + Dest.y := y; + smallint( Dest.h ) := smallint( Dest.h ) - Diff; + if smallint( Dest.h ) < 1 then + exit; + end; + end; + with SrcSurface^ do + begin + SrcAddr := cardinal( Pixels ) + UInt32( Src.y ) * Pitch + UInt32( Src.x ) * + Format.BytesPerPixel; + SrcMod := Pitch - Src.w * Format.BytesPerPixel; + TransparentColor := format.colorkey; + end; + with DestSurface^ do + begin + DestAddr := cardinal( Pixels ) + UInt32( Dest.y ) * Pitch + UInt32( Dest.x ) * + Format.BytesPerPixel; + DestMod := Pitch - Dest.w * Format.BytesPerPixel; + BPP := DestSurface.Format.BitsPerPixel; + end; + with Texture^ do + begin + TextAddr := cardinal( Pixels ) + UInt32( TextureRect.y ) * Pitch + + UInt32( TextureRect.x ) * Format.BytesPerPixel; + TextMod := Pitch - Src.w * Format.BytesPerPixel; + end; + SDL_LockSurface( SrcSurface ); + SDL_LockSurface( DestSurface ); + SDL_LockSurface( Texture ); + WorkY := Src.h; + case BPP of + 1 : + begin + repeat + WorkX := Src.w; + repeat + SrcColor := PUInt8( SrcAddr )^; + if SrcColor <> TransparentColor then + PUInt8( DestAddr )^ := PUint8( TextAddr )^; + inc( SrcAddr ); + inc( DestAddr ); + inc( TextAddr ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + inc( TextAddr, TextMod ); + dec( WorkY ); + until WorkY = 0; + end; + 2 : + begin + repeat + WorkX := Src.w; + repeat + SrcColor := PUInt16( SrcAddr )^; + if SrcColor <> TransparentColor then + PUInt16( DestAddr )^ := PUInt16( TextAddr )^; + inc( SrcAddr ); + inc( DestAddr ); + inc( TextAddr ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + inc( TextAddr, TextMod ); + dec( WorkY ); + until WorkY = 0; + end; + 3 : + begin + repeat + WorkX := Src.w; + repeat + SrcColor := PUInt32( SrcAddr )^ and $FFFFFF; + if SrcColor <> TransparentColor then + PUInt32( DestAddr )^ := ( PUInt32( DestAddr )^ and $FFFFFF ) or ( PUInt32( TextAddr )^ and $FFFFFF ); + inc( SrcAddr ); + inc( DestAddr ); + inc( TextAddr ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + inc( TextAddr, TextMod ); + dec( WorkY ); + until WorkY = 0; + end; + 4 : + begin + repeat + WorkX := Src.w; + repeat + SrcColor := PUInt32( SrcAddr )^; + if SrcColor <> TransparentColor then + PUInt32( DestAddr )^ := PUInt32( TextAddr )^; + inc( SrcAddr ); + inc( DestAddr ); + inc( TextAddr ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + inc( TextAddr, TextMod ); + dec( WorkY ); + until WorkY = 0; + end; + end; + SDL_UnlockSurface( SrcSurface ); + SDL_UnlockSurface( DestSurface ); + SDL_UnlockSurface( Texture ); +end; + +procedure SDL_ZoomSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; DstSurface : PSDL_Surface; DstRect : PSDL_Rect ); +var + xc, yc : cardinal; + rx, wx, ry, wy, ry16 : cardinal; + color : cardinal; + modx, mody : cardinal; +begin + // Warning! No checks for surface pointers!!! + if srcrect = nil then + srcrect := @SrcSurface.clip_rect; + if dstrect = nil then + dstrect := @DstSurface.clip_rect; + if SDL_MustLock( SrcSurface ) then + SDL_LockSurface( SrcSurface ); + if SDL_MustLock( DstSurface ) then + SDL_LockSurface( DstSurface ); + modx := trunc( ( srcrect.w / dstrect.w ) * 65536 ); + mody := trunc( ( srcrect.h / dstrect.h ) * 65536 ); + //rx := srcrect.x * 65536; + ry := srcrect.y * 65536; + wy := dstrect.y; + for yc := 0 to dstrect.h - 1 do + begin + rx := srcrect.x * 65536; + wx := dstrect.x; + ry16 := ry shr 16; + for xc := 0 to dstrect.w - 1 do + begin + color := SDL_GetPixel( SrcSurface, rx shr 16, ry16 ); + SDL_PutPixel( DstSurface, wx, wy, color ); + rx := rx + modx; + inc( wx ); + end; + ry := ry + mody; + inc( wy ); + end; + if SDL_MustLock( SrcSurface ) then + SDL_UnlockSurface( SrcSurface ); + if SDL_MustLock( DstSurface ) then + SDL_UnlockSurface( DstSurface ); +end; +// Re-map a rectangular area into an area defined by four vertices +// Converted from C to Pascal by KiCHY + +procedure SDL_WarpSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; DstSurface : PSDL_Surface; UL, UR, LR, LL : PPoint ); +const + SHIFTS = 15; // Extend ints to limit round-off error (try 2 - 20) + THRESH = 1 shl SHIFTS; // Threshold for pixel size value + procedure CopySourceToDest( UL, UR, LR, LL : TPoint; x1, y1, x2, y2 : cardinal ); + var + tm, lm, rm, bm, m : TPoint; + mx, my : cardinal; + cr : cardinal; + begin + // Does the destination area specify a single pixel? + if ( ( abs( ul.x - ur.x ) < THRESH ) and + ( abs( ul.x - lr.x ) < THRESH ) and + ( abs( ul.x - ll.x ) < THRESH ) and + ( abs( ul.y - ur.y ) < THRESH ) and + ( abs( ul.y - lr.y ) < THRESH ) and + ( abs( ul.y - ll.y ) < THRESH ) ) then + begin // Yes + cr := SDL_GetPixel( SrcSurface, ( x1 shr SHIFTS ), ( y1 shr SHIFTS ) ); + SDL_PutPixel( DstSurface, ( ul.x shr SHIFTS ), ( ul.y shr SHIFTS ), cr ); + end + else + begin // No + // Quarter the source and the destination, and then recurse + tm.x := ( ul.x + ur.x ) shr 1; + tm.y := ( ul.y + ur.y ) shr 1; + bm.x := ( ll.x + lr.x ) shr 1; + bm.y := ( ll.y + lr.y ) shr 1; + lm.x := ( ul.x + ll.x ) shr 1; + lm.y := ( ul.y + ll.y ) shr 1; + rm.x := ( ur.x + lr.x ) shr 1; + rm.y := ( ur.y + lr.y ) shr 1; + m.x := ( tm.x + bm.x ) shr 1; + m.y := ( tm.y + bm.y ) shr 1; + mx := ( x1 + x2 ) shr 1; + my := ( y1 + y2 ) shr 1; + CopySourceToDest( ul, tm, m, lm, x1, y1, mx, my ); + CopySourceToDest( tm, ur, rm, m, mx, y1, x2, my ); + CopySourceToDest( m, rm, lr, bm, mx, my, x2, y2 ); + CopySourceToDest( lm, m, bm, ll, x1, my, mx, y2 ); + end; + end; +var + _UL, _UR, _LR, _LL : TPoint; + Rect_x, Rect_y, Rect_w, Rect_h : integer; +begin + if SDL_MustLock( SrcSurface ) then + SDL_LockSurface( SrcSurface ); + if SDL_MustLock( DstSurface ) then + SDL_LockSurface( DstSurface ); + if SrcRect = nil then + begin + Rect_x := 0; + Rect_y := 0; + Rect_w := ( SrcSurface.w - 1 ) shl SHIFTS; + Rect_h := ( SrcSurface.h - 1 ) shl SHIFTS; + end + else + begin + Rect_x := SrcRect.x; + Rect_y := SrcRect.y; + Rect_w := ( SrcRect.w - 1 ) shl SHIFTS; + Rect_h := ( SrcRect.h - 1 ) shl SHIFTS; + end; + // Shift all values to help reduce round-off error. + _ul.x := ul.x shl SHIFTS; + _ul.y := ul.y shl SHIFTS; + _ur.x := ur.x shl SHIFTS; + _ur.y := ur.y shl SHIFTS; + _lr.x := lr.x shl SHIFTS; + _lr.y := lr.y shl SHIFTS; + _ll.x := ll.x shl SHIFTS; + _ll.y := ll.y shl SHIFTS; + CopySourceToDest( _ul, _ur, _lr, _ll, Rect_x, Rect_y, Rect_w, Rect_h ); + if SDL_MustLock( SrcSurface ) then + SDL_UnlockSurface( SrcSurface ); + if SDL_MustLock( DstSurface ) then + SDL_UnlockSurface( DstSurface ); +end; + +// Draw a line between x1,y1 and x2,y2 to the given surface +// NOTE: The surface must be locked before calling this! + +procedure SDL_DrawLine( DstSurface : PSDL_Surface; x1, y1, x2, y2 : integer; Color : + cardinal ); +var + dx, dy, sdx, sdy, x, y, px, py : integer; +begin + dx := x2 - x1; + dy := y2 - y1; + if dx < 0 then + sdx := -1 + else + sdx := 1; + if dy < 0 then + sdy := -1 + else + sdy := 1; + dx := sdx * dx + 1; + dy := sdy * dy + 1; + x := 0; + y := 0; + px := x1; + py := y1; + if dx >= dy then + begin + for x := 0 to dx - 1 do + begin + SDL_PutPixel( DstSurface, px, py, Color ); + y := y + dy; + if y >= dx then + begin + y := y - dx; + py := py + sdy; + end; + px := px + sdx; + end; + end + else + begin + for y := 0 to dy - 1 do + begin + SDL_PutPixel( DstSurface, px, py, Color ); + x := x + dx; + if x >= dy then + begin + x := x - dy; + px := px + sdx; + end; + py := py + sdy; + end; + end; +end; + +// Draw a dashed line between x1,y1 and x2,y2 to the given surface +// NOTE: The surface must be locked before calling this! + +procedure SDL_DrawLine( DstSurface : PSDL_Surface; x1, y1, x2, y2 : integer; Color : + cardinal; DashLength, DashSpace : byte ); overload; +var + dx, dy, sdx, sdy, x, y, px, py, counter : integer; drawdash : boolean; +begin + counter := 0; + drawdash := true; //begin line drawing with dash + + //Avoid invalid user-passed dash parameters + if ( DashLength < 1 ) + then + DashLength := 1; + if ( DashSpace < 1 ) + then + DashSpace := 0; + + dx := x2 - x1; + dy := y2 - y1; + if dx < 0 then + sdx := -1 + else + sdx := 1; + if dy < 0 then + sdy := -1 + else + sdy := 1; + dx := sdx * dx + 1; + dy := sdy * dy + 1; + x := 0; + y := 0; + px := x1; + py := y1; + if dx >= dy then + begin + for x := 0 to dx - 1 do + begin + + //Alternate drawing dashes, or leaving spaces + if drawdash then + begin + SDL_PutPixel( DstSurface, px, py, Color ); + inc( counter ); + if ( counter > DashLength - 1 ) and ( DashSpace > 0 ) then + begin + drawdash := false; + counter := 0; + end; + end + else //space + begin + inc( counter ); + if counter > DashSpace - 1 then + begin + drawdash := true; + counter := 0; + end; + end; + + y := y + dy; + if y >= dx then + begin + y := y - dx; + py := py + sdy; + end; + px := px + sdx; + end; + end + else + begin + for y := 0 to dy - 1 do + begin + + //Alternate drawing dashes, or leaving spaces + if drawdash then + begin + SDL_PutPixel( DstSurface, px, py, Color ); + inc( counter ); + if ( counter > DashLength - 1 ) and ( DashSpace > 0 ) then + begin + drawdash := false; + counter := 0; + end; + end + else //space + begin + inc( counter ); + if counter > DashSpace - 1 then + begin + drawdash := true; + counter := 0; + end; + end; + + x := x + dx; + if x >= dy then + begin + x := x - dy; + px := px + sdx; + end; + py := py + sdy; + end; + end; +end; + +procedure SDL_AddLine( DstSurface : PSDL_Surface; x1, y1, x2, y2 : integer; Color : + cardinal ); +var + dx, dy, sdx, sdy, x, y, px, py : integer; +begin + dx := x2 - x1; + dy := y2 - y1; + if dx < 0 then + sdx := -1 + else + sdx := 1; + if dy < 0 then + sdy := -1 + else + sdy := 1; + dx := sdx * dx + 1; + dy := sdy * dy + 1; + x := 0; + y := 0; + px := x1; + py := y1; + if dx >= dy then + begin + for x := 0 to dx - 1 do + begin + SDL_AddPixel( DstSurface, px, py, Color ); + y := y + dy; + if y >= dx then + begin + y := y - dx; + py := py + sdy; + end; + px := px + sdx; + end; + end + else + begin + for y := 0 to dy - 1 do + begin + SDL_AddPixel( DstSurface, px, py, Color ); + x := x + dx; + if x >= dy then + begin + x := x - dy; + px := px + sdx; + end; + py := py + sdy; + end; + end; +end; + +procedure SDL_SubLine( DstSurface : PSDL_Surface; x1, y1, x2, y2 : integer; Color : + cardinal ); +var + dx, dy, sdx, sdy, x, y, px, py : integer; +begin + dx := x2 - x1; + dy := y2 - y1; + if dx < 0 then + sdx := -1 + else + sdx := 1; + if dy < 0 then + sdy := -1 + else + sdy := 1; + dx := sdx * dx + 1; + dy := sdy * dy + 1; + x := 0; + y := 0; + px := x1; + py := y1; + if dx >= dy then + begin + for x := 0 to dx - 1 do + begin + SDL_SubPixel( DstSurface, px, py, Color ); + y := y + dy; + if y >= dx then + begin + y := y - dx; + py := py + sdy; + end; + px := px + sdx; + end; + end + else + begin + for y := 0 to dy - 1 do + begin + SDL_SubPixel( DstSurface, px, py, Color ); + x := x + dx; + if x >= dy then + begin + x := x - dy; + px := px + sdx; + end; + py := py + sdy; + end; + end; +end; + +// flips a rectangle vertically on given surface + +procedure SDL_FlipRectV( DstSurface : PSDL_Surface; Rect : PSDL_Rect ); +var + TmpRect : TSDL_Rect; + Locked : boolean; + y, FlipLength, RowLength : integer; + Row1, Row2 : Pointer; + OneRow : TByteArray; // Optimize it if you wish +begin + if DstSurface <> nil then + begin + if Rect = nil then + begin // if Rect=nil then we flip the whole surface + TmpRect := SDLRect( 0, 0, DstSurface.w, DstSurface.h ); + Rect := @TmpRect; + end; + FlipLength := Rect^.h shr 1 - 1; + RowLength := Rect^.w * DstSurface^.format.BytesPerPixel; + if SDL_MustLock( DstSurface ) then + begin + Locked := true; + SDL_LockSurface( DstSurface ); + end + else + Locked := false; + Row1 := pointer( cardinal( DstSurface^.Pixels ) + UInt32( Rect^.y ) * + DstSurface^.Pitch ); + Row2 := pointer( cardinal( DstSurface^.Pixels ) + ( UInt32( Rect^.y ) + Rect^.h - 1 ) + * DstSurface^.Pitch ); + for y := 0 to FlipLength do + begin + Move( Row1^, OneRow, RowLength ); + Move( Row2^, Row1^, RowLength ); + Move( OneRow, Row2^, RowLength ); + inc( cardinal( Row1 ), DstSurface^.Pitch ); + dec( cardinal( Row2 ), DstSurface^.Pitch ); + end; + if Locked then + SDL_UnlockSurface( DstSurface ); + end; +end; + +// flips a rectangle horizontally on given surface + +procedure SDL_FlipRectH( DstSurface : PSDL_Surface; Rect : PSDL_Rect ); +type + T24bit = packed array[ 0..2 ] of byte; + T24bitArray = packed array[ 0..8191 ] of T24bit; + P24bitArray = ^T24bitArray; + TLongWordArray = array[ 0..8191 ] of LongWord; + PLongWordArray = ^TLongWordArray; +var + TmpRect : TSDL_Rect; + Row8bit : PByteArray; + Row16bit : PWordArray; + Row24bit : P24bitArray; + Row32bit : PLongWordArray; + y, x, RightSide, FlipLength : integer; + Pixel : cardinal; + Pixel24 : T24bit; + Locked : boolean; +begin + if DstSurface <> nil then + begin + if Rect = nil then + begin + TmpRect := SDLRect( 0, 0, DstSurface.w, DstSurface.h ); + Rect := @TmpRect; + end; + FlipLength := Rect^.w shr 1 - 1; + if SDL_MustLock( DstSurface ) then + begin + Locked := true; + SDL_LockSurface( DstSurface ); + end + else + Locked := false; + case DstSurface^.format.BytesPerPixel of + 1 : + begin + Row8Bit := pointer( cardinal( DstSurface^.pixels ) + UInt32( Rect^.y ) * + DstSurface^.pitch ); + for y := 1 to Rect^.h do + begin + RightSide := Rect^.w - 1; + for x := 0 to FlipLength do + begin + Pixel := Row8Bit^[ x ]; + Row8Bit^[ x ] := Row8Bit^[ RightSide ]; + Row8Bit^[ RightSide ] := Pixel; + dec( RightSide ); + end; + inc( cardinal( Row8Bit ), DstSurface^.pitch ); + end; + end; + 2 : + begin + Row16Bit := pointer( cardinal( DstSurface^.pixels ) + UInt32( Rect^.y ) * + DstSurface^.pitch ); + for y := 1 to Rect^.h do + begin + RightSide := Rect^.w - 1; + for x := 0 to FlipLength do + begin + Pixel := Row16Bit^[ x ]; + Row16Bit^[ x ] := Row16Bit^[ RightSide ]; + Row16Bit^[ RightSide ] := Pixel; + dec( RightSide ); + end; + inc( cardinal( Row16Bit ), DstSurface^.pitch ); + end; + end; + 3 : + begin + Row24Bit := pointer( cardinal( DstSurface^.pixels ) + UInt32( Rect^.y ) * + DstSurface^.pitch ); + for y := 1 to Rect^.h do + begin + RightSide := Rect^.w - 1; + for x := 0 to FlipLength do + begin + Pixel24 := Row24Bit^[ x ]; + Row24Bit^[ x ] := Row24Bit^[ RightSide ]; + Row24Bit^[ RightSide ] := Pixel24; + dec( RightSide ); + end; + inc( cardinal( Row24Bit ), DstSurface^.pitch ); + end; + end; + 4 : + begin + Row32Bit := pointer( cardinal( DstSurface^.pixels ) + UInt32( Rect^.y ) * + DstSurface^.pitch ); + for y := 1 to Rect^.h do + begin + RightSide := Rect^.w - 1; + for x := 0 to FlipLength do + begin + Pixel := Row32Bit^[ x ]; + Row32Bit^[ x ] := Row32Bit^[ RightSide ]; + Row32Bit^[ RightSide ] := Pixel; + dec( RightSide ); + end; + inc( cardinal( Row32Bit ), DstSurface^.pitch ); + end; + end; + end; + if Locked then + SDL_UnlockSurface( DstSurface ); + end; +end; + +// Use with caution! The procedure allocates memory for TSDL_Rect and return with its pointer. +// But you MUST free it after you don't need it anymore!!! + +function PSDLRect( aLeft, aTop, aWidth, aHeight : integer ) : PSDL_Rect; +var + Rect : PSDL_Rect; +begin + New( Rect ); + with Rect^ do + begin + x := aLeft; + y := aTop; + w := aWidth; + h := aHeight; + end; + Result := Rect; +end; + +function SDLRect( aLeft, aTop, aWidth, aHeight : integer ) : TSDL_Rect; +begin + with result do + begin + x := aLeft; + y := aTop; + w := aWidth; + h := aHeight; + end; +end; + +function SDLRect( aRect : TRect ) : TSDL_Rect; +begin + with aRect do + result := SDLRect( Left, Top, Right - Left, Bottom - Top ); +end; + +procedure SDL_Stretch8( Surface, Dst_Surface : PSDL_Surface; x1, x2, y1, y2, yr, yw, + depth : integer ); +var + dx, dy, e, d, dx2 : integer; + src_pitch, dst_pitch : uint16; + src_pixels, dst_pixels : PUint8; +begin + if ( yw >= dst_surface^.h ) then + exit; + dx := ( x2 - x1 ); + dy := ( y2 - y1 ); + dy := dy shl 1; + e := dy - dx; + dx2 := dx shl 1; + src_pitch := Surface^.pitch; + dst_pitch := dst_surface^.pitch; + src_pixels := PUint8( integer( Surface^.pixels ) + yr * src_pitch + y1 * depth ); + dst_pixels := PUint8( integer( dst_surface^.pixels ) + yw * dst_pitch + x1 * + depth ); + for d := 0 to dx - 1 do + begin + move( src_pixels^, dst_pixels^, depth ); + while ( e >= 0 ) do + begin + inc( src_pixels, depth ); + e := e - dx2; + end; + inc( dst_pixels, depth ); + e := e + dy; + end; +end; + +function sign( x : integer ) : integer; +begin + if x > 0 then + result := 1 + else + result := -1; +end; + +// Stretches a part of a surface + +function SDL_ScaleSurfaceRect( SrcSurface : PSDL_Surface; SrcX1, SrcY1, SrcW, SrcH, + Width, Height : integer ) : PSDL_Surface; +var + dst_surface : PSDL_Surface; + dx, dy, e, d, dx2, srcx2, srcy2 : integer; + destx1, desty1 : integer; +begin + srcx2 := srcx1 + SrcW; + srcy2 := srcy1 + SrcH; + result := nil; + destx1 := 0; + desty1 := 0; + dx := abs( integer( Height - desty1 ) ); + dy := abs( integer( SrcY2 - SrcY1 ) ); + e := ( dy shl 1 ) - dx; + dx2 := dx shl 1; + dy := dy shl 1; + dst_surface := SDL_CreateRGBSurface( SDL_HWPALETTE, width - destx1, Height - + desty1, + SrcSurface^.Format^.BitsPerPixel, + SrcSurface^.Format^.RMask, + SrcSurface^.Format^.GMask, + SrcSurface^.Format^.BMask, + SrcSurface^.Format^.AMask ); + if ( dst_surface^.format^.BytesPerPixel = 1 ) then + SDL_SetColors( dst_surface, @SrcSurface^.format^.palette^.colors^[ 0 ], 0, 256 ); + SDL_SetColorKey( dst_surface, sdl_srccolorkey, SrcSurface^.format^.colorkey ); + if ( SDL_MustLock( dst_surface ) ) then + if ( SDL_LockSurface( dst_surface ) < 0 ) then + exit; + for d := 0 to dx - 1 do + begin + SDL_Stretch8( SrcSurface, dst_surface, destx1, Width, SrcX1, SrcX2, SrcY1, desty1, + SrcSurface^.format^.BytesPerPixel ); + while e >= 0 do + begin + inc( SrcY1 ); + e := e - dx2; + end; + inc( desty1 ); + e := e + dy; + end; + if SDL_MUSTLOCK( dst_surface ) then + SDL_UnlockSurface( dst_surface ); + result := dst_surface; +end; + +procedure SDL_MoveLine( Surface : PSDL_Surface; x1, x2, y1, xofs, depth : integer ); +var + src_pixels, dst_pixels : PUint8; + i : integer; +begin + src_pixels := PUint8( integer( Surface^.pixels ) + Surface^.w * y1 * depth + x2 * + depth ); + dst_pixels := PUint8( integer( Surface^.pixels ) + Surface^.w * y1 * depth + ( x2 + + xofs ) * depth ); + for i := x2 downto x1 do + begin + move( src_pixels^, dst_pixels^, depth ); + dec( src_pixels ); + dec( dst_pixels ); + end; +end; +{ Return the pixel value at (x, y) +NOTE: The surface must be locked before calling this! } + +function SDL_GetPixel( SrcSurface : PSDL_Surface; x : integer; y : integer ) : Uint32; +var + bpp : UInt32; + p : PInteger; +begin + bpp := SrcSurface.format.BytesPerPixel; + // Here p is the address to the pixel we want to retrieve + p := Pointer( Uint32( SrcSurface.pixels ) + UInt32( y ) * SrcSurface.pitch + UInt32( x ) * + bpp ); + case bpp of + 1 : result := PUint8( p )^; + 2 : result := PUint16( p )^; + 3 : + if ( SDL_BYTEORDER = SDL_BIG_ENDIAN ) then + result := PUInt8Array( p )[ 0 ] shl 16 or PUInt8Array( p )[ 1 ] shl 8 or + PUInt8Array( p )[ 2 ] + else + result := PUInt8Array( p )[ 0 ] or PUInt8Array( p )[ 1 ] shl 8 or + PUInt8Array( p )[ 2 ] shl 16; + 4 : result := PUint32( p )^; + else + result := 0; // shouldn't happen, but avoids warnings + end; +end; +{ Set the pixel at (x, y) to the given value + NOTE: The surface must be locked before calling this! } + +procedure SDL_PutPixel( DstSurface : PSDL_Surface; x : integer; y : integer; pixel : + Uint32 ); +var + bpp : UInt32; + p : PInteger; +begin + bpp := DstSurface.format.BytesPerPixel; + p := Pointer( Uint32( DstSurface.pixels ) + UInt32( y ) * DstSurface.pitch + UInt32( x ) + * bpp ); + case bpp of + 1 : PUint8( p )^ := pixel; + 2 : PUint16( p )^ := pixel; + 3 : + if ( SDL_BYTEORDER = SDL_BIG_ENDIAN ) then + begin + PUInt8Array( p )[ 0 ] := ( pixel shr 16 ) and $FF; + PUInt8Array( p )[ 1 ] := ( pixel shr 8 ) and $FF; + PUInt8Array( p )[ 2 ] := pixel and $FF; + end + else + begin + PUInt8Array( p )[ 0 ] := pixel and $FF; + PUInt8Array( p )[ 1 ] := ( pixel shr 8 ) and $FF; + PUInt8Array( p )[ 2 ] := ( pixel shr 16 ) and $FF; + end; + 4 : + PUint32( p )^ := pixel; + end; +end; + +procedure SDL_ScrollY( DstSurface : PSDL_Surface; DifY : integer ); +var + r1, r2 : TSDL_Rect; + //buffer: PSDL_Surface; + YPos : Integer; +begin + if ( DstSurface <> nil ) and ( DifY <> 0 ) then + begin + //if DifY > 0 then // going up + //begin + ypos := 0; + r1.x := 0; + r2.x := 0; + r1.w := DstSurface.w; + r2.w := DstSurface.w; + r1.h := DifY; + r2.h := DifY; + while ypos < DstSurface.h do + begin + r1.y := ypos; + r2.y := ypos + DifY; + SDL_BlitSurface( DstSurface, @r2, DstSurface, @r1 ); + ypos := ypos + DifY; + end; + //end + //else + //begin // Going Down + //end; + end; +end; + +{procedure SDL_ScrollY(Surface: PSDL_Surface; DifY: integer); +var + r1, r2: TSDL_Rect; + buffer: PSDL_Surface; +begin + if (Surface <> nil) and (Dify <> 0) then + begin + buffer := SDL_CreateRGBSurface(SDL_HWSURFACE, (Surface^.w - DifY) * 2, + Surface^.h * 2, + Surface^.Format^.BitsPerPixel, 0, 0, 0, 0); + if buffer <> nil then + begin + if (buffer^.format^.BytesPerPixel = 1) then + SDL_SetColors(buffer, @Surface^.format^.palette^.colors^[0], 0, 256); + r1 := SDLRect(0, DifY, buffer^.w, buffer^.h); + r2 := SDLRect(0, 0, buffer^.w, buffer^.h); + SDL_BlitSurface(Surface, @r1, buffer, @r2); + SDL_BlitSurface(buffer, @r2, Surface, @r2); + SDL_FreeSurface(buffer); + end; + end; +end;} + +procedure SDL_ScrollX( DstSurface : PSDL_Surface; DifX : integer ); +var + r1, r2 : TSDL_Rect; + buffer : PSDL_Surface; +begin + if ( DstSurface <> nil ) and ( DifX <> 0 ) then + begin + buffer := SDL_CreateRGBSurface( SDL_HWSURFACE, ( DstSurface^.w - DifX ) * 2, + DstSurface^.h * 2, + DstSurface^.Format^.BitsPerPixel, + DstSurface^.Format^.RMask, + DstSurface^.Format^.GMask, + DstSurface^.Format^.BMask, + DstSurface^.Format^.AMask ); + if buffer <> nil then + begin + if ( buffer^.format^.BytesPerPixel = 1 ) then + SDL_SetColors( buffer, @DstSurface^.format^.palette^.colors^[ 0 ], 0, 256 ); + r1 := SDLRect( DifX, 0, buffer^.w, buffer^.h ); + r2 := SDLRect( 0, 0, buffer^.w, buffer^.h ); + SDL_BlitSurface( DstSurface, @r1, buffer, @r2 ); + SDL_BlitSurface( buffer, @r2, DstSurface, @r2 ); + SDL_FreeSurface( buffer ); + end; + end; +end; + +procedure SDL_RotateRad( DstSurface, SrcSurface : PSDL_Surface; SrcRect : + PSDL_Rect; DestX, DestY, OffsetX, OffsetY : Integer; Angle : Single ); +var + aSin, aCos : Single; + MX, MY, DX, DY, NX, NY, SX, SY, OX, OY, Width, Height, TX, TY, RX, RY, ROX, ROY : Integer; + Colour, TempTransparentColour : UInt32; + MAXX, MAXY : Integer; +begin + // Rotate the surface to the target surface. + TempTransparentColour := SrcSurface.format.colorkey; + {if srcRect.w > srcRect.h then + begin + Width := srcRect.w; + Height := srcRect.w; + end + else + begin + Width := srcRect.h; + Height := srcRect.h; + end; } + + maxx := DstSurface.w; + maxy := DstSurface.h; + aCos := cos( Angle ); + aSin := sin( Angle ); + + Width := round( abs( srcrect.h * acos ) + abs( srcrect.w * asin ) ); + Height := round( abs( srcrect.h * asin ) + abs( srcrect.w * acos ) ); + + OX := Width div 2; + OY := Height div 2; ; + MX := ( srcRect.x + ( srcRect.x + srcRect.w ) ) div 2; + MY := ( srcRect.y + ( srcRect.y + srcRect.h ) ) div 2; + ROX := ( -( srcRect.w div 2 ) ) + Offsetx; + ROY := ( -( srcRect.h div 2 ) ) + OffsetY; + Tx := ox + round( ROX * aSin - ROY * aCos ); + Ty := oy + round( ROY * aSin + ROX * aCos ); + SX := 0; + for DX := DestX - TX to DestX - TX + ( width ) do + begin + Inc( SX ); + SY := 0; + for DY := DestY - TY to DestY - TY + ( Height ) do + begin + RX := SX - OX; + RY := SY - OY; + NX := round( mx + RX * aSin + RY * aCos ); // + NY := round( my + RY * aSin - RX * aCos ); // + // Used for testing only + //SDL_PutPixel(DestSurface.SDLSurfacePointer,DX,DY,0); + if ( ( DX > 0 ) and ( DX < MAXX ) ) and ( ( DY > 0 ) and ( DY < MAXY ) ) then + begin + if ( NX >= srcRect.x ) and ( NX <= srcRect.x + srcRect.w ) then + begin + if ( NY >= srcRect.y ) and ( NY <= srcRect.y + srcRect.h ) then + begin + Colour := SDL_GetPixel( SrcSurface, NX, NY ); + if Colour <> TempTransparentColour then + begin + SDL_PutPixel( DstSurface, DX, DY, Colour ); + end; + end; + end; + end; + inc( SY ); + end; + end; +end; + +procedure SDL_RotateDeg( DstSurface, SrcSurface : PSDL_Surface; SrcRect : + PSDL_Rect; DestX, DestY, OffsetX, OffsetY : Integer; Angle : Integer ); +begin + SDL_RotateRad( DstSurface, SrcSurface, SrcRect, DestX, DestY, OffsetX, OffsetY, DegToRad( Angle ) ); +end; + +function ValidateSurfaceRect( DstSurface : PSDL_Surface; dstrect : PSDL_Rect ) : TSDL_Rect; +var + RealRect : TSDL_Rect; + OutOfRange : Boolean; +begin + OutOfRange := false; + if dstrect = nil then + begin + RealRect.x := 0; + RealRect.y := 0; + RealRect.w := DstSurface.w; + RealRect.h := DstSurface.h; + end + else + begin + if dstrect.x < DstSurface.w then + begin + RealRect.x := dstrect.x; + end + else if dstrect.x < 0 then + begin + realrect.x := 0; + end + else + begin + OutOfRange := True; + end; + if dstrect.y < DstSurface.h then + begin + RealRect.y := dstrect.y; + end + else if dstrect.y < 0 then + begin + realrect.y := 0; + end + else + begin + OutOfRange := True; + end; + if OutOfRange = False then + begin + if realrect.x + dstrect.w <= DstSurface.w then + begin + RealRect.w := dstrect.w; + end + else + begin + RealRect.w := dstrect.w - realrect.x; + end; + if realrect.y + dstrect.h <= DstSurface.h then + begin + RealRect.h := dstrect.h; + end + else + begin + RealRect.h := dstrect.h - realrect.y; + end; + end; + end; + if OutOfRange = False then + begin + result := realrect; + end + else + begin + realrect.w := 0; + realrect.h := 0; + realrect.x := 0; + realrect.y := 0; + result := realrect; + end; +end; + +procedure SDL_FillRectAdd( DstSurface : PSDL_Surface; dstrect : PSDL_Rect; color : UInt32 ); +var + RealRect : TSDL_Rect; + Addr : pointer; + ModX, BPP : cardinal; + x, y, R, G, B, SrcColor : cardinal; +begin + RealRect := ValidateSurfaceRect( DstSurface, DstRect ); + if ( RealRect.w > 0 ) and ( RealRect.h > 0 ) then + begin + SDL_LockSurface( DstSurface ); + BPP := DstSurface.format.BytesPerPixel; + with DstSurface^ do + begin + Addr := pointer( UInt32( pixels ) + UInt32( RealRect.y ) * pitch + UInt32( RealRect.x ) * BPP ); + ModX := Pitch - UInt32( RealRect.w ) * BPP; + end; + case DstSurface.format.BitsPerPixel of + 8 : + begin + for y := 0 to RealRect.h - 1 do + begin + for x := 0 to RealRect.w - 1 do + begin + SrcColor := PUInt32( Addr )^; + R := SrcColor and $E0 + Color and $E0; + G := SrcColor and $1C + Color and $1C; + B := SrcColor and $03 + Color and $03; + if R > $E0 then + R := $E0; + if G > $1C then + G := $1C; + if B > $03 then + B := $03; + PUInt8( Addr )^ := R or G or B; + inc( UInt32( Addr ), BPP ); + end; + inc( UInt32( Addr ), ModX ); + end; + end; + 15 : + begin + for y := 0 to RealRect.h - 1 do + begin + for x := 0 to RealRect.w - 1 do + begin + SrcColor := PUInt32( Addr )^; + R := SrcColor and $7C00 + Color and $7C00; + G := SrcColor and $03E0 + Color and $03E0; + B := SrcColor and $001F + Color and $001F; + if R > $7C00 then + R := $7C00; + if G > $03E0 then + G := $03E0; + if B > $001F then + B := $001F; + PUInt16( Addr )^ := R or G or B; + inc( UInt32( Addr ), BPP ); + end; + inc( UInt32( Addr ), ModX ); + end; + end; + 16 : + begin + for y := 0 to RealRect.h - 1 do + begin + for x := 0 to RealRect.w - 1 do + begin + SrcColor := PUInt32( Addr )^; + R := SrcColor and $F800 + Color and $F800; + G := SrcColor and $07C0 + Color and $07C0; + B := SrcColor and $001F + Color and $001F; + if R > $F800 then + R := $F800; + if G > $07C0 then + G := $07C0; + if B > $001F then + B := $001F; + PUInt16( Addr )^ := R or G or B; + inc( UInt32( Addr ), BPP ); + end; + inc( UInt32( Addr ), ModX ); + end; + end; + 24 : + begin + for y := 0 to RealRect.h - 1 do + begin + for x := 0 to RealRect.w - 1 do + begin + SrcColor := PUInt32( Addr )^; + R := SrcColor and $00FF0000 + Color and $00FF0000; + G := SrcColor and $0000FF00 + Color and $0000FF00; + B := SrcColor and $000000FF + Color and $000000FF; + if R > $FF0000 then + R := $FF0000; + if G > $00FF00 then + G := $00FF00; + if B > $0000FF then + B := $0000FF; + PUInt32( Addr )^ := SrcColor and $FF000000 or R or G or B; + inc( UInt32( Addr ), BPP ); + end; + inc( UInt32( Addr ), ModX ); + end; + end; + 32 : + begin + for y := 0 to RealRect.h - 1 do + begin + for x := 0 to RealRect.w - 1 do + begin + SrcColor := PUInt32( Addr )^; + R := SrcColor and $00FF0000 + Color and $00FF0000; + G := SrcColor and $0000FF00 + Color and $0000FF00; + B := SrcColor and $000000FF + Color and $000000FF; + if R > $FF0000 then + R := $FF0000; + if G > $00FF00 then + G := $00FF00; + if B > $0000FF then + B := $0000FF; + PUInt32( Addr )^ := R or G or B; + inc( UInt32( Addr ), BPP ); + end; + inc( UInt32( Addr ), ModX ); + end; + end; + end; + SDL_UnlockSurface( DstSurface ); + end; +end; + +procedure SDL_FillRectSub( DstSurface : PSDL_Surface; dstrect : PSDL_Rect; color : UInt32 ); +var + RealRect : TSDL_Rect; + Addr : pointer; + ModX, BPP : cardinal; + x, y, R, G, B, SrcColor : cardinal; +begin + RealRect := ValidateSurfaceRect( DstSurface, DstRect ); + if ( RealRect.w > 0 ) and ( RealRect.h > 0 ) then + begin + SDL_LockSurface( DstSurface ); + BPP := DstSurface.format.BytesPerPixel; + with DstSurface^ do + begin + Addr := pointer( UInt32( pixels ) + UInt32( RealRect.y ) * pitch + UInt32( RealRect.x ) * BPP ); + ModX := Pitch - UInt32( RealRect.w ) * BPP; + end; + case DstSurface.format.BitsPerPixel of + 8 : + begin + for y := 0 to RealRect.h - 1 do + begin + for x := 0 to RealRect.w - 1 do + begin + SrcColor := PUInt32( Addr )^; + R := SrcColor and $E0 - Color and $E0; + G := SrcColor and $1C - Color and $1C; + B := SrcColor and $03 - Color and $03; + if R > $E0 then + R := 0; + if G > $1C then + G := 0; + if B > $03 then + B := 0; + PUInt8( Addr )^ := R or G or B; + inc( UInt32( Addr ), BPP ); + end; + inc( UInt32( Addr ), ModX ); + end; + end; + 15 : + begin + for y := 0 to RealRect.h - 1 do + begin + for x := 0 to RealRect.w - 1 do + begin + SrcColor := PUInt32( Addr )^; + R := SrcColor and $7C00 - Color and $7C00; + G := SrcColor and $03E0 - Color and $03E0; + B := SrcColor and $001F - Color and $001F; + if R > $7C00 then + R := 0; + if G > $03E0 then + G := 0; + if B > $001F then + B := 0; + PUInt16( Addr )^ := R or G or B; + inc( UInt32( Addr ), BPP ); + end; + inc( UInt32( Addr ), ModX ); + end; + end; + 16 : + begin + for y := 0 to RealRect.h - 1 do + begin + for x := 0 to RealRect.w - 1 do + begin + SrcColor := PUInt32( Addr )^; + R := SrcColor and $F800 - Color and $F800; + G := SrcColor and $07C0 - Color and $07C0; + B := SrcColor and $001F - Color and $001F; + if R > $F800 then + R := 0; + if G > $07C0 then + G := 0; + if B > $001F then + B := 0; + PUInt16( Addr )^ := R or G or B; + inc( UInt32( Addr ), BPP ); + end; + inc( UInt32( Addr ), ModX ); + end; + end; + 24 : + begin + for y := 0 to RealRect.h - 1 do + begin + for x := 0 to RealRect.w - 1 do + begin + SrcColor := PUInt32( Addr )^; + R := SrcColor and $00FF0000 - Color and $00FF0000; + G := SrcColor and $0000FF00 - Color and $0000FF00; + B := SrcColor and $000000FF - Color and $000000FF; + if R > $FF0000 then + R := 0; + if G > $00FF00 then + G := 0; + if B > $0000FF then + B := 0; + PUInt32( Addr )^ := SrcColor and $FF000000 or R or G or B; + inc( UInt32( Addr ), BPP ); + end; + inc( UInt32( Addr ), ModX ); + end; + end; + 32 : + begin + for y := 0 to RealRect.h - 1 do + begin + for x := 0 to RealRect.w - 1 do + begin + SrcColor := PUInt32( Addr )^; + R := SrcColor and $00FF0000 - Color and $00FF0000; + G := SrcColor and $0000FF00 - Color and $0000FF00; + B := SrcColor and $000000FF - Color and $000000FF; + if R > $FF0000 then + R := 0; + if G > $00FF00 then + G := 0; + if B > $0000FF then + B := 0; + PUInt32( Addr )^ := R or G or B; + inc( UInt32( Addr ), BPP ); + end; + inc( UInt32( Addr ), ModX ); + end; + end; + end; + SDL_UnlockSurface( DstSurface ); + end; +end; + +procedure SDL_GradientFillRect( DstSurface : PSDL_Surface; const Rect : PSDL_Rect; const StartColor, EndColor : TSDL_Color; const Style : TGradientStyle ); +var + FBC : array[ 0..255 ] of Cardinal; + // temp vars + i, YR, YG, YB, SR, SG, SB, DR, DG, DB : Integer; + + TempStepV, TempStepH : Single; + TempLeft, TempTop, TempHeight, TempWidth : integer; + TempRect : TSDL_Rect; + +begin + // calc FBC + YR := StartColor.r; + YG := StartColor.g; + YB := StartColor.b; + SR := YR; + SG := YG; + SB := YB; + DR := EndColor.r - SR; + DG := EndColor.g - SG; + DB := EndColor.b - SB; + + for i := 0 to 255 do + begin + FBC[ i ] := SDL_MapRGB( DstSurface.format, YR, YG, YB ); + YR := SR + round( DR / 255 * i ); + YG := SG + round( DG / 255 * i ); + YB := SB + round( DB / 255 * i ); + end; + + // if aStyle = 1 then begin + TempStepH := Rect.w / 255; + TempStepV := Rect.h / 255; + TempHeight := Trunc( TempStepV + 1 ); + TempWidth := Trunc( TempStepH + 1 ); + TempTop := 0; + TempLeft := 0; + TempRect.x := Rect.x; + TempRect.y := Rect.y; + TempRect.h := Rect.h; + TempRect.w := Rect.w; + + case Style of + gsHorizontal : + begin + TempRect.h := TempHeight; + for i := 0 to 255 do + begin + TempRect.y := Rect.y + TempTop; + SDL_FillRect( DstSurface, @TempRect, FBC[ i ] ); + TempTop := Trunc( TempStepV * i ); + end; + end; + gsVertical : + begin + TempRect.w := TempWidth; + for i := 0 to 255 do + begin + TempRect.x := Rect.x + TempLeft; + SDL_FillRect( DstSurface, @TempRect, FBC[ i ] ); + TempLeft := Trunc( TempStepH * i ); + end; + end; + end; +end; + +procedure SDL_2xBlit( Src, Dest : PSDL_Surface ); +var + ReadAddr, WriteAddr, ReadRow, WriteRow : UInt32; + SrcPitch, DestPitch, x, y : UInt32; +begin + if ( Src = nil ) or ( Dest = nil ) then + exit; + if ( Src.w shl 1 ) < Dest.w then + exit; + if ( Src.h shl 1 ) < Dest.h then + exit; + + if SDL_MustLock( Src ) then + SDL_LockSurface( Src ); + if SDL_MustLock( Dest ) then + SDL_LockSurface( Dest ); + + ReadRow := UInt32( Src.Pixels ); + WriteRow := UInt32( Dest.Pixels ); + + SrcPitch := Src.pitch; + DestPitch := Dest.pitch; + + case Src.format.BytesPerPixel of + 1 : for y := 1 to Src.h do + begin + ReadAddr := ReadRow; + WriteAddr := WriteRow; + for x := 1 to Src.w do + begin + PUInt8( WriteAddr )^ := PUInt8( ReadAddr )^; + PUInt8( WriteAddr + 1 )^ := PUInt8( ReadAddr )^; + PUInt8( WriteAddr + DestPitch )^ := PUInt8( ReadAddr )^; + PUInt8( WriteAddr + DestPitch + 1 )^ := PUInt8( ReadAddr )^; + inc( ReadAddr ); + inc( WriteAddr, 2 ); + end; + inc( UInt32( ReadRow ), SrcPitch ); + inc( UInt32( WriteRow ), DestPitch * 2 ); + end; + 2 : for y := 1 to Src.h do + begin + ReadAddr := ReadRow; + WriteAddr := WriteRow; + for x := 1 to Src.w do + begin + PUInt16( WriteAddr )^ := PUInt16( ReadAddr )^; + PUInt16( WriteAddr + 2 )^ := PUInt16( ReadAddr )^; + PUInt16( WriteAddr + DestPitch )^ := PUInt16( ReadAddr )^; + PUInt16( WriteAddr + DestPitch + 2 )^ := PUInt16( ReadAddr )^; + inc( ReadAddr, 2 ); + inc( WriteAddr, 4 ); + end; + inc( UInt32( ReadRow ), SrcPitch ); + inc( UInt32( WriteRow ), DestPitch * 2 ); + end; + 3 : for y := 1 to Src.h do + begin + ReadAddr := ReadRow; + WriteAddr := WriteRow; + for x := 1 to Src.w do + begin + PUInt32( WriteAddr )^ := ( PUInt32( WriteAddr )^ and $FF000000 ) or ( PUInt32( ReadAddr )^ and $00FFFFFF ); + PUInt32( WriteAddr + 3 )^ := ( PUInt32( WriteAddr + 3 )^ and $FF000000 ) or ( PUInt32( ReadAddr )^ and $00FFFFFF ); + PUInt32( WriteAddr + DestPitch )^ := ( PUInt32( WriteAddr + DestPitch )^ and $FF000000 ) or ( PUInt32( ReadAddr )^ and $00FFFFFF ); + PUInt32( WriteAddr + DestPitch + 3 )^ := ( PUInt32( WriteAddr + DestPitch + 3 )^ and $FF000000 ) or ( PUInt32( ReadAddr )^ and $00FFFFFF ); + inc( ReadAddr, 3 ); + inc( WriteAddr, 6 ); + end; + inc( UInt32( ReadRow ), SrcPitch ); + inc( UInt32( WriteRow ), DestPitch * 2 ); + end; + 4 : for y := 1 to Src.h do + begin + ReadAddr := ReadRow; + WriteAddr := WriteRow; + for x := 1 to Src.w do + begin + PUInt32( WriteAddr )^ := PUInt32( ReadAddr )^; + PUInt32( WriteAddr + 4 )^ := PUInt32( ReadAddr )^; + PUInt32( WriteAddr + DestPitch )^ := PUInt32( ReadAddr )^; + PUInt32( WriteAddr + DestPitch + 4 )^ := PUInt32( ReadAddr )^; + inc( ReadAddr, 4 ); + inc( WriteAddr, 8 ); + end; + inc( UInt32( ReadRow ), SrcPitch ); + inc( UInt32( WriteRow ), DestPitch * 2 ); + end; + end; + + if SDL_MustLock( Src ) then + SDL_UnlockSurface( Src ); + if SDL_MustLock( Dest ) then + SDL_UnlockSurface( Dest ); +end; + +procedure SDL_Scanline2xBlit( Src, Dest : PSDL_Surface ); +var + ReadAddr, WriteAddr, ReadRow, WriteRow : UInt32; + SrcPitch, DestPitch, x, y : UInt32; +begin + if ( Src = nil ) or ( Dest = nil ) then + exit; + if ( Src.w shl 1 ) < Dest.w then + exit; + if ( Src.h shl 1 ) < Dest.h then + exit; + + if SDL_MustLock( Src ) then + SDL_LockSurface( Src ); + if SDL_MustLock( Dest ) then + SDL_LockSurface( Dest ); + + ReadRow := UInt32( Src.Pixels ); + WriteRow := UInt32( Dest.Pixels ); + + SrcPitch := Src.pitch; + DestPitch := Dest.pitch; + + case Src.format.BytesPerPixel of + 1 : for y := 1 to Src.h do + begin + ReadAddr := ReadRow; + WriteAddr := WriteRow; + for x := 1 to Src.w do + begin + PUInt8( WriteAddr )^ := PUInt8( ReadAddr )^; + PUInt8( WriteAddr + 1 )^ := PUInt8( ReadAddr )^; + inc( ReadAddr ); + inc( WriteAddr, 2 ); + end; + inc( UInt32( ReadRow ), SrcPitch ); + inc( UInt32( WriteRow ), DestPitch * 2 ); + end; + 2 : for y := 1 to Src.h do + begin + ReadAddr := ReadRow; + WriteAddr := WriteRow; + for x := 1 to Src.w do + begin + PUInt16( WriteAddr )^ := PUInt16( ReadAddr )^; + PUInt16( WriteAddr + 2 )^ := PUInt16( ReadAddr )^; + inc( ReadAddr, 2 ); + inc( WriteAddr, 4 ); + end; + inc( UInt32( ReadRow ), SrcPitch ); + inc( UInt32( WriteRow ), DestPitch * 2 ); + end; + 3 : for y := 1 to Src.h do + begin + ReadAddr := ReadRow; + WriteAddr := WriteRow; + for x := 1 to Src.w do + begin + PUInt32( WriteAddr )^ := ( PUInt32( WriteAddr )^ and $FF000000 ) or ( PUInt32( ReadAddr )^ and $00FFFFFF ); + PUInt32( WriteAddr + 3 )^ := ( PUInt32( WriteAddr + 3 )^ and $FF000000 ) or ( PUInt32( ReadAddr )^ and $00FFFFFF ); + inc( ReadAddr, 3 ); + inc( WriteAddr, 6 ); + end; + inc( UInt32( ReadRow ), SrcPitch ); + inc( UInt32( WriteRow ), DestPitch * 2 ); + end; + 4 : for y := 1 to Src.h do + begin + ReadAddr := ReadRow; + WriteAddr := WriteRow; + for x := 1 to Src.w do + begin + PUInt32( WriteAddr )^ := PUInt32( ReadAddr )^; + PUInt32( WriteAddr + 4 )^ := PUInt32( ReadAddr )^; + inc( ReadAddr, 4 ); + inc( WriteAddr, 8 ); + end; + inc( UInt32( ReadRow ), SrcPitch ); + inc( UInt32( WriteRow ), DestPitch * 2 ); + end; + end; + + if SDL_MustLock( Src ) then + SDL_UnlockSurface( Src ); + if SDL_MustLock( Dest ) then + SDL_UnlockSurface( Dest ); +end; + +procedure SDL_50Scanline2xBlit( Src, Dest : PSDL_Surface ); +var + ReadAddr, WriteAddr, ReadRow, WriteRow : UInt32; + SrcPitch, DestPitch, x, y, Color : UInt32; +begin + if ( Src = nil ) or ( Dest = nil ) then + exit; + if ( Src.w shl 1 ) < Dest.w then + exit; + if ( Src.h shl 1 ) < Dest.h then + exit; + + if SDL_MustLock( Src ) then + SDL_LockSurface( Src ); + if SDL_MustLock( Dest ) then + SDL_LockSurface( Dest ); + + ReadRow := UInt32( Src.Pixels ); + WriteRow := UInt32( Dest.Pixels ); + + SrcPitch := Src.pitch; + DestPitch := Dest.pitch; + + case Src.format.BitsPerPixel of + 8 : for y := 1 to Src.h do + begin + ReadAddr := ReadRow; + WriteAddr := WriteRow; + for x := 1 to Src.w do + begin + Color := PUInt8( ReadAddr )^; + PUInt8( WriteAddr )^ := Color; + PUInt8( WriteAddr + 1 )^ := Color; + Color := ( Color shr 1 ) and $6D; {%01101101} + PUInt8( WriteAddr + DestPitch )^ := Color; + PUInt8( WriteAddr + DestPitch + 1 )^ := Color; + inc( ReadAddr ); + inc( WriteAddr, 2 ); + end; + inc( UInt32( ReadRow ), SrcPitch ); + inc( UInt32( WriteRow ), DestPitch * 2 ); + end; + 15 : for y := 1 to Src.h do + begin + ReadAddr := ReadRow; + WriteAddr := WriteRow; + for x := 1 to Src.w do + begin + Color := PUInt16( ReadAddr )^; + PUInt16( WriteAddr )^ := Color; + PUInt16( WriteAddr + 2 )^ := Color; + Color := ( Color shr 1 ) and $3DEF; {%0011110111101111} + PUInt16( WriteAddr + DestPitch )^ := Color; + PUInt16( WriteAddr + DestPitch + 2 )^ := Color; + inc( ReadAddr, 2 ); + inc( WriteAddr, 4 ); + end; + inc( UInt32( ReadRow ), SrcPitch ); + inc( UInt32( WriteRow ), DestPitch * 2 ); + end; + 16 : for y := 1 to Src.h do + begin + ReadAddr := ReadRow; + WriteAddr := WriteRow; + for x := 1 to Src.w do + begin + Color := PUInt16( ReadAddr )^; + PUInt16( WriteAddr )^ := Color; + PUInt16( WriteAddr + 2 )^ := Color; + Color := ( Color shr 1 ) and $7BEF; {%0111101111101111} + PUInt16( WriteAddr + DestPitch )^ := Color; + PUInt16( WriteAddr + DestPitch + 2 )^ := Color; + inc( ReadAddr, 2 ); + inc( WriteAddr, 4 ); + end; + inc( UInt32( ReadRow ), SrcPitch ); + inc( UInt32( WriteRow ), DestPitch * 2 ); + end; + 24 : for y := 1 to Src.h do + begin + ReadAddr := ReadRow; + WriteAddr := WriteRow; + for x := 1 to Src.w do + begin + Color := ( PUInt32( WriteAddr )^ and $FF000000 ) or ( PUInt32( ReadAddr )^ and $00FFFFFF ); + PUInt32( WriteAddr )^ := Color; + PUInt32( WriteAddr + 3 )^ := Color; + Color := ( Color shr 1 ) and $007F7F7F; {%011111110111111101111111} + PUInt32( WriteAddr + DestPitch )^ := Color; + PUInt32( WriteAddr + DestPitch + 3 )^ := Color; + inc( ReadAddr, 3 ); + inc( WriteAddr, 6 ); + end; + inc( UInt32( ReadRow ), SrcPitch ); + inc( UInt32( WriteRow ), DestPitch * 2 ); + end; + 32 : for y := 1 to Src.h do + begin + ReadAddr := ReadRow; + WriteAddr := WriteRow; + for x := 1 to Src.w do + begin + Color := PUInt32( ReadAddr )^; + PUInt32( WriteAddr )^ := Color; + PUInt32( WriteAddr + 4 )^ := Color; + Color := ( Color shr 1 ) and $7F7F7F7F; + PUInt32( WriteAddr + DestPitch )^ := Color; + PUInt32( WriteAddr + DestPitch + 4 )^ := Color; + inc( ReadAddr, 4 ); + inc( WriteAddr, 8 ); + end; + inc( UInt32( ReadRow ), SrcPitch ); + inc( UInt32( WriteRow ), DestPitch * 2 ); + end; + end; + + if SDL_MustLock( Src ) then + SDL_UnlockSurface( Src ); + if SDL_MustLock( Dest ) then + SDL_UnlockSurface( Dest ); +end; + +function SDL_PixelTestSurfaceVsRect( SrcSurface1 : PSDL_Surface; SrcRect1 : + PSDL_Rect; SrcRect2 : PSDL_Rect; Left1, Top1, Left2, Top2 : integer ) : + boolean; +var + Src_Rect1, Src_Rect2 : TSDL_Rect; + right1, bottom1 : integer; + right2, bottom2 : integer; + Scan1Start, {Scan2Start,} ScanWidth, ScanHeight : cardinal; + Mod1 : cardinal; + Addr1 : cardinal; + BPP : cardinal; + Pitch1 : cardinal; + TransparentColor1 : cardinal; + tx, ty : cardinal; + StartTick : cardinal; + Color1 : cardinal; +begin + Result := false; + if SrcRect1 = nil then + begin + with Src_Rect1 do + begin + x := 0; + y := 0; + w := SrcSurface1.w; + h := SrcSurface1.h; + end; + end + else + Src_Rect1 := SrcRect1^; + + Src_Rect2 := SrcRect2^; + with Src_Rect1 do + begin + Right1 := Left1 + w; + Bottom1 := Top1 + h; + end; + with Src_Rect2 do + begin + Right2 := Left2 + w; + Bottom2 := Top2 + h; + end; + if ( Left1 >= Right2 ) or ( Right1 <= Left2 ) or ( Top1 >= Bottom2 ) or ( Bottom1 <= Top2 ) then + exit; + if Left1 <= Left2 then + begin + // 1. left, 2. right + Scan1Start := Src_Rect1.x + Left2 - Left1; + //Scan2Start := Src_Rect2.x; + ScanWidth := Right1 - Left2; + with Src_Rect2 do + if ScanWidth > w then + ScanWidth := w; + end + else + begin + // 1. right, 2. left + Scan1Start := Src_Rect1.x; + //Scan2Start := Src_Rect2.x + Left1 - Left2; + ScanWidth := Right2 - Left1; + with Src_Rect1 do + if ScanWidth > w then + ScanWidth := w; + end; + with SrcSurface1^ do + begin + Pitch1 := Pitch; + Addr1 := cardinal( Pixels ); + inc( Addr1, Pitch1 * UInt32( Src_Rect1.y ) ); + with format^ do + begin + BPP := BytesPerPixel; + TransparentColor1 := colorkey; + end; + end; + + Mod1 := Pitch1 - ( ScanWidth * BPP ); + + inc( Addr1, BPP * Scan1Start ); + + if Top1 <= Top2 then + begin + // 1. up, 2. down + ScanHeight := Bottom1 - Top2; + if ScanHeight > Src_Rect2.h then + ScanHeight := Src_Rect2.h; + inc( Addr1, Pitch1 * UInt32( Top2 - Top1 ) ); + end + else + begin + // 1. down, 2. up + ScanHeight := Bottom2 - Top1; + if ScanHeight > Src_Rect1.h then + ScanHeight := Src_Rect1.h; + + end; + case BPP of + 1 : + for ty := 1 to ScanHeight do + begin + for tx := 1 to ScanWidth do + begin + if ( PByte( Addr1 )^ <> TransparentColor1 ) then + begin + Result := true; + exit; + end; + inc( Addr1 ); + + end; + inc( Addr1, Mod1 ); + + end; + 2 : + for ty := 1 to ScanHeight do + begin + for tx := 1 to ScanWidth do + begin + if ( PWord( Addr1 )^ <> TransparentColor1 ) then + begin + Result := true; + exit; + end; + inc( Addr1, 2 ); + + end; + inc( Addr1, Mod1 ); + + end; + 3 : + for ty := 1 to ScanHeight do + begin + for tx := 1 to ScanWidth do + begin + Color1 := PLongWord( Addr1 )^ and $00FFFFFF; + + if ( Color1 <> TransparentColor1 ) + then + begin + Result := true; + exit; + end; + inc( Addr1, 3 ); + + end; + inc( Addr1, Mod1 ); + + end; + 4 : + for ty := 1 to ScanHeight do + begin + for tx := 1 to ScanWidth do + begin + if ( PLongWord( Addr1 )^ <> TransparentColor1 ) then + begin + Result := true; + exit; + end; + inc( Addr1, 4 ); + + end; + inc( Addr1, Mod1 ); + + end; + end; +end; + +procedure SDL_ORSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; + DestSurface : PSDL_Surface; DestRect : PSDL_Rect ); +var + R, G, B, Pixel1, Pixel2, TransparentColor : cardinal; + Src, Dest : TSDL_Rect; + Diff : integer; + SrcAddr, DestAddr : cardinal; + WorkX, WorkY : word; + SrcMod, DestMod : cardinal; + Bits : cardinal; +begin + if ( SrcSurface = nil ) or ( DestSurface = nil ) then + exit; // Remove this to make it faster + if ( SrcSurface.Format.BitsPerPixel <> DestSurface.Format.BitsPerPixel ) then + exit; // Remove this to make it faster + if SrcRect = nil then + begin + with Src do + begin + x := 0; + y := 0; + w := SrcSurface.w; + h := SrcSurface.h; + end; + end + else + Src := SrcRect^; + if DestRect = nil then + begin + Dest.x := 0; + Dest.y := 0; + end + else + Dest := DestRect^; + Dest.w := Src.w; + Dest.h := Src.h; + with DestSurface.Clip_Rect do + begin + // Source's right side is greater than the dest.cliprect + if Dest.x + Src.w > x + w then + begin + smallint( Src.w ) := x + w - Dest.x; + smallint( Dest.w ) := x + w - Dest.x; + if smallint( Dest.w ) < 1 then + exit; + end; + // Source's bottom side is greater than the dest.clip + if Dest.y + Src.h > y + h then + begin + smallint( Src.h ) := y + h - Dest.y; + smallint( Dest.h ) := y + h - Dest.y; + if smallint( Dest.h ) < 1 then + exit; + end; + // Source's left side is less than the dest.clip + if Dest.x < x then + begin + Diff := x - Dest.x; + Src.x := Src.x + Diff; + smallint( Src.w ) := smallint( Src.w ) - Diff; + Dest.x := x; + smallint( Dest.w ) := smallint( Dest.w ) - Diff; + if smallint( Dest.w ) < 1 then + exit; + end; + // Source's Top side is less than the dest.clip + if Dest.y < y then + begin + Diff := y - Dest.y; + Src.y := Src.y + Diff; + smallint( Src.h ) := smallint( Src.h ) - Diff; + Dest.y := y; + smallint( Dest.h ) := smallint( Dest.h ) - Diff; + if smallint( Dest.h ) < 1 then + exit; + end; + end; + with SrcSurface^ do + begin + SrcAddr := cardinal( Pixels ) + UInt32( Src.y ) * Pitch + UInt32( Src.x ) * + Format.BytesPerPixel; + SrcMod := Pitch - Src.w * Format.BytesPerPixel; + TransparentColor := Format.colorkey; + end; + with DestSurface^ do + begin + DestAddr := cardinal( Pixels ) + UInt32( Dest.y ) * Pitch + UInt32( Dest.x ) * + Format.BytesPerPixel; + DestMod := Pitch - Dest.w * Format.BytesPerPixel; + Bits := Format.BitsPerPixel; + end; + SDL_LockSurface( SrcSurface ); + SDL_LockSurface( DestSurface ); + WorkY := Src.h; + case bits of + 8 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt8( SrcAddr )^; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt8( DestAddr )^; + PUInt8( DestAddr )^ := Pixel2 or Pixel1; + end; + inc( SrcAddr ); + inc( DestAddr ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + 15 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt16( SrcAddr )^; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt16( DestAddr )^; + + PUInt16( DestAddr )^ := Pixel2 or Pixel1; + + end; + inc( SrcAddr, 2 ); + inc( DestAddr, 2 ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + 16 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt16( SrcAddr )^; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt16( DestAddr )^; + + PUInt16( DestAddr )^ := Pixel2 or Pixel1; + + end; + inc( SrcAddr, 2 ); + inc( DestAddr, 2 ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + 24 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt32( SrcAddr )^ and $00FFFFFF; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt32( DestAddr )^ and $00FFFFFF; + + PUInt32( DestAddr )^ := PUInt32( DestAddr )^ and $FF000000 or Pixel2 or Pixel1; + end; + inc( SrcAddr, 3 ); + inc( DestAddr, 3 ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + 32 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt32( SrcAddr )^; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt32( DestAddr )^; + + PUInt32( DestAddr )^ := Pixel2 or Pixel1; + end; + inc( SrcAddr, 4 ); + inc( DestAddr, 4 ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + end; + SDL_UnlockSurface( SrcSurface ); + SDL_UnlockSurface( DestSurface ); +end; + +procedure SDL_ANDSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; + DestSurface : PSDL_Surface; DestRect : PSDL_Rect ); +var + R, G, B, Pixel1, Pixel2, TransparentColor : cardinal; + Src, Dest : TSDL_Rect; + Diff : integer; + SrcAddr, DestAddr : cardinal; + WorkX, WorkY : word; + SrcMod, DestMod : cardinal; + Bits : cardinal; +begin + if ( SrcSurface = nil ) or ( DestSurface = nil ) then + exit; // Remove this to make it faster + if ( SrcSurface.Format.BitsPerPixel <> DestSurface.Format.BitsPerPixel ) then + exit; // Remove this to make it faster + if SrcRect = nil then + begin + with Src do + begin + x := 0; + y := 0; + w := SrcSurface.w; + h := SrcSurface.h; + end; + end + else + Src := SrcRect^; + if DestRect = nil then + begin + Dest.x := 0; + Dest.y := 0; + end + else + Dest := DestRect^; + Dest.w := Src.w; + Dest.h := Src.h; + with DestSurface.Clip_Rect do + begin + // Source's right side is greater than the dest.cliprect + if Dest.x + Src.w > x + w then + begin + smallint( Src.w ) := x + w - Dest.x; + smallint( Dest.w ) := x + w - Dest.x; + if smallint( Dest.w ) < 1 then + exit; + end; + // Source's bottom side is greater than the dest.clip + if Dest.y + Src.h > y + h then + begin + smallint( Src.h ) := y + h - Dest.y; + smallint( Dest.h ) := y + h - Dest.y; + if smallint( Dest.h ) < 1 then + exit; + end; + // Source's left side is less than the dest.clip + if Dest.x < x then + begin + Diff := x - Dest.x; + Src.x := Src.x + Diff; + smallint( Src.w ) := smallint( Src.w ) - Diff; + Dest.x := x; + smallint( Dest.w ) := smallint( Dest.w ) - Diff; + if smallint( Dest.w ) < 1 then + exit; + end; + // Source's Top side is less than the dest.clip + if Dest.y < y then + begin + Diff := y - Dest.y; + Src.y := Src.y + Diff; + smallint( Src.h ) := smallint( Src.h ) - Diff; + Dest.y := y; + smallint( Dest.h ) := smallint( Dest.h ) - Diff; + if smallint( Dest.h ) < 1 then + exit; + end; + end; + with SrcSurface^ do + begin + SrcAddr := cardinal( Pixels ) + UInt32( Src.y ) * Pitch + UInt32( Src.x ) * + Format.BytesPerPixel; + SrcMod := Pitch - Src.w * Format.BytesPerPixel; + TransparentColor := Format.colorkey; + end; + with DestSurface^ do + begin + DestAddr := cardinal( Pixels ) + UInt32( Dest.y ) * Pitch + UInt32( Dest.x ) * + Format.BytesPerPixel; + DestMod := Pitch - Dest.w * Format.BytesPerPixel; + Bits := Format.BitsPerPixel; + end; + SDL_LockSurface( SrcSurface ); + SDL_LockSurface( DestSurface ); + WorkY := Src.h; + case bits of + 8 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt8( SrcAddr )^; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt8( DestAddr )^; + PUInt8( DestAddr )^ := Pixel2 and Pixel1; + end; + inc( SrcAddr ); + inc( DestAddr ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + 15 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt16( SrcAddr )^; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt16( DestAddr )^; + + PUInt16( DestAddr )^ := Pixel2 and Pixel1; + + end; + inc( SrcAddr, 2 ); + inc( DestAddr, 2 ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + 16 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt16( SrcAddr )^; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt16( DestAddr )^; + + PUInt16( DestAddr )^ := Pixel2 and Pixel1; + + end; + inc( SrcAddr, 2 ); + inc( DestAddr, 2 ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + 24 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt32( SrcAddr )^ and $00FFFFFF; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt32( DestAddr )^ and $00FFFFFF; + + PUInt32( DestAddr )^ := PUInt32( DestAddr )^ and $FF000000 or Pixel2 and Pixel1; + end; + inc( SrcAddr, 3 ); + inc( DestAddr, 3 ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + 32 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt32( SrcAddr )^; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt32( DestAddr )^; + + PUInt32( DestAddr )^ := Pixel2 and Pixel1; + end; + inc( SrcAddr, 4 ); + inc( DestAddr, 4 ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + end; + SDL_UnlockSurface( SrcSurface ); + SDL_UnlockSurface( DestSurface ); +end; + + + +procedure SDL_GTSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; + DestSurface : PSDL_Surface; DestRect : PSDL_Rect ); +var + R, G, B, Pixel1, Pixel2, TransparentColor : cardinal; + Src, Dest : TSDL_Rect; + Diff : integer; + SrcAddr, DestAddr : cardinal; + WorkX, WorkY : word; + SrcMod, DestMod : cardinal; + Bits : cardinal; +begin + if ( SrcSurface = nil ) or ( DestSurface = nil ) then + exit; // Remove this to make it faster + if ( SrcSurface.Format.BitsPerPixel <> DestSurface.Format.BitsPerPixel ) then + exit; // Remove this to make it faster + if SrcRect = nil then + begin + with Src do + begin + x := 0; + y := 0; + w := SrcSurface.w; + h := SrcSurface.h; + end; + end + else + Src := SrcRect^; + if DestRect = nil then + begin + Dest.x := 0; + Dest.y := 0; + end + else + Dest := DestRect^; + Dest.w := Src.w; + Dest.h := Src.h; + with DestSurface.Clip_Rect do + begin + // Source's right side is greater than the dest.cliprect + if Dest.x + Src.w > x + w then + begin + smallint( Src.w ) := x + w - Dest.x; + smallint( Dest.w ) := x + w - Dest.x; + if smallint( Dest.w ) < 1 then + exit; + end; + // Source's bottom side is greater than the dest.clip + if Dest.y + Src.h > y + h then + begin + smallint( Src.h ) := y + h - Dest.y; + smallint( Dest.h ) := y + h - Dest.y; + if smallint( Dest.h ) < 1 then + exit; + end; + // Source's left side is less than the dest.clip + if Dest.x < x then + begin + Diff := x - Dest.x; + Src.x := Src.x + Diff; + smallint( Src.w ) := smallint( Src.w ) - Diff; + Dest.x := x; + smallint( Dest.w ) := smallint( Dest.w ) - Diff; + if smallint( Dest.w ) < 1 then + exit; + end; + // Source's Top side is less than the dest.clip + if Dest.y < y then + begin + Diff := y - Dest.y; + Src.y := Src.y + Diff; + smallint( Src.h ) := smallint( Src.h ) - Diff; + Dest.y := y; + smallint( Dest.h ) := smallint( Dest.h ) - Diff; + if smallint( Dest.h ) < 1 then + exit; + end; + end; + with SrcSurface^ do + begin + SrcAddr := cardinal( Pixels ) + UInt32( Src.y ) * Pitch + UInt32( Src.x ) * + Format.BytesPerPixel; + SrcMod := Pitch - Src.w * Format.BytesPerPixel; + TransparentColor := Format.colorkey; + end; + with DestSurface^ do + begin + DestAddr := cardinal( Pixels ) + UInt32( Dest.y ) * Pitch + UInt32( Dest.x ) * + Format.BytesPerPixel; + DestMod := Pitch - Dest.w * Format.BytesPerPixel; + Bits := Format.BitsPerPixel; + end; + SDL_LockSurface( SrcSurface ); + SDL_LockSurface( DestSurface ); + WorkY := Src.h; + case bits of + 8 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt8( SrcAddr )^; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt8( DestAddr )^; + if Pixel2 > 0 then + begin + if Pixel2 and $E0 > Pixel1 and $E0 then + R := Pixel2 and $E0 + else + R := Pixel1 and $E0; + if Pixel2 and $1C > Pixel1 and $1C then + G := Pixel2 and $1C + else + G := Pixel1 and $1C; + if Pixel2 and $03 > Pixel1 and $03 then + B := Pixel2 and $03 + else + B := Pixel1 and $03; + + if R > $E0 then + R := $E0; + if G > $1C then + G := $1C; + if B > $03 then + B := $03; + PUInt8( DestAddr )^ := R or G or B; + end + else + PUInt8( DestAddr )^ := Pixel1; + end; + inc( SrcAddr ); + inc( DestAddr ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + 15 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt16( SrcAddr )^; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt16( DestAddr )^; + if Pixel2 > 0 then + begin + + if Pixel2 and $7C00 > Pixel1 and $7C00 then + R := Pixel2 and $7C00 + else + R := Pixel1 and $7C00; + if Pixel2 and $03E0 > Pixel1 and $03E0 then + G := Pixel2 and $03E0 + else + G := Pixel1 and $03E0; + if Pixel2 and $001F > Pixel1 and $001F then + B := Pixel2 and $001F + else + B := Pixel1 and $001F; + + PUInt16( DestAddr )^ := R or G or B; + end + else + PUInt16( DestAddr )^ := Pixel1; + end; + inc( SrcAddr, 2 ); + inc( DestAddr, 2 ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + 16 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt16( SrcAddr )^; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt16( DestAddr )^; + if Pixel2 > 0 then + begin + + if Pixel2 and $F800 > Pixel1 and $F800 then + R := Pixel2 and $F800 + else + R := Pixel1 and $F800; + if Pixel2 and $07E0 > Pixel1 and $07E0 then + G := Pixel2 and $07E0 + else + G := Pixel1 and $07E0; + if Pixel2 and $001F > Pixel1 and $001F then + B := Pixel2 and $001F + else + B := Pixel1 and $001F; + + PUInt16( DestAddr )^ := R or G or B; + end + else + PUInt16( DestAddr )^ := Pixel1; + end; + inc( SrcAddr, 2 ); + inc( DestAddr, 2 ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + 24 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt32( SrcAddr )^ and $00FFFFFF; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt32( DestAddr )^ and $00FFFFFF; + if Pixel2 > 0 then + begin + + if Pixel2 and $FF0000 > Pixel1 and $FF0000 then + R := Pixel2 and $FF0000 + else + R := Pixel1 and $FF0000; + if Pixel2 and $00FF00 > Pixel1 and $00FF00 then + G := Pixel2 and $00FF00 + else + G := Pixel1 and $00FF00; + if Pixel2 and $0000FF > Pixel1 and $0000FF then + B := Pixel2 and $0000FF + else + B := Pixel1 and $0000FF; + + PUInt32( DestAddr )^ := PUInt32( DestAddr )^ and $FF000000 or ( R or G or B ); + end + else + PUInt32( DestAddr )^ := PUInt32( DestAddr )^ and $FF000000 or Pixel1; + end; + inc( SrcAddr, 3 ); + inc( DestAddr, 3 ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + 32 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt32( SrcAddr )^; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt32( DestAddr )^; + if Pixel2 > 0 then + begin + + if Pixel2 and $FF0000 > Pixel1 and $FF0000 then + R := Pixel2 and $FF0000 + else + R := Pixel1 and $FF0000; + if Pixel2 and $00FF00 > Pixel1 and $00FF00 then + G := Pixel2 and $00FF00 + else + G := Pixel1 and $00FF00; + if Pixel2 and $0000FF > Pixel1 and $0000FF then + B := Pixel2 and $0000FF + else + B := Pixel1 and $0000FF; + + PUInt32( DestAddr )^ := R or G or B; + end + else + PUInt32( DestAddr )^ := Pixel1; + end; + inc( SrcAddr, 4 ); + inc( DestAddr, 4 ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + end; + SDL_UnlockSurface( SrcSurface ); + SDL_UnlockSurface( DestSurface ); +end; + + +procedure SDL_LTSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; + DestSurface : PSDL_Surface; DestRect : PSDL_Rect ); +var + R, G, B, Pixel1, Pixel2, TransparentColor : cardinal; + Src, Dest : TSDL_Rect; + Diff : integer; + SrcAddr, DestAddr : cardinal; + WorkX, WorkY : word; + SrcMod, DestMod : cardinal; + Bits : cardinal; +begin + if ( SrcSurface = nil ) or ( DestSurface = nil ) then + exit; // Remove this to make it faster + if ( SrcSurface.Format.BitsPerPixel <> DestSurface.Format.BitsPerPixel ) then + exit; // Remove this to make it faster + if SrcRect = nil then + begin + with Src do + begin + x := 0; + y := 0; + w := SrcSurface.w; + h := SrcSurface.h; + end; + end + else + Src := SrcRect^; + if DestRect = nil then + begin + Dest.x := 0; + Dest.y := 0; + end + else + Dest := DestRect^; + Dest.w := Src.w; + Dest.h := Src.h; + with DestSurface.Clip_Rect do + begin + // Source's right side is greater than the dest.cliprect + if Dest.x + Src.w > x + w then + begin + smallint( Src.w ) := x + w - Dest.x; + smallint( Dest.w ) := x + w - Dest.x; + if smallint( Dest.w ) < 1 then + exit; + end; + // Source's bottom side is greater than the dest.clip + if Dest.y + Src.h > y + h then + begin + smallint( Src.h ) := y + h - Dest.y; + smallint( Dest.h ) := y + h - Dest.y; + if smallint( Dest.h ) < 1 then + exit; + end; + // Source's left side is less than the dest.clip + if Dest.x < x then + begin + Diff := x - Dest.x; + Src.x := Src.x + Diff; + smallint( Src.w ) := smallint( Src.w ) - Diff; + Dest.x := x; + smallint( Dest.w ) := smallint( Dest.w ) - Diff; + if smallint( Dest.w ) < 1 then + exit; + end; + // Source's Top side is less than the dest.clip + if Dest.y < y then + begin + Diff := y - Dest.y; + Src.y := Src.y + Diff; + smallint( Src.h ) := smallint( Src.h ) - Diff; + Dest.y := y; + smallint( Dest.h ) := smallint( Dest.h ) - Diff; + if smallint( Dest.h ) < 1 then + exit; + end; + end; + with SrcSurface^ do + begin + SrcAddr := cardinal( Pixels ) + UInt32( Src.y ) * Pitch + UInt32( Src.x ) * + Format.BytesPerPixel; + SrcMod := Pitch - Src.w * Format.BytesPerPixel; + TransparentColor := Format.colorkey; + end; + with DestSurface^ do + begin + DestAddr := cardinal( Pixels ) + UInt32( Dest.y ) * Pitch + UInt32( Dest.x ) * + Format.BytesPerPixel; + DestMod := Pitch - Dest.w * Format.BytesPerPixel; + Bits := Format.BitsPerPixel; + end; + SDL_LockSurface( SrcSurface ); + SDL_LockSurface( DestSurface ); + WorkY := Src.h; + case bits of + 8 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt8( SrcAddr )^; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt8( DestAddr )^; + if Pixel2 > 0 then + begin + if Pixel2 and $E0 < Pixel1 and $E0 then + R := Pixel2 and $E0 + else + R := Pixel1 and $E0; + if Pixel2 and $1C < Pixel1 and $1C then + G := Pixel2 and $1C + else + G := Pixel1 and $1C; + if Pixel2 and $03 < Pixel1 and $03 then + B := Pixel2 and $03 + else + B := Pixel1 and $03; + + if R > $E0 then + R := $E0; + if G > $1C then + G := $1C; + if B > $03 then + B := $03; + PUInt8( DestAddr )^ := R or G or B; + end + else + PUInt8( DestAddr )^ := Pixel1; + end; + inc( SrcAddr ); + inc( DestAddr ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + 15 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt16( SrcAddr )^; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt16( DestAddr )^; + if Pixel2 > 0 then + begin + + if Pixel2 and $7C00 < Pixel1 and $7C00 then + R := Pixel2 and $7C00 + else + R := Pixel1 and $7C00; + if Pixel2 and $03E0 < Pixel1 and $03E0 then + G := Pixel2 and $03E0 + else + G := Pixel1 and $03E0; + if Pixel2 and $001F < Pixel1 and $001F then + B := Pixel2 and $001F + else + B := Pixel1 and $001F; + + PUInt16( DestAddr )^ := R or G or B; + end + else + PUInt16( DestAddr )^ := Pixel1; + end; + inc( SrcAddr, 2 ); + inc( DestAddr, 2 ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + 16 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt16( SrcAddr )^; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt16( DestAddr )^; + if Pixel2 > 0 then + begin + + if Pixel2 and $F800 < Pixel1 and $F800 then + R := Pixel2 and $F800 + else + R := Pixel1 and $F800; + if Pixel2 and $07E0 < Pixel1 and $07E0 then + G := Pixel2 and $07E0 + else + G := Pixel1 and $07E0; + if Pixel2 and $001F < Pixel1 and $001F then + B := Pixel2 and $001F + else + B := Pixel1 and $001F; + + PUInt16( DestAddr )^ := R or G or B; + end + else + PUInt16( DestAddr )^ := Pixel1; + end; + inc( SrcAddr, 2 ); + inc( DestAddr, 2 ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + 24 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt32( SrcAddr )^ and $00FFFFFF; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt32( DestAddr )^ and $00FFFFFF; + if Pixel2 > 0 then + begin + + if Pixel2 and $FF0000 < Pixel1 and $FF0000 then + R := Pixel2 and $FF0000 + else + R := Pixel1 and $FF0000; + if Pixel2 and $00FF00 < Pixel1 and $00FF00 then + G := Pixel2 and $00FF00 + else + G := Pixel1 and $00FF00; + if Pixel2 and $0000FF < Pixel1 and $0000FF then + B := Pixel2 and $0000FF + else + B := Pixel1 and $0000FF; + + PUInt32( DestAddr )^ := PUInt32( DestAddr )^ and $FF000000 or ( R or G or B ); + end + else + PUInt32( DestAddr )^ := PUInt32( DestAddr )^ and $FF000000 or Pixel1; + end; + inc( SrcAddr, 3 ); + inc( DestAddr, 3 ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + 32 : + begin + repeat + WorkX := Src.w; + repeat + Pixel1 := PUInt32( SrcAddr )^; + if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then + begin + Pixel2 := PUInt32( DestAddr )^; + if Pixel2 > 0 then + begin + + if Pixel2 and $FF0000 < Pixel1 and $FF0000 then + R := Pixel2 and $FF0000 + else + R := Pixel1 and $FF0000; + if Pixel2 and $00FF00 < Pixel1 and $00FF00 then + G := Pixel2 and $00FF00 + else + G := Pixel1 and $00FF00; + if Pixel2 and $0000FF < Pixel1 and $0000FF then + B := Pixel2 and $0000FF + else + B := Pixel1 and $0000FF; + + PUInt32( DestAddr )^ := R or G or B; + end + else + PUInt32( DestAddr )^ := Pixel1; + end; + inc( SrcAddr, 4 ); + inc( DestAddr, 4 ); + dec( WorkX ); + until WorkX = 0; + inc( SrcAddr, SrcMod ); + inc( DestAddr, DestMod ); + dec( WorkY ); + until WorkY = 0; + end; + end; + SDL_UnlockSurface( SrcSurface ); + SDL_UnlockSurface( DestSurface ); +end; + +// Will clip the x1,x2,y1,x2 params to the ClipRect provided + +function SDL_ClipLine( var x1, y1, x2, y2 : Integer; ClipRect : PSDL_Rect ) : boolean; +var + tflag, flag1, flag2 : word; + txy, xedge, yedge : Integer; + slope : single; + + function ClipCode( x, y : Integer ) : word; + begin + Result := 0; + if x < ClipRect.x then + Result := 1; + if x >= ClipRect.w + ClipRect.x then + Result := Result or 2; + if y < ClipRect.y then + Result := Result or 4; + if y >= ClipRect.h + ClipRect.y then + Result := Result or 8; + end; + +begin + flag1 := ClipCode( x1, y1 ); + flag2 := ClipCode( x2, y2 ); + result := true; + + while true do + begin + if ( flag1 or flag2 ) = 0 then + Exit; // all in + + if ( flag1 and flag2 ) <> 0 then + begin + result := false; + Exit; // all out + end; + + if flag2 = 0 then + begin + txy := x1; x1 := x2; x2 := txy; + txy := y1; y1 := y2; y2 := txy; + tflag := flag1; flag1 := flag2; flag2 := tflag; + end; + + if ( flag2 and 3 ) <> 0 then + begin + if ( flag2 and 1 ) <> 0 then + xedge := ClipRect.x + else + xedge := ClipRect.w + ClipRect.x - 1; // back 1 pixel otherwise we end up in a loop + + slope := ( y2 - y1 ) / ( x2 - x1 ); + y2 := y1 + Round( slope * ( xedge - x1 ) ); + x2 := xedge; + end + else + begin + if ( flag2 and 4 ) <> 0 then + yedge := ClipRect.y + else + yedge := ClipRect.h + ClipRect.y - 1; // up 1 pixel otherwise we end up in a loop + + slope := ( x2 - x1 ) / ( y2 - y1 ); + x2 := x1 + Round( slope * ( yedge - y1 ) ); + y2 := yedge; + end; + + flag2 := ClipCode( x2, y2 ); + end; +end; + +end. + diff --git a/lib/base/sdl/smpeg.nim b/lib/base/sdl/smpeg.nim new file mode 100644 index 000000000..ada0ed57c --- /dev/null +++ b/lib/base/sdl/smpeg.nim @@ -0,0 +1,319 @@ + +#****************************************************************************** +# +# $Id: smpeg.pas,v 1.7 2004/08/14 22:54:30 savage Exp $ +# +# +# +# Borland Delphi SMPEG - SDL MPEG Player Library +# Conversion of the SMPEG - SDL MPEG Player Library +# +# Portions created by Sam Lantinga <slouken@devolution.com> are +# Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga +# 5635-34 Springhouse Dr. +# Pleasanton, CA 94588 (USA) +# +# All Rights Reserved. +# +# The original files are : smpeg.h +# +# The initial developer of this Pascal code was : +# Matthias Thoma <ma.thoma@gmx.de> +# +# Portions created by Matthias Thoma are +# Copyright (C) 2000 - 2001 Matthias Thoma. +# +# +# Contributor(s) +# -------------- +# Tom Jones <tigertomjones@gmx.de> His Project inspired this conversion +# Matthias Thoma <ma.thoma@gmx.de> +# +# Obtained through: +# Joint Endeavour of Delphi Innovators ( Project JEDI ) +# +# You may retrieve the latest version of this file at the Project +# JEDI home page, located at http://delphi-jedi.org +# +# The contents of this file are used with permission, subject to +# the Mozilla Public License Version 1.1 (the "License"); you may +# not use this file except in compliance with the License. You may +# obtain a copy of the License at +# http://www.mozilla.org/MPL/MPL-1.1.html +# +# Software distributed under the License is distributed on an +# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# Description +# ----------- +# +# +# +# +# +# +# +# Requires +# -------- +# The SDL Runtime libraris on Win32 : SDL.dll on Linux : libSDL-1.2.so.0 +# They are available from... +# http://www.libsdl.org . +# +# Programming Notes +# ----------------- +# +# +# +# +# Revision History +# ---------------- +# May 08 2001 - MT : Initial conversion +# +# October 12 2001 - DA : Various changes as suggested by David Acklam +# +# April 03 2003 - DL : Added jedi-sdl.inc include file to support more +# Pascal compilers. Initial support is now included +# for GnuPascal, VirtualPascal, TMT and obviously +# continue support for Delphi Kylix and FreePascal. +# +# April 08 2003 - MK : Aka Mr Kroket - Added Better FPC support +# Fixed all invalid calls to DLL. +# Changed constant names to: +# const +# STATUS_SMPEG_ERROR = -1; +# STATUS_SMPEG_STOPPED = 0; +# STATUS_SMPEG_PLAYING = 1; +# because SMPEG_ERROR is a function (_SMPEG_error +# isn't correct), and cannot be two elements with the +# same name +# +# April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added +# better TMT Pascal support and under instruction +# from Prof. Abimbola Olowofoyeku (The African Chief), +# I have added better Gnu Pascal support +# +# April 30 2003 - DL : under instruction from David Mears AKA +# Jason Siletto, I have added FPC Linux support. +# This was compiled with fpc 1.1, so remember to set +# include file path. ie. -Fi/usr/share/fpcsrc/rtl/* +# +# +# $Log: smpeg.pas,v $ +# Revision 1.7 2004/08/14 22:54:30 savage +# Updated so that Library name defines are correctly defined for MacOS X. +# +# Revision 1.6 2004/05/10 14:10:04 savage +# Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ). +# +# Revision 1.5 2004/04/13 09:32:08 savage +# Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary. +# +# Revision 1.4 2004/04/02 10:40:55 savage +# Changed Linux Shared Object name so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site. +# +# Revision 1.3 2004/03/31 22:20:02 savage +# Windows unit not used in this file, so it was removed to keep the code tidy. +# +# Revision 1.2 2004/03/30 20:23:28 savage +# Tidied up use of UNIX compiler directive. +# +# Revision 1.1 2004/02/14 23:35:42 savage +# version 1 of sdl_image, sdl_mixer and smpeg. +# +# +# +#****************************************************************************** + +import + sdl + +when defined(windows): + const SmpegLibName = "smpeg.dll" +elif defined(macosx): + const SmpegLibName = "libsmpeg.dylib" +else: + const SmpegLibName = "libsmpeg.so" + +const + SMPEG_FILTER_INFO_MB_ERROR* = 1 + SMPEG_FILTER_INFO_PIXEL_ERROR* = 2 # Filter info from SMPEG + +type + SMPEG_FilterInfo*{.final.} = object + yuv_mb_square_error*: PUint16 + yuv_pixel_square_error*: PUint16 + + TSMPEG_FilterInfo* = SMPEG_FilterInfo + PSMPEG_FilterInfo* = ptr SMPEG_FilterInfo # MPEG filter definition + PSMPEG_Filter* = ptr TSMPEG_Filter # Callback functions for the filter + TSMPEG_FilterCallback* = proc (dest, source: PSDL_Overlay, region: PSDL_Rect, + filter_info: PSMPEG_FilterInfo, data: Pointer): Pointer{. + cdecl.} + TSMPEG_FilterDestroy* = proc (Filter: PSMPEG_Filter): Pointer{.cdecl.} # The filter + # definition itself + TSMPEG_Filter*{.final.} = object # The null filter (default). It simply copies the source rectangle to the video overlay. + flags*: Uint32 + data*: Pointer + callback*: TSMPEG_FilterCallback + destroy*: TSMPEG_FilterDestroy + + +proc SMPEGfilter_null*(): PSMPEG_Filter{.cdecl, importc, dynlib: SmpegLibName.} + # The bilinear filter. A basic low-pass filter that will produce a smoother image. +proc SMPEGfilter_bilinear*(): PSMPEG_Filter{.cdecl, importc, dynlib: SmpegLibName.} + # The deblocking filter. It filters block borders and non-intra coded blocks to reduce blockiness +proc SMPEGfilter_deblocking*(): PSMPEG_Filter{.cdecl, importc, dynlib: SmpegLibName.} + #------------------------------------------------------------------------------ + # SMPEG.h + #------------------------------------------------------------------------------ +const + SMPEG_MAJOR_VERSION* = 0'i8 + SMPEG_MINOR_VERSION* = 4'i8 + SMPEG_PATCHLEVEL* = 2'i8 + +type + SMPEG_version*{.final.} = object + major*: UInt8 + minor*: UInt8 + patch*: UInt8 + + TSMPEG_version* = SMPEG_version + PSMPEG_version* = ptr TSMPEG_version # This is the actual SMPEG object + TSMPEG*{.final.} = object + PSMPEG* = ptr TSMPEG # Used to get information about the SMPEG object + TSMPEG_Info*{.final.} = object + has_audio*: int + has_video*: int + width*: int + height*: int + current_frame*: int + current_fps*: float64 + audio_string*: array[0..79, char] + audio_current_frame*: int + current_offset*: UInt32 + total_size*: UInt32 + current_time*: float64 + total_time*: float64 + + PSMPEG_Info* = ptr TSMPEG_Info # Possible MPEG status codes + +const + STATUS_SMPEG_ERROR* = - 1 + STATUS_SMPEG_STOPPED* = 0 + STATUS_SMPEG_PLAYING* = 1 + +type + TSMPEGstatus* = int + PSMPEGstatus* = ptr int # Matches the declaration of SDL_UpdateRect() + TSMPEG_DisplayCallback* = proc (dst: PSDL_Surface, x, y: int, w, h: int): Pointer{. + cdecl.} # Create a new SMPEG object from an MPEG file. + # On return, if 'info' is not NULL, it will be filled with information + # about the MPEG object. + # This function returns a new SMPEG object. Use SMPEG_error() to find out + # whether or not there was a problem building the MPEG stream. + # The sdl_audio parameter indicates if SMPEG should initialize the SDL audio + # subsystem. If not, you will have to use the SMPEG_playaudio() function below + # to extract the decoded data. + +proc SMPEG_new*(theFile: cstring, info: PSMPEG_Info, sdl_audio: int): PSMPEG{. + cdecl, importc, dynlib: SmpegLibName.} + # The same as above for a file descriptor +proc SMPEG_new_descr*(theFile: int, info: PSMPEG_Info, sdl_audio: int): PSMPEG{. + cdecl, importc, dynlib: SmpegLibName.} + # The same as above but for a raw chunk of data. SMPEG makes a copy of the + # data, so the application is free to delete after a successful call to this + # function. +proc SMPEG_new_data*(data: Pointer, size: int, info: PSMPEG_Info, sdl_audio: int): PSMPEG{. + cdecl, importc, dynlib: SmpegLibName.} + # Get current information about an SMPEG object +proc SMPEG_getinfo*(mpeg: PSMPEG, info: PSMPEG_Info){.cdecl, + importc, dynlib: SmpegLibName.} + #procedure SMPEG_getinfo(mpeg: PSMPEG; info: Pointer); + #cdecl; external SmpegLibName; + # Enable or disable audio playback in MPEG stream +proc SMPEG_enableaudio*(mpeg: PSMPEG, enable: int){.cdecl, importc, dynlib: SmpegLibName.} + # Enable or disable video playback in MPEG stream +proc SMPEG_enablevideo*(mpeg: PSMPEG, enable: int){.cdecl, importc, dynlib: SmpegLibName.} + # Delete an SMPEG object +proc SMPEG_delete*(mpeg: PSMPEG){.cdecl, importc, dynlib: SmpegLibName.} + # Get the current status of an SMPEG object +proc SMPEG_status*(mpeg: PSMPEG): TSMPEGstatus{.cdecl, importc, dynlib: SmpegLibName.} + # status + # Set the audio volume of an MPEG stream, in the range 0-100 +proc SMPEG_setvolume*(mpeg: PSMPEG, volume: int){.cdecl, importc, dynlib: SmpegLibName.} + # Set the destination surface for MPEG video playback + # 'surfLock' is a mutex used to synchronize access to 'dst', and can be NULL. + # 'callback' is a function called when an area of 'dst' needs to be updated. + # If 'callback' is NULL, the default function (SDL_UpdateRect) will be used. +proc SMPEG_setdisplay*(mpeg: PSMPEG, dst: PSDL_Surface, surfLock: PSDL_mutex, + callback: TSMPEG_DisplayCallback){.cdecl, + importc, dynlib: SmpegLibName.} + # Set or clear looping play on an SMPEG object +proc SMPEG_loop*(mpeg: PSMPEG, repeat_: int){.cdecl, importc, dynlib: SmpegLibName.} + # Scale pixel display on an SMPEG object +proc SMPEG_scaleXY*(mpeg: PSMPEG, width, height: int){.cdecl, + importc, dynlib: SmpegLibName.} +proc SMPEG_scale*(mpeg: PSMPEG, scale: int){.cdecl, importc, dynlib: SmpegLibName.} +proc SMPEG_Double*(mpeg: PSMPEG, doubleit: bool) + # Move the video display area within the destination surface +proc SMPEG_move*(mpeg: PSMPEG, x, y: int){.cdecl, importc, dynlib: SmpegLibName.} + # Set the region of the video to be shown +proc SMPEG_setdisplayregion*(mpeg: PSMPEG, x, y, w, h: int){.cdecl, + importc, dynlib: SmpegLibName.} + # Play an SMPEG object +proc SMPEG_play*(mpeg: PSMPEG){.cdecl, importc, dynlib: SmpegLibName.} + # Pause/Resume playback of an SMPEG object +proc SMPEG_pause*(mpeg: PSMPEG){.cdecl, importc, dynlib: SmpegLibName.} + # Stop playback of an SMPEG object +proc SMPEG_stop*(mpeg: PSMPEG){.cdecl, importc, dynlib: SmpegLibName.} + # Rewind the play position of an SMPEG object to the beginning of the MPEG +proc SMPEG_rewind*(mpeg: PSMPEG){.cdecl, importc, dynlib: SmpegLibName.} + # Seek 'bytes' bytes in the MPEG stream +proc SMPEG_seek*(mpeg: PSMPEG, bytes: int){.cdecl, importc, dynlib: SmpegLibName.} + # Skip 'seconds' seconds in the MPEG stream +proc SMPEG_skip*(mpeg: PSMPEG, seconds: float32){.cdecl, importc, dynlib: SmpegLibName.} + # Render a particular frame in the MPEG video + # API CHANGE: This function no longer takes a target surface and position. + # Use SMPEG_setdisplay() and SMPEG_move() to set this information. +proc SMPEG_renderFrame*(mpeg: PSMPEG, framenum: int){.cdecl, + importc, dynlib: SmpegLibName.} + # Render the last frame of an MPEG video +proc SMPEG_renderFinal*(mpeg: PSMPEG, dst: PSDL_Surface, x, y: int){.cdecl, + importc, dynlib: SmpegLibName.} + # Set video filter +proc SMPEG_filter*(mpeg: PSMPEG, filter: PSMPEG_Filter): PSMPEG_Filter{.cdecl, + importc, dynlib: SmpegLibName.} + # Return NULL if there is no error in the MPEG stream, or an error message + # if there was a fatal error in the MPEG stream for the SMPEG object. +proc SMPEG_error*(mpeg: PSMPEG): cstring{.cdecl, importc, dynlib: SmpegLibName.} + # Exported callback function for audio playback. + # The function takes a buffer and the amount of data to fill, and returns + # the amount of data in bytes that was actually written. This will be the + # amount requested unless the MPEG audio has finished. + # +proc SMPEG_playAudio*(mpeg: PSMPEG, stream: PUInt8, length: int): int{.cdecl, + importc, dynlib: SmpegLibName.} + # Wrapper for SMPEG_playAudio() that can be passed to SDL and SDL_mixer +proc SMPEG_playAudioSDL*(mpeg: Pointer, stream: PUInt8, length: int){.cdecl, + importc, dynlib: SmpegLibName.} + # Get the best SDL audio spec for the audio stream +proc SMPEG_wantedSpec*(mpeg: PSMPEG, wanted: PSDL_AudioSpec): int{.cdecl, + importc, dynlib: SmpegLibName.} + # Inform SMPEG of the actual SDL audio spec used for sound playback +proc SMPEG_actualSpec*(mpeg: PSMPEG, spec: PSDL_AudioSpec){.cdecl, + importc, dynlib: SmpegLibName.} + # This macro can be used to fill a version structure with the compile-time + # version of the SDL library. +proc SMPEG_GETVERSION*(X: var TSMPEG_version) +# implementation + +proc SMPEG_double(mpeg: PSMPEG, doubleit: bool) = + if doubleit: SMPEG_scale(mpeg, 2) + else: SMPEG_scale(mpeg, 1) + +proc SMPEG_GETVERSION(X: var TSMPEG_version) = + X.major = SMPEG_MAJOR_VERSION + X.minor = SMPEG_MINOR_VERSION + X.patch = SMPEG_PATCHLEVEL diff --git a/lib/base/x11/cursorfont.nim b/lib/base/x11/cursorfont.nim new file mode 100644 index 000000000..b262ad7c1 --- /dev/null +++ b/lib/base/x11/cursorfont.nim @@ -0,0 +1,110 @@ +# $Xorg: cursorfont.h,v 1.4 2001/02/09 02:03:39 xorgcvs Exp $ +# +# +#Copyright 1987, 1998 The Open Group +# +#Permission to use, copy, modify, distribute, and sell this software and its +#documentation for any purpose is hereby granted without fee, provided that +#the above copyright notice appear in all copies and that both that +#copyright notice and this permission notice appear in supporting +#documentation. +# +#The above copyright notice and this permission notice shall be included +#in all copies or substantial portions of the Software. +# +#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +#OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +#MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +#IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR +#OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +#ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +#OTHER DEALINGS IN THE SOFTWARE. +# +#Except as contained in this notice, the name of The Open Group shall +#not be used in advertising or otherwise to promote the sale, use or +#other dealings in this Software without prior written authorization +#from The Open Group. +# +# + +const + XC_num_glyphs* = 154 + XC_X_cursor* = 0 + XC_arrow* = 2 + XC_based_arrow_down* = 4 + XC_based_arrow_up* = 6 + XC_boat* = 8 + XC_bogosity* = 10 + XC_bottom_left_corner* = 12 + XC_bottom_right_corner* = 14 + XC_bottom_side* = 16 + XC_bottom_tee* = 18 + XC_box_spiral* = 20 + XC_center_ptr* = 22 + XC_circle* = 24 + XC_clock* = 26 + XC_coffee_mug* = 28 + XC_cross* = 30 + XC_cross_reverse* = 32 + XC_crosshair* = 34 + XC_diamond_cross* = 36 + XC_dot* = 38 + XC_dotbox* = 40 + XC_double_arrow* = 42 + XC_draft_large* = 44 + XC_draft_small* = 46 + XC_draped_box* = 48 + XC_exchange* = 50 + XC_fleur* = 52 + XC_gobbler* = 54 + XC_gumby* = 56 + XC_hand1* = 58 + XC_hand2* = 60 + XC_heart* = 62 + XC_icon* = 64 + XC_iron_cross* = 66 + XC_left_ptr* = 68 + XC_left_side* = 70 + XC_left_tee* = 72 + XC_leftbutton* = 74 + XC_ll_angle* = 76 + XC_lr_angle* = 78 + XC_man* = 80 + XC_middlebutton* = 82 + XC_mouse* = 84 + XC_pencil* = 86 + XC_pirate* = 88 + XC_plus* = 90 + XC_question_arrow* = 92 + XC_right_ptr* = 94 + XC_right_side* = 96 + XC_right_tee* = 98 + XC_rightbutton* = 100 + XC_rtl_logo* = 102 + XC_sailboat* = 104 + XC_sb_down_arrow* = 106 + XC_sb_h_double_arrow* = 108 + XC_sb_left_arrow* = 110 + XC_sb_right_arrow* = 112 + XC_sb_up_arrow* = 114 + XC_sb_v_double_arrow* = 116 + XC_shuttle* = 118 + XC_sizing* = 120 + XC_spider* = 122 + XC_spraycan* = 124 + XC_star* = 126 + XC_target* = 128 + XC_tcross* = 130 + XC_top_left_arrow* = 132 + XC_top_left_corner* = 134 + XC_top_right_corner* = 136 + XC_top_side* = 138 + XC_top_tee* = 140 + XC_trek* = 142 + XC_ul_angle* = 144 + XC_umbrella* = 146 + XC_ur_angle* = 148 + XC_watch* = 150 + XC_xterm* = 152 + +# implementation diff --git a/lib/base/x11/keysym.nim b/lib/base/x11/keysym.nim new file mode 100644 index 000000000..8958aabcb --- /dev/null +++ b/lib/base/x11/keysym.nim @@ -0,0 +1,1900 @@ +# +#Converted from X11/keysym.h and X11/keysymdef.h +# +#Capital letter consts renamed from XK_... to XKc_... +# (since Pascal isn't case-sensitive) +# +#i.e. +#C Pascal +#XK_a XK_a +#XK_A XKc_A +# + +#* default keysyms * + +const + XK_VoidSymbol* = 0x00FFFFFF # void symbol + +when defined(XK_MISCELLANY): + #* + # * TTY Functions, cleverly chosen to map to ascii, for convenience of + # * programming, but could have been arbitrary (at the cost of lookup + # * tables in client code. + # * + XK_BackSpace == 0x0000FF08 # back space, back char + XK_Tab == 0x0000FF09 + XK_Linefeed == 0x0000FF0A # Linefeed, LF + XK_Clear == 0x0000FF0B + XK_Return == 0x0000FF0D # Return, enter + XK_Pause == 0x0000FF13 # Pause, hold + XK_Scroll_Lock == 0x0000FF14 + XK_Sys_Req == 0x0000FF15 + XK_Escape == 0x0000FF1B + XK_Delete == 0x0000FFFF # Delete, rubout + # International & multi-key character composition + XK_Multi_key == 0x0000FF20 # Multi-key character compose + XK_Codeinput == 0x0000FF37 + XK_SingleCandidate == 0x0000FF3C + XK_MultipleCandidate == 0x0000FF3D + XK_PreviousCandidate == 0x0000FF3E # Japanese keyboard support + XK_Kanji == 0x0000FF21 # Kanji, Kanji convert + XK_Muhenkan == 0x0000FF22 # Cancel Conversion + XK_Henkan_Mode == 0x0000FF23 # Start/Stop Conversion + XK_Henkan == 0x0000FF23 # Alias for Henkan_Mode + XK_Romaji == 0x0000FF24 # to Romaji + XK_Hiragana == 0x0000FF25 # to Hiragana + XK_Katakana == 0x0000FF26 # to Katakana + XK_Hiragana_Katakana == 0x0000FF27 # Hiragana/Katakana toggle + XK_Zenkaku == 0x0000FF28 # to Zenkaku + XK_Hankaku == 0x0000FF29 # to Hankaku + XK_Zenkaku_Hankaku == 0x0000FF2A # Zenkaku/Hankaku toggle + XK_Touroku == 0x0000FF2B # Add to Dictionary + XK_Massyo == 0x0000FF2C # Delete from Dictionary + XK_Kana_Lock == 0x0000FF2D # Kana Lock + XK_Kana_Shift == 0x0000FF2E # Kana Shift + XK_Eisu_Shift == 0x0000FF2F # Alphanumeric Shift + XK_Eisu_toggle == 0x0000FF30 # Alphanumeric toggle + XK_Kanji_Bangou == 0x0000FF37 # Codeinput + XK_Zen_Koho == 0x0000FF3D # Multiple/All Candidate(s) + XK_Mae_Koho == 0x0000FF3E # Previous Candidate + # = $FF31 thru = $FF3F are under XK_KOREAN + # Cursor control & motion + XK_Home == 0x0000FF50 + XK_Left == 0x0000FF51 # Move left, left arrow + XK_Up == 0x0000FF52 # Move up, up arrow + XK_Right == 0x0000FF53 # Move right, right arrow + XK_Down == 0x0000FF54 # Move down, down arrow + XK_Prior == 0x0000FF55 # Prior, previous + XK_Page_Up == 0x0000FF55 + XK_Next == 0x0000FF56 # Next + XK_Page_Down == 0x0000FF56 + XK_End == 0x0000FF57 # EOL + XK_Begin == 0x0000FF58 # BOL + # Misc Functions + XK_Select == 0x0000FF60 # Select, mark + XK_Print == 0x0000FF61 + XK_Execute == 0x0000FF62 # Execute, run, do + XK_Insert == 0x0000FF63 # Insert, insert here + XK_Undo == 0x0000FF65 # Undo, oops + XK_Redo == 0x0000FF66 # redo, again + XK_Menu == 0x0000FF67 + XK_Find == 0x0000FF68 # Find, search + XK_Cancel == 0x0000FF69 # Cancel, stop, abort, exit + XK_Help == 0x0000FF6A # Help + XK_Break == 0x0000FF6B + XK_Mode_switch == 0x0000FF7E # Character set switch + XK_script_switch == 0x0000FF7E # Alias for mode_switch + XK_Num_Lock == 0x0000FF7F # Keypad Functions, keypad numbers cleverly chosen to map to ascii + XK_KP_Space == 0x0000FF80 # space + XK_KP_Tab == 0x0000FF89 + XK_KP_Enter == 0x0000FF8D # enter + XK_KP_F1 == 0x0000FF91 # PF1, KP_A, ... + XK_KP_F2 == 0x0000FF92 + XK_KP_F3 == 0x0000FF93 + XK_KP_F4 == 0x0000FF94 + XK_KP_Home == 0x0000FF95 + XK_KP_Left == 0x0000FF96 + XK_KP_Up == 0x0000FF97 + XK_KP_Right == 0x0000FF98 + XK_KP_Down == 0x0000FF99 + XK_KP_Prior == 0x0000FF9A + XK_KP_Page_Up == 0x0000FF9A + XK_KP_Next == 0x0000FF9B + XK_KP_Page_Down == 0x0000FF9B + XK_KP_End == 0x0000FF9C + XK_KP_Begin == 0x0000FF9D + XK_KP_Insert == 0x0000FF9E + XK_KP_Delete == 0x0000FF9F + XK_KP_Equal == 0x0000FFBD # equals + XK_KP_Multiply == 0x0000FFAA + XK_KP_Add == 0x0000FFAB + XK_KP_Separator == 0x0000FFAC # separator, often comma + XK_KP_Subtract == 0x0000FFAD + XK_KP_Decimal == 0x0000FFAE + XK_KP_Divide == 0x0000FFAF + XK_KP_0 == 0x0000FFB0 + XK_KP_1 == 0x0000FFB1 + XK_KP_2 == 0x0000FFB2 + XK_KP_3 == 0x0000FFB3 + XK_KP_4 == 0x0000FFB4 + XK_KP_5 == 0x0000FFB5 + XK_KP_6 == 0x0000FFB6 + XK_KP_7 == 0x0000FFB7 + XK_KP_8 == 0x0000FFB8 + XK_KP_9 == 0x0000FFB9 #* + # * Auxilliary Functions; note the duplicate definitions for left and right + # * function keys; Sun keyboards and a few other manufactures have such + # * function key groups on the left and/or right sides of the keyboard. + # * We've not found a keyboard with more than 35 function keys total. + # * + XK_F1 == 0x0000FFBE + XK_F2 == 0x0000FFBF + XK_F3 == 0x0000FFC0 + XK_F4 == 0x0000FFC1 + XK_F5 == 0x0000FFC2 + XK_F6 == 0x0000FFC3 + XK_F7 == 0x0000FFC4 + XK_F8 == 0x0000FFC5 + XK_F9 == 0x0000FFC6 + XK_F10 == 0x0000FFC7 + XK_F11 == 0x0000FFC8 + XK_L1 == 0x0000FFC8 + XK_F12 == 0x0000FFC9 + XK_L2 == 0x0000FFC9 + XK_F13 == 0x0000FFCA + XK_L3 == 0x0000FFCA + XK_F14 == 0x0000FFCB + XK_L4 == 0x0000FFCB + XK_F15 == 0x0000FFCC + XK_L5 == 0x0000FFCC + XK_F16 == 0x0000FFCD + XK_L6 == 0x0000FFCD + XK_F17 == 0x0000FFCE + XK_L7 == 0x0000FFCE + XK_F18 == 0x0000FFCF + XK_L8 == 0x0000FFCF + XK_F19 == 0x0000FFD0 + XK_L9 == 0x0000FFD0 + XK_F20 == 0x0000FFD1 + XK_L10 == 0x0000FFD1 + XK_F21 == 0x0000FFD2 + XK_R1 == 0x0000FFD2 + XK_F22 == 0x0000FFD3 + XK_R2 == 0x0000FFD3 + XK_F23 == 0x0000FFD4 + XK_R3 == 0x0000FFD4 + XK_F24 == 0x0000FFD5 + XK_R4 == 0x0000FFD5 + XK_F25 == 0x0000FFD6 + XK_R5 == 0x0000FFD6 + XK_F26 == 0x0000FFD7 + XK_R6 == 0x0000FFD7 + XK_F27 == 0x0000FFD8 + XK_R7 == 0x0000FFD8 + XK_F28 == 0x0000FFD9 + XK_R8 == 0x0000FFD9 + XK_F29 == 0x0000FFDA + XK_R9 == 0x0000FFDA + XK_F30 == 0x0000FFDB + XK_R10 == 0x0000FFDB + XK_F31 == 0x0000FFDC + XK_R11 == 0x0000FFDC + XK_F32 == 0x0000FFDD + XK_R12 == 0x0000FFDD + XK_F33 == 0x0000FFDE + XK_R13 == 0x0000FFDE + XK_F34 == 0x0000FFDF + XK_R14 == 0x0000FFDF + XK_F35 == 0x0000FFE0 + XK_R15 == 0x0000FFE0 # Modifiers + XK_Shift_L == 0x0000FFE1 # Left shift + XK_Shift_R == 0x0000FFE2 # Right shift + XK_Control_L == 0x0000FFE3 # Left control + XK_Control_R == 0x0000FFE4 # Right control + XK_Caps_Lock == 0x0000FFE5 # Caps lock + XK_Shift_Lock == 0x0000FFE6 # Shift lock + XK_Meta_L == 0x0000FFE7 # Left meta + XK_Meta_R == 0x0000FFE8 # Right meta + XK_Alt_L == 0x0000FFE9 # Left alt + XK_Alt_R == 0x0000FFEA # Right alt + XK_Super_L == 0x0000FFEB # Left super + XK_Super_R == 0x0000FFEC # Right super + XK_Hyper_L == 0x0000FFED # Left hyper + XK_Hyper_R == 0x0000FFEE # Right hyper +# XK_MISCELLANY +#* +# * ISO 9995 Function and Modifier Keys +# * Byte 3 = = $FE +# * + +when defined(XK_XKB_KEYS): + XK_ISO_Lock == 0x0000FE01 + XK_ISO_Level2_Latch == 0x0000FE02 + XK_ISO_Level3_Shift == 0x0000FE03 + XK_ISO_Level3_Latch == 0x0000FE04 + XK_ISO_Level3_Lock == 0x0000FE05 + XK_ISO_Group_Shift == 0x0000FF7E # Alias for mode_switch + XK_ISO_Group_Latch == 0x0000FE06 + XK_ISO_Group_Lock == 0x0000FE07 + XK_ISO_Next_Group == 0x0000FE08 + XK_ISO_Next_Group_Lock == 0x0000FE09 + XK_ISO_Prev_Group == 0x0000FE0A + XK_ISO_Prev_Group_Lock == 0x0000FE0B + XK_ISO_First_Group == 0x0000FE0C + XK_ISO_First_Group_Lock == 0x0000FE0D + XK_ISO_Last_Group == 0x0000FE0E + XK_ISO_Last_Group_Lock == 0x0000FE0F + XK_ISO_Left_Tab == 0x0000FE20 + XK_ISO_Move_Line_Up == 0x0000FE21 + XK_ISO_Move_Line_Down == 0x0000FE22 + XK_ISO_Partial_Line_Up == 0x0000FE23 + XK_ISO_Partial_Line_Down == 0x0000FE24 + XK_ISO_Partial_Space_Left == 0x0000FE25 + XK_ISO_Partial_Space_Right == 0x0000FE26 + XK_ISO_Set_Margin_Left == 0x0000FE27 + XK_ISO_Set_Margin_Right == 0x0000FE28 + XK_ISO_Release_Margin_Left == 0x0000FE29 + XK_ISO_Release_Margin_Right == 0x0000FE2A + XK_ISO_Release_Both_Margins == 0x0000FE2B + XK_ISO_Fast_Cursor_Left == 0x0000FE2C + XK_ISO_Fast_Cursor_Right == 0x0000FE2D + XK_ISO_Fast_Cursor_Up == 0x0000FE2E + XK_ISO_Fast_Cursor_Down == 0x0000FE2F + XK_ISO_Continuous_Underline == 0x0000FE30 + XK_ISO_Discontinuous_Underline == 0x0000FE31 + XK_ISO_Emphasize == 0x0000FE32 + XK_ISO_Center_Object == 0x0000FE33 + XK_ISO_Enter == 0x0000FE34 + XK_dead_grave == 0x0000FE50 + XK_dead_acute == 0x0000FE51 + XK_dead_circumflex == 0x0000FE52 + XK_dead_tilde == 0x0000FE53 + XK_dead_macron == 0x0000FE54 + XK_dead_breve == 0x0000FE55 + XK_dead_abovedot == 0x0000FE56 + XK_dead_diaeresis == 0x0000FE57 + XK_dead_abovering == 0x0000FE58 + XK_dead_doubleacute == 0x0000FE59 + XK_dead_caron == 0x0000FE5A + XK_dead_cedilla == 0x0000FE5B + XK_dead_ogonek == 0x0000FE5C + XK_dead_iota == 0x0000FE5D + XK_dead_voiced_sound == 0x0000FE5E + XK_dead_semivoiced_sound == 0x0000FE5F + XK_dead_belowdot == 0x0000FE60 + XK_dead_hook == 0x0000FE61 + XK_dead_horn == 0x0000FE62 + XK_First_Virtual_Screen == 0x0000FED0 + XK_Prev_Virtual_Screen == 0x0000FED1 + XK_Next_Virtual_Screen == 0x0000FED2 + XK_Last_Virtual_Screen == 0x0000FED4 + XK_Terminate_Server == 0x0000FED5 + XK_AccessX_Enable == 0x0000FE70 + XK_AccessX_Feedback_Enable == 0x0000FE71 + XK_RepeatKeys_Enable == 0x0000FE72 + XK_SlowKeys_Enable == 0x0000FE73 + XK_BounceKeys_Enable == 0x0000FE74 + XK_StickyKeys_Enable == 0x0000FE75 + XK_MouseKeys_Enable == 0x0000FE76 + XK_MouseKeys_Accel_Enable == 0x0000FE77 + XK_Overlay1_Enable == 0x0000FE78 + XK_Overlay2_Enable == 0x0000FE79 + XK_AudibleBell_Enable == 0x0000FE7A + XK_Pointer_Left == 0x0000FEE0 + XK_Pointer_Right == 0x0000FEE1 + XK_Pointer_Up == 0x0000FEE2 + XK_Pointer_Down == 0x0000FEE3 + XK_Pointer_UpLeft == 0x0000FEE4 + XK_Pointer_UpRight == 0x0000FEE5 + XK_Pointer_DownLeft == 0x0000FEE6 + XK_Pointer_DownRight == 0x0000FEE7 + XK_Pointer_Button_Dflt == 0x0000FEE8 + XK_Pointer_Button1 == 0x0000FEE9 + XK_Pointer_Button2 == 0x0000FEEA + XK_Pointer_Button3 == 0x0000FEEB + XK_Pointer_Button4 == 0x0000FEEC + XK_Pointer_Button5 == 0x0000FEED + XK_Pointer_DblClick_Dflt == 0x0000FEEE + XK_Pointer_DblClick1 == 0x0000FEEF + XK_Pointer_DblClick2 == 0x0000FEF0 + XK_Pointer_DblClick3 == 0x0000FEF1 + XK_Pointer_DblClick4 == 0x0000FEF2 + XK_Pointer_DblClick5 == 0x0000FEF3 + XK_Pointer_Drag_Dflt == 0x0000FEF4 + XK_Pointer_Drag1 == 0x0000FEF5 + XK_Pointer_Drag2 == 0x0000FEF6 + XK_Pointer_Drag3 == 0x0000FEF7 + XK_Pointer_Drag4 == 0x0000FEF8 + XK_Pointer_Drag5 == 0x0000FEFD + XK_Pointer_EnableKeys == 0x0000FEF9 + XK_Pointer_Accelerate == 0x0000FEFA + XK_Pointer_DfltBtnNext == 0x0000FEFB + XK_Pointer_DfltBtnPrev == 0x0000FEFC +#* +# * 3270 Terminal Keys +# * Byte 3 = = $FD +# * + +when defined(XK_3270): + XK_3270_Duplicate == 0x0000FD01 + XK_3270_FieldMark == 0x0000FD02 + XK_3270_Right2 == 0x0000FD03 + XK_3270_Left2 == 0x0000FD04 + XK_3270_BackTab == 0x0000FD05 + XK_3270_EraseEOF == 0x0000FD06 + XK_3270_EraseInput == 0x0000FD07 + XK_3270_Reset == 0x0000FD08 + XK_3270_Quit == 0x0000FD09 + XK_3270_PA1 == 0x0000FD0A + XK_3270_PA2 == 0x0000FD0B + XK_3270_PA3 == 0x0000FD0C + XK_3270_Test == 0x0000FD0D + XK_3270_Attn == 0x0000FD0E + XK_3270_CursorBlink == 0x0000FD0F + XK_3270_AltCursor == 0x0000FD10 + XK_3270_KeyClick == 0x0000FD11 + XK_3270_Jump == 0x0000FD12 + XK_3270_Ident == 0x0000FD13 + XK_3270_Rule == 0x0000FD14 + XK_3270_Copy == 0x0000FD15 + XK_3270_Play == 0x0000FD16 + XK_3270_Setup == 0x0000FD17 + XK_3270_Record == 0x0000FD18 + XK_3270_ChangeScreen == 0x0000FD19 + XK_3270_DeleteWord == 0x0000FD1A + XK_3270_ExSelect == 0x0000FD1B + XK_3270_CursorSelect == 0x0000FD1C + XK_3270_PrintScreen == 0x0000FD1D + XK_3270_Enter == 0x0000FD1E +#* +# * Latin 1 +# * Byte 3 = 0 +# * + +when defined(XK_LATIN1): + XK_space == 0x00000020 + XK_exclam == 0x00000021 + XK_quotedbl == 0x00000022 + XK_numbersign == 0x00000023 + XK_dollar == 0x00000024 + XK_percent == 0x00000025 + XK_ampersand == 0x00000026 + XK_apostrophe == 0x00000027 + XK_quoteright == 0x00000027 # deprecated + XK_parenleft == 0x00000028 + XK_parenright == 0x00000029 + XK_asterisk == 0x0000002A + XK_plus == 0x0000002B + XK_comma == 0x0000002C + XK_minus == 0x0000002D + XK_period == 0x0000002E + XK_slash == 0x0000002F + XK_0 == 0x00000030 + XK_1 == 0x00000031 + XK_2 == 0x00000032 + XK_3 == 0x00000033 + XK_4 == 0x00000034 + XK_5 == 0x00000035 + XK_6 == 0x00000036 + XK_7 == 0x00000037 + XK_8 == 0x00000038 + XK_9 == 0x00000039 + XK_colon == 0x0000003A + XK_semicolon == 0x0000003B + XK_less == 0x0000003C + XK_equal == 0x0000003D + XK_greater == 0x0000003E + XK_question == 0x0000003F + XK_at == 0x00000040 + XKc_A == 0x00000041 + XKc_B == 0x00000042 + XKc_C == 0x00000043 + XKc_D == 0x00000044 + XKc_E == 0x00000045 + XKc_F == 0x00000046 + XKc_G == 0x00000047 + XKc_H == 0x00000048 + XKc_I == 0x00000049 + XKc_J == 0x0000004A + XKc_K == 0x0000004B + XKc_L == 0x0000004C + XKc_M == 0x0000004D + XKc_N == 0x0000004E + XKc_O == 0x0000004F + XKc_P == 0x00000050 + XKc_Q == 0x00000051 + XKc_R == 0x00000052 + XKc_S == 0x00000053 + XKc_T == 0x00000054 + XKc_U == 0x00000055 + XKc_V == 0x00000056 + XKc_W == 0x00000057 + XKc_X == 0x00000058 + XKc_Y == 0x00000059 + XKc_Z == 0x0000005A + XK_bracketleft == 0x0000005B + XK_backslash == 0x0000005C + XK_bracketright == 0x0000005D + XK_asciicircum == 0x0000005E + XK_underscore == 0x0000005F + XK_grave == 0x00000060 + XK_quoteleft == 0x00000060 # deprecated + XK_a == 0x00000061 + XK_b == 0x00000062 + XK_c == 0x00000063 + XK_d == 0x00000064 + XK_e == 0x00000065 + XK_f == 0x00000066 + XK_g == 0x00000067 + XK_h == 0x00000068 + XK_i == 0x00000069 + XK_j == 0x0000006A + XK_k == 0x0000006B + XK_l == 0x0000006C + XK_m == 0x0000006D + XK_n == 0x0000006E + XK_o == 0x0000006F + XK_p == 0x00000070 + XK_q == 0x00000071 + XK_r == 0x00000072 + XK_s == 0x00000073 + XK_t == 0x00000074 + XK_u == 0x00000075 + XK_v == 0x00000076 + XK_w == 0x00000077 + XK_x == 0x00000078 + XK_y == 0x00000079 + XK_z == 0x0000007A + XK_braceleft == 0x0000007B + XK_bar == 0x0000007C + XK_braceright == 0x0000007D + XK_asciitilde == 0x0000007E + XK_nobreakspace == 0x000000A0 + XK_exclamdown == 0x000000A1 + XK_cent == 0x000000A2 + XK_sterling == 0x000000A3 + XK_currency == 0x000000A4 + XK_yen == 0x000000A5 + XK_brokenbar == 0x000000A6 + XK_section == 0x000000A7 + XK_diaeresis == 0x000000A8 + XK_copyright == 0x000000A9 + XK_ordfeminine == 0x000000AA + XK_guillemotleft == 0x000000AB # left angle quotation mark + XK_notsign == 0x000000AC + XK_hyphen == 0x000000AD + XK_registered == 0x000000AE + XK_macron == 0x000000AF + XK_degree == 0x000000B0 + XK_plusminus == 0x000000B1 + XK_twosuperior == 0x000000B2 + XK_threesuperior == 0x000000B3 + XK_acute == 0x000000B4 + XK_mu == 0x000000B5 + XK_paragraph == 0x000000B6 + XK_periodcentered == 0x000000B7 + XK_cedilla == 0x000000B8 + XK_onesuperior == 0x000000B9 + XK_masculine == 0x000000BA + XK_guillemotright == 0x000000BB # right angle quotation mark + XK_onequarter == 0x000000BC + XK_onehalf == 0x000000BD + XK_threequarters == 0x000000BE + XK_questiondown == 0x000000BF + XKc_Agrave == 0x000000C0 + XKc_Aacute == 0x000000C1 + XKc_Acircumflex == 0x000000C2 + XKc_Atilde == 0x000000C3 + XKc_Adiaeresis == 0x000000C4 + XKc_Aring == 0x000000C5 + XKc_AE == 0x000000C6 + XKc_Ccedilla == 0x000000C7 + XKc_Egrave == 0x000000C8 + XKc_Eacute == 0x000000C9 + XKc_Ecircumflex == 0x000000CA + XKc_Ediaeresis == 0x000000CB + XKc_Igrave == 0x000000CC + XKc_Iacute == 0x000000CD + XKc_Icircumflex == 0x000000CE + XKc_Idiaeresis == 0x000000CF + XKc_ETH == 0x000000D0 + XKc_Ntilde == 0x000000D1 + XKc_Ograve == 0x000000D2 + XKc_Oacute == 0x000000D3 + XKc_Ocircumflex == 0x000000D4 + XKc_Otilde == 0x000000D5 + XKc_Odiaeresis == 0x000000D6 + XK_multiply == 0x000000D7 + XKc_Ooblique == 0x000000D8 + XKc_Oslash == XKc_Ooblique + XKc_Ugrave == 0x000000D9 + XKc_Uacute == 0x000000DA + XKc_Ucircumflex == 0x000000DB + XKc_Udiaeresis == 0x000000DC + XKc_Yacute == 0x000000DD + XKc_THORN == 0x000000DE + XK_ssharp == 0x000000DF + XK_agrave == 0x000000E0 + XK_aacute == 0x000000E1 + XK_acircumflex == 0x000000E2 + XK_atilde == 0x000000E3 + XK_adiaeresis == 0x000000E4 + XK_aring == 0x000000E5 + XK_ae == 0x000000E6 + XK_ccedilla == 0x000000E7 + XK_egrave == 0x000000E8 + XK_eacute == 0x000000E9 + XK_ecircumflex == 0x000000EA + XK_ediaeresis == 0x000000EB + XK_igrave == 0x000000EC + XK_iacute == 0x000000ED + XK_icircumflex == 0x000000EE + XK_idiaeresis == 0x000000EF + XK_eth == 0x000000F0 + XK_ntilde == 0x000000F1 + XK_ograve == 0x000000F2 + XK_oacute == 0x000000F3 + XK_ocircumflex == 0x000000F4 + XK_otilde == 0x000000F5 + XK_odiaeresis == 0x000000F6 + XK_division == 0x000000F7 + XK_oslash == 0x000000F8 + XK_ooblique == XK_oslash + XK_ugrave == 0x000000F9 + XK_uacute == 0x000000FA + XK_ucircumflex == 0x000000FB + XK_udiaeresis == 0x000000FC + XK_yacute == 0x000000FD + XK_thorn == 0x000000FE + XK_ydiaeresis == 0x000000FF +# XK_LATIN1 +#* +# * Latin 2 +# * Byte 3 = 1 +# * + +when defined(XK_LATIN2): + XKc_Aogonek == 0x000001A1 + XK_breve == 0x000001A2 + XKc_Lstroke == 0x000001A3 + XKc_Lcaron == 0x000001A5 + XKc_Sacute == 0x000001A6 + XKc_Scaron == 0x000001A9 + XKc_Scedilla == 0x000001AA + XKc_Tcaron == 0x000001AB + XKc_Zacute == 0x000001AC + XKc_Zcaron == 0x000001AE + XKc_Zabovedot == 0x000001AF + XK_aogonek == 0x000001B1 + XK_ogonek == 0x000001B2 + XK_lstroke == 0x000001B3 + XK_lcaron == 0x000001B5 + XK_sacute == 0x000001B6 + XK_caron == 0x000001B7 + XK_scaron == 0x000001B9 + XK_scedilla == 0x000001BA + XK_tcaron == 0x000001BB + XK_zacute == 0x000001BC + XK_doubleacute == 0x000001BD + XK_zcaron == 0x000001BE + XK_zabovedot == 0x000001BF + XKc_Racute == 0x000001C0 + XKc_Abreve == 0x000001C3 + XKc_Lacute == 0x000001C5 + XKc_Cacute == 0x000001C6 + XKc_Ccaron == 0x000001C8 + XKc_Eogonek == 0x000001CA + XKc_Ecaron == 0x000001CC + XKc_Dcaron == 0x000001CF + XKc_Dstroke == 0x000001D0 + XKc_Nacute == 0x000001D1 + XKc_Ncaron == 0x000001D2 + XKc_Odoubleacute == 0x000001D5 + XKc_Rcaron == 0x000001D8 + XKc_Uring == 0x000001D9 + XKc_Udoubleacute == 0x000001DB + XKc_Tcedilla == 0x000001DE + XK_racute == 0x000001E0 + XK_abreve == 0x000001E3 + XK_lacute == 0x000001E5 + XK_cacute == 0x000001E6 + XK_ccaron == 0x000001E8 + XK_eogonek == 0x000001EA + XK_ecaron == 0x000001EC + XK_dcaron == 0x000001EF + XK_dstroke == 0x000001F0 + XK_nacute == 0x000001F1 + XK_ncaron == 0x000001F2 + XK_odoubleacute == 0x000001F5 + XK_udoubleacute == 0x000001FB + XK_rcaron == 0x000001F8 + XK_uring == 0x000001F9 + XK_tcedilla == 0x000001FE + XK_abovedot == 0x000001FF +# XK_LATIN2 +#* +# * Latin 3 +# * Byte 3 = 2 +# * + +when defined(XK_LATIN3): + XKc_Hstroke == 0x000002A1 + XKc_Hcircumflex == 0x000002A6 + XKc_Iabovedot == 0x000002A9 + XKc_Gbreve == 0x000002AB + XKc_Jcircumflex == 0x000002AC + XK_hstroke == 0x000002B1 + XK_hcircumflex == 0x000002B6 + XK_idotless == 0x000002B9 + XK_gbreve == 0x000002BB + XK_jcircumflex == 0x000002BC + XKc_Cabovedot == 0x000002C5 + XKc_Ccircumflex == 0x000002C6 + XKc_Gabovedot == 0x000002D5 + XKc_Gcircumflex == 0x000002D8 + XKc_Ubreve == 0x000002DD + XKc_Scircumflex == 0x000002DE + XK_cabovedot == 0x000002E5 + XK_ccircumflex == 0x000002E6 + XK_gabovedot == 0x000002F5 + XK_gcircumflex == 0x000002F8 + XK_ubreve == 0x000002FD + XK_scircumflex == 0x000002FE +# XK_LATIN3 +#* +# * Latin 4 +# * Byte 3 = 3 +# * + +when defined(XK_LATIN4): + XK_kra == 0x000003A2 + XK_kappa == 0x000003A2 # deprecated + XKc_Rcedilla == 0x000003A3 + XKc_Itilde == 0x000003A5 + XKc_Lcedilla == 0x000003A6 + XKc_Emacron == 0x000003AA + XKc_Gcedilla == 0x000003AB + XKc_Tslash == 0x000003AC + XK_rcedilla == 0x000003B3 + XK_itilde == 0x000003B5 + XK_lcedilla == 0x000003B6 + XK_emacron == 0x000003BA + XK_gcedilla == 0x000003BB + XK_tslash == 0x000003BC + XKc_ENG == 0x000003BD + XK_eng == 0x000003BF + XKc_Amacron == 0x000003C0 + XKc_Iogonek == 0x000003C7 + XKc_Eabovedot == 0x000003CC + XKc_Imacron == 0x000003CF + XKc_Ncedilla == 0x000003D1 + XKc_Omacron == 0x000003D2 + XKc_Kcedilla == 0x000003D3 + XKc_Uogonek == 0x000003D9 + XKc_Utilde == 0x000003DD + XKc_Umacron == 0x000003DE + XK_amacron == 0x000003E0 + XK_iogonek == 0x000003E7 + XK_eabovedot == 0x000003EC + XK_imacron == 0x000003EF + XK_ncedilla == 0x000003F1 + XK_omacron == 0x000003F2 + XK_kcedilla == 0x000003F3 + XK_uogonek == 0x000003F9 + XK_utilde == 0x000003FD + XK_umacron == 0x000003FE +# XK_LATIN4 +#* +# * Latin-8 +# * Byte 3 = 18 +# * + +when defined(XK_LATIN8): + XKc_Babovedot == 0x000012A1 + XK_babovedot == 0x000012A2 + XKc_Dabovedot == 0x000012A6 + XKc_Wgrave == 0x000012A8 + XKc_Wacute == 0x000012AA + XK_dabovedot == 0x000012AB + XKc_Ygrave == 0x000012AC + XKc_Fabovedot == 0x000012B0 + XK_fabovedot == 0x000012B1 + XKc_Mabovedot == 0x000012B4 + XK_mabovedot == 0x000012B5 + XKc_Pabovedot == 0x000012B7 + XK_wgrave == 0x000012B8 + XK_pabovedot == 0x000012B9 + XK_wacute == 0x000012BA + XKc_Sabovedot == 0x000012BB + XK_ygrave == 0x000012BC + XKc_Wdiaeresis == 0x000012BD + XK_wdiaeresis == 0x000012BE + XK_sabovedot == 0x000012BF + XKc_Wcircumflex == 0x000012D0 + XKc_Tabovedot == 0x000012D7 + XKc_Ycircumflex == 0x000012DE + XK_wcircumflex == 0x000012F0 + XK_tabovedot == 0x000012F7 + XK_ycircumflex == 0x000012FE +# XK_LATIN8 +#* +# * Latin-9 (a.k.a. Latin-0) +# * Byte 3 = 19 +# * + +when defined(XK_LATIN9): + XKc_OE == 0x000013BC + XK_oe == 0x000013BD + XKc_Ydiaeresis == 0x000013BE +# XK_LATIN9 +#* +# * Katakana +# * Byte 3 = 4 +# * + +when defined(XK_KATAKANA): + XK_overline == 0x0000047E + XK_kana_fullstop == 0x000004A1 + XK_kana_openingbracket == 0x000004A2 + XK_kana_closingbracket == 0x000004A3 + XK_kana_comma == 0x000004A4 + XK_kana_conjunctive == 0x000004A5 + XK_kana_middledot == 0x000004A5 # deprecated + XKc_kana_WO == 0x000004A6 + XK_kana_a == 0x000004A7 + XK_kana_i == 0x000004A8 + XK_kana_u == 0x000004A9 + XK_kana_e == 0x000004AA + XK_kana_o == 0x000004AB + XK_kana_ya == 0x000004AC + XK_kana_yu == 0x000004AD + XK_kana_yo == 0x000004AE + XK_kana_tsu == 0x000004AF + XK_kana_tu == 0x000004AF # deprecated + XK_prolongedsound == 0x000004B0 + XKc_kana_A == 0x000004B1 + XKc_kana_I == 0x000004B2 + XKc_kana_U == 0x000004B3 + XKc_kana_E == 0x000004B4 + XKc_kana_O == 0x000004B5 + XKc_kana_KA == 0x000004B6 + XKc_kana_KI == 0x000004B7 + XKc_kana_KU == 0x000004B8 + XKc_kana_KE == 0x000004B9 + XKc_kana_KO == 0x000004BA + XKc_kana_SA == 0x000004BB + XKc_kana_SHI == 0x000004BC + XKc_kana_SU == 0x000004BD + XKc_kana_SE == 0x000004BE + XKc_kana_SO == 0x000004BF + XKc_kana_TA == 0x000004C0 + XKc_kana_CHI == 0x000004C1 + XKc_kana_TI == 0x000004C1 # deprecated + XKc_kana_TSU == 0x000004C2 + XKc_kana_TU == 0x000004C2 # deprecated + XKc_kana_TE == 0x000004C3 + XKc_kana_TO == 0x000004C4 + XKc_kana_NA == 0x000004C5 + XKc_kana_NI == 0x000004C6 + XKc_kana_NU == 0x000004C7 + XKc_kana_NE == 0x000004C8 + XKc_kana_NO == 0x000004C9 + XKc_kana_HA == 0x000004CA + XKc_kana_HI == 0x000004CB + XKc_kana_FU == 0x000004CC + XKc_kana_HU == 0x000004CC # deprecated + XKc_kana_HE == 0x000004CD + XKc_kana_HO == 0x000004CE + XKc_kana_MA == 0x000004CF + XKc_kana_MI == 0x000004D0 + XKc_kana_MU == 0x000004D1 + XKc_kana_ME == 0x000004D2 + XKc_kana_MO == 0x000004D3 + XKc_kana_YA == 0x000004D4 + XKc_kana_YU == 0x000004D5 + XKc_kana_YO == 0x000004D6 + XKc_kana_RA == 0x000004D7 + XKc_kana_RI == 0x000004D8 + XKc_kana_RU == 0x000004D9 + XKc_kana_RE == 0x000004DA + XKc_kana_RO == 0x000004DB + XKc_kana_WA == 0x000004DC + XKc_kana_N == 0x000004DD + XK_voicedsound == 0x000004DE + XK_semivoicedsound == 0x000004DF + XK_kana_switch == 0x0000FF7E # Alias for mode_switch +# XK_KATAKANA +#* +# * Arabic +# * Byte 3 = 5 +# * + +when defined(XK_ARABIC): + XK_Farsi_0 == 0x00000590 + XK_Farsi_1 == 0x00000591 + XK_Farsi_2 == 0x00000592 + XK_Farsi_3 == 0x00000593 + XK_Farsi_4 == 0x00000594 + XK_Farsi_5 == 0x00000595 + XK_Farsi_6 == 0x00000596 + XK_Farsi_7 == 0x00000597 + XK_Farsi_8 == 0x00000598 + XK_Farsi_9 == 0x00000599 + XK_Arabic_percent == 0x000005A5 + XK_Arabic_superscript_alef == 0x000005A6 + XK_Arabic_tteh == 0x000005A7 + XK_Arabic_peh == 0x000005A8 + XK_Arabic_tcheh == 0x000005A9 + XK_Arabic_ddal == 0x000005AA + XK_Arabic_rreh == 0x000005AB + XK_Arabic_comma == 0x000005AC + XK_Arabic_fullstop == 0x000005AE + XK_Arabic_0 == 0x000005B0 + XK_Arabic_1 == 0x000005B1 + XK_Arabic_2 == 0x000005B2 + XK_Arabic_3 == 0x000005B3 + XK_Arabic_4 == 0x000005B4 + XK_Arabic_5 == 0x000005B5 + XK_Arabic_6 == 0x000005B6 + XK_Arabic_7 == 0x000005B7 + XK_Arabic_8 == 0x000005B8 + XK_Arabic_9 == 0x000005B9 + XK_Arabic_semicolon == 0x000005BB + XK_Arabic_question_mark == 0x000005BF + XK_Arabic_hamza == 0x000005C1 + XK_Arabic_maddaonalef == 0x000005C2 + XK_Arabic_hamzaonalef == 0x000005C3 + XK_Arabic_hamzaonwaw == 0x000005C4 + XK_Arabic_hamzaunderalef == 0x000005C5 + XK_Arabic_hamzaonyeh == 0x000005C6 + XK_Arabic_alef == 0x000005C7 + XK_Arabic_beh == 0x000005C8 + XK_Arabic_tehmarbuta == 0x000005C9 + XK_Arabic_teh == 0x000005CA + XK_Arabic_theh == 0x000005CB + XK_Arabic_jeem == 0x000005CC + XK_Arabic_hah == 0x000005CD + XK_Arabic_khah == 0x000005CE + XK_Arabic_dal == 0x000005CF + XK_Arabic_thal == 0x000005D0 + XK_Arabic_ra == 0x000005D1 + XK_Arabic_zain == 0x000005D2 + XK_Arabic_seen == 0x000005D3 + XK_Arabic_sheen == 0x000005D4 + XK_Arabic_sad == 0x000005D5 + XK_Arabic_dad == 0x000005D6 + XK_Arabic_tah == 0x000005D7 + XK_Arabic_zah == 0x000005D8 + XK_Arabic_ain == 0x000005D9 + XK_Arabic_ghain == 0x000005DA + XK_Arabic_tatweel == 0x000005E0 + XK_Arabic_feh == 0x000005E1 + XK_Arabic_qaf == 0x000005E2 + XK_Arabic_kaf == 0x000005E3 + XK_Arabic_lam == 0x000005E4 + XK_Arabic_meem == 0x000005E5 + XK_Arabic_noon == 0x000005E6 + XK_Arabic_ha == 0x000005E7 + XK_Arabic_heh == 0x000005E7 # deprecated + XK_Arabic_waw == 0x000005E8 + XK_Arabic_alefmaksura == 0x000005E9 + XK_Arabic_yeh == 0x000005EA + XK_Arabic_fathatan == 0x000005EB + XK_Arabic_dammatan == 0x000005EC + XK_Arabic_kasratan == 0x000005ED + XK_Arabic_fatha == 0x000005EE + XK_Arabic_damma == 0x000005EF + XK_Arabic_kasra == 0x000005F0 + XK_Arabic_shadda == 0x000005F1 + XK_Arabic_sukun == 0x000005F2 + XK_Arabic_madda_above == 0x000005F3 + XK_Arabic_hamza_above == 0x000005F4 + XK_Arabic_hamza_below == 0x000005F5 + XK_Arabic_jeh == 0x000005F6 + XK_Arabic_veh == 0x000005F7 + XK_Arabic_keheh == 0x000005F8 + XK_Arabic_gaf == 0x000005F9 + XK_Arabic_noon_ghunna == 0x000005FA + XK_Arabic_heh_doachashmee == 0x000005FB + XK_Farsi_yeh == 0x000005FC + XK_Arabic_farsi_yeh == XK_Farsi_yeh + XK_Arabic_yeh_baree == 0x000005FD + XK_Arabic_heh_goal == 0x000005FE + XK_Arabic_switch == 0x0000FF7E # Alias for mode_switch +# XK_ARABIC +#* +# * Cyrillic +# * Byte 3 = 6 +# * + +when defined(XK_CYRILLIC): + XKc_Cyrillic_GHE_bar == 0x00000680 + XK_Cyrillic_ghe_bar == 0x00000690 + XKc_Cyrillic_ZHE_descender == 0x00000681 + XK_Cyrillic_zhe_descender == 0x00000691 + XKc_Cyrillic_KA_descender == 0x00000682 + XK_Cyrillic_ka_descender == 0x00000692 + XKc_Cyrillic_KA_vertstroke == 0x00000683 + XK_Cyrillic_ka_vertstroke == 0x00000693 + XKc_Cyrillic_EN_descender == 0x00000684 + XK_Cyrillic_en_descender == 0x00000694 + XKc_Cyrillic_U_straight == 0x00000685 + XK_Cyrillic_u_straight == 0x00000695 + XKc_Cyrillic_U_straight_bar == 0x00000686 + XK_Cyrillic_u_straight_bar == 0x00000696 + XKc_Cyrillic_HA_descender == 0x00000687 + XK_Cyrillic_ha_descender == 0x00000697 + XKc_Cyrillic_CHE_descender == 0x00000688 + XK_Cyrillic_che_descender == 0x00000698 + XKc_Cyrillic_CHE_vertstroke == 0x00000689 + XK_Cyrillic_che_vertstroke == 0x00000699 + XKc_Cyrillic_SHHA == 0x0000068A + XK_Cyrillic_shha == 0x0000069A + XKc_Cyrillic_SCHWA == 0x0000068C + XK_Cyrillic_schwa == 0x0000069C + XKc_Cyrillic_I_macron == 0x0000068D + XK_Cyrillic_i_macron == 0x0000069D + XKc_Cyrillic_O_bar == 0x0000068E + XK_Cyrillic_o_bar == 0x0000069E + XKc_Cyrillic_U_macron == 0x0000068F + XK_Cyrillic_u_macron == 0x0000069F + XK_Serbian_dje == 0x000006A1 + XK_Macedonia_gje == 0x000006A2 + XK_Cyrillic_io == 0x000006A3 + XK_Ukrainian_ie == 0x000006A4 + XK_Ukranian_je == 0x000006A4 # deprecated + XK_Macedonia_dse == 0x000006A5 + XK_Ukrainian_i == 0x000006A6 + XK_Ukranian_i == 0x000006A6 # deprecated + XK_Ukrainian_yi == 0x000006A7 + XK_Ukranian_yi == 0x000006A7 # deprecated + XK_Cyrillic_je == 0x000006A8 + XK_Serbian_je == 0x000006A8 # deprecated + XK_Cyrillic_lje == 0x000006A9 + XK_Serbian_lje == 0x000006A9 # deprecated + XK_Cyrillic_nje == 0x000006AA + XK_Serbian_nje == 0x000006AA # deprecated + XK_Serbian_tshe == 0x000006AB + XK_Macedonia_kje == 0x000006AC + XK_Ukrainian_ghe_with_upturn == 0x000006AD + XK_Byelorussian_shortu == 0x000006AE + XK_Cyrillic_dzhe == 0x000006AF + XK_Serbian_dze == 0x000006AF # deprecated + XK_numerosign == 0x000006B0 + XKc_Serbian_DJE == 0x000006B1 + XKc_Macedonia_GJE == 0x000006B2 + XKc_Cyrillic_IO == 0x000006B3 + XKc_Ukrainian_IE == 0x000006B4 + XKc_Ukranian_JE == 0x000006B4 # deprecated + XKc_Macedonia_DSE == 0x000006B5 + XKc_Ukrainian_I == 0x000006B6 + XKc_Ukranian_I == 0x000006B6 # deprecated + XKc_Ukrainian_YI == 0x000006B7 + XKc_Ukranian_YI == 0x000006B7 # deprecated + XKc_Cyrillic_JE == 0x000006B8 + XKc_Serbian_JE == 0x000006B8 # deprecated + XKc_Cyrillic_LJE == 0x000006B9 + XKc_Serbian_LJE == 0x000006B9 # deprecated + XKc_Cyrillic_NJE == 0x000006BA + XKc_Serbian_NJE == 0x000006BA # deprecated + XKc_Serbian_TSHE == 0x000006BB + XKc_Macedonia_KJE == 0x000006BC + XKc_Ukrainian_GHE_WITH_UPTURN == 0x000006BD + XKc_Byelorussian_SHORTU == 0x000006BE + XKc_Cyrillic_DZHE == 0x000006BF + XKc_Serbian_DZE == 0x000006BF # deprecated + XK_Cyrillic_yu == 0x000006C0 + XK_Cyrillic_a == 0x000006C1 + XK_Cyrillic_be == 0x000006C2 + XK_Cyrillic_tse == 0x000006C3 + XK_Cyrillic_de == 0x000006C4 + XK_Cyrillic_ie == 0x000006C5 + XK_Cyrillic_ef == 0x000006C6 + XK_Cyrillic_ghe == 0x000006C7 + XK_Cyrillic_ha == 0x000006C8 + XK_Cyrillic_i == 0x000006C9 + XK_Cyrillic_shorti == 0x000006CA + XK_Cyrillic_ka == 0x000006CB + XK_Cyrillic_el == 0x000006CC + XK_Cyrillic_em == 0x000006CD + XK_Cyrillic_en == 0x000006CE + XK_Cyrillic_o == 0x000006CF + XK_Cyrillic_pe == 0x000006D0 + XK_Cyrillic_ya == 0x000006D1 + XK_Cyrillic_er == 0x000006D2 + XK_Cyrillic_es == 0x000006D3 + XK_Cyrillic_te == 0x000006D4 + XK_Cyrillic_u == 0x000006D5 + XK_Cyrillic_zhe == 0x000006D6 + XK_Cyrillic_ve == 0x000006D7 + XK_Cyrillic_softsign == 0x000006D8 + XK_Cyrillic_yeru == 0x000006D9 + XK_Cyrillic_ze == 0x000006DA + XK_Cyrillic_sha == 0x000006DB + XK_Cyrillic_e == 0x000006DC + XK_Cyrillic_shcha == 0x000006DD + XK_Cyrillic_che == 0x000006DE + XK_Cyrillic_hardsign == 0x000006DF + XKc_Cyrillic_YU == 0x000006E0 + XKc_Cyrillic_A == 0x000006E1 + XKc_Cyrillic_BE == 0x000006E2 + XKc_Cyrillic_TSE == 0x000006E3 + XKc_Cyrillic_DE == 0x000006E4 + XKc_Cyrillic_IE == 0x000006E5 + XKc_Cyrillic_EF == 0x000006E6 + XKc_Cyrillic_GHE == 0x000006E7 + XKc_Cyrillic_HA == 0x000006E8 + XKc_Cyrillic_I == 0x000006E9 + XKc_Cyrillic_SHORTI == 0x000006EA + XKc_Cyrillic_KA == 0x000006EB + XKc_Cyrillic_EL == 0x000006EC + XKc_Cyrillic_EM == 0x000006ED + XKc_Cyrillic_EN == 0x000006EE + XKc_Cyrillic_O == 0x000006EF + XKc_Cyrillic_PE == 0x000006F0 + XKc_Cyrillic_YA == 0x000006F1 + XKc_Cyrillic_ER == 0x000006F2 + XKc_Cyrillic_ES == 0x000006F3 + XKc_Cyrillic_TE == 0x000006F4 + XKc_Cyrillic_U == 0x000006F5 + XKc_Cyrillic_ZHE == 0x000006F6 + XKc_Cyrillic_VE == 0x000006F7 + XKc_Cyrillic_SOFTSIGN == 0x000006F8 + XKc_Cyrillic_YERU == 0x000006F9 + XKc_Cyrillic_ZE == 0x000006FA + XKc_Cyrillic_SHA == 0x000006FB + XKc_Cyrillic_E == 0x000006FC + XKc_Cyrillic_SHCHA == 0x000006FD + XKc_Cyrillic_CHE == 0x000006FE + XKc_Cyrillic_HARDSIGN == 0x000006FF +# XK_CYRILLIC +#* +# * Greek +# * Byte 3 = 7 +# * + +when defined(XK_GREEK): + XKc_Greek_ALPHAaccent == 0x000007A1 + XKc_Greek_EPSILONaccent == 0x000007A2 + XKc_Greek_ETAaccent == 0x000007A3 + XKc_Greek_IOTAaccent == 0x000007A4 + XKc_Greek_IOTAdieresis == 0x000007A5 + XKc_Greek_IOTAdiaeresis == XKc_Greek_IOTAdieresis # old typo + XKc_Greek_OMICRONaccent == 0x000007A7 + XKc_Greek_UPSILONaccent == 0x000007A8 + XKc_Greek_UPSILONdieresis == 0x000007A9 + XKc_Greek_OMEGAaccent == 0x000007AB + XK_Greek_accentdieresis == 0x000007AE + XK_Greek_horizbar == 0x000007AF + XK_Greek_alphaaccent == 0x000007B1 + XK_Greek_epsilonaccent == 0x000007B2 + XK_Greek_etaaccent == 0x000007B3 + XK_Greek_iotaaccent == 0x000007B4 + XK_Greek_iotadieresis == 0x000007B5 + XK_Greek_iotaaccentdieresis == 0x000007B6 + XK_Greek_omicronaccent == 0x000007B7 + XK_Greek_upsilonaccent == 0x000007B8 + XK_Greek_upsilondieresis == 0x000007B9 + XK_Greek_upsilonaccentdieresis == 0x000007BA + XK_Greek_omegaaccent == 0x000007BB + XKc_Greek_ALPHA == 0x000007C1 + XKc_Greek_BETA == 0x000007C2 + XKc_Greek_GAMMA == 0x000007C3 + XKc_Greek_DELTA == 0x000007C4 + XKc_Greek_EPSILON == 0x000007C5 + XKc_Greek_ZETA == 0x000007C6 + XKc_Greek_ETA == 0x000007C7 + XKc_Greek_THETA == 0x000007C8 + XKc_Greek_IOTA == 0x000007C9 + XKc_Greek_KAPPA == 0x000007CA + XKc_Greek_LAMDA == 0x000007CB + XKc_Greek_LAMBDA == 0x000007CB + XKc_Greek_MU == 0x000007CC + XKc_Greek_NU == 0x000007CD + XKc_Greek_XI == 0x000007CE + XKc_Greek_OMICRON == 0x000007CF + XKc_Greek_PI == 0x000007D0 + XKc_Greek_RHO == 0x000007D1 + XKc_Greek_SIGMA == 0x000007D2 + XKc_Greek_TAU == 0x000007D4 + XKc_Greek_UPSILON == 0x000007D5 + XKc_Greek_PHI == 0x000007D6 + XKc_Greek_CHI == 0x000007D7 + XKc_Greek_PSI == 0x000007D8 + XKc_Greek_OMEGA == 0x000007D9 + XK_Greek_alpha == 0x000007E1 + XK_Greek_beta == 0x000007E2 + XK_Greek_gamma == 0x000007E3 + XK_Greek_delta == 0x000007E4 + XK_Greek_epsilon == 0x000007E5 + XK_Greek_zeta == 0x000007E6 + XK_Greek_eta == 0x000007E7 + XK_Greek_theta == 0x000007E8 + XK_Greek_iota == 0x000007E9 + XK_Greek_kappa == 0x000007EA + XK_Greek_lamda == 0x000007EB + XK_Greek_lambda == 0x000007EB + XK_Greek_mu == 0x000007EC + XK_Greek_nu == 0x000007ED + XK_Greek_xi == 0x000007EE + XK_Greek_omicron == 0x000007EF + XK_Greek_pi == 0x000007F0 + XK_Greek_rho == 0x000007F1 + XK_Greek_sigma == 0x000007F2 + XK_Greek_finalsmallsigma == 0x000007F3 + XK_Greek_tau == 0x000007F4 + XK_Greek_upsilon == 0x000007F5 + XK_Greek_phi == 0x000007F6 + XK_Greek_chi == 0x000007F7 + XK_Greek_psi == 0x000007F8 + XK_Greek_omega == 0x000007F9 + XK_Greek_switch == 0x0000FF7E # Alias for mode_switch +# XK_GREEK +#* +# * Technical +# * Byte 3 = 8 +# * + +when defined(XK_TECHNICAL): + XK_leftradical == 0x000008A1 + XK_topleftradical == 0x000008A2 + XK_horizconnector == 0x000008A3 + XK_topintegral == 0x000008A4 + XK_botintegral == 0x000008A5 + XK_vertconnector == 0x000008A6 + XK_topleftsqbracket == 0x000008A7 + XK_botleftsqbracket == 0x000008A8 + XK_toprightsqbracket == 0x000008A9 + XK_botrightsqbracket == 0x000008AA + XK_topleftparens == 0x000008AB + XK_botleftparens == 0x000008AC + XK_toprightparens == 0x000008AD + XK_botrightparens == 0x000008AE + XK_leftmiddlecurlybrace == 0x000008AF + XK_rightmiddlecurlybrace == 0x000008B0 + XK_topleftsummation == 0x000008B1 + XK_botleftsummation == 0x000008B2 + XK_topvertsummationconnector == 0x000008B3 + XK_botvertsummationconnector == 0x000008B4 + XK_toprightsummation == 0x000008B5 + XK_botrightsummation == 0x000008B6 + XK_rightmiddlesummation == 0x000008B7 + XK_lessthanequal == 0x000008BC + XK_notequal == 0x000008BD + XK_greaterthanequal == 0x000008BE + XK_integral == 0x000008BF + XK_therefore == 0x000008C0 + XK_variation == 0x000008C1 + XK_infinity == 0x000008C2 + XK_nabla == 0x000008C5 + XK_approximate == 0x000008C8 + XK_similarequal == 0x000008C9 + XK_ifonlyif == 0x000008CD + XK_implies == 0x000008CE + XK_identical == 0x000008CF + XK_radical == 0x000008D6 + XK_includedin == 0x000008DA + XK_includes == 0x000008DB + XK_intersection == 0x000008DC + XK_union == 0x000008DD + XK_logicaland == 0x000008DE + XK_logicalor == 0x000008DF + XK_partialderivative == 0x000008EF + XK_function == 0x000008F6 + XK_leftarrow == 0x000008FB + XK_uparrow == 0x000008FC + XK_rightarrow == 0x000008FD + XK_downarrow == 0x000008FE +# XK_TECHNICAL +#* +# * Special +# * Byte 3 = 9 +# * + +when defined(XK_SPECIAL): + XK_blank == 0x000009DF + XK_soliddiamond == 0x000009E0 + XK_checkerboard == 0x000009E1 + XK_ht == 0x000009E2 + XK_ff == 0x000009E3 + XK_cr == 0x000009E4 + XK_lf == 0x000009E5 + XK_nl == 0x000009E8 + XK_vt == 0x000009E9 + XK_lowrightcorner == 0x000009EA + XK_uprightcorner == 0x000009EB + XK_upleftcorner == 0x000009EC + XK_lowleftcorner == 0x000009ED + XK_crossinglines == 0x000009EE + XK_horizlinescan1 == 0x000009EF + XK_horizlinescan3 == 0x000009F0 + XK_horizlinescan5 == 0x000009F1 + XK_horizlinescan7 == 0x000009F2 + XK_horizlinescan9 == 0x000009F3 + XK_leftt == 0x000009F4 + XK_rightt == 0x000009F5 + XK_bott == 0x000009F6 + XK_topt == 0x000009F7 + XK_vertbar == 0x000009F8 +# XK_SPECIAL +#* +# * Publishing +# * Byte 3 = a +# * + +when defined(XK_PUBLISHING): + XK_emspace == 0x00000AA1 + XK_enspace == 0x00000AA2 + XK_em3space == 0x00000AA3 + XK_em4space == 0x00000AA4 + XK_digitspace == 0x00000AA5 + XK_punctspace == 0x00000AA6 + XK_thinspace == 0x00000AA7 + XK_hairspace == 0x00000AA8 + XK_emdash == 0x00000AA9 + XK_endash == 0x00000AAA + XK_signifblank == 0x00000AAC + XK_ellipsis == 0x00000AAE + XK_doubbaselinedot == 0x00000AAF + XK_onethird == 0x00000AB0 + XK_twothirds == 0x00000AB1 + XK_onefifth == 0x00000AB2 + XK_twofifths == 0x00000AB3 + XK_threefifths == 0x00000AB4 + XK_fourfifths == 0x00000AB5 + XK_onesixth == 0x00000AB6 + XK_fivesixths == 0x00000AB7 + XK_careof == 0x00000AB8 + XK_figdash == 0x00000ABB + XK_leftanglebracket == 0x00000ABC + XK_decimalpoint == 0x00000ABD + XK_rightanglebracket == 0x00000ABE + XK_marker == 0x00000ABF + XK_oneeighth == 0x00000AC3 + XK_threeeighths == 0x00000AC4 + XK_fiveeighths == 0x00000AC5 + XK_seveneighths == 0x00000AC6 + XK_trademark == 0x00000AC9 + XK_signaturemark == 0x00000ACA + XK_trademarkincircle == 0x00000ACB + XK_leftopentriangle == 0x00000ACC + XK_rightopentriangle == 0x00000ACD + XK_emopencircle == 0x00000ACE + XK_emopenrectangle == 0x00000ACF + XK_leftsinglequotemark == 0x00000AD0 + XK_rightsinglequotemark == 0x00000AD1 + XK_leftdoublequotemark == 0x00000AD2 + XK_rightdoublequotemark == 0x00000AD3 + XK_prescription == 0x00000AD4 + XK_minutes == 0x00000AD6 + XK_seconds == 0x00000AD7 + XK_latincross == 0x00000AD9 + XK_hexagram == 0x00000ADA + XK_filledrectbullet == 0x00000ADB + XK_filledlefttribullet == 0x00000ADC + XK_filledrighttribullet == 0x00000ADD + XK_emfilledcircle == 0x00000ADE + XK_emfilledrect == 0x00000ADF + XK_enopencircbullet == 0x00000AE0 + XK_enopensquarebullet == 0x00000AE1 + XK_openrectbullet == 0x00000AE2 + XK_opentribulletup == 0x00000AE3 + XK_opentribulletdown == 0x00000AE4 + XK_openstar == 0x00000AE5 + XK_enfilledcircbullet == 0x00000AE6 + XK_enfilledsqbullet == 0x00000AE7 + XK_filledtribulletup == 0x00000AE8 + XK_filledtribulletdown == 0x00000AE9 + XK_leftpointer == 0x00000AEA + XK_rightpointer == 0x00000AEB + XK_club == 0x00000AEC + XK_diamond == 0x00000AED + XK_heart == 0x00000AEE + XK_maltesecross == 0x00000AF0 + XK_dagger == 0x00000AF1 + XK_doubledagger == 0x00000AF2 + XK_checkmark == 0x00000AF3 + XK_ballotcross == 0x00000AF4 + XK_musicalsharp == 0x00000AF5 + XK_musicalflat == 0x00000AF6 + XK_malesymbol == 0x00000AF7 + XK_femalesymbol == 0x00000AF8 + XK_telephone == 0x00000AF9 + XK_telephonerecorder == 0x00000AFA + XK_phonographcopyright == 0x00000AFB + XK_caret == 0x00000AFC + XK_singlelowquotemark == 0x00000AFD + XK_doublelowquotemark == 0x00000AFE + XK_cursor == 0x00000AFF +# XK_PUBLISHING +#* +# * APL +# * Byte 3 = b +# * + +when defined(XK_APL): + XK_leftcaret == 0x00000BA3 + XK_rightcaret == 0x00000BA6 + XK_downcaret == 0x00000BA8 + XK_upcaret == 0x00000BA9 + XK_overbar == 0x00000BC0 + XK_downtack == 0x00000BC2 + XK_upshoe == 0x00000BC3 + XK_downstile == 0x00000BC4 + XK_underbar == 0x00000BC6 + XK_jot == 0x00000BCA + XK_quad == 0x00000BCC + XK_uptack == 0x00000BCE + XK_circle == 0x00000BCF + XK_upstile == 0x00000BD3 + XK_downshoe == 0x00000BD6 + XK_rightshoe == 0x00000BD8 + XK_leftshoe == 0x00000BDA + XK_lefttack == 0x00000BDC + XK_righttack == 0x00000BFC +# XK_APL +#* +# * Hebrew +# * Byte 3 = c +# * + +when defined(XK_HEBREW): + XK_hebrew_doublelowline == 0x00000CDF + XK_hebrew_aleph == 0x00000CE0 + XK_hebrew_bet == 0x00000CE1 + XK_hebrew_beth == 0x00000CE1 # deprecated + XK_hebrew_gimel == 0x00000CE2 + XK_hebrew_gimmel == 0x00000CE2 # deprecated + XK_hebrew_dalet == 0x00000CE3 + XK_hebrew_daleth == 0x00000CE3 # deprecated + XK_hebrew_he == 0x00000CE4 + XK_hebrew_waw == 0x00000CE5 + XK_hebrew_zain == 0x00000CE6 + XK_hebrew_zayin == 0x00000CE6 # deprecated + XK_hebrew_chet == 0x00000CE7 + XK_hebrew_het == 0x00000CE7 # deprecated + XK_hebrew_tet == 0x00000CE8 + XK_hebrew_teth == 0x00000CE8 # deprecated + XK_hebrew_yod == 0x00000CE9 + XK_hebrew_finalkaph == 0x00000CEA + XK_hebrew_kaph == 0x00000CEB + XK_hebrew_lamed == 0x00000CEC + XK_hebrew_finalmem == 0x00000CED + XK_hebrew_mem == 0x00000CEE + XK_hebrew_finalnun == 0x00000CEF + XK_hebrew_nun == 0x00000CF0 + XK_hebrew_samech == 0x00000CF1 + XK_hebrew_samekh == 0x00000CF1 # deprecated + XK_hebrew_ayin == 0x00000CF2 + XK_hebrew_finalpe == 0x00000CF3 + XK_hebrew_pe == 0x00000CF4 + XK_hebrew_finalzade == 0x00000CF5 + XK_hebrew_finalzadi == 0x00000CF5 # deprecated + XK_hebrew_zade == 0x00000CF6 + XK_hebrew_zadi == 0x00000CF6 # deprecated + XK_hebrew_qoph == 0x00000CF7 + XK_hebrew_kuf == 0x00000CF7 # deprecated + XK_hebrew_resh == 0x00000CF8 + XK_hebrew_shin == 0x00000CF9 + XK_hebrew_taw == 0x00000CFA + XK_hebrew_taf == 0x00000CFA # deprecated + XK_Hebrew_switch == 0x0000FF7E # Alias for mode_switch +# XK_HEBREW +#* +# * Thai +# * Byte 3 = d +# * + +when defined(XK_THAI): + XK_Thai_kokai == 0x00000DA1 + XK_Thai_khokhai == 0x00000DA2 + XK_Thai_khokhuat == 0x00000DA3 + XK_Thai_khokhwai == 0x00000DA4 + XK_Thai_khokhon == 0x00000DA5 + XK_Thai_khorakhang == 0x00000DA6 + XK_Thai_ngongu == 0x00000DA7 + XK_Thai_chochan == 0x00000DA8 + XK_Thai_choching == 0x00000DA9 + XK_Thai_chochang == 0x00000DAA + XK_Thai_soso == 0x00000DAB + XK_Thai_chochoe == 0x00000DAC + XK_Thai_yoying == 0x00000DAD + XK_Thai_dochada == 0x00000DAE + XK_Thai_topatak == 0x00000DAF + XK_Thai_thothan == 0x00000DB0 + XK_Thai_thonangmontho == 0x00000DB1 + XK_Thai_thophuthao == 0x00000DB2 + XK_Thai_nonen == 0x00000DB3 + XK_Thai_dodek == 0x00000DB4 + XK_Thai_totao == 0x00000DB5 + XK_Thai_thothung == 0x00000DB6 + XK_Thai_thothahan == 0x00000DB7 + XK_Thai_thothong == 0x00000DB8 + XK_Thai_nonu == 0x00000DB9 + XK_Thai_bobaimai == 0x00000DBA + XK_Thai_popla == 0x00000DBB + XK_Thai_phophung == 0x00000DBC + XK_Thai_fofa == 0x00000DBD + XK_Thai_phophan == 0x00000DBE + XK_Thai_fofan == 0x00000DBF + XK_Thai_phosamphao == 0x00000DC0 + XK_Thai_moma == 0x00000DC1 + XK_Thai_yoyak == 0x00000DC2 + XK_Thai_rorua == 0x00000DC3 + XK_Thai_ru == 0x00000DC4 + XK_Thai_loling == 0x00000DC5 + XK_Thai_lu == 0x00000DC6 + XK_Thai_wowaen == 0x00000DC7 + XK_Thai_sosala == 0x00000DC8 + XK_Thai_sorusi == 0x00000DC9 + XK_Thai_sosua == 0x00000DCA + XK_Thai_hohip == 0x00000DCB + XK_Thai_lochula == 0x00000DCC + XK_Thai_oang == 0x00000DCD + XK_Thai_honokhuk == 0x00000DCE + XK_Thai_paiyannoi == 0x00000DCF + XK_Thai_saraa == 0x00000DD0 + XK_Thai_maihanakat == 0x00000DD1 + XK_Thai_saraaa == 0x00000DD2 + XK_Thai_saraam == 0x00000DD3 + XK_Thai_sarai == 0x00000DD4 + XK_Thai_saraii == 0x00000DD5 + XK_Thai_saraue == 0x00000DD6 + XK_Thai_sarauee == 0x00000DD7 + XK_Thai_sarau == 0x00000DD8 + XK_Thai_sarauu == 0x00000DD9 + XK_Thai_phinthu == 0x00000DDA + XK_Thai_maihanakat_maitho == 0x00000DDE + XK_Thai_baht == 0x00000DDF + XK_Thai_sarae == 0x00000DE0 + XK_Thai_saraae == 0x00000DE1 + XK_Thai_sarao == 0x00000DE2 + XK_Thai_saraaimaimuan == 0x00000DE3 + XK_Thai_saraaimaimalai == 0x00000DE4 + XK_Thai_lakkhangyao == 0x00000DE5 + XK_Thai_maiyamok == 0x00000DE6 + XK_Thai_maitaikhu == 0x00000DE7 + XK_Thai_maiek == 0x00000DE8 + XK_Thai_maitho == 0x00000DE9 + XK_Thai_maitri == 0x00000DEA + XK_Thai_maichattawa == 0x00000DEB + XK_Thai_thanthakhat == 0x00000DEC + XK_Thai_nikhahit == 0x00000DED + XK_Thai_leksun == 0x00000DF0 + XK_Thai_leknung == 0x00000DF1 + XK_Thai_leksong == 0x00000DF2 + XK_Thai_leksam == 0x00000DF3 + XK_Thai_leksi == 0x00000DF4 + XK_Thai_lekha == 0x00000DF5 + XK_Thai_lekhok == 0x00000DF6 + XK_Thai_lekchet == 0x00000DF7 + XK_Thai_lekpaet == 0x00000DF8 + XK_Thai_lekkao == 0x00000DF9 +# XK_THAI +#* +# * Korean +# * Byte 3 = e +# * + +when defined(XK_KOREAN): + XK_Hangul == 0x0000FF31 # Hangul start/stop(toggle) + XK_Hangul_Start == 0x0000FF32 # Hangul start + XK_Hangul_End == 0x0000FF33 # Hangul end, English start + XK_Hangul_Hanja == 0x0000FF34 # Start Hangul->Hanja Conversion + XK_Hangul_Jamo == 0x0000FF35 # Hangul Jamo mode + XK_Hangul_Romaja == 0x0000FF36 # Hangul Romaja mode + XK_Hangul_Codeinput == 0x0000FF37 # Hangul code input mode + XK_Hangul_Jeonja == 0x0000FF38 # Jeonja mode + XK_Hangul_Banja == 0x0000FF39 # Banja mode + XK_Hangul_PreHanja == 0x0000FF3A # Pre Hanja conversion + XK_Hangul_PostHanja == 0x0000FF3B # Post Hanja conversion + XK_Hangul_SingleCandidate == 0x0000FF3C # Single candidate + XK_Hangul_MultipleCandidate == 0x0000FF3D # Multiple candidate + XK_Hangul_PreviousCandidate == 0x0000FF3E # Previous candidate + XK_Hangul_Special == 0x0000FF3F # Special symbols + XK_Hangul_switch == 0x0000FF7E # Alias for mode_switch + # Hangul Consonant Characters + XK_Hangul_Kiyeog == 0x00000EA1 + XK_Hangul_SsangKiyeog == 0x00000EA2 + XK_Hangul_KiyeogSios == 0x00000EA3 + XK_Hangul_Nieun == 0x00000EA4 + XK_Hangul_NieunJieuj == 0x00000EA5 + XK_Hangul_NieunHieuh == 0x00000EA6 + XK_Hangul_Dikeud == 0x00000EA7 + XK_Hangul_SsangDikeud == 0x00000EA8 + XK_Hangul_Rieul == 0x00000EA9 + XK_Hangul_RieulKiyeog == 0x00000EAA + XK_Hangul_RieulMieum == 0x00000EAB + XK_Hangul_RieulPieub == 0x00000EAC + XK_Hangul_RieulSios == 0x00000EAD + XK_Hangul_RieulTieut == 0x00000EAE + XK_Hangul_RieulPhieuf == 0x00000EAF + XK_Hangul_RieulHieuh == 0x00000EB0 + XK_Hangul_Mieum == 0x00000EB1 + XK_Hangul_Pieub == 0x00000EB2 + XK_Hangul_SsangPieub == 0x00000EB3 + XK_Hangul_PieubSios == 0x00000EB4 + XK_Hangul_Sios == 0x00000EB5 + XK_Hangul_SsangSios == 0x00000EB6 + XK_Hangul_Ieung == 0x00000EB7 + XK_Hangul_Jieuj == 0x00000EB8 + XK_Hangul_SsangJieuj == 0x00000EB9 + XK_Hangul_Cieuc == 0x00000EBA + XK_Hangul_Khieuq == 0x00000EBB + XK_Hangul_Tieut == 0x00000EBC + XK_Hangul_Phieuf == 0x00000EBD + XK_Hangul_Hieuh == 0x00000EBE # Hangul Vowel Characters + XK_Hangul_A == 0x00000EBF + XK_Hangul_AE == 0x00000EC0 + XK_Hangul_YA == 0x00000EC1 + XK_Hangul_YAE == 0x00000EC2 + XK_Hangul_EO == 0x00000EC3 + XK_Hangul_E == 0x00000EC4 + XK_Hangul_YEO == 0x00000EC5 + XK_Hangul_YE == 0x00000EC6 + XK_Hangul_O == 0x00000EC7 + XK_Hangul_WA == 0x00000EC8 + XK_Hangul_WAE == 0x00000EC9 + XK_Hangul_OE == 0x00000ECA + XK_Hangul_YO == 0x00000ECB + XK_Hangul_U == 0x00000ECC + XK_Hangul_WEO == 0x00000ECD + XK_Hangul_WE == 0x00000ECE + XK_Hangul_WI == 0x00000ECF + XK_Hangul_YU == 0x00000ED0 + XK_Hangul_EU == 0x00000ED1 + XK_Hangul_YI == 0x00000ED2 + XK_Hangul_I == 0x00000ED3 # Hangul syllable-final (JongSeong) Characters + XK_Hangul_J_Kiyeog == 0x00000ED4 + XK_Hangul_J_SsangKiyeog == 0x00000ED5 + XK_Hangul_J_KiyeogSios == 0x00000ED6 + XK_Hangul_J_Nieun == 0x00000ED7 + XK_Hangul_J_NieunJieuj == 0x00000ED8 + XK_Hangul_J_NieunHieuh == 0x00000ED9 + XK_Hangul_J_Dikeud == 0x00000EDA + XK_Hangul_J_Rieul == 0x00000EDB + XK_Hangul_J_RieulKiyeog == 0x00000EDC + XK_Hangul_J_RieulMieum == 0x00000EDD + XK_Hangul_J_RieulPieub == 0x00000EDE + XK_Hangul_J_RieulSios == 0x00000EDF + XK_Hangul_J_RieulTieut == 0x00000EE0 + XK_Hangul_J_RieulPhieuf == 0x00000EE1 + XK_Hangul_J_RieulHieuh == 0x00000EE2 + XK_Hangul_J_Mieum == 0x00000EE3 + XK_Hangul_J_Pieub == 0x00000EE4 + XK_Hangul_J_PieubSios == 0x00000EE5 + XK_Hangul_J_Sios == 0x00000EE6 + XK_Hangul_J_SsangSios == 0x00000EE7 + XK_Hangul_J_Ieung == 0x00000EE8 + XK_Hangul_J_Jieuj == 0x00000EE9 + XK_Hangul_J_Cieuc == 0x00000EEA + XK_Hangul_J_Khieuq == 0x00000EEB + XK_Hangul_J_Tieut == 0x00000EEC + XK_Hangul_J_Phieuf == 0x00000EED + XK_Hangul_J_Hieuh == 0x00000EEE # Ancient Hangul Consonant Characters + XK_Hangul_RieulYeorinHieuh == 0x00000EEF + XK_Hangul_SunkyeongeumMieum == 0x00000EF0 + XK_Hangul_SunkyeongeumPieub == 0x00000EF1 + XK_Hangul_PanSios == 0x00000EF2 + XK_Hangul_KkogjiDalrinIeung == 0x00000EF3 + XK_Hangul_SunkyeongeumPhieuf == 0x00000EF4 + XK_Hangul_YeorinHieuh == 0x00000EF5 # Ancient Hangul Vowel Characters + XK_Hangul_AraeA == 0x00000EF6 + XK_Hangul_AraeAE == 0x00000EF7 # Ancient Hangul syllable-final (JongSeong) Characters + XK_Hangul_J_PanSios == 0x00000EF8 + XK_Hangul_J_KkogjiDalrinIeung == 0x00000EF9 + XK_Hangul_J_YeorinHieuh == 0x00000EFA # Korean currency symbol + XK_Korean_Won == 0x00000EFF +# XK_KOREAN +#* +# * Armenian +# * Byte 3 = = $14 +# * + +when defined(XK_ARMENIAN): + XK_Armenian_eternity == 0x000014A1 + XK_Armenian_ligature_ew == 0x000014A2 + XK_Armenian_full_stop == 0x000014A3 + XK_Armenian_verjaket == 0x000014A3 + XK_Armenian_parenright == 0x000014A4 + XK_Armenian_parenleft == 0x000014A5 + XK_Armenian_guillemotright == 0x000014A6 + XK_Armenian_guillemotleft == 0x000014A7 + XK_Armenian_em_dash == 0x000014A8 + XK_Armenian_dot == 0x000014A9 + XK_Armenian_mijaket == 0x000014A9 + XK_Armenian_separation_mark == 0x000014AA + XK_Armenian_but == 0x000014AA + XK_Armenian_comma == 0x000014AB + XK_Armenian_en_dash == 0x000014AC + XK_Armenian_hyphen == 0x000014AD + XK_Armenian_yentamna == 0x000014AD + XK_Armenian_ellipsis == 0x000014AE + XK_Armenian_exclam == 0x000014AF + XK_Armenian_amanak == 0x000014AF + XK_Armenian_accent == 0x000014B0 + XK_Armenian_shesht == 0x000014B0 + XK_Armenian_question == 0x000014B1 + XK_Armenian_paruyk == 0x000014B1 + XKc_Armenian_AYB == 0x000014B2 + XK_Armenian_ayb == 0x000014B3 + XKc_Armenian_BEN == 0x000014B4 + XK_Armenian_ben == 0x000014B5 + XKc_Armenian_GIM == 0x000014B6 + XK_Armenian_gim == 0x000014B7 + XKc_Armenian_DA == 0x000014B8 + XK_Armenian_da == 0x000014B9 + XKc_Armenian_YECH == 0x000014BA + XK_Armenian_yech == 0x000014BB + XKc_Armenian_ZA == 0x000014BC + XK_Armenian_za == 0x000014BD + XKc_Armenian_E == 0x000014BE + XK_Armenian_e == 0x000014BF + XKc_Armenian_AT == 0x000014C0 + XK_Armenian_at == 0x000014C1 + XKc_Armenian_TO == 0x000014C2 + XK_Armenian_to == 0x000014C3 + XKc_Armenian_ZHE == 0x000014C4 + XK_Armenian_zhe == 0x000014C5 + XKc_Armenian_INI == 0x000014C6 + XK_Armenian_ini == 0x000014C7 + XKc_Armenian_LYUN == 0x000014C8 + XK_Armenian_lyun == 0x000014C9 + XKc_Armenian_KHE == 0x000014CA + XK_Armenian_khe == 0x000014CB + XKc_Armenian_TSA == 0x000014CC + XK_Armenian_tsa == 0x000014CD + XKc_Armenian_KEN == 0x000014CE + XK_Armenian_ken == 0x000014CF + XKc_Armenian_HO == 0x000014D0 + XK_Armenian_ho == 0x000014D1 + XKc_Armenian_DZA == 0x000014D2 + XK_Armenian_dza == 0x000014D3 + XKc_Armenian_GHAT == 0x000014D4 + XK_Armenian_ghat == 0x000014D5 + XKc_Armenian_TCHE == 0x000014D6 + XK_Armenian_tche == 0x000014D7 + XKc_Armenian_MEN == 0x000014D8 + XK_Armenian_men == 0x000014D9 + XKc_Armenian_HI == 0x000014DA + XK_Armenian_hi == 0x000014DB + XKc_Armenian_NU == 0x000014DC + XK_Armenian_nu == 0x000014DD + XKc_Armenian_SHA == 0x000014DE + XK_Armenian_sha == 0x000014DF + XKc_Armenian_VO == 0x000014E0 + XK_Armenian_vo == 0x000014E1 + XKc_Armenian_CHA == 0x000014E2 + XK_Armenian_cha == 0x000014E3 + XKc_Armenian_PE == 0x000014E4 + XK_Armenian_pe == 0x000014E5 + XKc_Armenian_JE == 0x000014E6 + XK_Armenian_je == 0x000014E7 + XKc_Armenian_RA == 0x000014E8 + XK_Armenian_ra == 0x000014E9 + XKc_Armenian_SE == 0x000014EA + XK_Armenian_se == 0x000014EB + XKc_Armenian_VEV == 0x000014EC + XK_Armenian_vev == 0x000014ED + XKc_Armenian_TYUN == 0x000014EE + XK_Armenian_tyun == 0x000014EF + XKc_Armenian_RE == 0x000014F0 + XK_Armenian_re == 0x000014F1 + XKc_Armenian_TSO == 0x000014F2 + XK_Armenian_tso == 0x000014F3 + XKc_Armenian_VYUN == 0x000014F4 + XK_Armenian_vyun == 0x000014F5 + XKc_Armenian_PYUR == 0x000014F6 + XK_Armenian_pyur == 0x000014F7 + XKc_Armenian_KE == 0x000014F8 + XK_Armenian_ke == 0x000014F9 + XKc_Armenian_O == 0x000014FA + XK_Armenian_o == 0x000014FB + XKc_Armenian_FE == 0x000014FC + XK_Armenian_fe == 0x000014FD + XK_Armenian_apostrophe == 0x000014FE + XK_Armenian_section_sign == 0x000014FF +# XK_ARMENIAN +#* +# * Georgian +# * Byte 3 = = $15 +# * + +when defined(XK_GEORGIAN): + XK_Georgian_an == 0x000015D0 + XK_Georgian_ban == 0x000015D1 + XK_Georgian_gan == 0x000015D2 + XK_Georgian_don == 0x000015D3 + XK_Georgian_en == 0x000015D4 + XK_Georgian_vin == 0x000015D5 + XK_Georgian_zen == 0x000015D6 + XK_Georgian_tan == 0x000015D7 + XK_Georgian_in == 0x000015D8 + XK_Georgian_kan == 0x000015D9 + XK_Georgian_las == 0x000015DA + XK_Georgian_man == 0x000015DB + XK_Georgian_nar == 0x000015DC + XK_Georgian_on == 0x000015DD + XK_Georgian_par == 0x000015DE + XK_Georgian_zhar == 0x000015DF + XK_Georgian_rae == 0x000015E0 + XK_Georgian_san == 0x000015E1 + XK_Georgian_tar == 0x000015E2 + XK_Georgian_un == 0x000015E3 + XK_Georgian_phar == 0x000015E4 + XK_Georgian_khar == 0x000015E5 + XK_Georgian_ghan == 0x000015E6 + XK_Georgian_qar == 0x000015E7 + XK_Georgian_shin == 0x000015E8 + XK_Georgian_chin == 0x000015E9 + XK_Georgian_can == 0x000015EA + XK_Georgian_jil == 0x000015EB + XK_Georgian_cil == 0x000015EC + XK_Georgian_char == 0x000015ED + XK_Georgian_xan == 0x000015EE + XK_Georgian_jhan == 0x000015EF + XK_Georgian_hae == 0x000015F0 + XK_Georgian_he == 0x000015F1 + XK_Georgian_hie == 0x000015F2 + XK_Georgian_we == 0x000015F3 + XK_Georgian_har == 0x000015F4 + XK_Georgian_hoe == 0x000015F5 + XK_Georgian_fi == 0x000015F6 +# XK_GEORGIAN +#* +# * Azeri (and other Turkic or Caucasian languages of ex-USSR) +# * Byte 3 = = $16 +# * + +when defined(XK_CAUCASUS): + # latin + XKc_Ccedillaabovedot == 0x000016A2 + XKc_Xabovedot == 0x000016A3 + XKc_Qabovedot == 0x000016A5 + XKc_Ibreve == 0x000016A6 + XKc_IE == 0x000016A7 + XKc_UO == 0x000016A8 + XKc_Zstroke == 0x000016A9 + XKc_Gcaron == 0x000016AA + XKc_Obarred == 0x000016AF + XK_ccedillaabovedot == 0x000016B2 + XK_xabovedot == 0x000016B3 + XKc_Ocaron == 0x000016B4 + XK_qabovedot == 0x000016B5 + XK_ibreve == 0x000016B6 + XK_ie == 0x000016B7 + XK_uo == 0x000016B8 + XK_zstroke == 0x000016B9 + XK_gcaron == 0x000016BA + XK_ocaron == 0x000016BD + XK_obarred == 0x000016BF + XKc_SCHWA == 0x000016C6 + XK_schwa == 0x000016F6 # those are not really Caucasus, but I put them here for now + # For Inupiak + XKc_Lbelowdot == 0x000016D1 + XKc_Lstrokebelowdot == 0x000016D2 + XK_lbelowdot == 0x000016E1 + XK_lstrokebelowdot == 0x000016E2 # For Guarani + XKc_Gtilde == 0x000016D3 + XK_gtilde == 0x000016E3 +# XK_CAUCASUS +#* +# * Vietnamese +# * Byte 3 = = $1e +# * + +when defined(XK_VIETNAMESE): + XKc_Abelowdot == 0x00001EA0 + XK_abelowdot == 0x00001EA1 + XKc_Ahook == 0x00001EA2 + XK_ahook == 0x00001EA3 + XKc_Acircumflexacute == 0x00001EA4 + XK_acircumflexacute == 0x00001EA5 + XKc_Acircumflexgrave == 0x00001EA6 + XK_acircumflexgrave == 0x00001EA7 + XKc_Acircumflexhook == 0x00001EA8 + XK_acircumflexhook == 0x00001EA9 + XKc_Acircumflextilde == 0x00001EAA + XK_acircumflextilde == 0x00001EAB + XKc_Acircumflexbelowdot == 0x00001EAC + XK_acircumflexbelowdot == 0x00001EAD + XKc_Abreveacute == 0x00001EAE + XK_abreveacute == 0x00001EAF + XKc_Abrevegrave == 0x00001EB0 + XK_abrevegrave == 0x00001EB1 + XKc_Abrevehook == 0x00001EB2 + XK_abrevehook == 0x00001EB3 + XKc_Abrevetilde == 0x00001EB4 + XK_abrevetilde == 0x00001EB5 + XKc_Abrevebelowdot == 0x00001EB6 + XK_abrevebelowdot == 0x00001EB7 + XKc_Ebelowdot == 0x00001EB8 + XK_ebelowdot == 0x00001EB9 + XKc_Ehook == 0x00001EBA + XK_ehook == 0x00001EBB + XKc_Etilde == 0x00001EBC + XK_etilde == 0x00001EBD + XKc_Ecircumflexacute == 0x00001EBE + XK_ecircumflexacute == 0x00001EBF + XKc_Ecircumflexgrave == 0x00001EC0 + XK_ecircumflexgrave == 0x00001EC1 + XKc_Ecircumflexhook == 0x00001EC2 + XK_ecircumflexhook == 0x00001EC3 + XKc_Ecircumflextilde == 0x00001EC4 + XK_ecircumflextilde == 0x00001EC5 + XKc_Ecircumflexbelowdot == 0x00001EC6 + XK_ecircumflexbelowdot == 0x00001EC7 + XKc_Ihook == 0x00001EC8 + XK_ihook == 0x00001EC9 + XKc_Ibelowdot == 0x00001ECA + XK_ibelowdot == 0x00001ECB + XKc_Obelowdot == 0x00001ECC + XK_obelowdot == 0x00001ECD + XKc_Ohook == 0x00001ECE + XK_ohook == 0x00001ECF + XKc_Ocircumflexacute == 0x00001ED0 + XK_ocircumflexacute == 0x00001ED1 + XKc_Ocircumflexgrave == 0x00001ED2 + XK_ocircumflexgrave == 0x00001ED3 + XKc_Ocircumflexhook == 0x00001ED4 + XK_ocircumflexhook == 0x00001ED5 + XKc_Ocircumflextilde == 0x00001ED6 + XK_ocircumflextilde == 0x00001ED7 + XKc_Ocircumflexbelowdot == 0x00001ED8 + XK_ocircumflexbelowdot == 0x00001ED9 + XKc_Ohornacute == 0x00001EDA + XK_ohornacute == 0x00001EDB + XKc_Ohorngrave == 0x00001EDC + XK_ohorngrave == 0x00001EDD + XKc_Ohornhook == 0x00001EDE + XK_ohornhook == 0x00001EDF + XKc_Ohorntilde == 0x00001EE0 + XK_ohorntilde == 0x00001EE1 + XKc_Ohornbelowdot == 0x00001EE2 + XK_ohornbelowdot == 0x00001EE3 + XKc_Ubelowdot == 0x00001EE4 + XK_ubelowdot == 0x00001EE5 + XKc_Uhook == 0x00001EE6 + XK_uhook == 0x00001EE7 + XKc_Uhornacute == 0x00001EE8 + XK_uhornacute == 0x00001EE9 + XKc_Uhorngrave == 0x00001EEA + XK_uhorngrave == 0x00001EEB + XKc_Uhornhook == 0x00001EEC + XK_uhornhook == 0x00001EED + XKc_Uhorntilde == 0x00001EEE + XK_uhorntilde == 0x00001EEF + XKc_Uhornbelowdot == 0x00001EF0 + XK_uhornbelowdot == 0x00001EF1 + XKc_Ybelowdot == 0x00001EF4 + XK_ybelowdot == 0x00001EF5 + XKc_Yhook == 0x00001EF6 + XK_yhook == 0x00001EF7 + XKc_Ytilde == 0x00001EF8 + XK_ytilde == 0x00001EF9 + XKc_Ohorn == 0x00001EFA # U+01a0 + XK_ohorn == 0x00001EFB # U+01a1 + XKc_Uhorn == 0x00001EFC # U+01af + XK_uhorn == 0x00001EFD # U+01b0 + XK_combining_tilde == 0x00001E9F # U+0303 + XK_combining_grave == 0x00001EF2 # U+0300 + XK_combining_acute == 0x00001EF3 # U+0301 + XK_combining_hook == 0x00001EFE # U+0309 + XK_combining_belowdot == 0x00001EFF # U+0323 +# XK_VIETNAMESE + +when defined(XK_CURRENCY): + XK_EcuSign == 0x000020A0 + XK_ColonSign == 0x000020A1 + XK_CruzeiroSign == 0x000020A2 + XK_FFrancSign == 0x000020A3 + XK_LiraSign == 0x000020A4 + XK_MillSign == 0x000020A5 + XK_NairaSign == 0x000020A6 + XK_PesetaSign == 0x000020A7 + XK_RupeeSign == 0x000020A8 + XK_WonSign == 0x000020A9 + XK_NewSheqelSign == 0x000020AA + XK_DongSign == 0x000020AB + XK_EuroSign == 0x000020AC +# implementation diff --git a/lib/base/x11/x.nim b/lib/base/x11/x.nim new file mode 100644 index 000000000..aa6e7f821 --- /dev/null +++ b/lib/base/x11/x.nim @@ -0,0 +1,399 @@ + +# +# Automatically converted by H2Pas 0.99.15 from x.h +# The following command line parameters were used: +# -p +# -T +# -S +# -d +# -c +# x.h +# +# Pointers to basic pascal types, inserted by h2pas conversion program. + +const + X_PROTOCOL* = 11 + X_PROTOCOL_REVISION* = 0 + +type + culong* = int + cuchar* = char + PXID* = ptr TXID + TXID* = culong + PMask* = ptr TMask + TMask* = culong + PPAtom* = ptr PAtom + PAtom* = ptr TAtom + TAtom* = culong + PVisualID* = ptr TVisualID + TVisualID* = culong + PTime* = ptr TTime + TTime* = culong + PPWindow* = ptr PWindow + PWindow* = ptr TWindow + TWindow* = TXID + PDrawable* = ptr TDrawable + TDrawable* = TXID + PFont* = ptr TFont + TFont* = TXID + PPixmap* = ptr TPixmap + TPixmap* = TXID + PCursor* = ptr TCursor + TCursor* = TXID + PColormap* = ptr TColormap + TColormap* = TXID + PGContext* = ptr TGContext + TGContext* = TXID + PKeySym* = ptr TKeySym + TKeySym* = TXID + PKeyCode* = ptr TKeyCode + TKeyCode* = cuchar + +const + None* = 0 + ParentRelative* = 1 + CopyFromParent* = 0 + PointerWindow* = 0 + InputFocus* = 1 + PointerRoot* = 1 + AnyPropertyType* = 0 + AnyKey* = 0 + AnyButton* = 0 + AllTemporary* = 0 + CurrentTime* = 0 + NoSymbol* = 0 + NoEventMask* = 0 + KeyPressMask* = 1 shl 0 + KeyReleaseMask* = 1 shl 1 + ButtonPressMask* = 1 shl 2 + ButtonReleaseMask* = 1 shl 3 + EnterWindowMask* = 1 shl 4 + LeaveWindowMask* = 1 shl 5 + PointerMotionMask* = 1 shl 6 + PointerMotionHintMask* = 1 shl 7 + Button1MotionMask* = 1 shl 8 + Button2MotionMask* = 1 shl 9 + Button3MotionMask* = 1 shl 10 + Button4MotionMask* = 1 shl 11 + Button5MotionMask* = 1 shl 12 + ButtonMotionMask* = 1 shl 13 + KeymapStateMask* = 1 shl 14 + ExposureMask* = 1 shl 15 + VisibilityChangeMask* = 1 shl 16 + StructureNotifyMask* = 1 shl 17 + ResizeRedirectMask* = 1 shl 18 + SubstructureNotifyMask* = 1 shl 19 + SubstructureRedirectMask* = 1 shl 20 + FocusChangeMask* = 1 shl 21 + PropertyChangeMask* = 1 shl 22 + ColormapChangeMask* = 1 shl 23 + OwnerGrabButtonMask* = 1 shl 24 + KeyPress* = 2 + KeyRelease* = 3 + ButtonPress* = 4 + ButtonRelease* = 5 + MotionNotify* = 6 + EnterNotify* = 7 + LeaveNotify* = 8 + FocusIn* = 9 + FocusOut* = 10 + KeymapNotify* = 11 + Expose* = 12 + GraphicsExpose* = 13 + NoExpose* = 14 + VisibilityNotify* = 15 + CreateNotify* = 16 + DestroyNotify* = 17 + UnmapNotify* = 18 + MapNotify* = 19 + MapRequest* = 20 + ReparentNotify* = 21 + ConfigureNotify* = 22 + ConfigureRequest* = 23 + GravityNotify* = 24 + ResizeRequest* = 25 + CirculateNotify* = 26 + CirculateRequest* = 27 + PropertyNotify* = 28 + SelectionClear* = 29 + SelectionRequest* = 30 + SelectionNotify* = 31 + ColormapNotify* = 32 + ClientMessage* = 33 + MappingNotify* = 34 + LASTEvent* = 35 + ShiftMask* = 1 shl 0 + LockMask* = 1 shl 1 + ControlMask* = 1 shl 2 + Mod1Mask* = 1 shl 3 + Mod2Mask* = 1 shl 4 + Mod3Mask* = 1 shl 5 + Mod4Mask* = 1 shl 6 + Mod5Mask* = 1 shl 7 + ShiftMapIndex* = 0 + LockMapIndex* = 1 + ControlMapIndex* = 2 + Mod1MapIndex* = 3 + Mod2MapIndex* = 4 + Mod3MapIndex* = 5 + Mod4MapIndex* = 6 + Mod5MapIndex* = 7 + Button1Mask* = 1 shl 8 + Button2Mask* = 1 shl 9 + Button3Mask* = 1 shl 10 + Button4Mask* = 1 shl 11 + Button5Mask* = 1 shl 12 + AnyModifier* = 1 shl 15 + Button1* = 1 + Button2* = 2 + Button3* = 3 + Button4* = 4 + Button5* = 5 + NotifyNormal* = 0 + NotifyGrab* = 1 + NotifyUngrab* = 2 + NotifyWhileGrabbed* = 3 + NotifyHint* = 1 + NotifyAncestor* = 0 + NotifyVirtual* = 1 + NotifyInferior* = 2 + NotifyNonlinear* = 3 + NotifyNonlinearVirtual* = 4 + NotifyPointer* = 5 + NotifyPointerRoot* = 6 + NotifyDetailNone* = 7 + VisibilityUnobscured* = 0 + VisibilityPartiallyObscured* = 1 + VisibilityFullyObscured* = 2 + PlaceOnTop* = 0 + PlaceOnBottom* = 1 + FamilyInternet* = 0 + FamilyDECnet* = 1 + FamilyChaos* = 2 + FamilyInternet6* = 6 + FamilyServerInterpreted* = 5 + PropertyNewValue* = 0 + PropertyDelete* = 1 + ColormapUninstalled* = 0 + ColormapInstalled* = 1 + GrabModeSync* = 0 + GrabModeAsync* = 1 + GrabSuccess* = 0 + AlreadyGrabbed* = 1 + GrabInvalidTime* = 2 + GrabNotViewable* = 3 + GrabFrozen* = 4 + AsyncPointer* = 0 + SyncPointer* = 1 + ReplayPointer* = 2 + AsyncKeyboard* = 3 + SyncKeyboard* = 4 + ReplayKeyboard* = 5 + AsyncBoth* = 6 + SyncBoth* = 7 + RevertToNone* = None + RevertToPointerRoot* = PointerRoot + RevertToParent* = 2 + Success* = 0 + BadRequest* = 1 + BadValue* = 2 + BadWindow* = 3 + BadPixmap* = 4 + BadAtom* = 5 + BadCursor* = 6 + BadFont* = 7 + BadMatch* = 8 + BadDrawable* = 9 + BadAccess* = 10 + BadAlloc* = 11 + BadColor* = 12 + BadGC* = 13 + BadIDChoice* = 14 + BadName* = 15 + BadLength* = 16 + BadImplementation* = 17 + FirstExtensionError* = 128 + LastExtensionError* = 255 + InputOutput* = 1 + InputOnly* = 2 + CWBackPixmap* = 1 shl 0 + CWBackPixel* = 1 shl 1 + CWBorderPixmap* = 1 shl 2 + CWBorderPixel* = 1 shl 3 + CWBitGravity* = 1 shl 4 + CWWinGravity* = 1 shl 5 + CWBackingStore* = 1 shl 6 + CWBackingPlanes* = 1 shl 7 + CWBackingPixel* = 1 shl 8 + CWOverrideRedirect* = 1 shl 9 + CWSaveUnder* = 1 shl 10 + CWEventMask* = 1 shl 11 + CWDontPropagate* = 1 shl 12 + CWColormap* = 1 shl 13 + CWCursor* = 1 shl 14 + CWX* = 1 shl 0 + CWY* = 1 shl 1 + CWWidth* = 1 shl 2 + CWHeight* = 1 shl 3 + CWBorderWidth* = 1 shl 4 + CWSibling* = 1 shl 5 + CWStackMode* = 1 shl 6 + ForgetGravity* = 0 + NorthWestGravity* = 1 + NorthGravity* = 2 + NorthEastGravity* = 3 + WestGravity* = 4 + CenterGravity* = 5 + EastGravity* = 6 + SouthWestGravity* = 7 + SouthGravity* = 8 + SouthEastGravity* = 9 + StaticGravity* = 10 + UnmapGravity* = 0 + NotUseful* = 0 + WhenMapped* = 1 + Always* = 2 + IsUnmapped* = 0 + IsUnviewable* = 1 + IsViewable* = 2 + SetModeInsert* = 0 + SetModeDelete* = 1 + DestroyAll* = 0 + RetainPermanent* = 1 + RetainTemporary* = 2 + Above* = 0 + Below* = 1 + TopIf* = 2 + BottomIf* = 3 + Opposite* = 4 + RaiseLowest* = 0 + LowerHighest* = 1 + PropModeReplace* = 0 + PropModePrepend* = 1 + PropModeAppend* = 2 + GXclear* = 0x00000000 + GXand* = 0x00000001 + GXandReverse* = 0x00000002 + GXcopy* = 0x00000003 + GXandInverted* = 0x00000004 + GXnoop* = 0x00000005 + GXxor* = 0x00000006 + GXor* = 0x00000007 + GXnor* = 0x00000008 + GXequiv* = 0x00000009 + GXinvert* = 0x0000000A + GXorReverse* = 0x0000000B + GXcopyInverted* = 0x0000000C + GXorInverted* = 0x0000000D + GXnand* = 0x0000000E + GXset* = 0x0000000F + LineSolid* = 0 + LineOnOffDash* = 1 + LineDoubleDash* = 2 + CapNotLast* = 0 + CapButt* = 1 + CapRound* = 2 + CapProjecting* = 3 + JoinMiter* = 0 + JoinRound* = 1 + JoinBevel* = 2 + FillSolid* = 0 + FillTiled* = 1 + FillStippled* = 2 + FillOpaqueStippled* = 3 + EvenOddRule* = 0 + WindingRule* = 1 + ClipByChildren* = 0 + IncludeInferiors* = 1 + Unsorted* = 0 + YSorted* = 1 + YXSorted* = 2 + YXBanded* = 3 + CoordModeOrigin* = 0 + CoordModePrevious* = 1 + Complex* = 0 + Nonconvex* = 1 + Convex* = 2 + ArcChord* = 0 + ArcPieSlice* = 1 + GCFunction* = 1 shl 0 + GCPlaneMask* = 1 shl 1 + GCForeground* = 1 shl 2 + GCBackground* = 1 shl 3 + GCLineWidth* = 1 shl 4 + GCLineStyle* = 1 shl 5 + GCCapStyle* = 1 shl 6 + GCJoinStyle* = 1 shl 7 + GCFillStyle* = 1 shl 8 + GCFillRule* = 1 shl 9 + GCTile* = 1 shl 10 + GCStipple* = 1 shl 11 + GCTileStipXOrigin* = 1 shl 12 + GCTileStipYOrigin* = 1 shl 13 + GCFont* = 1 shl 14 + GCSubwindowMode* = 1 shl 15 + GCGraphicsExposures* = 1 shl 16 + GCClipXOrigin* = 1 shl 17 + GCClipYOrigin* = 1 shl 18 + GCClipMask* = 1 shl 19 + GCDashOffset* = 1 shl 20 + GCDashList* = 1 shl 21 + GCArcMode* = 1 shl 22 + GCLastBit* = 22 + FontLeftToRight* = 0 + FontRightToLeft* = 1 + FontChange* = 255 + XYBitmap* = 0 + XYPixmap* = 1 + ZPixmap* = 2 + AllocNone* = 0 + AllocAll* = 1 + DoRed* = 1 shl 0 + DoGreen* = 1 shl 1 + DoBlue* = 1 shl 2 + CursorShape* = 0 + TileShape* = 1 + StippleShape* = 2 + AutoRepeatModeOff* = 0 + AutoRepeatModeOn* = 1 + AutoRepeatModeDefault* = 2 + LedModeOff* = 0 + LedModeOn* = 1 + KBKeyClickPercent* = 1 shl 0 + KBBellPercent* = 1 shl 1 + KBBellPitch* = 1 shl 2 + KBBellDuration* = 1 shl 3 + KBLed* = 1 shl 4 + KBLedMode* = 1 shl 5 + KBKey* = 1 shl 6 + KBAutoRepeatMode* = 1 shl 7 + MappingSuccess* = 0 + MappingBusy* = 1 + MappingFailed* = 2 + MappingModifier* = 0 + MappingKeyboard* = 1 + MappingPointer* = 2 + DontPreferBlanking* = 0 + PreferBlanking* = 1 + DefaultBlanking* = 2 + DisableScreenSaver* = 0 + DisableScreenInterval* = 0 + DontAllowExposures* = 0 + AllowExposures* = 1 + DefaultExposures* = 2 + ScreenSaverReset* = 0 + ScreenSaverActive* = 1 + HostInsert* = 0 + HostDelete* = 1 + EnableAccess* = 1 + DisableAccess* = 0 + StaticGray* = 0 + GrayScale* = 1 + StaticColor* = 2 + PseudoColor* = 3 + TrueColor* = 4 + DirectColor* = 5 + LSBFirst* = 0 + MSBFirst* = 1 + +# implementation diff --git a/lib/base/x11/xatom.nim b/lib/base/x11/xatom.nim new file mode 100644 index 000000000..b2e1dca91 --- /dev/null +++ b/lib/base/x11/xatom.nim @@ -0,0 +1,81 @@ +# +# THIS IS A GENERATED FILE +# +# Do not change! Changing this file implies a protocol change! +# + +import + X + +const + XA_PRIMARY* = TAtom(1) + XA_SECONDARY* = TAtom(2) + XA_ARC* = TAtom(3) + XA_ATOM* = TAtom(4) + XA_BITMAP* = TAtom(5) + XA_CARDINAL* = TAtom(6) + XA_COLORMAP* = TAtom(7) + XA_CURSOR* = TAtom(8) + XA_CUT_BUFFER0* = TAtom(9) + XA_CUT_BUFFER1* = TAtom(10) + XA_CUT_BUFFER2* = TAtom(11) + XA_CUT_BUFFER3* = TAtom(12) + XA_CUT_BUFFER4* = TAtom(13) + XA_CUT_BUFFER5* = TAtom(14) + XA_CUT_BUFFER6* = TAtom(15) + XA_CUT_BUFFER7* = TAtom(16) + XA_DRAWABLE* = TAtom(17) + XA_FONT* = TAtom(18) + XA_INTEGER* = TAtom(19) + XA_PIXMAP* = TAtom(20) + XA_POINT* = TAtom(21) + XA_RECTANGLE* = TAtom(22) + XA_RESOURCE_MANAGER* = TAtom(23) + XA_RGB_COLOR_MAP* = TAtom(24) + XA_RGB_BEST_MAP* = TAtom(25) + XA_RGB_BLUE_MAP* = TAtom(26) + XA_RGB_DEFAULT_MAP* = TAtom(27) + XA_RGB_GRAY_MAP* = TAtom(28) + XA_RGB_GREEN_MAP* = TAtom(29) + XA_RGB_RED_MAP* = TAtom(30) + XA_STRING* = TAtom(31) + XA_VISUALID* = TAtom(32) + XA_WINDOW* = TAtom(33) + XA_WM_COMMAND* = TAtom(34) + XA_WM_HINTS* = TAtom(35) + XA_WM_CLIENT_MACHINE* = TAtom(36) + XA_WM_ICON_NAME* = TAtom(37) + XA_WM_ICON_SIZE* = TAtom(38) + XA_WM_NAME* = TAtom(39) + XA_WM_NORMAL_HINTS* = TAtom(40) + XA_WM_SIZE_HINTS* = TAtom(41) + XA_WM_ZOOM_HINTS* = TAtom(42) + XA_MIN_SPACE* = TAtom(43) + XA_NORM_SPACE* = TAtom(44) + XA_MAX_SPACE* = TAtom(45) + XA_END_SPACE* = TAtom(46) + XA_SUPERSCRIPT_X* = TAtom(47) + XA_SUPERSCRIPT_Y* = TAtom(48) + XA_SUBSCRIPT_X* = TAtom(49) + XA_SUBSCRIPT_Y* = TAtom(50) + XA_UNDERLINE_POSITION* = TAtom(51) + XA_UNDERLINE_THICKNESS* = TAtom(52) + XA_STRIKEOUT_ASCENT* = TAtom(53) + XA_STRIKEOUT_DESCENT* = TAtom(54) + XA_ITALIC_ANGLE* = TAtom(55) + XA_X_HEIGHT* = TAtom(56) + XA_QUAD_WIDTH* = TAtom(57) + XA_WEIGHT* = TAtom(58) + XA_POINT_SIZE* = TAtom(59) + XA_RESOLUTION* = TAtom(60) + XA_COPYRIGHT* = TAtom(61) + XA_NOTICE* = TAtom(62) + XA_FONT_NAME* = TAtom(63) + XA_FAMILY_NAME* = TAtom(64) + XA_FULL_NAME* = TAtom(65) + XA_CAP_HEIGHT* = TAtom(66) + XA_WM_CLASS* = TAtom(67) + XA_WM_TRANSIENT_FOR* = TAtom(68) + XA_LAST_PREDEFINED* = TAtom(68) + +# implementation diff --git a/lib/base/x11/xcms.nim b/lib/base/x11/xcms.nim new file mode 100644 index 000000000..ab535ffc3 --- /dev/null +++ b/lib/base/x11/xcms.nim @@ -0,0 +1,396 @@ + +import + x, xlib + +#const +# libX11* = "X11" + +# +# Automatically converted by H2Pas 0.99.15 from xcms.h +# The following command line parameters were used: +# -p +# -T +# -S +# -d +# -c +# xcms.h +# + +const + XcmsFailure* = 0 + XcmsSuccess* = 1 + XcmsSuccessWithCompression* = 2 + +type + PXcmsColorFormat* = ptr TXcmsColorFormat + TXcmsColorFormat* = int32 + +proc XcmsUndefinedFormat*(): TXcmsColorFormat +proc XcmsCIEXYZFormat*(): TXcmsColorFormat +proc XcmsCIEuvYFormat*(): TXcmsColorFormat +proc XcmsCIExyYFormat*(): TXcmsColorFormat +proc XcmsCIELabFormat*(): TXcmsColorFormat +proc XcmsCIELuvFormat*(): TXcmsColorFormat +proc XcmsTekHVCFormat*(): TXcmsColorFormat +proc XcmsRGBFormat*(): TXcmsColorFormat +proc XcmsRGBiFormat*(): TXcmsColorFormat +const + XcmsInitNone* = 0x00000000 + XcmsInitSuccess* = 0x00000001 + XcmsInitFailure* = 0x000000FF + +when defined(MACROS): + proc DisplayOfCCC*(ccc: int32): int32 + proc ScreenNumberOfCCC*(ccc: int32): int32 + proc VisualOfCCC*(ccc: int32): int32 + proc ClientWhitePointOfCCC*(ccc: int32): int32 + proc ScreenWhitePointOfCCC*(ccc: int32): int32 + proc FunctionSetOfCCC*(ccc: int32): int32 +type + PXcmsFloat* = ptr TXcmsFloat + TXcmsFloat* = float64 + PXcmsRGB* = ptr TXcmsRGB + TXcmsRGB*{.final.} = object + red*: int16 + green*: int16 + blue*: int16 + + PXcmsRGBi* = ptr TXcmsRGBi + TXcmsRGBi*{.final.} = object + red*: TXcmsFloat + green*: TXcmsFloat + blue*: TXcmsFloat + + PXcmsCIEXYZ* = ptr TXcmsCIEXYZ + TXcmsCIEXYZ*{.final.} = object + X*: TXcmsFloat + Y*: TXcmsFloat + Z*: TXcmsFloat + + PXcmsCIEuvY* = ptr TXcmsCIEuvY + TXcmsCIEuvY*{.final.} = object + u_prime*: TXcmsFloat + v_prime*: TXcmsFloat + Y*: TXcmsFloat + + PXcmsCIExyY* = ptr TXcmsCIExyY + TXcmsCIExyY*{.final.} = object + x*: TXcmsFloat + y*: TXcmsFloat + theY*: TXcmsFloat + + PXcmsCIELab* = ptr TXcmsCIELab + TXcmsCIELab*{.final.} = object + L_star*: TXcmsFloat + a_star*: TXcmsFloat + b_star*: TXcmsFloat + + PXcmsCIELuv* = ptr TXcmsCIELuv + TXcmsCIELuv*{.final.} = object + L_star*: TXcmsFloat + u_star*: TXcmsFloat + v_star*: TXcmsFloat + + PXcmsTekHVC* = ptr TXcmsTekHVC + TXcmsTekHVC*{.final.} = object + H*: TXcmsFloat + V*: TXcmsFloat + C*: TXcmsFloat + + PXcmsPad* = ptr TXcmsPad + TXcmsPad*{.final.} = object + pad0*: TXcmsFloat + pad1*: TXcmsFloat + pad2*: TXcmsFloat + pad3*: TXcmsFloat + + PXcmsColor* = ptr TXcmsColor + TXcmsColor*{.final.} = object # spec : record + # case longint of + # 0 : ( RGB : TXcmsRGB ); + # 1 : ( RGBi : TXcmsRGBi ); + # 2 : ( CIEXYZ : TXcmsCIEXYZ ); + # 3 : ( CIEuvY : TXcmsCIEuvY ); + # 4 : ( CIExyY : TXcmsCIExyY ); + # 5 : ( CIELab : TXcmsCIELab ); + # 6 : ( CIELuv : TXcmsCIELuv ); + # 7 : ( TekHVC : TXcmsTekHVC ); + # 8 : ( Pad : TXcmsPad ); + # end; + pad*: TXcmsPad + pixel*: int32 + format*: TXcmsColorFormat + + PXcmsPerScrnInfo* = ptr TXcmsPerScrnInfo + TXcmsPerScrnInfo*{.final.} = object + screenWhitePt*: TXcmsColor + functionSet*: TXPointer + screenData*: TXPointer + state*: int8 + pad*: array[0..2, char] + + PXcmsCCC* = ptr TXcmsCCC + TXcmsCompressionProc* = proc (para1: PXcmsCCC, para2: PXcmsColor, + para3: int32, para4: int32, para5: PBool): TStatus{. + cdecl.} + TXcmsWhiteAdjustProc* = proc (para1: PXcmsCCC, para2: PXcmsColor, + para3: PXcmsColor, para4: TXcmsColorFormat, + para5: PXcmsColor, para6: int32, para7: PBool): TStatus{. + cdecl.} + TXcmsCCC*{.final.} = object + dpy*: PDisplay + screenNumber*: int32 + visual*: PVisual + clientWhitePt*: TXcmsColor + gamutCompProc*: TXcmsCompressionProc + gamutCompClientData*: TXPointer + whitePtAdjProc*: TXcmsWhiteAdjustProc + whitePtAdjClientData*: TXPointer + pPerScrnInfo*: PXcmsPerScrnInfo + + TXcmsCCCRec* = TXcmsCCC + PXcmsCCCRec* = ptr TXcmsCCCRec + TXcmsScreenInitProc* = proc (para1: PDisplay, para2: int32, + para3: PXcmsPerScrnInfo): TStatus{.cdecl.} + TXcmsScreenFreeProc* = proc (para1: TXPointer){.cdecl.} + TXcmsConversionProc* = proc (){.cdecl.} + PXcmsFuncListPtr* = ptr TXcmsFuncListPtr + TXcmsFuncListPtr* = TXcmsConversionProc + TXcmsParseStringProc* = proc (para1: cstring, para2: PXcmsColor): int32{.cdecl.} + PXcmsColorSpace* = ptr TXcmsColorSpace + TXcmsColorSpace*{.final.} = object + prefix*: cstring + id*: TXcmsColorFormat + parseString*: TXcmsParseStringProc + to_CIEXYZ*: TXcmsFuncListPtr + from_CIEXYZ*: TXcmsFuncListPtr + inverse_flag*: int32 + + PXcmsFunctionSet* = ptr TXcmsFunctionSet + TXcmsFunctionSet*{.final.} = object # error + #extern Status XcmsAddColorSpace ( + #in declaration at line 323 + DDColorSpaces*: ptr PXcmsColorSpace + screenInitProc*: TXcmsScreenInitProc + screenFreeProc*: TXcmsScreenFreeProc + + +proc XcmsAddFunctionSet*(para1: PXcmsFunctionSet): TStatus{.cdecl, + dynlib: libX11, importc.} +proc XcmsAllocColor*(para1: PDisplay, para2: TColormap, para3: PXcmsColor, + para4: TXcmsColorFormat): TStatus{.cdecl, dynlib: libX11, + importc.} +proc XcmsAllocNamedColor*(para1: PDisplay, para2: TColormap, para3: cstring, + para4: PXcmsColor, para5: PXcmsColor, + para6: TXcmsColorFormat): TStatus{.cdecl, + dynlib: libX11, importc.} +proc XcmsCCCOfColormap*(para1: PDisplay, para2: TColormap): TXcmsCCC{.cdecl, + dynlib: libX11, importc.} +proc XcmsCIELabClipab*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, + para4: int32, para5: PBool): TStatus{.cdecl, + dynlib: libX11, importc.} +proc XcmsCIELabClipL*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, + para4: int32, para5: PBool): TStatus{.cdecl, + dynlib: libX11, importc.} +proc XcmsCIELabClipLab*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, + para4: int32, para5: PBool): TStatus{.cdecl, + dynlib: libX11, importc.} +proc XcmsCIELabQueryMaxC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat, + para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11, + importc.} +proc XcmsCIELabQueryMaxL*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat, + para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11, + importc.} +proc XcmsCIELabQueryMaxLC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: PXcmsColor): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XcmsCIELabQueryMinL*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat, + para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11, + importc.} +proc XcmsCIELabToCIEXYZ*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, + para4: int32): TStatus{.cdecl, dynlib: libX11, importc.} +proc XcmsCIELabWhiteShiftColors*(para1: TXcmsCCC, para2: PXcmsColor, + para3: PXcmsColor, para4: TXcmsColorFormat, + para5: PXcmsColor, para6: int32, para7: PBool): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XcmsCIELuvClipL*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, + para4: int32, para5: PBool): TStatus{.cdecl, + dynlib: libX11, importc.} +proc XcmsCIELuvClipLuv*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, + para4: int32, para5: PBool): TStatus{.cdecl, + dynlib: libX11, importc.} +proc XcmsCIELuvClipuv*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, + para4: int32, para5: PBool): TStatus{.cdecl, + dynlib: libX11, importc.} +proc XcmsCIELuvQueryMaxC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat, + para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11, + importc.} +proc XcmsCIELuvQueryMaxL*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat, + para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11, + importc.} +proc XcmsCIELuvQueryMaxLC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: PXcmsColor): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XcmsCIELuvQueryMinL*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat, + para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11, + importc.} +proc XcmsCIELuvToCIEuvY*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, + para4: int32): TStatus{.cdecl, dynlib: libX11, importc.} +proc XcmsCIELuvWhiteShiftColors*(para1: TXcmsCCC, para2: PXcmsColor, + para3: PXcmsColor, para4: TXcmsColorFormat, + para5: PXcmsColor, para6: int32, para7: PBool): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XcmsCIEXYZToCIELab*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, + para4: int32): TStatus{.cdecl, dynlib: libX11, importc.} +proc XcmsCIEXYZToCIEuvY*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, + para4: int32): TStatus{.cdecl, dynlib: libX11, importc.} +proc XcmsCIEXYZToCIExyY*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, + para4: int32): TStatus{.cdecl, dynlib: libX11, importc.} +proc XcmsCIEXYZToRGBi*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, + para4: PBool): TStatus{.cdecl, dynlib: libX11, importc.} +proc XcmsCIEuvYToCIELuv*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, + para4: int32): TStatus{.cdecl, dynlib: libX11, importc.} +proc XcmsCIEuvYToCIEXYZ*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, + para4: int32): TStatus{.cdecl, dynlib: libX11, importc.} +proc XcmsCIEuvYToTekHVC*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, + para4: int32): TStatus{.cdecl, dynlib: libX11, importc.} +proc XcmsCIExyYToCIEXYZ*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, + para4: int32): TStatus{.cdecl, dynlib: libX11, importc.} +proc XcmsClientWhitePointOfCCC*(para1: TXcmsCCC): PXcmsColor{.cdecl, + dynlib: libX11, importc.} +proc XcmsConvertColors*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, + para4: TXcmsColorFormat, para5: PBool): TStatus{.cdecl, + dynlib: libX11, importc.} +proc XcmsCreateCCC*(para1: PDisplay, para2: int32, para3: PVisual, + para4: PXcmsColor, para5: TXcmsCompressionProc, + para6: TXPointer, para7: TXcmsWhiteAdjustProc, + para8: TXPointer): TXcmsCCC{.cdecl, dynlib: libX11, importc.} +proc XcmsDefaultCCC*(para1: PDisplay, para2: int32): TXcmsCCC{.cdecl, + dynlib: libX11, importc.} +proc XcmsDisplayOfCCC*(para1: TXcmsCCC): PDisplay{.cdecl, dynlib: libX11, + importc.} +proc XcmsFormatOfPrefix*(para1: cstring): TXcmsColorFormat{.cdecl, + dynlib: libX11, importc.} +proc XcmsFreeCCC*(para1: TXcmsCCC){.cdecl, dynlib: libX11, importc.} +proc XcmsLookupColor*(para1: PDisplay, para2: TColormap, para3: cstring, + para4: PXcmsColor, para5: PXcmsColor, + para6: TXcmsColorFormat): TStatus{.cdecl, dynlib: libX11, + importc.} +proc XcmsPrefixOfFormat*(para1: TXcmsColorFormat): cstring{.cdecl, + dynlib: libX11, importc.} +proc XcmsQueryBlack*(para1: TXcmsCCC, para2: TXcmsColorFormat, para3: PXcmsColor): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XcmsQueryBlue*(para1: TXcmsCCC, para2: TXcmsColorFormat, para3: PXcmsColor): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XcmsQueryColor*(para1: PDisplay, para2: TColormap, para3: PXcmsColor, + para4: TXcmsColorFormat): TStatus{.cdecl, dynlib: libX11, + importc.} +proc XcmsQueryColors*(para1: PDisplay, para2: TColormap, para3: PXcmsColor, + para4: int32, para5: TXcmsColorFormat): TStatus{.cdecl, + dynlib: libX11, importc.} +proc XcmsQueryGreen*(para1: TXcmsCCC, para2: TXcmsColorFormat, para3: PXcmsColor): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XcmsQueryRed*(para1: TXcmsCCC, para2: TXcmsColorFormat, para3: PXcmsColor): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XcmsQueryWhite*(para1: TXcmsCCC, para2: TXcmsColorFormat, para3: PXcmsColor): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XcmsRGBiToCIEXYZ*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, + para4: PBool): TStatus{.cdecl, dynlib: libX11, importc.} +proc XcmsRGBiToRGB*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, + para4: PBool): TStatus{.cdecl, dynlib: libX11, importc.} +proc XcmsRGBToRGBi*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, + para4: PBool): TStatus{.cdecl, dynlib: libX11, importc.} +proc XcmsScreenNumberOfCCC*(para1: TXcmsCCC): int32{.cdecl, dynlib: libX11, + importc.} +proc XcmsScreenWhitePointOfCCC*(para1: TXcmsCCC): PXcmsColor{.cdecl, + dynlib: libX11, importc.} +proc XcmsSetCCCOfColormap*(para1: PDisplay, para2: TColormap, para3: TXcmsCCC): TXcmsCCC{. + cdecl, dynlib: libX11, importc.} +proc XcmsSetCompressionProc*(para1: TXcmsCCC, para2: TXcmsCompressionProc, + para3: TXPointer): TXcmsCompressionProc{.cdecl, + dynlib: libX11, importc.} +proc XcmsSetWhiteAdjustProc*(para1: TXcmsCCC, para2: TXcmsWhiteAdjustProc, + para3: TXPointer): TXcmsWhiteAdjustProc{.cdecl, + dynlib: libX11, importc.} +proc XcmsSetWhitePoint*(para1: TXcmsCCC, para2: PXcmsColor): TStatus{.cdecl, + dynlib: libX11, importc.} +proc XcmsStoreColor*(para1: PDisplay, para2: TColormap, para3: PXcmsColor): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XcmsStoreColors*(para1: PDisplay, para2: TColormap, para3: PXcmsColor, + para4: int32, para5: PBool): TStatus{.cdecl, + dynlib: libX11, importc.} +proc XcmsTekHVCClipC*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, + para4: int32, para5: PBool): TStatus{.cdecl, + dynlib: libX11, importc.} +proc XcmsTekHVCClipV*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, + para4: int32, para5: PBool): TStatus{.cdecl, + dynlib: libX11, importc.} +proc XcmsTekHVCClipVC*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32, + para4: int32, para5: PBool): TStatus{.cdecl, + dynlib: libX11, importc.} +proc XcmsTekHVCQueryMaxC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat, + para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11, + importc.} +proc XcmsTekHVCQueryMaxV*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat, + para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11, + importc.} +proc XcmsTekHVCQueryMaxVC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: PXcmsColor): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XcmsTekHVCQueryMaxVSamples*(para1: TXcmsCCC, para2: TXcmsFloat, + para3: PXcmsColor, para4: int32): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XcmsTekHVCQueryMinV*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat, + para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11, + importc.} +proc XcmsTekHVCToCIEuvY*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor, + para4: int32): TStatus{.cdecl, dynlib: libX11, importc.} +proc XcmsTekHVCWhiteShiftColors*(para1: TXcmsCCC, para2: PXcmsColor, + para3: PXcmsColor, para4: TXcmsColorFormat, + para5: PXcmsColor, para6: int32, para7: PBool): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XcmsVisualOfCCC*(para1: TXcmsCCC): PVisual{.cdecl, dynlib: libX11, importc.} +# implementation + +proc XcmsUndefinedFormat(): TXcmsColorFormat = + result = TXcmsColorFormat(0x00000000) + +proc XcmsCIEXYZFormat(): TXcmsColorFormat = + result = TXcmsColorFormat(0x00000001) + +proc XcmsCIEuvYFormat(): TXcmsColorFormat = + result = TXcmsColorFormat(0x00000002) + +proc XcmsCIExyYFormat(): TXcmsColorFormat = + result = TXcmsColorFormat(0x00000003) + +proc XcmsCIELabFormat(): TXcmsColorFormat = + result = TXcmsColorFormat(0x00000004) + +proc XcmsCIELuvFormat(): TXcmsColorFormat = + result = TXcmsColorFormat(0x00000005) + +proc XcmsTekHVCFormat(): TXcmsColorFormat = + result = TXcmsColorFormat(0x00000006) + +proc XcmsRGBFormat(): TXcmsColorFormat = + result = TXcmsColorFormat(0x80000000) + +proc XcmsRGBiFormat(): TXcmsColorFormat = + result = TXcmsColorFormat(0x80000001) + +when defined(MACROS): + proc DisplayOfCCC(ccc: int32): int32 = + result = ccc.dpy + + proc ScreenNumberOfCCC(ccc: int32): int32 = + result = ccc.screenNumber + + proc VisualOfCCC(ccc: int32): int32 = + result = ccc.visual + + proc ClientWhitePointOfCCC(ccc: int32): int32 = + result = addr(ccc.clientWhitePt) + + proc ScreenWhitePointOfCCC(ccc: int32): int32 = + result = addr(ccc.pPerScrnInfo.screenWhitePt) + + proc FunctionSetOfCCC(ccc: int32): int32 = + result = ccc.pPerScrnInfo.functionSet diff --git a/lib/base/x11/xf86dga.nim b/lib/base/x11/xf86dga.nim new file mode 100644 index 000000000..376f11861 --- /dev/null +++ b/lib/base/x11/xf86dga.nim @@ -0,0 +1,235 @@ +# +# Copyright (c) 1999 XFree86 Inc +# +# $XFree86: xc/include/extensions/xf86dga.h,v 3.20 1999/10/13 04:20:48 dawes Exp $ + +import + x, xlib + +const + libXxf86dga* = "libXxf86dga.so" + +#type +# cfloat* = float32 + +# $XFree86: xc/include/extensions/xf86dga1.h,v 1.2 1999/04/17 07:05:41 dawes Exp $ +# +# +#Copyright (c) 1995 Jon Tombs +#Copyright (c) 1995 XFree86 Inc +# +# +#************************************************************************ +# +# THIS IS THE OLD DGA API AND IS OBSOLETE. PLEASE DO NOT USE IT ANYMORE +# +#************************************************************************ + +type + PPcchar* = ptr ptr cstring + +const + X_XF86DGAQueryVersion* = 0 + X_XF86DGAGetVideoLL* = 1 + X_XF86DGADirectVideo* = 2 + X_XF86DGAGetViewPortSize* = 3 + X_XF86DGASetViewPort* = 4 + X_XF86DGAGetVidPage* = 5 + X_XF86DGASetVidPage* = 6 + X_XF86DGAInstallColormap* = 7 + X_XF86DGAQueryDirectVideo* = 8 + X_XF86DGAViewPortChanged* = 9 + XF86DGADirectPresent* = 0x00000001 + XF86DGADirectGraphics* = 0x00000002 + XF86DGADirectMouse* = 0x00000004 + XF86DGADirectKeyb* = 0x00000008 + XF86DGAHasColormap* = 0x00000100 + XF86DGADirectColormap* = 0x00000200 + +proc XF86DGAQueryVersion*(dpy: PDisplay, majorVersion: Pcint, + minorVersion: Pcint): TBool{.CDecl, + dynlib: libXxf86dga, importc.} +proc XF86DGAQueryExtension*(dpy: PDisplay, event_base: Pcint, error_base: Pcint): TBool{. + CDecl, dynlib: libXxf86dga, importc.} +proc XF86DGAGetVideoLL*(dpy: PDisplay, screen: cint, base_addr: Pcint, + width: Pcint, bank_size: Pcint, ram_size: Pcint): TStatus{. + CDecl, dynlib: libXxf86dga, importc.} +proc XF86DGAGetVideo*(dpy: PDisplay, screen: cint, base_addr: PPcchar, + width: Pcint, bank_size: Pcint, ram_size: Pcint): TStatus{. + CDecl, dynlib: libXxf86dga, importc.} +proc XF86DGADirectVideo*(dpy: PDisplay, screen: cint, enable: cint): TStatus{. + CDecl, dynlib: libXxf86dga, importc.} +proc XF86DGADirectVideoLL*(dpy: PDisplay, screen: cint, enable: cint): TStatus{. + CDecl, dynlib: libXxf86dga, importc.} +proc XF86DGAGetViewPortSize*(dpy: PDisplay, screen: cint, width: Pcint, + height: Pcint): TStatus{.CDecl, + dynlib: libXxf86dga, importc.} +proc XF86DGASetViewPort*(dpy: PDisplay, screen: cint, x: cint, y: cint): TStatus{. + CDecl, dynlib: libXxf86dga, importc.} +proc XF86DGAGetVidPage*(dpy: PDisplay, screen: cint, vid_page: Pcint): TStatus{. + CDecl, dynlib: libXxf86dga, importc.} +proc XF86DGASetVidPage*(dpy: PDisplay, screen: cint, vid_page: cint): TStatus{. + CDecl, dynlib: libXxf86dga, importc.} +proc XF86DGAInstallColormap*(dpy: PDisplay, screen: cint, Colormap: TColormap): TStatus{. + CDecl, dynlib: libXxf86dga, importc.} +proc XF86DGAForkApp*(screen: cint): cint{.CDecl, dynlib: libXxf86dga, importc.} +proc XF86DGAQueryDirectVideo*(dpy: PDisplay, screen: cint, flags: Pcint): TStatus{. + CDecl, dynlib: libXxf86dga, importc.} +proc XF86DGAViewPortChanged*(dpy: PDisplay, screen: cint, n: cint): TBool{. + CDecl, dynlib: libXxf86dga, importc.} +const + X_XDGAQueryVersion* = 0 # 1 through 9 are in xf86dga1.pp + # 10 and 11 are reserved to avoid conflicts with rogue DGA extensions + X_XDGAQueryModes* = 12 + X_XDGASetMode* = 13 + X_XDGASetViewport* = 14 + X_XDGAInstallColormap* = 15 + X_XDGASelectInput* = 16 + X_XDGAFillRectangle* = 17 + X_XDGACopyArea* = 18 + X_XDGACopyTransparentArea* = 19 + X_XDGAGetViewportStatus* = 20 + X_XDGASync* = 21 + X_XDGAOpenFramebuffer* = 22 + X_XDGACloseFramebuffer* = 23 + X_XDGASetClientVersion* = 24 + X_XDGAChangePixmapMode* = 25 + X_XDGACreateColormap* = 26 + XDGAConcurrentAccess* = 0x00000001 + XDGASolidFillRect* = 0x00000002 + XDGABlitRect* = 0x00000004 + XDGABlitTransRect* = 0x00000008 + XDGAPixmap* = 0x00000010 + XDGAInterlaced* = 0x00010000 + XDGADoublescan* = 0x00020000 + XDGAFlipImmediate* = 0x00000001 + XDGAFlipRetrace* = 0x00000002 + XDGANeedRoot* = 0x00000001 + XF86DGANumberEvents* = 7 + XDGAPixmapModeLarge* = 0 + XDGAPixmapModeSmall* = 1 + XF86DGAClientNotLocal* = 0 + XF86DGANoDirectVideoMode* = 1 + XF86DGAScreenNotActive* = 2 + XF86DGADirectNotActivated* = 3 + XF86DGAOperationNotSupported* = 4 + XF86DGANumberErrors* = (XF86DGAOperationNotSupported + 1) + +type + PXDGAMode* = ptr TXDGAMode + TXDGAMode*{.final.} = object + num*: cint # A unique identifier for the mode (num > 0) + name*: cstring # name of mode given in the XF86Config + verticalRefresh*: cfloat + flags*: cint # DGA_CONCURRENT_ACCESS, etc... + imageWidth*: cint # linear accessible portion (pixels) + imageHeight*: cint + pixmapWidth*: cint # Xlib accessible portion (pixels) + pixmapHeight*: cint # both fields ignored if no concurrent access + bytesPerScanline*: cint + byteOrder*: cint # MSBFirst, LSBFirst + depth*: cint + bitsPerPixel*: cint + redMask*: culong + greenMask*: culong + blueMask*: culong + visualClass*: cshort + viewportWidth*: cint + viewportHeight*: cint + xViewportStep*: cint # viewport position granularity + yViewportStep*: cint + maxViewportX*: cint # max viewport origin + maxViewportY*: cint + viewportFlags*: cint # types of page flipping possible + reserved1*: cint + reserved2*: cint + + PXDGADevice* = ptr TXDGADevice + TXDGADevice*{.final.} = object + mode*: TXDGAMode + data*: Pcuchar + pixmap*: TPixmap + + PXDGAButtonEvent* = ptr TXDGAButtonEvent + TXDGAButtonEvent*{.final.} = object + theType*: cint + serial*: culong + display*: PDisplay + screen*: cint + time*: TTime + state*: cuint + button*: cuint + + PXDGAKeyEvent* = ptr TXDGAKeyEvent + TXDGAKeyEvent*{.final.} = object + theType*: cint + serial*: culong + display*: PDisplay + screen*: cint + time*: TTime + state*: cuint + keycode*: cuint + + PXDGAMotionEvent* = ptr TXDGAMotionEvent + TXDGAMotionEvent*{.final.} = object + theType*: cint + serial*: culong + display*: PDisplay + screen*: cint + time*: TTime + state*: cuint + dx*: cint + dy*: cint + + PXDGAEvent* = ptr TXDGAEvent + TXDGAEvent*{.final.} = object + pad*: array[0..23, clong] # sorry you have to cast if you want access + #Case LongInt Of + # 0 : (_type : cint); + # 1 : (xbutton : TXDGAButtonEvent); + # 2 : (xkey : TXDGAKeyEvent); + # 3 : (xmotion : TXDGAMotionEvent); + # 4 : (pad : Array[0..23] Of clong); + + +proc XDGAQueryExtension*(dpy: PDisplay, eventBase: Pcint, erroBase: Pcint): TBool{. + CDecl, dynlib: libXxf86dga, importc.} +proc XDGAQueryVersion*(dpy: PDisplay, majorVersion: Pcint, minorVersion: Pcint): TBool{. + CDecl, dynlib: libXxf86dga, importc.} +proc XDGAQueryModes*(dpy: PDisplay, screen: cint, num: Pcint): PXDGAMode{.CDecl, + dynlib: libXxf86dga, importc.} +proc XDGASetMode*(dpy: PDisplay, screen: cint, mode: cint): PXDGADevice{.CDecl, + dynlib: libXxf86dga, importc.} +proc XDGAOpenFramebuffer*(dpy: PDisplay, screen: cint): TBool{.CDecl, + dynlib: libXxf86dga, importc.} +proc XDGACloseFramebuffer*(dpy: PDisplay, screen: cint){.CDecl, + dynlib: libXxf86dga, importc.} +proc XDGASetViewport*(dpy: PDisplay, screen: cint, x: cint, y: cint, flags: cint){. + CDecl, dynlib: libXxf86dga, importc.} +proc XDGAInstallColormap*(dpy: PDisplay, screen: cint, cmap: TColormap){.CDecl, + dynlib: libXxf86dga, importc.} +proc XDGACreateColormap*(dpy: PDisplay, screen: cint, device: PXDGADevice, + alloc: cint): TColormap{.CDecl, dynlib: libXxf86dga, + importc.} +proc XDGASelectInput*(dpy: PDisplay, screen: cint, event_mask: clong){.CDecl, + dynlib: libXxf86dga, importc.} +proc XDGAFillRectangle*(dpy: PDisplay, screen: cint, x: cint, y: cint, + width: cuint, height: cuint, color: culong){.CDecl, + dynlib: libXxf86dga, importc.} +proc XDGACopyArea*(dpy: PDisplay, screen: cint, srcx: cint, srcy: cint, + width: cuint, height: cuint, dstx: cint, dsty: cint){.CDecl, + dynlib: libXxf86dga, importc.} +proc XDGACopyTransparentArea*(dpy: PDisplay, screen: cint, srcx: cint, + srcy: cint, width: cuint, height: cuint, + dstx: cint, dsty: cint, key: culong){.CDecl, + dynlib: libXxf86dga, importc.} +proc XDGAGetViewportStatus*(dpy: PDisplay, screen: cint): cint{.CDecl, + dynlib: libXxf86dga, importc.} +proc XDGASync*(dpy: PDisplay, screen: cint){.CDecl, dynlib: libXxf86dga, importc.} +proc XDGASetClientVersion*(dpy: PDisplay): TBool{.CDecl, dynlib: libXxf86dga, + importc.} +proc XDGAChangePixmapMode*(dpy: PDisplay, screen: cint, x: Pcint, y: Pcint, + mode: cint){.CDecl, dynlib: libXxf86dga, importc.} +proc XDGAKeyEventToXKeyEvent*(dk: PXDGAKeyEvent, xk: PXKeyEvent){.CDecl, + dynlib: libXxf86dga, importc.} +# implementation diff --git a/lib/base/x11/xf86vmode.nim b/lib/base/x11/xf86vmode.nim new file mode 100644 index 000000000..18a922cab --- /dev/null +++ b/lib/base/x11/xf86vmode.nim @@ -0,0 +1,229 @@ +# $XFree86: xc/include/extensions/xf86vmode.h,v 3.30 2001/05/07 20:09:50 mvojkovi Exp $ +# +# +#Copyright 1995 Kaleb S. KEITHLEY +# +#Permission is hereby granted, free of charge, to any person obtaining +#a copy of this software and associated documentation files (the +#"Software"), to deal in the Software without restriction, including +#without limitation the rights to use, copy, modify, merge, publish, +#distribute, sublicense, and/or sell copies of the Software, and to +#permit persons to whom the Software is furnished to do so, subject to +#the following conditions: +# +#The above copyright notice and this permission notice shall be +#included in all copies or substantial portions of the Software. +# +#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +#EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +#MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +#IN NO EVENT SHALL Kaleb S. KEITHLEY BE LIABLE FOR ANY CLAIM, DAMAGES +#OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +#ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +#OTHER DEALINGS IN THE SOFTWARE. +# +#Except as contained in this notice, the name of Kaleb S. KEITHLEY +#shall not be used in advertising or otherwise to promote the sale, use +#or other dealings in this Software without prior written authorization +#from Kaleb S. KEITHLEY +# +# +# $Xorg: xf86vmode.h,v 1.3 2000/08/18 04:05:46 coskrey Exp $ +# THIS IS NOT AN X CONSORTIUM STANDARD OR AN X PROJECT TEAM SPECIFICATION + +import + x, xlib + +const + libXxf86vm* = "libXxf86vm.so" + +type + PINT32* = ptr int32 + +const + X_XF86VidModeQueryVersion* = 0 + X_XF86VidModeGetModeLine* = 1 + X_XF86VidModeModModeLine* = 2 + X_XF86VidModeSwitchMode* = 3 + X_XF86VidModeGetMonitor* = 4 + X_XF86VidModeLockModeSwitch* = 5 + X_XF86VidModeGetAllModeLines* = 6 + X_XF86VidModeAddModeLine* = 7 + X_XF86VidModeDeleteModeLine* = 8 + X_XF86VidModeValidateModeLine* = 9 + X_XF86VidModeSwitchToMode* = 10 + X_XF86VidModeGetViewPort* = 11 + X_XF86VidModeSetViewPort* = 12 # new for version 2.x of this extension + X_XF86VidModeGetDotClocks* = 13 + X_XF86VidModeSetClientVersion* = 14 + X_XF86VidModeSetGamma* = 15 + X_XF86VidModeGetGamma* = 16 + X_XF86VidModeGetGammaRamp* = 17 + X_XF86VidModeSetGammaRamp* = 18 + X_XF86VidModeGetGammaRampSize* = 19 + X_XF86VidModeGetPermissions* = 20 + CLKFLAG_PROGRAMABLE* = 1 + +when defined(XF86VIDMODE_EVENTS): + const + XF86VidModeNotify* = 0 + XF86VidModeNumberEvents* = (XF86VidModeNotify + 1) + XF86VidModeNotifyMask* = 0x00000001 + XF86VidModeNonEvent* = 0 + XF86VidModeModeChange* = 1 +else: + const + XF86VidModeNumberEvents* = 0 +const + XF86VidModeBadClock* = 0 + XF86VidModeBadHTimings* = 1 + XF86VidModeBadVTimings* = 2 + XF86VidModeModeUnsuitable* = 3 + XF86VidModeExtensionDisabled* = 4 + XF86VidModeClientNotLocal* = 5 + XF86VidModeZoomLocked* = 6 + XF86VidModeNumberErrors* = (XF86VidModeZoomLocked + 1) + XF86VM_READ_PERMISSION* = 1 + XF86VM_WRITE_PERMISSION* = 2 + +type + PXF86VidModeModeLine* = ptr TXF86VidModeModeLine + TXF86VidModeModeLine*{.final.} = object + hdisplay*: cushort + hsyncstart*: cushort + hsyncend*: cushort + htotal*: cushort + hskew*: cushort + vdisplay*: cushort + vsyncstart*: cushort + vsyncend*: cushort + vtotal*: cushort + flags*: cuint + privsize*: cint + c_private*: PINT32 + + PPPXF86VidModeModeInfo* = ptr PPXF86VidModeModeInfo + PPXF86VidModeModeInfo* = ptr PXF86VidModeModeInfo + PXF86VidModeModeInfo* = ptr TXF86VidModeModeInfo + TXF86VidModeModeInfo*{.final.} = object + dotclock*: cuint + hdisplay*: cushort + hsyncstart*: cushort + hsyncend*: cushort + htotal*: cushort + hskew*: cushort + vdisplay*: cushort + vsyncstart*: cushort + vsyncend*: cushort + vtotal*: cushort + flags*: cuint + privsize*: cint + c_private*: PINT32 + + PXF86VidModeSyncRange* = ptr TXF86VidModeSyncRange + TXF86VidModeSyncRange*{.final.} = object + hi*: cfloat + lo*: cfloat + + PXF86VidModeMonitor* = ptr TXF86VidModeMonitor + TXF86VidModeMonitor*{.final.} = object + vendor*: cstring + model*: cstring + EMPTY*: cfloat + nhsync*: cuchar + hsync*: PXF86VidModeSyncRange + nvsync*: cuchar + vsync*: PXF86VidModeSyncRange + + PXF86VidModeNotifyEvent* = ptr TXF86VidModeNotifyEvent + TXF86VidModeNotifyEvent*{.final.} = object + theType*: cint # of event + serial*: culong # # of last request processed by server + send_event*: TBool # true if this came from a SendEvent req + display*: PDisplay # Display the event was read from + root*: TWindow # root window of event screen + state*: cint # What happened + kind*: cint # What happened + forced*: TBool # extents of new region + time*: TTime # event timestamp + + PXF86VidModeGamma* = ptr TXF86VidModeGamma + TXF86VidModeGamma*{.final.} = object + red*: cfloat # Red Gamma value + green*: cfloat # Green Gamma value + blue*: cfloat # Blue Gamma value + + +when defined(MACROS): + proc XF86VidModeSelectNextMode*(disp: PDisplay, scr: cint): TBool + proc XF86VidModeSelectPrevMode*(disp: PDisplay, scr: cint): TBool +proc XF86VidModeQueryVersion*(dpy: PDisplay, majorVersion: Pcint, + minorVersion: Pcint): TBool{.CDecl, + dynlib: libXxf86vm, importc.} +proc XF86VidModeQueryExtension*(dpy: PDisplay, event_base: Pcint, + error_base: Pcint): TBool{.CDecl, + dynlib: libXxf86vm, importc.} +proc XF86VidModeSetClientVersion*(dpy: PDisplay): TBool{.CDecl, + dynlib: libXxf86vm, importc.} +proc XF86VidModeGetModeLine*(dpy: PDisplay, screen: cint, dotclock: Pcint, + modeline: PXF86VidModeModeLine): TBool{.CDecl, + dynlib: libXxf86vm, importc.} +proc XF86VidModeGetAllModeLines*(dpy: PDisplay, screen: cint, modecount: Pcint, + modelinesPtr: PPPXF86VidModeModeInfo): TBool{. + CDecl, dynlib: libXxf86vm, importc.} +proc XF86VidModeAddModeLine*(dpy: PDisplay, screen: cint, + new_modeline: PXF86VidModeModeInfo, + after_modeline: PXF86VidModeModeInfo): TBool{. + CDecl, dynlib: libXxf86vm, importc.} +proc XF86VidModeDeleteModeLine*(dpy: PDisplay, screen: cint, + modeline: PXF86VidModeModeInfo): TBool{.CDecl, + dynlib: libXxf86vm, importc.} +proc XF86VidModeModModeLine*(dpy: PDisplay, screen: cint, + modeline: PXF86VidModeModeLine): TBool{.CDecl, + dynlib: libXxf86vm, importc.} +proc XF86VidModeValidateModeLine*(dpy: PDisplay, screen: cint, + modeline: PXF86VidModeModeInfo): TStatus{. + CDecl, dynlib: libXxf86vm, importc.} +proc XF86VidModeSwitchMode*(dpy: PDisplay, screen: cint, zoom: cint): TBool{. + CDecl, dynlib: libXxf86vm, importc.} +proc XF86VidModeSwitchToMode*(dpy: PDisplay, screen: cint, + modeline: PXF86VidModeModeInfo): TBool{.CDecl, + dynlib: libXxf86vm, importc.} +proc XF86VidModeLockModeSwitch*(dpy: PDisplay, screen: cint, lock: cint): TBool{. + CDecl, dynlib: libXxf86vm, importc.} +proc XF86VidModeGetMonitor*(dpy: PDisplay, screen: cint, + monitor: PXF86VidModeMonitor): TBool{.CDecl, + dynlib: libXxf86vm, importc.} +proc XF86VidModeGetViewPort*(dpy: PDisplay, screen: cint, x_return: Pcint, + y_return: Pcint): TBool{.CDecl, dynlib: libXxf86vm, + importc.} +proc XF86VidModeSetViewPort*(dpy: PDisplay, screen: cint, x: cint, y: cint): TBool{. + CDecl, dynlib: libXxf86vm, importc.} +proc XF86VidModeGetDotClocks*(dpy: PDisplay, screen: cint, flags_return: Pcint, + number_of_clocks_return: Pcint, + max_dot_clock_return: Pcint, clocks_return: PPcint): TBool{. + CDecl, dynlib: libXxf86vm, importc.} +proc XF86VidModeGetGamma*(dpy: PDisplay, screen: cint, Gamma: PXF86VidModeGamma): TBool{. + CDecl, dynlib: libXxf86vm, importc.} +proc XF86VidModeSetGamma*(dpy: PDisplay, screen: cint, Gamma: PXF86VidModeGamma): TBool{. + CDecl, dynlib: libXxf86vm, importc.} +proc XF86VidModeSetGammaRamp*(dpy: PDisplay, screen: cint, size: cint, + red_array: Pcushort, green_array: Pcushort, + blue_array: Pcushort): TBool{.CDecl, + dynlib: libXxf86vm, importc.} +proc XF86VidModeGetGammaRamp*(dpy: PDisplay, screen: cint, size: cint, + red_array: Pcushort, green_array: Pcushort, + blue_array: Pcushort): TBool{.CDecl, + dynlib: libXxf86vm, importc.} +proc XF86VidModeGetGammaRampSize*(dpy: PDisplay, screen: cint, size: Pcint): TBool{. + CDecl, dynlib: libXxf86vm, importc.} +proc XF86VidModeGetPermissions*(dpy: PDisplay, screen: cint, permissions: Pcint): TBool{. + CDecl, dynlib: libXxf86vm, importc.} +# implementation + +when defined(MACROS): + proc XF86VidModeSelectNextMode(disp: PDisplay, scr: cint): TBool = + XF86VidModeSelectNextMode = XF86VidModeSwitchMode(disp, scr, 1) + + proc XF86VidModeSelectPrevMode(disp: PDisplay, scr: cint): TBool = + XF86VidModeSelectPrevMode = XF86VidModeSwitchMode(disp, scr, - 1) diff --git a/lib/base/x11/xi.nim b/lib/base/x11/xi.nim new file mode 100644 index 000000000..194b0eff4 --- /dev/null +++ b/lib/base/x11/xi.nim @@ -0,0 +1,307 @@ +# +# $Xorg: XI.h,v 1.4 2001/02/09 02:03:23 xorgcvs Exp $ +# +#************************************************************ +# +#Copyright 1989, 1998 The Open Group +# +#Permission to use, copy, modify, distribute, and sell this software and its +#documentation for any purpose is hereby granted without fee, provided that +#the above copyright notice appear in all copies and that both that +#copyright notice and this permission notice appear in supporting +#documentation. +# +#The above copyright notice and this permission notice shall be included in +#all copies or substantial portions of the Software. +# +#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +#OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +#AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +#CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +#Except as contained in this notice, the name of The Open Group shall not be +#used in advertising or otherwise to promote the sale, use or other dealings +#in this Software without prior written authorization from The Open Group. +# +#Copyright 1989 by Hewlett-Packard Company, Palo Alto, California. +# +# All Rights Reserved +# +#Permission to use, copy, modify, and distribute this software and its +#documentation for any purpose and without fee is hereby granted, +#provided that the above copyright notice appear in all copies and that +#both that copyright notice and this permission notice appear in +#supporting documentation, and that the name of Hewlett-Packard not be +#used in advertising or publicity pertaining to distribution of the +#software without specific, written prior permission. +# +#HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +#ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +#HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +#ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +#WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +#ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +#SOFTWARE. +# +#********************************************************/ +# $XFree86: xc/include/extensions/XI.h,v 1.5 2001/12/14 19:53:28 dawes Exp $ +# +# Definitions used by the server, library and client +# +# Pascal Convertion was made by Ido Kannner - kanerido@actcom.net.il +# +#Histroy: +# 2004/10/15 - Fixed a bug of accessing second based records by removing "paced record" and chnaged it to +# "reocrd" only. +# 2004/10/07 - Removed the "uses X;" line. The unit does not need it. +# 2004/10/03 - Conversion from C header to Pascal unit. +# + +const + sz_xGetExtensionVersionReq* = 8 + sz_xGetExtensionVersionReply* = 32 + sz_xListInputDevicesReq* = 4 + sz_xListInputDevicesReply* = 32 + sz_xOpenDeviceReq* = 8 + sz_xOpenDeviceReply* = 32 + sz_xCloseDeviceReq* = 8 + sz_xSetDeviceModeReq* = 8 + sz_xSetDeviceModeReply* = 32 + sz_xSelectExtensionEventReq* = 12 + sz_xGetSelectedExtensionEventsReq* = 8 + sz_xGetSelectedExtensionEventsReply* = 32 + sz_xChangeDeviceDontPropagateListReq* = 12 + sz_xGetDeviceDontPropagateListReq* = 8 + sz_xGetDeviceDontPropagateListReply* = 32 + sz_xGetDeviceMotionEventsReq* = 16 + sz_xGetDeviceMotionEventsReply* = 32 + sz_xChangeKeyboardDeviceReq* = 8 + sz_xChangeKeyboardDeviceReply* = 32 + sz_xChangePointerDeviceReq* = 8 + sz_xChangePointerDeviceReply* = 32 + sz_xGrabDeviceReq* = 20 + sz_xGrabDeviceReply* = 32 + sz_xUngrabDeviceReq* = 12 + sz_xGrabDeviceKeyReq* = 20 + sz_xGrabDeviceKeyReply* = 32 + sz_xUngrabDeviceKeyReq* = 16 + sz_xGrabDeviceButtonReq* = 20 + sz_xGrabDeviceButtonReply* = 32 + sz_xUngrabDeviceButtonReq* = 16 + sz_xAllowDeviceEventsReq* = 12 + sz_xGetDeviceFocusReq* = 8 + sz_xGetDeviceFocusReply* = 32 + sz_xSetDeviceFocusReq* = 16 + sz_xGetFeedbackControlReq* = 8 + sz_xGetFeedbackControlReply* = 32 + sz_xChangeFeedbackControlReq* = 12 + sz_xGetDeviceKeyMappingReq* = 8 + sz_xGetDeviceKeyMappingReply* = 32 + sz_xChangeDeviceKeyMappingReq* = 8 + sz_xGetDeviceModifierMappingReq* = 8 + sz_xSetDeviceModifierMappingReq* = 8 + sz_xSetDeviceModifierMappingReply* = 32 + sz_xGetDeviceButtonMappingReq* = 8 + sz_xGetDeviceButtonMappingReply* = 32 + sz_xSetDeviceButtonMappingReq* = 8 + sz_xSetDeviceButtonMappingReply* = 32 + sz_xQueryDeviceStateReq* = 8 + sz_xQueryDeviceStateReply* = 32 + sz_xSendExtensionEventReq* = 16 + sz_xDeviceBellReq* = 8 + sz_xSetDeviceValuatorsReq* = 8 + sz_xSetDeviceValuatorsReply* = 32 + sz_xGetDeviceControlReq* = 8 + sz_xGetDeviceControlReply* = 32 + sz_xChangeDeviceControlReq* = 8 + sz_xChangeDeviceControlReply* = 32 + +const + INAME* = "XInputExtension" + +const + XI_KEYBOARD* = "KEYBOARD" + XI_MOUSE* = "MOUSE" + XI_TABLET* = "TABLET" + XI_TOUCHSCREEN* = "TOUCHSCREEN" + XI_TOUCHPAD* = "TOUCHPAD" + XI_BARCODE* = "BARCODE" + XI_BUTTONBOX* = "BUTTONBOX" + XI_KNOB_BOX* = "KNOB_BOX" + XI_ONE_KNOB* = "ONE_KNOB" + XI_NINE_KNOB* = "NINE_KNOB" + XI_TRACKBALL* = "TRACKBALL" + XI_QUADRATURE* = "QUADRATURE" + XI_ID_MODULE* = "ID_MODULE" + XI_SPACEBALL* = "SPACEBALL" + XI_DATAGLOVE* = "DATAGLOVE" + XI_EYETRACKER* = "EYETRACKER" + XI_CURSORKEYS* = "CURSORKEYS" + XI_FOOTMOUSE* = "FOOTMOUSE" + +const + Dont_Check* = 0 + XInput_Initial_Release* = 1 + XInput_Add_XDeviceBell* = 2 + XInput_Add_XSetDeviceValuators* = 3 + XInput_Add_XChangeDeviceControl* = 4 + +const + XI_Absent* = 0 + XI_Present* = 1 + +const + XI_Initial_Release_Major* = 1 + XI_Initial_Release_Minor* = 0 + +const + XI_Add_XDeviceBell_Major* = 1 + XI_Add_XDeviceBell_Minor* = 1 + +const + XI_Add_XSetDeviceValuators_Major* = 1 + XI_Add_XSetDeviceValuators_Minor* = 2 + +const + XI_Add_XChangeDeviceControl_Major* = 1 + XI_Add_XChangeDeviceControl_Minor* = 3 + +const + DEVICE_RESOLUTION* = 1 + +const + NoSuchExtension* = 1 + +const + COUNT* = 0 + CREATE* = 1 + +const + NewPointer* = 0 + NewKeyboard* = 1 + +const + XPOINTER* = 0 + XKEYBOARD* = 1 + +const + UseXKeyboard* = 0x000000FF + +const + IsXPointer* = 0 + IsXKeyboard* = 1 + IsXExtensionDevice* = 2 + +const + AsyncThisDevice* = 0 + SyncThisDevice* = 1 + ReplayThisDevice* = 2 + AsyncOtherDevices* = 3 + AsyncAll* = 4 + SyncAll* = 5 + +const + FollowKeyboard* = 3 + RevertToFollowKeyboard* = 3 + +const + DvAccelNum* = int(1) shl 0 + DvAccelDenom* = int(1) shl 1 + DvThreshold* = int(1) shl 2 + +const + DvKeyClickPercent* = int(1) shl 0 + DvPercent* = int(1) shl 1 + DvPitch* = int(1) shl 2 + DvDuration* = int(1) shl 3 + DvLed* = int(1) shl 4 + DvLedMode* = int(1) shl 5 + DvKey* = int(1) shl 6 + DvAutoRepeatMode* = int(1) shl 7 + +const + DvString* = int(1) shl 0 + +const + DvInteger* = int(1) shl 0 + +const + DeviceMode* = int(1) shl 0 + Relative* = 0 + Absolute* = 1 # Merged from Metrolink tree for XINPUT stuff + TS_Raw* = 57 + TS_Scaled* = 58 + SendCoreEvents* = 59 + DontSendCoreEvents* = 60 # End of merged section + +const + ProximityState* = int(1) shl 1 + InProximity* = int(0) shl 1 + OutOfProximity* = int(1) shl 1 + +const + AddToList* = 0 + DeleteFromList* = 1 + +const + KeyClass* = 0 + ButtonClass* = 1 + ValuatorClass* = 2 + FeedbackClass* = 3 + ProximityClass* = 4 + FocusClass* = 5 + OtherClass* = 6 + +const + KbdFeedbackClass* = 0 + PtrFeedbackClass* = 1 + StringFeedbackClass* = 2 + IntegerFeedbackClass* = 3 + LedFeedbackClass* = 4 + BellFeedbackClass* = 5 + +const + devicePointerMotionHint* = 0 + deviceButton1Motion* = 1 + deviceButton2Motion* = 2 + deviceButton3Motion* = 3 + deviceButton4Motion* = 4 + deviceButton5Motion* = 5 + deviceButtonMotion* = 6 + deviceButtonGrab* = 7 + deviceOwnerGrabButton* = 8 + noExtensionEvent* = 9 + +const + XI_BadDevice* = 0 + XI_BadEvent* = 1 + XI_BadMode* = 2 + XI_DeviceBusy* = 3 + XI_BadClass* = 4 # Make XEventClass be a CARD32 for 64 bit servers. Don't affect client + # definition of XEventClass since that would be a library interface change. + # See the top of X.h for more _XSERVER64 magic. + # + +when defined(XSERVER64): + type + XEventClass* = CARD32 +else: + type + XEventClass* = int32 +#****************************************************************** +# * +# * Extension version structure. +# * +# + +type + PXExtensionVersion* = ptr TXExtensionVersion + TXExtensionVersion*{.final.} = object + present*: int16 + major_version*: int16 + minor_version*: int16 + + +# implementation diff --git a/lib/base/x11/xinerama.nim b/lib/base/x11/xinerama.nim new file mode 100644 index 000000000..96f5d7da3 --- /dev/null +++ b/lib/base/x11/xinerama.nim @@ -0,0 +1,25 @@ +# Converted from X11/Xinerama.h +import + xlib + +const + xineramaLib = "libXinerama.so" + +type + PXineramaScreenInfo* = ptr TXineramaScreenInfo + TXineramaScreenInfo*{.final.} = object + screen_number*: cint + x_org*: int16 + y_org*: int16 + width*: int16 + height*: int16 + + +proc XineramaQueryExtension*(dpy: PDisplay, event_base: Pcint, error_base: Pcint): TBool{. + cdecl, dynlib: xineramaLib, importc.} +proc XineramaQueryVersion*(dpy: PDisplay, major: Pcint, minor: Pcint): TStatus{. + cdecl, dynlib: xineramaLib, importc.} +proc XineramaIsActive*(dpy: PDisplay): TBool{.cdecl, dynlib: xineramaLib, importc.} +proc XineramaQueryScreens*(dpy: PDisplay, number: Pcint): PXineramaScreenInfo{. + cdecl, dynlib: xineramaLib, importc.} + diff --git a/lib/base/x11/xkb.nim b/lib/base/x11/xkb.nim new file mode 100644 index 000000000..f1b0448a8 --- /dev/null +++ b/lib/base/x11/xkb.nim @@ -0,0 +1,2409 @@ +# +# $Xorg: XKB.h,v 1.3 2000/08/18 04:05:45 coskrey Exp $ +#************************************************************ +# $Xorg: XKBstr.h,v 1.3 2000/08/18 04:05:45 coskrey Exp $ +#************************************************************ +# $Xorg: XKBgeom.h,v 1.3 2000/08/18 04:05:45 coskrey Exp $ +#************************************************************ +# +#Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc. +# +#Permission to use, copy, modify, and distribute this +#software and its documentation for any purpose and without +#fee is hereby granted, provided that the above copyright +#notice appear in all copies and that both that copyright +#notice and this permission notice appear in supporting +#documentation, and that the name of Silicon Graphics not be +#used in advertising or publicity pertaining to distribution +#of the software without specific prior written permission. +#Silicon Graphics makes no representation about the suitability +#of this software for any purpose. It is provided "as is" +#without any express or implied warranty. +# +#SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS +#SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +#AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON +#GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL +#DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +#DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +#OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH +#THE USE OR PERFORMANCE OF THIS SOFTWARE. +# +#******************************************************** +# $XFree86: xc/include/extensions/XKB.h,v 1.5 2002/11/20 04:49:01 dawes Exp $ +# $XFree86: xc/include/extensions/XKBgeom.h,v 3.9 2002/09/18 17:11:40 tsi Exp $ +# +# Pascal Convertion was made by Ido Kannner - kanerido@actcom.net.il +# +#Thanks: +# I want to thanks to oliebol for putting up with all of the problems that was found +# while translating this code. ;) +# +# I want to thanks #fpc channel in freenode irc, for helping me, and to put up with my +# wierd questions ;) +# +# Thanks for mmc in #xlib on freenode irc And so for the channel itself for the helping me to +# understanding some of the problems I had converting this headers and pointing me to resources +# that helped translating this headers. +# +# Ido +# +#History: +# 2004/10/15 - Fixed a bug of accessing second based records by removing "paced record" and +# chnaged it to "reocrd" only. +# 2004/10/04 - 06 - Convertion from the c header of XKBgeom.h. +# 2004/10/03 - Removed the XKBstr_UNIT compiler decleration. Afther the joined files, +# There is no need for it anymore. +# - There is a need to define (for now) XKBgeom (compiler define) in order +# to use the code of it. At this moment, I did not yet converted it to Pascal. +# +# 2004/09/17 - 10/04 - Convertion from the c header of XKBstr. +# +# 2004/10/03 - Joined xkbstr.pas into xkb.pas because of the circular calls problems. +# - Added the history of xkbstr.pas above this addition. +# +# 2004/09/17 - Fixed a wrong convertion number of XkbPerKeyBitArraySize, insted +# of float, it's now converted into integer (as it should have been). +# +# 2004/09/15 - 16 - Convertion from the c header of XKB.h. +# + +import + X, Xlib + +proc XkbCharToInt*(v: int8): int16 +proc XkbIntTo2Chars*(i: int16, h, L: var int8) +proc Xkb2CharsToInt*(h, L: int8): int16 + # + # Common data structures and access macros + # +type + PWord* = ptr array[0..64_000, int16] + PByte* = ptr byte + PXkbStatePtr* = ptr TXkbStateRec + TXkbStateRec*{.final.} = object + group*: int8 + locked_group*: int8 + base_group*: int16 + latched_group*: int16 + mods*: int8 + base_mods*: int8 + latched_mods*: int8 + locked_mods*: int8 + compat_state*: int8 + grab_mods*: int8 + compat_grab_mods*: int8 + lookup_mods*: int8 + compat_lookup_mods*: int8 + ptr_buttons*: int16 + + +proc XkbModLocks*(s: PXkbStatePtr): int8 +proc XkbStateMods*(s: PXkbStatePtr): int16 +proc XkbGroupLock*(s: PXkbStatePtr): int8 +proc XkbStateGroup*(s: PXkbStatePtr): int16 +proc XkbStateFieldFromRec*(s: PXkbStatePtr): int +proc XkbGrabStateFromRec*(s: PXkbStatePtr): int +type + PXkbModsPtr* = ptr TXkbModsRec + TXkbModsRec*{.final.} = object + mask*: int8 # effective mods + real_mods*: int8 + vmods*: int16 + + +type + PXkbKTMapEntryPtr* = ptr TXkbKTMapEntryRec + TXkbKTMapEntryRec*{.final.} = object + active*: bool + level*: int8 + mods*: TXkbModsRec + + +type + PXkbKeyTypePtr* = ptr TXkbKeyTypeRec + TXkbKeyTypeRec*{.final.} = object + mods*: TXkbModsRec + num_levels*: int8 + map_count*: int8 + map*: PXkbKTMapEntryPtr + preserve*: PXkbModsPtr + name*: TAtom + level_names*: TAtom + + +proc XkbNumGroups*(g: int16): int16 +proc XkbOutOfRangeGroupInfo*(g: int16): int16 +proc XkbOutOfRangeGroupAction*(g: int16): int16 +proc XkbOutOfRangeGroupNumber*(g: int16): int16 +proc XkbSetGroupInfo*(g, w, n: int16): int16 +proc XkbSetNumGroups*(g, n: int16): int16 + # + # Structures and access macros used primarily by the server + # +type + PXkbBehavior* = ptr TXkbBehavior + TXkbBehavior*{.final.} = object + theType*: int8 + data*: int8 + + +type + PXkbModAction* = ptr TXkbModAction + TXkbModAction*{.final.} = object + theType*: int8 + flags*: int8 + mask*: int8 + real_mods*: int8 + vmods1*: int8 + vmods2*: int8 + + +proc XkbModActionVMods*(a: PXkbModAction): int16 +proc XkbSetModActionVMods*(a: PXkbModAction, v: int8) +type + PXkbGroupAction* = ptr TXkbGroupAction + TXkbGroupAction*{.final.} = object + theType*: int8 + flags*: int8 + group_XXX*: int8 + + +proc XkbSAGroup*(a: PXkbGroupAction): int8 +proc XkbSASetGroupProc*(a: PXkbGroupAction, g: int8) +type + PXkbISOAction* = ptr TXkbISOAction + TXkbISOAction*{.final.} = object + theType*: int8 + flags*: int8 + mask*: int8 + real_mods*: int8 + group_XXX*: int8 + affect*: int8 + vmods1*: int8 + vmods2*: int8 + + +type + PXkbPtrAction* = ptr TXkbPtrAction + TXkbPtrAction*{.final.} = object + theType*: int8 + flags*: int8 + high_XXX*: int8 + low_XXX*: int8 + high_YYY*: int8 + low_YYY*: int8 + + +proc XkbPtrActionX*(a: PXkbPtrAction): int16 +proc XkbPtrActionY*(a: PXkbPtrAction): int16 +proc XkbSetPtrActionX*(a: PXkbPtrAction, x: int8) +proc XkbSetPtrActionY*(a: PXkbPtrAction, y: int8) +type + PXkbPtrBtnAction* = ptr TXkbPtrBtnAction + TXkbPtrBtnAction*{.final.} = object + theType*: int8 + flags*: int8 + count*: int8 + button*: int8 + + +type + PXkbPtrDfltAction* = ptr TXkbPtrDfltAction + TXkbPtrDfltAction*{.final.} = object + theType*: int8 + flags*: int8 + affect*: int8 + valueXXX*: int8 + + +proc XkbSAPtrDfltValue*(a: PXkbPtrDfltAction): int8 +proc XkbSASetPtrDfltValue*(a: PXkbPtrDfltAction, c: pointer) +type + PXkbSwitchScreenAction* = ptr TXkbSwitchScreenAction + TXkbSwitchScreenAction*{.final.} = object + theType*: int8 + flags*: int8 + screenXXX*: int8 + + +proc XkbSAScreen*(a: PXkbSwitchScreenAction): int8 +proc XkbSASetScreen*(a: PXkbSwitchScreenAction, s: pointer) +type + PXkbCtrlsAction* = ptr TXkbCtrlsAction + TXkbCtrlsAction*{.final.} = object + theType*: int8 + flags*: int8 + ctrls3*: int8 + ctrls2*: int8 + ctrls1*: int8 + ctrls0*: int8 + + +proc XkbActionSetCtrls*(a: PXkbCtrlsAction, c: int8) +proc XkbActionCtrls*(a: PXkbCtrlsAction): int16 +type + PXkbMessageAction* = ptr TXkbMessageAction + TXkbMessageAction*{.final.} = object + theType*: int8 + flags*: int8 + message*: array[0..5, char] + + +type + PXkbRedirectKeyAction* = ptr TXkbRedirectKeyAction + TXkbRedirectKeyAction*{.final.} = object + theType*: int8 + new_key*: int8 + mods_mask*: int8 + mods*: int8 + vmods_mask0*: int8 + vmods_mask1*: int8 + vmods0*: int8 + vmods1*: int8 + + +proc XkbSARedirectVMods*(a: PXkbRedirectKeyAction): int16 +proc XkbSARedirectSetVMods*(a: PXkbRedirectKeyAction, m: int8) +proc XkbSARedirectVModsMask*(a: PXkbRedirectKeyAction): int16 +proc XkbSARedirectSetVModsMask*(a: PXkbRedirectKeyAction, m: int8) +type + PXkbDeviceBtnAction* = ptr TXkbDeviceBtnAction + TXkbDeviceBtnAction*{.final.} = object + theType*: int8 + flags*: int8 + count*: int8 + button*: int8 + device*: int8 + + +type + PXkbDeviceValuatorAction* = ptr TXkbDeviceValuatorAction + TXkbDeviceValuatorAction*{.final.} = object # + # Macros to classify key actions + # + theType*: int8 + device*: int8 + v1_what*: int8 + v1_ndx*: int8 + v1_value*: int8 + v2_what*: int8 + v2_ndx*: int8 + v2_value*: int8 + + +const + XkbAnyActionDataSize* = 7 + +type + PXkbAnyAction* = ptr TXkbAnyAction + TXkbAnyAction*{.final.} = object + theType*: int8 + data*: array[0..XkbAnyActionDataSize - 1, int8] + + +proc XkbIsModAction*(a: PXkbAnyAction): bool +proc XkbIsGroupAction*(a: PXkbAnyAction): bool +proc XkbIsPtrAction*(a: PXkbAnyAction): bool +type + PXkbAction* = ptr TXkbAction + TXkbAction*{.final.} = object # + # XKB request codes, used in: + # - xkbReqType field of all requests + # - requestMinor field of some events + # + any*: TXkbAnyAction + mods*: TXkbModAction + group*: TXkbGroupAction + iso*: TXkbISOAction + thePtr*: TXkbPtrAction + btn*: TXkbPtrBtnAction + dflt*: TXkbPtrDfltAction + screen*: TXkbSwitchScreenAction + ctrls*: TXkbCtrlsAction + msg*: TXkbMessageAction + redirect*: TXkbRedirectKeyAction + devbtn*: TXkbDeviceBtnAction + devval*: TXkbDeviceValuatorAction + theType*: int8 + + +const + X_kbUseExtension* = 0 + X_kbSelectEvents* = 1 + X_kbBell* = 3 + X_kbGetState* = 4 + X_kbLatchLockState* = 5 + X_kbGetControls* = 6 + X_kbSetControls* = 7 + X_kbGetMap* = 8 + X_kbSetMap* = 9 + X_kbGetCompatMap* = 10 + X_kbSetCompatMap* = 11 + X_kbGetIndicatorState* = 12 + X_kbGetIndicatorMap* = 13 + X_kbSetIndicatorMap* = 14 + X_kbGetNamedIndicator* = 15 + X_kbSetNamedIndicator* = 16 + X_kbGetNames* = 17 + X_kbSetNames* = 18 + X_kbGetGeometry* = 19 + X_kbSetGeometry* = 20 + X_kbPerClientFlags* = 21 + X_kbListComponents* = 22 + X_kbGetKbdByName* = 23 + X_kbGetDeviceInfo* = 24 + X_kbSetDeviceInfo* = 25 + X_kbSetDebuggingFlags* = 101 # + # In the X sense, XKB reports only one event. + # The type field of all XKB events is XkbEventCode + # + +const + XkbEventCode* = 0 + XkbNumberEvents* = XkbEventCode + 1 # + # XKB has a minor event code so it can use one X event code for + # multiple purposes. + # - reported in the xkbType field of all XKB events. + # - XkbSelectEventDetails: Indicates the event for which event details + # are being changed + # + +const + XkbNewKeyboardNotify* = 0 + XkbMapNotify* = 1 + XkbStateNotify* = 2 + XkbControlsNotify* = 3 + XkbIndicatorStateNotify* = 4 + XkbIndicatorMapNotify* = 5 + XkbNamesNotify* = 6 + XkbCompatMapNotify* = 7 + XkbBellNotify* = 8 + XkbActionMessage* = 9 + XkbAccessXNotify* = 10 + XkbExtensionDeviceNotify* = 11 # + # Event Mask: + # - XkbSelectEvents: Specifies event interest. + # + +const + XkbNewKeyboardNotifyMask* = int(1) shl 0 + XkbMapNotifyMask* = int(1) shl 1 + XkbStateNotifyMask* = int(1) shl 2 + XkbControlsNotifyMask* = int(1) shl 3 + XkbIndicatorStateNotifyMask* = int(1) shl 4 + XkbIndicatorMapNotifyMask* = int(1) shl 5 + XkbNamesNotifyMask* = int(1) shl 6 + XkbCompatMapNotifyMask* = int(1) shl 7 + XkbBellNotifyMask* = int(1) shl 8 + XkbActionMessageMask* = int(1) shl 9 + XkbAccessXNotifyMask* = int(1) shl 10 + XkbExtensionDeviceNotifyMask* = int(1) shl 11 + XkbAllEventsMask* = 0x00000FFF # + # NewKeyboardNotify event details: + # + +const + XkbNKN_KeycodesMask* = int(1) shl 0 + XkbNKN_GeometryMask* = int(1) shl 1 + XkbNKN_DeviceIDMask* = int(1) shl 2 + XkbAllNewKeyboardEventsMask* = 0x00000007 # + # AccessXNotify event types: + # - The 'what' field of AccessXNotify events reports the + # reason that the event was generated. + # + +const + XkbAXN_SKPress* = 0 + XkbAXN_SKAccept* = 1 + XkbAXN_SKReject* = 2 + XkbAXN_SKRelease* = 3 + XkbAXN_BKAccept* = 4 + XkbAXN_BKReject* = 5 + XkbAXN_AXKWarning* = 6 # + # AccessXNotify details: + # - Used as an event detail mask to limit the conditions under which + # AccessXNotify events are reported + # + +const + XkbAXN_SKPressMask* = int(1) shl 0 + XkbAXN_SKAcceptMask* = int(1) shl 1 + XkbAXN_SKRejectMask* = int(1) shl 2 + XkbAXN_SKReleaseMask* = int(1) shl 3 + XkbAXN_BKAcceptMask* = int(1) shl 4 + XkbAXN_BKRejectMask* = int(1) shl 5 + XkbAXN_AXKWarningMask* = int(1) shl 6 + XkbAllAccessXEventsMask* = 0x0000000F # + # State detail mask: + # - The 'changed' field of StateNotify events reports which of + # the keyboard state components have changed. + # - Used as an event detail mask to limit the conditions under + # which StateNotify events are reported. + # + +const + XkbModifierStateMask* = int(1) shl 0 + XkbModifierBaseMask* = int(1) shl 1 + XkbModifierLatchMask* = int(1) shl 2 + XkbModifierLockMask* = int(1) shl 3 + XkbGroupStateMask* = int(1) shl 4 + XkbGroupBaseMask* = int(1) shl 5 + XkbGroupLatchMask* = int(1) shl 6 + XkbGroupLockMask* = int(1) shl 7 + XkbCompatStateMask* = int(1) shl 8 + XkbGrabModsMask* = int(1) shl 9 + XkbCompatGrabModsMask* = int(1) shl 10 + XkbLookupModsMask* = int(1) shl 11 + XkbCompatLookupModsMask* = int(1) shl 12 + XkbPointerButtonMask* = int(1) shl 13 + XkbAllStateComponentsMask* = 0x00003FFF # + # Controls detail masks: + # The controls specified in XkbAllControlsMask: + # - The 'changed' field of ControlsNotify events reports which of + # the keyboard controls have changed. + # - The 'changeControls' field of the SetControls request specifies + # the controls for which values are to be changed. + # - Used as an event detail mask to limit the conditions under + # which ControlsNotify events are reported. + # + # The controls specified in the XkbAllBooleanCtrlsMask: + # - The 'enabledControls' field of ControlsNotify events reports the + # current status of the boolean controls. + # - The 'enabledControlsChanges' field of ControlsNotify events reports + # any boolean controls that have been turned on or off. + # - The 'affectEnabledControls' and 'enabledControls' fields of the + # kbSetControls request change the set of enabled controls. + # - The 'accessXTimeoutMask' and 'accessXTimeoutValues' fields of + # an XkbControlsRec specify the controls to be changed if the keyboard + # times out and the values to which they should be changed. + # - The 'autoCtrls' and 'autoCtrlsValues' fields of the PerClientFlags + # request specifies the specify the controls to be reset when the + # client exits and the values to which they should be reset. + # - The 'ctrls' field of an indicator map specifies the controls + # that drive the indicator. + # - Specifies the boolean controls affected by the SetControls and + # LockControls key actions. + # + +const + XkbRepeatKeysMask* = int(1) shl 0 + XkbSlowKeysMask* = int(1) shl 1 + XkbBounceKeysMask* = int(1) shl 2 + XkbStickyKeysMask* = int(1) shl 3 + XkbMouseKeysMask* = int(1) shl 4 + XkbMouseKeysAccelMask* = int(1) shl 5 + XkbAccessXKeysMask* = int(1) shl 6 + XkbAccessXTimeoutMask* = int(1) shl 7 + XkbAccessXFeedbackMask* = int(1) shl 8 + XkbAudibleBellMask* = int(1) shl 9 + XkbOverlay1Mask* = int(1) shl 10 + XkbOverlay2Mask* = int(1) shl 11 + XkbIgnoreGroupLockMask* = int(1) shl 12 + XkbGroupsWrapMask* = int(1) shl 27 + XkbInternalModsMask* = int(1) shl 28 + XkbIgnoreLockModsMask* = int(1) shl 29 + XkbPerKeyRepeatMask* = int(1) shl 30 + XkbControlsEnabledMask* = int(1) shl 31 + XkbAccessXOptionsMask* = XkbStickyKeysMask or XkbAccessXFeedbackMask + XkbAllBooleanCtrlsMask* = 0x00001FFF + XkbAllControlsMask* = 0xF8001FFF # + # Compatibility Map Compontents: + # - Specifies the components to be allocated in XkbAllocCompatMap. + # + +const + XkbSymInterpMask* = 1 shl 0 + XkbGroupCompatMask* = 1 shl 1 + XkbAllCompatMask* = 0x00000003 # + # Assorted constants and limits. + # + +const + XkbAllIndicatorsMask* = 0xFFFFFFFF # + # Map components masks: + # Those in AllMapComponentsMask: + # - Specifies the individual fields to be loaded or changed for the + # GetMap and SetMap requests. + # Those in ClientInfoMask: + # - Specifies the components to be allocated by XkbAllocClientMap. + # Those in ServerInfoMask: + # - Specifies the components to be allocated by XkbAllocServerMap. + # + +const + XkbKeyTypesMask* = 1 shl 0 + XkbKeySymsMask* = 1 shl 1 + XkbModifierMapMask* = 1 shl 2 + XkbExplicitComponentsMask* = 1 shl 3 + XkbKeyActionsMask* = 1 shl 4 + XkbKeyBehaviorsMask* = 1 shl 5 + XkbVirtualModsMask* = 1 shl 6 + XkbVirtualModMapMask* = 1 shl 7 + XkbAllClientInfoMask* = XkbKeyTypesMask or XkbKeySymsMask or + XkbModifierMapMask + XkbAllServerInfoMask* = XkbExplicitComponentsMask or XkbKeyActionsMask or + XkbKeyBehaviorsMask or XkbVirtualModsMask or XkbVirtualModMapMask + XkbAllMapComponentsMask* = XkbAllClientInfoMask or XkbAllServerInfoMask # + # Names component mask: + # - Specifies the names to be loaded or changed for the GetNames and + # SetNames requests. + # - Specifies the names that have changed in a NamesNotify event. + # - Specifies the names components to be allocated by XkbAllocNames. + # + +const + XkbKeycodesNameMask* = 1 shl 0 + XkbGeometryNameMask* = 1 shl 1 + XkbSymbolsNameMask* = 1 shl 2 + XkbPhysSymbolsNameMask* = 1 shl 3 + XkbTypesNameMask* = 1 shl 4 + XkbCompatNameMask* = 1 shl 5 + XkbKeyTypeNamesMask* = 1 shl 6 + XkbKTLevelNamesMask* = 1 shl 7 + XkbIndicatorNamesMask* = 1 shl 8 + XkbKeyNamesMask* = 1 shl 9 + XkbKeyAliasesMask* = 1 shl 10 + XkbVirtualModNamesMask* = 1 shl 11 + XkbGroupNamesMask* = 1 shl 12 + XkbRGNamesMask* = 1 shl 13 + XkbComponentNamesMask* = 0x0000003F + XkbAllNamesMask* = 0x00003FFF # + # Miscellaneous event details: + # - event detail masks for assorted events that don't reall + # have any details. + # + +const + XkbAllStateEventsMask* = XkbAllStateComponentsMask + XkbAllMapEventsMask* = XkbAllMapComponentsMask + XkbAllControlEventsMask* = XkbAllControlsMask + XkbAllIndicatorEventsMask* = XkbAllIndicatorsMask + XkbAllNameEventsMask* = XkbAllNamesMask + XkbAllCompatMapEventsMask* = XkbAllCompatMask + XkbAllBellEventsMask* = int(1) shl 0 + XkbAllActionMessagesMask* = int(1) shl 0 # + # XKB reports one error: BadKeyboard + # A further reason for the error is encoded into to most significant + # byte of the resourceID for the error: + # XkbErr_BadDevice - the device in question was not found + # XkbErr_BadClass - the device was found but it doesn't belong to + # the appropriate class. + # XkbErr_BadId - the device was found and belongs to the right + # class, but not feedback with a matching id was + # found. + # The low byte of the resourceID for this error contains the device + # id, class specifier or feedback id that failed. + # + +const + XkbKeyboard* = 0 + XkbNumberErrors* = 1 + XkbErr_BadDevice* = 0x000000FF + XkbErr_BadClass* = 0x000000FE + XkbErr_BadId* = 0x000000FD # + # Keyboard Components Mask: + # - Specifies the components that follow a GetKeyboardByNameReply + # + +const + XkbClientMapMask* = int(1) shl 0 + XkbServerMapMask* = int(1) shl 1 + XkbCompatMapMask* = int(1) shl 2 + XkbIndicatorMapMask* = int(1) shl 3 + XkbNamesMask* = int(1) shl 4 + XkbGeometryMask* = int(1) shl 5 + XkbControlsMask* = int(1) shl 6 + XkbAllComponentsMask* = 0x0000007F # + # AccessX Options Mask + # - The 'accessXOptions' field of an XkbControlsRec specifies the + # AccessX options that are currently in effect. + # - The 'accessXTimeoutOptionsMask' and 'accessXTimeoutOptionsValues' + # fields of an XkbControlsRec specify the Access X options to be + # changed if the keyboard times out and the values to which they + # should be changed. + # + +const + XkbAX_SKPressFBMask* = int(1) shl 0 + XkbAX_SKAcceptFBMask* = int(1) shl 1 + XkbAX_FeatureFBMask* = int(1) shl 2 + XkbAX_SlowWarnFBMask* = int(1) shl 3 + XkbAX_IndicatorFBMask* = int(1) shl 4 + XkbAX_StickyKeysFBMask* = int(1) shl 5 + XkbAX_TwoKeysMask* = int(1) shl 6 + XkbAX_LatchToLockMask* = int(1) shl 7 + XkbAX_SKReleaseFBMask* = int(1) shl 8 + XkbAX_SKRejectFBMask* = int(1) shl 9 + XkbAX_BKRejectFBMask* = int(1) shl 10 + XkbAX_DumbBellFBMask* = int(1) shl 11 + XkbAX_FBOptionsMask* = 0x00000F3F + XkbAX_SKOptionsMask* = 0x000000C0 + XkbAX_AllOptionsMask* = 0x00000FFF # + # XkbUseCoreKbd is used to specify the core keyboard without having + # to look up its X input extension identifier. + # XkbUseCorePtr is used to specify the core pointer without having + # to look up its X input extension identifier. + # XkbDfltXIClass is used to specify "don't care" any place that the + # XKB protocol is looking for an X Input Extension + # device class. + # XkbDfltXIId is used to specify "don't care" any place that the + # XKB protocol is looking for an X Input Extension + # feedback identifier. + # XkbAllXIClasses is used to get information about all device indicators, + # whether they're part of the indicator feedback class + # or the keyboard feedback class. + # XkbAllXIIds is used to get information about all device indicator + # feedbacks without having to list them. + # XkbXINone is used to indicate that no class or id has been specified. + # XkbLegalXILedClass(c) True if 'c' specifies a legal class with LEDs + # XkbLegalXIBellClass(c) True if 'c' specifies a legal class with bells + # XkbExplicitXIDevice(d) True if 'd' explicitly specifies a device + # XkbExplicitXIClass(c) True if 'c' explicitly specifies a device class + # XkbExplicitXIId(c) True if 'i' explicitly specifies a device id + # XkbSingleXIClass(c) True if 'c' specifies exactly one device class, + # including the default. + # XkbSingleXIId(i) True if 'i' specifies exactly one device + # identifier, including the default. + # + +const + XkbUseCoreKbd* = 0x00000100 + XkbUseCorePtr* = 0x00000200 + XkbDfltXIClass* = 0x00000300 + XkbDfltXIId* = 0x00000400 + XkbAllXIClasses* = 0x00000500 + XkbAllXIIds* = 0x00000600 + XkbXINone* = 0x0000FF00 + +proc XkbLegalXILedClass*(c: int): bool +proc XkbLegalXIBellClass*(c: int): bool +proc XkbExplicitXIDevice*(c: int): bool +proc XkbExplicitXIClass*(c: int): bool +proc XkbExplicitXIId*(c: int): bool +proc XkbSingleXIClass*(c: int): bool +proc XkbSingleXIId*(c: int): bool +const + XkbNoModifier* = 0x000000FF + XkbNoShiftLevel* = 0x000000FF + XkbNoShape* = 0x000000FF + XkbNoIndicator* = 0x000000FF + XkbNoModifierMask* = 0 + XkbAllModifiersMask* = 0x000000FF + XkbAllVirtualModsMask* = 0x0000FFFF + XkbNumKbdGroups* = 4 + XkbMaxKbdGroup* = XkbNumKbdGroups - 1 + XkbMaxMouseKeysBtn* = 4 # + # Group Index and Mask: + # - Indices into the kt_index array of a key type. + # - Mask specifies types to be changed for XkbChangeTypesOfKey + # + +const + XkbGroup1Index* = 0 + XkbGroup2Index* = 1 + XkbGroup3Index* = 2 + XkbGroup4Index* = 3 + XkbAnyGroup* = 254 + XkbAllGroups* = 255 + XkbGroup1Mask* = 1 shl 0 + XkbGroup2Mask* = 1 shl 1 + XkbGroup3Mask* = 1 shl 2 + XkbGroup4Mask* = 1 shl 3 + XkbAnyGroupMask* = 1 shl 7 + XkbAllGroupsMask* = 0x0000000F # + # BuildCoreState: Given a keyboard group and a modifier state, + # construct the value to be reported an event. + # GroupForCoreState: Given the state reported in an event, + # determine the keyboard group. + # IsLegalGroup: Returns TRUE if 'g' is a valid group index. + # + +proc XkbBuildCoreState*(m, g: int): int +proc XkbGroupForCoreState*(s: int): int +proc XkbIsLegalGroup*(g: int): bool + # + # GroupsWrap values: + # - The 'groupsWrap' field of an XkbControlsRec specifies the + # treatment of out of range groups. + # - Bits 6 and 7 of the group info field of a key symbol map + # specify the interpretation of out of range groups for the + # corresponding key. + # +const + XkbWrapIntoRange* = 0x00000000 + XkbClampIntoRange* = 0x00000040 + XkbRedirectIntoRange* = 0x00000080 # + # Action flags: Reported in the 'flags' field of most key actions. + # Interpretation depends on the type of the action; not all actions + # accept all flags. + # + # Option Used for Actions + # ------ ---------------- + # ClearLocks SetMods, LatchMods, SetGroup, LatchGroup + # LatchToLock SetMods, LatchMods, SetGroup, LatchGroup + # LockNoLock LockMods, ISOLock, LockPtrBtn, LockDeviceBtn + # LockNoUnlock LockMods, ISOLock, LockPtrBtn, LockDeviceBtn + # UseModMapMods SetMods, LatchMods, LockMods, ISOLock + # GroupAbsolute SetGroup, LatchGroup, LockGroup, ISOLock + # UseDfltButton PtrBtn, LockPtrBtn + # NoAcceleration MovePtr + # MoveAbsoluteX MovePtr + # MoveAbsoluteY MovePtr + # ISODfltIsGroup ISOLock + # ISONoAffectMods ISOLock + # ISONoAffectGroup ISOLock + # ISONoAffectPtr ISOLock + # ISONoAffectCtrls ISOLock + # MessageOnPress ActionMessage + # MessageOnRelease ActionMessage + # MessageGenKeyEvent ActionMessage + # AffectDfltBtn SetPtrDflt + # DfltBtnAbsolute SetPtrDflt + # SwitchApplication SwitchScreen + # SwitchAbsolute SwitchScreen + # + +const + XkbSA_ClearLocks* = int(1) shl 0 + XkbSA_LatchToLock* = int(1) shl 1 + XkbSA_LockNoLock* = int(1) shl 0 + XkbSA_LockNoUnlock* = int(1) shl 1 + XkbSA_UseModMapMods* = int(1) shl 2 + XkbSA_GroupAbsolute* = int(1) shl 2 + XkbSA_UseDfltButton* = 0 + XkbSA_NoAcceleration* = int(1) shl 0 + XkbSA_MoveAbsoluteX* = int(1) shl 1 + XkbSA_MoveAbsoluteY* = int(1) shl 2 + XkbSA_ISODfltIsGroup* = int(1) shl 7 + XkbSA_ISONoAffectMods* = int(1) shl 6 + XkbSA_ISONoAffectGroup* = int(1) shl 5 + XkbSA_ISONoAffectPtr* = int(1) shl 4 + XkbSA_ISONoAffectCtrls* = int(1) shl 3 + XkbSA_ISOAffectMask* = 0x00000078 + XkbSA_MessageOnPress* = int(1) shl 0 + XkbSA_MessageOnRelease* = int(1) shl 1 + XkbSA_MessageGenKeyEvent* = int(1) shl 2 + XkbSA_AffectDfltBtn* = 1 + XkbSA_DfltBtnAbsolute* = int(1) shl 2 + XkbSA_SwitchApplication* = int(1) shl 0 + XkbSA_SwitchAbsolute* = int(1) shl 2 # + # The following values apply to the SA_DeviceValuator + # action only. Valuator operations specify the action + # to be taken. Values specified in the action are + # multiplied by 2^scale before they are applied. + # + +const + XkbSA_IgnoreVal* = 0x00000000 + XkbSA_SetValMin* = 0x00000010 + XkbSA_SetValCenter* = 0x00000020 + XkbSA_SetValMax* = 0x00000030 + XkbSA_SetValRelative* = 0x00000040 + XkbSA_SetValAbsolute* = 0x00000050 + XkbSA_ValOpMask* = 0x00000070 + XkbSA_ValScaleMask* = 0x00000007 + +proc XkbSA_ValOp*(a: int): int +proc XkbSA_ValScale*(a: int): int + # + # Action types: specifies the type of a key action. Reported in the + # type field of all key actions. + # +const + XkbSA_NoAction* = 0x00000000 + XkbSA_SetMods* = 0x00000001 + XkbSA_LatchMods* = 0x00000002 + XkbSA_LockMods* = 0x00000003 + XkbSA_SetGroup* = 0x00000004 + XkbSA_LatchGroup* = 0x00000005 + XkbSA_LockGroup* = 0x00000006 + XkbSA_MovePtr* = 0x00000007 + XkbSA_PtrBtn* = 0x00000008 + XkbSA_LockPtrBtn* = 0x00000009 + XkbSA_SetPtrDflt* = 0x0000000A + XkbSA_ISOLock* = 0x0000000B + XkbSA_Terminate* = 0x0000000C + XkbSA_SwitchScreen* = 0x0000000D + XkbSA_SetControls* = 0x0000000E + XkbSA_LockControls* = 0x0000000F + XkbSA_ActionMessage* = 0x00000010 + XkbSA_RedirectKey* = 0x00000011 + XkbSA_DeviceBtn* = 0x00000012 + XkbSA_LockDeviceBtn* = 0x00000013 + XkbSA_DeviceValuator* = 0x00000014 + XkbSA_LastAction* = XkbSA_DeviceValuator + XkbSA_NumActions* = XkbSA_LastAction + 1 + +const + XkbSA_XFree86Private* = 0x00000086 +# +# Specifies the key actions that clear latched groups or modifiers. +# + +const ##define XkbSA_BreakLatch \ + # ((1<<XkbSA_NoAction)|(1<<XkbSA_PtrBtn)|(1<<XkbSA_LockPtrBtn)|\ + # (1<<XkbSA_Terminate)|(1<<XkbSA_SwitchScreen)|(1<<XkbSA_SetControls)|\ + # (1<<XkbSA_LockControls)|(1<<XkbSA_ActionMessage)|\ + # (1<<XkbSA_RedirectKey)|(1<<XkbSA_DeviceBtn)|(1<<XkbSA_LockDeviceBtn)) + # + XkbSA_BreakLatch* = (1 shl XkbSA_PtrBtn) or (1 shl XkbSA_LockPtrBtn) or + (1 shl XkbSA_Terminate) or (1 shl XkbSA_SwitchScreen) or + (1 shl XkbSA_SetControls) or (1 shl XkbSA_LockControls) or + (1 shl XkbSA_ActionMessage) or (1 shl XkbSA_RedirectKey) or + (1 shl XkbSA_DeviceBtn) or (1 shl XkbSA_LockDeviceBtn) # + # Key Behavior Qualifier: + # KB_Permanent indicates that the behavior describes an unalterable + # characteristic of the keyboard, not an XKB software-simulation of + # the listed behavior. + # Key Behavior Types: + # Specifies the behavior of the underlying key. + # + +const + XkbKB_Permanent* = 0x00000080 + XkbKB_OpMask* = 0x0000007F + XkbKB_Default* = 0x00000000 + XkbKB_Lock* = 0x00000001 + XkbKB_RadioGroup* = 0x00000002 + XkbKB_Overlay1* = 0x00000003 + XkbKB_Overlay2* = 0x00000004 + XkbKB_RGAllowNone* = 0x00000080 # + # Various macros which describe the range of legal keycodes. + # + +const + XkbMinLegalKeyCode* = 8 + XkbMaxLegalKeyCode* = 255 + XkbMaxKeyCount* = XkbMaxLegalKeyCode - XkbMinLegalKeyCode + 1 + XkbPerKeyBitArraySize* = (XkbMaxLegalKeyCode + 1) div 8 + +proc XkbIsLegalKeycode*(k: int): bool +type + PXkbControlsPtr* = ptr TXkbControlsRec + TXkbControlsRec*{.final.} = object + mk_dflt_btn*: int8 + num_groups*: int8 + groups_wrap*: int8 + internal*: TXkbModsRec + ignore_lock*: TXkbModsRec + enabled_ctrls*: int16 + repeat_delay*: int16 + repeat_interval*: int16 + slow_keys_delay*: int16 + debounce_delay*: int16 + mk_delay*: int16 + mk_interval*: int16 + mk_time_to_max*: int16 + mk_max_speed*: int16 + mk_curve*: int16 + ax_options*: int16 + ax_timeout*: int16 + axt_opts_mask*: int16 + axt_opts_values*: int16 + axt_ctrls_mask*: int16 + axt_ctrls_values*: int16 + per_key_repeat*: array[0..XkbPerKeyBitArraySize - 1, int8] + + +proc XkbAX_AnyFeedback*(c: PXkbControlsPtr): int16 +proc XkbAX_NeedOption*(c: PXkbControlsPtr, w: int16): int16 +proc XkbAX_NeedFeedback*(c: PXkbControlsPtr, w: int16): bool + # + # Assorted constants and limits. + # +const + XkbNumModifiers* = 8 + XkbNumVirtualMods* = 16 + XkbNumIndicators* = 32 + XkbMaxRadioGroups* = 32 + XkbAllRadioGroupsMask* = 0xFFFFFFFF + XkbMaxShiftLevel* = 63 + XkbMaxSymsPerKey* = XkbMaxShiftLevel * XkbNumKbdGroups + XkbRGMaxMembers* = 12 + XkbActionMessageLength* = 6 + XkbKeyNameLength* = 4 + XkbMaxRedirectCount* = 8 + XkbGeomPtsPerMM* = 10 + XkbGeomMaxColors* = 32 + XkbGeomMaxLabelColors* = 3 + XkbGeomMaxPriority* = 255 + +type + PXkbServerMapPtr* = ptr TXkbServerMapRec + TXkbServerMapRec*{.final.} = object + num_acts*: int16 + size_acts*: int16 + acts*: ptr array[0..0xfff, TXkbAction] + behaviors*: PXkbBehavior + key_acts*: PWord + explicit*: PByte + vmods*: array[0..XkbNumVirtualMods - 1, int8] + vmodmap*: PWord + + +proc XkbSMKeyActionsPtr*(m: PXkbServerMapPtr, k: int16): PXkbAction + # + # Structures and access macros used primarily by clients + # +type + PXkbSymMapPtr* = ptr TXkbSymMapRec + TXkbSymMapRec*{.final.} = object + kt_index*: array[0..XkbNumKbdGroups - 1, int8] + group_info*: int8 + width*: int8 + offset*: int8 + + +type + PXkbClientMapPtr* = ptr TXkbClientMapRec + TXkbClientMapRec*{.final.} = object + size_types*: int8 + num_types*: int8 + types*: ptr array[0..0xffff, TXkbKeyTypeRec] + size_syms*: int16 + num_syms*: int16 + syms*: ptr array[0..0xffff, TKeySym] + key_sym_map*: ptr array[0..0xffff, TXkbSymMapRec] + modmap*: PByte + + +proc XkbCMKeyGroupInfo*(m: PXkbClientMapPtr, k: int16): int8 +proc XkbCMKeyNumGroups*(m: PXkbClientMapPtr, k: int16): int8 +proc XkbCMKeyGroupWidth*(m: PXkbClientMapPtr, k: int16, g: int8): int8 +proc XkbCMKeyGroupsWidth*(m: PXkbClientMapPtr, k: int16): int8 +proc XkbCMKeyTypeIndex*(m: PXkbClientMapPtr, k: int16, g: int8): int8 +proc XkbCMKeyType*(m: PXkbClientMapPtr, k: int16, g: int8): PXkbKeyTypePtr +proc XkbCMKeyNumSyms*(m: PXkbClientMapPtr, k: int16): int16 +proc XkbCMKeySymsOffset*(m: PXkbClientMapPtr, k: int16): int8 + # + # Compatibility structures and access macros + # +type + PXkbSymInterpretPtr* = ptr TXkbSymInterpretRec + TXkbSymInterpretRec*{.final.} = object + sym*: TKeySym + flags*: int8 + match*: int8 + mods*: int8 + virtual_mod*: int8 + act*: TXkbAnyAction + + +type + PXkbCompatMapPtr* = ptr TXkbCompatMapRec + TXkbCompatMapRec*{.final.} = object + sym_interpret*: PXkbSymInterpretPtr + groups*: array[0..XkbNumKbdGroups - 1, TXkbModsRec] + num_si*: int16 + size_si*: int16 + + +type + PXkbIndicatorMapPtr* = ptr TXkbIndicatorMapRec + TXkbIndicatorMapRec*{.final.} = object + flags*: int8 + which_groups*: int8 + groups*: int8 + which_mods*: int8 + mods*: TXkbModsRec + ctrls*: int16 + + +proc XkbIM_IsAuto*(i: PXkbIndicatorMapPtr): bool +proc XkbIM_InUse*(i: PXkbIndicatorMapPtr): bool +type + PXkbIndicatorPtr* = ptr TXkbIndicatorRec + TXkbIndicatorRec*{.final.} = object + phys_indicators*: int32 + maps*: array[0..XkbNumIndicators - 1, TXkbIndicatorMapRec] + + +type + PXkbKeyNamePtr* = ptr TXkbKeyNameRec + TXkbKeyNameRec*{.final.} = object + name*: array[0..XkbKeyNameLength - 1, Char] + + +type + PXkbKeyAliasPtr* = ptr TXkbKeyAliasRec + TXkbKeyAliasRec*{.final.} = object # + # Names for everything + # + float*: array[0..XkbKeyNameLength - 1, Char] + alias*: array[0..XkbKeyNameLength - 1, Char] + + +type + PXkbNamesPtr* = ptr TXkbNamesRec + TXkbNamesRec*{.final.} = object # + # Key Type index and mask for the four standard key types. + # + keycodes*: TAtom + geometry*: TAtom + symbols*: TAtom + types*: TAtom + compat*: TAtom + vmods*: array[0..XkbNumVirtualMods - 1, TAtom] + indicators*: array[0..XkbNumIndicators - 1, TAtom] + groups*: array[0..XkbNumKbdGroups - 1, TAtom] + keys*: PXkbKeyNamePtr + key_aliases*: PXkbKeyAliasPtr + radio_groups*: PAtom + phys_symbols*: TAtom + num_keys*: int8 + num_key_aliases*: int8 + num_rg*: int16 + + +const + XkbOneLevelIndex* = 0 + XkbTwoLevelIndex* = 1 + XkbAlphabeticIndex* = 2 + XkbKeypadIndex* = 3 + XkbLastRequiredType* = XkbKeypadIndex + XkbNumRequiredTypes* = XkbLastRequiredType + 1 + XkbMaxKeyTypes* = 255 + XkbOneLevelMask* = 1 shl 0 + XkbTwoLevelMask* = 1 shl 1 + XkbAlphabeticMask* = 1 shl 2 + XkbKeypadMask* = 1 shl 3 + XkbAllRequiredTypes* = 0x0000000F + +proc XkbShiftLevel*(n: int8): int8 +proc XkbShiftLevelMask*(n: int8): int8 + # + # Extension name and version information + # +const + XkbName* = "XKEYBOARD" + XkbMajorVersion* = 1 + XkbMinorVersion* = 0 # + # Explicit map components: + # - Used in the 'explicit' field of an XkbServerMap. Specifies + # the keyboard components that should _not_ be updated automatically + # in response to core protocol keyboard mapping requests. + # + +const + XkbExplicitKeyTypesMask* = 0x0000000F + XkbExplicitKeyType1Mask* = 1 shl 0 + XkbExplicitKeyType2Mask* = 1 shl 1 + XkbExplicitKeyType3Mask* = 1 shl 2 + XkbExplicitKeyType4Mask* = 1 shl 3 + XkbExplicitInterpretMask* = 1 shl 4 + XkbExplicitAutoRepeatMask* = 1 shl 5 + XkbExplicitBehaviorMask* = 1 shl 6 + XkbExplicitVModMapMask* = 1 shl 7 + XkbAllExplicitMask* = 0x000000FF # + # Symbol interpretations flags: + # - Used in the flags field of a symbol interpretation + # + +const + XkbSI_AutoRepeat* = 1 shl 0 + XkbSI_LockingKey* = 1 shl 1 # + # Symbol interpretations match specification: + # - Used in the match field of a symbol interpretation to specify + # the conditions under which an interpretation is used. + # + +const + XkbSI_LevelOneOnly* = 0x00000080 + XkbSI_OpMask* = 0x0000007F + XkbSI_NoneOf* = 0 + XkbSI_AnyOfOrNone* = 1 + XkbSI_AnyOf* = 2 + XkbSI_AllOf* = 3 + XkbSI_Exactly* = 4 # + # Indicator map flags: + # - Used in the flags field of an indicator map to indicate the + # conditions under which and indicator can be changed and the + # effects of changing the indicator. + # + +const + XkbIM_NoExplicit* = int(1) shl 7 + XkbIM_NoAutomatic* = int(1) shl 6 + XkbIM_LEDDrivesKB* = int(1) shl 5 # + # Indicator map component specifications: + # - Used by the 'which_groups' and 'which_mods' fields of an indicator + # map to specify which keyboard components should be used to drive + # the indicator. + # + +const + XkbIM_UseBase* = int(1) shl 0 + XkbIM_UseLatched* = int(1) shl 1 + XkbIM_UseLocked* = int(1) shl 2 + XkbIM_UseEffective* = int(1) shl 3 + XkbIM_UseCompat* = int(1) shl 4 + XkbIM_UseNone* = 0 + XkbIM_UseAnyGroup* = XkbIM_UseBase or XkbIM_UseLatched or XkbIM_UseLocked or + XkbIM_UseEffective + XkbIM_UseAnyMods* = XkbIM_UseAnyGroup or XkbIM_UseCompat # + # GetByName components: + # - Specifies desired or necessary components to GetKbdByName request. + # - Reports the components that were found in a GetKbdByNameReply + # + +const + XkbGBN_TypesMask* = int(1) shl 0 + XkbGBN_CompatMapMask* = int(1) shl 1 + XkbGBN_ClientSymbolsMask* = int(1) shl 2 + XkbGBN_ServerSymbolsMask* = int(1) shl 3 + XkbGBN_SymbolsMask* = XkbGBN_ClientSymbolsMask or XkbGBN_ServerSymbolsMask + XkbGBN_IndicatorMapMask* = int(1) shl 4 + XkbGBN_KeyNamesMask* = int(1) shl 5 + XkbGBN_GeometryMask* = int(1) shl 6 + XkbGBN_OtherNamesMask* = int(1) shl 7 + XkbGBN_AllComponentsMask* = 0x000000FF # + # ListComponents flags + # + +const + XkbLC_Hidden* = int(1) shl 0 + XkbLC_Default* = int(1) shl 1 + XkbLC_Partial* = int(1) shl 2 + XkbLC_AlphanumericKeys* = int(1) shl 8 + XkbLC_ModifierKeys* = int(1) shl 9 + XkbLC_KeypadKeys* = int(1) shl 10 + XkbLC_FunctionKeys* = int(1) shl 11 + XkbLC_AlternateGroup* = int(1) shl 12 # + # X Input Extension Interactions + # - Specifies the possible interactions between XKB and the X input + # extension + # - Used to request (XkbGetDeviceInfo) or change (XKbSetDeviceInfo) + # XKB information about an extension device. + # - Reports the list of supported optional features in the reply to + # XkbGetDeviceInfo or in an XkbExtensionDeviceNotify event. + # XkbXI_UnsupportedFeature is reported in XkbExtensionDeviceNotify + # events to indicate an attempt to use an unsupported feature. + # + +const + XkbXI_KeyboardsMask* = int(1) shl 0 + XkbXI_ButtonActionsMask* = int(1) shl 1 + XkbXI_IndicatorNamesMask* = int(1) shl 2 + XkbXI_IndicatorMapsMask* = int(1) shl 3 + XkbXI_IndicatorStateMask* = int(1) shl 4 + XkbXI_UnsupportedFeatureMask* = int(1) shl 15 + XkbXI_AllFeaturesMask* = 0x0000001F + XkbXI_AllDeviceFeaturesMask* = 0x0000001E + XkbXI_IndicatorsMask* = 0x0000001C + XkbAllExtensionDeviceEventsMask* = 0x0000801F # + # Per-Client Flags: + # - Specifies flags to be changed by the PerClientFlags request. + # + +const + XkbPCF_DetectableAutoRepeatMask* = int(1) shl 0 + XkbPCF_GrabsUseXKBStateMask* = int(1) shl 1 + XkbPCF_AutoResetControlsMask* = int(1) shl 2 + XkbPCF_LookupStateWhenGrabbed* = int(1) shl 3 + XkbPCF_SendEventUsesXKBState* = int(1) shl 4 + XkbPCF_AllFlagsMask* = 0x0000001F # + # Debugging flags and controls + # + +const + XkbDF_DisableLocks* = 1 shl 0 + +type + PXkbPropertyPtr* = ptr TXkbPropertyRec + TXkbPropertyRec*{.final.} = object + name*: cstring + value*: cstring + + +type + PXkbColorPtr* = ptr TXkbColorRec + TXkbColorRec*{.final.} = object + pixel*: int16 + spec*: cstring + + +type + PXkbPointPtr* = ptr TXkbPointRec + TXkbPointRec*{.final.} = object + x*: int16 + y*: int16 + + +type + PXkbBoundsPtr* = ptr TXkbBoundsRec + TXkbBoundsRec*{.final.} = object + x1*: int16 + y1*: int16 + x2*: int16 + y2*: int16 + + +proc XkbBoundsWidth*(b: PXkbBoundsPtr): int16 +proc XkbBoundsHeight*(b: PXkbBoundsPtr): int16 +type + PXkbOutlinePtr* = ptr TXkbOutlineRec + TXkbOutlineRec*{.final.} = object + num_points*: int16 + sz_points*: int16 + corner_radius*: int16 + points*: PXkbPointPtr + + +type + PXkbShapePtr* = ptr TXkbShapeRec + TXkbShapeRec*{.final.} = object + name*: TAtom + num_outlines*: int16 + sz_outlines*: int16 + outlines*: ptr array [0..0xffff, TXkbOutlineRec] + approx*: ptr array[0..0xffff, TXkbOutlineRec] + primary*: ptr array[0..0xffff, TXkbOutlineRec] + bounds*: TXkbBoundsRec + + +proc XkbOutlineIndex*(s: PXkbShapePtr, o: PXkbOutlinePtr): int32 +type + PXkbShapeDoodadPtr* = ptr TXkbShapeDoodadRec + TXkbShapeDoodadRec*{.final.} = object + name*: TAtom + theType*: int8 + priority*: int8 + top*: int16 + left*: int16 + angle*: int16 + color_ndx*: int16 + shape_ndx*: int16 + + +type + PXkbTextDoodadPtr* = ptr TXkbTextDoodadRec + TXkbTextDoodadRec*{.final.} = object + name*: TAtom + theType*: int8 + priority*: int8 + top*: int16 + left*: int16 + angle*: int16 + width*: int16 + height*: int16 + color_ndx*: int16 + text*: cstring + font*: cstring + + +type + PXkbIndicatorDoodadPtr* = ptr TXkbIndicatorDoodadRec + TXkbIndicatorDoodadRec*{.final.} = object + name*: TAtom + theType*: int8 + priority*: int8 + top*: int16 + left*: int16 + angle*: int16 + shape_ndx*: int16 + on_color_ndx*: int16 + off_color_ndx*: int16 + + +type + PXkbLogoDoodadPtr* = ptr TXkbLogoDoodadRec + TXkbLogoDoodadRec*{.final.} = object + name*: TAtom + theType*: int8 + priority*: int8 + top*: int16 + left*: int16 + angle*: int16 + color_ndx*: int16 + shape_ndx*: int16 + logo_name*: cstring + + +type + PXkbAnyDoodadPtr* = ptr TXkbAnyDoodadRec + TXkbAnyDoodadRec*{.final.} = object + name*: TAtom + theType*: int8 + priority*: int8 + top*: int16 + left*: int16 + angle*: int16 + + +type + PXkbDoodadPtr* = ptr TXkbDoodadRec + TXkbDoodadRec*{.final.} = object + any*: TXkbAnyDoodadRec + shape*: TXkbShapeDoodadRec + text*: TXkbTextDoodadRec + indicator*: TXkbIndicatorDoodadRec + logo*: TXkbLogoDoodadRec + + +const + XkbUnknownDoodad* = 0 + XkbOutlineDoodad* = 1 + XkbSolidDoodad* = 2 + XkbTextDoodad* = 3 + XkbIndicatorDoodad* = 4 + XkbLogoDoodad* = 5 + +type + PXkbKeyPtr* = ptr TXkbKeyRec + TXkbKeyRec*{.final.} = object + name*: TXkbKeyNameRec + gap*: int16 + shape_ndx*: int8 + color_ndx*: int8 + + +type + PXkbRowPtr* = ptr TXkbRowRec + TXkbRowRec*{.final.} = object + top*: int16 + left*: int16 + num_keys*: int16 + sz_keys*: int16 + vertical*: int16 + Keys*: PXkbKeyPtr + bounds*: TXkbBoundsRec + + +type + PXkbOverlayPtr* = ptr TXkbOverlayRec #forward for TXkbSectionRec use. + #Do not add more "type" + PXkbSectionPtr* = ptr TXkbSectionRec + TXkbSectionRec*{.final.} = object #Do not add more "type" + name*: TAtom + priority*: int8 + top*: int16 + left*: int16 + width*: int16 + height*: int16 + angle*: int16 + num_rows*: int16 + num_doodads*: int16 + num_overlays*: int16 + rows*: PXkbRowPtr + doodads*: PXkbDoodadPtr + bounds*: TXkbBoundsRec + overlays*: PXkbOverlayPtr + + PXkbOverlayKeyPtr* = ptr TXkbOverlayKeyRec + TXkbOverlayKeyRec*{.final.} = object #Do not add more "type" + over*: TXkbKeyNameRec + under*: TXkbKeyNameRec + + PXkbOverlayRowPtr* = ptr TXkbOverlayRowRec + TXkbOverlayRowRec*{.final.} = object #Do not add more "type" + row_under*: int16 + num_keys*: int16 + sz_keys*: int16 + keys*: PXkbOverlayKeyPtr + + TXkbOverlayRec*{.final.} = object + name*: TAtom + section_under*: PXkbSectionPtr + num_rows*: int16 + sz_rows*: int16 + rows*: PXkbOverlayRowPtr + bounds*: PXkbBoundsPtr + + +type + PXkbGeometryRec* = ptr TXkbGeometryRec + PXkbGeometryPtr* = PXkbGeometryRec + TXkbGeometryRec*{.final.} = object + name*: TAtom + width_mm*: int16 + height_mm*: int16 + label_font*: cstring + label_color*: PXkbColorPtr + base_color*: PXkbColorPtr + sz_properties*: int16 + sz_colors*: int16 + sz_shapes*: int16 + sz_sections*: int16 + sz_doodads*: int16 + sz_key_aliases*: int16 + num_properties*: int16 + num_colors*: int16 + num_shapes*: int16 + num_sections*: int16 + num_doodads*: int16 + num_key_aliases*: int16 + properties*: ptr array[0..0xffff, TXkbPropertyRec] + colors*: ptr array[0..0xffff, TXkbColorRec] + shapes*: ptr array[0..0xffff, TXkbShapeRec] + sections*: ptr array[0..0xffff, TXkbSectionRec] + key_aliases*: ptr array[0..0xffff, TXkbKeyAliasRec] + + +const + XkbGeomPropertiesMask* = 1 shl 0 + XkbGeomColorsMask* = 1 shl 1 + XkbGeomShapesMask* = 1 shl 2 + XkbGeomSectionsMask* = 1 shl 3 + XkbGeomDoodadsMask* = 1 shl 4 + XkbGeomKeyAliasesMask* = 1 shl 5 + XkbGeomAllMask* = 0x0000003F + +type + PXkbGeometrySizesPtr* = ptr TXkbGeometrySizesRec + TXkbGeometrySizesRec*{.final.} = object # + # Tie it all together into one big keyboard description + # + which*: int16 + num_properties*: int16 + num_colors*: int16 + num_shapes*: int16 + num_sections*: int16 + num_doodads*: int16 + num_key_aliases*: int16 + + +type + PXkbDescPtr* = ptr TXkbDescRec + TXkbDescRec*{.final.} = object + dpy*: PDisplay + flags*: int16 + device_spec*: int16 + min_key_code*: TKeyCode + max_key_code*: TKeyCode + ctrls*: PXkbControlsPtr + server*: PXkbServerMapPtr + map*: PXkbClientMapPtr + indicators*: PXkbIndicatorPtr + names*: PXkbNamesPtr + compat*: PXkbCompatMapPtr + geom*: PXkbGeometryPtr + + +proc XkbKeyKeyTypeIndex*(d: PXkbDescPtr, k: int16, g: int8): int8 +proc XkbKeyKeyType*(d: PXkbDescPtr, k: int16, g: int8): PXkbKeyTypePtr +proc XkbKeyGroupWidth*(d: PXkbDescPtr, k: int16, g: int8): int8 +proc XkbKeyGroupsWidth*(d: PXkbDescPtr, k: int16): int8 +proc XkbKeyGroupInfo*(d: PXkbDescPtr, k: int16): int8 +proc XkbKeyNumGroups*(d: PXkbDescPtr, k: int16): int8 +proc XkbKeyNumSyms*(d: PXkbDescPtr, k: int16): int16 +proc XkbKeySym*(d: PXkbDescPtr, k: int16, n: int16): TKeySym +proc XkbKeySymEntry*(d: PXkbDescPtr, k: int16, sl: int16, g: int8): TKeySym +proc XkbKeyAction*(d: PXkbDescPtr, k: int16, n: int16): PXkbAction +proc XkbKeyActionEntry*(d: PXkbDescPtr, k: int16, sl: int16, g: int8): int8 +proc XkbKeyHasActions*(d: PXkbDescPtr, k: int16): bool +proc XkbKeyNumActions*(d: PXkbDescPtr, k: int16): int16 +proc XkbKeyActionsPtr*(d: PXkbDescPtr, k: int16): PXkbAction +proc XkbKeycodeInRange*(d: PXkbDescPtr, k: int16): bool +proc XkbNumKeys*(d: PXkbDescPtr): int8 + # + # The following structures can be used to track changes + # to a keyboard device + # +type + PXkbMapChangesPtr* = ptr TXkbMapChangesRec + TXkbMapChangesRec*{.final.} = object + changed*: int16 + min_key_code*: TKeyCode + max_key_code*: TKeyCode + first_type*: int8 + num_types*: int8 + first_key_sym*: TKeyCode + num_key_syms*: int8 + first_key_act*: TKeyCode + num_key_acts*: int8 + first_key_behavior*: TKeyCode + num_key_behaviors*: int8 + first_key_explicit*: TKeyCode + num_key_explicit*: int8 + first_modmap_key*: TKeyCode + num_modmap_keys*: int8 + first_vmodmap_key*: TKeyCode + num_vmodmap_keys*: int8 + pad*: int8 + vmods*: int16 + + +type + PXkbControlsChangesPtr* = ptr TXkbControlsChangesRec + TXkbControlsChangesRec*{.final.} = object + changed_ctrls*: int16 + enabled_ctrls_changes*: int16 + num_groups_changed*: bool + + +type + PXkbIndicatorChangesPtr* = ptr TXkbIndicatorChangesRec + TXkbIndicatorChangesRec*{.final.} = object + state_changes*: int16 + map_changes*: int16 + + +type + PXkbNameChangesPtr* = ptr TXkbNameChangesRec + TXkbNameChangesRec*{.final.} = object + changed*: int16 + first_type*: int8 + num_types*: int8 + first_lvl*: int8 + num_lvls*: int8 + num_aliases*: int8 + num_rg*: int8 + first_key*: int8 + num_keys*: int8 + changed_vmods*: int16 + changed_indicators*: int32 + changed_groups*: int8 + + +type + PXkbCompatChangesPtr* = ptr TXkbCompatChangesRec + TXkbCompatChangesRec*{.final.} = object + changed_groups*: int8 + first_si*: int16 + num_si*: int16 + + +type + PXkbChangesPtr* = ptr TXkbChangesRec + TXkbChangesRec*{.final.} = object # + # These data structures are used to construct a keymap from + # a set of components or to list components in the server + # database. + # + device_spec*: int16 + state_changes*: int16 + map*: TXkbMapChangesRec + ctrls*: TXkbControlsChangesRec + indicators*: TXkbIndicatorChangesRec + names*: TXkbNameChangesRec + compat*: TXkbCompatChangesRec + + +type + PXkbComponentNamesPtr* = ptr TXkbComponentNamesRec + TXkbComponentNamesRec*{.final.} = object + keymap*: ptr int16 + keycodes*: ptr int16 + types*: ptr int16 + compat*: ptr int16 + symbols*: ptr int16 + geometry*: ptr int16 + + +type + PXkbComponentNamePtr* = ptr TXkbComponentNameRec + TXkbComponentNameRec*{.final.} = object + flags*: int16 + name*: cstring + + +type + PXkbComponentListPtr* = ptr TXkbComponentListRec + TXkbComponentListRec*{.final.} = object # + # The following data structures describe and track changes to a + # non-keyboard extension device + # + num_keymaps*: int16 + num_keycodes*: int16 + num_types*: int16 + num_compat*: int16 + num_symbols*: int16 + num_geometry*: int16 + keymaps*: PXkbComponentNamePtr + keycodes*: PXkbComponentNamePtr + types*: PXkbComponentNamePtr + compat*: PXkbComponentNamePtr + symbols*: PXkbComponentNamePtr + geometry*: PXkbComponentNamePtr + + +type + PXkbDeviceLedInfoPtr* = ptr TXkbDeviceLedInfoRec + TXkbDeviceLedInfoRec*{.final.} = object + led_class*: int16 + led_id*: int16 + phys_indicators*: int16 + maps_present*: int16 + names_present*: int16 + state*: int16 + names*: array[0..XkbNumIndicators - 1, TAtom] + maps*: array[0..XkbNumIndicators - 1, TXkbIndicatorMapRec] + + +type + PXkbDeviceInfoPtr* = ptr TXkbDeviceInfoRec + TXkbDeviceInfoRec*{.final.} = object + name*: cstring + theType*: TAtom + device_spec*: int16 + has_own_state*: bool + supported*: int16 + unsupported*: int16 + num_btns*: int16 + btn_acts*: PXkbAction + sz_leds*: int16 + num_leds*: int16 + dflt_kbd_fb*: int16 + dflt_led_fb*: int16 + leds*: PXkbDeviceLedInfoPtr + + +proc XkbXI_DevHasBtnActs*(d: PXkbDeviceInfoPtr): bool +proc XkbXI_LegalDevBtn*(d: PXkbDeviceInfoPtr, b: int16): bool +proc XkbXI_DevHasLeds*(d: PXkbDeviceInfoPtr): bool +type + PXkbDeviceLedChangesPtr* = ptr TXkbDeviceLedChangesRec + TXkbDeviceLedChangesRec*{.final.} = object + led_class*: int16 + led_id*: int16 + defined*: int16 #names or maps changed + next*: PXkbDeviceLedChangesPtr + + +type + PXkbDeviceChangesPtr* = ptr TXkbDeviceChangesRec + TXkbDeviceChangesRec*{.final.} = object + changed*: int16 + first_btn*: int16 + num_btns*: int16 + leds*: TXkbDeviceLedChangesRec + + +proc XkbShapeDoodadColor*(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr): PXkbColorPtr +proc XkbShapeDoodadShape*(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr): PXkbShapePtr +proc XkbSetShapeDoodadColor*(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr, + c: PXkbColorPtr) +proc XkbSetShapeDoodadShape*(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr, + s: PXkbShapePtr) +proc XkbTextDoodadColor*(g: PXkbGeometryPtr, d: PXkbTextDoodadPtr): PXkbColorPtr +proc XkbSetTextDoodadColor*(g: PXkbGeometryPtr, d: PXkbTextDoodadPtr, + c: PXkbColorPtr) +proc XkbIndicatorDoodadShape*(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr): PXkbShapeDoodadPtr +proc XkbIndicatorDoodadOnColor*(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr): PXkbColorPtr +proc XkbIndicatorDoodadOffColor*(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr): PXkbColorPtr +proc XkbSetIndicatorDoodadOnColor*(g: PXkbGeometryPtr, + d: PXkbIndicatorDoodadPtr, c: PXkbColorPtr) +proc XkbSetIndicatorDoodadOffColor*(g: PXkbGeometryPtr, + d: PXkbIndicatorDoodadPtr, c: PXkbColorPtr) +proc XkbSetIndicatorDoodadShape*(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr, + s: PXkbShapeDoodadPtr) +proc XkbLogoDoodadColor*(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr): PXkbColorPtr +proc XkbLogoDoodadShape*(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr): PXkbShapeDoodadPtr +proc XkbSetLogoDoodadColor*(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr, + c: PXkbColorPtr) +proc XkbSetLogoDoodadShape*(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr, + s: PXkbShapeDoodadPtr) +proc XkbKeyShape*(g: PXkbGeometryPtr, k: PXkbKeyPtr): PXkbShapeDoodadPtr +proc XkbKeyColor*(g: PXkbGeometryPtr, k: PXkbKeyPtr): PXkbColorPtr +proc XkbSetKeyShape*(g: PXkbGeometryPtr, k: PXkbKeyPtr, s: PXkbShapeDoodadPtr) +proc XkbSetKeyColor*(g: PXkbGeometryPtr, k: PXkbKeyPtr, c: PXkbColorPtr) +proc XkbGeomColorIndex*(g: PXkbGeometryPtr, c: PXkbColorPtr): int32 +proc XkbAddGeomProperty*(geom: PXkbGeometryPtr, name: cstring, value: cstring): PXkbPropertyPtr{. + cdecl, dynlib: libX11, importc: "XkbAddGeomProperty".} +proc XkbAddGeomKeyAlias*(geom: PXkbGeometryPtr, alias: cstring, float: cstring): PXkbKeyAliasPtr{. + cdecl, dynlib: libX11, importc: "XkbAddGeomKeyAlias".} +proc XkbAddGeomColor*(geom: PXkbGeometryPtr, spec: cstring, pixel: int16): PXkbColorPtr{. + cdecl, dynlib: libX11, importc: "XkbAddGeomColor".} +proc XkbAddGeomOutline*(shape: PXkbShapePtr, sz_points: int16): PXkbOutlinePtr{. + cdecl, dynlib: libX11, importc: "XkbAddGeomOutline".} +proc XkbAddGeomShape*(geom: PXkbGeometryPtr, name: TAtom, sz_outlines: int16): PXkbShapePtr{. + cdecl, dynlib: libX11, importc: "XkbAddGeomShape".} +proc XkbAddGeomKey*(row: PXkbRowPtr): PXkbKeyPtr{.cdecl, dynlib: libX11, + importc: "XkbAddGeomKey".} +proc XkbAddGeomRow*(section: PXkbSectionPtr, sz_keys: int16): PXkbRowPtr{.cdecl, + dynlib: libX11, importc: "XkbAddGeomRow".} +proc XkbAddGeomSection*(geom: PXkbGeometryPtr, name: TAtom, sz_rows: int16, + sz_doodads: int16, sz_overlays: int16): PXkbSectionPtr{. + cdecl, dynlib: libX11, importc: "XkbAddGeomSection".} +proc XkbAddGeomOverlay*(section: PXkbSectionPtr, name: TAtom, sz_rows: int16): PXkbOverlayPtr{. + cdecl, dynlib: libX11, importc: "XkbAddGeomOverlay".} +proc XkbAddGeomOverlayRow*(overlay: PXkbOverlayPtr, row_under: int16, + sz_keys: int16): PXkbOverlayRowPtr{.cdecl, + dynlib: libX11, importc: "XkbAddGeomOverlayRow".} +proc XkbAddGeomOverlayKey*(overlay: PXkbOverlayPtr, row: PXkbOverlayRowPtr, + over: cstring, under: cstring): PXkbOverlayKeyPtr{. + cdecl, dynlib: libX11, importc: "XkbAddGeomOverlayKey".} +proc XkbAddGeomDoodad*(geom: PXkbGeometryPtr, section: PXkbSectionPtr, + name: TAtom): PXkbDoodadPtr{.cdecl, dynlib: libX11, + importc: "XkbAddGeomDoodad".} +proc XkbFreeGeomKeyAliases*(geom: PXkbGeometryPtr, first: int16, count: int16, + freeAll: bool){.cdecl, dynlib: libX11, + importc: "XkbFreeGeomKeyAliases".} +proc XkbFreeGeomColors*(geom: PXkbGeometryPtr, first: int16, count: int16, + freeAll: bool){.cdecl, dynlib: libX11, + importc: "XkbFreeGeomColors".} +proc XkbFreeGeomDoodads*(doodads: PXkbDoodadPtr, nDoodads: int16, freeAll: bool){. + cdecl, dynlib: libX11, importc: "XkbFreeGeomDoodads".} +proc XkbFreeGeomProperties*(geom: PXkbGeometryPtr, first: int16, count: int16, + freeAll: bool){.cdecl, dynlib: libX11, + importc: "XkbFreeGeomProperties".} +proc XkbFreeGeomOverlayKeys*(row: PXkbOverlayRowPtr, first: int16, count: int16, + freeAll: bool){.cdecl, dynlib: libX11, + importc: "XkbFreeGeomOverlayKeys".} +proc XkbFreeGeomOverlayRows*(overlay: PXkbOverlayPtr, first: int16, + count: int16, freeAll: bool){.cdecl, + dynlib: libX11, importc: "XkbFreeGeomOverlayRows".} +proc XkbFreeGeomOverlays*(section: PXkbSectionPtr, first: int16, count: int16, + freeAll: bool){.cdecl, dynlib: libX11, + importc: "XkbFreeGeomOverlays".} +proc XkbFreeGeomKeys*(row: PXkbRowPtr, first: int16, count: int16, freeAll: bool){. + cdecl, dynlib: libX11, importc: "XkbFreeGeomKeys".} +proc XkbFreeGeomRows*(section: PXkbSectionPtr, first: int16, count: int16, + freeAll: bool){.cdecl, dynlib: libX11, + importc: "XkbFreeGeomRows".} +proc XkbFreeGeomSections*(geom: PXkbGeometryPtr, first: int16, count: int16, + freeAll: bool){.cdecl, dynlib: libX11, + importc: "XkbFreeGeomSections".} +proc XkbFreeGeomPoints*(outline: PXkbOutlinePtr, first: int16, count: int16, + freeAll: bool){.cdecl, dynlib: libX11, + importc: "XkbFreeGeomPoints".} +proc XkbFreeGeomOutlines*(shape: PXkbShapePtr, first: int16, count: int16, + freeAll: bool){.cdecl, dynlib: libX11, + importc: "XkbFreeGeomOutlines".} +proc XkbFreeGeomShapes*(geom: PXkbGeometryPtr, first: int16, count: int16, + freeAll: bool){.cdecl, dynlib: libX11, + importc: "XkbFreeGeomShapes".} +proc XkbFreeGeometry*(geom: PXkbGeometryPtr, which: int16, freeMap: bool){. + cdecl, dynlib: libX11, importc: "XkbFreeGeometry".} +proc XkbAllocGeomProps*(geom: PXkbGeometryPtr, nProps: int16): TStatus{.cdecl, + dynlib: libX11, importc: "XkbAllocGeomProps".} +proc XkbAllocGeomKeyAliases*(geom: PXkbGeometryPtr, nAliases: int16): TStatus{. + cdecl, dynlib: libX11, importc: "XkbAllocGeomKeyAliases".} +proc XkbAllocGeomColors*(geom: PXkbGeometryPtr, nColors: int16): TStatus{.cdecl, + dynlib: libX11, importc: "XkbAllocGeomColors".} +proc XkbAllocGeomShapes*(geom: PXkbGeometryPtr, nShapes: int16): TStatus{.cdecl, + dynlib: libX11, importc: "XkbAllocGeomShapes".} +proc XkbAllocGeomSections*(geom: PXkbGeometryPtr, nSections: int16): TStatus{. + cdecl, dynlib: libX11, importc: "XkbAllocGeomSections".} +proc XkbAllocGeomOverlays*(section: PXkbSectionPtr, num_needed: int16): TStatus{. + cdecl, dynlib: libX11, importc: "XkbAllocGeomOverlays".} +proc XkbAllocGeomOverlayRows*(overlay: PXkbOverlayPtr, num_needed: int16): TStatus{. + cdecl, dynlib: libX11, importc: "XkbAllocGeomOverlayRows".} +proc XkbAllocGeomOverlayKeys*(row: PXkbOverlayRowPtr, num_needed: int16): TStatus{. + cdecl, dynlib: libX11, importc: "XkbAllocGeomOverlayKeys".} +proc XkbAllocGeomDoodads*(geom: PXkbGeometryPtr, nDoodads: int16): TStatus{. + cdecl, dynlib: libX11, importc: "XkbAllocGeomDoodads".} +proc XkbAllocGeomSectionDoodads*(section: PXkbSectionPtr, nDoodads: int16): TStatus{. + cdecl, dynlib: libX11, importc: "XkbAllocGeomSectionDoodads".} +proc XkbAllocGeomOutlines*(shape: PXkbShapePtr, nOL: int16): TStatus{.cdecl, + dynlib: libX11, importc: "XkbAllocGeomOutlines".} +proc XkbAllocGeomRows*(section: PXkbSectionPtr, nRows: int16): TStatus{.cdecl, + dynlib: libX11, importc: "XkbAllocGeomRows".} +proc XkbAllocGeomPoints*(ol: PXkbOutlinePtr, nPts: int16): TStatus{.cdecl, + dynlib: libX11, importc: "XkbAllocGeomPoints".} +proc XkbAllocGeomKeys*(row: PXkbRowPtr, nKeys: int16): TStatus{.cdecl, + dynlib: libX11, importc: "XkbAllocGeomKeys".} +proc XkbAllocGeometry*(xkb: PXkbDescPtr, sizes: PXkbGeometrySizesPtr): TStatus{. + cdecl, dynlib: libX11, importc: "XkbAllocGeometry".} +proc XkbSetGeometryProc*(dpy: PDisplay, deviceSpec: int16, geom: PXkbGeometryPtr): TStatus{. + cdecl, dynlib: libX11, importc: "XkbSetGeometry".} +proc XkbComputeShapeTop*(shape: PXkbShapePtr, bounds: PXkbBoundsPtr): bool{. + cdecl, dynlib: libX11, importc: "XkbComputeShapeTop".} +proc XkbComputeShapeBounds*(shape: PXkbShapePtr): bool{.cdecl, dynlib: libX11, + importc: "XkbComputeShapeBounds".} +proc XkbComputeRowBounds*(geom: PXkbGeometryPtr, section: PXkbSectionPtr, + row: PXkbRowPtr): bool{.cdecl, dynlib: libX11, + importc: "XkbComputeRowBounds".} +proc XkbComputeSectionBounds*(geom: PXkbGeometryPtr, section: PXkbSectionPtr): bool{. + cdecl, dynlib: libX11, importc: "XkbComputeSectionBounds".} +proc XkbFindOverlayForKey*(geom: PXkbGeometryPtr, wanted: PXkbSectionPtr, + under: cstring): cstring{.cdecl, dynlib: libX11, + importc: "XkbFindOverlayForKey".} +proc XkbGetGeometryProc*(dpy: PDisplay, xkb: PXkbDescPtr): TStatus{.cdecl, + dynlib: libX11, importc: "XkbGetGeometry".} +proc XkbGetNamedGeometry*(dpy: PDisplay, xkb: PXkbDescPtr, name: TAtom): TStatus{. + cdecl, dynlib: libX11, importc: "XkbGetNamedGeometry".} +when defined(XKB_IN_SERVER): + proc SrvXkbAddGeomKeyAlias*(geom: PXkbGeometryPtr, alias: cstring, + float: cstring): PXkbKeyAliasPtr{.cdecl, + dynlib: libX11, importc: "XkbAddGeomKeyAlias".} + proc SrvXkbAddGeomColor*(geom: PXkbGeometryPtr, spec: cstring, pixel: int16): PXkbColorPtr{. + cdecl, dynlib: libX11, importc: "XkbAddGeomColor".} + proc SrvXkbAddGeomDoodad*(geom: PXkbGeometryPtr, section: PXkbSectionPtr, + name: TAtom): PXkbDoodadPtr{.cdecl, dynlib: libX11, + importc: "XkbAddGeomDoodad".} + proc SrvXkbAddGeomKey*(geom: PXkbGeometryPtr, alias: cstring, float: cstring): PXkbKeyAliasPtr{. + cdecl, dynlib: libX11, importc: "XkbAddGeomKeyAlias".} + proc SrvXkbAddGeomOutline*(shape: PXkbShapePtr, sz_points: int16): PXkbOutlinePtr{. + cdecl, dynlib: libX11, importc: "XkbAddGeomOutline".} + proc SrvXkbAddGeomOverlay*(overlay: PXkbOverlayPtr, row: PXkbOverlayRowPtr, + over: cstring, under: cstring): PXkbOverlayKeyPtr{. + cdecl, dynlib: libX11, importc: "XkbAddGeomOverlayKey".} + proc SrvXkbAddGeomOverlayRow*(overlay: PXkbOverlayPtr, row_under: int16, + sz_keys: int16): PXkbOverlayRowPtr{.cdecl, + dynlib: libX11, importc: "XkbAddGeomOverlayRow".} + proc SrvXkbAddGeomOverlayKey*(overlay: PXkbOverlayPtr, row: PXkbOverlayRowPtr, + over: cstring, under: cstring): PXkbOverlayKeyPtr{. + cdecl, dynlib: libX11, importc: "XkbAddGeomOverlayKey".} + proc SrvXkbAddGeomProperty*(geom: PXkbGeometryPtr, name: cstring, + value: cstring): PXkbPropertyPtr{.cdecl, + dynlib: libX11, importc: "XkbAddGeomProperty".} + proc SrvXkbAddGeomRow*(section: PXkbSectionPtr, sz_keys: int16): PXkbRowPtr{. + cdecl, dynlib: libX11, importc: "XkbAddGeomRow".} + proc SrvXkbAddGeomSection*(geom: PXkbGeometryPtr, name: TAtom, sz_rows: int16, + sz_doodads: int16, sz_overlays: int16): PXkbSectionPtr{. + cdecl, dynlib: libX11, importc: "XkbAddGeomSection".} + proc SrvXkbAddGeomShape*(geom: PXkbGeometryPtr, name: TAtom, + sz_outlines: int16): PXkbShapePtr{.cdecl, + dynlib: libX11, importc: "XkbAddGeomShape".} + proc SrvXkbAllocGeomKeyAliases*(geom: PXkbGeometryPtr, nAliases: int16): TStatus{. + cdecl, dynlib: libX11, importc: "XkbAllocGeomKeyAliases".} + proc SrvXkbAllocGeomColors*(geom: PXkbGeometryPtr, nColors: int16): TStatus{. + cdecl, dynlib: libX11, importc: "XkbAllocGeomColors".} + proc SrvXkbAllocGeomDoodads*(geom: PXkbGeometryPtr, nDoodads: int16): TStatus{. + cdecl, dynlib: libX11, importc: "XkbAllocGeomDoodads".} + proc SrvXkbAllocGeomKeys*(row: PXkbRowPtr, nKeys: int16): TStatus{.cdecl, + dynlib: libX11, importc: "XkbAllocGeomKeys".} + proc SrvXkbAllocGeomOutlines*(shape: PXkbShapePtr, nOL: int16): TStatus{. + cdecl, dynlib: libX11, importc: "XkbAllocGeomOutlines".} + proc SrvXkbAllocGeomPoints*(ol: PXkbOutlinePtr, nPts: int16): TStatus{.cdecl, + dynlib: libX11, importc: "XkbAllocGeomPoints".} + proc SrvXkbAllocGeomProps*(geom: PXkbGeometryPtr, nProps: int16): TStatus{. + cdecl, dynlib: libX11, importc: "XkbAllocGeomProps".} + proc SrvXkbAllocGeomRows*(section: PXkbSectionPtr, nRows: int16): TStatus{. + cdecl, dynlib: libX11, importc: "XkbAllocGeomRows".} + proc SrvXkbAllocGeomSectionDoodads*(section: PXkbSectionPtr, nDoodads: int16): TStatus{. + cdecl, dynlib: libX11, importc: "XkbAllocGeomSectionDoodads".} + proc SrvXkbAllocGeomSections*(geom: PXkbGeometryPtr, nSections: int16): TStatus{. + cdecl, dynlib: libX11, importc: "XkbAllocGeomSections".} + proc SrvXkbAllocGeomOverlays*(section: PXkbSectionPtr, num_needed: int16): TStatus{. + cdecl, dynlib: libX11, importc: "XkbAllocGeomOverlays".} + proc SrvXkbAllocGeomOverlayRows*(overlay: PXkbOverlayPtr, num_needed: int16): TStatus{. + cdecl, dynlib: libX11, importc: "XkbAllocGeomOverlayRows".} + proc SrvXkbAllocGeomOverlayKeys*(row: PXkbOverlayRowPtr, num_needed: int16): TStatus{. + cdecl, dynlib: libX11, importc: "XkbAllocGeomOverlayKeys".} + proc SrvXkbAllocGeomShapes*(geom: PXkbGeometryPtr, nShapes: int16): TStatus{. + cdecl, dynlib: libX11, importc: "XkbAllocGeomShapes".} + proc SrvXkbAllocGeometry*(xkb: PXkbDescPtr, sizes: PXkbGeometrySizesPtr): TStatus{. + cdecl, dynlib: libX11, importc: "XkbAllocGeometry".} + proc SrvXkbFreeGeomKeyAliases*(geom: PXkbGeometryPtr, first: int16, + count: int16, freeAll: bool){.cdecl, + dynlib: libX11, importc: "XkbFreeGeomKeyAliases".} + proc SrvXkbFreeGeomColors*(geom: PXkbGeometryPtr, first: int16, count: int16, + freeAll: bool){.cdecl, dynlib: libX11, + importc: "XkbFreeGeomColors".} + proc SrvXkbFreeGeomDoodads*(doodads: PXkbDoodadPtr, nDoodads: int16, + freeAll: bool){.cdecl, dynlib: libX11, + importc: "XkbFreeGeomDoodads".} + proc SrvXkbFreeGeomProperties*(geom: PXkbGeometryPtr, first: int16, + count: int16, freeAll: bool){.cdecl, + dynlib: libX11, importc: "XkbFreeGeomProperties".} + proc SrvXkbFreeGeomOverlayKeys*(row: PXkbOverlayRowPtr, first: int16, + count: int16, freeAll: bool){.cdecl, + dynlib: libX11, importc: "XkbFreeGeomOverlayKeys".} + proc SrvXkbFreeGeomOverlayRows*(overlay: PXkbOverlayPtr, first: int16, + count: int16, freeAll: bool){.cdecl, + dynlib: libX11, importc: "XkbFreeGeomOverlayRows".} + proc SrvXkbFreeGeomOverlays*(section: PXkbSectionPtr, first: int16, + count: int16, freeAll: bool){.cdecl, + dynlib: libX11, importc: "XkbFreeGeomOverlays".} + proc SrvXkbFreeGeomKeys*(row: PXkbRowPtr, first: int16, count: int16, + freeAll: bool){.cdecl, dynlib: libX11, + importc: "XkbFreeGeomKeys".} + proc SrvXkbFreeGeomRows*(section: PXkbSectionPtr, first: int16, count: int16, + freeAll: bool){.cdecl, dynlib: libX11, + importc: "XkbFreeGeomRows".} + proc SrvXkbFreeGeomSections*(geom: PXkbGeometryPtr, first: int16, + count: int16, freeAll: bool){.cdecl, + dynlib: libX11, importc: "XkbFreeGeomSections".} + proc SrvXkbFreeGeomPoints*(outline: PXkbOutlinePtr, first: int16, + count: int16, freeAll: bool){.cdecl, + dynlib: libX11, importc: "XkbFreeGeomPoints".} + proc SrvXkbFreeGeomOutlines*(shape: PXkbShapePtr, first: int16, count: int16, + freeAll: bool){.cdecl, dynlib: libX11, + importc: "XkbFreeGeomOutlines".} + proc SrvXkbFreeGeomShapes*(geom: PXkbGeometryPtr, first: int16, count: int16, + freeAll: bool){.cdecl, dynlib: libX11, + importc: "XkbFreeGeomShapes".} + proc SrvXkbFreeGeometry*(geom: PXkbGeometryPtr, which: int16, freeMap: bool){. + cdecl, dynlib: libX11, importc: "XkbFreeGeometry".} +# implementation + +import #************************************ xkb ************************************ + xi + +proc XkbLegalXILedClass(c: int): bool = + ##define XkbLegalXILedClass(c) (((c)==KbdFeedbackClass)||((c)==LedFeedbackClass)|| + # ((c)==XkbDfltXIClass)||((c)==XkbAllXIClasses)) + Result = (c == KbdFeedbackClass) or (c == LedFeedbackClass) or + (c == XkbDfltXIClass) or (c == XkbAllXIClasses) + +proc XkbLegalXIBellClass(c: int): bool = + ##define XkbLegalXIBellClass(c) (((c)==KbdFeedbackClass)||((c)==BellFeedbackClass)|| + # ((c)==XkbDfltXIClass)||((c)==XkbAllXIClasses)) + Result = (c == KbdFeedbackClass) or (c == BellFeedbackClass) or + (c == XkbDfltXIClass) or (c == XkbAllXIClasses) + +proc XkbExplicitXIDevice(c: int): bool = + ##define XkbExplicitXIDevice(c) (((c)&(~0xff))==0) + Result = (c and (not 0x000000FF)) == 0 + +proc XkbExplicitXIClass(c: int): bool = + ##define XkbExplicitXIClass(c) (((c)&(~0xff))==0) + Result = (c and (not 0x000000FF)) == 0 + +proc XkbExplicitXIId(c: int): bool = + ##define XkbExplicitXIId(c) (((c)&(~0xff))==0) + Result = (c and (not 0x000000FF)) == 0 + +proc XkbSingleXIClass(c: int): bool = + ##define XkbSingleXIClass(c) ((((c)&(~0xff))==0)||((c)==XkbDfltXIClass)) + Result = ((c and (not 0x000000FF)) == 0) or (c == XkbDfltXIClass) + +proc XkbSingleXIId(c: int): bool = + ##define XkbSingleXIId(c) ((((c)&(~0xff))==0)||((c)==XkbDfltXIId)) + Result = ((c and (not 0x000000FF)) == 0) or (c == XkbDfltXIId) + +proc XkbBuildCoreState(m, g: int): int = + ##define XkbBuildCoreState(m,g) ((((g)&0x3)<<13)|((m)&0xff)) + Result = ((g and 0x00000003) shl 13) or (m and 0x000000FF) + +proc XkbGroupForCoreState(s: int): int = + ##define XkbGroupForCoreState(s) (((s)>>13)&0x3) + Result = (s shr 13) and 0x00000003 + +proc XkbIsLegalGroup(g: int): bool = + ##define XkbIsLegalGroup(g) (((g)>=0)&&((g)<XkbNumKbdGroups)) + Result = (g >= 0) and (g < XkbNumKbdGroups) + +proc XkbSA_ValOp(a: int): int = + ##define XkbSA_ValOp(a) ((a)&XkbSA_ValOpMask) + Result = a and XkbSA_ValOpMask + +proc XkbSA_ValScale(a: int): int = + ##define XkbSA_ValScale(a) ((a)&XkbSA_ValScaleMask) + Result = a and XkbSA_ValScaleMask + +proc XkbIsModAction(a: PXkbAnyAction): bool = + ##define XkbIsModAction(a) (((a)->type>=Xkb_SASetMods)&&((a)->type<=XkbSA_LockMods)) + Result = (ze(a.theType) >= XkbSA_SetMods) and (ze(a.theType) <= XkbSA_LockMods) + +proc XkbIsGroupAction(a: PXkbAnyAction): bool = + ##define XkbIsGroupAction(a) (((a)->type>=XkbSA_SetGroup)&&((a)->type<=XkbSA_LockGroup)) + Result = (ze(a.theType) >= XkbSA_SetGroup) or (ze(a.theType) <= XkbSA_LockGroup) + +proc XkbIsPtrAction(a: PXkbAnyAction): bool = + ##define XkbIsPtrAction(a) (((a)->type>=XkbSA_MovePtr)&&((a)->type<=XkbSA_SetPtrDflt)) + Result = (ze(a.theType) >= XkbSA_MovePtr) and + (ze(a.theType) <= XkbSA_SetPtrDflt) + +proc XkbIsLegalKeycode(k: int): bool = + ##define XkbIsLegalKeycode(k) (((k)>=XkbMinLegalKeyCode)&&((k)<=XkbMaxLegalKeyCode)) + Result = (k >= XkbMinLegalKeyCode) and (k <= XkbMaxLegalKeyCode) + +proc XkbShiftLevel(n: int8): int8 = + ##define XkbShiftLevel(n) ((n)-1) + Result = n - 1'i8 + +proc XkbShiftLevelMask(n: int8): int8 = + ##define XkbShiftLevelMask(n) (1<<((n)-1)) + Result = 1'i8 shl (n - 1'i8) + +proc XkbCharToInt(v: int8): int16 = + ##define XkbCharToInt(v) ((v)&0x80?(int)((v)|(~0xff)):(int)((v)&0x7f)) + if ((v and 0x80'i8) != 0'i8): Result = v or (not 0xFF'i16) + else: Result = int16(v and 0x7F'i8) + +proc XkbIntTo2Chars(i: int16, h, L: var int8) = + ##define XkbIntTo2Chars(i,h,l) (((h)=((i>>8)&0xff)),((l)=((i)&0xff))) + h = toU8((i shr 8'i16) and 0x00FF'i16) + L = toU8(i and 0xFF'i16) + +proc Xkb2CharsToInt(h, L: int8): int16 = + when defined(cpu64): + ##define Xkb2CharsToInt(h,l) ((h)&0x80?(int)(((h)<<8)|(l)|(~0xffff)): (int)(((h)<<8)|(l)&0x7fff)) + if (h and 0x80'i8) != 0'i8: + Result = toU16((ze(h) shl 8) or ze(L) or not 0x0000FFFF) + else: + Result = toU16((ze(h) shl 8) or ze(L) and 0x00007FFF) + else: + ##define Xkb2CharsToInt(h,l) ((short)(((h)<<8)|(l))) + Result = toU16(ze(h) shl 8 or ze(L)) + +proc XkbModLocks(s: PXkbStatePtr): int8 = + ##define XkbModLocks(s) ((s)->locked_mods) + Result = s.locked_mods + +proc XkbStateMods(s: PXkbStatePtr): int16 = + ##define XkbStateMods(s) ((s)->base_mods|(s)->latched_mods|XkbModLocks(s)) + Result = s.base_mods or s.latched_mods or XkbModLocks(s) + +proc XkbGroupLock(s: PXkbStatePtr): int8 = + ##define XkbGroupLock(s) ((s)->locked_group) + Result = s.locked_group + +proc XkbStateGroup(s: PXkbStatePtr): int16 = + ##define XkbStateGroup(s) ((s)->base_group+(s)->latched_group+XkbGroupLock(s)) + Result = S.base_group + (s.latched_group) + XkbGroupLock(s) + +proc XkbStateFieldFromRec(s: PXkbStatePtr): int = + ##define XkbStateFieldFromRec(s) XkbBuildCoreState((s)->lookup_mods,(s)->group) + Result = XkbBuildCoreState(s.lookup_mods, s.group) + +proc XkbGrabStateFromRec(s: PXkbStatePtr): int = + ##define XkbGrabStateFromRec(s) XkbBuildCoreState((s)->grab_mods,(s)->group) + Result = XkbBuildCoreState(s.grab_mods, s.group) + +proc XkbNumGroups(g: int16): int16 = + ##define XkbNumGroups(g) ((g)&0x0f) + Result = g and 0x0000000F'i16 + +proc XkbOutOfRangeGroupInfo(g: int16): int16 = + ##define XkbOutOfRangeGroupInfo(g) ((g)&0xf0) + Result = g and 0x000000F0'i16 + +proc XkbOutOfRangeGroupAction(g: int16): int16 = + ##define XkbOutOfRangeGroupAction(g) ((g)&0xc0) + Result = g and 0x000000C0'i16 + +proc XkbOutOfRangeGroupNumber(g: int16): int16 = + ##define XkbOutOfRangeGroupNumber(g) (((g)&0x30)>>4) + Result = (g and 0x00000030'i16) shr 4'i16 + +proc XkbSetGroupInfo(g, w, n: int16): int16 = + ##define XkbSetGroupInfo(g,w,n) (((w)&0xc0)|(((n)&3)<<4)|((g)&0x0f)) + Result = (w and 0x000000C0'i16) or + ((n and 3'i16) shl 4'i16) or (g and 0x0000000F'i16) + +proc XkbSetNumGroups(g, n: int16): int16 = + ##define XkbSetNumGroups(g,n) (((g)&0xf0)|((n)&0x0f)) + Result = (g and 0x000000F0'i16) or (n and 0x0000000F'i16) + +proc XkbModActionVMods(a: PXkbModAction): int16 = + ##define XkbModActionVMods(a) ((short)(((a)->vmods1<<8)|((a)->vmods2))) + Result = toU16((ze(a.vmods1) shl 8) or ze(a.vmods2)) + +proc XkbSetModActionVMods(a: PXkbModAction, v: int8) = + ##define XkbSetModActionVMods(a,v) (((a)->vmods1=(((v)>>8)&0xff)),(a)->vmods2=((v)&0xff)) + a.vmods1 = toU8((ze(v) shr 8) and 0x000000FF) + a.vmods2 = toU8(ze(v) and 0x000000FF) + +proc XkbSAGroup(a: PXkbGroupAction): int8 = + ##define XkbSAGroup(a) (XkbCharToInt((a)->group_XXX)) + Result = int8(XkbCharToInt(a.group_XXX)) + +proc XkbSASetGroupProc(a: PXkbGroupAction, g: int8) = + ##define XkbSASetGroup(a,g) ((a)->group_XXX=(g)) + a.group_XXX = g + +proc XkbPtrActionX(a: PXkbPtrAction): int16 = + ##define XkbPtrActionX(a) (Xkb2CharsToInt((a)->high_XXX,(a)->low_XXX)) + Result = int16(Xkb2CharsToInt(a.high_XXX, a.low_XXX)) + +proc XkbPtrActionY(a: PXkbPtrAction): int16 = + ##define XkbPtrActionY(a) (Xkb2CharsToInt((a)->high_YYY,(a)->low_YYY)) + Result = int16(Xkb2CharsToInt(a.high_YYY, a.low_YYY)) + +proc XkbSetPtrActionX(a: PXkbPtrAction, x: int8) = + ##define XkbSetPtrActionX(a,x) (XkbIntTo2Chars(x,(a)->high_XXX,(a)->low_XXX)) + XkbIntTo2Chars(x, a.high_XXX, a.low_XXX) + +proc XkbSetPtrActionY(a: PXkbPtrAction, y: int8) = + ##define XkbSetPtrActionY(a,y) (XkbIntTo2Chars(y,(a)->high_YYY,(a)->low_YYY)) + XkbIntTo2Chars(y, a.high_YYY, a.low_YYY) + +proc XkbSAPtrDfltValue(a: PXkbPtrDfltAction): int8 = + ##define XkbSAPtrDfltValue(a) (XkbCharToInt((a)->valueXXX)) + Result = int8(XkbCharToInt(a.valueXXX)) + +proc XkbSASetPtrDfltValue(a: PXkbPtrDfltAction, c: pointer) = + ##define XkbSASetPtrDfltValue(a,c) ((a)->valueXXX= ((c)&0xff)) + a.valueXXX = toU8(cast[int](c)) + +proc XkbSAScreen(a: PXkbSwitchScreenAction): int8 = + ##define XkbSAScreen(a) (XkbCharToInt((a)->screenXXX)) + Result = toU8(XkbCharToInt(a.screenXXX)) + +proc XkbSASetScreen(a: PXkbSwitchScreenAction, s: pointer) = + ##define XkbSASetScreen(a,s) ((a)->screenXXX= ((s)&0xff)) + a.screenXXX = toU8(cast[int](s)) + +proc XkbActionSetCtrls(a: PXkbCtrlsAction, c: int8) = + ##define XkbActionSetCtrls(a,c) (((a)->ctrls3=(((c)>>24)&0xff)),((a)->ctrls2=(((c)>>16)&0xff)), + # ((a)->ctrls1=(((c)>>8)&0xff)),((a)->ctrls0=((c)&0xff))) + a.ctrls3 = toU8((ze(c) shr 24) and 0x000000FF) + a.ctrls2 = toU8((ze(c) shr 16) and 0x000000FF) + a.ctrls1 = toU8((ze(c) shr 8) and 0x000000FF) + a.ctrls0 = toU8(ze(c) and 0x000000FF) + +proc XkbActionCtrls(a: PXkbCtrlsAction): int16 = + ##define XkbActionCtrls(a) ((((unsigned int)(a)->ctrls3)<<24)|(((unsigned int)(a)->ctrls2)<<16)| + # (((unsigned int)(a)->ctrls1)<<8)|((unsigned int)((a)->ctrls0))) + Result = toU16((ze(a.ctrls3) shl 24) or (ze(a.ctrls2) shl 16) or + (ze(a.ctrls1) shl 8) or ze(a.ctrls0)) + +proc XkbSARedirectVMods(a: PXkbRedirectKeyAction): int16 = + ##define XkbSARedirectVMods(a) ((((unsigned int)(a)->vmods1)<<8)|((unsigned int)(a)->vmods0)) + Result = toU16((ze(a.vmods1) shl 8) or ze(a.vmods0)) + +proc XkbSARedirectSetVMods(a: PXkbRedirectKeyAction, m: int8) = + ##define XkbSARedirectSetVMods(a,m) (((a)->vmods_mask1=(((m)>>8)&0xff)),((a)->vmods_mask0=((m)&0xff))) + a.vmods_mask1 = toU8((ze(m) shr 8) and 0x000000FF) + a.vmods_mask0 = toU8(ze(m) or 0x000000FF) + +proc XkbSARedirectVModsMask(a: PXkbRedirectKeyAction): int16 = + ##define XkbSARedirectVModsMask(a) ((((unsigned int)(a)->vmods_mask1)<<8)| + # ((unsigned int)(a)->vmods_mask0)) + Result = toU16((ze(a.vmods_mask1) shl 8) or ze(a.vmods_mask0)) + +proc XkbSARedirectSetVModsMask(a: PXkbRedirectKeyAction, m: int8) = + ##define XkbSARedirectSetVModsMask(a,m) (((a)->vmods_mask1=(((m)>>8)&0xff)),((a)->vmods_mask0=((m)&0xff))) + a.vmods_mask1 = toU8(ze(m) shr 8 and 0x000000FF) + a.vmods_mask0 = toU8(ze(m) and 0x000000FF) + +proc XkbAX_AnyFeedback(c: PXkbControlsPtr): int16 = + ##define XkbAX_AnyFeedback(c) ((c)->enabled_ctrls&XkbAccessXFeedbackMask) + Result = toU16(ze(c.enabled_ctrls) and XkbAccessXFeedbackMask) + +proc XkbAX_NeedOption(c: PXkbControlsPtr, w: int16): int16 = + ##define XkbAX_NeedOption(c,w) ((c)->ax_options&(w)) + Result = toU16(ze(c.ax_options) and ze(w)) + +proc XkbAX_NeedFeedback(c: PXkbControlsPtr, w: int16): bool = + ##define XkbAX_NeedFeedback(c,w) (XkbAX_AnyFeedback(c)&&XkbAX_NeedOption(c,w)) + Result = (XkbAX_AnyFeedback(c) > 0'i16) and (XkbAX_NeedOption(c, w) > 0'i16) + +proc XkbSMKeyActionsPtr(m: PXkbServerMapPtr, k: int16): PXkbAction = + ##define XkbSMKeyActionsPtr(m,k) (&(m)->acts[(m)->key_acts[k]]) + Result = addr(m.acts[ze(m.key_acts[ze(k)])]) + +proc XkbCMKeyGroupInfo(m: PXkbClientMapPtr, k: int16): int8 = + ##define XkbCMKeyGroupInfo(m,k) ((m)->key_sym_map[k].group_info) + Result = m.key_sym_map[ze(k)].group_info + +proc XkbCMKeyNumGroups(m: PXkbClientMapPtr, k: int16): int8 = + ##define XkbCMKeyNumGroups(m,k) (XkbNumGroups((m)->key_sym_map[k].group_info)) + Result = toU8(XkbNumGroups(m.key_sym_map[ze(k)].group_info)) + +proc XkbCMKeyGroupWidth(m: PXkbClientMapPtr, k: int16, g: int8): int8 = + ##define XkbCMKeyGroupWidth(m,k,g) (XkbCMKeyType(m,k,g)->num_levels) + Result = XkbCMKeyType(m, k, g).num_levels + +proc XkbCMKeyGroupsWidth(m: PXkbClientMapPtr, K: int16): int8 = + ##define XkbCMKeyGroupsWidth(m,k) ((m)->key_sym_map[k].width) + Result = m.key_sym_map[ze(k)].width + +proc XkbCMKeyTypeIndex(m: PXkbClientMapPtr, k: int16, g: int8): int8 = + ##define XkbCMKeyTypeIndex(m,k,g) ((m)->key_sym_map[k].kt_index[g&0x3]) + Result = m.key_sym_map[ze(k)].kt_index[ze(g) and 0x00000003] + +proc XkbCMKeyType(m: PXkbClientMapPtr, k: int16, g: int8): PXkbKeyTypePtr = + ##define XkbCMKeyType(m,k,g) (&(m)->types[XkbCMKeyTypeIndex(m,k,g)]) + Result = addr(m.types[ze(XkbCMKeyTypeIndex(m, k, g))]) + +proc XkbCMKeyNumSyms(m: PXkbClientMapPtr, k: int16): int16 = + ##define XkbCMKeyNumSyms(m,k) (XkbCMKeyGroupsWidth(m,k)*XkbCMKeyNumGroups(m,k)) + Result = toU16(ze(XkbCMKeyGroupsWidth(m, k)) or ze(XkbCMKeyNumGroups(m, k))) + +proc XkbCMKeySymsOffset(m: PXkbClientMapPtr, k: int16): int8 = + ##define XkbCMKeySymsOffset(m,k) ((m)->key_sym_map[k].offset) + Result = m.key_sym_map[ze(k)].offset + +proc XkbCMKeySymsPtr*(m: PXkbClientMapPtr, k: int16): PKeySym = + ##define XkbCMKeySymsPtr(m,k) (&(m)->syms[XkbCMKeySymsOffset(m,k)]) + Result = addr(m.syms[ze(XkbCMKeySymsOffset(m, k))]) + +proc XkbIM_IsAuto(i: PXkbIndicatorMapPtr): bool = + ##define XkbIM_IsAuto(i) ((((i)->flags&XkbIM_NoAutomatic)==0)&&(((i)->which_groups&&(i)->groups)|| + # ((i)->which_mods&&(i)->mods.mask)|| ((i)->ctrls))) + Result = ((ze(i.flags) and XkbIM_NoAutomatic) == 0) and + (((i.which_groups > 0'i8) and (i.groups > 0'i8)) or + ((i.which_mods > 0'i8) and (i.mods.mask > 0'i8)) or (i.ctrls > 0'i8)) + +proc XkbIM_InUse(i: PXkbIndicatorMapPtr): bool = + ##define XkbIM_InUse(i) (((i)->flags)||((i)->which_groups)||((i)->which_mods)||((i)->ctrls)) + Result = (i.flags > 0'i8) or (i.which_groups > 0'i8) or (i.which_mods > 0'i8) or + (i.ctrls > 0'i8) + +proc XkbKeyKeyTypeIndex(d: PXkbDescPtr, k: int16, g: int8): int8 = + ##define XkbKeyKeyTypeIndex(d,k,g) (XkbCMKeyTypeIndex((d)->map,k,g)) + Result = XkbCMKeyTypeIndex(d.map, k, g) + +proc XkbKeyKeyType(d: PXkbDescPtr, k: int16, g: int8): PXkbKeyTypePtr = + ##define XkbKeyKeyType(d,k,g) (XkbCMKeyType((d)->map,k,g)) + Result = XkbCMKeyType(d.map, k, g) + +proc XkbKeyGroupWidth(d: PXkbDescPtr, k: int16, g: int8): int8 = + ##define XkbKeyGroupWidth(d,k,g) (XkbCMKeyGroupWidth((d)->map,k,g)) + Result = XkbCMKeyGroupWidth(d.map, k, g) + +proc XkbKeyGroupsWidth(d: PXkbDescPtr, k: int16): int8 = + ##define XkbKeyGroupsWidth(d,k) (XkbCMKeyGroupsWidth((d)->map,k)) + Result = XkbCMKeyGroupsWidth(d.map, k) + +proc XkbKeyGroupInfo(d: PXkbDescPtr, k: int16): int8 = + ##define XkbKeyGroupInfo(d,k) (XkbCMKeyGroupInfo((d)->map,(k))) + Result = XkbCMKeyGroupInfo(d.map, k) + +proc XkbKeyNumGroups(d: PXkbDescPtr, k: int16): int8 = + ##define XkbKeyNumGroups(d,k) (XkbCMKeyNumGroups((d)->map,(k))) + Result = XkbCMKeyNumGroups(d.map, k) + +proc XkbKeyNumSyms(d: PXkbDescPtr, k: int16): int16 = + ##define XkbKeyNumSyms(d,k) (XkbCMKeyNumSyms((d)->map,(k))) + Result = XkbCMKeyNumSyms(d.map, k) + +proc XkbKeySymsPtr*(d: PXkbDescPtr, k: int16): PKeySym = + ##define XkbKeySymsPtr(d,k) (XkbCMKeySymsPtr((d)->map,(k))) + Result = XkbCMKeySymsPtr(d.map, k) + +proc XkbKeySym(d: PXkbDescPtr, k: int16, n: int16): TKeySym = + ##define XkbKeySym(d,k,n) (XkbKeySymsPtr(d,k)[n]) + Result = cast[ptr array[0..0xffff, TKeySym]](XkbKeySymsPtr(d, k))[ze(n)] # XXX: this seems strange! + +proc XkbKeySymEntry(d: PXkbDescPtr, k: int16, sl: int16, g: int8): TKeySym = + ##define XkbKeySymEntry(d,k,sl,g) (XkbKeySym(d,k,((XkbKeyGroupsWidth(d,k)*(g))+(sl)))) + Result = XkbKeySym(d, k, toU16(ze(XkbKeyGroupsWidth(d, k)) * ze(g) + ze(sl))) + +proc XkbKeyAction(d: PXkbDescPtr, k: int16, n: int16): PXkbAction = + ##define XkbKeyAction(d,k,n) (XkbKeyHasActions(d,k)?&XkbKeyActionsPtr(d,k)[n]:NULL) + #if (XkbKeyHasActions(d, k)): + # Result = XkbKeyActionsPtr(d, k)[ze(n)] #Buggy !!! + assert(false) + result = nil + +proc XkbKeyActionEntry(d: PXkbDescPtr, k: int16, sl: int16, g: int8): int8 = + ##define XkbKeyActionEntry(d,k,sl,g) (XkbKeyHasActions(d,k) ? + # XkbKeyAction(d, k, ((XkbKeyGroupsWidth(d, k) * (g))+(sl))):NULL) + if XkbKeyHasActions(d, k): + Result = XkbKeyGroupsWidth(d, k) *% g +% toU8(sl) + else: + Result = 0'i8 + +proc XkbKeyHasActions(d: PXkbDescPtr, k: int16): bool = + ##define XkbKeyHasActions(d,k) ((d)->server->key_acts[k]!=0) + Result = d.server.key_acts[ze(k)] != 0'i16 + +proc XkbKeyNumActions(d: PXkbDescPtr, k: int16): int16 = + ##define XkbKeyNumActions(d,k) (XkbKeyHasActions(d,k)?XkbKeyNumSyms(d,k):1) + if (XkbKeyHasActions(d, k)): Result = XkbKeyNumSyms(d, k) + else: Result = 1'i16 + +proc XkbKeyActionsPtr(d: PXkbDescPtr, k: int16): PXkbAction = + ##define XkbKeyActionsPtr(d,k) (XkbSMKeyActionsPtr((d)->server,k)) + Result = XkbSMKeyActionsPtr(d.server, k) + +proc XkbKeycodeInRange(d: PXkbDescPtr, k: int16): bool = + ##define XkbKeycodeInRange(d,k) (((k)>=(d)->min_key_code)&& ((k)<=(d)->max_key_code)) + Result = (char(toU8(k)) >= d.min_key_code) and (char(toU8(k)) <= d.max_key_code) + +proc XkbNumKeys(d: PXkbDescPtr): int8 = + ##define XkbNumKeys(d) ((d)->max_key_code-(d)->min_key_code+1) + Result = toU8(ord(d.max_key_code) - ord(d.min_key_code) + 1) + +proc XkbXI_DevHasBtnActs(d: PXkbDeviceInfoPtr): bool = + ##define XkbXI_DevHasBtnActs(d) (((d)->num_btns>0)&&((d)->btn_acts!=NULL)) + Result = (d.num_btns > 0'i16) and (not (d.btn_acts == nil)) + +proc XkbXI_LegalDevBtn(d: PXkbDeviceInfoPtr, b: int16): bool = + ##define XkbXI_LegalDevBtn(d,b) (XkbXI_DevHasBtnActs(d)&&((b)<(d)->num_btns)) + Result = XkbXI_DevHasBtnActs(d) and (b <% d.num_btns) + +proc XkbXI_DevHasLeds(d: PXkbDeviceInfoPtr): bool = + ##define XkbXI_DevHasLeds(d) (((d)->num_leds>0)&&((d)->leds!=NULL)) + Result = (d.num_leds > 0'i16) and (not (d.leds == nil)) + +proc XkbBoundsWidth(b: PXkbBoundsPtr): int16 = + ##define XkbBoundsWidth(b) (((b)->x2)-((b)->x1)) + Result = (b.x2) - b.x1 + +proc XkbBoundsHeight(b: PXkbBoundsPtr): int16 = + ##define XkbBoundsHeight(b) (((b)->y2)-((b)->y1)) + Result = (b.y2) - b.y1 + +proc XkbOutlineIndex(s: PXkbShapePtr, o: PXkbOutlinePtr): int32 = + ##define XkbOutlineIndex(s,o) ((int)((o)-&(s)->outlines[0])) + Result = int32((cast[TAddress](o) - cast[TAddress](addr(s.outlines[0]))) div sizeof(PXkbOutlinePtr)) + +proc XkbShapeDoodadColor(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr): PXkbColorPtr = + ##define XkbShapeDoodadColor(g,d) (&(g)->colors[(d)->color_ndx]) + Result = addr((g.colors[ze(d.color_ndx)])) + +proc XkbShapeDoodadShape(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr): PXkbShapePtr = + ##define XkbShapeDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx]) + Result = addr(g.shapes[ze(d.shape_ndx)]) + +proc XkbSetShapeDoodadColor(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr, + c: PXkbColorPtr) = + ##define XkbSetShapeDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0]) + d.color_ndx = toU16((cast[TAddress](c) - cast[TAddress](addr(g.colors[0]))) div sizeof(TXkbColorRec)) + +proc XkbSetShapeDoodadShape(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr, + s: PXkbShapePtr) = + ##define XkbSetShapeDoodadShape(g,d,s) ((d)->shape_ndx= (s)-&(g)->shapes[0]) + d.shape_ndx = toU16((cast[TAddress](s) - cast[TAddress](addr(g.shapes[0]))) div sizeof(TXkbShapeRec)) + +proc XkbTextDoodadColor(g: PXkbGeometryPtr, d: PXkbTextDoodadPtr): PXkbColorPtr = + ##define XkbTextDoodadColor(g,d) (&(g)->colors[(d)->color_ndx]) + Result = addr(g.colors[ze(d.color_ndx)]) + +proc XkbSetTextDoodadColor(g: PXkbGeometryPtr, d: PXkbTextDoodadPtr, + c: PXkbColorPtr) = + ##define XkbSetTextDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0]) + d.color_ndx = toU16((cast[TAddress](c) - cast[TAddress](addr(g.colors[0]))) div sizeof(TXkbColorRec)) + +proc XkbIndicatorDoodadShape(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr): PXkbShapeDoodadPtr = + ##define XkbIndicatorDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx]) + Result = cast[PXkbShapeDoodadPtr](addr(g.shapes[ze(d.shape_ndx)])) + +proc XkbIndicatorDoodadOnColor(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr): PXkbColorPtr = + ##define XkbIndicatorDoodadOnColor(g,d) (&(g)->colors[(d)->on_color_ndx]) + Result = addr(g.colors[ze(d.on_color_ndx)]) + +proc XkbIndicatorDoodadOffColor(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr): PXkbColorPtr = + ##define XkbIndicatorDoodadOffColor(g,d) (&(g)->colors[(d)->off_color_ndx]) + Result = addr(g.colors[ze(d.off_color_ndx)]) + +proc XkbSetIndicatorDoodadOnColor(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr, + c: PXkbColorPtr) = + ##define XkbSetIndicatorDoodadOnColor(g,d,c) ((d)->on_color_ndx= (c)-&(g)->colors[0]) + d.on_color_ndx = toU16((cast[TAddress](c) - cast[TAddress](addr(g.colors[0]))) div sizeof(TXkbColorRec)) + +proc XkbSetIndicatorDoodadOffColor(g: PXkbGeometryPtr, + d: PXkbIndicatorDoodadPtr, c: PXkbColorPtr) = + ##define XkbSetIndicatorDoodadOffColor(g,d,c) ((d)->off_color_ndx= (c)-&(g)->colors[0]) + d.off_color_ndx = toU16((cast[TAddress](c) - cast[TAddress](addr(g.colors[0]))) div sizeof(TxkbColorRec)) + +proc XkbSetIndicatorDoodadShape(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr, + s: PXkbShapeDoodadPtr) = + ##define XkbSetIndicatorDoodadShape(g,d,s) ((d)->shape_ndx= (s)-&(g)->shapes[0]) + d.shape_ndx = toU16((cast[TAddress](s) - (cast[TAddress](addr(g.shapes[0])))) div sizeof(TXkbShapeRec)) + +proc XkbLogoDoodadColor(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr): PXkbColorPtr = + ##define XkbLogoDoodadColor(g,d) (&(g)->colors[(d)->color_ndx]) + Result = addr(g.colors[ze(d.color_ndx)]) + +proc XkbLogoDoodadShape(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr): PXkbShapeDoodadPtr = + ##define XkbLogoDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx]) + Result = cast[PXkbShapeDoodadPtr](addr(g.shapes[ze(d.shape_ndx)])) + +proc XkbSetLogoDoodadColor(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr, + c: PXkbColorPtr) = + ##define XkbSetLogoDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0]) + d.color_ndx = toU16((cast[TAddress](c) - cast[TAddress](addr(g.colors[0]))) div sizeof(TXkbColorRec)) + +proc XkbSetLogoDoodadShape(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr, + s: PXkbShapeDoodadPtr) = + ##define XkbSetLogoDoodadShape(g,d,s) ((d)->shape_ndx= (s)-&(g)->shapes[0]) + d.shape_ndx = toU16((cast[TAddress](s) - cast[TAddress](addr(g.shapes[0]))) div sizeof(TXkbShapeRec)) + +proc XkbKeyShape(g: PXkbGeometryPtr, k: PXkbKeyPtr): PXkbShapeDoodadPtr = + ##define XkbKeyShape(g,k) (&(g)->shapes[(k)->shape_ndx]) + Result = cast[PXkbShapeDoodadPtr](addr(g.shapes[ze(k.shape_ndx)])) + +proc XkbKeyColor(g: PXkbGeometryPtr, k: PXkbKeyPtr): PXkbColorPtr = + ##define XkbKeyColor(g,k) (&(g)->colors[(k)->color_ndx]) + Result = addr(g.colors[ze(k.color_ndx)]) + +proc XkbSetKeyShape(g: PXkbGeometryPtr, k: PXkbKeyPtr, s: PXkbShapeDoodadPtr) = + ##define XkbSetKeyShape(g,k,s) ((k)->shape_ndx= (s)-&(g)->shapes[0]) + k.shape_ndx = toU8((cast[TAddress](s) - cast[TAddress](addr(g.shapes[0]))) div sizeof(TXkbShapeRec)) + +proc XkbSetKeyColor(g: PXkbGeometryPtr, k: PXkbKeyPtr, c: PXkbColorPtr) = + ##define XkbSetKeyColor(g,k,c) ((k)->color_ndx= (c)-&(g)->colors[0]) + k.color_ndx = toU8((cast[TAddress](c) - cast[TAddress](addr(g.colors[0]))) div sizeof(TxkbColorRec)) + +proc XkbGeomColorIndex(g: PXkbGeometryPtr, c: PXkbColorPtr): int32 = + ##define XkbGeomColorIndex(g,c) ((int)((c)-&(g)->colors[0])) + Result = toU16((cast[TAddress](c) - (cast[TAddress](addr(g.colors[0])))) div sizeof(TxkbColorRec)) diff --git a/lib/base/x11/xkblib.nim b/lib/base/x11/xkblib.nim new file mode 100644 index 000000000..92d438a60 --- /dev/null +++ b/lib/base/x11/xkblib.nim @@ -0,0 +1,699 @@ +# $Xorg: XKBlib.h,v 1.6 2000/08/17 19:45:03 cpqbld Exp $ +#************************************************************ +#Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc. +# +#Permission to use, copy, modify, and distribute this +#software and its documentation for any purpose and without +#fee is hereby granted, provided that the above copyright +#notice appear in all copies and that both that copyright +#notice and this permission notice appear in supporting +#documentation, and that the name of Silicon Graphics not be +#used in advertising or publicity pertaining to distribution +#of the software without specific prior written permission. +#Silicon Graphics makes no representation about the suitability +#of this software for any purpose. It is provided "as is" +#without any express or implied warranty. +# +#SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS +#SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +#AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON +#GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL +#DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING `from` LOSS OF USE, +#DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +#OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH +#THE USE OR PERFORMANCE OF THIS SOFTWARE. +# +#********************************************************/ +# $XFree86: xc/lib/X11/XKBlib.h,v 3.3 2001/08/01 00:44:38 tsi Exp $ +# +# Pascal Convertion was made by Ido Kannner - kanerido@actcom.net.il +# +#Thanks: +# I want to thanks to oliebol for putting up with all of the problems that was found +# while translating this code. ;) +# +# I want to thanks #fpc channel in freenode irc, for helping me, and to put up with my +# wierd questions ;) +# +# Thanks for mmc in #xlib on freenode irc And so for the channel itself for the helping me to +# understanding some of the problems I had converting this headers and pointing me to resources +# that helped translating this headers. +# +# Ido +# +#History: +# 2004/10/15 - Fixed a bug of accessing second based records by removing "paced record" and +# chnaged it to "reocrd" only. +# 2004/10/10 - Added to TXkbGetAtomNameFunc and TXkbInternAtomFunc the cdecl call. +# 2004/10/06 - 09 - Convertion `from` the c header of XKBlib.h +# +# + +import + X, Xlib, XKB + +type + PXkbAnyEvent* = ptr TXkbAnyEvent + TXkbAnyEvent*{.final.} = object + theType*: int16 # XkbAnyEvent + serial*: int32 # # of last req processed by server + send_event*: bool # is this `from` a SendEvent request? + display*: PDisplay # Display the event was read `from` + time*: TTime # milliseconds; + xkb_type*: int16 # XKB event minor code + device*: int16 # device ID + + +type + PXkbNewKeyboardNotifyEvent* = ptr TXkbNewKeyboardNotifyEvent + TXkbNewKeyboardNotifyEvent*{.final.} = object + theType*: int16 # XkbAnyEvent + serial*: int32 # of last req processed by server + send_event*: bool # is this `from` a SendEvent request? + display*: PDisplay # Display the event was read `from` + time*: TTime # milliseconds + xkb_type*: int16 # XkbNewKeyboardNotify + device*: int16 # device ID + old_device*: int16 # device ID of previous keyboard + min_key_code*: int16 # minimum key code + max_key_code*: int16 # maximum key code + old_min_key_code*: int16 # min key code of previous kbd + old_max_key_code*: int16 # max key code of previous kbd + changed*: int16 # changed aspects of the keyboard + req_major*: int8 # major and minor opcode of req + req_minor*: int8 # that caused change, if applicable + + +type + PXkbMapNotifyEvent* = ptr TXkbMapNotifyEvent + TXkbMapNotifyEvent*{.final.} = object + theType*: int16 # XkbAnyEvent + serial*: int32 # of last req processed by server + send_event*: bool # is this `from` a SendEvent request + display*: PDisplay # Display the event was read `from` + time*: TTime # milliseconds + xkb_type*: int16 # XkbMapNotify + device*: int16 # device ID + changed*: int16 # fields which have been changed + flags*: int16 # reserved + first_type*: int16 # first changed key type + num_types*: int16 # number of changed key types + min_key_code*: TKeyCode + max_key_code*: TKeyCode + first_key_sym*: TKeyCode + first_key_act*: TKeyCode + first_key_behavior*: TKeyCode + first_key_explicit*: TKeyCode + first_modmap_key*: TKeyCode + first_vmodmap_key*: TKeyCode + num_key_syms*: int16 + num_key_acts*: int16 + num_key_behaviors*: int16 + num_key_explicit*: int16 + num_modmap_keys*: int16 + num_vmodmap_keys*: int16 + vmods*: int16 # mask of changed virtual mods + + +type + PXkbStateNotifyEvent* = ptr TXkbStateNotifyEvent + TXkbStateNotifyEvent*{.final.} = object + theType*: int16 # XkbAnyEvent + serial*: int32 # # of last req processed by server + send_event*: bool # is this `from` a SendEvent request? + display*: PDisplay # Display the event was read `from` + time*: TTime # milliseconds + xkb_type*: int16 # XkbStateNotify + device*: int16 # device ID + changed*: int16 # mask of changed state components + group*: int16 # keyboard group + base_group*: int16 # base keyboard group + latched_group*: int16 # latched keyboard group + locked_group*: int16 # locked keyboard group + mods*: int16 # modifier state + base_mods*: int16 # base modifier state + latched_mods*: int16 # latched modifiers + locked_mods*: int16 # locked modifiers + compat_state*: int16 # compatibility state + grab_mods*: int8 # mods used for grabs + compat_grab_mods*: int8 # grab mods for non-XKB clients + lookup_mods*: int8 # mods sent to clients + compat_lookup_mods*: int8 # mods sent to non-XKB clients + ptr_buttons*: int16 # pointer button state + keycode*: TKeyCode # keycode that caused the change + event_type*: int8 # KeyPress or KeyRelease + req_major*: int8 # Major opcode of request + req_minor*: int8 # Minor opcode of request + + +type + PXkbControlsNotifyEvent* = ptr TXkbControlsNotifyEvent + TXkbControlsNotifyEvent*{.final.} = object + theType*: int16 # XkbAnyEvent + serial*: int32 # of last req processed by server + send_event*: bool # is this `from` a SendEvent request? + display*: PDisplay # Display the event was read `from` + time*: TTime # milliseconds + xkb_type*: int16 # XkbControlsNotify + device*: int16 # device ID + changed_ctrls*: int16 # controls with changed sub-values + enabled_ctrls*: int16 # controls currently enabled + enabled_ctrl_changes*: int16 # controls just {en,dis}abled + num_groups*: int16 # total groups on keyboard + keycode*: TKeyCode # key that caused change or 0 + event_type*: int8 # type of event that caused change + req_major*: int8 # if keycode==0, major and minor + req_minor*: int8 # opcode of req that caused change + + +type + PXkbIndicatorNotifyEvent* = ptr TXkbIndicatorNotifyEvent + TXkbIndicatorNotifyEvent*{.final.} = object + theType*: int16 # XkbAnyEvent + serial*: int32 # of last req processed by server + send_event*: bool # is this `from` a SendEvent request? + display*: PDisplay # Display the event was read `from` + time*: TTime # milliseconds + xkb_type*: int16 # XkbIndicatorNotify + device*: int16 # device + changed*: int16 # indicators with new state or map + state*: int16 # current state of all indicators + + +type + PXkbNamesNotifyEvent* = ptr TXkbNamesNotifyEvent + TXkbNamesNotifyEvent*{.final.} = object + theType*: int16 # XkbAnyEvent + serial*: int32 # of last req processed by server + send_event*: bool # is this `from` a SendEvent request? + display*: PDisplay # Display the event was read `from` + time*: TTime # milliseconds + xkb_type*: int16 # XkbNamesNotify + device*: int16 # device ID + changed*: int32 # names that have changed + first_type*: int16 # first key type with new name + num_types*: int16 # number of key types with new names + first_lvl*: int16 # first key type new new level names + num_lvls*: int16 # # of key types w/new level names + num_aliases*: int16 # total number of key aliases + num_radio_groups*: int16 # total number of radio groups + changed_vmods*: int16 # virtual modifiers with new names + changed_groups*: int16 # groups with new names + changed_indicators*: int16 # indicators with new names + first_key*: int16 # first key with new name + num_keys*: int16 # number of keys with new names + + +type + PXkbCompatMapNotifyEvent* = ptr TXkbCompatMapNotifyEvent + TXkbCompatMapNotifyEvent*{.final.} = object + theType*: int16 # XkbAnyEvent + serial*: int32 # of last req processed by server + send_event*: bool # is this `from` a SendEvent request? + display*: PDisplay # Display the event was read `from` + time*: TTime # milliseconds + xkb_type*: int16 # XkbCompatMapNotify + device*: int16 # device ID + changed_groups*: int16 # groups with new compat maps + first_si*: int16 # first new symbol interp + num_si*: int16 # number of new symbol interps + num_total_si*: int16 # total # of symbol interps + + +type + PXkbBellNotifyEvent* = ptr TXkbBellNotifyEvent + TXkbBellNotifyEvent*{.final.} = object + theType*: int16 # XkbAnyEvent + serial*: int32 # of last req processed by server + send_event*: bool # is this `from` a SendEvent request? + display*: PDisplay # Display the event was read `from` + time*: TTime # milliseconds + xkb_type*: int16 # XkbBellNotify + device*: int16 # device ID + percent*: int16 # requested volume as a % of maximum + pitch*: int16 # requested pitch in Hz + duration*: int16 # requested duration in useconds + bell_class*: int16 # (input extension) feedback class + bell_id*: int16 # (input extension) ID of feedback + name*: TAtom # "name" of requested bell + window*: TWindow # window associated with event + event_only*: bool # "event only" requested + + +type + PXkbActionMessageEvent* = ptr TXkbActionMessageEvent + TXkbActionMessageEvent*{.final.} = object + theType*: int16 # XkbAnyEvent + serial*: int32 # of last req processed by server + send_event*: bool # is this `from` a SendEvent request? + display*: PDisplay # Display the event was read `from` + time*: TTime # milliseconds + xkb_type*: int16 # XkbActionMessage + device*: int16 # device ID + keycode*: TKeyCode # key that generated the event + press*: bool # true if act caused by key press + key_event_follows*: bool # true if key event also generated + group*: int16 # effective group + mods*: int16 # effective mods + message*: array[0..XkbActionMessageLength, Char] # message -- leave space for NUL + + +type + PXkbAccessXNotifyEvent* = ptr TXkbAccessXNotifyEvent + TXkbAccessXNotifyEvent*{.final.} = object + theType*: int16 # XkbAnyEvent + serial*: int32 # of last req processed by server + send_event*: bool # is this `from` a SendEvent request? + display*: PDisplay # Display the event was read `from` + time*: TTime # milliseconds + xkb_type*: int16 # XkbAccessXNotify + device*: int16 # device ID + detail*: int16 # XkbAXN_* + keycode*: int16 # key of event + sk_delay*: int16 # current slow keys delay + debounce_delay*: int16 # current debounce delay + + +type + PXkbExtensionDeviceNotifyEvent* = ptr TXkbExtensionDeviceNotifyEvent + TXkbExtensionDeviceNotifyEvent*{.final.} = object + theType*: int16 # XkbAnyEvent + serial*: int32 # of last req processed by server + send_event*: bool # is this `from` a SendEvent request? + display*: PDisplay # Display the event was read `from` + time*: TTime # milliseconds + xkb_type*: int16 # XkbExtensionDeviceNotify + device*: int16 # device ID + reason*: int16 # reason for the event + supported*: int16 # mask of supported features + unsupported*: int16 # mask of unsupported features + # that some app tried to use + first_btn*: int16 # first button that changed + num_btns*: int16 # range of buttons changed + leds_defined*: int16 # indicators with names or maps + led_state*: int16 # current state of the indicators + led_class*: int16 # feedback class for led changes + led_id*: int16 # feedback id for led changes + + +type + PXkbEvent* = ptr TXkbEvent + TXkbEvent*{.final.} = object + theType*: int16 + any*: TXkbAnyEvent + new_kbd*: TXkbNewKeyboardNotifyEvent + map*: TXkbMapNotifyEvent + state*: TXkbStateNotifyEvent + ctrls*: TXkbControlsNotifyEvent + indicators*: TXkbIndicatorNotifyEvent + names*: TXkbNamesNotifyEvent + compat*: TXkbCompatMapNotifyEvent + bell*: TXkbBellNotifyEvent + message*: TXkbActionMessageEvent + accessx*: TXkbAccessXNotifyEvent + device*: TXkbExtensionDeviceNotifyEvent + core*: TXEvent + + +type + PXkbKbdDpyStatePtr* = ptr TXkbKbdDpyStateRec + TXkbKbdDpyStateRec*{.final.} = object # XkbOpenDisplay error codes + +const + XkbOD_Success* = 0 + XkbOD_BadLibraryVersion* = 1 + XkbOD_ConnectionRefused* = 2 + XkbOD_NonXkbServer* = 3 + XkbOD_BadServerVersion* = 4 # Values for XlibFlags + +const + XkbLC_ForceLatin1Lookup* = 1 shl 0 + XkbLC_ConsumeLookupMods* = 1 shl 1 + XkbLC_AlwaysConsumeShiftAndLock* = 1 shl 2 + XkbLC_IgnoreNewKeyboards* = 1 shl 3 + XkbLC_ControlFallback* = 1 shl 4 + XkbLC_ConsumeKeysOnComposeFail* = 1 shl 29 + XkbLC_ComposeLED* = 1 shl 30 + XkbLC_BeepOnComposeFail* = 1 shl 31 + XkbLC_AllComposeControls* = 0xC0000000 + XkbLC_AllControls* = 0xC000001F + +proc XkbIgnoreExtension*(ignore: bool): bool{.cdecl, dynlib: libX11, + importc: "XkbIgnoreExtension".} +proc XkbOpenDisplay*(name: cstring, ev_rtrn, err_rtrn, major_rtrn, minor_rtrn, + reason: ptr int16): PDisplay{.cdecl, + dynlib: libX11, importc: "XkbOpenDisplay".} +proc XkbQueryExtension*(dpy: PDisplay, opcodeReturn, eventBaseReturn, + errorBaseReturn, majorRtrn, minorRtrn: ptr int16): bool{. + cdecl, dynlib: libX11, importc: "XkbQueryExtension".} +proc XkbUseExtension*(dpy: PDisplay, major_rtrn, minor_rtrn: ptr int16): bool{. + cdecl, dynlib: libX11, importc: "XkbUseExtension".} +proc XkbLibraryVersion*(libMajorRtrn, libMinorRtrn: ptr int16): bool{.cdecl, + dynlib: libX11, importc: "XkbLibraryVersion".} +proc XkbSetXlibControls*(dpy: PDisplay, affect, values: int16): int16{.cdecl, + dynlib: libX11, importc: "XkbSetXlibControls".} +proc XkbGetXlibControls*(dpy: PDisplay): int16{.cdecl, dynlib: libX11, + importc: "XkbGetXlibControls".} +type + TXkbInternAtomFunc* = proc (dpy: PDisplay, name: cstring, only_if_exists: bool): TAtom{. + cdecl.} + +type + TXkbGetAtomNameFunc* = proc (dpy: PDisplay, atom: TAtom): cstring{.cdecl.} + +proc XkbSetAtomFuncs*(getAtom: TXkbInternAtomFunc, getName: TXkbGetAtomNameFunc){. + cdecl, dynlib: libX11, importc: "XkbSetAtomFuncs".} +proc XkbKeycodeToKeysym*(dpy: PDisplay, kc: TKeyCode, group, level: int16): TKeySym{. + cdecl, dynlib: libX11, importc: "XkbKeycodeToKeysym".} +proc XkbKeysymToModifiers*(dpy: PDisplay, ks: TKeySym): int16{.cdecl, + dynlib: libX11, importc: "XkbKeysymToModifiers".} +proc XkbLookupKeySym*(dpy: PDisplay, keycode: TKeyCode, + modifiers, modifiers_return: int16, keysym_return: PKeySym): bool{. + cdecl, dynlib: libX11, importc: "XkbLookupKeySym".} +proc XkbLookupKeyBinding*(dpy: PDisplay, sym_rtrn: TKeySym, mods: int16, + buffer: cstring, nbytes: int16, extra_rtrn: ptr int16): int16{. + cdecl, dynlib: libX11, importc: "XkbLookupKeyBinding".} +proc XkbTranslateKeyCode*(xkb: PXkbDescPtr, keycode: TKeyCode, + modifiers, modifiers_return: int16, + keysym_return: PKeySym): bool{.cdecl, dynlib: libX11, + importc: "XkbTranslateKeyCode".} +proc XkbTranslateKeySym*(dpy: PDisplay, sym_return: TKeySym, modifiers: int16, + buffer: cstring, nbytes: int16, extra_rtrn: ptr int16): int16{. + cdecl, dynlib: libX11, importc: "XkbTranslateKeySym".} +proc XkbSetAutoRepeatRate*(dpy: PDisplay, deviceSpec, delay, interval: int16): bool{. + cdecl, dynlib: libX11, importc: "XkbSetAutoRepeatRate".} +proc XkbGetAutoRepeatRate*(dpy: PDisplay, deviceSpec: int16, + delayRtrn, intervalRtrn: PWord): bool{.cdecl, + dynlib: libX11, importc: "XkbGetAutoRepeatRate".} +proc XkbChangeEnabledControls*(dpy: PDisplay, deviceSpec, affect, values: int16): bool{. + cdecl, dynlib: libX11, importc: "XkbChangeEnabledControls".} +proc XkbDeviceBell*(dpy: PDisplay, win: TWindow, + deviceSpec, bellClass, bellID, percent: int16, name: TAtom): bool{. + cdecl, dynlib: libX11, importc: "XkbDeviceBell".} +proc XkbForceDeviceBell*(dpy: PDisplay, + deviceSpec, bellClass, bellID, percent: int16): bool{. + cdecl, dynlib: libX11, importc: "XkbForceDeviceBell".} +proc XkbDeviceBellEvent*(dpy: PDisplay, win: TWindow, + deviceSpec, bellClass, bellID, percent: int16, + name: TAtom): bool{.cdecl, dynlib: libX11, + importc: "XkbDeviceBellEvent".} +proc XkbBell*(dpy: PDisplay, win: TWindow, percent: int16, name: TAtom): bool{. + cdecl, dynlib: libX11, importc: "XkbBell".} +proc XkbForceBell*(dpy: PDisplay, percent: int16): bool{.cdecl, dynlib: libX11, + importc: "XkbForceBell".} +proc XkbBellEvent*(dpy: PDisplay, win: TWindow, percent: int16, name: TAtom): bool{. + cdecl, dynlib: libX11, importc: "XkbBellEvent".} +proc XkbSelectEvents*(dpy: PDisplay, deviceID, affect, values: int16): bool{. + cdecl, dynlib: libX11, importc: "XkbSelectEvents".} +proc XkbSelectEventDetails*(dpy: PDisplay, deviceID, eventType: int16, + affect, details: int32): bool{.cdecl, + dynlib: libX11, importc: "XkbSelectEventDetails".} +proc XkbNoteMapChanges*(old: PXkbMapChangesPtr, new: PXkbMapNotifyEvent, + wanted: int16){.cdecl, dynlib: libX11, + importc: "XkbNoteMapChanges".} +proc XkbNoteNameChanges*(old: PXkbNameChangesPtr, new: PXkbNamesNotifyEvent, + wanted: int16){.cdecl, dynlib: libX11, + importc: "XkbNoteNameChanges".} +proc XkbGetIndicatorState*(dpy: PDisplay, deviceSpec: int16, pStateRtrn: PWord): TStatus{. + cdecl, dynlib: libX11, importc: "XkbGetIndicatorState".} +proc XkbGetDeviceIndicatorState*(dpy: PDisplay, + deviceSpec, ledClass, ledID: int16, + pStateRtrn: PWord): TStatus{.cdecl, + dynlib: libX11, importc: "XkbGetDeviceIndicatorState".} +proc XkbGetIndicatorMap*(dpy: PDisplay, which: int32, desc: PXkbDescPtr): TStatus{. + cdecl, dynlib: libX11, importc: "XkbGetIndicatorMap".} +proc XkbSetIndicatorMap*(dpy: PDisplay, which: int32, desc: PXkbDescPtr): bool{. + cdecl, dynlib: libX11, importc: "XkbSetIndicatorMap".} +proc XkbNoteIndicatorMapChanges*(o, n: PXkbIndicatorChangesPtr, w: int16) +proc XkbNoteIndicatorStateChanges*(o, n: PXkbIndicatorChangesPtr, w: int16) +proc XkbGetIndicatorMapChanges*(d: PDisplay, x: PXkbDescPtr, + c: PXkbIndicatorChangesPtr): TStatus +proc XkbChangeIndicatorMaps*(d: PDisplay, x: PXkbDescPtr, + c: PXkbIndicatorChangesPtr): bool +proc XkbGetNamedIndicator*(dpy: PDisplay, name: TAtom, pNdxRtrn: ptr int16, + pStateRtrn: ptr bool, pMapRtrn: PXkbIndicatorMapPtr, + pRealRtrn: ptr bool): bool{.cdecl, dynlib: libX11, + importc: "XkbGetNamedIndicator".} +proc XkbGetNamedDeviceIndicator*(dpy: PDisplay, + deviceSpec, ledClass, ledID: int16, + name: TAtom, pNdxRtrn: ptr int16, + pStateRtrn: ptr bool, + pMapRtrn: PXkbIndicatorMapPtr, + pRealRtrn: ptr bool): bool{.cdecl, + dynlib: libX11, importc: "XkbGetNamedDeviceIndicator".} +proc XkbSetNamedIndicator*(dpy: PDisplay, name: TAtom, + changeState, state, createNewMap: bool, + pMap: PXkbIndicatorMapPtr): bool{.cdecl, + dynlib: libX11, importc: "XkbSetNamedIndicator".} +proc XkbSetNamedDeviceIndicator*(dpy: PDisplay, + deviceSpec, ledClass, ledID: int16, + name: TAtom, + changeState, state, createNewMap: bool, + pMap: PXkbIndicatorMapPtr): bool{.cdecl, + dynlib: libX11, importc: "XkbSetNamedDeviceIndicator".} +proc XkbLockModifiers*(dpy: PDisplay, deviceSpec, affect, values: int16): bool{. + cdecl, dynlib: libX11, importc: "XkbLockModifiers".} +proc XkbLatchModifiers*(dpy: PDisplay, deviceSpec, affect, values: int16): bool{. + cdecl, dynlib: libX11, importc: "XkbLatchModifiers".} +proc XkbLockGroup*(dpy: PDisplay, deviceSpec, group: int16): bool{.cdecl, + dynlib: libX11, importc: "XkbLockGroup".} +proc XkbLatchGroup*(dpy: PDisplay, deviceSpec, group: int16): bool{.cdecl, + dynlib: libX11, importc: "XkbLatchGroup".} +proc XkbSetServerInternalMods*(dpy: PDisplay, deviceSpec, affectReal, + realValues, affectVirtual, virtualValues: int16): bool{.cdecl, + dynlib: libX11, importc: "XkbSetServerInternalMods".} +proc XkbSetIgnoreLockMods*(dpy: PDisplay, deviceSpec, affectReal, realValues, + affectVirtual, virtualValues: int16): bool{.cdecl, dynlib: libX11, + importc: "XkbSetIgnoreLockMods".} +proc XkbVirtualModsToReal*(dpy: PDisplay, virtual_mask: int16, mask_rtrn: PWord): bool{. + cdecl, dynlib: libX11, importc: "XkbVirtualModsToReal".} +proc XkbComputeEffectiveMap*(xkb: PXkbDescPtr, theType: PXkbKeyTypePtr, + map_rtrn: PByte): bool{.cdecl, dynlib: libX11, + importc: "XkbComputeEffectiveMap".} +proc XkbInitCanonicalKeyTypes*(xkb: PXkbDescPtr, which: int16, keypadVMod: int16): TStatus{. + cdecl, dynlib: libX11, importc: "XkbInitCanonicalKeyTypes".} +proc XkbAllocKeyboard*(): PXkbDescPtr{.cdecl, dynlib: libX11, + importc: "XkbAllocKeyboard".} +proc XkbFreeKeyboard*(xkb: PXkbDescPtr, which: int16, freeDesc: bool){.cdecl, + dynlib: libX11, importc: "XkbFreeKeyboard".} +proc XkbAllocClientMap*(xkb: PXkbDescPtr, which, nTypes: int16): TStatus{.cdecl, + dynlib: libX11, importc: "XkbAllocClientMap".} +proc XkbAllocServerMap*(xkb: PXkbDescPtr, which, nActions: int16): TStatus{. + cdecl, dynlib: libX11, importc: "XkbAllocServerMap".} +proc XkbFreeClientMap*(xkb: PXkbDescPtr, what: int16, freeMap: bool){.cdecl, + dynlib: libX11, importc: "XkbFreeClientMap".} +proc XkbFreeServerMap*(xkb: PXkbDescPtr, what: int16, freeMap: bool){.cdecl, + dynlib: libX11, importc: "XkbFreeServerMap".} +proc XkbAddKeyType*(xkb: PXkbDescPtr, name: TAtom, map_count: int16, + want_preserve: bool, num_lvls: int16): PXkbKeyTypePtr{. + cdecl, dynlib: libX11, importc: "XkbAddKeyType".} +proc XkbAllocIndicatorMaps*(xkb: PXkbDescPtr): TStatus{.cdecl, dynlib: libX11, + importc: "XkbAllocIndicatorMaps".} +proc XkbFreeIndicatorMaps*(xkb: PXkbDescPtr){.cdecl, dynlib: libX11, + importc: "XkbFreeIndicatorMaps".} +proc XkbGetMap*(dpy: PDisplay, which, deviceSpec: int16): PXkbDescPtr{.cdecl, + dynlib: libX11, importc: "XkbGetMap".} +proc XkbGetUpdatedMap*(dpy: PDisplay, which: int16, desc: PXkbDescPtr): TStatus{. + cdecl, dynlib: libX11, importc: "XkbGetUpdatedMap".} +proc XkbGetMapChanges*(dpy: PDisplay, xkb: PXkbDescPtr, + changes: PXkbMapChangesPtr): TStatus{.cdecl, + dynlib: libX11, importc: "XkbGetMapChanges".} +proc XkbRefreshKeyboardMapping*(event: PXkbMapNotifyEvent): TStatus{.cdecl, + dynlib: libX11, importc: "XkbRefreshKeyboardMapping".} +proc XkbGetKeyTypes*(dpy: PDisplay, first, num: int16, xkb: PXkbDescPtr): TStatus{. + cdecl, dynlib: libX11, importc: "XkbGetKeyTypes".} +proc XkbGetKeySyms*(dpy: PDisplay, first, num: int16, xkb: PXkbDescPtr): TStatus{. + cdecl, dynlib: libX11, importc: "XkbGetKeySyms".} +proc XkbGetKeyActions*(dpy: PDisplay, first, num: int16, xkb: PXkbDescPtr): TStatus{. + cdecl, dynlib: libX11, importc: "XkbGetKeyActions".} +proc XkbGetKeyBehaviors*(dpy: PDisplay, firstKey, nKeys: int16, + desc: PXkbDescPtr): TStatus{.cdecl, dynlib: libX11, + importc: "XkbGetKeyBehaviors".} +proc XkbGetVirtualMods*(dpy: PDisplay, which: int16, desc: PXkbDescPtr): TStatus{. + cdecl, dynlib: libX11, importc: "XkbGetVirtualMods".} +proc XkbGetKeyExplicitComponents*(dpy: PDisplay, firstKey, nKeys: int16, + desc: PXkbDescPtr): TStatus{.cdecl, + dynlib: libX11, importc: "XkbGetKeyExplicitComponents".} +proc XkbGetKeyModifierMap*(dpy: PDisplay, firstKey, nKeys: int16, + desc: PXkbDescPtr): TStatus{.cdecl, dynlib: libX11, + importc: "XkbGetKeyModifierMap".} +proc XkbAllocControls*(xkb: PXkbDescPtr, which: int16): TStatus{.cdecl, + dynlib: libX11, importc: "XkbAllocControls".} +proc XkbFreeControls*(xkb: PXkbDescPtr, which: int16, freeMap: bool){.cdecl, + dynlib: libX11, importc: "XkbFreeControls".} +proc XkbGetControls*(dpy: PDisplay, which: int32, desc: PXkbDescPtr): TStatus{. + cdecl, dynlib: libX11, importc: "XkbGetControls".} +proc XkbSetControls*(dpy: PDisplay, which: int32, desc: PXkbDescPtr): bool{. + cdecl, dynlib: libX11, importc: "XkbSetControls".} +proc XkbNoteControlsChanges*(old: PXkbControlsChangesPtr, + new: PXkbControlsNotifyEvent, wanted: int16){. + cdecl, dynlib: libX11, importc: "XkbNoteControlsChanges".} +proc XkbGetControlsChanges*(d: PDisplay, x: PXkbDescPtr, + c: PXkbControlsChangesPtr): TStatus +proc XkbChangeControls*(d: PDisplay, x: PXkbDescPtr, c: PXkbControlsChangesPtr): bool +proc XkbAllocCompatMap*(xkb: PXkbDescPtr, which, nInterpret: int16): TStatus{. + cdecl, dynlib: libX11, importc: "XkbAllocCompatMap".} +proc XkbFreeCompatMap*(xkib: PXkbDescPtr, which: int16, freeMap: bool){.cdecl, + dynlib: libX11, importc: "XkbFreeCompatMap".} +proc XkbGetCompatMap*(dpy: PDisplay, which: int16, xkb: PXkbDescPtr): TStatus{. + cdecl, dynlib: libX11, importc: "XkbGetCompatMap".} +proc XkbSetCompatMap*(dpy: PDisplay, which: int16, xkb: PXkbDescPtr, + updateActions: bool): bool{.cdecl, dynlib: libX11, + importc: "XkbSetCompatMap".} +proc XkbAddSymInterpret*(xkb: PXkbDescPtr, si: PXkbSymInterpretPtr, + updateMap: bool, changes: PXkbChangesPtr): PXkbSymInterpretPtr{. + cdecl, dynlib: libX11, importc: "XkbAddSymInterpret".} +proc XkbAllocNames*(xkb: PXkbDescPtr, which: int16, + nTotalRG, nTotalAliases: int16): TStatus{.cdecl, + dynlib: libX11, importc: "XkbAllocNames".} +proc XkbGetNames*(dpy: PDisplay, which: int16, desc: PXkbDescPtr): TStatus{. + cdecl, dynlib: libX11, importc: "XkbGetNames".} +proc XkbSetNames*(dpy: PDisplay, which, firstType, nTypes: int16, + desc: PXkbDescPtr): bool{.cdecl, dynlib: libX11, + importc: "XkbSetNames".} +proc XkbChangeNames*(dpy: PDisplay, xkb: PXkbDescPtr, + changes: PXkbNameChangesPtr): bool{.cdecl, dynlib: libX11, + importc: "XkbChangeNames".} +proc XkbFreeNames*(xkb: PXkbDescPtr, which: int16, freeMap: bool){.cdecl, + dynlib: libX11, importc: "XkbFreeNames".} +proc XkbGetState*(dpy: PDisplay, deviceSpec: int16, rtrnState: PXkbStatePtr): TStatus{. + cdecl, dynlib: libX11, importc: "XkbGetState".} +proc XkbSetMap*(dpy: PDisplay, which: int16, desc: PXkbDescPtr): bool{.cdecl, + dynlib: libX11, importc: "XkbSetMap".} +proc XkbChangeMap*(dpy: PDisplay, desc: PXkbDescPtr, changes: PXkbMapChangesPtr): bool{. + cdecl, dynlib: libX11, importc: "XkbChangeMap".} +proc XkbSetDetectableAutoRepeat*(dpy: PDisplay, detectable: bool, + supported: ptr bool): bool{.cdecl, + dynlib: libX11, importc: "XkbSetDetectableAutoRepeat".} +proc XkbGetDetectableAutoRepeat*(dpy: PDisplay, supported: ptr bool): bool{. + cdecl, dynlib: libX11, importc: "XkbGetDetectableAutoRepeat".} +proc XkbSetAutoResetControls*(dpy: PDisplay, changes: int16, + auto_ctrls, auto_values: PWord): bool{.cdecl, + dynlib: libX11, importc: "XkbSetAutoResetControls".} +proc XkbGetAutoResetControls*(dpy: PDisplay, auto_ctrls, auto_ctrl_values: PWord): bool{. + cdecl, dynlib: libX11, importc: "XkbGetAutoResetControls".} +proc XkbSetPerClientControls*(dpy: PDisplay, change: int16, values: PWord): bool{. + cdecl, dynlib: libX11, importc: "XkbSetPerClientControls".} +proc XkbGetPerClientControls*(dpy: PDisplay, ctrls: PWord): bool{.cdecl, + dynlib: libX11, importc: "XkbGetPerClientControls".} +proc XkbCopyKeyType*(`from`, into: PXkbKeyTypePtr): TStatus{.cdecl, + dynlib: libX11, importc: "XkbCopyKeyType".} +proc XkbCopyKeyTypes*(`from`, into: PXkbKeyTypePtr, num_types: int16): TStatus{. + cdecl, dynlib: libX11, importc: "XkbCopyKeyTypes".} +proc XkbResizeKeyType*(xkb: PXkbDescPtr, type_ndx, map_count: int16, + want_preserve: bool, new_num_lvls: int16): TStatus{. + cdecl, dynlib: libX11, importc: "XkbResizeKeyType".} +proc XkbResizeKeySyms*(desc: PXkbDescPtr, forKey, symsNeeded: int16): PKeySym{. + cdecl, dynlib: libX11, importc: "XkbResizeKeySyms".} +proc XkbResizeKeyActions*(desc: PXkbDescPtr, forKey, actsNeeded: int16): PXkbAction{. + cdecl, dynlib: libX11, importc: "XkbResizeKeyActions".} +proc XkbChangeTypesOfKey*(xkb: PXkbDescPtr, key, num_groups: int16, + groups: int16, newTypes: ptr int16, + pChanges: PXkbMapChangesPtr): TStatus{.cdecl, + dynlib: libX11, importc: "XkbChangeTypesOfKey".} + +proc XkbListComponents*(dpy: PDisplay, deviceSpec: int16, + ptrns: PXkbComponentNamesPtr, max_inout: ptr int16): PXkbComponentListPtr{. + cdecl, dynlib: libX11, importc: "XkbListComponents".} +proc XkbFreeComponentList*(list: PXkbComponentListPtr){.cdecl, dynlib: libX11, + importc: "XkbFreeComponentList".} +proc XkbGetKeyboard*(dpy: PDisplay, which, deviceSpec: int16): PXkbDescPtr{. + cdecl, dynlib: libX11, importc: "XkbGetKeyboard".} +proc XkbGetKeyboardByName*(dpy: PDisplay, deviceSpec: int16, + names: PXkbComponentNamesPtr, want, need: int16, + load: bool): PXkbDescPtr{.cdecl, dynlib: libX11, + importc: "XkbGetKeyboardByName".} + +proc XkbKeyTypesForCoreSymbols*(xkb: PXkbDescPtr, + map_width: int16, # keyboard device + core_syms: PKeySym, # always mapWidth symbols + protected: int16, # explicit key types + types_inout: ptr int16, # always four type indices + xkb_syms_rtrn: PKeySym): int16{.cdecl, + dynlib: libX11, importc: "XkbKeyTypesForCoreSymbols".} + # must have enough space +proc XkbApplyCompatMapToKey*(xkb: PXkbDescPtr, + key: TKeyCode, # key to be updated + changes: PXkbChangesPtr): bool{.cdecl, + dynlib: libX11, importc: "XkbApplyCompatMapToKey".} + # resulting changes to map +proc XkbUpdateMapFromCore*(xkb: PXkbDescPtr, + first_key: TKeyCode, # first changed key + num_keys, + map_width: int16, + core_keysyms: PKeySym, # symbols `from` core keymap + changes: PXkbChangesPtr): bool{.cdecl, + dynlib: libX11, importc: "XkbUpdateMapFromCore".} + +proc XkbAddDeviceLedInfo*(devi: PXkbDeviceInfoPtr, ledClass, ledId: int16): PXkbDeviceLedInfoPtr{. + cdecl, dynlib: libX11, importc: "XkbAddDeviceLedInfo".} +proc XkbResizeDeviceButtonActions*(devi: PXkbDeviceInfoPtr, newTotal: int16): TStatus{. + cdecl, dynlib: libX11, importc: "XkbResizeDeviceButtonActions".} +proc XkbAllocDeviceInfo*(deviceSpec, nButtons, szLeds: int16): PXkbDeviceInfoPtr{. + cdecl, dynlib: libX11, importc: "XkbAllocDeviceInfo".} +proc XkbFreeDeviceInfo*(devi: PXkbDeviceInfoPtr, which: int16, freeDevI: bool){. + cdecl, dynlib: libX11, importc: "XkbFreeDeviceInfo".} +proc XkbNoteDeviceChanges*(old: PXkbDeviceChangesPtr, + new: PXkbExtensionDeviceNotifyEvent, wanted: int16){. + cdecl, dynlib: libX11, importc: "XkbNoteDeviceChanges".} +proc XkbGetDeviceInfo*(dpy: PDisplay, which, deviceSpec, ledClass, ledID: int16): PXkbDeviceInfoPtr{. + cdecl, dynlib: libX11, importc: "XkbGetDeviceInfo".} +proc XkbGetDeviceInfoChanges*(dpy: PDisplay, devi: PXkbDeviceInfoPtr, + changes: PXkbDeviceChangesPtr): TStatus{.cdecl, + dynlib: libX11, importc: "XkbGetDeviceInfoChanges".} +proc XkbGetDeviceButtonActions*(dpy: PDisplay, devi: PXkbDeviceInfoPtr, + all: bool, first, nBtns: int16): TStatus{.cdecl, + dynlib: libX11, importc: "XkbGetDeviceButtonActions".} +proc XkbGetDeviceLedInfo*(dpy: PDisplay, devi: PXkbDeviceInfoPtr, + ledClass, ledId, which: int16): TStatus{.cdecl, + dynlib: libX11, importc: "XkbGetDeviceLedInfo".} +proc XkbSetDeviceInfo*(dpy: PDisplay, which: int16, devi: PXkbDeviceInfoPtr): bool{. + cdecl, dynlib: libX11, importc: "XkbSetDeviceInfo".} +proc XkbChangeDeviceInfo*(dpy: PDisplay, desc: PXkbDeviceInfoPtr, + changes: PXkbDeviceChangesPtr): bool{.cdecl, + dynlib: libX11, importc: "XkbChangeDeviceInfo".} +proc XkbSetDeviceLedInfo*(dpy: PDisplay, devi: PXkbDeviceInfoPtr, + ledClass, ledID, which: int16): bool{.cdecl, + dynlib: libX11, importc: "XkbSetDeviceLedInfo".} +proc XkbSetDeviceButtonActions*(dpy: PDisplay, devi: PXkbDeviceInfoPtr, + first, nBtns: int16): bool{.cdecl, + dynlib: libX11, importc: "XkbSetDeviceButtonActions".} + +proc XkbToControl*(c: int8): int8{.cdecl, dynlib: libX11, + importc: "XkbToControl".} + +proc XkbSetDebuggingFlags*(dpy: PDisplay, mask, flags: int16, msg: cstring, + ctrls_mask, ctrls, rtrn_flags, rtrn_ctrls: int16): bool{. + cdecl, dynlib: libX11, importc: "XkbSetDebuggingFlags".} +proc XkbApplyVirtualModChanges*(xkb: PXkbDescPtr, changed: int16, + changes: PXkbChangesPtr): bool{.cdecl, + dynlib: libX11, importc: "XkbApplyVirtualModChanges".} + +# implementation + +proc XkbNoteIndicatorMapChanges(o, n: PXkbIndicatorChangesPtr, w: int16) = + ##define XkbNoteIndicatorMapChanges(o,n,w) ((o)->map_changes|=((n)->map_changes&(w))) + o.map_changes = o.map_changes or (n.map_changes and w) + +proc XkbNoteIndicatorStateChanges(o, n: PXkbIndicatorChangesPtr, w: int16) = + ##define XkbNoteIndicatorStateChanges(o,n,w) ((o)->state_changes|=((n)->state_changes&(w))) + o.state_changes = o.state_changes or (n.state_changes and (w)) + +proc XkbGetIndicatorMapChanges(d: PDisplay, x: PXkbDescPtr, + c: PXkbIndicatorChangesPtr): TStatus = + ##define XkbGetIndicatorMapChanges(d,x,c) (XkbGetIndicatorMap((d),(c)->map_changes,x) + Result = XkbGetIndicatorMap(d, c.map_changes, x) + +proc XkbChangeIndicatorMaps(d: PDisplay, x: PXkbDescPtr, + c: PXkbIndicatorChangesPtr): bool = + ##define XkbChangeIndicatorMaps(d,x,c) (XkbSetIndicatorMap((d),(c)->map_changes,x)) + Result = XkbSetIndicatorMap(d, c.map_changes, x) + +proc XkbGetControlsChanges(d: PDisplay, x: PXkbDescPtr, + c: PXkbControlsChangesPtr): TStatus = + ##define XkbGetControlsChanges(d,x,c) XkbGetControls(d,(c)->changed_ctrls,x) + Result = XkbGetControls(d, c.changed_ctrls, x) + +proc XkbChangeControls(d: PDisplay, x: PXkbDescPtr, c: PXkbControlsChangesPtr): bool = + ##define XkbChangeControls(d,x,c) XkbSetControls(d,(c)->changed_ctrls,x) + Result = XkbSetControls(d, c.changed_ctrls, x) diff --git a/lib/base/x11/xlib.nim b/lib/base/x11/xlib.nim new file mode 100644 index 000000000..84f9bbfc5 --- /dev/null +++ b/lib/base/x11/xlib.nim @@ -0,0 +1,2218 @@ + +import + x + +const + libX11* = "libX11.so" + +type + cuint* = cint + cunsigned* = cint + cushort* = int16 + Pcint* = ptr cint + PPcint* = ptr Pcint + PPcuchar* = ptr ptr cuchar + PWideChar* = ptr int16 + PPChar* = ptr cstring + PPPChar* = ptr ptr cstring + Pculong* = ptr int + Pcuchar* = cstring + Pcuint* = ptr cint + Pcushort* = ptr int16 +# Automatically converted by H2Pas 0.99.15 from xlib.h +# The following command line parameters were used: +# -p +# -T +# -S +# -d +# -c +# xlib.h + +const + XlibSpecificationRelease* = 6 + +type + PXPointer* = ptr TXPointer + TXPointer* = ptr char + PBool* = ptr TBool + TBool* = int #cint? + PStatus* = ptr TStatus + TStatus* = cint + +const + QueuedAlready* = 0 + QueuedAfterReading* = 1 + QueuedAfterFlush* = 2 + +type + PPXExtData* = ptr PXExtData + PXExtData* = ptr TXExtData + TXExtData*{.final.} = object + number*: cint + next*: PXExtData + free_private*: proc (extension: PXExtData): cint{.cdecl.} + private_data*: TXPointer + + PXExtCodes* = ptr TXExtCodes + TXExtCodes*{.final.} = object + extension*: cint + major_opcode*: cint + first_event*: cint + first_error*: cint + + PXPixmapFormatValues* = ptr TXPixmapFormatValues + TXPixmapFormatValues*{.final.} = object + depth*: cint + bits_per_pixel*: cint + scanline_pad*: cint + + PXGCValues* = ptr TXGCValues + TXGCValues*{.final.} = object + function_*: cint + plane_mask*: culong + foreground*: culong + background*: culong + line_width*: cint + line_style*: cint + cap_style*: cint + join_style*: cint + fill_style*: cint + fill_rule*: cint + arc_mode*: cint + tile*: TPixmap + stipple*: TPixmap + ts_x_origin*: cint + ts_y_origin*: cint + font*: TFont + subwindow_mode*: cint + graphics_exposures*: TBool + clip_x_origin*: cint + clip_y_origin*: cint + clip_mask*: TPixmap + dash_offset*: cint + dashes*: cchar + + PXGC* = ptr TXGC + TXGC*{.final.} = object + TGC* = PXGC + PGC* = ptr TGC + PVisual* = ptr TVisual + TVisual*{.final.} = object + ext_data*: PXExtData + visualid*: TVisualID + c_class*: cint + red_mask*, green_mask*, blue_mask*: culong + bits_per_rgb*: cint + map_entries*: cint + + PDepth* = ptr TDepth + TDepth*{.final.} = object + depth*: cint + nvisuals*: cint + visuals*: PVisual + + PXDisplay* = ptr TXDisplay + TXDisplay*{.final.} = object + PScreen* = ptr TScreen + TScreen*{.final.} = object + ext_data*: PXExtData + display*: PXDisplay + root*: TWindow + width*, height*: cint + mwidth*, mheight*: cint + ndepths*: cint + depths*: PDepth + root_depth*: cint + root_visual*: PVisual + default_gc*: TGC + cmap*: TColormap + white_pixel*: culong + black_pixel*: culong + max_maps*, min_maps*: cint + backing_store*: cint + save_unders*: TBool + root_input_mask*: clong + + PScreenFormat* = ptr TScreenFormat + TScreenFormat*{.final.} = object + ext_data*: PXExtData + depth*: cint + bits_per_pixel*: cint + scanline_pad*: cint + + PXSetWindowAttributes* = ptr TXSetWindowAttributes + TXSetWindowAttributes*{.final.} = object + background_pixmap*: TPixmap + background_pixel*: culong + border_pixmap*: TPixmap + border_pixel*: culong + bit_gravity*: cint + win_gravity*: cint + backing_store*: cint + backing_planes*: culong + backing_pixel*: culong + save_under*: TBool + event_mask*: clong + do_not_propagate_mask*: clong + override_redirect*: TBool + colormap*: TColormap + cursor*: TCursor + + PXWindowAttributes* = ptr TXWindowAttributes + TXWindowAttributes*{.final.} = object + x*, y*: cint + width*, height*: cint + border_width*: cint + depth*: cint + visual*: PVisual + root*: TWindow + c_class*: cint + bit_gravity*: cint + win_gravity*: cint + backing_store*: cint + backing_planes*: culong + backing_pixel*: culong + save_under*: TBool + colormap*: TColormap + map_installed*: TBool + map_state*: cint + all_event_masks*: clong + your_event_mask*: clong + do_not_propagate_mask*: clong + override_redirect*: TBool + screen*: PScreen + + PXHostAddress* = ptr TXHostAddress + TXHostAddress*{.final.} = object + family*: cint + len*: cint + address*: cstring + + PXServerInterpretedAddress* = ptr TXServerInterpretedAddress + TXServerInterpretedAddress*{.final.} = object + typelength*: cint + valuelength*: cint + theType*: cstring + value*: cstring + + PXImage* = ptr TXImage + TF*{.final.} = object + create_image*: proc (para1: PXDisplay, para2: PVisual, para3: cuint, + para4: cint, para5: cint, para6: cstring, para7: cuint, + para8: cuint, para9: cint, para10: cint): PXImage{. + cdecl.} + destroy_image*: proc (para1: PXImage): cint{.cdecl.} + get_pixel*: proc (para1: PXImage, para2: cint, para3: cint): culong{.cdecl.} + put_pixel*: proc (para1: PXImage, para2: cint, para3: cint, para4: culong): cint{. + cdecl.} + sub_image*: proc (para1: PXImage, para2: cint, para3: cint, para4: cuint, + para5: cuint): PXImage{.cdecl.} + add_pixel*: proc (para1: PXImage, para2: clong): cint{.cdecl.} + + TXImage*{.final.} = object + width*, height*: cint + xoffset*: cint + format*: cint + data*: cstring + byte_order*: cint + bitmap_unit*: cint + bitmap_bit_order*: cint + bitmap_pad*: cint + depth*: cint + bytes_per_line*: cint + bits_per_pixel*: cint + red_mask*: culong + green_mask*: culong + blue_mask*: culong + obdata*: TXPointer + f*: TF + + PXWindowChanges* = ptr TXWindowChanges + TXWindowChanges*{.final.} = object + x*, y*: cint + width*, height*: cint + border_width*: cint + sibling*: TWindow + stack_mode*: cint + + PXColor* = ptr TXColor + TXColor*{.final.} = object + pixel*: culong + red*, green*, blue*: cushort + flags*: cchar + pad*: cchar + + PXSegment* = ptr TXSegment + TXSegment*{.final.} = object + x1*, y1*, x2*, y2*: cshort + + PXPoint* = ptr TXPoint + TXPoint*{.final.} = object + x*, y*: cshort + + PXRectangle* = ptr TXRectangle + TXRectangle*{.final.} = object + x*, y*: cshort + width*, height*: cushort + + PXArc* = ptr TXArc + TXArc*{.final.} = object + x*, y*: cshort + width*, height*: cushort + angle1*, angle2*: cshort + + PXKeyboardControl* = ptr TXKeyboardControl + TXKeyboardControl*{.final.} = object + key_click_percent*: cint + bell_percent*: cint + bell_pitch*: cint + bell_duration*: cint + led*: cint + led_mode*: cint + key*: cint + auto_repeat_mode*: cint + + PXKeyboardState* = ptr TXKeyboardState + TXKeyboardState*{.final.} = object + key_click_percent*: cint + bell_percent*: cint + bell_pitch*, bell_duration*: cuint + led_mask*: culong + global_auto_repeat*: cint + auto_repeats*: array[0..31, cchar] + + PXTimeCoord* = ptr TXTimeCoord + TXTimeCoord*{.final.} = object + time*: TTime + x*, y*: cshort + + PXModifierKeymap* = ptr TXModifierKeymap + TXModifierKeymap*{.final.} = object + max_keypermod*: cint + modifiermap*: PKeyCode + + PDisplay* = ptr TDisplay + TDisplay* = TXDisplay + PXPrivate* = ptr TXPrivate + TXPrivate*{.final.} = object + PXrmHashBucketRec* = ptr TXrmHashBucketRec + TXrmHashBucketRec*{.final.} = object + PXPrivDisplay* = ptr TXPrivDisplay + TXPrivDisplay*{.final.} = object + ext_data*: PXExtData + private1*: PXPrivate + fd*: cint + private2*: cint + proto_major_version*: cint + proto_minor_version*: cint + vendor*: cstring + private3*: TXID + private4*: TXID + private5*: TXID + private6*: cint + resource_alloc*: proc (para1: PXDisplay): TXID{.cdecl.} + byte_order*: cint + bitmap_unit*: cint + bitmap_pad*: cint + bitmap_bit_order*: cint + nformats*: cint + pixmap_format*: PScreenFormat + private8*: cint + release*: cint + private9*, private10*: PXPrivate + qlen*: cint + last_request_read*: culong + request*: culong + private11*: TXPointer + private12*: TXPointer + private13*: TXPointer + private14*: TXPointer + max_request_size*: cunsigned + db*: PXrmHashBucketRec + private15*: proc (para1: PXDisplay): cint{.cdecl.} + display_name*: cstring + default_screen*: cint + nscreens*: cint + screens*: PScreen + motion_buffer*: culong + private16*: culong + min_keycode*: cint + max_keycode*: cint + private17*: TXPointer + private18*: TXPointer + private19*: cint + xdefaults*: cstring + + PXKeyEvent* = ptr TXKeyEvent + TXKeyEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + window*: TWindow + root*: TWindow + subwindow*: TWindow + time*: TTime + x*, y*: cint + x_root*, y_root*: cint + state*: cuint + keycode*: cuint + same_screen*: TBool + + PXKeyPressedEvent* = ptr TXKeyPressedEvent + TXKeyPressedEvent* = TXKeyEvent + PXKeyReleasedEvent* = ptr TXKeyReleasedEvent + TXKeyReleasedEvent* = TXKeyEvent + PXButtonEvent* = ptr TXButtonEvent + TXButtonEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + window*: TWindow + root*: TWindow + subwindow*: TWindow + time*: TTime + x*, y*: cint + x_root*, y_root*: cint + state*: cuint + button*: cuint + same_screen*: TBool + + PXButtonPressedEvent* = ptr TXButtonPressedEvent + TXButtonPressedEvent* = TXButtonEvent + PXButtonReleasedEvent* = ptr TXButtonReleasedEvent + TXButtonReleasedEvent* = TXButtonEvent + PXMotionEvent* = ptr TXMotionEvent + TXMotionEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + window*: TWindow + root*: TWindow + subwindow*: TWindow + time*: TTime + x*, y*: cint + x_root*, y_root*: cint + state*: cuint + is_hint*: cchar + same_screen*: TBool + + PXPointerMovedEvent* = ptr TXPointerMovedEvent + TXPointerMovedEvent* = TXMotionEvent + PXCrossingEvent* = ptr TXCrossingEvent + TXCrossingEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + window*: TWindow + root*: TWindow + subwindow*: TWindow + time*: TTime + x*, y*: cint + x_root*, y_root*: cint + mode*: cint + detail*: cint + same_screen*: TBool + focus*: TBool + state*: cuint + + PXEnterWindowEvent* = ptr TXEnterWindowEvent + TXEnterWindowEvent* = TXCrossingEvent + PXLeaveWindowEvent* = ptr TXLeaveWindowEvent + TXLeaveWindowEvent* = TXCrossingEvent + PXFocusChangeEvent* = ptr TXFocusChangeEvent + TXFocusChangeEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + window*: TWindow + mode*: cint + detail*: cint + + PXFocusInEvent* = ptr TXFocusInEvent + TXFocusInEvent* = TXFocusChangeEvent + PXFocusOutEvent* = ptr TXFocusOutEvent + TXFocusOutEvent* = TXFocusChangeEvent + PXKeymapEvent* = ptr TXKeymapEvent + TXKeymapEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + window*: TWindow + key_vector*: array[0..31, cchar] + + PXExposeEvent* = ptr TXExposeEvent + TXExposeEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + window*: TWindow + x*, y*: cint + width*, height*: cint + count*: cint + + PXGraphicsExposeEvent* = ptr TXGraphicsExposeEvent + TXGraphicsExposeEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + drawable*: TDrawable + x*, y*: cint + width*, height*: cint + count*: cint + major_code*: cint + minor_code*: cint + + PXNoExposeEvent* = ptr TXNoExposeEvent + TXNoExposeEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + drawable*: TDrawable + major_code*: cint + minor_code*: cint + + PXVisibilityEvent* = ptr TXVisibilityEvent + TXVisibilityEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + window*: TWindow + state*: cint + + PXCreateWindowEvent* = ptr TXCreateWindowEvent + TXCreateWindowEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + parent*: TWindow + window*: TWindow + x*, y*: cint + width*, height*: cint + border_width*: cint + override_redirect*: TBool + + PXDestroyWindowEvent* = ptr TXDestroyWindowEvent + TXDestroyWindowEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + event*: TWindow + window*: TWindow + + PXUnmapEvent* = ptr TXUnmapEvent + TXUnmapEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + event*: TWindow + window*: TWindow + from_configure*: TBool + + PXMapEvent* = ptr TXMapEvent + TXMapEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + event*: TWindow + window*: TWindow + override_redirect*: TBool + + PXMapRequestEvent* = ptr TXMapRequestEvent + TXMapRequestEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + parent*: TWindow + window*: TWindow + + PXReparentEvent* = ptr TXReparentEvent + TXReparentEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + event*: TWindow + window*: TWindow + parent*: TWindow + x*, y*: cint + override_redirect*: TBool + + PXConfigureEvent* = ptr TXConfigureEvent + TXConfigureEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + event*: TWindow + window*: TWindow + x*, y*: cint + width*, height*: cint + border_width*: cint + above*: TWindow + override_redirect*: TBool + + PXGravityEvent* = ptr TXGravityEvent + TXGravityEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + event*: TWindow + window*: TWindow + x*, y*: cint + + PXResizeRequestEvent* = ptr TXResizeRequestEvent + TXResizeRequestEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + window*: TWindow + width*, height*: cint + + PXConfigureRequestEvent* = ptr TXConfigureRequestEvent + TXConfigureRequestEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + parent*: TWindow + window*: TWindow + x*, y*: cint + width*, height*: cint + border_width*: cint + above*: TWindow + detail*: cint + value_mask*: culong + + PXCirculateEvent* = ptr TXCirculateEvent + TXCirculateEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + event*: TWindow + window*: TWindow + place*: cint + + PXCirculateRequestEvent* = ptr TXCirculateRequestEvent + TXCirculateRequestEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + parent*: TWindow + window*: TWindow + place*: cint + + PXPropertyEvent* = ptr TXPropertyEvent + TXPropertyEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + window*: TWindow + atom*: TAtom + time*: TTime + state*: cint + + PXSelectionClearEvent* = ptr TXSelectionClearEvent + TXSelectionClearEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + window*: TWindow + selection*: TAtom + time*: TTime + + PXSelectionRequestEvent* = ptr TXSelectionRequestEvent + TXSelectionRequestEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + owner*: TWindow + requestor*: TWindow + selection*: TAtom + target*: TAtom + property_*: TAtom + time*: TTime + + PXSelectionEvent* = ptr TXSelectionEvent + TXSelectionEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + requestor*: TWindow + selection*: TAtom + target*: TAtom + property_*: TAtom + time*: TTime + + PXColormapEvent* = ptr TXColormapEvent + TXColormapEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + window*: TWindow + colormap*: TColormap + c_new*: TBool + state*: cint + + PXClientMessageEvent* = ptr TXClientMessageEvent + TXClientMessageEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + window*: TWindow + message_type*: TAtom + format*: cint + data*: array[0..19, char] + + PXMappingEvent* = ptr TXMappingEvent + TXMappingEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + window*: TWindow + request*: cint + first_keycode*: cint + count*: cint + + PXErrorEvent* = ptr TXErrorEvent + TXErrorEvent*{.final.} = object + theType*: cint + display*: PDisplay + resourceid*: TXID + serial*: culong + error_code*: cuchar + request_code*: cuchar + minor_code*: cuchar + + PXAnyEvent* = ptr TXAnyEvent + TXAnyEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + window*: TWindow + + PXEvent* = ptr TXEvent + TXEvent*{.final.} = object + theType*: cint + pad*: array[0..22, clong] # + # case longint of + # 0 : ( theType : cint ); + # 1 : ( xany : TXAnyEvent ); + # 2 : ( xkey : TXKeyEvent ); + # 3 : ( xbutton : TXButtonEvent ); + # 4 : ( xmotion : TXMotionEvent ); + # 5 : ( xcrossing : TXCrossingEvent ); + # 6 : ( xfocus : TXFocusChangeEvent ); + # 7 : ( xexpose : TXExposeEvent ); + # 8 : ( xgraphicsexpose : TXGraphicsExposeEvent ); + # 9 : ( xnoexpose : TXNoExposeEvent ); + # 10 : ( xvisibility : TXVisibilityEvent ); + # 11 : ( xcreatewindow : TXCreateWindowEvent ); + # 12 : ( xdestroywindow : TXDestroyWindowEvent ); + # 13 : ( xunmap : TXUnmapEvent ); + # 14 : ( xmap : TXMapEvent ); + # 15 : ( xmaprequest : TXMapRequestEvent ); + # 16 : ( xreparent : TXReparentEvent ); + # 17 : ( xconfigure : TXConfigureEvent ); + # 18 : ( xgravity : TXGravityEvent ); + # 19 : ( xresizerequest : TXResizeRequestEvent ); + # 20 : ( xconfigurerequest : TXConfigureRequestEvent ); + # 21 : ( xcirculate : TXCirculateEvent ); + # 22 : ( xcirculaterequest : TXCirculateRequestEvent ); + # 23 : ( xproperty : TXPropertyEvent ); + # 24 : ( xselectionclear : TXSelectionClearEvent ); + # 25 : ( xselectionrequest : TXSelectionRequestEvent ); + # 26 : ( xselection : TXSelectionEvent ); + # 27 : ( xcolormap : TXColormapEvent ); + # 28 : ( xclient : TXClientMessageEvent ); + # 29 : ( xmapping : TXMappingEvent ); + # 30 : ( xerror : TXErrorEvent ); + # 31 : ( xkeymap : TXKeymapEvent ); + # 32 : ( pad : array[0..23] of clong ); + # + + +type + PXCharStruct* = ptr TXCharStruct + TXCharStruct*{.final.} = object + lbearing*: cshort + rbearing*: cshort + width*: cshort + ascent*: cshort + descent*: cshort + attributes*: cushort + + PXFontProp* = ptr TXFontProp + TXFontProp*{.final.} = object + name*: TAtom + card32*: culong + + PPPXFontStruct* = ptr PPXFontStruct + PPXFontStruct* = ptr PXFontStruct + PXFontStruct* = ptr TXFontStruct + TXFontStruct*{.final.} = object + ext_data*: PXExtData + fid*: TFont + direction*: cunsigned + min_char_or_byte2*: cunsigned + max_char_or_byte2*: cunsigned + min_byte1*: cunsigned + max_byte1*: cunsigned + all_chars_exist*: TBool + default_char*: cunsigned + n_properties*: cint + properties*: PXFontProp + min_bounds*: TXCharStruct + max_bounds*: TXCharStruct + per_char*: PXCharStruct + ascent*: cint + descent*: cint + + PXTextItem* = ptr TXTextItem + TXTextItem*{.final.} = object + chars*: cstring + nchars*: cint + delta*: cint + font*: TFont + + PXChar2b* = ptr TXChar2b + TXChar2b*{.final.} = object + byte1*: cuchar + byte2*: cuchar + + PXTextItem16* = ptr TXTextItem16 + TXTextItem16*{.final.} = object + chars*: PXChar2b + nchars*: cint + delta*: cint + font*: TFont + + PXEDataObject* = ptr TXEDataObject + TXEDataObject*{.final.} = object + display*: PDisplay #case longint of + # 0 : ( display : PDisplay ); + # 1 : ( gc : TGC ); + # 2 : ( visual : PVisual ); + # 3 : ( screen : PScreen ); + # 4 : ( pixmap_format : PScreenFormat ); + # 5 : ( font : PXFontStruct ); + + PXFontSetExtents* = ptr TXFontSetExtents + TXFontSetExtents*{.final.} = object + max_ink_extent*: TXRectangle + max_logical_extent*: TXRectangle + + PXOM* = ptr TXOM + TXOM*{.final.} = object + PXOC* = ptr TXOC + TXOC*{.final.} = object + TXFontSet* = PXOC + PXFontSet* = ptr TXFontSet + PXmbTextItem* = ptr TXmbTextItem + TXmbTextItem*{.final.} = object + chars*: cstring + nchars*: cint + delta*: cint + font_set*: TXFontSet + + PXwcTextItem* = ptr TXwcTextItem + TXwcTextItem*{.final.} = object + chars*: PWideChar #wchar_t* + nchars*: cint + delta*: cint + font_set*: TXFontSet + + +const + XNRequiredCharSet* = "requiredCharSet" + XNQueryOrientation* = "queryOrientation" + XNBaseFontName* = "baseFontName" + XNOMAutomatic* = "omAutomatic" + XNMissingCharSet* = "missingCharSet" + XNDefaultString* = "defaultString" + XNOrientation* = "orientation" + XNDirectionalDependentDrawing* = "directionalDependentDrawing" + XNContextualDrawing* = "contextualDrawing" + XNFontInfo* = "fontInfo" + +type + PXOMCharSetList* = ptr TXOMCharSetList + TXOMCharSetList*{.final.} = object + charset_count*: cint + charset_list*: PPChar + + PXOrientation* = ptr TXOrientation + TXOrientation* = enum + XOMOrientation_LTR_TTB, XOMOrientation_RTL_TTB, XOMOrientation_TTB_LTR, + XOMOrientation_TTB_RTL, XOMOrientation_Context + PXOMOrientation* = ptr TXOMOrientation + TXOMOrientation*{.final.} = object + num_orientation*: cint + orientation*: PXOrientation + + PXOMFontInfo* = ptr TXOMFontInfo + TXOMFontInfo*{.final.} = object + num_font*: cint + font_struct_list*: ptr PXFontStruct + font_name_list*: PPChar + + PXIM* = ptr TXIM + TXIM*{.final.} = object + PXIC* = ptr TXIC + TXIC*{.final.} = object + TXIMProc* = proc (para1: TXIM, para2: TXPointer, para3: TXPointer){.cdecl.} + TXICProc* = proc (para1: TXIC, para2: TXPointer, para3: TXPointer): TBool{. + cdecl.} + TXIDProc* = proc (para1: PDisplay, para2: TXPointer, para3: TXPointer){.cdecl.} + PXIMStyle* = ptr TXIMStyle + TXIMStyle* = culong + PXIMStyles* = ptr TXIMStyles + TXIMStyles*{.final.} = object + count_styles*: cushort + supported_styles*: PXIMStyle + + +const + XIMPreeditArea* = 0x00000001 + XIMPreeditCallbacks* = 0x00000002 + XIMPreeditPosition* = 0x00000004 + XIMPreeditNothing* = 0x00000008 + XIMPreeditNone* = 0x00000010 + XIMStatusArea* = 0x00000100 + XIMStatusCallbacks* = 0x00000200 + XIMStatusNothing* = 0x00000400 + XIMStatusNone* = 0x00000800 + XNVaNestedList* = "XNVaNestedList" + XNQueryInputStyle* = "queryInputStyle" + XNClientWindow* = "clientWindow" + XNInputStyle* = "inputStyle" + XNFocusWindow* = "focusWindow" + XNResourceName* = "resourceName" + XNResourceClass* = "resourceClass" + XNGeometryCallback* = "geometryCallback" + XNDestroyCallback* = "destroyCallback" + XNFilterEvents* = "filterEvents" + XNPreeditStartCallback* = "preeditStartCallback" + XNPreeditDoneCallback* = "preeditDoneCallback" + XNPreeditDrawCallback* = "preeditDrawCallback" + XNPreeditCaretCallback* = "preeditCaretCallback" + XNPreeditStateNotifyCallback* = "preeditStateNotifyCallback" + XNPreeditAttributes* = "preeditAttributes" + XNStatusStartCallback* = "statusStartCallback" + XNStatusDoneCallback* = "statusDoneCallback" + XNStatusDrawCallback* = "statusDrawCallback" + XNStatusAttributes* = "statusAttributes" + XNArea* = "area" + XNAreaNeeded* = "areaNeeded" + XNSpotLocation* = "spotLocation" + XNColormap* = "colorMap" + XNStdColormap* = "stdColorMap" + XNForeground* = "foreground" + XNBackground* = "background" + XNBackgroundPixmap* = "backgroundPixmap" + XNFontSet* = "fontSet" + XNLineSpace* = "lineSpace" + XNCursor* = "cursor" + XNQueryIMValuesList* = "queryIMValuesList" + XNQueryICValuesList* = "queryICValuesList" + XNVisiblePosition* = "visiblePosition" + XNR6PreeditCallback* = "r6PreeditCallback" + XNStringConversionCallback* = "stringConversionCallback" + XNStringConversion* = "stringConversion" + XNResetState* = "resetState" + XNHotKey* = "hotKey" + XNHotKeyState* = "hotKeyState" + XNPreeditState* = "preeditState" + XNSeparatorofNestedList* = "separatorofNestedList" + XBufferOverflow* = - (1) + XLookupNone* = 1 + XLookupChars* = 2 + XLookupKeySymVal* = 3 + XLookupBoth* = 4 + +type + PXVaNestedList* = ptr TXVaNestedList + TXVaNestedList* = pointer + PXIMCallback* = ptr TXIMCallback + TXIMCallback*{.final.} = object + client_data*: TXPointer + callback*: TXIMProc + + PXICCallback* = ptr TXICCallback + TXICCallback*{.final.} = object + client_data*: TXPointer + callback*: TXICProc + + PXIMFeedback* = ptr TXIMFeedback + TXIMFeedback* = culong + +const + XIMReverse* = 1 + XIMUnderline* = 1 shl 1 + XIMHighlight* = 1 shl 2 + XIMPrimary* = 1 shl 5 + XIMSecondary* = 1 shl 6 + XIMTertiary* = 1 shl 7 + XIMVisibleToForward* = 1 shl 8 + XIMVisibleToBackword* = 1 shl 9 + XIMVisibleToCenter* = 1 shl 10 + +type + PXIMText* = ptr TXIMText + TXIMText*{.final.} = object + len*: cushort + feedback*: PXIMFeedback + encoding_is_wchar*: TBool + multi_byte*: cstring + + PXIMPreeditState* = ptr TXIMPreeditState + TXIMPreeditState* = culong + +const + XIMPreeditUnKnown* = 0 + XIMPreeditEnable* = 1 + XIMPreeditDisable* = 1 shl 1 + +type + PXIMPreeditStateNotifyCallbackStruct* = ptr TXIMPreeditStateNotifyCallbackStruct + TXIMPreeditStateNotifyCallbackStruct*{.final.} = object + state*: TXIMPreeditState + + PXIMResetState* = ptr TXIMResetState + TXIMResetState* = culong + +const + XIMInitialState* = 1 + XIMPreserveState* = 1 shl 1 + +type + PXIMStringConversionFeedback* = ptr TXIMStringConversionFeedback + TXIMStringConversionFeedback* = culong + +const + XIMStringConversionLeftEdge* = 0x00000001 + XIMStringConversionRightEdge* = 0x00000002 + XIMStringConversionTopEdge* = 0x00000004 + XIMStringConversionBottomEdge* = 0x00000008 + XIMStringConversionConcealed* = 0x00000010 + XIMStringConversionWrapped* = 0x00000020 + +type + PXIMStringConversionText* = ptr TXIMStringConversionText + TXIMStringConversionText*{.final.} = object + len*: cushort + feedback*: PXIMStringConversionFeedback + encoding_is_wchar*: TBool + mbs*: cstring + + PXIMStringConversionPosition* = ptr TXIMStringConversionPosition + TXIMStringConversionPosition* = cushort + PXIMStringConversionType* = ptr TXIMStringConversionType + TXIMStringConversionType* = cushort + +const + XIMStringConversionBuffer* = 0x00000001 + XIMStringConversionLine* = 0x00000002 + XIMStringConversionWord* = 0x00000003 + XIMStringConversionChar* = 0x00000004 + +type + PXIMStringConversionOperation* = ptr TXIMStringConversionOperation + TXIMStringConversionOperation* = cushort + +const + XIMStringConversionSubstitution* = 0x00000001 + XIMStringConversionRetrieval* = 0x00000002 + +type + PXIMCaretDirection* = ptr TXIMCaretDirection + TXIMCaretDirection* = enum + XIMForwardChar, XIMBackwardChar, XIMForwardWord, XIMBackwardWord, + XIMCaretUp, XIMCaretDown, XIMNextLine, XIMPreviousLine, XIMLineStart, + XIMLineEnd, XIMAbsolutePosition, XIMDontChange + PXIMStringConversionCallbackStruct* = ptr TXIMStringConversionCallbackStruct + TXIMStringConversionCallbackStruct*{.final.} = object + position*: TXIMStringConversionPosition + direction*: TXIMCaretDirection + operation*: TXIMStringConversionOperation + factor*: cushort + text*: PXIMStringConversionText + + PXIMPreeditDrawCallbackStruct* = ptr TXIMPreeditDrawCallbackStruct + TXIMPreeditDrawCallbackStruct*{.final.} = object + caret*: cint + chg_first*: cint + chg_length*: cint + text*: PXIMText + + PXIMCaretStyle* = ptr TXIMCaretStyle + TXIMCaretStyle* = enum + XIMIsInvisible, XIMIsPrimary, XIMIsSecondary + PXIMPreeditCaretCallbackStruct* = ptr TXIMPreeditCaretCallbackStruct + TXIMPreeditCaretCallbackStruct*{.final.} = object + position*: cint + direction*: TXIMCaretDirection + style*: TXIMCaretStyle + + PXIMStatusDataType* = ptr TXIMStatusDataType + TXIMStatusDataType* = enum + XIMTextType, XIMBitmapType + PXIMStatusDrawCallbackStruct* = ptr TXIMStatusDrawCallbackStruct + TXIMStatusDrawCallbackStruct*{.final.} = object + theType*: TXIMStatusDataType + bitmap*: TPixmap + + PXIMHotKeyTrigger* = ptr TXIMHotKeyTrigger + TXIMHotKeyTrigger*{.final.} = object + keysym*: TKeySym + modifier*: cint + modifier_mask*: cint + + PXIMHotKeyTriggers* = ptr TXIMHotKeyTriggers + TXIMHotKeyTriggers*{.final.} = object + num_hot_key*: cint + key*: PXIMHotKeyTrigger + + PXIMHotKeyState* = ptr TXIMHotKeyState + TXIMHotKeyState* = culong + +const + XIMHotKeyStateON* = 0x00000001 + XIMHotKeyStateOFF* = 0x00000002 + +type + PXIMValuesList* = ptr TXIMValuesList + TXIMValuesList*{.final.} = object + count_values*: cushort + supported_values*: PPChar + + +type + funcdisp* = proc (display: PDisplay): cint{.cdecl.} + funcifevent* = proc (display: PDisplay, event: PXEvent, p: TXPointer): TBool{. + cdecl.} + chararr32* = array[0..31, char] + +const + AllPlanes*: culong = culong(not 0) + +proc XLoadQueryFont*(para1: PDisplay, para2: cstring): PXFontStruct{.cdecl, + dynlib: libX11, importc.} +proc XQueryFont*(para1: PDisplay, para2: TXID): PXFontStruct{.cdecl, + dynlib: libX11, importc.} +proc XGetMotionEvents*(para1: PDisplay, para2: TWindow, para3: TTime, + para4: TTime, para5: Pcint): PXTimeCoord{.cdecl, + dynlib: libX11, importc.} +proc XDeleteModifiermapEntry*(para1: PXModifierKeymap, para2: TKeyCode, + para3: cint): PXModifierKeymap{.cdecl, + dynlib: libX11, importc.} +proc XGetModifierMapping*(para1: PDisplay): PXModifierKeymap{.cdecl, + dynlib: libX11, importc.} +proc XInsertModifiermapEntry*(para1: PXModifierKeymap, para2: TKeyCode, + para3: cint): PXModifierKeymap{.cdecl, + dynlib: libX11, importc.} +proc XNewModifiermap*(para1: cint): PXModifierKeymap{.cdecl, dynlib: libX11, + importc.} +proc XCreateImage*(para1: PDisplay, para2: PVisual, para3: cuint, para4: cint, + para5: cint, para6: cstring, para7: cuint, para8: cuint, + para9: cint, para10: cint): PXImage{.cdecl, dynlib: libX11, + importc.} +proc XInitImage*(para1: PXImage): TStatus{.cdecl, dynlib: libX11, importc.} +proc XGetImage*(para1: PDisplay, para2: TDrawable, para3: cint, para4: cint, + para5: cuint, para6: cuint, para7: culong, para8: cint): PXImage{. + cdecl, dynlib: libX11, importc.} +proc XGetSubImage*(para1: PDisplay, para2: TDrawable, para3: cint, para4: cint, + para5: cuint, para6: cuint, para7: culong, para8: cint, + para9: PXImage, para10: cint, para11: cint): PXImage{.cdecl, + dynlib: libX11, importc.} +proc XOpenDisplay*(para1: cstring): PDisplay{.cdecl, dynlib: libX11, importc.} +proc XrmInitialize*(){.cdecl, dynlib: libX11, importc.} +proc XFetchBytes*(para1: PDisplay, para2: Pcint): cstring{.cdecl, + dynlib: libX11, importc.} +proc XFetchBuffer*(para1: PDisplay, para2: Pcint, para3: cint): cstring{.cdecl, + dynlib: libX11, importc.} +proc XGetAtomName*(para1: PDisplay, para2: TAtom): cstring{.cdecl, + dynlib: libX11, importc.} +proc XGetAtomNames*(para1: PDisplay, para2: PAtom, para3: cint, para4: PPchar): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XGetDefault*(para1: PDisplay, para2: cstring, para3: cstring): cstring{. + cdecl, dynlib: libX11, importc.} +proc XDisplayName*(para1: cstring): cstring{.cdecl, dynlib: libX11, importc.} +proc XKeysymToString*(para1: TKeySym): cstring{.cdecl, dynlib: libX11, importc.} +proc XSynchronize*(para1: PDisplay, para2: TBool): funcdisp{.cdecl, + dynlib: libX11, importc.} +proc XSetAfterFunction*(para1: PDisplay, para2: funcdisp): funcdisp{.cdecl, + dynlib: libX11, importc.} +proc XInternAtom*(para1: PDisplay, para2: cstring, para3: TBool): TAtom{.cdecl, + dynlib: libX11, importc.} +proc XInternAtoms*(para1: PDisplay, para2: PPchar, para3: cint, para4: TBool, + para5: PAtom): TStatus{.cdecl, dynlib: libX11, importc.} +proc XCopyColormapAndFree*(para1: PDisplay, para2: TColormap): TColormap{.cdecl, + dynlib: libX11, importc.} +proc XCreateColormap*(para1: PDisplay, para2: TWindow, para3: PVisual, + para4: cint): TColormap{.cdecl, dynlib: libX11, importc.} +proc XCreatePixmapCursor*(para1: PDisplay, para2: TPixmap, para3: TPixmap, + para4: PXColor, para5: PXColor, para6: cuint, + para7: cuint): TCursor{.cdecl, dynlib: libX11, importc.} +proc XCreateGlyphCursor*(para1: PDisplay, para2: TFont, para3: TFont, + para4: cuint, para5: cuint, para6: PXColor, + para7: PXColor): TCursor{.cdecl, dynlib: libX11, + importc.} +proc XCreateFontCursor*(para1: PDisplay, para2: cuint): TCursor{.cdecl, + dynlib: libX11, importc.} +proc XLoadFont*(para1: PDisplay, para2: cstring): TFont{.cdecl, dynlib: libX11, + importc.} +proc XCreateGC*(para1: PDisplay, para2: TDrawable, para3: culong, + para4: PXGCValues): TGC{.cdecl, dynlib: libX11, importc.} +proc XGContextFromGC*(para1: TGC): TGContext{.cdecl, dynlib: libX11, importc.} +proc XFlushGC*(para1: PDisplay, para2: TGC){.cdecl, dynlib: libX11, importc.} +proc XCreatePixmap*(para1: PDisplay, para2: TDrawable, para3: cuint, + para4: cuint, para5: cuint): TPixmap{.cdecl, dynlib: libX11, + importc.} +proc XCreateBitmapFromData*(para1: PDisplay, para2: TDrawable, para3: cstring, + para4: cuint, para5: cuint): TPixmap{.cdecl, + dynlib: libX11, importc.} +proc XCreatePixmapFromBitmapData*(para1: PDisplay, para2: TDrawable, + para3: cstring, para4: cuint, para5: cuint, + para6: culong, para7: culong, para8: cuint): TPixmap{. + cdecl, dynlib: libX11, importc.} +proc XCreateSimpleWindow*(para1: PDisplay, para2: TWindow, para3: cint, + para4: cint, para5: cuint, para6: cuint, para7: cuint, + para8: culong, para9: culong): TWindow{.cdecl, + dynlib: libX11, importc.} +proc XGetSelectionOwner*(para1: PDisplay, para2: TAtom): TWindow{.cdecl, + dynlib: libX11, importc.} +proc XCreateWindow*(para1: PDisplay, para2: TWindow, para3: cint, para4: cint, + para5: cuint, para6: cuint, para7: cuint, para8: cint, + para9: cuint, para10: PVisual, para11: culong, + para12: PXSetWindowAttributes): TWindow{.cdecl, + dynlib: libX11, importc.} +proc XListInstalledColormaps*(para1: PDisplay, para2: TWindow, para3: Pcint): PColormap{. + cdecl, dynlib: libX11, importc.} +proc XListFonts*(para1: PDisplay, para2: cstring, para3: cint, para4: Pcint): PPChar{. + cdecl, dynlib: libX11, importc.} +proc XListFontsWithInfo*(para1: PDisplay, para2: cstring, para3: cint, + para4: Pcint, para5: PPXFontStruct): PPChar{.cdecl, + dynlib: libX11, importc.} +proc XGetFontPath*(para1: PDisplay, para2: Pcint): PPChar{.cdecl, + dynlib: libX11, importc.} +proc XListExtensions*(para1: PDisplay, para2: Pcint): PPChar{.cdecl, + dynlib: libX11, importc.} +proc XListProperties*(para1: PDisplay, para2: TWindow, para3: Pcint): PAtom{. + cdecl, dynlib: libX11, importc.} +proc XListHosts*(para1: PDisplay, para2: Pcint, para3: PBool): PXHostAddress{. + cdecl, dynlib: libX11, importc.} +proc XKeycodeToKeysym*(para1: PDisplay, para2: TKeyCode, para3: cint): TKeySym{. + cdecl, dynlib: libX11, importc.} +proc XLookupKeysym*(para1: PXKeyEvent, para2: cint): TKeySym{.cdecl, + dynlib: libX11, importc.} +proc XGetKeyboardMapping*(para1: PDisplay, para2: TKeyCode, para3: cint, + para4: Pcint): PKeySym{.cdecl, dynlib: libX11, importc.} +proc XStringToKeysym*(para1: cstring): TKeySym{.cdecl, dynlib: libX11, importc.} +proc XMaxRequestSize*(para1: PDisplay): clong{.cdecl, dynlib: libX11, importc.} +proc XExtendedMaxRequestSize*(para1: PDisplay): clong{.cdecl, dynlib: libX11, + importc.} +proc XResourceManagerString*(para1: PDisplay): cstring{.cdecl, dynlib: libX11, + importc.} +proc XScreenResourceString*(para1: PScreen): cstring{.cdecl, dynlib: libX11, + importc.} +proc XDisplayMotionBufferSize*(para1: PDisplay): culong{.cdecl, dynlib: libX11, + importc.} +proc XVisualIDFromVisual*(para1: PVisual): TVisualID{.cdecl, dynlib: libX11, + importc.} +proc XInitThreads*(): TStatus{.cdecl, dynlib: libX11, importc.} +proc XLockDisplay*(para1: PDisplay){.cdecl, dynlib: libX11, importc.} +proc XUnlockDisplay*(para1: PDisplay){.cdecl, dynlib: libX11, importc.} +proc XInitExtension*(para1: PDisplay, para2: cstring): PXExtCodes{.cdecl, + dynlib: libX11, importc.} +proc XAddExtension*(para1: PDisplay): PXExtCodes{.cdecl, dynlib: libX11, importc.} +proc XFindOnExtensionList*(para1: PPXExtData, para2: cint): PXExtData{.cdecl, + dynlib: libX11, importc.} +proc XEHeadOfExtensionList*(para1: TXEDataObject): PPXExtData{.cdecl, + dynlib: libX11, importc.} +proc XRootWindow*(para1: PDisplay, para2: cint): TWindow{.cdecl, dynlib: libX11, + importc.} +proc XDefaultRootWindow*(para1: PDisplay): TWindow{.cdecl, dynlib: libX11, + importc.} +proc XRootWindowOfScreen*(para1: PScreen): TWindow{.cdecl, dynlib: libX11, + importc.} +proc XDefaultVisual*(para1: PDisplay, para2: cint): PVisual{.cdecl, + dynlib: libX11, importc.} +proc XDefaultVisualOfScreen*(para1: PScreen): PVisual{.cdecl, dynlib: libX11, + importc.} +proc XDefaultGC*(para1: PDisplay, para2: cint): TGC{.cdecl, dynlib: libX11, + importc.} +proc XDefaultGCOfScreen*(para1: PScreen): TGC{.cdecl, dynlib: libX11, importc.} +proc XBlackPixel*(para1: PDisplay, para2: cint): culong{.cdecl, dynlib: libX11, + importc.} +proc XWhitePixel*(para1: PDisplay, para2: cint): culong{.cdecl, dynlib: libX11, + importc.} +proc XAllPlanes*(): culong{.cdecl, dynlib: libX11, importc.} +proc XBlackPixelOfScreen*(para1: PScreen): culong{.cdecl, dynlib: libX11, + importc.} +proc XWhitePixelOfScreen*(para1: PScreen): culong{.cdecl, dynlib: libX11, + importc.} +proc XNextRequest*(para1: PDisplay): culong{.cdecl, dynlib: libX11, importc.} +proc XLastKnownRequestProcessed*(para1: PDisplay): culong{.cdecl, + dynlib: libX11, importc.} +proc XServerVendor*(para1: PDisplay): cstring{.cdecl, dynlib: libX11, importc.} +proc XDisplayString*(para1: PDisplay): cstring{.cdecl, dynlib: libX11, importc.} +proc XDefaultColormap*(para1: PDisplay, para2: cint): TColormap{.cdecl, + dynlib: libX11, importc.} +proc XDefaultColormapOfScreen*(para1: PScreen): TColormap{.cdecl, + dynlib: libX11, importc.} +proc XDisplayOfScreen*(para1: PScreen): PDisplay{.cdecl, dynlib: libX11, importc.} +proc XScreenOfDisplay*(para1: PDisplay, para2: cint): PScreen{.cdecl, + dynlib: libX11, importc.} +proc XDefaultScreenOfDisplay*(para1: PDisplay): PScreen{.cdecl, dynlib: libX11, + importc.} +proc XEventMaskOfScreen*(para1: PScreen): clong{.cdecl, dynlib: libX11, importc.} +proc XScreenNumberOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, + importc.} +type + TXErrorHandler* = proc (para1: PDisplay, para2: PXErrorEvent): cint{.cdecl.} + +proc XSetErrorHandler*(para1: TXErrorHandler): TXErrorHandler{.cdecl, + dynlib: libX11, importc.} +type + TXIOErrorHandler* = proc (para1: PDisplay): cint{.cdecl.} + +proc XSetIOErrorHandler*(para1: TXIOErrorHandler): TXIOErrorHandler{.cdecl, + dynlib: libX11, importc.} +proc XListPixmapFormats*(para1: PDisplay, para2: Pcint): PXPixmapFormatValues{. + cdecl, dynlib: libX11, importc.} +proc XListDepths*(para1: PDisplay, para2: cint, para3: Pcint): Pcint{.cdecl, + dynlib: libX11, importc.} +proc XReconfigureWMWindow*(para1: PDisplay, para2: TWindow, para3: cint, + para4: cuint, para5: PXWindowChanges): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XGetWMProtocols*(para1: PDisplay, para2: TWindow, para3: PPAtom, + para4: Pcint): TStatus{.cdecl, dynlib: libX11, importc.} +proc XSetWMProtocols*(para1: PDisplay, para2: TWindow, para3: PAtom, para4: cint): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XIconifyWindow*(para1: PDisplay, para2: TWindow, para3: cint): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XWithdrawWindow*(para1: PDisplay, para2: TWindow, para3: cint): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XGetCommand*(para1: PDisplay, para2: TWindow, para3: PPPchar, para4: Pcint): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XGetWMColormapWindows*(para1: PDisplay, para2: TWindow, para3: PPWindow, + para4: Pcint): TStatus{.cdecl, dynlib: libX11, + importc.} +proc XSetWMColormapWindows*(para1: PDisplay, para2: TWindow, para3: PWindow, + para4: cint): TStatus{.cdecl, dynlib: libX11, + importc.} +proc XFreeStringList*(para1: PPchar){.cdecl, dynlib: libX11, importc.} +proc XSetTransientForHint*(para1: PDisplay, para2: TWindow, para3: TWindow): cint{. + cdecl, dynlib: libX11, importc.} +proc XActivateScreenSaver*(para1: PDisplay): cint{.cdecl, dynlib: libX11, + importc.} +proc XAddHost*(para1: PDisplay, para2: PXHostAddress): cint{.cdecl, + dynlib: libX11, importc.} +proc XAddHosts*(para1: PDisplay, para2: PXHostAddress, para3: cint): cint{. + cdecl, dynlib: libX11, importc.} +proc XAddToExtensionList*(para1: PPXExtData, para2: PXExtData): cint{.cdecl, + dynlib: libX11, importc.} +proc XAddToSaveSet*(para1: PDisplay, para2: TWindow): cint{.cdecl, + dynlib: libX11, importc.} +proc XAllocColor*(para1: PDisplay, para2: TColormap, para3: PXColor): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XAllocColorCells*(para1: PDisplay, para2: TColormap, para3: TBool, + para4: Pculong, para5: cuint, para6: Pculong, + para7: cuint): TStatus{.cdecl, dynlib: libX11, importc.} +proc XAllocColorPlanes*(para1: PDisplay, para2: TColormap, para3: TBool, + para4: Pculong, para5: cint, para6: cint, para7: cint, + para8: cint, para9: Pculong, para10: Pculong, + para11: Pculong): TStatus{.cdecl, dynlib: libX11, + importc.} +proc XAllocNamedColor*(para1: PDisplay, para2: TColormap, para3: cstring, + para4: PXColor, para5: PXColor): TStatus{.cdecl, + dynlib: libX11, importc.} +proc XAllowEvents*(para1: PDisplay, para2: cint, para3: TTime): cint{.cdecl, + dynlib: libX11, importc.} +proc XAutoRepeatOff*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.} +proc XAutoRepeatOn*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.} +proc XBell*(para1: PDisplay, para2: cint): cint{.cdecl, dynlib: libX11, importc.} +proc XBitmapBitOrder*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.} +proc XBitmapPad*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.} +proc XBitmapUnit*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.} +proc XCellsOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, importc.} +proc XChangeActivePointerGrab*(para1: PDisplay, para2: cuint, para3: TCursor, + para4: TTime): cint{.cdecl, dynlib: libX11, + importc.} +proc XChangeGC*(para1: PDisplay, para2: TGC, para3: culong, para4: PXGCValues): cint{. + cdecl, dynlib: libX11, importc.} +proc XChangeKeyboardControl*(para1: PDisplay, para2: culong, + para3: PXKeyboardControl): cint{.cdecl, + dynlib: libX11, importc.} +proc XChangeKeyboardMapping*(para1: PDisplay, para2: cint, para3: cint, + para4: PKeySym, para5: cint): cint{.cdecl, + dynlib: libX11, importc.} +proc XChangePointerControl*(para1: PDisplay, para2: TBool, para3: TBool, + para4: cint, para5: cint, para6: cint): cint{.cdecl, + dynlib: libX11, importc.} +proc XChangeProperty*(para1: PDisplay, para2: TWindow, para3: TAtom, + para4: TAtom, para5: cint, para6: cint, para7: Pcuchar, + para8: cint): cint{.cdecl, dynlib: libX11, importc.} +proc XChangeSaveSet*(para1: PDisplay, para2: TWindow, para3: cint): cint{.cdecl, + dynlib: libX11, importc.} +proc XChangeWindowAttributes*(para1: PDisplay, para2: TWindow, para3: culong, + para4: PXSetWindowAttributes): cint{.cdecl, + dynlib: libX11, importc.} +proc XCheckIfEvent*(para1: PDisplay, para2: PXEvent, para3: funcifevent, + para4: TXPointer): TBool{.cdecl, dynlib: libX11, importc.} +proc XCheckMaskEvent*(para1: PDisplay, para2: clong, para3: PXEvent): TBool{. + cdecl, dynlib: libX11, importc.} +proc XCheckTypedEvent*(para1: PDisplay, para2: cint, para3: PXEvent): TBool{. + cdecl, dynlib: libX11, importc.} +proc XCheckTypedWindowEvent*(para1: PDisplay, para2: TWindow, para3: cint, + para4: PXEvent): TBool{.cdecl, dynlib: libX11, + importc.} +proc XCheckWindowEvent*(para1: PDisplay, para2: TWindow, para3: clong, + para4: PXEvent): TBool{.cdecl, dynlib: libX11, importc.} +proc XCirculateSubwindows*(para1: PDisplay, para2: TWindow, para3: cint): cint{. + cdecl, dynlib: libX11, importc.} +proc XCirculateSubwindowsDown*(para1: PDisplay, para2: TWindow): cint{.cdecl, + dynlib: libX11, importc.} +proc XCirculateSubwindowsUp*(para1: PDisplay, para2: TWindow): cint{.cdecl, + dynlib: libX11, importc.} +proc XClearArea*(para1: PDisplay, para2: TWindow, para3: cint, para4: cint, + para5: cuint, para6: cuint, para7: TBool): cint{.cdecl, + dynlib: libX11, importc.} +proc XClearWindow*(para1: PDisplay, para2: TWindow): cint{.cdecl, + dynlib: libX11, importc.} +proc XCloseDisplay*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.} +proc XConfigureWindow*(para1: PDisplay, para2: TWindow, para3: cuint, + para4: PXWindowChanges): cint{.cdecl, dynlib: libX11, + importc.} +proc XConnectionNumber*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.} +proc XConvertSelection*(para1: PDisplay, para2: TAtom, para3: TAtom, + para4: TAtom, para5: TWindow, para6: TTime): cint{. + cdecl, dynlib: libX11, importc.} +proc XCopyArea*(para1: PDisplay, para2: TDrawable, para3: TDrawable, para4: TGC, + para5: cint, para6: cint, para7: cuint, para8: cuint, + para9: cint, para10: cint): cint{.cdecl, dynlib: libX11, importc.} +proc XCopyGC*(para1: PDisplay, para2: TGC, para3: culong, para4: TGC): cint{. + cdecl, dynlib: libX11, importc.} +proc XCopyPlane*(para1: PDisplay, para2: TDrawable, para3: TDrawable, + para4: TGC, para5: cint, para6: cint, para7: cuint, + para8: cuint, para9: cint, para10: cint, para11: culong): cint{. + cdecl, dynlib: libX11, importc.} +proc XDefaultDepth*(para1: PDisplay, para2: cint): cint{.cdecl, dynlib: libX11, + importc.} +proc XDefaultDepthOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, + importc.} +proc XDefaultScreen*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.} +proc XDefineCursor*(para1: PDisplay, para2: TWindow, para3: TCursor): cint{. + cdecl, dynlib: libX11, importc.} +proc XDeleteProperty*(para1: PDisplay, para2: TWindow, para3: TAtom): cint{. + cdecl, dynlib: libX11, importc.} +proc XDestroyWindow*(para1: PDisplay, para2: TWindow): cint{.cdecl, + dynlib: libX11, importc.} +proc XDestroySubwindows*(para1: PDisplay, para2: TWindow): cint{.cdecl, + dynlib: libX11, importc.} +proc XDoesBackingStore*(para1: PScreen): cint{.cdecl, dynlib: libX11, importc.} +proc XDoesSaveUnders*(para1: PScreen): TBool{.cdecl, dynlib: libX11, importc.} +proc XDisableAccessControl*(para1: PDisplay): cint{.cdecl, dynlib: libX11, + importc.} +proc XDisplayCells*(para1: PDisplay, para2: cint): cint{.cdecl, dynlib: libX11, + importc.} +proc XDisplayHeight*(para1: PDisplay, para2: cint): cint{.cdecl, dynlib: libX11, + importc.} +proc XDisplayHeightMM*(para1: PDisplay, para2: cint): cint{.cdecl, + dynlib: libX11, importc.} +proc XDisplayKeycodes*(para1: PDisplay, para2: Pcint, para3: Pcint): cint{. + cdecl, dynlib: libX11, importc.} +proc XDisplayPlanes*(para1: PDisplay, para2: cint): cint{.cdecl, dynlib: libX11, + importc.} +proc XDisplayWidth*(para1: PDisplay, para2: cint): cint{.cdecl, dynlib: libX11, + importc.} +proc XDisplayWidthMM*(para1: PDisplay, para2: cint): cint{.cdecl, + dynlib: libX11, importc.} +proc XDrawArc*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, + para5: cint, para6: cuint, para7: cuint, para8: cint, para9: cint): cint{. + cdecl, dynlib: libX11, importc.} +proc XDrawArcs*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: PXArc, + para5: cint): cint{.cdecl, dynlib: libX11, importc.} +proc XDrawImageString*(para1: PDisplay, para2: TDrawable, para3: TGC, + para4: cint, para5: cint, para6: cstring, para7: cint): cint{. + cdecl, dynlib: libX11, importc.} +proc XDrawImageString16*(para1: PDisplay, para2: TDrawable, para3: TGC, + para4: cint, para5: cint, para6: PXChar2b, para7: cint): cint{. + cdecl, dynlib: libX11, importc.} +proc XDrawLine*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, + para5: cint, para6: cint, para7: cint): cint{.cdecl, + dynlib: libX11, importc.} +proc XDrawLines*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: PXPoint, + para5: cint, para6: cint): cint{.cdecl, dynlib: libX11, importc.} +proc XDrawPoint*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, + para5: cint): cint{.cdecl, dynlib: libX11, importc.} +proc XDrawPoints*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: PXPoint, + para5: cint, para6: cint): cint{.cdecl, dynlib: libX11, + importc.} +proc XDrawRectangle*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, + para5: cint, para6: cuint, para7: cuint): cint{.cdecl, + dynlib: libX11, importc.} +proc XDrawRectangles*(para1: PDisplay, para2: TDrawable, para3: TGC, + para4: PXRectangle, para5: cint): cint{.cdecl, + dynlib: libX11, importc.} +proc XDrawSegments*(para1: PDisplay, para2: TDrawable, para3: TGC, + para4: PXSegment, para5: cint): cint{.cdecl, dynlib: libX11, + importc.} +proc XDrawString*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, + para5: cint, para6: cstring, para7: cint): cint{.cdecl, + dynlib: libX11, importc.} +proc XDrawString16*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, + para5: cint, para6: PXChar2b, para7: cint): cint{.cdecl, + dynlib: libX11, importc.} +proc XDrawText*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, + para5: cint, para6: PXTextItem, para7: cint): cint{.cdecl, + dynlib: libX11, importc.} +proc XDrawText16*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, + para5: cint, para6: PXTextItem16, para7: cint): cint{.cdecl, + dynlib: libX11, importc.} +proc XEnableAccessControl*(para1: PDisplay): cint{.cdecl, dynlib: libX11, + importc.} +proc XEventsQueued*(para1: PDisplay, para2: cint): cint{.cdecl, dynlib: libX11, + importc.} +proc XFetchName*(para1: PDisplay, para2: TWindow, para3: PPchar): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XFillArc*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, + para5: cint, para6: cuint, para7: cuint, para8: cint, para9: cint): cint{. + cdecl, dynlib: libX11, importc.} +proc XFillArcs*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: PXArc, + para5: cint): cint{.cdecl, dynlib: libX11, importc.} +proc XFillPolygon*(para1: PDisplay, para2: TDrawable, para3: TGC, + para4: PXPoint, para5: cint, para6: cint, para7: cint): cint{. + cdecl, dynlib: libX11, importc.} +proc XFillRectangle*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, + para5: cint, para6: cuint, para7: cuint): cint{.cdecl, + dynlib: libX11, importc.} +proc XFillRectangles*(para1: PDisplay, para2: TDrawable, para3: TGC, + para4: PXRectangle, para5: cint): cint{.cdecl, + dynlib: libX11, importc.} +proc XFlush*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.} +proc XForceScreenSaver*(para1: PDisplay, para2: cint): cint{.cdecl, + dynlib: libX11, importc.} +proc XFree*(para1: pointer): cint{.cdecl, dynlib: libX11, importc.} +proc XFreeColormap*(para1: PDisplay, para2: TColormap): cint{.cdecl, + dynlib: libX11, importc.} +proc XFreeColors*(para1: PDisplay, para2: TColormap, para3: Pculong, + para4: cint, para5: culong): cint{.cdecl, dynlib: libX11, + importc.} +proc XFreeCursor*(para1: PDisplay, para2: TCursor): cint{.cdecl, dynlib: libX11, + importc.} +proc XFreeExtensionList*(para1: PPchar): cint{.cdecl, dynlib: libX11, importc.} +proc XFreeFont*(para1: PDisplay, para2: PXFontStruct): cint{.cdecl, + dynlib: libX11, importc.} +proc XFreeFontInfo*(para1: PPchar, para2: PXFontStruct, para3: cint): cint{. + cdecl, dynlib: libX11, importc.} +proc XFreeFontNames*(para1: PPchar): cint{.cdecl, dynlib: libX11, importc.} +proc XFreeFontPath*(para1: PPchar): cint{.cdecl, dynlib: libX11, importc.} +proc XFreeGC*(para1: PDisplay, para2: TGC): cint{.cdecl, dynlib: libX11, importc.} +proc XFreeModifiermap*(para1: PXModifierKeymap): cint{.cdecl, dynlib: libX11, + importc.} +proc XFreePixmap*(para1: PDisplay, para2: TPixmap): cint{.cdecl, dynlib: libX11, + importc.} +proc XGeometry*(para1: PDisplay, para2: cint, para3: cstring, para4: cstring, + para5: cuint, para6: cuint, para7: cuint, para8: cint, + para9: cint, para10: Pcint, para11: Pcint, para12: Pcint, + para13: Pcint): cint{.cdecl, dynlib: libX11, importc.} +proc XGetErrorDatabaseText*(para1: PDisplay, para2: cstring, para3: cstring, + para4: cstring, para5: cstring, para6: cint): cint{. + cdecl, dynlib: libX11, importc.} +proc XGetErrorText*(para1: PDisplay, para2: cint, para3: cstring, para4: cint): cint{. + cdecl, dynlib: libX11, importc.} +proc XGetFontProperty*(para1: PXFontStruct, para2: TAtom, para3: Pculong): TBool{. + cdecl, dynlib: libX11, importc.} +proc XGetGCValues*(para1: PDisplay, para2: TGC, para3: culong, para4: PXGCValues): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XGetGeometry*(para1: PDisplay, para2: TDrawable, para3: PWindow, + para4: Pcint, para5: Pcint, para6: Pcuint, para7: Pcuint, + para8: Pcuint, para9: Pcuint): TStatus{.cdecl, + dynlib: libX11, importc.} +proc XGetIconName*(para1: PDisplay, para2: TWindow, para3: PPchar): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XGetInputFocus*(para1: PDisplay, para2: PWindow, para3: Pcint): cint{. + cdecl, dynlib: libX11, importc.} +proc XGetKeyboardControl*(para1: PDisplay, para2: PXKeyboardState): cint{.cdecl, + dynlib: libX11, importc.} +proc XGetPointerControl*(para1: PDisplay, para2: Pcint, para3: Pcint, + para4: Pcint): cint{.cdecl, dynlib: libX11, importc.} +proc XGetPointerMapping*(para1: PDisplay, para2: Pcuchar, para3: cint): cint{. + cdecl, dynlib: libX11, importc.} +proc XGetScreenSaver*(para1: PDisplay, para2: Pcint, para3: Pcint, para4: Pcint, + para5: Pcint): cint{.cdecl, dynlib: libX11, importc.} +proc XGetTransientForHint*(para1: PDisplay, para2: TWindow, para3: PWindow): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XGetWindowProperty*(para1: PDisplay, para2: TWindow, para3: TAtom, + para4: clong, para5: clong, para6: TBool, para7: TAtom, + para8: PAtom, para9: Pcint, para10: Pculong, + para11: Pculong, para12: PPcuchar): cint{.cdecl, + dynlib: libX11, importc.} +proc XGetWindowAttributes*(para1: PDisplay, para2: TWindow, + para3: PXWindowAttributes): TStatus{.cdecl, + dynlib: libX11, importc.} +proc XGrabButton*(para1: PDisplay, para2: cuint, para3: cuint, para4: TWindow, + para5: TBool, para6: cuint, para7: cint, para8: cint, + para9: TWindow, para10: TCursor): cint{.cdecl, dynlib: libX11, + importc.} +proc XGrabKey*(para1: PDisplay, para2: cint, para3: cuint, para4: TWindow, + para5: TBool, para6: cint, para7: cint): cint{.cdecl, + dynlib: libX11, importc.} +proc XGrabKeyboard*(para1: PDisplay, para2: TWindow, para3: TBool, para4: cint, + para5: cint, para6: TTime): cint{.cdecl, dynlib: libX11, + importc.} +proc XGrabPointer*(para1: PDisplay, para2: TWindow, para3: TBool, para4: cuint, + para5: cint, para6: cint, para7: TWindow, para8: TCursor, + para9: TTime): cint{.cdecl, dynlib: libX11, importc.} +proc XGrabServer*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.} +proc XHeightMMOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, importc.} +proc XHeightOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, importc.} +proc XIfEvent*(para1: PDisplay, para2: PXEvent, para3: funcifevent, + para4: TXPointer): cint{.cdecl, dynlib: libX11, importc.} +proc XImageByteOrder*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.} +proc XInstallColormap*(para1: PDisplay, para2: TColormap): cint{.cdecl, + dynlib: libX11, importc.} +proc XKeysymToKeycode*(para1: PDisplay, para2: TKeySym): TKeyCode{.cdecl, + dynlib: libX11, importc.} +proc XKillClient*(para1: PDisplay, para2: TXID): cint{.cdecl, dynlib: libX11, + importc.} +proc XLookupColor*(para1: PDisplay, para2: TColormap, para3: cstring, + para4: PXColor, para5: PXColor): TStatus{.cdecl, + dynlib: libX11, importc.} +proc XLowerWindow*(para1: PDisplay, para2: TWindow): cint{.cdecl, + dynlib: libX11, importc.} +proc XMapRaised*(para1: PDisplay, para2: TWindow): cint{.cdecl, dynlib: libX11, + importc.} +proc XMapSubwindows*(para1: PDisplay, para2: TWindow): cint{.cdecl, + dynlib: libX11, importc.} +proc XMapWindow*(para1: PDisplay, para2: TWindow): cint{.cdecl, dynlib: libX11, + importc.} +proc XMaskEvent*(para1: PDisplay, para2: clong, para3: PXEvent): cint{.cdecl, + dynlib: libX11, importc.} +proc XMaxCmapsOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, importc.} +proc XMinCmapsOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, importc.} +proc XMoveResizeWindow*(para1: PDisplay, para2: TWindow, para3: cint, + para4: cint, para5: cuint, para6: cuint): cint{.cdecl, + dynlib: libX11, importc.} +proc XMoveWindow*(para1: PDisplay, para2: TWindow, para3: cint, para4: cint): cint{. + cdecl, dynlib: libX11, importc.} +proc XNextEvent*(para1: PDisplay, para2: PXEvent): cint{.cdecl, dynlib: libX11, + importc.} +proc XNoOp*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.} +proc XParseColor*(para1: PDisplay, para2: TColormap, para3: cstring, + para4: PXColor): TStatus{.cdecl, dynlib: libX11, importc.} +proc XParseGeometry*(para1: cstring, para2: Pcint, para3: Pcint, para4: Pcuint, + para5: Pcuint): cint{.cdecl, dynlib: libX11, importc.} +proc XPeekEvent*(para1: PDisplay, para2: PXEvent): cint{.cdecl, dynlib: libX11, + importc.} +proc XPeekIfEvent*(para1: PDisplay, para2: PXEvent, para3: funcifevent, + para4: TXPointer): cint{.cdecl, dynlib: libX11, importc.} +proc XPending*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.} +proc XPlanesOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, importc.} +proc XProtocolRevision*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.} +proc XProtocolVersion*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.} +proc XPutBackEvent*(para1: PDisplay, para2: PXEvent): cint{.cdecl, + dynlib: libX11, importc.} +proc XPutImage*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: PXImage, + para5: cint, para6: cint, para7: cint, para8: cint, + para9: cuint, para10: cuint): cint{.cdecl, dynlib: libX11, + importc.} +proc XQLength*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.} +proc XQueryBestCursor*(para1: PDisplay, para2: TDrawable, para3: cuint, + para4: cuint, para5: Pcuint, para6: Pcuint): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XQueryBestSize*(para1: PDisplay, para2: cint, para3: TDrawable, + para4: cuint, para5: cuint, para6: Pcuint, para7: Pcuint): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XQueryBestStipple*(para1: PDisplay, para2: TDrawable, para3: cuint, + para4: cuint, para5: Pcuint, para6: Pcuint): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XQueryBestTile*(para1: PDisplay, para2: TDrawable, para3: cuint, + para4: cuint, para5: Pcuint, para6: Pcuint): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XQueryColor*(para1: PDisplay, para2: TColormap, para3: PXColor): cint{. + cdecl, dynlib: libX11, importc.} +proc XQueryColors*(para1: PDisplay, para2: TColormap, para3: PXColor, + para4: cint): cint{.cdecl, dynlib: libX11, importc.} +proc XQueryExtension*(para1: PDisplay, para2: cstring, para3: Pcint, + para4: Pcint, para5: Pcint): TBool{.cdecl, dynlib: libX11, + importc.} + #? +proc XQueryKeymap*(para1: PDisplay, para2: chararr32): cint{.cdecl, + dynlib: libX11, importc.} +proc XQueryPointer*(para1: PDisplay, para2: TWindow, para3: PWindow, + para4: PWindow, para5: Pcint, para6: Pcint, para7: Pcint, + para8: Pcint, para9: Pcuint): TBool{.cdecl, dynlib: libX11, + importc.} +proc XQueryTextExtents*(para1: PDisplay, para2: TXID, para3: cstring, + para4: cint, para5: Pcint, para6: Pcint, para7: Pcint, + para8: PXCharStruct): cint{.cdecl, dynlib: libX11, + importc.} +proc XQueryTextExtents16*(para1: PDisplay, para2: TXID, para3: PXChar2b, + para4: cint, para5: Pcint, para6: Pcint, para7: Pcint, + para8: PXCharStruct): cint{.cdecl, dynlib: libX11, + importc.} +proc XQueryTree*(para1: PDisplay, para2: TWindow, para3: PWindow, + para4: PWindow, para5: PPWindow, para6: Pcuint): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XRaiseWindow*(para1: PDisplay, para2: TWindow): cint{.cdecl, + dynlib: libX11, importc.} +proc XReadBitmapFile*(para1: PDisplay, para2: TDrawable, para3: cstring, + para4: Pcuint, para5: Pcuint, para6: PPixmap, + para7: Pcint, para8: Pcint): cint{.cdecl, dynlib: libX11, + importc.} +proc XReadBitmapFileData*(para1: cstring, para2: Pcuint, para3: Pcuint, + para4: PPcuchar, para5: Pcint, para6: Pcint): cint{. + cdecl, dynlib: libX11, importc.} +proc XRebindKeysym*(para1: PDisplay, para2: TKeySym, para3: PKeySym, + para4: cint, para5: Pcuchar, para6: cint): cint{.cdecl, + dynlib: libX11, importc.} +proc XRecolorCursor*(para1: PDisplay, para2: TCursor, para3: PXColor, + para4: PXColor): cint{.cdecl, dynlib: libX11, importc.} +proc XRefreshKeyboardMapping*(para1: PXMappingEvent): cint{.cdecl, + dynlib: libX11, importc.} +proc XRemoveFromSaveSet*(para1: PDisplay, para2: TWindow): cint{.cdecl, + dynlib: libX11, importc.} +proc XRemoveHost*(para1: PDisplay, para2: PXHostAddress): cint{.cdecl, + dynlib: libX11, importc.} +proc XRemoveHosts*(para1: PDisplay, para2: PXHostAddress, para3: cint): cint{. + cdecl, dynlib: libX11, importc.} +proc XReparentWindow*(para1: PDisplay, para2: TWindow, para3: TWindow, + para4: cint, para5: cint): cint{.cdecl, dynlib: libX11, + importc.} +proc XResetScreenSaver*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.} +proc XResizeWindow*(para1: PDisplay, para2: TWindow, para3: cuint, para4: cuint): cint{. + cdecl, dynlib: libX11, importc.} +proc XRestackWindows*(para1: PDisplay, para2: PWindow, para3: cint): cint{. + cdecl, dynlib: libX11, importc.} +proc XRotateBuffers*(para1: PDisplay, para2: cint): cint{.cdecl, dynlib: libX11, + importc.} +proc XRotateWindowProperties*(para1: PDisplay, para2: TWindow, para3: PAtom, + para4: cint, para5: cint): cint{.cdecl, + dynlib: libX11, importc.} +proc XScreenCount*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.} +proc XSelectInput*(para1: PDisplay, para2: TWindow, para3: clong): cint{.cdecl, + dynlib: libX11, importc.} +proc XSendEvent*(para1: PDisplay, para2: TWindow, para3: TBool, para4: clong, + para5: PXEvent): TStatus{.cdecl, dynlib: libX11, importc.} +proc XSetAccessControl*(para1: PDisplay, para2: cint): cint{.cdecl, + dynlib: libX11, importc.} +proc XSetArcMode*(para1: PDisplay, para2: TGC, para3: cint): cint{.cdecl, + dynlib: libX11, importc.} +proc XSetBackground*(para1: PDisplay, para2: TGC, para3: culong): cint{.cdecl, + dynlib: libX11, importc.} +proc XSetClipMask*(para1: PDisplay, para2: TGC, para3: TPixmap): cint{.cdecl, + dynlib: libX11, importc.} +proc XSetClipOrigin*(para1: PDisplay, para2: TGC, para3: cint, para4: cint): cint{. + cdecl, dynlib: libX11, importc.} +proc XSetClipRectangles*(para1: PDisplay, para2: TGC, para3: cint, para4: cint, + para5: PXRectangle, para6: cint, para7: cint): cint{. + cdecl, dynlib: libX11, importc.} +proc XSetCloseDownMode*(para1: PDisplay, para2: cint): cint{.cdecl, + dynlib: libX11, importc.} +proc XSetCommand*(para1: PDisplay, para2: TWindow, para3: PPchar, para4: cint): cint{. + cdecl, dynlib: libX11, importc.} +proc XSetDashes*(para1: PDisplay, para2: TGC, para3: cint, para4: cstring, + para5: cint): cint{.cdecl, dynlib: libX11, importc.} +proc XSetFillRule*(para1: PDisplay, para2: TGC, para3: cint): cint{.cdecl, + dynlib: libX11, importc.} +proc XSetFillStyle*(para1: PDisplay, para2: TGC, para3: cint): cint{.cdecl, + dynlib: libX11, importc.} +proc XSetFont*(para1: PDisplay, para2: TGC, para3: TFont): cint{.cdecl, + dynlib: libX11, importc.} +proc XSetFontPath*(para1: PDisplay, para2: PPchar, para3: cint): cint{.cdecl, + dynlib: libX11, importc.} +proc XSetForeground*(para1: PDisplay, para2: TGC, para3: culong): cint{.cdecl, + dynlib: libX11, importc.} +proc XSetFunction*(para1: PDisplay, para2: TGC, para3: cint): cint{.cdecl, + dynlib: libX11, importc.} +proc XSetGraphicsExposures*(para1: PDisplay, para2: TGC, para3: TBool): cint{. + cdecl, dynlib: libX11, importc.} +proc XSetIconName*(para1: PDisplay, para2: TWindow, para3: cstring): cint{. + cdecl, dynlib: libX11, importc.} +proc XSetInputFocus*(para1: PDisplay, para2: TWindow, para3: cint, para4: TTime): cint{. + cdecl, dynlib: libX11, importc.} +proc XSetLineAttributes*(para1: PDisplay, para2: TGC, para3: cuint, para4: cint, + para5: cint, para6: cint): cint{.cdecl, dynlib: libX11, + importc.} +proc XSetModifierMapping*(para1: PDisplay, para2: PXModifierKeymap): cint{. + cdecl, dynlib: libX11, importc.} +proc XSetPlaneMask*(para1: PDisplay, para2: TGC, para3: culong): cint{.cdecl, + dynlib: libX11, importc.} +proc XSetPointerMapping*(para1: PDisplay, para2: Pcuchar, para3: cint): cint{. + cdecl, dynlib: libX11, importc.} +proc XSetScreenSaver*(para1: PDisplay, para2: cint, para3: cint, para4: cint, + para5: cint): cint{.cdecl, dynlib: libX11, importc.} +proc XSetSelectionOwner*(para1: PDisplay, para2: TAtom, para3: TWindow, + para4: TTime): cint{.cdecl, dynlib: libX11, importc.} +proc XSetState*(para1: PDisplay, para2: TGC, para3: culong, para4: culong, + para5: cint, para6: culong): cint{.cdecl, dynlib: libX11, + importc.} +proc XSetStipple*(para1: PDisplay, para2: TGC, para3: TPixmap): cint{.cdecl, + dynlib: libX11, importc.} +proc XSetSubwindowMode*(para1: PDisplay, para2: TGC, para3: cint): cint{.cdecl, + dynlib: libX11, importc.} +proc XSetTSOrigin*(para1: PDisplay, para2: TGC, para3: cint, para4: cint): cint{. + cdecl, dynlib: libX11, importc.} +proc XSetTile*(para1: PDisplay, para2: TGC, para3: TPixmap): cint{.cdecl, + dynlib: libX11, importc.} +proc XSetWindowBackground*(para1: PDisplay, para2: TWindow, para3: culong): cint{. + cdecl, dynlib: libX11, importc.} +proc XSetWindowBackgroundPixmap*(para1: PDisplay, para2: TWindow, para3: TPixmap): cint{. + cdecl, dynlib: libX11, importc.} +proc XSetWindowBorder*(para1: PDisplay, para2: TWindow, para3: culong): cint{. + cdecl, dynlib: libX11, importc.} +proc XSetWindowBorderPixmap*(para1: PDisplay, para2: TWindow, para3: TPixmap): cint{. + cdecl, dynlib: libX11, importc.} +proc XSetWindowBorderWidth*(para1: PDisplay, para2: TWindow, para3: cuint): cint{. + cdecl, dynlib: libX11, importc.} +proc XSetWindowColormap*(para1: PDisplay, para2: TWindow, para3: TColormap): cint{. + cdecl, dynlib: libX11, importc.} +proc XStoreBuffer*(para1: PDisplay, para2: cstring, para3: cint, para4: cint): cint{. + cdecl, dynlib: libX11, importc.} +proc XStoreBytes*(para1: PDisplay, para2: cstring, para3: cint): cint{.cdecl, + dynlib: libX11, importc.} +proc XStoreColor*(para1: PDisplay, para2: TColormap, para3: PXColor): cint{. + cdecl, dynlib: libX11, importc.} +proc XStoreColors*(para1: PDisplay, para2: TColormap, para3: PXColor, + para4: cint): cint{.cdecl, dynlib: libX11, importc.} +proc XStoreName*(para1: PDisplay, para2: TWindow, para3: cstring): cint{.cdecl, + dynlib: libX11, importc.} +proc XStoreNamedColor*(para1: PDisplay, para2: TColormap, para3: cstring, + para4: culong, para5: cint): cint{.cdecl, dynlib: libX11, + importc.} +proc XSync*(para1: PDisplay, para2: TBool): cint{.cdecl, dynlib: libX11, importc.} +proc XTextExtents*(para1: PXFontStruct, para2: cstring, para3: cint, + para4: Pcint, para5: Pcint, para6: Pcint, para7: PXCharStruct): cint{. + cdecl, dynlib: libX11, importc.} +proc XTextExtents16*(para1: PXFontStruct, para2: PXChar2b, para3: cint, + para4: Pcint, para5: Pcint, para6: Pcint, + para7: PXCharStruct): cint{.cdecl, dynlib: libX11, importc.} +proc XTextWidth*(para1: PXFontStruct, para2: cstring, para3: cint): cint{.cdecl, + dynlib: libX11, importc.} +proc XTextWidth16*(para1: PXFontStruct, para2: PXChar2b, para3: cint): cint{. + cdecl, dynlib: libX11, importc.} +proc XTranslateCoordinates*(para1: PDisplay, para2: TWindow, para3: TWindow, + para4: cint, para5: cint, para6: Pcint, + para7: Pcint, para8: PWindow): TBool{.cdecl, + dynlib: libX11, importc.} +proc XUndefineCursor*(para1: PDisplay, para2: TWindow): cint{.cdecl, + dynlib: libX11, importc.} +proc XUngrabButton*(para1: PDisplay, para2: cuint, para3: cuint, para4: TWindow): cint{. + cdecl, dynlib: libX11, importc.} +proc XUngrabKey*(para1: PDisplay, para2: cint, para3: cuint, para4: TWindow): cint{. + cdecl, dynlib: libX11, importc.} +proc XUngrabKeyboard*(para1: PDisplay, para2: TTime): cint{.cdecl, + dynlib: libX11, importc.} +proc XUngrabPointer*(para1: PDisplay, para2: TTime): cint{.cdecl, + dynlib: libX11, importc.} +proc XUngrabServer*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.} +proc XUninstallColormap*(para1: PDisplay, para2: TColormap): cint{.cdecl, + dynlib: libX11, importc.} +proc XUnloadFont*(para1: PDisplay, para2: TFont): cint{.cdecl, dynlib: libX11, + importc.} +proc XUnmapSubwindows*(para1: PDisplay, para2: TWindow): cint{.cdecl, + dynlib: libX11, importc.} +proc XUnmapWindow*(para1: PDisplay, para2: TWindow): cint{.cdecl, + dynlib: libX11, importc.} +proc XVendorRelease*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.} +proc XWarpPointer*(para1: PDisplay, para2: TWindow, para3: TWindow, para4: cint, + para5: cint, para6: cuint, para7: cuint, para8: cint, + para9: cint): cint{.cdecl, dynlib: libX11, importc.} +proc XWidthMMOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, importc.} +proc XWidthOfScreen*(para1: PScreen): cint{.cdecl, dynlib: libX11, importc.} +proc XWindowEvent*(para1: PDisplay, para2: TWindow, para3: clong, para4: PXEvent): cint{. + cdecl, dynlib: libX11, importc.} +proc XWriteBitmapFile*(para1: PDisplay, para2: cstring, para3: TPixmap, + para4: cuint, para5: cuint, para6: cint, para7: cint): cint{. + cdecl, dynlib: libX11, importc.} +proc XSupportsLocale*(): TBool{.cdecl, dynlib: libX11, importc.} +proc XSetLocaleModifiers*(para1: cstring): cstring{.cdecl, dynlib: libX11, + importc.} +proc XOpenOM*(para1: PDisplay, para2: PXrmHashBucketRec, para3: cstring, + para4: cstring): TXOM{.cdecl, dynlib: libX11, importc.} +proc XCloseOM*(para1: TXOM): TStatus{.cdecl, dynlib: libX11, importc.} +proc XSetOMValues*(para1: TXOM): cstring{.varargs, cdecl, dynlib: libX11, + importc.} +proc XGetOMValues*(para1: TXOM): cstring{.varargs, cdecl, dynlib: libX11, + importc.} +proc XDisplayOfOM*(para1: TXOM): PDisplay{.cdecl, dynlib: libX11, importc.} +proc XLocaleOfOM*(para1: TXOM): cstring{.cdecl, dynlib: libX11, importc.} +proc XCreateOC*(para1: TXOM): TXOC{.varargs, cdecl, dynlib: libX11, importc.} +proc XDestroyOC*(para1: TXOC){.cdecl, dynlib: libX11, importc.} +proc XOMOfOC*(para1: TXOC): TXOM{.cdecl, dynlib: libX11, importc.} +proc XSetOCValues*(para1: TXOC): cstring{.varargs, cdecl, dynlib: libX11, + importc.} +proc XGetOCValues*(para1: TXOC): cstring{.varargs, cdecl, dynlib: libX11, + importc.} +proc XCreateFontSet*(para1: PDisplay, para2: cstring, para3: PPPchar, + para4: Pcint, para5: PPchar): TXFontSet{.cdecl, + dynlib: libX11, importc.} +proc XFreeFontSet*(para1: PDisplay, para2: TXFontSet){.cdecl, dynlib: libX11, + importc.} +proc XFontsOfFontSet*(para1: TXFontSet, para2: PPPXFontStruct, para3: PPPchar): cint{. + cdecl, dynlib: libX11, importc.} +proc XBaseFontNameListOfFontSet*(para1: TXFontSet): cstring{.cdecl, + dynlib: libX11, importc.} +proc XLocaleOfFontSet*(para1: TXFontSet): cstring{.cdecl, dynlib: libX11, + importc.} +proc XContextDependentDrawing*(para1: TXFontSet): TBool{.cdecl, dynlib: libX11, + importc.} +proc XDirectionalDependentDrawing*(para1: TXFontSet): TBool{.cdecl, + dynlib: libX11, importc.} +proc XContextualDrawing*(para1: TXFontSet): TBool{.cdecl, dynlib: libX11, + importc.} +proc XExtentsOfFontSet*(para1: TXFontSet): PXFontSetExtents{.cdecl, + dynlib: libX11, importc.} +proc XmbTextEscapement*(para1: TXFontSet, para2: cstring, para3: cint): cint{. + cdecl, dynlib: libX11, importc.} +proc XwcTextEscapement*(para1: TXFontSet, para2: PWideChar, para3: cint): cint{. + cdecl, dynlib: libX11, importc.} +proc Xutf8TextEscapement*(para1: TXFontSet, para2: cstring, para3: cint): cint{. + cdecl, dynlib: libX11, importc.} +proc XmbTextExtents*(para1: TXFontSet, para2: cstring, para3: cint, + para4: PXRectangle, para5: PXRectangle): cint{.cdecl, + dynlib: libX11, importc.} +proc XwcTextExtents*(para1: TXFontSet, para2: PWideChar, para3: cint, + para4: PXRectangle, para5: PXRectangle): cint{.cdecl, + dynlib: libX11, importc.} +proc Xutf8TextExtents*(para1: TXFontSet, para2: cstring, para3: cint, + para4: PXRectangle, para5: PXRectangle): cint{.cdecl, + dynlib: libX11, importc.} +proc XmbTextPerCharExtents*(para1: TXFontSet, para2: cstring, para3: cint, + para4: PXRectangle, para5: PXRectangle, para6: cint, + para7: Pcint, para8: PXRectangle, para9: PXRectangle): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XwcTextPerCharExtents*(para1: TXFontSet, para2: PWideChar, para3: cint, + para4: PXRectangle, para5: PXRectangle, para6: cint, + para7: Pcint, para8: PXRectangle, para9: PXRectangle): TStatus{. + cdecl, dynlib: libX11, importc.} +proc Xutf8TextPerCharExtents*(para1: TXFontSet, para2: cstring, para3: cint, + para4: PXRectangle, para5: PXRectangle, + para6: cint, para7: Pcint, para8: PXRectangle, + para9: PXRectangle): TStatus{.cdecl, + dynlib: libX11, importc.} +proc XmbDrawText*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, + para5: cint, para6: PXmbTextItem, para7: cint){.cdecl, + dynlib: libX11, importc.} +proc XwcDrawText*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, + para5: cint, para6: PXwcTextItem, para7: cint){.cdecl, + dynlib: libX11, importc.} +proc Xutf8DrawText*(para1: PDisplay, para2: TDrawable, para3: TGC, para4: cint, + para5: cint, para6: PXmbTextItem, para7: cint){.cdecl, + dynlib: libX11, importc.} +proc XmbDrawString*(para1: PDisplay, para2: TDrawable, para3: TXFontSet, + para4: TGC, para5: cint, para6: cint, para7: cstring, + para8: cint){.cdecl, dynlib: libX11, importc.} +proc XwcDrawString*(para1: PDisplay, para2: TDrawable, para3: TXFontSet, + para4: TGC, para5: cint, para6: cint, para7: PWideChar, + para8: cint){.cdecl, dynlib: libX11, importc.} +proc Xutf8DrawString*(para1: PDisplay, para2: TDrawable, para3: TXFontSet, + para4: TGC, para5: cint, para6: cint, para7: cstring, + para8: cint){.cdecl, dynlib: libX11, importc.} +proc XmbDrawImageString*(para1: PDisplay, para2: TDrawable, para3: TXFontSet, + para4: TGC, para5: cint, para6: cint, para7: cstring, + para8: cint){.cdecl, dynlib: libX11, importc.} +proc XwcDrawImageString*(para1: PDisplay, para2: TDrawable, para3: TXFontSet, + para4: TGC, para5: cint, para6: cint, para7: PWideChar, + para8: cint){.cdecl, dynlib: libX11, importc.} +proc Xutf8DrawImageString*(para1: PDisplay, para2: TDrawable, para3: TXFontSet, + para4: TGC, para5: cint, para6: cint, para7: cstring, + para8: cint){.cdecl, dynlib: libX11, importc.} +proc XOpenIM*(para1: PDisplay, para2: PXrmHashBucketRec, para3: cstring, + para4: cstring): TXIM{.cdecl, dynlib: libX11, importc.} +proc XCloseIM*(para1: TXIM): TStatus{.cdecl, dynlib: libX11, importc.} +proc XGetIMValues*(para1: TXIM): cstring{.varargs, cdecl, dynlib: libX11, + importc.} +proc XSetIMValues*(para1: TXIM): cstring{.varargs, cdecl, dynlib: libX11, + importc.} +proc XDisplayOfIM*(para1: TXIM): PDisplay{.cdecl, dynlib: libX11, importc.} +proc XLocaleOfIM*(para1: TXIM): cstring{.cdecl, dynlib: libX11, importc.} +proc XCreateIC*(para1: TXIM): TXIC{.varargs, cdecl, dynlib: libX11, importc.} +proc XDestroyIC*(para1: TXIC){.cdecl, dynlib: libX11, importc.} +proc XSetICFocus*(para1: TXIC){.cdecl, dynlib: libX11, importc.} +proc XUnsetICFocus*(para1: TXIC){.cdecl, dynlib: libX11, importc.} +proc XwcResetIC*(para1: TXIC): PWideChar{.cdecl, dynlib: libX11, importc.} +proc XmbResetIC*(para1: TXIC): cstring{.cdecl, dynlib: libX11, importc.} +proc Xutf8ResetIC*(para1: TXIC): cstring{.cdecl, dynlib: libX11, importc.} +proc XSetICValues*(para1: TXIC): cstring{.varargs, cdecl, dynlib: libX11, + importc.} +proc XGetICValues*(para1: TXIC): cstring{.varargs, cdecl, dynlib: libX11, + importc.} +proc XIMOfIC*(para1: TXIC): TXIM{.cdecl, dynlib: libX11, importc.} +proc XFilterEvent*(para1: PXEvent, para2: TWindow): TBool{.cdecl, + dynlib: libX11, importc.} +proc XmbLookupString*(para1: TXIC, para2: PXKeyPressedEvent, para3: cstring, + para4: cint, para5: PKeySym, para6: PStatus): cint{.cdecl, + dynlib: libX11, importc.} +proc XwcLookupString*(para1: TXIC, para2: PXKeyPressedEvent, para3: PWideChar, + para4: cint, para5: PKeySym, para6: PStatus): cint{.cdecl, + dynlib: libX11, importc.} +proc Xutf8LookupString*(para1: TXIC, para2: PXKeyPressedEvent, para3: cstring, + para4: cint, para5: PKeySym, para6: PStatus): cint{. + cdecl, dynlib: libX11, importc.} +proc XVaCreateNestedList*(unused: cint): TXVaNestedList{.varargs, cdecl, + dynlib: libX11, importc.} +proc XRegisterIMInstantiateCallback*(para1: PDisplay, para2: PXrmHashBucketRec, + para3: cstring, para4: cstring, + para5: TXIDProc, para6: TXPointer): TBool{. + cdecl, dynlib: libX11, importc.} +proc XUnregisterIMInstantiateCallback*(para1: PDisplay, + para2: PXrmHashBucketRec, para3: cstring, + para4: cstring, para5: TXIDProc, + para6: TXPointer): TBool{.cdecl, + dynlib: libX11, importc.} +type + TXConnectionWatchProc* = proc (para1: PDisplay, para2: TXPointer, para3: cint, + para4: TBool, para5: PXPointer){.cdecl.} + +proc XInternalConnectionNumbers*(para1: PDisplay, para2: PPcint, para3: Pcint): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XProcessInternalConnection*(para1: PDisplay, para2: cint){.cdecl, + dynlib: libX11, importc.} +proc XAddConnectionWatch*(para1: PDisplay, para2: TXConnectionWatchProc, + para3: TXPointer): TStatus{.cdecl, dynlib: libX11, + importc.} +proc XRemoveConnectionWatch*(para1: PDisplay, para2: TXConnectionWatchProc, + para3: TXPointer){.cdecl, dynlib: libX11, importc.} +proc XSetAuthorization*(para1: cstring, para2: cint, para3: cstring, para4: cint){. + cdecl, dynlib: libX11, importc.} + # + # _Xmbtowc? + # _Xwctomb? + # +when defined(MACROS): + proc ConnectionNumber*(dpy: PDisplay): cint + proc RootWindow*(dpy: PDisplay, scr: cint): TWindow + proc DefaultScreen*(dpy: PDisplay): cint + proc DefaultRootWindow*(dpy: PDisplay): TWindow + proc DefaultVisual*(dpy: PDisplay, scr: cint): PVisual + proc DefaultGC*(dpy: PDisplay, scr: cint): TGC + proc BlackPixel*(dpy: PDisplay, scr: cint): culong + proc WhitePixel*(dpy: PDisplay, scr: cint): culong + proc QLength*(dpy: PDisplay): cint + proc DisplayWidth*(dpy: PDisplay, scr: cint): cint + proc DisplayHeight*(dpy: PDisplay, scr: cint): cint + proc DisplayWidthMM*(dpy: PDisplay, scr: cint): cint + proc DisplayHeightMM*(dpy: PDisplay, scr: cint): cint + proc DisplayPlanes*(dpy: PDisplay, scr: cint): cint + proc DisplayCells*(dpy: PDisplay, scr: cint): cint + proc ScreenCount*(dpy: PDisplay): cint + proc ServerVendor*(dpy: PDisplay): cstring + proc ProtocolVersion*(dpy: PDisplay): cint + proc ProtocolRevision*(dpy: PDisplay): cint + proc VendorRelease*(dpy: PDisplay): cint + proc DisplayString*(dpy: PDisplay): cstring + proc DefaultDepth*(dpy: PDisplay, scr: cint): cint + proc DefaultColormap*(dpy: PDisplay, scr: cint): TColormap + proc BitmapUnit*(dpy: PDisplay): cint + proc BitmapBitOrder*(dpy: PDisplay): cint + proc BitmapPad*(dpy: PDisplay): cint + proc ImageByteOrder*(dpy: PDisplay): cint + proc NextRequest*(dpy: PDisplay): culong + proc LastKnownRequestProcessed*(dpy: PDisplay): culong + proc ScreenOfDisplay*(dpy: PDisplay, scr: cint): PScreen + proc DefaultScreenOfDisplay*(dpy: PDisplay): PScreen + proc DisplayOfScreen*(s: PScreen): PDisplay + proc RootWindowOfScreen*(s: PScreen): TWindow + proc BlackPixelOfScreen*(s: PScreen): culong + proc WhitePixelOfScreen*(s: PScreen): culong + proc DefaultColormapOfScreen*(s: PScreen): TColormap + proc DefaultDepthOfScreen*(s: PScreen): cint + proc DefaultGCOfScreen*(s: PScreen): TGC + proc DefaultVisualOfScreen*(s: PScreen): PVisual + proc WidthOfScreen*(s: PScreen): cint + proc HeightOfScreen*(s: PScreen): cint + proc WidthMMOfScreen*(s: PScreen): cint + proc HeightMMOfScreen*(s: PScreen): cint + proc PlanesOfScreen*(s: PScreen): cint + proc CellsOfScreen*(s: PScreen): cint + proc MinCmapsOfScreen*(s: PScreen): cint + proc MaxCmapsOfScreen*(s: PScreen): cint + proc DoesSaveUnders*(s: PScreen): TBool + proc DoesBackingStore*(s: PScreen): cint + proc EventMaskOfScreen*(s: PScreen): clong + proc XAllocID*(dpy: PDisplay): TXID +# implementation + +when defined(MACROS): + proc ConnectionNumber(dpy: PDisplay): cint = + ConnectionNumber = (PXPrivDisplay(dpy))^ .fd + + proc RootWindow(dpy: PDisplay, scr: cint): TWindow = + RootWindow = (ScreenOfDisplay(dpy, scr))^ .root + + proc DefaultScreen(dpy: PDisplay): cint = + DefaultScreen = (PXPrivDisplay(dpy))^ .default_screen + + proc DefaultRootWindow(dpy: PDisplay): TWindow = + DefaultRootWindow = (ScreenOfDisplay(dpy, DefaultScreen(dpy)))^ .root + + proc DefaultVisual(dpy: PDisplay, scr: cint): PVisual = + DefaultVisual = (ScreenOfDisplay(dpy, scr))^ .root_visual + + proc DefaultGC(dpy: PDisplay, scr: cint): TGC = + DefaultGC = (ScreenOfDisplay(dpy, scr))^ .default_gc + + proc BlackPixel(dpy: PDisplay, scr: cint): culong = + BlackPixel = (ScreenOfDisplay(dpy, scr))^ .black_pixel + + proc WhitePixel(dpy: PDisplay, scr: cint): culong = + WhitePixel = (ScreenOfDisplay(dpy, scr))^ .white_pixel + + proc QLength(dpy: PDisplay): cint = + QLength = (PXPrivDisplay(dpy))^ .qlen + + proc DisplayWidth(dpy: PDisplay, scr: cint): cint = + DisplayWidth = (ScreenOfDisplay(dpy, scr))^ .width + + proc DisplayHeight(dpy: PDisplay, scr: cint): cint = + DisplayHeight = (ScreenOfDisplay(dpy, scr))^ .height + + proc DisplayWidthMM(dpy: PDisplay, scr: cint): cint = + DisplayWidthMM = (ScreenOfDisplay(dpy, scr))^ .mwidth + + proc DisplayHeightMM(dpy: PDisplay, scr: cint): cint = + DisplayHeightMM = (ScreenOfDisplay(dpy, scr))^ .mheight + + proc DisplayPlanes(dpy: PDisplay, scr: cint): cint = + DisplayPlanes = (ScreenOfDisplay(dpy, scr))^ .root_depth + + proc DisplayCells(dpy: PDisplay, scr: cint): cint = + DisplayCells = (DefaultVisual(dpy, scr))^ .map_entries + + proc ScreenCount(dpy: PDisplay): cint = + ScreenCount = (PXPrivDisplay(dpy))^ .nscreens + + proc ServerVendor(dpy: PDisplay): cstring = + ServerVendor = (PXPrivDisplay(dpy))^ .vendor + + proc ProtocolVersion(dpy: PDisplay): cint = + ProtocolVersion = (PXPrivDisplay(dpy))^ .proto_major_version + + proc ProtocolRevision(dpy: PDisplay): cint = + ProtocolRevision = (PXPrivDisplay(dpy))^ .proto_minor_version + + proc VendorRelease(dpy: PDisplay): cint = + VendorRelease = (PXPrivDisplay(dpy))^ .release + + proc DisplayString(dpy: PDisplay): cstring = + DisplayString = (PXPrivDisplay(dpy))^ .display_name + + proc DefaultDepth(dpy: PDisplay, scr: cint): cint = + DefaultDepth = (ScreenOfDisplay(dpy, scr))^ .root_depth + + proc DefaultColormap(dpy: PDisplay, scr: cint): TColormap = + DefaultColormap = (ScreenOfDisplay(dpy, scr))^ .cmap + + proc BitmapUnit(dpy: PDisplay): cint = + BitmapUnit = (PXPrivDisplay(dpy))^ .bitmap_unit + + proc BitmapBitOrder(dpy: PDisplay): cint = + BitmapBitOrder = (PXPrivDisplay(dpy))^ .bitmap_bit_order + + proc BitmapPad(dpy: PDisplay): cint = + BitmapPad = (PXPrivDisplay(dpy))^ .bitmap_pad + + proc ImageByteOrder(dpy: PDisplay): cint = + ImageByteOrder = (PXPrivDisplay(dpy))^ .byte_order + + proc NextRequest(dpy: PDisplay): culong = + NextRequest = ((PXPrivDisplay(dpy))^ .request) + 1 + + proc LastKnownRequestProcessed(dpy: PDisplay): culong = + LastKnownRequestProcessed = (PXPrivDisplay(dpy))^ .last_request_read + + proc ScreenOfDisplay(dpy: PDisplay, scr: cint): PScreen = + ScreenOfDisplay = addr((((PXPrivDisplay(dpy))^ .screens)[scr])) + + proc DefaultScreenOfDisplay(dpy: PDisplay): PScreen = + DefaultScreenOfDisplay = ScreenOfDisplay(dpy, DefaultScreen(dpy)) + + proc DisplayOfScreen(s: PScreen): PDisplay = + DisplayOfScreen = s^ .display + + proc RootWindowOfScreen(s: PScreen): TWindow = + RootWindowOfScreen = s^ .root + + proc BlackPixelOfScreen(s: PScreen): culong = + BlackPixelOfScreen = s^ .black_pixel + + proc WhitePixelOfScreen(s: PScreen): culong = + WhitePixelOfScreen = s^ .white_pixel + + proc DefaultColormapOfScreen(s: PScreen): TColormap = + DefaultColormapOfScreen = s^ .cmap + + proc DefaultDepthOfScreen(s: PScreen): cint = + DefaultDepthOfScreen = s^ .root_depth + + proc DefaultGCOfScreen(s: PScreen): TGC = + DefaultGCOfScreen = s^ .default_gc + + proc DefaultVisualOfScreen(s: PScreen): PVisual = + DefaultVisualOfScreen = s^ .root_visual + + proc WidthOfScreen(s: PScreen): cint = + WidthOfScreen = s^ .width + + proc HeightOfScreen(s: PScreen): cint = + HeightOfScreen = s^ .height + + proc WidthMMOfScreen(s: PScreen): cint = + WidthMMOfScreen = s^ .mwidth + + proc HeightMMOfScreen(s: PScreen): cint = + HeightMMOfScreen = s^ .mheight + + proc PlanesOfScreen(s: PScreen): cint = + PlanesOfScreen = s^ .root_depth + + proc CellsOfScreen(s: PScreen): cint = + CellsOfScreen = (DefaultVisualOfScreen(s))^ .map_entries + + proc MinCmapsOfScreen(s: PScreen): cint = + MinCmapsOfScreen = s^ .min_maps + + proc MaxCmapsOfScreen(s: PScreen): cint = + MaxCmapsOfScreen = s^ .max_maps + + proc DoesSaveUnders(s: PScreen): TBool = + DoesSaveUnders = s^ .save_unders + + proc DoesBackingStore(s: PScreen): cint = + DoesBackingStore = s^ .backing_store + + proc EventMaskOfScreen(s: PScreen): clong = + EventMaskOfScreen = s^ .root_input_mask + + proc XAllocID(dpy: PDisplay): TXID = + XAllocID = (PXPrivDisplay(dpy))^ .resource_alloc(dpy) diff --git a/lib/base/x11/xrandr.nim b/lib/base/x11/xrandr.nim new file mode 100644 index 000000000..ebc656260 --- /dev/null +++ b/lib/base/x11/xrandr.nim @@ -0,0 +1,194 @@ +# +# $XFree86: xc/lib/Xrandr/Xrandr.h,v 1.9 2002/09/29 23:39:44 keithp Exp $ +# +# Copyright (C) 2000 Compaq Computer Corporation, Inc. +# Copyright (C) 2002 Hewlett-Packard Company, Inc. +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of Compaq not be used in advertising or +# publicity pertaining to distribution of the software without specific, +# written prior permission. HP makes no representations about the +# suitability of this software for any purpose. It is provided "as is" +# without express or implied warranty. +# +# HP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL COMPAQ +# BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# +# Author: Jim Gettys, HP Labs, HP. +# + +import + x, xlib + +const + libXrandr* = "libXrandr.so" + +# * $XFree86: xc/include/extensions/randr.h,v 1.4 2001/11/24 07:24:58 keithp Exp $ +# * +# * Copyright (C) 2000, Compaq Computer Corporation, +# * Copyright (C) 2002, Hewlett Packard, Inc. +# * +# * Permission to use, copy, modify, distribute, and sell this software and its +# * documentation for any purpose is hereby granted without fee, provided that +# * the above copyright notice appear in all copies and that both that +# * copyright notice and this permission notice appear in supporting +# * documentation, and that the name of Compaq or HP not be used in advertising +# * or publicity pertaining to distribution of the software without specific, +# * written prior permission. HP makes no representations about the +# * suitability of this software for any purpose. It is provided "as is" +# * without express or implied warranty. +# * +# * HP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL +# * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL HP +# * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +# * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +# * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# * +# * Author: Jim Gettys, HP Labs, Hewlett-Packard, Inc. +# * + +type + PRotation* = ptr TRotation + TRotation* = cushort + PSizeID* = ptr TSizeID + TSizeID* = cushort + PSubpixelOrder* = ptr TSubpixelOrder + TSubpixelOrder* = cushort + +const + RANDR_NAME* = "RANDR" + RANDR_MAJOR* = 1 + RANDR_MINOR* = 1 + RRNumberErrors* = 0 + RRNumberEvents* = 1 + constX_RRQueryVersion* = 0 # we skip 1 to make old clients fail pretty immediately + X_RROldGetScreenInfo* = 1 + X_RR1_0SetScreenConfig* = 2 # V1.0 apps share the same set screen config request id + constX_RRSetScreenConfig* = 2 + X_RROldScreenChangeSelectInput* = 3 # 3 used to be ScreenChangeSelectInput; deprecated + constX_RRSelectInput* = 4 + constX_RRGetScreenInfo* = 5 # used in XRRSelectInput + RRScreenChangeNotifyMask* = 1 shl 0 + RRScreenChangeNotify* = 0 # used in the rotation field; rotation and reflection in 0.1 proto. + RR_Rotate_0* = 1 + RR_Rotate_90* = 2 + RR_Rotate_180* = 4 + RR_Rotate_270* = 8 # new in 1.0 protocol, to allow reflection of screen + RR_Reflect_X* = 16 + RR_Reflect_Y* = 32 + RRSetConfigSuccess* = 0 + RRSetConfigInvalidConfigTime* = 1 + RRSetConfigInvalidTime* = 2 + RRSetConfigFailed* = 3 + +type + PXRRScreenSize* = ptr TXRRScreenSize + TXRRScreenSize*{.final.} = object # + # Events. + # + width*, height*: cint + mwidth*, mheight*: cint + + TXRRScreenChangeNotifyEvent*{.final.} = object # internal representation is private to the library + type_*: cint # event base + serial*: culong # # of last request processed by server + send_event*: TBool # true if this came from a SendEvent request + display*: PDisplay # Display the event was read from + window*: TWindow # window which selected for this event + root*: TWindow # Root window for changed screen + timestamp*: TTime # when the screen change occurred + config_timestamp*: TTime # when the last configuration change + size_index*: TSizeID + subpixel_order*: TSubpixelOrder + rotation*: TRotation + width*: cint + height*: cint + mwidth*: cint + mheight*: cint + + PXRRScreenConfiguration* = ptr TXRRScreenConfiguration + TXRRScreenConfiguration*{.final.} = object + +proc XRRQueryExtension*(dpy: PDisplay, event_basep, error_basep: Pcint): TBool{. + cdecl, dynlib: libXrandr, importc.} +proc XRRQueryVersion*(dpy: PDisplay, major_versionp: Pcint, + minor_versionp: Pcint): TStatus{.cdecl, dynlib: libXrandr, + importc.} +proc XRRGetScreenInfo*(dpy: PDisplay, draw: TDrawable): PXRRScreenConfiguration{. + cdecl, dynlib: libXrandr, importc.} +proc XRRFreeScreenConfigInfo*(config: PXRRScreenConfiguration){.cdecl, + dynlib: libXrandr, importc.} + # + # Note that screen configuration changes are only permitted if the client can + # prove it has up to date configuration information. We are trying to + # insist that it become possible for screens to change dynamically, so + # we want to ensure the client knows what it is talking about when requesting + # changes. + # +proc XRRSetScreenConfig*(dpy: PDisplay, config: PXRRScreenConfiguration, + draw: TDrawable, size_index: cint, rotation: TRotation, + timestamp: TTime): TStatus{.cdecl, dynlib: libXrandr, + importc.} + # added in v1.1, sorry for the lame name +proc XRRSetScreenConfigAndRate*(dpy: PDisplay, config: PXRRScreenConfiguration, + draw: TDrawable, size_index: cint, + rotation: TRotation, rate: cshort, + timestamp: TTime): TStatus{.cdecl, + dynlib: libXrandr, importc.} +proc XRRConfigRotations*(config: PXRRScreenConfiguration, + current_rotation: PRotation): TRotation{.cdecl, + dynlib: libXrandr, importc.} +proc XRRConfigTimes*(config: PXRRScreenConfiguration, config_timestamp: PTime): TTime{. + cdecl, dynlib: libXrandr, importc.} +proc XRRConfigSizes*(config: PXRRScreenConfiguration, nsizes: Pcint): PXRRScreenSize{. + cdecl, dynlib: libXrandr, importc.} +proc XRRConfigRates*(config: PXRRScreenConfiguration, sizeID: cint, + nrates: Pcint): ptr int16{.cdecl, dynlib: libXrandr, importc.} +proc XRRConfigCurrentConfiguration*(config: PXRRScreenConfiguration, + rotation: PRotation): TSizeID{.cdecl, + dynlib: libXrandr, importc.} +proc XRRConfigCurrentRate*(config: PXRRScreenConfiguration): cshort{.cdecl, + dynlib: libXrandr, importc.} +proc XRRRootToScreen*(dpy: PDisplay, root: TWindow): cint{.cdecl, + dynlib: libXrandr, importc.} + # + # returns the screen configuration for the specified screen; does a lazy + # evalution to delay getting the information, and caches the result. + # These routines should be used in preference to XRRGetScreenInfo + # to avoid unneeded round trips to the X server. These are new + # in protocol version 0.1. + # +proc XRRScreenConfig*(dpy: PDisplay, screen: cint): PXRRScreenConfiguration{. + cdecl, dynlib: libXrandr, importc.} +proc XRRConfig*(screen: PScreen): PXRRScreenConfiguration{.cdecl, + dynlib: libXrandr, importc.} +proc XRRSelectInput*(dpy: PDisplay, window: TWindow, mask: cint){.cdecl, + dynlib: libXrandr, importc.} + # + # the following are always safe to call, even if RandR is not implemented + # on a screen + # +proc XRRRotations*(dpy: PDisplay, screen: cint, current_rotation: PRotation): TRotation{. + cdecl, dynlib: libXrandr, importc.} +proc XRRSizes*(dpy: PDisplay, screen: cint, nsizes: Pcint): PXRRScreenSize{. + cdecl, dynlib: libXrandr, importc.} +proc XRRRates*(dpy: PDisplay, screen: cint, sizeID: cint, nrates: Pcint): ptr int16{. + cdecl, dynlib: libXrandr, importc.} +proc XRRTimes*(dpy: PDisplay, screen: cint, config_timestamp: PTime): TTime{. + cdecl, dynlib: libXrandr, importc.} + # + # intended to take RRScreenChangeNotify, or + # ConfigureNotify (on the root window) + # returns 1 if it is an event type it understands, 0 if not + # +proc XRRUpdateConfiguration*(event: PXEvent): cint{.cdecl, dynlib: libXrandr, + importc.} +# implementation diff --git a/lib/base/x11/xrender.nim b/lib/base/x11/xrender.nim new file mode 100644 index 000000000..c4f817607 --- /dev/null +++ b/lib/base/x11/xrender.nim @@ -0,0 +1,231 @@ + +import + x, xlib + +#const +# libX11* = "libX11.so" + +# +# Automatically converted by H2Pas 0.99.15 from xrender.h +# The following command line parameters were used: +# -p +# -T +# -S +# -d +# -c +# xrender.h +# + +type + PGlyph* = ptr TGlyph + TGlyph* = int32 + PGlyphSet* = ptr TGlyphSet + TGlyphSet* = int32 + PPicture* = ptr TPicture + TPicture* = int32 + PPictFormat* = ptr TPictFormat + TPictFormat* = int32 + +const + RENDER_NAME* = "RENDER" + RENDER_MAJOR* = 0 + RENDER_MINOR* = 0 + constX_RenderQueryVersion* = 0 + X_RenderQueryPictFormats* = 1 + X_RenderQueryPictIndexValues* = 2 + X_RenderQueryDithers* = 3 + constX_RenderCreatePicture* = 4 + constX_RenderChangePicture* = 5 + X_RenderSetPictureClipRectangles* = 6 + constX_RenderFreePicture* = 7 + constX_RenderComposite* = 8 + X_RenderScale* = 9 + X_RenderTrapezoids* = 10 + X_RenderTriangles* = 11 + X_RenderTriStrip* = 12 + X_RenderTriFan* = 13 + X_RenderColorTrapezoids* = 14 + X_RenderColorTriangles* = 15 + X_RenderTransform* = 16 + constX_RenderCreateGlyphSet* = 17 + constX_RenderReferenceGlyphSet* = 18 + constX_RenderFreeGlyphSet* = 19 + constX_RenderAddGlyphs* = 20 + constX_RenderAddGlyphsFromPicture* = 21 + constX_RenderFreeGlyphs* = 22 + constX_RenderCompositeGlyphs8* = 23 + constX_RenderCompositeGlyphs16* = 24 + constX_RenderCompositeGlyphs32* = 25 + BadPictFormat* = 0 + BadPicture* = 1 + BadPictOp* = 2 + BadGlyphSet* = 3 + BadGlyph* = 4 + RenderNumberErrors* = BadGlyph + 1 + PictTypeIndexed* = 0 + PictTypeDirect* = 1 + PictOpClear* = 0 + PictOpSrc* = 1 + PictOpDst* = 2 + PictOpOver* = 3 + PictOpOverReverse* = 4 + PictOpIn* = 5 + PictOpInReverse* = 6 + PictOpOut* = 7 + PictOpOutReverse* = 8 + PictOpAtop* = 9 + PictOpAtopReverse* = 10 + PictOpXor* = 11 + PictOpAdd* = 12 + PictOpSaturate* = 13 + PictOpMaximum* = 13 + PolyEdgeSharp* = 0 + PolyEdgeSmooth* = 1 + PolyModePrecise* = 0 + PolyModeImprecise* = 1 + CPRepeat* = 1 shl 0 + CPAlphaMap* = 1 shl 1 + CPAlphaXOrigin* = 1 shl 2 + CPAlphaYOrigin* = 1 shl 3 + CPClipXOrigin* = 1 shl 4 + CPClipYOrigin* = 1 shl 5 + CPClipMask* = 1 shl 6 + CPGraphicsExposure* = 1 shl 7 + CPSubwindowMode* = 1 shl 8 + CPPolyEdge* = 1 shl 9 + CPPolyMode* = 1 shl 10 + CPDither* = 1 shl 11 + CPLastBit* = 11 + +type + PXRenderDirectFormat* = ptr TXRenderDirectFormat + TXRenderDirectFormat*{.final.} = object + red*: int16 + redMask*: int16 + green*: int16 + greenMask*: int16 + blue*: int16 + blueMask*: int16 + alpha*: int16 + alphaMask*: int16 + + PXRenderPictFormat* = ptr TXRenderPictFormat + TXRenderPictFormat*{.final.} = object + id*: TPictFormat + thetype*: int32 + depth*: int32 + direct*: TXRenderDirectFormat + colormap*: TColormap + + +const + PictFormatID* = 1 shl 0 + PictFormatType* = 1 shl 1 + PictFormatDepth* = 1 shl 2 + PictFormatRed* = 1 shl 3 + PictFormatRedMask* = 1 shl 4 + PictFormatGreen* = 1 shl 5 + PictFormatGreenMask* = 1 shl 6 + PictFormatBlue* = 1 shl 7 + PictFormatBlueMask* = 1 shl 8 + PictFormatAlpha* = 1 shl 9 + PictFormatAlphaMask* = 1 shl 10 + PictFormatColormap* = 1 shl 11 + +type + PXRenderVisual* = ptr TXRenderVisual + TXRenderVisual*{.final.} = object + visual*: PVisual + format*: PXRenderPictFormat + + PXRenderDepth* = ptr TXRenderDepth + TXRenderDepth*{.final.} = object + depth*: int32 + nvisuals*: int32 + visuals*: PXRenderVisual + + PXRenderScreen* = ptr TXRenderScreen + TXRenderScreen*{.final.} = object + depths*: PXRenderDepth + ndepths*: int32 + fallback*: PXRenderPictFormat + + PXRenderInfo* = ptr TXRenderInfo + TXRenderInfo*{.final.} = object + format*: PXRenderPictFormat + nformat*: int32 + screen*: PXRenderScreen + nscreen*: int32 + depth*: PXRenderDepth + ndepth*: int32 + visual*: PXRenderVisual + nvisual*: int32 + + PXRenderPictureAttributes* = ptr TXRenderPictureAttributes + TXRenderPictureAttributes*{.final.} = object + repeat_*: TBool + alpha_map*: TPicture + alpha_x_origin*: int32 + alpha_y_origin*: int32 + clip_x_origin*: int32 + clip_y_origin*: int32 + clip_mask*: TPixmap + graphics_exposures*: TBool + subwindow_mode*: int32 + poly_edge*: int32 + poly_mode*: int32 + dither*: TAtom + + PXGlyphInfo* = ptr TXGlyphInfo + TXGlyphInfo*{.final.} = object + width*: int16 + height*: int16 + x*: int16 + y*: int16 + xOff*: int16 + yOff*: int16 + + +proc XRenderQueryExtension*(dpy: PDisplay, event_basep: ptr int32, + error_basep: ptr int32): TBool{.cdecl, + dynlib: libX11, importc.} +proc XRenderQueryVersion*(dpy: PDisplay, major_versionp: ptr int32, + minor_versionp: ptr int32): TStatus{.cdecl, + dynlib: libX11, importc.} +proc XRenderQueryFormats*(dpy: PDisplay): TStatus{.cdecl, dynlib: libX11, + importc.} +proc XRenderFindVisualFormat*(dpy: PDisplay, visual: PVisual): PXRenderPictFormat{. + cdecl, dynlib: libX11, importc.} +proc XRenderFindFormat*(dpy: PDisplay, mask: int32, + `template`: PXRenderPictFormat, count: int32): PXRenderPictFormat{. + cdecl, dynlib: libX11, importc.} +proc XRenderCreatePicture*(dpy: PDisplay, drawable: TDrawable, + format: PXRenderPictFormat, valuemask: int32, + attributes: PXRenderPictureAttributes): TPicture{. + cdecl, dynlib: libX11, importc.} +proc XRenderChangePicture*(dpy: PDisplay, picture: TPicture, valuemask: int32, + attributes: PXRenderPictureAttributes){.cdecl, + dynlib: libX11, importc.} +proc XRenderFreePicture*(dpy: PDisplay, picture: TPicture){.cdecl, + dynlib: libX11, importc.} +proc XRenderComposite*(dpy: PDisplay, op: int32, src: TPicture, mask: TPicture, + dst: TPicture, src_x: int32, src_y: int32, mask_x: int32, + mask_y: int32, dst_x: int32, dst_y: int32, width: int32, + height: int32){.cdecl, dynlib: libX11, importc.} +proc XRenderCreateGlyphSet*(dpy: PDisplay, format: PXRenderPictFormat): TGlyphSet{. + cdecl, dynlib: libX11, importc.} +proc XRenderReferenceGlyphSet*(dpy: PDisplay, existing: TGlyphSet): TGlyphSet{. + cdecl, dynlib: libX11, importc.} +proc XRenderFreeGlyphSet*(dpy: PDisplay, glyphset: TGlyphSet){.cdecl, + dynlib: libX11, importc.} +proc XRenderAddGlyphs*(dpy: PDisplay, glyphset: TGlyphSet, gids: PGlyph, + glyphs: PXGlyphInfo, nglyphs: int32, images: cstring, + nbyte_images: int32){.cdecl, dynlib: libX11, importc.} +proc XRenderFreeGlyphs*(dpy: PDisplay, glyphset: TGlyphSet, gids: PGlyph, + nglyphs: int32){.cdecl, dynlib: libX11, importc.} +proc XRenderCompositeString8*(dpy: PDisplay, op: int32, src: TPicture, + dst: TPicture, maskFormat: PXRenderPictFormat, + glyphset: TGlyphSet, xSrc: int32, ySrc: int32, + xDst: int32, yDst: int32, str: cstring, + nchar: int32){.cdecl, dynlib: libX11, importc.} +# implementation diff --git a/lib/base/x11/xresource.nim b/lib/base/x11/xresource.nim new file mode 100644 index 000000000..ddb2a89c2 --- /dev/null +++ b/lib/base/x11/xresource.nim @@ -0,0 +1,200 @@ + +import + x, xlib + +#const +# libX11* = "libX11.so" + +# +# Automatically converted by H2Pas 0.99.15 from xresource.h +# The following command line parameters were used: +# -p +# -T +# -S +# -d +# -c +# xresource.h +# + +proc Xpermalloc*(para1: int32): cstring{.cdecl, dynlib: libX11, importc.} +type + PXrmQuark* = ptr TXrmQuark + TXrmQuark* = int32 + TXrmQuarkList* = PXrmQuark + PXrmQuarkList* = ptr TXrmQuarkList + +proc NULLQUARK*(): TXrmQuark +type + PXrmString* = ptr TXrmString + TXrmString* = ptr char + +proc NULLSTRING*(): TXrmString +proc XrmStringToQuark*(para1: cstring): TXrmQuark{.cdecl, dynlib: libX11, + importc.} +proc XrmPermStringToQuark*(para1: cstring): TXrmQuark{.cdecl, dynlib: libX11, + importc.} +proc XrmQuarkToString*(para1: TXrmQuark): TXrmString{.cdecl, dynlib: libX11, + importc.} +proc XrmUniqueQuark*(): TXrmQuark{.cdecl, dynlib: libX11, importc.} +when defined(MACROS): + proc XrmStringsEqual*(a1, a2: cstring): bool +type + PXrmBinding* = ptr TXrmBinding + TXrmBinding* = enum + XrmBindTightly, XrmBindLoosely + TXrmBindingList* = PXrmBinding + PXrmBindingList* = ptr TXrmBindingList + +proc XrmStringToQuarkList*(para1: cstring, para2: TXrmQuarkList){.cdecl, + dynlib: libX11, importc.} +proc XrmStringToBindingQuarkList*(para1: cstring, para2: TXrmBindingList, + para3: TXrmQuarkList){.cdecl, dynlib: libX11, + importc.} +type + PXrmName* = ptr TXrmName + TXrmName* = TXrmQuark + PXrmNameList* = ptr TXrmNameList + TXrmNameList* = TXrmQuarkList + +when defined(MACROS): + proc XrmNameToString*(name: int32): TXrmString + proc XrmStringToName*(str: cstring): int32 + proc XrmStringToNameList*(str: cstring, name: PXrmQuark) +type + PXrmClass* = ptr TXrmClass + TXrmClass* = TXrmQuark + PXrmClassList* = ptr TXrmClassList + TXrmClassList* = TXrmQuarkList + +when defined(MACROS): + proc XrmClassToString*(c_class: int32): TXrmString + proc XrmStringToClass*(c_class: cstring): int32 + proc XrmStringToClassList*(str: cstring, c_class: PXrmQuark) +type + PXrmRepresentation* = ptr TXrmRepresentation + TXrmRepresentation* = TXrmQuark + +when defined(MACROS): + proc XrmStringToRepresentation*(str: cstring): int32 + proc XrmRepresentationToString*(thetype: int32): TXrmString +type + PXrmValue* = ptr TXrmValue + TXrmValue*{.final.} = object + size*: int32 + address*: TXPointer + + TXrmValuePtr* = PXrmValue + PXrmValuePtr* = ptr TXrmValuePtr + PXrmHashBucketRec* = ptr TXrmHashBucketRec + TXrmHashBucketRec*{.final.} = object + TXrmHashBucket* = PXrmHashBucketRec + PXrmHashBucket* = ptr TXrmHashBucket + PXrmHashTable* = ptr TXrmHashTable + TXrmHashTable* = ptr TXrmHashBucket + TXrmDatabase* = PXrmHashBucketRec + PXrmDatabase* = ptr TXrmDatabase + +proc XrmDestroyDatabase*(para1: TXrmDatabase){.cdecl, dynlib: libX11, importc.} +proc XrmQPutResource*(para1: PXrmDatabase, para2: TXrmBindingList, + para3: TXrmQuarkList, para4: TXrmRepresentation, + para5: PXrmValue){.cdecl, dynlib: libX11, importc.} +proc XrmPutResource*(para1: PXrmDatabase, para2: cstring, para3: cstring, + para4: PXrmValue){.cdecl, dynlib: libX11, importc.} +proc XrmQPutStringResource*(para1: PXrmDatabase, para2: TXrmBindingList, + para3: TXrmQuarkList, para4: cstring){.cdecl, + dynlib: libX11, importc.} +proc XrmPutStringResource*(para1: PXrmDatabase, para2: cstring, para3: cstring){. + cdecl, dynlib: libX11, importc.} +proc XrmPutLineResource*(para1: PXrmDatabase, para2: cstring){.cdecl, + dynlib: libX11, importc.} +proc XrmQGetResource*(para1: TXrmDatabase, para2: TXrmNameList, + para3: TXrmClassList, para4: PXrmRepresentation, + para5: PXrmValue): TBool{.cdecl, dynlib: libX11, importc.} +proc XrmGetResource*(para1: TXrmDatabase, para2: cstring, para3: cstring, + para4: PPchar, para5: PXrmValue): TBool{.cdecl, + dynlib: libX11, importc.} + # There is no definition of TXrmSearchList + #function XrmQGetSearchList(para1:TXrmDatabase; para2:TXrmNameList; para3:TXrmClassList; para4:TXrmSearchList; para5:longint):TBool;cdecl;external libX11; + #function XrmQGetSearchResource(para1:TXrmSearchList; para2:TXrmName; para3:TXrmClass; para4:PXrmRepresentation; para5:PXrmValue):TBool;cdecl;external libX11; +proc XrmSetDatabase*(para1: PDisplay, para2: TXrmDatabase){.cdecl, + dynlib: libX11, importc.} +proc XrmGetDatabase*(para1: PDisplay): TXrmDatabase{.cdecl, dynlib: libX11, + importc.} +proc XrmGetFileDatabase*(para1: cstring): TXrmDatabase{.cdecl, dynlib: libX11, + importc.} +proc XrmCombineFileDatabase*(para1: cstring, para2: PXrmDatabase, para3: TBool): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XrmGetStringDatabase*(para1: cstring): TXrmDatabase{.cdecl, dynlib: libX11, + importc.} +proc XrmPutFileDatabase*(para1: TXrmDatabase, para2: cstring){.cdecl, + dynlib: libX11, importc.} +proc XrmMergeDatabases*(para1: TXrmDatabase, para2: PXrmDatabase){.cdecl, + dynlib: libX11, importc.} +proc XrmCombineDatabase*(para1: TXrmDatabase, para2: PXrmDatabase, para3: TBool){. + cdecl, dynlib: libX11, importc.} +const + XrmEnumAllLevels* = 0 + XrmEnumOneLevel* = 1 + +type + funcbool* = proc (): TBool + +proc XrmEnumerateDatabase*(para1: TXrmDatabase, para2: TXrmNameList, + para3: TXrmClassList, para4: int32, para5: funcbool, + para6: TXPointer): TBool{.cdecl, dynlib: libX11, + importc.} +proc XrmLocaleOfDatabase*(para1: TXrmDatabase): cstring{.cdecl, dynlib: libX11, + importc.} +type + PXrmOptionKind* = ptr TXrmOptionKind + TXrmOptionKind* = enum + XrmoptionNoArg, XrmoptionIsArg, XrmoptionStickyArg, XrmoptionSepArg, + XrmoptionResArg, XrmoptionSkipArg, XrmoptionSkipLine, XrmoptionSkipNArgs + PXrmOptionDescRec* = ptr TXrmOptionDescRec + TXrmOptionDescRec*{.final.} = object + option*: cstring + specifier*: cstring + argKind*: TXrmOptionKind + value*: TXPointer + + TXrmOptionDescList* = PXrmOptionDescRec + PXrmOptionDescList* = ptr TXrmOptionDescList + +proc XrmParseCommand*(para1: PXrmDatabase, para2: TXrmOptionDescList, + para3: int32, para4: cstring, para5: ptr int32, + para6: PPchar){.cdecl, dynlib: libX11, importc.} +# implementation + +proc NULLQUARK(): TXrmQuark = + result = TXrmQuark(0) + +proc NULLSTRING(): TXrmString = + result = nil + +when defined(MACROS): + proc XrmStringsEqual(a1, a2: cstring): bool = + result = (strcomp(a1, a2)) == 0 + + proc XrmNameToString(name: int32): TXrmString = + result = XrmQuarkToString(name) + + proc XrmStringToName(str: cstring): int32 = + result = XrmStringToQuark(str) + + proc XrmStringToNameList(str: cstring, name: PXrmQuark) = + XrmStringToQuarkList(str, name) + + proc XrmClassToString(c_class: int32): TXrmString = + result = XrmQuarkToString(c_class) + + proc XrmStringToClass(c_class: cstring): int32 = + result = XrmStringToQuark(c_class) + + proc XrmStringToClassList(str: cstring, c_class: PXrmQuark) = + XrmStringToQuarkList(str, c_class) + + proc XrmStringToRepresentation(str: cstring): int32 = + result = XrmStringToQuark(str) + + proc XrmRepresentationToString(thetype: int32): TXrmString = + result = XrmQuarkToString(thetype) diff --git a/lib/base/x11/xshm.nim b/lib/base/x11/xshm.nim new file mode 100644 index 000000000..e56bd87b1 --- /dev/null +++ b/lib/base/x11/xshm.nim @@ -0,0 +1,77 @@ + +import + x, xlib + +#const +# libX11* = "libX11.so" + +# +# Automatically converted by H2Pas 0.99.15 from xshm.h +# The following command line parameters were used: +# -p +# -T +# -S +# -d +# -c +# xshm.h +# + +const + constX_ShmQueryVersion* = 0 + constX_ShmAttach* = 1 + constX_ShmDetach* = 2 + constX_ShmPutImage* = 3 + constX_ShmGetImage* = 4 + constX_ShmCreatePixmap* = 5 + ShmCompletion* = 0 + ShmNumberEvents* = ShmCompletion + 1 + BadShmSeg* = 0 + ShmNumberErrors* = BadShmSeg + 1 + +type + PShmSeg* = ptr TShmSeg + TShmSeg* = culong + PXShmCompletionEvent* = ptr TXShmCompletionEvent + TXShmCompletionEvent*{.final.} = object + theType*: cint + serial*: culong + send_event*: TBool + display*: PDisplay + drawable*: TDrawable + major_code*: cint + minor_code*: cint + shmseg*: TShmSeg + offset*: culong + + PXShmSegmentInfo* = ptr TXShmSegmentInfo + TXShmSegmentInfo*{.final.} = object + shmseg*: TShmSeg + shmid*: cint + shmaddr*: cstring + readOnly*: TBool + + +proc XShmQueryExtension*(para1: PDisplay): TBool{.cdecl, dynlib: libX11, importc.} +proc XShmGetEventBase*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.} +proc XShmQueryVersion*(para1: PDisplay, para2: Pcint, para3: Pcint, para4: PBool): TBool{. + cdecl, dynlib: libX11, importc.} +proc XShmPixmapFormat*(para1: PDisplay): cint{.cdecl, dynlib: libX11, importc.} +proc XShmAttach*(para1: PDisplay, para2: PXShmSegmentInfo): TStatus{.cdecl, + dynlib: libX11, importc.} +proc XShmDetach*(para1: PDisplay, para2: PXShmSegmentInfo): TStatus{.cdecl, + dynlib: libX11, importc.} +proc XShmPutImage*(para1: PDisplay, para2: TDrawable, para3: TGC, + para4: PXImage, para5: cint, para6: cint, para7: cint, + para8: cint, para9: cuint, para10: cuint, para11: TBool): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XShmGetImage*(para1: PDisplay, para2: TDrawable, para3: PXImage, + para4: cint, para5: cint, para6: culong): TStatus{.cdecl, + dynlib: libX11, importc.} +proc XShmCreateImage*(para1: PDisplay, para2: PVisual, para3: cuint, + para4: cint, para5: cstring, para6: PXShmSegmentInfo, + para7: cuint, para8: cuint): PXImage{.cdecl, + dynlib: libX11, importc.} +proc XShmCreatePixmap*(para1: PDisplay, para2: TDrawable, para3: cstring, + para4: PXShmSegmentInfo, para5: cuint, para6: cuint, + para7: cuint): TPixmap{.cdecl, dynlib: libX11, importc.} +# implementation diff --git a/lib/base/x11/xutil.nim b/lib/base/x11/xutil.nim new file mode 100644 index 000000000..6cea7fba3 --- /dev/null +++ b/lib/base/x11/xutil.nim @@ -0,0 +1,412 @@ + +import + x, xlib, keysym + +#const +# libX11* = "libX11.so" + +# +# Automatically converted by H2Pas 0.99.15 from xutil.h +# The following command line parameters were used: +# -p +# -T +# -S +# -d +# -c +# xutil.h +# + +const + NoValue* = 0x00000000 + XValue* = 0x00000001 + YValue* = 0x00000002 + WidthValue* = 0x00000004 + HeightValue* = 0x00000008 + AllValues* = 0x0000000F + XNegative* = 0x00000010 + YNegative* = 0x00000020 + +type + TCPoint*{.final.} = object + x*: cint + y*: cint + + PXSizeHints* = ptr TXSizeHints + TXSizeHints*{.final.} = object + flags*: clong + x*, y*: cint + width*, height*: cint + min_width*, min_height*: cint + max_width*, max_height*: cint + width_inc*, height_inc*: cint + min_aspect*, max_aspect*: TCPoint + base_width*, base_height*: cint + win_gravity*: cint + + +const + USPosition* = 1 shl 0 + USSize* = 1 shl 1 + PPosition* = 1 shl 2 + PSize* = 1 shl 3 + PMinSize* = 1 shl 4 + PMaxSize* = 1 shl 5 + PResizeInc* = 1 shl 6 + PAspect* = 1 shl 7 + PBaseSize* = 1 shl 8 + PWinGravity* = 1 shl 9 + PAllHints* = PPosition or PSize or PMinSize or PMaxSize or PResizeInc or + PAspect + +type + PXWMHints* = ptr TXWMHints + TXWMHints*{.final.} = object + flags*: clong + input*: TBool + initial_state*: cint + icon_pixmap*: TPixmap + icon_window*: TWindow + icon_x*, icon_y*: cint + icon_mask*: TPixmap + window_group*: TXID + + +const + InputHint* = 1 shl 0 + StateHint* = 1 shl 1 + IconPixmapHint* = 1 shl 2 + IconWindowHint* = 1 shl 3 + IconPositionHint* = 1 shl 4 + IconMaskHint* = 1 shl 5 + WindowGroupHint* = 1 shl 6 + AllHints* = InputHint or StateHint or IconPixmapHint or IconWindowHint or + IconPositionHint or IconMaskHint or WindowGroupHint + XUrgencyHint* = 1 shl 8 + WithdrawnState* = 0 + NormalState* = 1 + IconicState* = 3 + DontCareState* = 0 + ZoomState* = 2 + InactiveState* = 4 + +type + PXTextProperty* = ptr TXTextProperty + TXTextProperty*{.final.} = object + value*: pcuchar + encoding*: TAtom + format*: cint + nitems*: culong + + +const + XNoMemory* = - 1 + XLocaleNotSupported* = - 2 + XConverterNotFound* = - 3 + +type + PXICCEncodingStyle* = ptr TXICCEncodingStyle + TXICCEncodingStyle* = enum + XStringStyle, XCompoundTextStyle, XTextStyle, XStdICCTextStyle, + XUTF8StringStyle + PPXIconSize* = ptr PXIconSize + PXIconSize* = ptr TXIconSize + TXIconSize*{.final.} = object + min_width*, min_height*: cint + max_width*, max_height*: cint + width_inc*, height_inc*: cint + + PXClassHint* = ptr TXClassHint + TXClassHint*{.final.} = object + res_name*: cstring + res_class*: cstring + + +type + PXComposeStatus* = ptr TXComposeStatus + TXComposeStatus*{.final.} = object + compose_ptr*: TXPointer + chars_matched*: cint + + +type + PXRegion* = ptr TXRegion + TXRegion*{.final.} = object + TRegion* = PXRegion + PRegion* = ptr TRegion + +const + RectangleOut* = 0 + RectangleIn* = 1 + RectanglePart* = 2 + +type + PXVisualInfo* = ptr TXVisualInfo + TXVisualInfo*{.final.} = object + visual*: PVisual + visualid*: TVisualID + screen*: cint + depth*: cint + class_*: cint + red_mask*: culong + green_mask*: culong + blue_mask*: culong + colormap_size*: cint + bits_per_rgb*: cint + + +const + VisualNoMask* = 0x00000000 + VisualIDMask* = 0x00000001 + VisualScreenMask* = 0x00000002 + VisualDepthMask* = 0x00000004 + VisualClassMask* = 0x00000008 + VisualRedMaskMask* = 0x00000010 + VisualGreenMaskMask* = 0x00000020 + VisualBlueMaskMask* = 0x00000040 + VisualColormapSizeMask* = 0x00000080 + VisualBitsPerRGBMask* = 0x00000100 + VisualAllMask* = 0x000001FF + +type + PPXStandardColormap* = ptr PXStandardColormap + PXStandardColormap* = ptr TXStandardColormap + TXStandardColormap*{.final.} = object + colormap*: TColormap + red_max*: culong + red_mult*: culong + green_max*: culong + green_mult*: culong + blue_max*: culong + blue_mult*: culong + base_pixel*: culong + visualid*: TVisualID + killid*: TXID + + +const + BitmapSuccess* = 0 + BitmapOpenFailed* = 1 + BitmapFileInvalid* = 2 + BitmapNoMemory* = 3 + XCSUCCESS* = 0 + XCNOMEM* = 1 + XCNOENT* = 2 + ReleaseByFreeingColormap*: TXID = TXID(1) + +type + PXContext* = ptr TXContext + TXContext* = cint + +proc XAllocClassHint*(): PXClassHint{.cdecl, dynlib: libX11, importc.} +proc XAllocIconSize*(): PXIconSize{.cdecl, dynlib: libX11, importc.} +proc XAllocSizeHints*(): PXSizeHints{.cdecl, dynlib: libX11, importc.} +proc XAllocStandardColormap*(): PXStandardColormap{.cdecl, dynlib: libX11, + importc.} +proc XAllocWMHints*(): PXWMHints{.cdecl, dynlib: libX11, importc.} +proc XClipBox*(para1: TRegion, para2: PXRectangle): cint{.cdecl, dynlib: libX11, + importc.} +proc XCreateRegion*(): TRegion{.cdecl, dynlib: libX11, importc.} +proc XDefaultString*(): cstring{.cdecl, dynlib: libX11, importc.} +proc XDeleteContext*(para1: PDisplay, para2: TXID, para3: TXContext): cint{. + cdecl, dynlib: libX11, importc.} +proc XDestroyRegion*(para1: TRegion): cint{.cdecl, dynlib: libX11, importc.} +proc XEmptyRegion*(para1: TRegion): cint{.cdecl, dynlib: libX11, importc.} +proc XEqualRegion*(para1: TRegion, para2: TRegion): cint{.cdecl, dynlib: libX11, + importc.} +proc XFindContext*(para1: PDisplay, para2: TXID, para3: TXContext, + para4: PXPointer): cint{.cdecl, dynlib: libX11, importc.} +proc XGetClassHint*(para1: PDisplay, para2: TWindow, para3: PXClassHint): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XGetIconSizes*(para1: PDisplay, para2: TWindow, para3: PPXIconSize, + para4: Pcint): TStatus{.cdecl, dynlib: libX11, importc.} +proc XGetNormalHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XGetRGBColormaps*(para1: PDisplay, para2: TWindow, + para3: PPXStandardColormap, para4: Pcint, para5: TAtom): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XGetSizeHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints, + para4: TAtom): TStatus{.cdecl, dynlib: libX11, importc.} +proc XGetStandardColormap*(para1: PDisplay, para2: TWindow, + para3: PXStandardColormap, para4: TAtom): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XGetTextProperty*(para1: PDisplay, para2: TWindow, para3: PXTextProperty, + para4: TAtom): TStatus{.cdecl, dynlib: libX11, importc.} +proc XGetVisualInfo*(para1: PDisplay, para2: clong, para3: PXVisualInfo, + para4: Pcint): PXVisualInfo{.cdecl, dynlib: libX11, importc.} +proc XGetWMClientMachine*(para1: PDisplay, para2: TWindow, para3: PXTextProperty): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XGetWMHints*(para1: PDisplay, para2: TWindow): PXWMHints{.cdecl, + dynlib: libX11, importc.} +proc XGetWMIconName*(para1: PDisplay, para2: TWindow, para3: PXTextProperty): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XGetWMName*(para1: PDisplay, para2: TWindow, para3: PXTextProperty): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XGetWMNormalHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints, + para4: ptr int): TStatus{.cdecl, dynlib: libX11, importc.} +proc XGetWMSizeHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints, + para4: ptr int, para5: TAtom): TStatus{.cdecl, + dynlib: libX11, importc.} +proc XGetZoomHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints): TStatus{. + cdecl, dynlib: libX11, importc.} +proc XIntersectRegion*(para1: TRegion, para2: TRegion, para3: TRegion): cint{. + cdecl, dynlib: libX11, importc.} +proc XConvertCase*(para1: TKeySym, para2: PKeySym, para3: PKeySym){.cdecl, + dynlib: libX11, importc.} +proc XLookupString*(para1: PXKeyEvent, para2: cstring, para3: cint, + para4: PKeySym, para5: PXComposeStatus): cint{.cdecl, + dynlib: libX11, importc.} +proc XMatchVisualInfo*(para1: PDisplay, para2: cint, para3: cint, para4: cint, + para5: PXVisualInfo): TStatus{.cdecl, dynlib: libX11, + importc.} +proc XOffsetRegion*(para1: TRegion, para2: cint, para3: cint): cint{.cdecl, + dynlib: libX11, importc.} +proc XPointInRegion*(para1: TRegion, para2: cint, para3: cint): TBool{.cdecl, + dynlib: libX11, importc.} +proc XPolygonRegion*(para1: PXPoint, para2: cint, para3: cint): TRegion{.cdecl, + dynlib: libX11, importc.} +proc XRectInRegion*(para1: TRegion, para2: cint, para3: cint, para4: cuint, + para5: cuint): cint{.cdecl, dynlib: libX11, importc.} +proc XSaveContext*(para1: PDisplay, para2: TXID, para3: TXContext, + para4: cstring): cint{.cdecl, dynlib: libX11, importc.} +proc XSetClassHint*(para1: PDisplay, para2: TWindow, para3: PXClassHint): cint{. + cdecl, dynlib: libX11, importc.} +proc XSetIconSizes*(para1: PDisplay, para2: TWindow, para3: PXIconSize, + para4: cint): cint{.cdecl, dynlib: libX11, importc.} +proc XSetNormalHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints): cint{. + cdecl, dynlib: libX11, importc.} +proc XSetRGBColormaps*(para1: PDisplay, para2: TWindow, + para3: PXStandardColormap, para4: cint, para5: TAtom){. + cdecl, dynlib: libX11, importc.} +proc XSetSizeHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints, + para4: TAtom): cint{.cdecl, dynlib: libX11, importc.} +proc XSetStandardProperties*(para1: PDisplay, para2: TWindow, para3: cstring, + para4: cstring, para5: TPixmap, para6: PPchar, + para7: cint, para8: PXSizeHints): cint{.cdecl, + dynlib: libX11, importc.} +proc XSetTextProperty*(para1: PDisplay, para2: TWindow, para3: PXTextProperty, + para4: TAtom){.cdecl, dynlib: libX11, importc.} +proc XSetWMClientMachine*(para1: PDisplay, para2: TWindow, para3: PXTextProperty){. + cdecl, dynlib: libX11, importc.} +proc XSetWMHints*(para1: PDisplay, para2: TWindow, para3: PXWMHints): cint{. + cdecl, dynlib: libX11, importc.} +proc XSetWMIconName*(para1: PDisplay, para2: TWindow, para3: PXTextProperty){. + cdecl, dynlib: libX11, importc.} +proc XSetWMName*(para1: PDisplay, para2: TWindow, para3: PXTextProperty){.cdecl, + dynlib: libX11, importc.} +proc XSetWMNormalHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints){. + cdecl, dynlib: libX11, importc.} +proc XSetWMProperties*(para1: PDisplay, para2: TWindow, para3: PXTextProperty, + para4: PXTextProperty, para5: PPchar, para6: cint, + para7: PXSizeHints, para8: PXWMHints, para9: PXClassHint){. + cdecl, dynlib: libX11, importc.} +proc XmbSetWMProperties*(para1: PDisplay, para2: TWindow, para3: cstring, + para4: cstring, para5: PPchar, para6: cint, + para7: PXSizeHints, para8: PXWMHints, + para9: PXClassHint){.cdecl, dynlib: libX11, importc.} +proc Xutf8SetWMProperties*(para1: PDisplay, para2: TWindow, para3: cstring, + para4: cstring, para5: PPchar, para6: cint, + para7: PXSizeHints, para8: PXWMHints, + para9: PXClassHint){.cdecl, dynlib: libX11, importc.} +proc XSetWMSizeHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints, + para4: TAtom){.cdecl, dynlib: libX11, importc.} +proc XSetRegion*(para1: PDisplay, para2: TGC, para3: TRegion): cint{.cdecl, + dynlib: libX11, importc.} +proc XSetStandardColormap*(para1: PDisplay, para2: TWindow, + para3: PXStandardColormap, para4: TAtom){.cdecl, + dynlib: libX11, importc.} +proc XSetZoomHints*(para1: PDisplay, para2: TWindow, para3: PXSizeHints): cint{. + cdecl, dynlib: libX11, importc.} +proc XShrinkRegion*(para1: TRegion, para2: cint, para3: cint): cint{.cdecl, + dynlib: libX11, importc.} +proc XStringListToTextProperty*(para1: PPchar, para2: cint, + para3: PXTextProperty): TStatus{.cdecl, + dynlib: libX11, importc.} +proc XSubtractRegion*(para1: TRegion, para2: TRegion, para3: TRegion): cint{. + cdecl, dynlib: libX11, importc.} +proc XmbTextListToTextProperty*(para1: PDisplay, para2: PPchar, para3: cint, + para4: TXICCEncodingStyle, para5: PXTextProperty): cint{. + cdecl, dynlib: libX11, importc.} +proc XwcTextListToTextProperty*(para1: PDisplay, para2: ptr ptr int16, para3: cint, + para4: TXICCEncodingStyle, para5: PXTextProperty): cint{. + cdecl, dynlib: libX11, importc.} +proc Xutf8TextListToTextProperty*(para1: PDisplay, para2: PPchar, para3: cint, + para4: TXICCEncodingStyle, + para5: PXTextProperty): cint{.cdecl, + dynlib: libX11, importc.} +proc XwcFreeStringList*(para1: ptr ptr int16){.cdecl, dynlib: libX11, importc.} +proc XTextPropertyToStringList*(para1: PXTextProperty, para2: PPPchar, + para3: Pcint): TStatus{.cdecl, dynlib: libX11, + importc.} +proc XmbTextPropertyToTextList*(para1: PDisplay, para2: PXTextProperty, + para3: PPPchar, para4: Pcint): cint{.cdecl, + dynlib: libX11, importc.} +proc XwcTextPropertyToTextList*(para1: PDisplay, para2: PXTextProperty, + para3: ptr ptr ptr int16, para4: Pcint): cint{.cdecl, + dynlib: libX11, importc.} +proc Xutf8TextPropertyToTextList*(para1: PDisplay, para2: PXTextProperty, + para3: PPPchar, para4: Pcint): cint{.cdecl, + dynlib: libX11, importc.} +proc XUnionRectWithRegion*(para1: PXRectangle, para2: TRegion, para3: TRegion): cint{. + cdecl, dynlib: libX11, importc.} +proc XUnionRegion*(para1: TRegion, para2: TRegion, para3: TRegion): cint{.cdecl, + dynlib: libX11, importc.} +proc XWMGeometry*(para1: PDisplay, para2: cint, para3: cstring, para4: cstring, + para5: cuint, para6: PXSizeHints, para7: Pcint, para8: Pcint, + para9: Pcint, para10: Pcint, para11: Pcint): cint{.cdecl, + dynlib: libX11, importc.} +proc XXorRegion*(para1: TRegion, para2: TRegion, para3: TRegion): cint{.cdecl, + dynlib: libX11, importc.} +when defined(MACROS): + proc XDestroyImage*(ximage: PXImage): cint + proc XGetPixel*(ximage: PXImage, x, y: cint): culong + proc XPutPixel*(ximage: PXImage, x, y: cint, pixel: culong): cint + proc XSubImage*(ximage: PXImage, x, y: cint, width, height: cuint): PXImage + proc XAddPixel*(ximage: PXImage, value: clong): cint + proc IsKeypadKey*(keysym: TKeySym): bool + proc IsPrivateKeypadKey*(keysym: TKeySym): bool + proc IsCursorKey*(keysym: TKeySym): bool + proc IsPFKey*(keysym: TKeySym): bool + proc IsFunctionKey*(keysym: TKeySym): bool + proc IsMiscFunctionKey*(keysym: TKeySym): bool + proc IsModifierKey*(keysym: TKeySym): bool + #function XUniqueContext : TXContext; + #function XStringToContext(_string : Pchar) : TXContext; +# implementation + +when defined(MACROS): + proc XDestroyImage(ximage: PXImage): cint = + XDestroyImage = ximage^ .f.destroy_image(ximage) + + proc XGetPixel(ximage: PXImage, x, y: cint): culong = + XGetPixel = ximage^ .f.get_pixel(ximage, x, y) + + proc XPutPixel(ximage: PXImage, x, y: cint, pixel: culong): cint = + XPutPixel = ximage^ .f.put_pixel(ximage, x, y, pixel) + + proc XSubImage(ximage: PXImage, x, y: cint, width, height: cuint): PXImage = + XSubImage = ximage^ .f.sub_image(ximage, x, y, width, height) + + proc XAddPixel(ximage: PXImage, value: clong): cint = + XAddPixel = ximage^ .f.add_pixel(ximage, value) + + proc IsKeypadKey(keysym: TKeySym): bool = + IsKeypadKey = (keysym >= XK_KP_Space) and (keysym <= XK_KP_Equal) + + proc IsPrivateKeypadKey(keysym: TKeySym): bool = + IsPrivateKeypadKey = (keysym >= 0x11000000) and (keysym <= 0x1100FFFF) + + proc IsCursorKey(keysym: TKeySym): bool = + IsCursorKey = (keysym >= XK_Home) and (keysym < XK_Select) + + proc IsPFKey(keysym: TKeySym): bool = + IsPFKey = (keysym >= XK_KP_F1) and (keysym <= XK_KP_F4) + + proc IsFunctionKey(keysym: TKeySym): bool = + IsFunctionKey = (keysym >= XK_F1) and (keysym <= XK_F35) + + proc IsMiscFunctionKey(keysym: TKeySym): bool = + IsMiscFunctionKey = (keysym >= XK_Select) and (keysym <= XK_Break) + + proc IsModifierKey(keysym: TKeySym): bool = + IsModifierKey = ((keysym >= XK_Shift_L) And (keysym <= XK_Hyper_R)) Or + (keysym == XK_Mode_switch) Or (keysym == XK_Num_Lock) diff --git a/lib/base/x11/xv.nim b/lib/base/x11/xv.nim new file mode 100644 index 000000000..45ab61418 --- /dev/null +++ b/lib/base/x11/xv.nim @@ -0,0 +1,84 @@ +#*********************************************************** +#Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts, +#and the Massachusetts Institute of Technology, Cambridge, Massachusetts. +# +# All Rights Reserved +# +#Permission to use, copy, modify, and distribute this software and its +#documentation for any purpose and without fee is hereby granted, +#provided that the above copyright notice appear in all copies and that +#both that copyright notice and this permission notice appear in +#supporting documentation, and that the names of Digital or MIT not be +#used in advertising or publicity pertaining to distribution of the +#software without specific, written prior permission. +# +#DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +#ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +#DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +#ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +#WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +#ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +#SOFTWARE. +# +#****************************************************************** +# $XFree86: xc/include/extensions/Xv.h,v 1.3 1999/05/23 06:33:22 dawes Exp $ + +import + x + +const + XvName* = "libXVideo.so" + XvVersion* = 2 + XvRevision* = 2 # Symbols + +type + TXvPortID* = TXID + TXvEncodingID* = TXID + +const + XvNone* = 0 + XvInput* = 0 + XvOutput* = 1 + XvInputMask* = 1 shl XvInput + XvOutputMask* = 1 shl XvOutput + XvVideoMask* = 0x00000004 + XvStillMask* = 0x00000008 + XvImageMask* = 0x00000010 # These two are not client viewable + XvPixmapMask* = 0x00010000 + XvWindowMask* = 0x00020000 + XvGettable* = 0x00000001 + XvSettable* = 0x00000002 + XvRGB* = 0 + XvYUV* = 1 + XvPacked* = 0 + XvPlanar* = 1 + XvTopToBottom* = 0 + XvBottomToTop* = 1 # Events + XvVideoNotify* = 0 + XvPortNotify* = 1 + XvNumEvents* = 2 # Video Notify Reasons + XvStarted* = 0 + XvStopped* = 1 + XvBusy* = 2 + XvPreempted* = 3 + XvHardError* = 4 + XvLastReason* = 4 + XvNumReasons* = XvLastReason + 1 + XvStartedMask* = 1 shl XvStarted + XvStoppedMask* = 1 shl XvStopped + XvBusyMask* = 1 shl XvBusy + XvPreemptedMask* = 1 shl XvPreempted + XvHardErrorMask* = 1 shl XvHardError + XvAnyReasonMask* = (1 shl XvNumReasons) - 1 + XvNoReasonMask* = 0 # Errors + XvBadPort* = 0 + XvBadEncoding* = 1 + XvBadControl* = 2 + XvNumErrors* = 3 # Status + XvBadExtension* = 1 + XvAlreadyGrabbed* = 2 + XvInvalidTime* = 3 + XvBadReply* = 4 + XvBadAlloc* = 5 + +# implementation diff --git a/lib/base/x11/xvlib.nim b/lib/base/x11/xvlib.nim new file mode 100644 index 000000000..19fd0d000 --- /dev/null +++ b/lib/base/x11/xvlib.nim @@ -0,0 +1,234 @@ +#*********************************************************** +#Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts, +#and the Massachusetts Institute of Technology, Cambridge, Massachusetts. +# +# All Rights Reserved +# +#Permission to use, copy, modify, and distribute this software and its +#documentation for any purpose and without fee is hereby granted, +#provided that the above copyright notice appear in all copies and that +#both that copyright notice and this permission notice appear in +#supporting documentation, and that the names of Digital or MIT not be +#used in advertising or publicity pertaining to distribution of the +#software without specific, written prior permission. +# +#DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +#ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +#DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +#ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +#WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +#ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +#SOFTWARE. +# +#****************************************************************** +# $XFree86: xc/include/extensions/Xvlib.h,v 1.3 1999/12/11 19:28:48 mvojkovi Exp $ +#* +#** File: +#** +#** Xvlib.h --- Xv library public header file +#** +#** Author: +#** +#** David Carver (Digital Workstation Engineering/Project Athena) +#** +#** Revisions: +#** +#** 26.06.91 Carver +#** - changed XvFreeAdaptors to XvFreeAdaptorInfo +#** - changed XvFreeEncodings to XvFreeEncodingInfo +#** +#** 11.06.91 Carver +#** - changed SetPortControl to SetPortAttribute +#** - changed GetPortControl to GetPortAttribute +#** - changed QueryBestSize +#** +#** 05.15.91 Carver +#** - version 2.0 upgrade +#** +#** 01.24.91 Carver +#** - version 1.4 upgrade +#** +#* + +import + x, xlib, xshm, xv + +const + libXv* = "libXv.so" + +type + PXvRational* = ptr TXvRational + TXvRational*{.final.} = object + numerator*: cint + denominator*: cint + + PXvAttribute* = ptr TXvAttribute + TXvAttribute*{.final.} = object + flags*: cint # XvGettable, XvSettable + min_value*: cint + max_value*: cint + name*: cstring + + PPXvEncodingInfo* = ptr PXvEncodingInfo + PXvEncodingInfo* = ptr TXvEncodingInfo + TXvEncodingInfo*{.final.} = object + encoding_id*: TXvEncodingID + name*: cstring + width*: culong + height*: culong + rate*: TXvRational + num_encodings*: culong + + PXvFormat* = ptr TXvFormat + TXvFormat*{.final.} = object + depth*: cchar + visual_id*: culong + + PPXvAdaptorInfo* = ptr PXvAdaptorInfo + PXvAdaptorInfo* = ptr TXvAdaptorInfo + TXvAdaptorInfo*{.final.} = object + base_id*: TXvPortID + num_ports*: culong + thetype*: cchar + name*: cstring + num_formats*: culong + formats*: PXvFormat + num_adaptors*: culong + + PXvVideoNotifyEvent* = ptr TXvVideoNotifyEvent + TXvVideoNotifyEvent*{.final.} = object + theType*: cint + serial*: culong # # of last request processed by server + send_event*: TBool # true if this came from a SendEvent request + display*: PDisplay # Display the event was read from + drawable*: TDrawable # drawable + reason*: culong # what generated this event + port_id*: TXvPortID # what port + time*: TTime # milliseconds + + PXvPortNotifyEvent* = ptr TXvPortNotifyEvent + TXvPortNotifyEvent*{.final.} = object + theType*: cint + serial*: culong # # of last request processed by server + send_event*: TBool # true if this came from a SendEvent request + display*: PDisplay # Display the event was read from + port_id*: TXvPortID # what port + time*: TTime # milliseconds + attribute*: TAtom # atom that identifies attribute + value*: clong # value of attribute + + PXvEvent* = ptr TXvEvent + TXvEvent*{.final.} = object + pad*: array[0..23, clong] #case longint of + # 0 : ( + # theType : cint; + # ); + # 1 : ( + # xvvideo : TXvVideoNotifyEvent; + # ); + # 2 : ( + # xvport : TXvPortNotifyEvent; + # ); + # 3 : ( + # + # ); + + PXvImageFormatValues* = ptr TXvImageFormatValues + TXvImageFormatValues*{.final.} = object + id*: cint # Unique descriptor for the format + theType*: cint # XvRGB, XvYUV + byte_order*: cint # LSBFirst, MSBFirst + guid*: array[0..15, cchar] # Globally Unique IDentifier + bits_per_pixel*: cint + format*: cint # XvPacked, XvPlanar + num_planes*: cint # for RGB formats only + depth*: cint + red_mask*: cuint + green_mask*: cuint + blue_mask*: cuint # for YUV formats only + y_sample_bits*: cuint + u_sample_bits*: cuint + v_sample_bits*: cuint + horz_y_period*: cuint + horz_u_period*: cuint + horz_v_period*: cuint + vert_y_period*: cuint + vert_u_period*: cuint + vert_v_period*: cuint + component_order*: array[0..31, char] # eg. UYVY + scanline_order*: cint # XvTopToBottom, XvBottomToTop + + PXvImage* = ptr TXvImage + TXvImage*{.final.} = object + id*: cint + width*, height*: cint + data_size*: cint # bytes + num_planes*: cint + pitches*: pcint # bytes + offsets*: pcint # bytes + data*: pointer + obdata*: TXPointer + + +proc XvQueryExtension*(display: PDisplay, p_version, p_revision, p_requestBase, + p_eventBase, p_errorBase: pcuint): cint{.cdecl, dynlib: libXv, importc.} +proc XvQueryAdaptors*(display: PDisplay, window: TWindow, p_nAdaptors: pcuint, + p_pAdaptors: PPXvAdaptorInfo): cint{.cdecl, dynlib: libXv, + importc.} +proc XvQueryEncodings*(display: PDisplay, port: TXvPortID, p_nEncoding: pcuint, + p_pEncoding: PPXvEncodingInfo): cint{.cdecl, + dynlib: libXv, importc.} +proc XvPutVideo*(display: PDisplay, port: TXvPortID, d: TDrawable, gc: TGC, + vx, vy: cint, vw, vh: cuint, dx, dy: cint, dw, dh: cuint): cint{. + cdecl, dynlib: libXv, importc.} +proc XvPutStill*(display: PDisplay, port: TXvPortID, d: TDrawable, gc: TGC, + vx, vy: cint, vw, vh: cuint, dx, dy: cint, dw, dh: cuint): cint{. + cdecl, dynlib: libXv, importc.} +proc XvGetVideo*(display: PDisplay, port: TXvPortID, d: TDrawable, gc: TGC, + vx, vy: cint, vw, vh: cuint, dx, dy: cint, dw, dh: cuint): cint{. + cdecl, dynlib: libXv, importc.} +proc XvGetStill*(display: PDisplay, port: TXvPortID, d: TDrawable, gc: TGC, + vx, vy: cint, vw, vh: cuint, dx, dy: cint, dw, dh: cuint): cint{. + cdecl, dynlib: libXv, importc.} +proc XvStopVideo*(display: PDisplay, port: TXvPortID, drawable: TDrawable): cint{. + cdecl, dynlib: libXv, importc.} +proc XvGrabPort*(display: PDisplay, port: TXvPortID, time: TTime): cint{.cdecl, + dynlib: libXv, importc.} +proc XvUngrabPort*(display: PDisplay, port: TXvPortID, time: TTime): cint{. + cdecl, dynlib: libXv, importc.} +proc XvSelectVideoNotify*(display: PDisplay, drawable: TDrawable, onoff: TBool): cint{. + cdecl, dynlib: libXv, importc.} +proc XvSelectPortNotify*(display: PDisplay, port: TXvPortID, onoff: TBool): cint{. + cdecl, dynlib: libXv, importc.} +proc XvSetPortAttribute*(display: PDisplay, port: TXvPortID, attribute: TAtom, + value: cint): cint{.cdecl, dynlib: libXv, importc.} +proc XvGetPortAttribute*(display: PDisplay, port: TXvPortID, attribute: TAtom, + p_value: pcint): cint{.cdecl, dynlib: libXv, importc.} +proc XvQueryBestSize*(display: PDisplay, port: TXvPortID, motion: TBool, + vid_w, vid_h, drw_w, drw_h: cuint, + p_actual_width, p_actual_height: pcuint): cint{.cdecl, + dynlib: libXv, importc.} +proc XvQueryPortAttributes*(display: PDisplay, port: TXvPortID, number: pcint): PXvAttribute{. + cdecl, dynlib: libXv, importc.} +proc XvFreeAdaptorInfo*(adaptors: PXvAdaptorInfo){.cdecl, dynlib: libXv, importc.} +proc XvFreeEncodingInfo*(encodings: PXvEncodingInfo){.cdecl, dynlib: libXv, + importc.} +proc XvListImageFormats*(display: PDisplay, port_id: TXvPortID, + count_return: pcint): PXvImageFormatValues{.cdecl, + dynlib: libXv, importc.} +proc XvCreateImage*(display: PDisplay, port: TXvPortID, id: cint, data: pointer, + width, height: cint): PXvImage{.cdecl, dynlib: libXv, + importc.} +proc XvPutImage*(display: PDisplay, id: TXvPortID, d: TDrawable, gc: TGC, + image: PXvImage, src_x, src_y: cint, src_w, src_h: cuint, + dest_x, dest_y: cint, dest_w, dest_h: cuint): cint{.cdecl, + dynlib: libXv, importc.} +proc XvShmPutImage*(display: PDisplay, id: TXvPortID, d: TDrawable, gc: TGC, + image: PXvImage, src_x, src_y: cint, src_w, src_h: cuint, + dest_x, dest_y: cint, dest_w, dest_h: cuint, + send_event: TBool): cint{.cdecl, dynlib: libXv, importc.} +proc XvShmCreateImage*(display: PDisplay, port: TXvPortID, id: cint, + data: pointer, width, height: cint, + shminfo: PXShmSegmentInfo): PXvImage{.cdecl, + dynlib: libXv, importc.} +# implementation diff --git a/lib/base/zip/libzip.nim b/lib/base/zip/libzip.nim new file mode 100644 index 000000000..2f8abc46c --- /dev/null +++ b/lib/base/zip/libzip.nim @@ -0,0 +1,241 @@ +# +# +# Nimrod's Runtime Library +# (c) Copyright 2008 Andreas Rumpf +# +# See the file "copying.txt", included in this +# distribution, for details about the copyright. +# + +## Interface to the `libzip <http://www.nih.at/libzip/index.html>`_ library by +## Dieter Baron and Thomas Klausner. However, this does not need any external +## library (DLL, lib*.so), as the source for this library is included and +## compiled with this interface. + +# +# zip.h -- exported declarations. +# Copyright (C) 1999-2008 Dieter Baron and Thomas Klausner +# +# This file is part of libzip, a library to manipulate ZIP archives. +# The authors can be contacted at <libzip@nih.at> +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. The names of the authors may not be used to endorse or promote +# products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +import times + +{.compile: "libzip_all.c".} +when defined(unix): + {.passl: "-lz".} + +type + Tzip_source_cmd* = int32 + + Tzip_source_callback* = proc (state: pointer, data: pointer, length: int, + cmd: Tzip_source_cmd): int {.cdecl.} + Pzip_stat* = ptr Tzip_stat + Tzip_stat* {.final, pure.} = object + name*: cstring ## name of the file + index*: int32 ## index within archive + crc*: int32 ## crc of file data + mtime*: TTime ## modification time + size*: int ## size of file (uncompressed) + comp_size*: int ## size of file (compressed) + comp_method*: int16 ## compression method used + encryption_method*: int16 ## encryption method used + + Tzip {.final, pure.} = object + Tzip_source {.final, pure.} = object + Tzip_file {.final, pure.} = object + + Pzip* = ptr Tzip ## represents a zip archive + Pzip_file* = ptr Tzip_file ## represents a file within an archive + Pzip_source* = ptr Tzip_source ## represents a source for an archive + + +# flags for zip_name_locate, zip_fopen, zip_stat, ... +const + ZIP_CREATE* = 1'i32 + ZIP_EXCL* = 2'i32 + ZIP_CHECKCONS* = 4'i32 + ZIP_FL_NOCASE* = 1'i32 ## ignore case on name lookup + ZIP_FL_NODIR* = 2'i32 ## ignore directory component + ZIP_FL_COMPRESSED* = 4'i32 ## read compressed data + ZIP_FL_UNCHANGED* = 8'i32 ## use original data, ignoring changes + ZIP_FL_RECOMPRESS* = 16'i32 ## force recompression of data + +const # archive global flags flags + ZIP_AFL_TORRENT* = 1'i32 ## torrent zipped + +const # libzip error codes + ZIP_ER_OK* = 0'i32 ## N No error + ZIP_ER_MULTIDISK* = 1'i32 ## N Multi-disk zip archives not supported + ZIP_ER_RENAME* = 2'i32 ## S Renaming temporary file failed + ZIP_ER_CLOSE* = 3'i32 ## S Closing zip archive failed + ZIP_ER_SEEK* = 4'i32 ## S Seek error + ZIP_ER_READ* = 5'i32 ## S Read error + ZIP_ER_WRITE* = 6'i32 ## S Write error + ZIP_ER_CRC* = 7'i32 ## N CRC error + ZIP_ER_ZIPCLOSED* = 8'i32 ## N Containing zip archive was closed + ZIP_ER_NOENT* = 9'i32 ## N No such file + ZIP_ER_EXISTS* = 10'i32 ## N File already exists + ZIP_ER_OPEN* = 11'i32 ## S Can't open file + ZIP_ER_TMPOPEN* = 12'i32 ## S Failure to create temporary file + ZIP_ER_ZLIB* = 13'i32 ## Z Zlib error + ZIP_ER_MEMORY* = 14'i32 ## N Malloc failure + ZIP_ER_CHANGED* = 15'i32 ## N Entry has been changed + ZIP_ER_COMPNOTSUPP* = 16'i32 ## N Compression method not supported + ZIP_ER_EOF* = 17'i32 ## N Premature EOF + ZIP_ER_INVAL* = 18'i32 ## N Invalid argument + ZIP_ER_NOZIP* = 19'i32 ## N Not a zip archive + ZIP_ER_INTERNAL* = 20'i32 ## N Internal error + ZIP_ER_INCONS* = 21'i32 ## N Zip archive inconsistent + ZIP_ER_REMOVE* = 22'i32 ## S Can't remove file + ZIP_ER_DELETED* = 23'i32 ## N Entry has been deleted + +const # type of system error value + ZIP_ET_NONE* = 0'i32 ## sys_err unused + ZIP_ET_SYS* = 1'i32 ## sys_err is errno + ZIP_ET_ZLIB* = 2'i32 ## sys_err is zlib error code + +const # compression methods + ZIP_CM_DEFAULT* = -1'i32 ## better of deflate or store + ZIP_CM_STORE* = 0'i32 ## stored (uncompressed) + ZIP_CM_SHRINK* = 1'i32 ## shrunk + ZIP_CM_REDUCE_1* = 2'i32 ## reduced with factor 1 + ZIP_CM_REDUCE_2* = 3'i32 ## reduced with factor 2 + ZIP_CM_REDUCE_3* = 4'i32 ## reduced with factor 3 + ZIP_CM_REDUCE_4* = 5'i32 ## reduced with factor 4 + ZIP_CM_IMPLODE* = 6'i32 ## imploded + ## 7 - Reserved for Tokenizing compression algorithm + ZIP_CM_DEFLATE* = 8'i32 ## deflated + ZIP_CM_DEFLATE64* = 9'i32 ## deflate64 + ZIP_CM_PKWARE_IMPLODE* = 10'i32 ## PKWARE imploding + ## 11 - Reserved by PKWARE + ZIP_CM_BZIP2* = 12'i32 ## compressed using BZIP2 algorithm + ## 13 - Reserved by PKWARE + ZIP_CM_LZMA* = 14'i32 ## LZMA (EFS) + ## 15-17 - Reserved by PKWARE + ZIP_CM_TERSE* = 18'i32 ## compressed using IBM TERSE (new) + ZIP_CM_LZ77* = 19'i32 ## IBM LZ77 z Architecture (PFS) + ZIP_CM_WAVPACK* = 97'i32 ## WavPack compressed data + ZIP_CM_PPMD* = 98'i32 ## PPMd version I, Rev 1 + +const # encryption methods + ZIP_EM_NONE* = 0'i32 ## not encrypted + ZIP_EM_TRAD_PKWARE* = 1'i32 ## traditional PKWARE encryption + +const + ZIP_EM_UNKNOWN* = 0x0000FFFF'i32 ## unknown algorithm + +const + ZIP_SOURCE_OPEN* = 0'i32 ## prepare for reading + ZIP_SOURCE_READ* = 1'i32 ## read data + ZIP_SOURCE_CLOSE* = 2'i32 ## reading is done + ZIP_SOURCE_STAT* = 3'i32 ## get meta information + ZIP_SOURCE_ERROR* = 4'i32 ## get error information + constZIP_SOURCE_FREE* = 5'i32 ## cleanup and free resources + +proc zip_add*(para1: Pzip, para2: cstring, para3: Pzip_source): int32 {.cdecl, + importc: "zip_add".} +proc zip_add_dir*(para1: Pzip, para2: cstring): int32 {.cdecl, + importc: "zip_add_dir".} +proc zip_close*(para1: Pzip) {.cdecl, importc: "zip_close".} +proc zip_delete*(para1: Pzip, para2: int32): int32 {.cdecl, + importc: "zip_delete".} +proc zip_error_clear*(para1: Pzip) {.cdecl, importc: "zip_error_clear".} +proc zip_error_get*(para1: Pzip, para2: ptr int32, para3: ptr int32) {.cdecl, + importc: "zip_error_get".} +proc zip_error_get_sys_type*(para1: int32): int32 {.cdecl, + importc: "zip_error_get_sys_type".} +proc zip_error_to_str*(para1: cstring, para2: int, para3: int32, + para4: int32): int32 {.cdecl, + importc: "zip_error_to_str".} +proc zip_fclose*(para1: Pzip_file) {.cdecl, + importc: "zip_fclose".} +proc zip_file_error_clear*(para1: Pzip_file) {.cdecl, + importc: "zip_file_error_clear".} +proc zip_file_error_get*(para1: Pzip_file, para2: ptr int32, para3: ptr int32) {. + cdecl, importc: "zip_file_error_get".} +proc zip_file_strerror*(para1: Pzip_file): cstring {.cdecl, + importc: "zip_file_strerror".} +proc zip_fopen*(para1: Pzip, para2: cstring, para3: int32): Pzip_file {.cdecl, + importc: "zip_fopen".} +proc zip_fopen_index*(para1: Pzip, para2: int32, para3: int32): Pzip_file {. + cdecl, importc: "zip_fopen_index".} +proc zip_fread*(para1: Pzip_file, para2: pointer, para3: int): int {. + cdecl, importc: "zip_fread".} +proc zip_get_archive_comment*(para1: Pzip, para2: ptr int32, para3: int32): cstring {. + cdecl, importc: "zip_get_archive_comment".} +proc zip_get_archive_flag*(para1: Pzip, para2: int32, para3: int32): int32 {. + cdecl, importc: "zip_get_archive_flag".} +proc zip_get_file_comment*(para1: Pzip, para2: int32, para3: ptr int32, + para4: int32): cstring {.cdecl, + importc: "zip_get_file_comment".} +proc zip_get_name*(para1: Pzip, para2: int32, para3: int32): cstring {.cdecl, + importc: "zip_get_name".} +proc zip_get_num_files*(para1: Pzip): int32 {.cdecl, + importc: "zip_get_num_files".} +proc zip_name_locate*(para1: Pzip, para2: cstring, para3: int32): int32 {.cdecl, + importc: "zip_name_locate".} +proc zip_open*(para1: cstring, para2: int32, para3: ptr int32): Pzip {.cdecl, + importc: "zip_open".} +proc zip_rename*(para1: Pzip, para2: int32, para3: cstring): int32 {.cdecl, + importc: "zip_rename".} +proc zip_replace*(para1: Pzip, para2: int32, para3: Pzip_source): int32 {.cdecl, + importc: "zip_replace".} +proc zip_set_archive_comment*(para1: Pzip, para2: cstring, para3: int32): int32 {. + cdecl, importc: "zip_set_archive_comment".} +proc zip_set_archive_flag*(para1: Pzip, para2: int32, para3: int32): int32 {. + cdecl, importc: "zip_set_archive_flag".} +proc zip_set_file_comment*(para1: Pzip, para2: int32, para3: cstring, + para4: int32): int32 {.cdecl, + importc: "zip_set_file_comment".} +proc zip_source_buffer*(para1: Pzip, para2: pointer, para3: int, para4: int32): Pzip_source {. + cdecl, importc: "zip_source_buffer".} +proc zip_source_file*(para1: Pzip, para2: cstring, para3: int, para4: int): Pzip_source {. + cdecl, importc: "zip_source_file".} +proc zip_source_filep*(para1: Pzip, para2: TFile, para3: int, para4: int): Pzip_source {. + cdecl, importc: "zip_source_filep".} +proc zip_source_free*(para1: Pzip_source) {.cdecl, + importc: "zip_source_free".} +proc zip_source_function*(para1: Pzip, para2: Tzip_source_callback, + para3: pointer): Pzip_source {.cdecl, + importc: "zip_source_function".} +proc zip_source_zip*(para1: Pzip, para2: Pzip, para3: int32, para4: int32, + para5: int, para6: int): Pzip_source {.cdecl, + importc: "zip_source_zip".} +proc zip_stat*(para1: Pzip, para2: cstring, para3: int32, para4: Pzip_stat): int32 {. + cdecl, importc: "zip_stat".} +proc zip_stat_index*(para1: Pzip, para2: int32, para3: int32, para4: Pzip_stat): int32 {. + cdecl, importc: "zip_stat_index".} +proc zip_stat_init*(para1: Pzip_stat) {.cdecl, importc: "zip_stat_init".} +proc zip_strerror*(para1: Pzip): cstring {.cdecl, importc: "zip_strerror".} +proc zip_unchange*(para1: Pzip, para2: int32): int32 {.cdecl, + importc: "zip_unchange".} +proc zip_unchange_all*(para1: Pzip): int32 {.cdecl, importc: "zip_unchange_all".} +proc zip_unchange_archive*(para1: Pzip): int32 {.cdecl, + importc: "zip_unchange_archive".} diff --git a/lib/base/zip/libzip_all.c b/lib/base/zip/libzip_all.c new file mode 100644 index 000000000..797374b29 --- /dev/null +++ b/lib/base/zip/libzip_all.c @@ -0,0 +1,4189 @@ +/* + zipint.h -- internal declarations. + Copyright (C) 1999-2008 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at <libzip@nih.at> + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include <zlib.h> + +/* +#ifdef _MSC_VER +#define ZIP_EXTERN __declspec(dllimport) +#endif +*/ + +/* + zip.h -- exported declarations. + Copyright (C) 1999-2008 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at <libzip@nih.at> + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#ifndef ZIP_EXTERN +#define ZIP_EXTERN +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#include <sys/types.h> +#include <stdio.h> +#include <time.h> + +/* flags for zip_open */ + +#define ZIP_CREATE 1 +#define ZIP_EXCL 2 +#define ZIP_CHECKCONS 4 + + +/* flags for zip_name_locate, zip_fopen, zip_stat, ... */ + +#define ZIP_FL_NOCASE 1 /* ignore case on name lookup */ +#define ZIP_FL_NODIR 2 /* ignore directory component */ +#define ZIP_FL_COMPRESSED 4 /* read compressed data */ +#define ZIP_FL_UNCHANGED 8 /* use original data, ignoring changes */ +#define ZIP_FL_RECOMPRESS 16 /* force recompression of data */ + +/* archive global flags flags */ + +#define ZIP_AFL_TORRENT 1 /* torrent zipped */ + +/* libzip error codes */ + +#define ZIP_ER_OK 0 /* N No error */ +#define ZIP_ER_MULTIDISK 1 /* N Multi-disk zip archives not supported */ +#define ZIP_ER_RENAME 2 /* S Renaming temporary file failed */ +#define ZIP_ER_CLOSE 3 /* S Closing zip archive failed */ +#define ZIP_ER_SEEK 4 /* S Seek error */ +#define ZIP_ER_READ 5 /* S Read error */ +#define ZIP_ER_WRITE 6 /* S Write error */ +#define ZIP_ER_CRC 7 /* N CRC error */ +#define ZIP_ER_ZIPCLOSED 8 /* N Containing zip archive was closed */ +#define ZIP_ER_NOENT 9 /* N No such file */ +#define ZIP_ER_EXISTS 10 /* N File already exists */ +#define ZIP_ER_OPEN 11 /* S Can't open file */ +#define ZIP_ER_TMPOPEN 12 /* S Failure to create temporary file */ +#define ZIP_ER_ZLIB 13 /* Z Zlib error */ +#define ZIP_ER_MEMORY 14 /* N Malloc failure */ +#define ZIP_ER_CHANGED 15 /* N Entry has been changed */ +#define ZIP_ER_COMPNOTSUPP 16 /* N Compression method not supported */ +#define ZIP_ER_EOF 17 /* N Premature EOF */ +#define ZIP_ER_INVAL 18 /* N Invalid argument */ +#define ZIP_ER_NOZIP 19 /* N Not a zip archive */ +#define ZIP_ER_INTERNAL 20 /* N Internal error */ +#define ZIP_ER_INCONS 21 /* N Zip archive inconsistent */ +#define ZIP_ER_REMOVE 22 /* S Can't remove file */ +#define ZIP_ER_DELETED 23 /* N Entry has been deleted */ + + +/* type of system error value */ + +#define ZIP_ET_NONE 0 /* sys_err unused */ +#define ZIP_ET_SYS 1 /* sys_err is errno */ +#define ZIP_ET_ZLIB 2 /* sys_err is zlib error code */ + +/* compression methods */ + +#define ZIP_CM_DEFAULT -1 /* better of deflate or store */ +#define ZIP_CM_STORE 0 /* stored (uncompressed) */ +#define ZIP_CM_SHRINK 1 /* shrunk */ +#define ZIP_CM_REDUCE_1 2 /* reduced with factor 1 */ +#define ZIP_CM_REDUCE_2 3 /* reduced with factor 2 */ +#define ZIP_CM_REDUCE_3 4 /* reduced with factor 3 */ +#define ZIP_CM_REDUCE_4 5 /* reduced with factor 4 */ +#define ZIP_CM_IMPLODE 6 /* imploded */ +/* 7 - Reserved for Tokenizing compression algorithm */ +#define ZIP_CM_DEFLATE 8 /* deflated */ +#define ZIP_CM_DEFLATE64 9 /* deflate64 */ +#define ZIP_CM_PKWARE_IMPLODE 10 /* PKWARE imploding */ +/* 11 - Reserved by PKWARE */ +#define ZIP_CM_BZIP2 12 /* compressed using BZIP2 algorithm */ +/* 13 - Reserved by PKWARE */ +#define ZIP_CM_LZMA 14 /* LZMA (EFS) */ +/* 15-17 - Reserved by PKWARE */ +#define ZIP_CM_TERSE 18 /* compressed using IBM TERSE (new) */ +#define ZIP_CM_LZ77 19 /* IBM LZ77 z Architecture (PFS) */ +#define ZIP_CM_WAVPACK 97 /* WavPack compressed data */ +#define ZIP_CM_PPMD 98 /* PPMd version I, Rev 1 */ + +/* encryption methods */ + +#define ZIP_EM_NONE 0 /* not encrypted */ +#define ZIP_EM_TRAD_PKWARE 1 /* traditional PKWARE encryption */ +#if 0 /* Strong Encryption Header not parsed yet */ +#define ZIP_EM_DES 0x6601 /* strong encryption: DES */ +#define ZIP_EM_RC2_OLD 0x6602 /* strong encryption: RC2, version < 5.2 */ +#define ZIP_EM_3DES_168 0x6603 +#define ZIP_EM_3DES_112 0x6609 +#define ZIP_EM_AES_128 0x660e +#define ZIP_EM_AES_192 0x660f +#define ZIP_EM_AES_256 0x6610 +#define ZIP_EM_RC2 0x6702 /* strong encryption: RC2, version >= 5.2 */ +#define ZIP_EM_RC4 0x6801 +#endif +#define ZIP_EM_UNKNOWN 0xffff /* unknown algorithm */ + +typedef long myoff_t; /* XXX: 64 bit support */ + +enum zip_source_cmd { + ZIP_SOURCE_OPEN, /* prepare for reading */ + ZIP_SOURCE_READ, /* read data */ + ZIP_SOURCE_CLOSE, /* reading is done */ + ZIP_SOURCE_STAT, /* get meta information */ + ZIP_SOURCE_ERROR, /* get error information */ + ZIP_SOURCE_FREE /* cleanup and free resources */ +}; + +typedef ssize_t (*zip_source_callback)(void *state, void *data, + size_t len, enum zip_source_cmd cmd); + +struct zip_stat { + const char *name; /* name of the file */ + int index; /* index within archive */ + unsigned int crc; /* crc of file data */ + time_t mtime; /* modification time */ + myoff_t size; /* size of file (uncompressed) */ + myoff_t comp_size; /* size of file (compressed) */ + unsigned short comp_method; /* compression method used */ + unsigned short encryption_method; /* encryption method used */ +}; + +struct zip; +struct zip_file; +struct zip_source; + + +ZIP_EXTERN int zip_add(struct zip *, const char *, struct zip_source *); +ZIP_EXTERN int zip_add_dir(struct zip *, const char *); +ZIP_EXTERN int zip_close(struct zip *); +ZIP_EXTERN int zip_delete(struct zip *, int); +ZIP_EXTERN void zip_error_clear(struct zip *); +ZIP_EXTERN void zip_error_get(struct zip *, int *, int *); +ZIP_EXTERN int zip_error_get_sys_type(int); +ZIP_EXTERN int zip_error_to_str(char *, size_t, int, int); +ZIP_EXTERN int zip_fclose(struct zip_file *); +ZIP_EXTERN void zip_file_error_clear(struct zip_file *); +ZIP_EXTERN void zip_file_error_get(struct zip_file *, int *, int *); +ZIP_EXTERN const char *zip_file_strerror(struct zip_file *); +ZIP_EXTERN struct zip_file *zip_fopen(struct zip *, const char *, int); +ZIP_EXTERN struct zip_file *zip_fopen_index(struct zip *, int, int); +ZIP_EXTERN ssize_t zip_fread(struct zip_file *, void *, size_t); +ZIP_EXTERN const char *zip_get_archive_comment(struct zip *, int *, int); +ZIP_EXTERN int zip_get_archive_flag(struct zip *, int, int); +ZIP_EXTERN const char *zip_get_file_comment(struct zip *, int, int *, int); +ZIP_EXTERN const char *zip_get_name(struct zip *, int, int); +ZIP_EXTERN int zip_get_num_files(struct zip *); +ZIP_EXTERN int zip_name_locate(struct zip *, const char *, int); +ZIP_EXTERN struct zip *zip_open(const char *, int, int *); +ZIP_EXTERN int zip_rename(struct zip *, int, const char *); +ZIP_EXTERN int zip_replace(struct zip *, int, struct zip_source *); +ZIP_EXTERN int zip_set_archive_comment(struct zip *, const char *, int); +ZIP_EXTERN int zip_set_archive_flag(struct zip *, int, int); +ZIP_EXTERN int zip_set_file_comment(struct zip *, int, const char *, int); +ZIP_EXTERN struct zip_source *zip_source_buffer(struct zip *, const void *, + myoff_t, int); +ZIP_EXTERN struct zip_source *zip_source_file(struct zip *, const char *, + myoff_t, myoff_t); +ZIP_EXTERN struct zip_source *zip_source_filep(struct zip *, FILE *, + myoff_t, myoff_t); +ZIP_EXTERN void zip_source_free(struct zip_source *); +ZIP_EXTERN struct zip_source *zip_source_function(struct zip *, + zip_source_callback, void *); +ZIP_EXTERN struct zip_source *zip_source_zip(struct zip *, struct zip *, + int, int, myoff_t, myoff_t); +ZIP_EXTERN int zip_stat(struct zip *, const char *, int, struct zip_stat *); +ZIP_EXTERN int zip_stat_index(struct zip *, int, int, struct zip_stat *); +ZIP_EXTERN void zip_stat_init(struct zip_stat *); +ZIP_EXTERN const char *zip_strerror(struct zip *); +ZIP_EXTERN int zip_unchange(struct zip *, int); +ZIP_EXTERN int zip_unchange_all(struct zip *); +ZIP_EXTERN int zip_unchange_archive(struct zip *); + +#ifdef __cplusplus +} +#endif + + +/* config.h. Generated from config.h.in by configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. + */ +/* #undef HAVE_DECL_TZNAME */ + +#define HAVE_CONFIG_H 1 + +/* Define to 1 if you have the <dlfcn.h> header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the `fseeko' function. */ +#define HAVE_FSEEKO 1 + +/* Define to 1 if you have the `ftello' function. */ +#define HAVE_FTELLO 1 + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `z' library (-lz). */ +#define HAVE_LIBZ 1 + +/* Define to 1 if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mkstemp' function. */ +#define HAVE_MKSTEMP 1 + +/* Define to 1 if you have the `MoveFileExA' function. */ +/* #undef HAVE_MOVEFILEEXA */ + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if `tm_zone' is member of `struct tm'. */ +#define HAVE_STRUCT_TM_TM_ZONE 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +#define HAVE_TM_ZONE 1 + +/* Define to 1 if you don't have `tm_zone' but do have the external array + `tzname'. */ +/* #undef HAVE_TZNAME */ + +/* Define to 1 if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +/* #undef NO_MINUS_C_MINUS_O */ + +/* Name of package */ +#define PACKAGE "libzip" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "libzip@nih.at" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "libzip" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "libzip 0.9" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "libzip" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "0.9" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if your <sys/time.h> declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* Version number of package */ +#define VERSION "0.9" + + +#ifndef HAVE_MKSTEMP +int _zip_mkstemp(char *); +#define mkstemp _zip_mkstemp +#endif + +#ifdef HAVE_MOVEFILEEXA +#include <windows.h> +#define _zip_rename(s, t) \ + (!MoveFileExA((s), (t), \ + MOVEFILE_COPY_ALLOWED|MOVEFILE_REPLACE_EXISTING)) +#else +#define _zip_rename rename +#endif + +#ifndef HAVE_FSEEKO +#define fseeko(s, o, w) (fseek((s), (long int)(o), (w))) +#endif +#ifndef HAVE_FTELLO +#define ftello(s) ((long)ftell((s))) +#endif + + +#define CENTRAL_MAGIC "PK\1\2" +#define LOCAL_MAGIC "PK\3\4" +#define EOCD_MAGIC "PK\5\6" +#define DATADES_MAGIC "PK\7\8" +#define TORRENT_SIG "TORRENTZIPPED-" +#define TORRENT_SIG_LEN 14 +#define TORRENT_CRC_LEN 8 +#define TORRENT_MEM_LEVEL 8 +#define CDENTRYSIZE 46u +#define LENTRYSIZE 30 +#define MAXCOMLEN 65536 +#define EOCDLEN 22 +#define CDBUFSIZE (MAXCOMLEN+EOCDLEN) +#define BUFSIZE 8192 + + +/* state of change of a file in zip archive */ + +enum zip_state { ZIP_ST_UNCHANGED, ZIP_ST_DELETED, ZIP_ST_REPLACED, + ZIP_ST_ADDED, ZIP_ST_RENAMED }; + +/* constants for struct zip_file's member flags */ + +#define ZIP_ZF_EOF 1 /* EOF reached */ +#define ZIP_ZF_DECOMP 2 /* decompress data */ +#define ZIP_ZF_CRC 4 /* compute and compare CRC */ + +/* directory entry: general purpose bit flags */ + +#define ZIP_GPBF_ENCRYPTED 0x0001 /* is encrypted */ +#define ZIP_GPBF_DATA_DESCRIPTOR 0x0008 /* crc/size after file data */ +#define ZIP_GPBF_STRONG_ENCRYPTION 0x0040 /* uses strong encryption */ + +/* error information */ + +struct zip_error { + int zip_err; /* libzip error code (ZIP_ER_*) */ + int sys_err; /* copy of errno (E*) or zlib error code */ + char *str; /* string representation or NULL */ +}; + +/* zip archive, part of API */ + +struct zip { + char *zn; /* file name */ + FILE *zp; /* file */ + struct zip_error error; /* error information */ + + unsigned int flags; /* archive global flags */ + unsigned int ch_flags; /* changed archive global flags */ + + struct zip_cdir *cdir; /* central directory */ + char *ch_comment; /* changed archive comment */ + int ch_comment_len; /* length of changed zip archive + * comment, -1 if unchanged */ + int nentry; /* number of entries */ + int nentry_alloc; /* number of entries allocated */ + struct zip_entry *entry; /* entries */ + int nfile; /* number of opened files within archive */ + int nfile_alloc; /* number of files allocated */ + struct zip_file **file; /* opened files within archive */ +}; + +/* file in zip archive, part of API */ + +struct zip_file { + struct zip *za; /* zip archive containing this file */ + struct zip_error error; /* error information */ + int flags; /* -1: eof, >0: error */ + + int method; /* compression method */ + myoff_t fpos; /* position within zip file (fread/fwrite) */ + unsigned long bytes_left; /* number of bytes left to read */ + unsigned long cbytes_left; /* number of bytes of compressed data left */ + + unsigned long crc; /* CRC so far */ + unsigned long crc_orig; /* CRC recorded in archive */ + + char *buffer; + z_stream *zstr; +}; + +/* zip archive directory entry (central or local) */ + +struct zip_dirent { + unsigned short version_madeby; /* (c) version of creator */ + unsigned short version_needed; /* (cl) version needed to extract */ + unsigned short bitflags; /* (cl) general purpose bit flag */ + unsigned short comp_method; /* (cl) compression method used */ + time_t last_mod; /* (cl) time of last modification */ + unsigned int crc; /* (cl) CRC-32 of uncompressed data */ + unsigned int comp_size; /* (cl) size of commpressed data */ + unsigned int uncomp_size; /* (cl) size of uncommpressed data */ + char *filename; /* (cl) file name (NUL-terminated) */ + unsigned short filename_len; /* (cl) length of filename (w/o NUL) */ + char *extrafield; /* (cl) extra field */ + unsigned short extrafield_len; /* (cl) length of extra field */ + char *comment; /* (c) file comment */ + unsigned short comment_len; /* (c) length of file comment */ + unsigned short disk_number; /* (c) disk number start */ + unsigned short int_attrib; /* (c) internal file attributes */ + unsigned int ext_attrib; /* (c) external file attributes */ + unsigned int offset; /* (c) offset of local header */ +}; + +/* zip archive central directory */ + +struct zip_cdir { + struct zip_dirent *entry; /* directory entries */ + int nentry; /* number of entries */ + + unsigned int size; /* size of central direcotry */ + unsigned int offset; /* offset of central directory in file */ + char *comment; /* zip archive comment */ + unsigned short comment_len; /* length of zip archive comment */ +}; + + + +struct zip_source { + zip_source_callback f; + void *ud; +}; + +/* entry in zip archive directory */ + +struct zip_entry { + enum zip_state state; + struct zip_source *source; + char *ch_filename; + char *ch_comment; + int ch_comment_len; +}; + + + +extern const char * const _zip_err_str[]; +extern const int _zip_nerr_str; +extern const int _zip_err_type[]; + + + +#define ZIP_ENTRY_DATA_CHANGED(x) \ + ((x)->state == ZIP_ST_REPLACED \ + || (x)->state == ZIP_ST_ADDED) + + + +int _zip_cdir_compute_crc(struct zip *, uLong *); +void _zip_cdir_free(struct zip_cdir *); +struct zip_cdir *_zip_cdir_new(int, struct zip_error *); +int _zip_cdir_write(struct zip_cdir *, FILE *, struct zip_error *); + +void _zip_dirent_finalize(struct zip_dirent *); +void _zip_dirent_init(struct zip_dirent *); +int _zip_dirent_read(struct zip_dirent *, FILE *, + unsigned char **, unsigned int, int, struct zip_error *); +void _zip_dirent_torrent_normalize(struct zip_dirent *); +int _zip_dirent_write(struct zip_dirent *, FILE *, int, struct zip_error *); + +void _zip_entry_free(struct zip_entry *); +void _zip_entry_init(struct zip *, int); +struct zip_entry *_zip_entry_new(struct zip *); + +void _zip_error_clear(struct zip_error *); +void _zip_error_copy(struct zip_error *, struct zip_error *); +void _zip_error_fini(struct zip_error *); +void _zip_error_get(struct zip_error *, int *, int *); +void _zip_error_init(struct zip_error *); +void _zip_error_set(struct zip_error *, int, int); +const char *_zip_error_strerror(struct zip_error *); + +int _zip_file_fillbuf(void *, size_t, struct zip_file *); +unsigned int _zip_file_get_offset(struct zip *, int); + +int _zip_filerange_crc(FILE *, myoff_t, myoff_t, uLong *, struct zip_error *); + +struct zip_source *_zip_source_file_or_p(struct zip *, const char *, FILE *, + myoff_t, myoff_t); + +void _zip_free(struct zip *); +const char *_zip_get_name(struct zip *, int, int, struct zip_error *); +int _zip_local_header_read(struct zip *, int); +void *_zip_memdup(const void *, size_t, struct zip_error *); +int _zip_name_locate(struct zip *, const char *, int, struct zip_error *); +struct zip *_zip_new(struct zip_error *); +unsigned short _zip_read2(unsigned char **); +unsigned int _zip_read4(unsigned char **); +int _zip_replace(struct zip *, int, const char *, struct zip_source *); +int _zip_set_name(struct zip *, int, const char *); +int _zip_unchange(struct zip *, int, int); +void _zip_unchange_data(struct zip_entry *); + + +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +const char * +_zip_error_strerror(struct zip_error *err) +{ + const char *zs, *ss; + char buf[128], *s; + + _zip_error_fini(err); + + if (err->zip_err < 0 || err->zip_err >= _zip_nerr_str) { + sprintf(buf, "Unknown error %d", err->zip_err); + zs = NULL; + ss = buf; + } + else { + zs = _zip_err_str[err->zip_err]; + + switch (_zip_err_type[err->zip_err]) { + case ZIP_ET_SYS: + ss = strerror(err->sys_err); + break; + + case ZIP_ET_ZLIB: + ss = zError(err->sys_err); + break; + + default: + ss = NULL; + } + } + + if (ss == NULL) + return zs; + else { + if ((s=(char *)malloc(strlen(ss) + + (zs ? strlen(zs)+2 : 0) + 1)) == NULL) + return _zip_err_str[ZIP_ER_MEMORY]; + + sprintf(s, "%s%s%s", + (zs ? zs : ""), + (zs ? ": " : ""), + ss); + err->str = s; + + return s; + } +} + +#include <stdlib.h> + + + +void +_zip_error_clear(struct zip_error *err) +{ + err->zip_err = ZIP_ER_OK; + err->sys_err = 0; +} + + + +void +_zip_error_copy(struct zip_error *dst, struct zip_error *src) +{ + dst->zip_err = src->zip_err; + dst->sys_err = src->sys_err; +} + + + +void +_zip_error_fini(struct zip_error *err) +{ + free(err->str); + err->str = NULL; +} + + + +void +_zip_error_get(struct zip_error *err, int *zep, int *sep) +{ + if (zep) + *zep = err->zip_err; + if (sep) { + if (zip_error_get_sys_type(err->zip_err) != ZIP_ET_NONE) + *sep = err->sys_err; + else + *sep = 0; + } +} + + + +void +_zip_error_init(struct zip_error *err) +{ + err->zip_err = ZIP_ER_OK; + err->sys_err = 0; + err->str = NULL; +} + + + +void +_zip_error_set(struct zip_error *err, int ze, int se) +{ + if (err) { + err->zip_err = ze; + err->sys_err = se; + } +} + + +#include <sys/types.h> +#include <sys/stat.h> + +#include <assert.h> +#include <ctype.h> +#include <errno.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> + +#ifndef O_BINARY +#define O_BINARY 0 +#endif + + + +int +_zip_mkstemp(char *path) +{ + int fd; + char *start, *trv; + struct stat sbuf; + pid_t pid; + + /* To guarantee multiple calls generate unique names even if + the file is not created. 676 different possibilities with 7 + or more X's, 26 with 6 or less. */ + static char xtra[2] = "aa"; + int xcnt = 0; + + pid = getpid(); + + /* Move to end of path and count trailing X's. */ + for (trv = path; *trv; ++trv) + if (*trv == 'X') + xcnt++; + else + xcnt = 0; + + /* Use at least one from xtra. Use 2 if more than 6 X's. */ + if (*(trv - 1) == 'X') + *--trv = xtra[0]; + if (xcnt > 6 && *(trv - 1) == 'X') + *--trv = xtra[1]; + + /* Set remaining X's to pid digits with 0's to the left. */ + while (*--trv == 'X') { + *trv = (pid % 10) + '0'; + pid /= 10; + } + + /* update xtra for next call. */ + if (xtra[0] != 'z') + xtra[0]++; + else { + xtra[0] = 'a'; + if (xtra[1] != 'z') + xtra[1]++; + else + xtra[1] = 'a'; + } + + /* + * check the target directory; if you have six X's and it + * doesn't exist this runs for a *very* long time. + */ + for (start = trv + 1;; --trv) { + if (trv <= path) + break; + if (*trv == '/') { + *trv = '\0'; + if (stat(path, &sbuf)) + return (0); + if (!S_ISDIR(sbuf.st_mode)) { + errno = ENOTDIR; + return (0); + } + *trv = '/'; + break; + } + } + + for (;;) { + if ((fd=open(path, O_CREAT|O_EXCL|O_RDWR|O_BINARY, 0600)) >= 0) + return (fd); + if (errno != EEXIST) + return (0); + + /* tricky little algorithm for backward compatibility */ + for (trv = start;;) { + if (!*trv) + return (0); + if (*trv == 'z') + *trv++ = 'a'; + else { + if (isdigit((unsigned char)*trv)) + *trv = 'a'; + else + ++*trv; + break; + } + } + } + /*NOTREACHED*/ +} + + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> + +static time_t _zip_d2u_time(int, int); +static char *_zip_readfpstr(FILE *, unsigned int, int, struct zip_error *); +static char *_zip_readstr(unsigned char **, int, int, struct zip_error *); +static void _zip_u2d_time(time_t, unsigned short *, unsigned short *); +static void _zip_write2(unsigned short, FILE *); +static void _zip_write4(unsigned int, FILE *); + + + +void +_zip_cdir_free(struct zip_cdir *cd) +{ + int i; + + if (!cd) + return; + + for (i=0; i<cd->nentry; i++) + _zip_dirent_finalize(cd->entry+i); + free(cd->comment); + free(cd->entry); + free(cd); +} + + + +struct zip_cdir * +_zip_cdir_new(int nentry, struct zip_error *error) +{ + struct zip_cdir *cd; + + if ((cd=(struct zip_cdir *)malloc(sizeof(*cd))) == NULL) { + _zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + if ((cd->entry=(struct zip_dirent *)malloc(sizeof(*(cd->entry))*nentry)) + == NULL) { + _zip_error_set(error, ZIP_ER_MEMORY, 0); + free(cd); + return NULL; + } + + /* entries must be initialized by caller */ + + cd->nentry = nentry; + cd->size = cd->offset = 0; + cd->comment = NULL; + cd->comment_len = 0; + + return cd; +} + + + +int +_zip_cdir_write(struct zip_cdir *cd, FILE *fp, struct zip_error *error) +{ + int i; + + cd->offset = ftello(fp); + + for (i=0; i<cd->nentry; i++) { + if (_zip_dirent_write(cd->entry+i, fp, 0, error) != 0) + return -1; + } + + cd->size = ftello(fp) - cd->offset; + + /* clearerr(fp); */ + fwrite(EOCD_MAGIC, 1, 4, fp); + _zip_write4(0, fp); + _zip_write2((unsigned short)cd->nentry, fp); + _zip_write2((unsigned short)cd->nentry, fp); + _zip_write4(cd->size, fp); + _zip_write4(cd->offset, fp); + _zip_write2(cd->comment_len, fp); + fwrite(cd->comment, 1, cd->comment_len, fp); + + if (ferror(fp)) { + _zip_error_set(error, ZIP_ER_WRITE, errno); + return -1; + } + + return 0; +} + + + +void +_zip_dirent_finalize(struct zip_dirent *zde) +{ + free(zde->filename); + zde->filename = NULL; + free(zde->extrafield); + zde->extrafield = NULL; + free(zde->comment); + zde->comment = NULL; +} + + + +void +_zip_dirent_init(struct zip_dirent *de) +{ + de->version_madeby = 0; + de->version_needed = 20; /* 2.0 */ + de->bitflags = 0; + de->comp_method = 0; + de->last_mod = 0; + de->crc = 0; + de->comp_size = 0; + de->uncomp_size = 0; + de->filename = NULL; + de->filename_len = 0; + de->extrafield = NULL; + de->extrafield_len = 0; + de->comment = NULL; + de->comment_len = 0; + de->disk_number = 0; + de->int_attrib = 0; + de->ext_attrib = 0; + de->offset = 0; +} + + + +/* _zip_dirent_read(zde, fp, bufp, left, localp, error): + Fills the zip directory entry zde. + + If bufp is non-NULL, data is taken from there and bufp is advanced + by the amount of data used; no more than left bytes are used. + Otherwise data is read from fp as needed. + + If localp != 0, it reads a local header instead of a central + directory entry. + + Returns 0 if successful. On error, error is filled in and -1 is + returned. +*/ + +int +_zip_dirent_read(struct zip_dirent *zde, FILE *fp, + unsigned char **bufp, unsigned int left, int localp, + struct zip_error *error) +{ + unsigned char buf[CDENTRYSIZE]; + unsigned char *cur; + unsigned short dostime, dosdate; + unsigned int size; + + if (localp) + size = LENTRYSIZE; + else + size = CDENTRYSIZE; + + if (bufp) { + /* use data from buffer */ + cur = *bufp; + if (left < size) { + _zip_error_set(error, ZIP_ER_NOZIP, 0); + return -1; + } + } + else { + /* read entry from disk */ + if ((fread(buf, 1, size, fp)<size)) { + _zip_error_set(error, ZIP_ER_READ, errno); + return -1; + } + left = size; + cur = buf; + } + + if (memcmp(cur, (localp ? LOCAL_MAGIC : CENTRAL_MAGIC), 4) != 0) { + _zip_error_set(error, ZIP_ER_NOZIP, 0); + return -1; + } + cur += 4; + + + /* convert buffercontents to zip_dirent */ + + if (!localp) + zde->version_madeby = _zip_read2(&cur); + else + zde->version_madeby = 0; + zde->version_needed = _zip_read2(&cur); + zde->bitflags = _zip_read2(&cur); + zde->comp_method = _zip_read2(&cur); + + /* convert to time_t */ + dostime = _zip_read2(&cur); + dosdate = _zip_read2(&cur); + zde->last_mod = _zip_d2u_time(dostime, dosdate); + + zde->crc = _zip_read4(&cur); + zde->comp_size = _zip_read4(&cur); + zde->uncomp_size = _zip_read4(&cur); + + zde->filename_len = _zip_read2(&cur); + zde->extrafield_len = _zip_read2(&cur); + + if (localp) { + zde->comment_len = 0; + zde->disk_number = 0; + zde->int_attrib = 0; + zde->ext_attrib = 0; + zde->offset = 0; + } else { + zde->comment_len = _zip_read2(&cur); + zde->disk_number = _zip_read2(&cur); + zde->int_attrib = _zip_read2(&cur); + zde->ext_attrib = _zip_read4(&cur); + zde->offset = _zip_read4(&cur); + } + + zde->filename = NULL; + zde->extrafield = NULL; + zde->comment = NULL; + + if (bufp) { + if (left < CDENTRYSIZE + (zde->filename_len+zde->extrafield_len + +zde->comment_len)) { + _zip_error_set(error, ZIP_ER_NOZIP, 0); + return -1; + } + + if (zde->filename_len) { + zde->filename = _zip_readstr(&cur, zde->filename_len, 1, error); + if (!zde->filename) + return -1; + } + + if (zde->extrafield_len) { + zde->extrafield = _zip_readstr(&cur, zde->extrafield_len, 0, + error); + if (!zde->extrafield) + return -1; + } + + if (zde->comment_len) { + zde->comment = _zip_readstr(&cur, zde->comment_len, 0, error); + if (!zde->comment) + return -1; + } + } + else { + if (zde->filename_len) { + zde->filename = _zip_readfpstr(fp, zde->filename_len, 1, error); + if (!zde->filename) + return -1; + } + + if (zde->extrafield_len) { + zde->extrafield = _zip_readfpstr(fp, zde->extrafield_len, 0, + error); + if (!zde->extrafield) + return -1; + } + + if (zde->comment_len) { + zde->comment = _zip_readfpstr(fp, zde->comment_len, 0, error); + if (!zde->comment) + return -1; + } + } + + if (bufp) + *bufp = cur; + + return 0; +} + + + +/* _zip_dirent_torrent_normalize(de); + Set values suitable for torrentzip. +*/ + +void +_zip_dirent_torrent_normalize(struct zip_dirent *de) +{ + static struct tm torrenttime; + static time_t last_mod = 0; + + if (last_mod == 0) { +#ifdef HAVE_STRUCT_TM_TM_ZONE + time_t now; + struct tm *l; +#endif + + torrenttime.tm_sec = 0; + torrenttime.tm_min = 32; + torrenttime.tm_hour = 23; + torrenttime.tm_mday = 24; + torrenttime.tm_mon = 11; + torrenttime.tm_year = 96; + torrenttime.tm_wday = 0; + torrenttime.tm_yday = 0; + torrenttime.tm_isdst = 0; + +#ifdef HAVE_STRUCT_TM_TM_ZONE + time(&now); + l = localtime(&now); + torrenttime.tm_gmtoff = l->tm_gmtoff; + torrenttime.tm_zone = l->tm_zone; +#endif + + last_mod = mktime(&torrenttime); + } + + de->version_madeby = 0; + de->version_needed = 20; /* 2.0 */ + de->bitflags = 2; /* maximum compression */ + de->comp_method = ZIP_CM_DEFLATE; + de->last_mod = last_mod; + + de->disk_number = 0; + de->int_attrib = 0; + de->ext_attrib = 0; + de->offset = 0; + + free(de->extrafield); + de->extrafield = NULL; + de->extrafield_len = 0; + free(de->comment); + de->comment = NULL; + de->comment_len = 0; +} + + + +/* _zip_dirent_write(zde, fp, localp, error): + Writes zip directory entry zde to file fp. + + If localp != 0, it writes a local header instead of a central + directory entry. + + Returns 0 if successful. On error, error is filled in and -1 is + returned. +*/ + +int +_zip_dirent_write(struct zip_dirent *zde, FILE *fp, int localp, + struct zip_error *error) +{ + unsigned short dostime, dosdate; + + fwrite(localp ? LOCAL_MAGIC : CENTRAL_MAGIC, 1, 4, fp); + + if (!localp) + _zip_write2(zde->version_madeby, fp); + _zip_write2(zde->version_needed, fp); + _zip_write2(zde->bitflags, fp); + _zip_write2(zde->comp_method, fp); + + _zip_u2d_time(zde->last_mod, &dostime, &dosdate); + _zip_write2(dostime, fp); + _zip_write2(dosdate, fp); + + _zip_write4(zde->crc, fp); + _zip_write4(zde->comp_size, fp); + _zip_write4(zde->uncomp_size, fp); + + _zip_write2(zde->filename_len, fp); + _zip_write2(zde->extrafield_len, fp); + + if (!localp) { + _zip_write2(zde->comment_len, fp); + _zip_write2(zde->disk_number, fp); + _zip_write2(zde->int_attrib, fp); + _zip_write4(zde->ext_attrib, fp); + _zip_write4(zde->offset, fp); + } + + if (zde->filename_len) + fwrite(zde->filename, 1, zde->filename_len, fp); + + if (zde->extrafield_len) + fwrite(zde->extrafield, 1, zde->extrafield_len, fp); + + if (!localp) { + if (zde->comment_len) + fwrite(zde->comment, 1, zde->comment_len, fp); + } + + if (ferror(fp)) { + _zip_error_set(error, ZIP_ER_WRITE, errno); + return -1; + } + + return 0; +} + + + +static time_t +_zip_d2u_time(int dtime, int ddate) +{ + struct tm *tm; + time_t now; + + now = time(NULL); + tm = localtime(&now); + /* let mktime decide if DST is in effect */ + tm->tm_isdst = -1; + + tm->tm_year = ((ddate>>9)&127) + 1980 - 1900; + tm->tm_mon = ((ddate>>5)&15) - 1; + tm->tm_mday = ddate&31; + + tm->tm_hour = (dtime>>11)&31; + tm->tm_min = (dtime>>5)&63; + tm->tm_sec = (dtime<<1)&62; + + return mktime(tm); +} + + + +unsigned short +_zip_read2(unsigned char **a) +{ + unsigned short ret; + + ret = (*a)[0]+((*a)[1]<<8); + *a += 2; + + return ret; +} + + + +unsigned int +_zip_read4(unsigned char **a) +{ + unsigned int ret; + + ret = ((((((*a)[3]<<8)+(*a)[2])<<8)+(*a)[1])<<8)+(*a)[0]; + *a += 4; + + return ret; +} + + + +static char * +_zip_readfpstr(FILE *fp, unsigned int len, int nulp, struct zip_error *error) +{ + char *r, *o; + + r = (char *)malloc(nulp ? len+1 : len); + if (!r) { + _zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + if (fread(r, 1, len, fp)<len) { + free(r); + _zip_error_set(error, ZIP_ER_READ, errno); + return NULL; + } + + if (nulp) { + /* replace any in-string NUL characters with spaces */ + r[len] = 0; + for (o=r; o<r+len; o++) + if (*o == '\0') + *o = ' '; + } + + return r; +} + + + +static char * +_zip_readstr(unsigned char **buf, int len, int nulp, struct zip_error *error) +{ + char *r, *o; + + r = (char *)malloc(nulp ? len+1 : len); + if (!r) { + _zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + memcpy(r, *buf, len); + *buf += len; + + if (nulp) { + /* replace any in-string NUL characters with spaces */ + r[len] = 0; + for (o=r; o<r+len; o++) + if (*o == '\0') + *o = ' '; + } + + return r; +} + + + +static void +_zip_write2(unsigned short i, FILE *fp) +{ + putc(i&0xff, fp); + putc((i>>8)&0xff, fp); + + return; +} + + + +static void +_zip_write4(unsigned int i, FILE *fp) +{ + putc(i&0xff, fp); + putc((i>>8)&0xff, fp); + putc((i>>16)&0xff, fp); + putc((i>>24)&0xff, fp); + + return; +} + + + +static void +_zip_u2d_time(time_t time, unsigned short *dtime, unsigned short *ddate) +{ + struct tm *tm; + + tm = localtime(&time); + *ddate = ((tm->tm_year+1900-1980)<<9) + ((tm->tm_mon+1)<<5) + + tm->tm_mday; + *dtime = ((tm->tm_hour)<<11) + ((tm->tm_min)<<5) + + ((tm->tm_sec)>>1); + + return; +} + + + +ZIP_EXTERN int +zip_delete(struct zip *za, int idx) +{ + if (idx < 0 || idx >= za->nentry) { + _zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + /* allow duplicate file names, because the file will + * be removed directly afterwards */ + if (_zip_unchange(za, idx, 1) != 0) + return -1; + + za->entry[idx].state = ZIP_ST_DELETED; + + return 0; +} + + + +ZIP_EXTERN void +zip_error_clear(struct zip *za) +{ + _zip_error_clear(&za->error); +} + + +ZIP_EXTERN int +zip_add(struct zip *za, const char *name, struct zip_source *source) +{ + if (name == NULL || source == NULL) { + _zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + return _zip_replace(za, -1, name, source); +} + + +ZIP_EXTERN int +zip_error_get_sys_type(int ze) +{ + if (ze < 0 || ze >= _zip_nerr_str) + return 0; + + return _zip_err_type[ze]; +} + + +ZIP_EXTERN void +zip_error_get(struct zip *za, int *zep, int *sep) +{ + _zip_error_get(&za->error, zep, sep); +} + + +const char * const _zip_err_str[] = { + "No error", + "Multi-disk zip archives not supported", + "Renaming temporary file failed", + "Closing zip archive failed", + "Seek error", + "Read error", + "Write error", + "CRC error", + "Containing zip archive was closed", + "No such file", + "File already exists", + "Can't open file", + "Failure to create temporary file", + "Zlib error", + "Malloc failure", + "Entry has been changed", + "Compression method not supported", + "Premature EOF", + "Invalid argument", + "Not a zip archive", + "Internal error", + "Zip archive inconsistent", + "Can't remove file", + "Entry has been deleted", +}; + +const int _zip_nerr_str = sizeof(_zip_err_str)/sizeof(_zip_err_str[0]); + +#define N ZIP_ET_NONE +#define S ZIP_ET_SYS +#define Z ZIP_ET_ZLIB + +const int _zip_err_type[] = { + N, + N, + S, + S, + S, + S, + S, + N, + N, + N, + N, + S, + S, + Z, + N, + N, + N, + N, + N, + N, + N, + N, + S, + N, +}; + + +struct zip_entry * +_zip_entry_new(struct zip *za) +{ + struct zip_entry *ze; + if (!za) { + ze = (struct zip_entry *)malloc(sizeof(struct zip_entry)); + if (!ze) { + _zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return NULL; + } + } + else { + if (za->nentry >= za->nentry_alloc-1) { + za->nentry_alloc += 16; + za->entry = (struct zip_entry *)realloc(za->entry, + sizeof(struct zip_entry) + * za->nentry_alloc); + if (!za->entry) { + _zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return NULL; + } + } + ze = za->entry+za->nentry; + } + + ze->state = ZIP_ST_UNCHANGED; + + ze->ch_filename = NULL; + ze->ch_comment = NULL; + ze->ch_comment_len = -1; + ze->source = NULL; + + if (za) + za->nentry++; + + return ze; +} + + +void +_zip_entry_free(struct zip_entry *ze) +{ + free(ze->ch_filename); + ze->ch_filename = NULL; + free(ze->ch_comment); + ze->ch_comment = NULL; + ze->ch_comment_len = -1; + + _zip_unchange_data(ze); +} + + +static int add_data(struct zip *, struct zip_source *, struct zip_dirent *, + FILE *); +static int add_data_comp(zip_source_callback, void *, struct zip_stat *, + FILE *, struct zip_error *); +static int add_data_uncomp(struct zip *, zip_source_callback, void *, + struct zip_stat *, FILE *); +static void ch_set_error(struct zip_error *, zip_source_callback, void *); +static int copy_data(FILE *, myoff_t, FILE *, struct zip_error *); +static int write_cdir(struct zip *, struct zip_cdir *, FILE *); +static int _zip_cdir_set_comment(struct zip_cdir *, struct zip *); +static int _zip_changed(struct zip *, int *); +static char *_zip_create_temp_output(struct zip *, FILE **); +static int _zip_torrentzip_cmp(const void *, const void *); + + + +struct filelist { + int idx; + const char *name; +}; + + + +ZIP_EXTERN int +zip_close(struct zip *za) +{ + int survivors; + int i, j, error; + char *temp; + FILE *out; + mode_t mask; + struct zip_cdir *cd; + struct zip_dirent de; + struct filelist *filelist; + int reopen_on_error; + int new_torrentzip; + + reopen_on_error = 0; + + if (za == NULL) + return -1; + + if (!_zip_changed(za, &survivors)) { + _zip_free(za); + return 0; + } + + /* don't create zip files with no entries */ + if (survivors == 0) { + if (za->zn && za->zp) { + if (remove(za->zn) != 0) { + _zip_error_set(&za->error, ZIP_ER_REMOVE, errno); + return -1; + } + } + _zip_free(za); + return 0; + } + + if ((filelist=(struct filelist *)malloc(sizeof(filelist[0])*survivors)) + == NULL) + return -1; + + if ((cd=_zip_cdir_new(survivors, &za->error)) == NULL) { + free(filelist); + return -1; + } + + for (i=0; i<survivors; i++) + _zip_dirent_init(&cd->entry[i]); + + /* archive comment is special for torrentzip */ + if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0)) { + cd->comment = _zip_memdup(TORRENT_SIG "XXXXXXXX", + TORRENT_SIG_LEN + TORRENT_CRC_LEN, + &za->error); + if (cd->comment == NULL) { + _zip_cdir_free(cd); + free(filelist); + return -1; + } + cd->comment_len = TORRENT_SIG_LEN + TORRENT_CRC_LEN; + } + else if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, ZIP_FL_UNCHANGED) == 0) { + if (_zip_cdir_set_comment(cd, za) == -1) { + _zip_cdir_free(cd); + free(filelist); + return -1; + } + } + + if ((temp=_zip_create_temp_output(za, &out)) == NULL) { + _zip_cdir_free(cd); + return -1; + } + + + /* create list of files with index into original archive */ + for (i=j=0; i<za->nentry; i++) { + if (za->entry[i].state == ZIP_ST_DELETED) + continue; + + filelist[j].idx = i; + filelist[j].name = zip_get_name(za, i, 0); + j++; + } + if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0)) + qsort(filelist, survivors, sizeof(filelist[0]), + _zip_torrentzip_cmp); + + new_torrentzip = (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0) == 1 + && zip_get_archive_flag(za, ZIP_AFL_TORRENT, + ZIP_FL_UNCHANGED) == 0); + error = 0; + for (j=0; j<survivors; j++) { + i = filelist[j].idx; + + /* create new local directory entry */ + if (ZIP_ENTRY_DATA_CHANGED(za->entry+i) || new_torrentzip) { + _zip_dirent_init(&de); + + if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0)) + _zip_dirent_torrent_normalize(&de); + + /* use it as central directory entry */ + memcpy(cd->entry+j, &de, sizeof(cd->entry[j])); + + /* set/update file name */ + if (za->entry[i].ch_filename == NULL) { + if (za->entry[i].state == ZIP_ST_ADDED) { + de.filename = strdup("-"); + de.filename_len = 1; + cd->entry[j].filename = "-"; + } + else { + de.filename = strdup(za->cdir->entry[i].filename); + de.filename_len = strlen(de.filename); + cd->entry[j].filename = za->cdir->entry[i].filename; + cd->entry[j].filename_len = de.filename_len; + } + } + } + else { + /* copy existing directory entries */ + if (fseeko(za->zp, za->cdir->entry[i].offset, SEEK_SET) != 0) { + _zip_error_set(&za->error, ZIP_ER_SEEK, errno); + error = 1; + break; + } + if (_zip_dirent_read(&de, za->zp, NULL, 0, 1, &za->error) != 0) { + error = 1; + break; + } + if (de.bitflags & ZIP_GPBF_DATA_DESCRIPTOR) { + de.crc = za->cdir->entry[i].crc; + de.comp_size = za->cdir->entry[i].comp_size; + de.uncomp_size = za->cdir->entry[i].uncomp_size; + de.bitflags &= ~ZIP_GPBF_DATA_DESCRIPTOR; + } + memcpy(cd->entry+j, za->cdir->entry+i, sizeof(cd->entry[j])); + } + + if (za->entry[i].ch_filename) { + free(de.filename); + if ((de.filename=strdup(za->entry[i].ch_filename)) == NULL) { + error = 1; + break; + } + de.filename_len = strlen(de.filename); + cd->entry[j].filename = za->entry[i].ch_filename; + cd->entry[j].filename_len = de.filename_len; + } + + if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0) == 0 + && za->entry[i].ch_comment_len != -1) { + /* as the rest of cd entries, its malloc/free is done by za */ + cd->entry[j].comment = za->entry[i].ch_comment; + cd->entry[j].comment_len = za->entry[i].ch_comment_len; + } + + cd->entry[j].offset = ftello(out); + + if (ZIP_ENTRY_DATA_CHANGED(za->entry+i) || new_torrentzip) { + struct zip_source *zs; + + zs = NULL; + if (!ZIP_ENTRY_DATA_CHANGED(za->entry+i)) { + if ((zs=zip_source_zip(za, za, i, ZIP_FL_RECOMPRESS, 0, -1)) + == NULL) { + error = 1; + break; + } + } + + if (add_data(za, zs ? zs : za->entry[i].source, &de, out) < 0) { + error = 1; + break; + } + cd->entry[j].last_mod = de.last_mod; + cd->entry[j].comp_method = de.comp_method; + cd->entry[j].comp_size = de.comp_size; + cd->entry[j].uncomp_size = de.uncomp_size; + cd->entry[j].crc = de.crc; + } + else { + if (_zip_dirent_write(&de, out, 1, &za->error) < 0) { + error = 1; + break; + } + /* we just read the local dirent, file is at correct position */ + if (copy_data(za->zp, cd->entry[j].comp_size, out, + &za->error) < 0) { + error = 1; + break; + } + } + + _zip_dirent_finalize(&de); + } + + if (!error) { + if (write_cdir(za, cd, out) < 0) + error = 1; + } + + /* pointers in cd entries are owned by za */ + cd->nentry = 0; + _zip_cdir_free(cd); + + if (error) { + _zip_dirent_finalize(&de); + fclose(out); + remove(temp); + free(temp); + return -1; + } + + if (fclose(out) != 0) { + _zip_error_set(&za->error, ZIP_ER_CLOSE, errno); + remove(temp); + free(temp); + return -1; + } + + if (za->zp) { + fclose(za->zp); + za->zp = NULL; + reopen_on_error = 1; + } + if (_zip_rename(temp, za->zn) != 0) { + _zip_error_set(&za->error, ZIP_ER_RENAME, errno); + remove(temp); + free(temp); + if (reopen_on_error) { + /* ignore errors, since we're already in an error case */ + za->zp = fopen(za->zn, "rb"); + } + return -1; + } + mask = umask(0); + umask(mask); + chmod(za->zn, 0666&~mask); + + _zip_free(za); + free(temp); + + return 0; +} + + + +static int +add_data(struct zip *za, struct zip_source *zs, struct zip_dirent *de, FILE *ft) +{ + myoff_t offstart, offend; + zip_source_callback cb; + void *ud; + struct zip_stat st; + + cb = zs->f; + ud = zs->ud; + + if (cb(ud, &st, sizeof(st), ZIP_SOURCE_STAT) < (ssize_t)sizeof(st)) { + ch_set_error(&za->error, cb, ud); + return -1; + } + + if (cb(ud, NULL, 0, ZIP_SOURCE_OPEN) < 0) { + ch_set_error(&za->error, cb, ud); + return -1; + } + + offstart = ftello(ft); + + if (_zip_dirent_write(de, ft, 1, &za->error) < 0) + return -1; + + if (st.comp_method != ZIP_CM_STORE) { + if (add_data_comp(cb, ud, &st, ft, &za->error) < 0) + return -1; + } + else { + if (add_data_uncomp(za, cb, ud, &st, ft) < 0) + return -1; + } + + if (cb(ud, NULL, 0, ZIP_SOURCE_CLOSE) < 0) { + ch_set_error(&za->error, cb, ud); + return -1; + } + + offend = ftello(ft); + + if (fseeko(ft, offstart, SEEK_SET) < 0) { + _zip_error_set(&za->error, ZIP_ER_SEEK, errno); + return -1; + } + + + de->last_mod = st.mtime; + de->comp_method = st.comp_method; + de->crc = st.crc; + de->uncomp_size = st.size; + de->comp_size = st.comp_size; + + if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0)) + _zip_dirent_torrent_normalize(de); + + if (_zip_dirent_write(de, ft, 1, &za->error) < 0) + return -1; + + if (fseeko(ft, offend, SEEK_SET) < 0) { + _zip_error_set(&za->error, ZIP_ER_SEEK, errno); + return -1; + } + + return 0; +} + + + +static int +add_data_comp(zip_source_callback cb, void *ud, struct zip_stat *st,FILE *ft, + struct zip_error *error) +{ + char buf[BUFSIZE]; + ssize_t n; + + st->comp_size = 0; + while ((n=cb(ud, buf, sizeof(buf), ZIP_SOURCE_READ)) > 0) { + if (fwrite(buf, 1, n, ft) != (size_t)n) { + _zip_error_set(error, ZIP_ER_WRITE, errno); + return -1; + } + + st->comp_size += n; + } + if (n < 0) { + ch_set_error(error, cb, ud); + return -1; + } + + return 0; +} + + + +static int +add_data_uncomp(struct zip *za, zip_source_callback cb, void *ud, + struct zip_stat *st, FILE *ft) +{ + char b1[BUFSIZE], b2[BUFSIZE]; + int end, flush, ret; + ssize_t n; + size_t n2; + z_stream zstr; + int mem_level; + + st->comp_method = ZIP_CM_DEFLATE; + st->comp_size = st->size = 0; + st->crc = crc32(0, NULL, 0); + + zstr.zalloc = Z_NULL; + zstr.zfree = Z_NULL; + zstr.opaque = NULL; + zstr.avail_in = 0; + zstr.avail_out = 0; + + if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0)) + mem_level = TORRENT_MEM_LEVEL; + else + mem_level = MAX_MEM_LEVEL; + + /* -MAX_WBITS: undocumented feature of zlib to _not_ write a zlib header */ + deflateInit2(&zstr, Z_BEST_COMPRESSION, Z_DEFLATED, -MAX_WBITS, mem_level, + Z_DEFAULT_STRATEGY); + + zstr.next_out = (Bytef *)b2; + zstr.avail_out = sizeof(b2); + zstr.avail_in = 0; + + flush = 0; + end = 0; + while (!end) { + if (zstr.avail_in == 0 && !flush) { + if ((n=cb(ud, b1, sizeof(b1), ZIP_SOURCE_READ)) < 0) { + ch_set_error(&za->error, cb, ud); + deflateEnd(&zstr); + return -1; + } + if (n > 0) { + zstr.avail_in = n; + zstr.next_in = (Bytef *)b1; + st->size += n; + st->crc = crc32(st->crc, (Bytef *)b1, n); + } + else + flush = Z_FINISH; + } + + ret = deflate(&zstr, flush); + if (ret != Z_OK && ret != Z_STREAM_END) { + _zip_error_set(&za->error, ZIP_ER_ZLIB, ret); + return -1; + } + + if (zstr.avail_out != sizeof(b2)) { + n2 = sizeof(b2) - zstr.avail_out; + + if (fwrite(b2, 1, n2, ft) != n2) { + _zip_error_set(&za->error, ZIP_ER_WRITE, errno); + return -1; + } + + zstr.next_out = (Bytef *)b2; + zstr.avail_out = sizeof(b2); + st->comp_size += n2; + } + + if (ret == Z_STREAM_END) { + deflateEnd(&zstr); + end = 1; + } + } + + return 0; +} + + + +static void +ch_set_error(struct zip_error *error, zip_source_callback cb, void *ud) +{ + int e[2]; + + if ((cb(ud, e, sizeof(e), ZIP_SOURCE_ERROR)) < (ssize_t)sizeof(e)) { + error->zip_err = ZIP_ER_INTERNAL; + error->sys_err = 0; + } + else { + error->zip_err = e[0]; + error->sys_err = e[1]; + } +} + + + +static int +copy_data(FILE *fs, myoff_t len, FILE *ft, struct zip_error *error) +{ + char buf[BUFSIZE]; + int n, nn; + + if (len == 0) + return 0; + + while (len > 0) { + nn = len > sizeof(buf) ? sizeof(buf) : len; + if ((n=fread(buf, 1, nn, fs)) < 0) { + _zip_error_set(error, ZIP_ER_READ, errno); + return -1; + } + else if (n == 0) { + _zip_error_set(error, ZIP_ER_EOF, 0); + return -1; + } + + if (fwrite(buf, 1, n, ft) != (size_t)n) { + _zip_error_set(error, ZIP_ER_WRITE, errno); + return -1; + } + + len -= n; + } + + return 0; +} + + + +static int +write_cdir(struct zip *za, struct zip_cdir *cd, FILE *out) +{ + myoff_t offset; + uLong crc; + char buf[TORRENT_CRC_LEN+1]; + + if (_zip_cdir_write(cd, out, &za->error) < 0) + return -1; + + if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0) == 0) + return 0; + + + /* fix up torrentzip comment */ + + offset = ftello(out); + + if (_zip_filerange_crc(out, cd->offset, cd->size, &crc, &za->error) < 0) + return -1; + + snprintf(buf, sizeof(buf), "%08lX", (long)crc); + + if (fseeko(out, offset-TORRENT_CRC_LEN, SEEK_SET) < 0) { + _zip_error_set(&za->error, ZIP_ER_SEEK, errno); + return -1; + } + + if (fwrite(buf, TORRENT_CRC_LEN, 1, out) != 1) { + _zip_error_set(&za->error, ZIP_ER_WRITE, errno); + return -1; + } + + return 0; +} + + + +static int +_zip_cdir_set_comment(struct zip_cdir *dest, struct zip *src) +{ + if (src->ch_comment_len != -1) { + dest->comment = _zip_memdup(src->ch_comment, + src->ch_comment_len, &src->error); + if (dest->comment == NULL) + return -1; + dest->comment_len = src->ch_comment_len; + } else { + if (src->cdir && src->cdir->comment) { + dest->comment = _zip_memdup(src->cdir->comment, + src->cdir->comment_len, &src->error); + if (dest->comment == NULL) + return -1; + dest->comment_len = src->cdir->comment_len; + } + } + + return 0; +} + + + +static int +_zip_changed(struct zip *za, int *survivorsp) +{ + int changed, i, survivors; + + changed = survivors = 0; + + if (za->ch_comment_len != -1 + || za->ch_flags != za->flags) + changed = 1; + + for (i=0; i<za->nentry; i++) { + if ((za->entry[i].state != ZIP_ST_UNCHANGED) + || (za->entry[i].ch_comment_len != -1)) + changed = 1; + if (za->entry[i].state != ZIP_ST_DELETED) + survivors++; + } + + *survivorsp = survivors; + + return changed; +} + + + +static char * +_zip_create_temp_output(struct zip *za, FILE **outp) +{ + char *temp; + int tfd; + FILE *tfp; + + if ((temp=(char *)malloc(strlen(za->zn)+8)) == NULL) { + _zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return NULL; + } + + sprintf(temp, "%s.XXXXXX", za->zn); + + if ((tfd=mkstemp(temp)) == -1) { + _zip_error_set(&za->error, ZIP_ER_TMPOPEN, errno); + free(temp); + return NULL; + } + + if ((tfp=fdopen(tfd, "r+b")) == NULL) { + _zip_error_set(&za->error, ZIP_ER_TMPOPEN, errno); + close(tfd); + remove(temp); + free(temp); + return NULL; + } + + *outp = tfp; + return temp; +} + + + +static int +_zip_torrentzip_cmp(const void *a, const void *b) +{ + return strcasecmp(((const struct filelist *)a)->name, + ((const struct filelist *)b)->name); +} + + + +ZIP_EXTERN int +zip_add_dir(struct zip *za, const char *name) +{ + int len, ret; + char *s; + struct zip_source *source; + + if (name == NULL) { + _zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + s = NULL; + len = strlen(name); + + if (name[len-1] != '/') { + if ((s=(char *)malloc(len+2)) == NULL) { + _zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return -1; + } + strcpy(s, name); + s[len] = '/'; + s[len+1] = '\0'; + } + + if ((source=zip_source_buffer(za, NULL, 0, 0)) == NULL) { + free(s); + return -1; + } + + ret = _zip_replace(za, -1, s ? s : name, source); + + free(s); + if (ret < 0) + zip_source_free(source); + + return ret; +} + + +ZIP_EXTERN int +zip_error_to_str(char *buf, size_t len, int ze, int se) +{ + const char *zs, *ss; + + if (ze < 0 || ze >= _zip_nerr_str) + return snprintf(buf, len, "Unknown error %d", ze); + + zs = _zip_err_str[ze]; + + switch (_zip_err_type[ze]) { + case ZIP_ET_SYS: + ss = strerror(se); + break; + + case ZIP_ET_ZLIB: + ss = zError(se); + break; + + default: + ss = NULL; + } + + return snprintf(buf, len, "%s%s%s", + zs, (ss ? ": " : ""), (ss ? ss : "")); +} + + +ZIP_EXTERN void +zip_file_error_clear(struct zip_file *zf) +{ + _zip_error_clear(&zf->error); +} + + +ZIP_EXTERN int +zip_fclose(struct zip_file *zf) +{ + int i, ret; + + if (zf->zstr) + inflateEnd(zf->zstr); + free(zf->buffer); + free(zf->zstr); + + for (i=0; i<zf->za->nfile; i++) { + if (zf->za->file[i] == zf) { + zf->za->file[i] = zf->za->file[zf->za->nfile-1]; + zf->za->nfile--; + break; + } + } + + ret = 0; + if (zf->error.zip_err) + ret = zf->error.zip_err; + else if ((zf->flags & ZIP_ZF_CRC) && (zf->flags & ZIP_ZF_EOF)) { + /* if EOF, compare CRC */ + if (zf->crc_orig != zf->crc) + ret = ZIP_ER_CRC; + } + + free(zf); + return ret; +} + + +int +_zip_filerange_crc(FILE *fp, myoff_t start, myoff_t len, uLong *crcp, + struct zip_error *errp) +{ + Bytef buf[BUFSIZE]; + size_t n; + + *crcp = crc32(0L, Z_NULL, 0); + + if (fseeko(fp, start, SEEK_SET) != 0) { + _zip_error_set(errp, ZIP_ER_SEEK, errno); + return -1; + } + + while (len > 0) { + n = len > BUFSIZE ? BUFSIZE : len; + if ((n=fread(buf, 1, n, fp)) <= 0) { + _zip_error_set(errp, ZIP_ER_READ, errno); + return -1; + } + + *crcp = crc32(*crcp, buf, n); + + len-= n; + } + + return 0; +} + + +ZIP_EXTERN const char * +zip_file_strerror(struct zip_file *zf) +{ + return _zip_error_strerror(&zf->error); +} + + +/* _zip_file_get_offset(za, ze): + Returns the offset of the file data for entry ze. + + On error, fills in za->error and returns 0. +*/ + +unsigned int +_zip_file_get_offset(struct zip *za, int idx) +{ + struct zip_dirent de; + unsigned int offset; + + offset = za->cdir->entry[idx].offset; + + if (fseeko(za->zp, offset, SEEK_SET) != 0) { + _zip_error_set(&za->error, ZIP_ER_SEEK, errno); + return 0; + } + + if (_zip_dirent_read(&de, za->zp, NULL, 0, 1, &za->error) != 0) + return 0; + + offset += LENTRYSIZE + de.filename_len + de.extrafield_len; + + _zip_dirent_finalize(&de); + + return offset; +} + + +ZIP_EXTERN void +zip_file_error_get(struct zip_file *zf, int *zep, int *sep) +{ + _zip_error_get(&zf->error, zep, sep); +} + + +static struct zip_file *_zip_file_new(struct zip *za); + + + +ZIP_EXTERN struct zip_file * +zip_fopen_index(struct zip *za, int fileno, int flags) +{ + int len, ret; + int zfflags; + struct zip_file *zf; + + if ((fileno < 0) || (fileno >= za->nentry)) { + _zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return NULL; + } + + if ((flags & ZIP_FL_UNCHANGED) == 0 + && ZIP_ENTRY_DATA_CHANGED(za->entry+fileno)) { + _zip_error_set(&za->error, ZIP_ER_CHANGED, 0); + return NULL; + } + + if (fileno >= za->cdir->nentry) { + _zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return NULL; + } + + zfflags = 0; + switch (za->cdir->entry[fileno].comp_method) { + case ZIP_CM_STORE: + zfflags |= ZIP_ZF_CRC; + break; + + case ZIP_CM_DEFLATE: + if ((flags & ZIP_FL_COMPRESSED) == 0) + zfflags |= ZIP_ZF_CRC | ZIP_ZF_DECOMP; + break; + default: + if ((flags & ZIP_FL_COMPRESSED) == 0) { + _zip_error_set(&za->error, ZIP_ER_COMPNOTSUPP, 0); + return NULL; + } + break; + } + + zf = _zip_file_new(za); + + zf->flags = zfflags; + /* zf->name = za->cdir->entry[fileno].filename; */ + zf->method = za->cdir->entry[fileno].comp_method; + zf->bytes_left = za->cdir->entry[fileno].uncomp_size; + zf->cbytes_left = za->cdir->entry[fileno].comp_size; + zf->crc_orig = za->cdir->entry[fileno].crc; + + if ((zf->fpos=_zip_file_get_offset(za, fileno)) == 0) { + zip_fclose(zf); + return NULL; + } + + if ((zf->flags & ZIP_ZF_DECOMP) == 0) + zf->bytes_left = zf->cbytes_left; + else { + if ((zf->buffer=(char *)malloc(BUFSIZE)) == NULL) { + _zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + zip_fclose(zf); + return NULL; + } + + len = _zip_file_fillbuf(zf->buffer, BUFSIZE, zf); + if (len <= 0) { + _zip_error_copy(&za->error, &zf->error); + zip_fclose(zf); + return NULL; + } + + if ((zf->zstr = (z_stream *)malloc(sizeof(z_stream))) == NULL) { + _zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + zip_fclose(zf); + return NULL; + } + zf->zstr->zalloc = Z_NULL; + zf->zstr->zfree = Z_NULL; + zf->zstr->opaque = NULL; + zf->zstr->next_in = (Bytef *)zf->buffer; + zf->zstr->avail_in = len; + + /* negative value to tell zlib that there is no header */ + if ((ret=inflateInit2(zf->zstr, -MAX_WBITS)) != Z_OK) { + _zip_error_set(&za->error, ZIP_ER_ZLIB, ret); + zip_fclose(zf); + return NULL; + } + } + + return zf; +} + + + +int +_zip_file_fillbuf(void *buf, size_t buflen, struct zip_file *zf) +{ + int i, j; + + if (zf->error.zip_err != ZIP_ER_OK) + return -1; + + if ((zf->flags & ZIP_ZF_EOF) || zf->cbytes_left <= 0 || buflen <= 0) + return 0; + + if (fseeko(zf->za->zp, zf->fpos, SEEK_SET) < 0) { + _zip_error_set(&zf->error, ZIP_ER_SEEK, errno); + return -1; + } + if (buflen < zf->cbytes_left) + i = buflen; + else + i = zf->cbytes_left; + + j = fread(buf, 1, i, zf->za->zp); + if (j == 0) { + _zip_error_set(&zf->error, ZIP_ER_EOF, 0); + j = -1; + } + else if (j < 0) + _zip_error_set(&zf->error, ZIP_ER_READ, errno); + else { + zf->fpos += j; + zf->cbytes_left -= j; + } + + return j; +} + + + +static struct zip_file * +_zip_file_new(struct zip *za) +{ + struct zip_file *zf, **file; + int n; + + if ((zf=(struct zip_file *)malloc(sizeof(struct zip_file))) == NULL) { + _zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return NULL; + } + + if (za->nfile >= za->nfile_alloc-1) { + n = za->nfile_alloc + 10; + file = (struct zip_file **)realloc(za->file, + n*sizeof(struct zip_file *)); + if (file == NULL) { + _zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + free(zf); + return NULL; + } + za->nfile_alloc = n; + za->file = file; + } + + za->file[za->nfile++] = zf; + + zf->za = za; + _zip_error_init(&zf->error); + zf->flags = 0; + zf->crc = crc32(0L, Z_NULL, 0); + zf->crc_orig = 0; + zf->method = -1; + zf->bytes_left = zf->cbytes_left = 0; + zf->fpos = 0; + zf->buffer = NULL; + zf->zstr = NULL; + + return zf; +} + + +ZIP_EXTERN struct zip_file * +zip_fopen(struct zip *za, const char *fname, int flags) +{ + int idx; + + if ((idx=zip_name_locate(za, fname, flags)) < 0) + return NULL; + + return zip_fopen_index(za, idx, flags); +} + + +ZIP_EXTERN int +zip_set_file_comment(struct zip *za, int idx, const char *comment, int len) +{ + char *tmpcom; + + if (idx < 0 || idx >= za->nentry + || len < 0 || len > MAXCOMLEN + || (len > 0 && comment == NULL)) { + _zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + if (len > 0) { + if ((tmpcom=(char *)_zip_memdup(comment, len, &za->error)) == NULL) + return -1; + } + else + tmpcom = NULL; + + free(za->entry[idx].ch_comment); + za->entry[idx].ch_comment = tmpcom; + za->entry[idx].ch_comment_len = len; + + return 0; +} + + +ZIP_EXTERN struct zip_source * +zip_source_file(struct zip *za, const char *fname, myoff_t start, myoff_t len) +{ + if (za == NULL) + return NULL; + + if (fname == NULL || start < 0 || len < -1) { + _zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return NULL; + } + + return _zip_source_file_or_p(za, fname, NULL, start, len); +} + + +struct read_data { + const char *buf, *data, *end; + time_t mtime; + int freep; +}; + +static ssize_t read_data(void *state, void *data, size_t len, + enum zip_source_cmd cmd); + + + +ZIP_EXTERN struct zip_source * +zip_source_buffer(struct zip *za, const void *data, myoff_t len, int freep) +{ + struct read_data *f; + struct zip_source *zs; + + if (za == NULL) + return NULL; + + if (len < 0 || (data == NULL && len > 0)) { + _zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return NULL; + } + + if ((f=(struct read_data *)malloc(sizeof(*f))) == NULL) { + _zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return NULL; + } + + f->data = (const char *)data; + f->end = ((const char *)data)+len; + f->freep = freep; + f->mtime = time(NULL); + + if ((zs=zip_source_function(za, read_data, f)) == NULL) { + free(f); + return NULL; + } + + return zs; +} + + + +static ssize_t +read_data(void *state, void *data, size_t len, enum zip_source_cmd cmd) +{ + struct read_data *z; + char *buf; + size_t n; + + z = (struct read_data *)state; + buf = (char *)data; + + switch (cmd) { + case ZIP_SOURCE_OPEN: + z->buf = z->data; + return 0; + + case ZIP_SOURCE_READ: + n = z->end - z->buf; + if (n > len) + n = len; + + if (n) { + memcpy(buf, z->buf, n); + z->buf += n; + } + + return n; + + case ZIP_SOURCE_CLOSE: + return 0; + + case ZIP_SOURCE_STAT: + { + struct zip_stat *st; + + if (len < sizeof(*st)) + return -1; + + st = (struct zip_stat *)data; + + zip_stat_init(st); + st->mtime = z->mtime; + st->size = z->end - z->data; + + return sizeof(*st); + } + + case ZIP_SOURCE_ERROR: + { + int *e; + + if (len < sizeof(int)*2) + return -1; + + e = (int *)data; + e[0] = e[1] = 0; + } + return sizeof(int)*2; + + case ZIP_SOURCE_FREE: + if (z->freep) { + free((void *)z->data); + z->data = NULL; + } + free(z); + return 0; + + default: + ; + } + + return -1; +} + + +int +_zip_set_name(struct zip *za, int idx, const char *name) +{ + char *s; + int i; + + if (idx < 0 || idx >= za->nentry || name == NULL) { + _zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + if ((i=_zip_name_locate(za, name, 0, NULL)) != -1 && i != idx) { + _zip_error_set(&za->error, ZIP_ER_EXISTS, 0); + return -1; + } + + /* no effective name change */ + if (i == idx) + return 0; + + if ((s=strdup(name)) == NULL) { + _zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return -1; + } + + if (za->entry[idx].state == ZIP_ST_UNCHANGED) + za->entry[idx].state = ZIP_ST_RENAMED; + + free(za->entry[idx].ch_filename); + za->entry[idx].ch_filename = s; + + return 0; +} + + +ZIP_EXTERN int +zip_set_archive_flag(struct zip *za, int flag, int value) +{ + if (value) + za->ch_flags |= flag; + else + za->ch_flags &= ~flag; + + return 0; +} + + +void +_zip_unchange_data(struct zip_entry *ze) +{ + if (ze->source) { + (void)ze->source->f(ze->source->ud, NULL, 0, ZIP_SOURCE_FREE); + free(ze->source); + ze->source = NULL; + } + + ze->state = ze->ch_filename ? ZIP_ST_RENAMED : ZIP_ST_UNCHANGED; +} + + +ZIP_EXTERN int +zip_unchange_archive(struct zip *za) +{ + free(za->ch_comment); + za->ch_comment = NULL; + za->ch_comment_len = -1; + + za->ch_flags = za->flags; + + return 0; +} + +ZIP_EXTERN int +zip_unchange(struct zip *za, int idx) +{ + return _zip_unchange(za, idx, 0); +} + + + +int +_zip_unchange(struct zip *za, int idx, int allow_duplicates) +{ + int i; + + if (idx < 0 || idx >= za->nentry) { + _zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + if (za->entry[idx].ch_filename) { + if (!allow_duplicates) { + i = _zip_name_locate(za, + _zip_get_name(za, idx, ZIP_FL_UNCHANGED, NULL), + 0, NULL); + if (i != -1 && i != idx) { + _zip_error_set(&za->error, ZIP_ER_EXISTS, 0); + return -1; + } + } + + free(za->entry[idx].ch_filename); + za->entry[idx].ch_filename = NULL; + } + + free(za->entry[idx].ch_comment); + za->entry[idx].ch_comment = NULL; + za->entry[idx].ch_comment_len = -1; + + _zip_unchange_data(za->entry+idx); + + return 0; +} + +ZIP_EXTERN int +zip_unchange_all(struct zip *za) +{ + int ret, i; + + ret = 0; + for (i=0; i<za->nentry; i++) + ret |= _zip_unchange(za, i, 1); + + ret |= zip_unchange_archive(za); + + return ret; +} + + +ZIP_EXTERN int +zip_set_archive_comment(struct zip *za, const char *comment, int len) +{ + char *tmpcom; + + if (len < 0 || len > MAXCOMLEN + || (len > 0 && comment == NULL)) { + _zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + if (len > 0) { + if ((tmpcom=(char *)_zip_memdup(comment, len, &za->error)) == NULL) + return -1; + } + else + tmpcom = NULL; + + free(za->ch_comment); + za->ch_comment = tmpcom; + za->ch_comment_len = len; + + return 0; +} + + +ZIP_EXTERN int +zip_replace(struct zip *za, int idx, struct zip_source *source) +{ + if (idx < 0 || idx >= za->nentry || source == NULL) { + _zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + if (_zip_replace(za, idx, NULL, source) == -1) + return -1; + + return 0; +} + + + + +int +_zip_replace(struct zip *za, int idx, const char *name, + struct zip_source *source) +{ + if (idx == -1) { + if (_zip_entry_new(za) == NULL) + return -1; + + idx = za->nentry - 1; + } + + _zip_unchange_data(za->entry+idx); + + if (name && _zip_set_name(za, idx, name) != 0) + return -1; + + za->entry[idx].state = ((za->cdir == NULL || idx >= za->cdir->nentry) + ? ZIP_ST_ADDED : ZIP_ST_REPLACED); + za->entry[idx].source = source; + + return idx; +} + + +ZIP_EXTERN int +zip_rename(struct zip *za, int idx, const char *name) +{ + const char *old_name; + int old_is_dir, new_is_dir; + + if (idx >= za->nentry || idx < 0 || name[0] == '\0') { + _zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + if ((old_name=zip_get_name(za, idx, 0)) == NULL) + return -1; + + new_is_dir = (name[strlen(name)-1] == '/'); + old_is_dir = (old_name[strlen(old_name)-1] == '/'); + + if (new_is_dir != old_is_dir) { + _zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + return _zip_set_name(za, idx, name); +} + +#include <sys/stat.h> +#include <errno.h> +#include <limits.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +static void set_error(int *, struct zip_error *, int); +static struct zip *_zip_allocate_new(const char *, int *); +static int _zip_checkcons(FILE *, struct zip_cdir *, struct zip_error *); +static void _zip_check_torrentzip(struct zip *); +static struct zip_cdir *_zip_find_central_dir(FILE *, int, int *, myoff_t); +static int _zip_file_exists(const char *, int, int *); +static int _zip_headercomp(struct zip_dirent *, int, + struct zip_dirent *, int); +static unsigned char *_zip_memmem(const unsigned char *, int, + const unsigned char *, int); +static struct zip_cdir *_zip_readcdir(FILE *, unsigned char *, unsigned char *, + int, int, struct zip_error *); + + + +ZIP_EXTERN struct zip * +zip_open(const char *fn, int flags, int *zep) +{ + FILE *fp; + struct zip *za; + struct zip_cdir *cdir; + int i; + myoff_t len; + + switch (_zip_file_exists(fn, flags, zep)) { + case -1: + return NULL; + case 0: + return _zip_allocate_new(fn, zep); + default: + break; + } + + if ((fp=fopen(fn, "rb")) == NULL) { + set_error(zep, NULL, ZIP_ER_OPEN); + return NULL; + } + + fseeko(fp, 0, SEEK_END); + len = ftello(fp); + + /* treat empty files as empty archives */ + if (len == 0) { + if ((za=_zip_allocate_new(fn, zep)) == NULL) + fclose(fp); + else + za->zp = fp; + return za; + } + + cdir = _zip_find_central_dir(fp, flags, zep, len); + if (cdir == NULL) { + fclose(fp); + return NULL; + } + + if ((za=_zip_allocate_new(fn, zep)) == NULL) { + _zip_cdir_free(cdir); + fclose(fp); + return NULL; + } + + za->cdir = cdir; + za->zp = fp; + + if ((za->entry=(struct zip_entry *)malloc(sizeof(*(za->entry)) + * cdir->nentry)) == NULL) { + set_error(zep, NULL, ZIP_ER_MEMORY); + _zip_free(za); + return NULL; + } + for (i=0; i<cdir->nentry; i++) + _zip_entry_new(za); + + _zip_check_torrentzip(za); + za->ch_flags = za->flags; + + return za; +} + + + +static void +set_error(int *zep, struct zip_error *err, int ze) +{ + int se; + + if (err) { + _zip_error_get(err, &ze, &se); + if (zip_error_get_sys_type(ze) == ZIP_ET_SYS) + errno = se; + } + + if (zep) + *zep = ze; +} + + + +/* _zip_readcdir: + tries to find a valid end-of-central-directory at the beginning of + buf, and then the corresponding central directory entries. + Returns a struct zip_cdir which contains the central directory + entries, or NULL if unsuccessful. */ + +static struct zip_cdir * +_zip_readcdir(FILE *fp, unsigned char *buf, unsigned char *eocd, int buflen, + int flags, struct zip_error *error) +{ + struct zip_cdir *cd; + unsigned char *cdp, **bufp; + int i, comlen, nentry; + + comlen = buf + buflen - eocd - EOCDLEN; + if (comlen < 0) { + /* not enough bytes left for comment */ + _zip_error_set(error, ZIP_ER_NOZIP, 0); + return NULL; + } + + /* check for end-of-central-dir magic */ + if (memcmp(eocd, EOCD_MAGIC, 4) != 0) { + _zip_error_set(error, ZIP_ER_NOZIP, 0); + return NULL; + } + + if (memcmp(eocd+4, "\0\0\0\0", 4) != 0) { + _zip_error_set(error, ZIP_ER_MULTIDISK, 0); + return NULL; + } + + cdp = eocd + 8; + /* number of cdir-entries on this disk */ + i = _zip_read2(&cdp); + /* number of cdir-entries */ + nentry = _zip_read2(&cdp); + + if ((cd=_zip_cdir_new(nentry, error)) == NULL) + return NULL; + + cd->size = _zip_read4(&cdp); + cd->offset = _zip_read4(&cdp); + cd->comment = NULL; + cd->comment_len = _zip_read2(&cdp); + + if ((comlen < cd->comment_len) || (cd->nentry != i)) { + _zip_error_set(error, ZIP_ER_NOZIP, 0); + free(cd); + return NULL; + } + if ((flags & ZIP_CHECKCONS) && comlen != cd->comment_len) { + _zip_error_set(error, ZIP_ER_INCONS, 0); + free(cd); + return NULL; + } + + if (cd->comment_len) { + if ((cd->comment=(char *)_zip_memdup(eocd+EOCDLEN, + cd->comment_len, error)) + == NULL) { + free(cd); + return NULL; + } + } + + cdp = eocd; + if (cd->size < (unsigned int)(eocd-buf)) { + /* if buffer already read in, use it */ + cdp = eocd - cd->size; + bufp = &cdp; + } + else { + /* go to start of cdir and read it entry by entry */ + bufp = NULL; + clearerr(fp); + fseeko(fp, cd->offset, SEEK_SET); + /* possible consistency check: cd->offset = + len-(cd->size+cd->comment_len+EOCDLEN) ? */ + if (ferror(fp) || ((unsigned long)ftello(fp) != cd->offset)) { + /* seek error or offset of cdir wrong */ + if (ferror(fp)) + _zip_error_set(error, ZIP_ER_SEEK, errno); + else + _zip_error_set(error, ZIP_ER_NOZIP, 0); + free(cd); + return NULL; + } + } + + for (i=0; i<cd->nentry; i++) { + if ((_zip_dirent_read(cd->entry+i, fp, bufp, eocd-cdp, 0, + error)) < 0) { + cd->nentry = i; + _zip_cdir_free(cd); + return NULL; + } + } + + return cd; +} + + + +/* _zip_checkcons: + Checks the consistency of the central directory by comparing central + directory entries with local headers and checking for plausible + file and header offsets. Returns -1 if not plausible, else the + difference between the lowest and the highest fileposition reached */ + +static int +_zip_checkcons(FILE *fp, struct zip_cdir *cd, struct zip_error *error) +{ + int i; + unsigned int min, max, j; + struct zip_dirent temp; + + if (cd->nentry) { + max = cd->entry[0].offset; + min = cd->entry[0].offset; + } + else + min = max = 0; + + for (i=0; i<cd->nentry; i++) { + if (cd->entry[i].offset < min) + min = cd->entry[i].offset; + if (min > cd->offset) { + _zip_error_set(error, ZIP_ER_NOZIP, 0); + return -1; + } + + j = cd->entry[i].offset + cd->entry[i].comp_size + + cd->entry[i].filename_len + LENTRYSIZE; + if (j > max) + max = j; + if (max > cd->offset) { + _zip_error_set(error, ZIP_ER_NOZIP, 0); + return -1; + } + + if (fseeko(fp, cd->entry[i].offset, SEEK_SET) != 0) { + _zip_error_set(error, ZIP_ER_SEEK, 0); + return -1; + } + + if (_zip_dirent_read(&temp, fp, NULL, 0, 1, error) == -1) + return -1; + + if (_zip_headercomp(cd->entry+i, 0, &temp, 1) != 0) { + _zip_error_set(error, ZIP_ER_INCONS, 0); + _zip_dirent_finalize(&temp); + return -1; + } + _zip_dirent_finalize(&temp); + } + + return max - min; +} + + + +/* _zip_check_torrentzip: + check wether ZA has a valid TORRENTZIP comment, i.e. is torrentzipped */ + +static void +_zip_check_torrentzip(struct zip *za) +{ + uLong crc_got, crc_should; + char buf[8+1]; + char *end; + + if (za->zp == NULL || za->cdir == NULL) + return; + + if (za->cdir->comment_len != TORRENT_SIG_LEN+8 + || strncmp(za->cdir->comment, TORRENT_SIG, TORRENT_SIG_LEN) != 0) + return; + + memcpy(buf, za->cdir->comment+TORRENT_SIG_LEN, 8); + buf[8] = '\0'; + errno = 0; + crc_should = strtoul(buf, &end, 16); + if ((crc_should == UINT_MAX && errno != 0) || (end && *end)) + return; + + if (_zip_filerange_crc(za->zp, za->cdir->offset, za->cdir->size, + &crc_got, NULL) < 0) + return; + + if (crc_got == crc_should) + za->flags |= ZIP_AFL_TORRENT; +} + + + + +/* _zip_headercomp: + compares two headers h1 and h2; if they are local headers, set + local1p or local2p respectively to 1, else 0. Return 0 if they + are identical, -1 if not. */ + +static int +_zip_headercomp(struct zip_dirent *h1, int local1p, struct zip_dirent *h2, + int local2p) +{ + if ((h1->version_needed != h2->version_needed) +#if 0 + /* some zip-files have different values in local + and global headers for the bitflags */ + || (h1->bitflags != h2->bitflags) +#endif + || (h1->comp_method != h2->comp_method) + || (h1->last_mod != h2->last_mod) + || (h1->filename_len != h2->filename_len) + || !h1->filename || !h2->filename + || strcmp(h1->filename, h2->filename)) + return -1; + + /* check that CRC and sizes are zero if data descriptor is used */ + if ((h1->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) && local1p + && (h1->crc != 0 + || h1->comp_size != 0 + || h1->uncomp_size != 0)) + return -1; + if ((h2->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) && local2p + && (h2->crc != 0 + || h2->comp_size != 0 + || h2->uncomp_size != 0)) + return -1; + + /* check that CRC and sizes are equal if no data descriptor is used */ + if (((h1->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) == 0 || local1p == 0) + && ((h2->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) == 0 || local2p == 0)) { + if ((h1->crc != h2->crc) + || (h1->comp_size != h2->comp_size) + || (h1->uncomp_size != h2->uncomp_size)) + return -1; + } + + if ((local1p == local2p) + && ((h1->extrafield_len != h2->extrafield_len) + || (h1->extrafield_len && h2->extrafield + && memcmp(h1->extrafield, h2->extrafield, + h1->extrafield_len)))) + return -1; + + /* if either is local, nothing more to check */ + if (local1p || local2p) + return 0; + + if ((h1->version_madeby != h2->version_madeby) + || (h1->disk_number != h2->disk_number) + || (h1->int_attrib != h2->int_attrib) + || (h1->ext_attrib != h2->ext_attrib) + || (h1->offset != h2->offset) + || (h1->comment_len != h2->comment_len) + || (h1->comment_len && h2->comment + && memcmp(h1->comment, h2->comment, h1->comment_len))) + return -1; + + return 0; +} + + + +static struct zip * +_zip_allocate_new(const char *fn, int *zep) +{ + struct zip *za; + struct zip_error error; + + if ((za=_zip_new(&error)) == NULL) { + set_error(zep, &error, 0); + return NULL; + } + + za->zn = strdup(fn); + if (!za->zn) { + _zip_free(za); + set_error(zep, NULL, ZIP_ER_MEMORY); + return NULL; + } + return za; +} + + + +static int +_zip_file_exists(const char *fn, int flags, int *zep) +{ + struct stat st; + + if (fn == NULL) { + set_error(zep, NULL, ZIP_ER_INVAL); + return -1; + } + + if (stat(fn, &st) != 0) { + if (flags & ZIP_CREATE) + return 0; + else { + set_error(zep, NULL, ZIP_ER_OPEN); + return -1; + } + } + else if ((flags & ZIP_EXCL)) { + set_error(zep, NULL, ZIP_ER_EXISTS); + return -1; + } + /* ZIP_CREATE gets ignored if file exists and not ZIP_EXCL, + just like open() */ + + return 1; +} + + + +static struct zip_cdir * +_zip_find_central_dir(FILE *fp, int flags, int *zep, myoff_t len) +{ + struct zip_cdir *cdir, *cdirnew; + unsigned char *buf, *match; + int a, best, buflen, i; + struct zip_error zerr; + + i = fseeko(fp, -(len < CDBUFSIZE ? len : CDBUFSIZE), SEEK_END); + if (i == -1 && errno != EFBIG) { + /* seek before start of file on my machine */ + set_error(zep, NULL, ZIP_ER_SEEK); + return NULL; + } + + /* 64k is too much for stack */ + if ((buf=(unsigned char *)malloc(CDBUFSIZE)) == NULL) { + set_error(zep, NULL, ZIP_ER_MEMORY); + return NULL; + } + + clearerr(fp); + buflen = fread(buf, 1, CDBUFSIZE, fp); + + if (ferror(fp)) { + set_error(zep, NULL, ZIP_ER_READ); + free(buf); + return NULL; + } + + best = -1; + cdir = NULL; + match = buf; + _zip_error_set(&zerr, ZIP_ER_NOZIP, 0); + + while ((match=_zip_memmem(match, buflen-(match-buf)-18, + (const unsigned char *)EOCD_MAGIC, 4))!=NULL) { + /* found match -- check, if good */ + /* to avoid finding the same match all over again */ + match++; + if ((cdirnew=_zip_readcdir(fp, buf, match-1, buflen, flags, + &zerr)) == NULL) + continue; + + if (cdir) { + if (best <= 0) + best = _zip_checkcons(fp, cdir, &zerr); + a = _zip_checkcons(fp, cdirnew, &zerr); + if (best < a) { + _zip_cdir_free(cdir); + cdir = cdirnew; + best = a; + } + else + _zip_cdir_free(cdirnew); + } + else { + cdir = cdirnew; + if (flags & ZIP_CHECKCONS) + best = _zip_checkcons(fp, cdir, &zerr); + else + best = 0; + } + cdirnew = NULL; + } + + free(buf); + + if (best < 0) { + set_error(zep, &zerr, 0); + _zip_cdir_free(cdir); + return NULL; + } + + return cdir; +} + + + +static unsigned char * +_zip_memmem(const unsigned char *big, int biglen, const unsigned char *little, + int littlelen) +{ + const unsigned char *p; + + if ((biglen < littlelen) || (littlelen == 0)) + return NULL; + p = big-1; + while ((p=(const unsigned char *) + memchr(p+1, little[0], (size_t)(big-(p+1)+biglen-littlelen+1))) + != NULL) { + if (memcmp(p+1, little+1, littlelen-1)==0) + return (unsigned char *)p; + } + + return NULL; +} + + +/* _zip_new: + creates a new zipfile struct, and sets the contents to zero; returns + the new struct. */ + +struct zip * +_zip_new(struct zip_error *error) +{ + struct zip *za; + + za = (struct zip *)malloc(sizeof(struct zip)); + if (!za) { + _zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + za->zn = NULL; + za->zp = NULL; + _zip_error_init(&za->error); + za->cdir = NULL; + za->ch_comment = NULL; + za->ch_comment_len = -1; + za->nentry = za->nentry_alloc = 0; + za->entry = NULL; + za->nfile = za->nfile_alloc = 0; + za->file = NULL; + za->flags = za->ch_flags = 0; + + return za; +} + + +void * +_zip_memdup(const void *mem, size_t len, struct zip_error *error) +{ + void *ret; + + ret = malloc(len); + if (!ret) { + _zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + memcpy(ret, mem, len); + + return ret; +} + + +ZIP_EXTERN int +zip_get_num_files(struct zip *za) +{ + if (za == NULL) + return -1; + + return za->nentry; +} + +ZIP_EXTERN const char * +zip_get_name(struct zip *za, int idx, int flags) +{ + return _zip_get_name(za, idx, flags, &za->error); +} + + + +const char * +_zip_get_name(struct zip *za, int idx, int flags, struct zip_error *error) +{ + if (idx < 0 || idx >= za->nentry) { + _zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + + if ((flags & ZIP_FL_UNCHANGED) == 0) { + if (za->entry[idx].state == ZIP_ST_DELETED) { + _zip_error_set(error, ZIP_ER_DELETED, 0); + return NULL; + } + if (za->entry[idx].ch_filename) + return za->entry[idx].ch_filename; + } + + if (za->cdir == NULL || idx >= za->cdir->nentry) { + _zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + + return za->cdir->entry[idx].filename; +} + + +ZIP_EXTERN const char * +zip_get_file_comment(struct zip *za, int idx, int *lenp, int flags) +{ + if (idx < 0 || idx >= za->nentry) { + _zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return NULL; + } + + if ((flags & ZIP_FL_UNCHANGED) + || (za->entry[idx].ch_comment_len == -1)) { + if (lenp != NULL) + *lenp = za->cdir->entry[idx].comment_len; + return za->cdir->entry[idx].comment; + } + + if (lenp != NULL) + *lenp = za->entry[idx].ch_comment_len; + return za->entry[idx].ch_comment; +} + + +ZIP_EXTERN int +zip_get_archive_flag(struct zip *za, int flag, int flags) +{ + int fl; + + fl = (flags & ZIP_FL_UNCHANGED) ? za->flags : za->ch_flags; + + return (fl & flag) ? 1 : 0; +} + + +ZIP_EXTERN const char * +zip_get_archive_comment(struct zip *za, int *lenp, int flags) +{ + if ((flags & ZIP_FL_UNCHANGED) + || (za->ch_comment_len == -1)) { + if (za->cdir) { + if (lenp != NULL) + *lenp = za->cdir->comment_len; + return za->cdir->comment; + } + else { + if (lenp != NULL) + *lenp = -1; + return NULL; + } + } + + if (lenp != NULL) + *lenp = za->ch_comment_len; + return za->ch_comment; +} + + +/* _zip_free: + frees the space allocated to a zipfile struct, and closes the + corresponding file. */ + +void +_zip_free(struct zip *za) +{ + int i; + + if (za == NULL) + return; + + if (za->zn) + free(za->zn); + + if (za->zp) + fclose(za->zp); + + _zip_cdir_free(za->cdir); + + if (za->entry) { + for (i=0; i<za->nentry; i++) { + _zip_entry_free(za->entry+i); + } + free(za->entry); + } + + for (i=0; i<za->nfile; i++) { + if (za->file[i]->error.zip_err == ZIP_ER_OK) { + _zip_error_set(&za->file[i]->error, ZIP_ER_ZIPCLOSED, 0); + za->file[i]->za = NULL; + } + } + + free(za->file); + + free(za); + + return; +} + + +ZIP_EXTERN ssize_t +zip_fread(struct zip_file *zf, void *outbuf, size_t toread) +{ + int ret; + size_t out_before, len; + int i; + + if (!zf) + return -1; + + if (zf->error.zip_err != 0) + return -1; + + if ((zf->flags & ZIP_ZF_EOF) || (toread == 0)) + return 0; + + if (zf->bytes_left == 0) { + zf->flags |= ZIP_ZF_EOF; + if (zf->flags & ZIP_ZF_CRC) { + if (zf->crc != zf->crc_orig) { + _zip_error_set(&zf->error, ZIP_ER_CRC, 0); + return -1; + } + } + return 0; + } + + if ((zf->flags & ZIP_ZF_DECOMP) == 0) { + ret = _zip_file_fillbuf(outbuf, toread, zf); + if (ret > 0) { + if (zf->flags & ZIP_ZF_CRC) + zf->crc = crc32(zf->crc, (Bytef *)outbuf, ret); + zf->bytes_left -= ret; + } + return ret; + } + + zf->zstr->next_out = (Bytef *)outbuf; + zf->zstr->avail_out = toread; + out_before = zf->zstr->total_out; + + /* endless loop until something has been accomplished */ + for (;;) { + ret = inflate(zf->zstr, Z_SYNC_FLUSH); + + switch (ret) { + case Z_OK: + case Z_STREAM_END: + /* all ok */ + /* Z_STREAM_END probably won't happen, since we didn't + have a header */ + len = zf->zstr->total_out - out_before; + if (len >= zf->bytes_left || len >= toread) { + if (zf->flags & ZIP_ZF_CRC) + zf->crc = crc32(zf->crc, (Bytef *)outbuf, len); + zf->bytes_left -= len; + return len; + } + break; + + case Z_BUF_ERROR: + if (zf->zstr->avail_in == 0) { + i = _zip_file_fillbuf(zf->buffer, BUFSIZE, zf); + if (i == 0) { + _zip_error_set(&zf->error, ZIP_ER_INCONS, 0); + return -1; + } + else if (i < 0) + return -1; + zf->zstr->next_in = (Bytef *)zf->buffer; + zf->zstr->avail_in = i; + continue; + } + /* fallthrough */ + case Z_NEED_DICT: + case Z_DATA_ERROR: + case Z_STREAM_ERROR: + case Z_MEM_ERROR: + _zip_error_set(&zf->error, ZIP_ER_ZLIB, ret); + return -1; + } + } +} + + +ZIP_EXTERN const char * +zip_strerror(struct zip *za) +{ + return _zip_error_strerror(&za->error); +} + + +ZIP_EXTERN void +zip_stat_init(struct zip_stat *st) +{ + st->name = NULL; + st->index = -1; + st->crc = 0; + st->mtime = (time_t)-1; + st->size = -1; + st->comp_size = -1; + st->comp_method = ZIP_CM_STORE; + st->encryption_method = ZIP_EM_NONE; +} + + +ZIP_EXTERN int +zip_stat_index(struct zip *za, int index, int flags, struct zip_stat *st) +{ + const char *name; + + if (index < 0 || index >= za->nentry) { + _zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + if ((name=zip_get_name(za, index, flags)) == NULL) + return -1; + + + if ((flags & ZIP_FL_UNCHANGED) == 0 + && ZIP_ENTRY_DATA_CHANGED(za->entry+index)) { + if (za->entry[index].source->f(za->entry[index].source->ud, + st, sizeof(*st), ZIP_SOURCE_STAT) < 0) { + _zip_error_set(&za->error, ZIP_ER_CHANGED, 0); + return -1; + } + } + else { + if (za->cdir == NULL || index >= za->cdir->nentry) { + _zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + st->crc = za->cdir->entry[index].crc; + st->size = za->cdir->entry[index].uncomp_size; + st->mtime = za->cdir->entry[index].last_mod; + st->comp_size = za->cdir->entry[index].comp_size; + st->comp_method = za->cdir->entry[index].comp_method; + if (za->cdir->entry[index].bitflags & ZIP_GPBF_ENCRYPTED) { + if (za->cdir->entry[index].bitflags & ZIP_GPBF_STRONG_ENCRYPTION) { + /* XXX */ + st->encryption_method = ZIP_EM_UNKNOWN; + } + else + st->encryption_method = ZIP_EM_TRAD_PKWARE; + } + else + st->encryption_method = ZIP_EM_NONE; + /* st->bitflags = za->cdir->entry[index].bitflags; */ + } + + st->index = index; + st->name = name; + + return 0; +} + + +ZIP_EXTERN int +zip_stat(struct zip *za, const char *fname, int flags, struct zip_stat *st) +{ + int idx; + + if ((idx=zip_name_locate(za, fname, flags)) < 0) + return -1; + + return zip_stat_index(za, idx, flags, st); +} + + +struct read_zip { + struct zip_file *zf; + struct zip_stat st; + myoff_t off, len; +}; + +static ssize_t read_zip(void *st, void *data, size_t len, + enum zip_source_cmd cmd); + + + +ZIP_EXTERN struct zip_source * +zip_source_zip(struct zip *za, struct zip *srcza, int srcidx, int flags, + myoff_t start, myoff_t len) +{ + struct zip_error error; + struct zip_source *zs; + struct read_zip *p; + + /* XXX: ZIP_FL_RECOMPRESS */ + + if (za == NULL) + return NULL; + + if (srcza == NULL || start < 0 || len < -1 || srcidx < 0 || srcidx >= srcza->nentry) { + _zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return NULL; + } + + if ((flags & ZIP_FL_UNCHANGED) == 0 + && ZIP_ENTRY_DATA_CHANGED(srcza->entry+srcidx)) { + _zip_error_set(&za->error, ZIP_ER_CHANGED, 0); + return NULL; + } + + if (len == 0) + len = -1; + + if (start == 0 && len == -1 && (flags & ZIP_FL_RECOMPRESS) == 0) + flags |= ZIP_FL_COMPRESSED; + else + flags &= ~ZIP_FL_COMPRESSED; + + if ((p=(struct read_zip *)malloc(sizeof(*p))) == NULL) { + _zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return NULL; + } + + _zip_error_copy(&error, &srcza->error); + + if (zip_stat_index(srcza, srcidx, flags, &p->st) < 0 + || (p->zf=zip_fopen_index(srcza, srcidx, flags)) == NULL) { + free(p); + _zip_error_copy(&za->error, &srcza->error); + _zip_error_copy(&srcza->error, &error); + + return NULL; + } + p->off = start; + p->len = len; + + if ((flags & ZIP_FL_COMPRESSED) == 0) { + p->st.size = p->st.comp_size = len; + p->st.comp_method = ZIP_CM_STORE; + p->st.crc = 0; + } + + if ((zs=zip_source_function(za, read_zip, p)) == NULL) { + free(p); + return NULL; + } + + return zs; +} + + + +static ssize_t +read_zip(void *state, void *data, size_t len, enum zip_source_cmd cmd) +{ + struct read_zip *z; + char b[8192], *buf; + int i, n; + + z = (struct read_zip *)state; + buf = (char *)data; + + switch (cmd) { + case ZIP_SOURCE_OPEN: + for (n=0; n<z->off; n+= i) { + i = (z->off-n > sizeof(b) ? sizeof(b) : z->off-n); + if ((i=zip_fread(z->zf, b, i)) < 0) { + zip_fclose(z->zf); + z->zf = NULL; + return -1; + } + } + return 0; + + case ZIP_SOURCE_READ: + if (z->len != -1) + n = len > z->len ? z->len : len; + else + n = len; + + + if ((i=zip_fread(z->zf, buf, n)) < 0) + return -1; + + if (z->len != -1) + z->len -= i; + + return i; + + case ZIP_SOURCE_CLOSE: + return 0; + + case ZIP_SOURCE_STAT: + if (len < sizeof(z->st)) + return -1; + len = sizeof(z->st); + + memcpy(data, &z->st, len); + return len; + + case ZIP_SOURCE_ERROR: + { + int *e; + + if (len < sizeof(int)*2) + return -1; + + e = (int *)data; + zip_file_error_get(z->zf, e, e+1); + } + return sizeof(int)*2; + + case ZIP_SOURCE_FREE: + zip_fclose(z->zf); + free(z); + return 0; + + default: + ; + } + + return -1; +} + + +ZIP_EXTERN struct zip_source * +zip_source_function(struct zip *za, zip_source_callback zcb, void *ud) +{ + struct zip_source *zs; + + if (za == NULL) + return NULL; + + if ((zs=(struct zip_source *)malloc(sizeof(*zs))) == NULL) { + _zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return NULL; + } + + zs->f = zcb; + zs->ud = ud; + + return zs; +} + + +ZIP_EXTERN void +zip_source_free(struct zip_source *source) +{ + if (source == NULL) + return; + + (void)source->f(source->ud, NULL, 0, ZIP_SOURCE_FREE); + + free(source); +} + + +struct read_file { + char *fname; /* name of file to copy from */ + FILE *f; /* file to copy from */ + myoff_t off; /* start offset of */ + myoff_t len; /* lengt of data to copy */ + myoff_t remain; /* bytes remaining to be copied */ + int e[2]; /* error codes */ +}; + +static ssize_t read_file(void *state, void *data, size_t len, + enum zip_source_cmd cmd); + + + +ZIP_EXTERN struct zip_source * +zip_source_filep(struct zip *za, FILE *file, myoff_t start, myoff_t len) +{ + if (za == NULL) + return NULL; + + if (file == NULL || start < 0 || len < -1) { + _zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return NULL; + } + + return _zip_source_file_or_p(za, NULL, file, start, len); +} + + + +struct zip_source * +_zip_source_file_or_p(struct zip *za, const char *fname, FILE *file, + myoff_t start, myoff_t len) +{ + struct read_file *f; + struct zip_source *zs; + + if (file == NULL && fname == NULL) { + _zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return NULL; + } + + if ((f=(struct read_file *)malloc(sizeof(struct read_file))) == NULL) { + _zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return NULL; + } + + f->fname = NULL; + if (fname) { + if ((f->fname=strdup(fname)) == NULL) { + _zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + free(f); + return NULL; + } + } + f->f = file; + f->off = start; + f->len = (len ? len : -1); + + if ((zs=zip_source_function(za, read_file, f)) == NULL) { + free(f); + return NULL; + } + + return zs; +} + + + +static ssize_t +read_file(void *state, void *data, size_t len, enum zip_source_cmd cmd) +{ + struct read_file *z; + char *buf; + int i, n; + + z = (struct read_file *)state; + buf = (char *)data; + + switch (cmd) { + case ZIP_SOURCE_OPEN: + if (z->fname) { + if ((z->f=fopen(z->fname, "rb")) == NULL) { + z->e[0] = ZIP_ER_OPEN; + z->e[1] = errno; + return -1; + } + } + + if (fseeko(z->f, z->off, SEEK_SET) < 0) { + z->e[0] = ZIP_ER_SEEK; + z->e[1] = errno; + return -1; + } + z->remain = z->len; + return 0; + + case ZIP_SOURCE_READ: + if (z->remain != -1) + n = len > z->remain ? z->remain : len; + else + n = len; + + if ((i=fread(buf, 1, n, z->f)) < 0) { + z->e[0] = ZIP_ER_READ; + z->e[1] = errno; + return -1; + } + + if (z->remain != -1) + z->remain -= i; + + return i; + + case ZIP_SOURCE_CLOSE: + if (z->fname) { + fclose(z->f); + z->f = NULL; + } + return 0; + + case ZIP_SOURCE_STAT: + { + struct zip_stat *st; + struct stat fst; + int err; + + if (len < sizeof(*st)) + return -1; + + if (z->f) + err = fstat(fileno(z->f), &fst); + else + err = stat(z->fname, &fst); + + if (err != 0) { + z->e[0] = ZIP_ER_READ; /* best match */ + z->e[1] = errno; + return -1; + } + + st = (struct zip_stat *)data; + + zip_stat_init(st); + st->mtime = fst.st_mtime; + if (z->len != -1) + st->size = z->len; + else if ((fst.st_mode&S_IFMT) == S_IFREG) + st->size = fst.st_size; + + return sizeof(*st); + } + + case ZIP_SOURCE_ERROR: + if (len < sizeof(int)*2) + return -1; + + memcpy(data, z->e, sizeof(int)*2); + return sizeof(int)*2; + + case ZIP_SOURCE_FREE: + free(z->fname); + if (z->f) + fclose(z->f); + free(z); + return 0; + + default: + ; + } + + return -1; +} + + +ZIP_EXTERN int +zip_name_locate(struct zip *za, const char *fname, int flags) +{ + return _zip_name_locate(za, fname, flags, &za->error); +} + + + +int +_zip_name_locate(struct zip *za, const char *fname, int flags, + struct zip_error *error) +{ + int (*cmp)(const char *, const char *); + const char *fn, *p; + int i, n; + + if (fname == NULL) { + _zip_error_set(error, ZIP_ER_INVAL, 0); + return -1; + } + + cmp = (flags & ZIP_FL_NOCASE) ? strcasecmp : strcmp; + + n = (flags & ZIP_FL_UNCHANGED) ? za->cdir->nentry : za->nentry; + for (i=0; i<n; i++) { + if (flags & ZIP_FL_UNCHANGED) + fn = za->cdir->entry[i].filename; + else + fn = _zip_get_name(za, i, flags, error); + + /* newly added (partially filled) entry */ + if (fn == NULL) + continue; + + if (flags & ZIP_FL_NODIR) { + p = strrchr(fn, '/'); + if (p) + fn = p+1; + } + + if (cmp(fname, fn) == 0) + return i; + } + + _zip_error_set(error, ZIP_ER_NOENT, 0); + return -1; +} + diff --git a/lib/base/zip/zipfiles.nim b/lib/base/zip/zipfiles.nim new file mode 100644 index 000000000..e48b0f08e --- /dev/null +++ b/lib/base/zip/zipfiles.nim @@ -0,0 +1,144 @@ +# +# +# Nimrod's Runtime Library +# (c) Copyright 2008 Andreas Rumpf +# +# See the file "copying.txt", included in this +# distribution, for details about the copyright. +# + +## This module implements a zip archive creator/reader/modifier. + +import + streams, libzip, times, os + +type + TZipArchive* = object of TObject ## represents a zip archive + mode: TFileMode + w: PZip + + +proc zipError(z: var TZipArchive) = + var e: ref EIO + new(e) + e.msg = zip_strerror(z.w) + raise e + +proc open*(z: var TZipArchive, filename: string, mode: TFileMode = fmRead): bool = + ## Opens a zip file for reading, writing or appending. All file modes are + ## supported. Returns true iff successful, false otherwise. + var err, flags: int32 + case mode + of fmRead, fmReadWriteExisting, fmAppend: flags = 0 + of fmWrite: + if existsFile(filename): removeFile(filename) + flags = ZIP_CREATE or ZIP_EXCL + of fmReadWrite: flags = ZIP_CREATE + z.w = zip_open(filename, flags, addr(err)) + z.mode = mode + result = z.w != nil + +proc close*(z: var TZipArchive) = + ## Closes a zip file. + zip_close(z.w) + +proc createDir*(z: var TZipArchive, dir: string) = + ## Creates a directory within the `z` archive. This does not fails if the + ## directory already exists. Note that for adding a file like + ## ``"path1/path2/filename"`` it is not necessary + ## to create the ``"path/path2"`` subdirectories - it will be done + ## automatically by ``addFile``. + assert(z.mode != fmRead) + discard zip_add_dir(z.w, dir) + zip_error_clear(z.w) + +proc addFile*(z: var TZipArchive, dest, src: string) = + ## Adds the file `src` to the archive `z` with the name `dest`. `dest` + ## may contain a path that will be created. + assert(z.mode != fmRead) + var zipsrc = zip_source_file(z.w, src, 0, -1) + if zipsrc == nil: + echo("Dest: " & dest) + echo("Src: " & src) + zipError(z) + if zip_add(z.w, dest, zipsrc) < 0'i32: + zip_source_free(zipsrc) + zipError(z) + +proc addFile*(z: var TZipArchive, file: string) = + ## A shortcut for ``addFile(z, file, file)``, i.e. the name of the source is + ## the name of the destination. + addFile(z, file, file) + +proc mySourceCallback(state, data: pointer, len: int, + cmd: Tzip_source_cmd): int {.cdecl.} = + var src = cast[PStream](state) + case cmd + of ZIP_SOURCE_OPEN: + if src.setPosition != nil: src.setPosition(src, 0) # reset + of ZIP_SOURCE_READ: + result = src.readData(src, data, len) + of ZIP_SOURCE_CLOSE: src.close(src) + of ZIP_SOURCE_STAT: + var stat = cast[PZipStat](data) + zip_stat_init(stat) + stat.size = high(int32)-1 # we don't know the size + stat.mtime = getTime() + result = sizeof(TZipStat) + of ZIP_SOURCE_ERROR: + var err = cast[ptr array[0..1, cint]](data) + err[0] = ZIP_ER_INTERNAL + err[1] = 0 + result = 2*sizeof(cint) + of constZIP_SOURCE_FREE: GC_unref(src) + else: assert(false) + +proc addFile*(z: var TZipArchive, dest: string, src: PStream) = + ## Adds a file named with `dest` to the archive `z`. `dest` + ## may contain a path. The file's content is read from the `src` stream. + assert(z.mode != fmRead) + GC_ref(src) + var zipsrc = zip_source_function(z.w, mySourceCallback, cast[pointer](src)) + if zipsrc == nil: zipError(z) + if zip_add(z.w, dest, zipsrc) < 0'i32: + zip_source_free(zipsrc) + zipError(z) + +# -------------- zip file stream --------------------------------------------- + +type + TZipFileStream = object of TStream + f: Pzip_file + + PZipFileStream* = + ref TZipFileStream ## a reader stream of a file within a zip archive + +proc fsClose(s: PZipFileStream) = zip_fclose(s.f) +proc fsReadData(s: PZipFileStream, buffer: pointer, bufLen: int): int = + result = zip_fread(s.f, buffer, bufLen) + +proc newZipFileStream(f: PZipFile): PZipFileStream = + new(result) + result.f = f + result.close = fsClose + result.readData = fsReadData + # other methods are nil! + +# ---------------------------------------------------------------------------- + +proc getStream*(z: var TZipArchive, filename: string): PZipFileStream = + ## returns a stream that can be used to read the file named `filename` + ## from the archive `z`. Returns nil in case of an error. + ## The returned stream does not support the `setPosition`, `getPosition`, + ## `writeData` or `atEnd` methods. + var x = zip_fopen(z.w, filename, 0'i32) + if x != nil: result = newZipFileStream(x) + +iterator walkFiles*(z: var TZipArchive): string = + ## walks over all files in the archive `z` and returns the filename + ## (including the path). + var i = 0 + var num = int(zip_get_num_files(z.w)) + while i < num: + yield $zip_get_name(z.w, i, 0'i32) + inc(i) diff --git a/lib/base/zip/zlib.nim b/lib/base/zip/zlib.nim new file mode 100644 index 000000000..9b49b9663 --- /dev/null +++ b/lib/base/zip/zlib.nim @@ -0,0 +1,181 @@ +# Converted from Pascal + +## Interface to the zlib http://www.zlib.net/ compression library. + +when defined(windows): + const libz = "zlib1.dll" +elif defined(macosx): + const libz = "libz.dylib" +else: + const libz = "libz.so" + +type + Uint* = int32 + Ulong* = int + Ulongf* = int + Pulongf* = ptr Ulongf + z_off_t* = int32 + pbyte* = cstring + pbytef* = cstring + TAllocfunc* = proc (p: pointer, items: uInt, size: uInt): pointer{.cdecl.} + TFreeFunc* = proc (p: pointer, address: pointer){.cdecl.} + TInternalState*{.final, pure.} = object + PInternalState* = ptr TInternalstate + TZStream*{.final, pure.} = object + next_in*: pbytef + avail_in*: uInt + total_in*: uLong + next_out*: pbytef + avail_out*: uInt + total_out*: uLong + msg*: pbytef + state*: PInternalState + zalloc*: TAllocFunc + zfree*: TFreeFunc + opaque*: pointer + data_type*: int32 + adler*: uLong + reserved*: uLong + + TZStreamRec* = TZStream + PZstream* = ptr TZStream + gzFile* = pointer + +const + Z_NO_FLUSH* = 0 + Z_PARTIAL_FLUSH* = 1 + Z_SYNC_FLUSH* = 2 + Z_FULL_FLUSH* = 3 + Z_FINISH* = 4 + Z_OK* = 0 + Z_STREAM_END* = 1 + Z_NEED_DICT* = 2 + Z_ERRNO* = -1 + Z_STREAM_ERROR* = -2 + Z_DATA_ERROR* = -3 + Z_MEM_ERROR* = -4 + Z_BUF_ERROR* = -5 + Z_VERSION_ERROR* = -6 + Z_NO_COMPRESSION* = 0 + Z_BEST_SPEED* = 1 + Z_BEST_COMPRESSION* = 9 + Z_DEFAULT_COMPRESSION* = -1 + Z_FILTERED* = 1 + Z_HUFFMAN_ONLY* = 2 + Z_DEFAULT_STRATEGY* = 0 + Z_BINARY* = 0 + Z_ASCII* = 1 + Z_UNKNOWN* = 2 + Z_DEFLATED* = 8 + Z_NULL* = 0 + +proc zlibVersion*(): cstring{.cdecl, dynlib: libz, importc: "zlibVersion".} +proc deflate*(strm: var TZStream, flush: int32): int32{.cdecl, dynlib: libz, + importc: "deflate".} +proc deflateEnd*(strm: var TZStream): int32{.cdecl, dynlib: libz, + importc: "deflateEnd".} +proc inflate*(strm: var TZStream, flush: int32): int32{.cdecl, dynlib: libz, + importc: "inflate".} +proc inflateEnd*(strm: var TZStream): int32{.cdecl, dynlib: libz, + importc: "inflateEnd".} +proc deflateSetDictionary*(strm: var TZStream, dictionary: pbytef, + dictLength: uInt): int32{.cdecl, dynlib: libz, + importc: "deflateSetDictionary".} +proc deflateCopy*(dest, source: var TZstream): int32{.cdecl, dynlib: libz, + importc: "deflateCopy".} +proc deflateReset*(strm: var TZStream): int32{.cdecl, dynlib: libz, + importc: "deflateReset".} +proc deflateParams*(strm: var TZStream, level: int32, strategy: int32): int32{. + cdecl, dynlib: libz, importc: "deflateParams".} +proc inflateSetDictionary*(strm: var TZStream, dictionary: pbytef, + dictLength: uInt): int32{.cdecl, dynlib: libz, + importc: "inflateSetDictionary".} +proc inflateSync*(strm: var TZStream): int32{.cdecl, dynlib: libz, + importc: "inflateSync".} +proc inflateReset*(strm: var TZStream): int32{.cdecl, dynlib: libz, + importc: "inflateReset".} +proc compress*(dest: pbytef, destLen: puLongf, source: pbytef, sourceLen: uLong): cint{. + cdecl, dynlib: libz, importc: "compress".} +proc compress2*(dest: pbytef, destLen: puLongf, source: pbytef, + sourceLen: uLong, level: cint): cint{.cdecl, dynlib: libz, + importc: "compress2".} +proc uncompress*(dest: pbytef, destLen: puLongf, source: pbytef, + sourceLen: uLong): cint{.cdecl, dynlib: libz, + importc: "uncompress".} +proc gzopen*(path: cstring, mode: cstring): gzFile{.cdecl, dynlib: libz, + importc: "gzopen".} +proc gzdopen*(fd: int32, mode: cstring): gzFile{.cdecl, dynlib: libz, + importc: "gzdopen".} +proc gzsetparams*(thefile: gzFile, level: int32, strategy: int32): int32{.cdecl, + dynlib: libz, importc: "gzsetparams".} +proc gzread*(thefile: gzFile, buf: pointer, length: int): int32{.cdecl, + dynlib: libz, importc: "gzread".} +proc gzwrite*(thefile: gzFile, buf: pointer, length: int): int32{.cdecl, + dynlib: libz, importc: "gzwrite".} +proc gzprintf*(thefile: gzFile, format: pbytef): int32{.varargs, cdecl, + dynlib: libz, importc: "gzprintf".} +proc gzputs*(thefile: gzFile, s: pbytef): int32{.cdecl, dynlib: libz, + importc: "gzputs".} +proc gzgets*(thefile: gzFile, buf: pbytef, length: int32): pbytef{.cdecl, + dynlib: libz, importc: "gzgets".} +proc gzputc*(thefile: gzFile, c: char): char{.cdecl, dynlib: libz, + importc: "gzputc".} +proc gzgetc*(thefile: gzFile): char{.cdecl, dynlib: libz, importc: "gzgetc".} +proc gzflush*(thefile: gzFile, flush: int32): int32{.cdecl, dynlib: libz, + importc: "gzflush".} +proc gzseek*(thefile: gzFile, offset: z_off_t, whence: int32): z_off_t{.cdecl, + dynlib: libz, importc: "gzseek".} +proc gzrewind*(thefile: gzFile): int32{.cdecl, dynlib: libz, importc: "gzrewind".} +proc gztell*(thefile: gzFile): z_off_t{.cdecl, dynlib: libz, importc: "gztell".} +proc gzeof*(thefile: gzFile): int {.cdecl, dynlib: libz, importc: "gzeof".} +proc gzclose*(thefile: gzFile): int32{.cdecl, dynlib: libz, importc: "gzclose".} +proc gzerror*(thefile: gzFile, errnum: var int32): pbytef{.cdecl, dynlib: libz, + importc: "gzerror".} +proc adler32*(adler: uLong, buf: pbytef, length: uInt): uLong{.cdecl, + dynlib: libz, importc: "adler32".} +proc crc32*(crc: uLong, buf: pbytef, length: uInt): uLong{.cdecl, dynlib: libz, + importc: "crc32".} +proc deflateInitu*(strm: var TZStream, level: int32, version: cstring, + stream_size: int32): int32{.cdecl, dynlib: libz, + importc: "deflateInit_".} +proc inflateInitu*(strm: var TZStream, version: cstring, + stream_size: int32): int32 {. + cdecl, dynlib: libz, importc: "inflateInit_".} +proc deflateInit*(strm: var TZStream, level: int32): int32 +proc inflateInit*(strm: var TZStream): int32 +proc deflateInit2u*(strm: var TZStream, level: int32, `method`: int32, + windowBits: int32, memLevel: int32, strategy: int32, + version: cstring, stream_size: int32): int32 {.cdecl, + dynlib: libz, importc: "deflateInit2_".} +proc inflateInit2u*(strm: var TZStream, windowBits: int32, version: cstring, + stream_size: int32): int32{.cdecl, dynlib: libz, + importc: "inflateInit2_".} +proc deflateInit2*(strm: var TZStream, + level, `method`, windowBits, memLevel, + strategy: int32): int32 +proc inflateInit2*(strm: var TZStream, windowBits: int32): int32 +proc zError*(err: int32): cstring{.cdecl, dynlib: libz, importc: "zError".} +proc inflateSyncPoint*(z: PZstream): int32{.cdecl, dynlib: libz, + importc: "inflateSyncPoint".} +proc get_crc_table*(): pointer{.cdecl, dynlib: libz, importc: "get_crc_table".} + +proc deflateInit(strm: var TZStream, level: int32): int32 = + result = deflateInitu(strm, level, ZLIB_VERSION(), sizeof(TZStream)) + +proc inflateInit(strm: var TZStream): int32 = + result = inflateInitu(strm, ZLIB_VERSION(), sizeof(TZStream)) + +proc deflateInit2(strm: var TZStream, + level, `method`, windowBits, memLevel, + strategy: int32): int32 = + result = deflateInit2u(strm, level, `method`, windowBits, memLevel, + strategy, ZLIB_VERSION(), sizeof(TZStream)) + +proc inflateInit2(strm: var TZStream, windowBits: int32): int32 = + result = inflateInit2u(strm, windowBits, ZLIB_VERSION(), sizeof(TZStream)) + +proc zlibAllocMem*(AppData: Pointer, Items, Size: int): Pointer {.cdecl.} = + result = Alloc(Items * Size) + +proc zlibFreeMem*(AppData, `Block`: Pointer) {.cdecl.} = + dealloc(`Block`) diff --git a/lib/base/zip/zzip.nim b/lib/base/zip/zzip.nim new file mode 100644 index 000000000..a656322ee --- /dev/null +++ b/lib/base/zip/zzip.nim @@ -0,0 +1,172 @@ +# +# +# Nimrod's Runtime Library +# (c) Copyright 2008 Andreas Rumpf +# +# See the file "copying.txt", included in this +# distribution, for details about the copyright. +# + +## This module is an interface to the zzip library. + +# Author: +# Guido Draheim <guidod@gmx.de> +# Tomi Ollila <Tomi.Ollila@iki.fi> +# Copyright (c) 1999,2000,2001,2002,2003,2004 Guido Draheim +# All rights reserved, +# usage allowed under the restrictions of the +# Lesser GNU General Public License +# or alternatively the restrictions +# of the Mozilla Public License 1.1 + +when defined(windows): + const + dllname = "zzip.dll" +else: + const + dllname = "libzzip.so" + +type + TZZipError* = int32 +const + ZZIP_ERROR* = -4096'i32 + ZZIP_NO_ERROR* = 0'i32 # no error, may be used if user sets it. + ZZIP_OUTOFMEM* = ZZIP_ERROR - 20'i32 # out of memory + ZZIP_DIR_OPEN* = ZZIP_ERROR - 21'i32 # failed to open zipfile, see errno for details + ZZIP_DIR_STAT* = ZZIP_ERROR - 22'i32 # failed to fstat zipfile, see errno for details + ZZIP_DIR_SEEK* = ZZIP_ERROR - 23'i32 # failed to lseek zipfile, see errno for details + ZZIP_DIR_READ* = ZZIP_ERROR - 24'i32 # failed to read zipfile, see errno for details + ZZIP_DIR_TOO_SHORT* = ZZIP_ERROR - 25'i32 + ZZIP_DIR_EDH_MISSING* = ZZIP_ERROR - 26'i32 + ZZIP_DIRSIZE* = ZZIP_ERROR - 27'i32 + ZZIP_ENOENT* = ZZIP_ERROR - 28'i32 + ZZIP_UNSUPP_COMPR* = ZZIP_ERROR - 29'i32 + ZZIP_CORRUPTED* = ZZIP_ERROR - 31'i32 + ZZIP_UNDEF* = ZZIP_ERROR - 32'i32 + ZZIP_DIR_LARGEFILE* = ZZIP_ERROR - 33'i32 + + ZZIP_CASELESS* = 1'i32 shl 12'i32 + ZZIP_NOPATHS* = 1'i32 shl 13'i32 + ZZIP_PREFERZIP* = 1'i32 shl 14'i32 + ZZIP_ONLYZIP* = 1'i32 shl 16'i32 + ZZIP_FACTORY* = 1'i32 shl 17'i32 + ZZIP_ALLOWREAL* = 1'i32 shl 18'i32 + ZZIP_THREADED* = 1'i32 shl 19'i32 + +type + TZZipDir* {.final, pure.} = object + TZZipFile* {.final, pure.} = object + TZZipPluginIO* {.final, pure.} = object + + TZZipDirent* {.final, pure.} = object + d_compr*: int32 ## compression method + d_csize*: int32 ## compressed size + st_size*: int32 ## file size / decompressed size + d_name*: cstring ## file name / strdupped name + + TZZipStat* = TZZipDirent + +proc zzip_strerror*(errcode: int32): cstring {.cdecl, dynlib: dllname, + importc: "zzip_strerror".} +proc zzip_strerror_of*(dir: ptr TZZipDir): cstring {.cdecl, dynlib: dllname, + importc: "zzip_strerror_of".} +proc zzip_errno*(errcode: int32): int32 {.cdecl, dynlib: dllname, + importc: "zzip_errno".} + +proc zzip_geterror*(dir: ptr TZZipDir): int32 {.cdecl, dynlib: dllname, + importc: "zzip_error".} +proc zzip_seterror*(dir: ptr TZZipDir, errcode: int32) {.cdecl, dynlib: dllname, + importc: "zzip_seterror".} +proc zzip_compr_str*(compr: int32): cstring {.cdecl, dynlib: dllname, + importc: "zzip_compr_str".} +proc zzip_dirhandle*(fp: ptr TZZipFile): ptr TZZipDir {.cdecl, dynlib: dllname, + importc: "zzip_dirhandle".} +proc zzip_dirfd*(dir: ptr TZZipDir): int32 {.cdecl, dynlib: dllname, + importc: "zzip_dirfd".} +proc zzip_dir_real*(dir: ptr TZZipDir): int32 {.cdecl, dynlib: dllname, + importc: "zzip_dir_real".} +proc zzip_file_real*(fp: ptr TZZipFile): int32 {.cdecl, dynlib: dllname, + importc: "zzip_file_real".} +proc zzip_realdir*(dir: ptr TZZipDir): pointer {.cdecl, dynlib: dllname, + importc: "zzip_realdir".} +proc zzip_realfd*(fp: ptr TZZipFile): int32 {.cdecl, dynlib: dllname, + importc: "zzip_realfd".} + +proc zzip_dir_alloc*(fileext: cstringArray): ptr TZZipDir {.cdecl, + dynlib: dllname, importc: "zzip_dir_alloc".} +proc zzip_dir_free*(para1: ptr TZZipDir): int32 {.cdecl, dynlib: dllname, + importc: "zzip_dir_free".} + +proc zzip_dir_fdopen*(fd: int32, errcode_p: ptr TZZipError): ptr TZZipDir {.cdecl, + dynlib: dllname, importc: "zzip_dir_fdopen".} +proc zzip_dir_open*(filename: cstring, errcode_p: ptr TZZipError): ptr TZZipDir {. + cdecl, dynlib: dllname, importc: "zzip_dir_open".} +proc zzip_dir_close*(dir: ptr TZZipDir) {.cdecl, dynlib: dllname, + importc: "zzip_dir_close".} +proc zzip_dir_read*(dir: ptr TZZipDir, dirent: ptr TZZipDirent): int32 {.cdecl, + dynlib: dllname, importc: "zzip_dir_read".} + +proc zzip_opendir*(filename: cstring): ptr TZZipDir {.cdecl, dynlib: dllname, + importc: "zzip_opendir".} +proc zzip_closedir*(dir: ptr TZZipDir) {.cdecl, dynlib: dllname, + importc: "zzip_closedir".} +proc zzip_readdir*(dir: ptr TZZipDir): ptr TZZipDirent {.cdecl, dynlib: dllname, + importc: "zzip_readdir".} +proc zzip_rewinddir*(dir: ptr TZZipDir) {.cdecl, dynlib: dllname, + importc: "zzip_rewinddir".} +proc zzip_telldir*(dir: ptr TZZipDir): int {.cdecl, dynlib: dllname, + importc: "zzip_telldir".} +proc zzip_seekdir*(dir: ptr TZZipDir, offset: int) {.cdecl, dynlib: dllname, + importc: "zzip_seekdir".} + +proc zzip_file_open*(dir: ptr TZZipDir, name: cstring, flags: int32): ptr TZZipFile {. + cdecl, dynlib: dllname, importc: "zzip_file_open".} +proc zzip_file_close*(fp: ptr TZZipFile) {.cdecl, dynlib: dllname, + importc: "zzip_file_close".} +proc zzip_file_read*(fp: ptr TZZipFile, buf: pointer, length: int): int {. + cdecl, dynlib: dllname, importc: "zzip_file_read".} +proc zzip_open*(name: cstring, flags: int32): ptr TZZipFile {.cdecl, + dynlib: dllname, importc: "zzip_open".} +proc zzip_close*(fp: ptr TZZipFile) {.cdecl, dynlib: dllname, + importc: "zzip_close".} +proc zzip_read*(fp: ptr TZZipFile, buf: pointer, length: int): int {. + cdecl, dynlib: dllname, importc: "zzip_read".} + +proc zzip_freopen*(name: cstring, mode: cstring, para3: ptr TZZipFile): ptr TZZipFile {. + cdecl, dynlib: dllname, importc: "zzip_freopen".} +proc zzip_fopen*(name: cstring, mode: cstring): ptr TZZipFile {.cdecl, + dynlib: dllname, importc: "zzip_fopen".} +proc zzip_fread*(p: pointer, size: int, nmemb: int, + file: ptr TZZipFile): int {.cdecl, dynlib: dllname, + importc: "zzip_fread".} +proc zzip_fclose*(fp: ptr TZZipFile) {.cdecl, dynlib: dllname, + importc: "zzip_fclose".} + +proc zzip_rewind*(fp: ptr TZZipFile): int32 {.cdecl, dynlib: dllname, + importc: "zzip_rewind".} +proc zzip_seek*(fp: ptr TZZipFile, offset: int, whence: int32): int {. + cdecl, dynlib: dllname, importc: "zzip_seek".} +proc zzip_tell*(fp: ptr TZZipFile): int {.cdecl, dynlib: dllname, + importc: "zzip_tell".} + +proc zzip_dir_stat*(dir: ptr TZZipDir, name: cstring, zs: ptr TZZipStat, + flags: int32): int32 {.cdecl, dynlib: dllname, + importc: "zzip_dir_stat".} +proc zzip_file_stat*(fp: ptr TZZipFile, zs: ptr TZZipStat): int32 {.cdecl, + dynlib: dllname, importc: "zzip_file_stat".} +proc zzip_fstat*(fp: ptr TZZipFile, zs: ptr TZZipStat): int32 {.cdecl, dynlib: dllname, + importc: "zzip_fstat".} + +proc zzip_open_shared_io*(stream: ptr TZZipFile, name: cstring, + o_flags: int32, o_modes: int32, ext: cstringArray, + io: ptr TZZipPluginIO): ptr TZZipFile {.cdecl, + dynlib: dllname, importc: "zzip_open_shared_io".} +proc zzip_open_ext_io*(name: cstring, o_flags: int32, o_modes: int32, + ext: cstringArray, io: ptr TZZipPluginIO): ptr TZZipFile {. + cdecl, dynlib: dllname, importc: "zzip_open_ext_io".} +proc zzip_opendir_ext_io*(name: cstring, o_modes: int32, + ext: cstringArray, io: ptr TZZipPluginIO): ptr TZZipDir {. + cdecl, dynlib: dllname, importc: "zzip_opendir_ext_io".} +proc zzip_dir_open_ext_io*(filename: cstring, errcode_p: ptr TZZipError, + ext: cstringArray, io: ptr TZZipPluginIO): ptr TZZipDir {. + cdecl, dynlib: dllname, importc: "zzip_dir_open_ext_io".} |