summaryrefslogtreecommitdiff
path: root/fpcsrc/rtl/morphos/tinygl.pp
blob: 9f236c9412706abe0ff1335632ac6751d3620012 (plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{
    This file is part of the Free Pascal run time library.
    Copyright (c) 2005 by Karoly Balogh

    TinyGL/OpenGL initialization unit for MorphOS/PowerPC

    Thanks to Michal 'kiero' Wozniak and Mark 'bigfoot' Olsen
    for their help.

    See the file COPYING.FPC, included in this distribution,
    for details about the copyright.

    This program 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.

 **********************************************************************}

{$MODE FPC} { fsck Delphi mode }
{$INLINE ON}
unit tinygl;

interface

uses
  exec;

const
  TINYGLNAME : PChar = 'tinygl.library';

var
  TinyGLBase: Pointer;
  tglContext: Pointer;

function InitTinyGLLibrary : boolean;

implementation

function _GLInit: Pointer; 
syscall sysvbase TinyGLBase 640;

procedure _GLClose(gcl: pointer);
syscall sysvbase TinyGLBase 646;

const
  { Change VERSION and LIBVERSION to proper values }
  VERSION : string[2] = '50';
  LIBVERSION : longword = 50;

var
  tinygl_exit : Pointer;

procedure CloseTinyGLLibrary;
begin
  ExitProc := tinygl_exit;
  if TinyGLBase <> nil then begin
    if tglContext <> nil then begin
      _GLClose(tglContext);
      tglContext := nil;
    end;
    CloseLibrary(PLibrary(TinyGLBase));
    TinyGLBase := nil;
  end;
end;

function InitTinyGLLibrary : boolean;
begin
  TinyGLBase := nil;
  TinyGLBase := OpenLibrary(TINYGLNAME,LIBVERSION);
  if TinyGLBase <> nil then begin
    tinygl_exit := ExitProc;
    ExitProc := @CloseTinyGLLibrary;
    tglContext := _GLInit;
    InitTinyGLLibrary := True;
  end else begin
    InitTinyGLLibrary := False;
  end;
end;

end.