1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
{$inline on}
unit tw13596a;
interface
const
LUT_SIZE = 512;
LUT_MASK = 511;
procedure gluPerspective(fovy, aspect, zNear, zFar: single); inline;
procedure gluPerspectivef32(fovy: longint; aspect, zNear, zFar: longint); inline;
function mulf32(a, b: longint): longint; inline;
function floattof32(n: single): longint; inline;
implementation
function floattof32(n: single): longint; inline;
begin
floattof32 := trunc((n) * (1 shl 12));
end;
function mulf32(a, b: longint): longint; inline;
var
rslt: int64;
begin
rslt := int64(a) * int64(b);
mulf32 := longint(rslt shr 12);
end;
procedure gluPerspectivef32(fovy: longint; aspect, zNear, zFar: longint); inline;
var
xmin, xmax, ymin, ymax: longint;
TAN_bin: array [0..511] of smallint;
begin
ymax := mulf32(zNear, TAN_bin[(fovy shr 1) and LUT_MASK]);
ymin := -ymax;
xmin := mulf32(ymin, aspect);
xmax := mulf32(ymax, aspect);
// glFrustumf32(xmin, xmax, ymin, ymax, zNear, zFar);
end;
procedure gluPerspective(fovy, aspect, zNear, zFar: single); inline;
begin
gluPerspectivef32(trunc(fovy * LUT_SIZE / 360.0), floattof32(aspect), floattof32(zNear), floattof32(zFar));
end;
end.
|