tinygl.pp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2005 by Karoly Balogh
  4. TinyGL/OpenGL initialization unit for MorphOS/PowerPC
  5. Thanks to Michal 'kiero' Wozniak and Mark 'bigfoot' Olsen
  6. for their help.
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. {$MODE FPC} { fsck Delphi mode }
  14. {$INLINE ON}
  15. unit tinygl;
  16. interface
  17. uses
  18. exec;
  19. const
  20. TINYGLNAME : PChar = 'tinygl.library';
  21. var
  22. TinyGLBase: Pointer;
  23. tglContext: Pointer;
  24. function InitTinyGLLibrary : boolean;
  25. implementation
  26. function _GLInit: Pointer;
  27. syscall sysvbase TinyGLBase 640;
  28. procedure _GLClose(gcl: pointer);
  29. syscall sysvbase TinyGLBase 646;
  30. const
  31. { Change VERSION and LIBVERSION to proper values }
  32. VERSION : string[2] = '50';
  33. LIBVERSION : longword = 50;
  34. var
  35. tinygl_exit : Pointer;
  36. procedure CloseTinyGLLibrary;
  37. begin
  38. ExitProc := tinygl_exit;
  39. if TinyGLBase <> nil then begin
  40. if tglContext <> nil then begin
  41. _GLClose(tglContext);
  42. tglContext := nil;
  43. end;
  44. CloseLibrary(PLibrary(TinyGLBase));
  45. TinyGLBase := nil;
  46. end;
  47. end;
  48. function InitTinyGLLibrary : boolean;
  49. begin
  50. TinyGLBase := nil;
  51. TinyGLBase := OpenLibrary(TINYGLNAME,LIBVERSION);
  52. if TinyGLBase <> nil then begin
  53. tinygl_exit := ExitProc;
  54. ExitProc := @CloseTinyGLLibrary;
  55. tglContext := _GLInit;
  56. InitTinyGLLibrary := True;
  57. end else begin
  58. InitTinyGLLibrary := False;
  59. end;
  60. end;
  61. end.