glut_linux.tem 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. {
  2. $Id$
  3. Translation of the Mesa GLUT headers for FreePascal
  4. Linux Version, Copyright (C) 1999 Sebastian Guenther
  5. Mesa 3-D graphics library
  6. Version: 3.0
  7. Copyright (C) 1995-1998 Brian Paul
  8. This library is free software; you can redistribute it and/or
  9. modify it under the terms of the GNU Library General Public
  10. License as published by the Free Software Foundation; either
  11. version 2 of the License, or (at your option) any later version.
  12. This library is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. Library General Public License for more details.
  16. You should have received a copy of the GNU Library General Public
  17. License along with this library; if not, write to the Free
  18. Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. }
  20. {$MODE delphi}
  21. unit GLUT;
  22. interface
  23. uses GL;
  24. function InitGLUTFromLibrary(libname: PChar): Boolean;
  25. // determines automatically which library to use:
  26. function InitGLUT: Boolean;
  27. var
  28. GLUTInitialized: Boolean;
  29. %GLUTDeclsIF
  30. %GLUTProcsPD
  31. implementation
  32. {$LINKLIB Xmu}
  33. function dlopen(AFile: PChar; mode: LongInt): Pointer; external 'dl';
  34. function dlclose(handle: Pointer): LongInt; external 'dl';
  35. function dlsym(handle: Pointer; name: PChar): Pointer; external 'dl';
  36. function LoadLibrary(name: PChar): Pointer;
  37. begin
  38. Result := dlopen(name, $101 {RTLD_GLOBAL or RTLD_LAZY});
  39. end;
  40. procedure FreeLibrary(handle: Pointer);
  41. begin
  42. dlclose(handle);
  43. end;
  44. function GetProc(handle: Pointer; name: PChar): Pointer;
  45. begin
  46. Result := dlsym(handle, name);
  47. // if Result = nil then WriteLn('Unresolved: ', name);
  48. end;
  49. var
  50. libGLUT: Pointer;
  51. function InitGLUTFromLibrary(libname: PChar): Boolean;
  52. begin
  53. Result := False;
  54. libGLUT := LoadLibrary(libname);
  55. if not Assigned(libGLUT) then exit;
  56. %GLUTProcsPL
  57. GLUTInitialized := True;
  58. Result := True;
  59. end;
  60. function InitGLUT: Boolean;
  61. begin
  62. Result := InitGLUTFromLibrary('libglut.so.1');
  63. end;
  64. finalization
  65. if Assigned(libGLUT) then FreeLibrary(libGLUT);
  66. end.