123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- {
- $Id$
- Translation of the Mesa GLUT headers for FreePascal
- Linux Version, 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.
- }
- {$MODE delphi}
- unit GLUT;
- interface
- uses GL;
- function InitGLUTFromLibrary(libname: PChar): Boolean;
- // determines automatically which library to use:
- function InitGLUT: Boolean;
- var
- GLUTInitialized: Boolean;
- %GLUTDeclsIF
- %GLUTProcsPD
- implementation
- {$LINKLIB Xmu}
- function dlopen(AFile: PChar; mode: LongInt): Pointer; external 'dl';
- function dlclose(handle: Pointer): LongInt; external 'dl';
- function dlsym(handle: Pointer; name: PChar): Pointer; external 'dl';
- function LoadLibrary(name: PChar): Pointer;
- begin
- Result := dlopen(name, $101 {RTLD_GLOBAL or RTLD_LAZY});
- end;
- procedure FreeLibrary(handle: Pointer);
- begin
- dlclose(handle);
- end;
- function GetProc(handle: Pointer; name: PChar): Pointer;
- begin
- Result := dlsym(handle, name);
- // if Result = nil then WriteLn('Unresolved: ', name);
- end;
- var
- libGLUT: Pointer;
- function InitGLUTFromLibrary(libname: PChar): Boolean;
- begin
- Result := False;
- libGLUT := LoadLibrary(libname);
- if not Assigned(libGLUT) then exit;
- %GLUTProcsPL
- GLUTInitialized := True;
- Result := True;
- end;
- function InitGLUT: Boolean;
- begin
- Result := InitGLUTFromLibrary('libglut.so.1');
- end;
- finalization
- if Assigned(libGLUT) then FreeLibrary(libGLUT);
- end.
|