mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-02 02:26:14 +02:00
76 lines
1.1 KiB
Plaintext
76 lines
1.1 KiB
Plaintext
{$MODE delphi}
|
|
|
|
unit GLUT;
|
|
|
|
interface
|
|
|
|
{$MACRO ON}
|
|
|
|
{$IFDEF Win32}
|
|
{$DEFINE glut_dll := }
|
|
{$DEFINE gldecl := stdcall;}
|
|
{$DEFINE extdecl := stdcall;}
|
|
uses windows, GL;
|
|
{$ELSE}
|
|
{$MESSAGE Unsupported platform.}
|
|
{$ENDIF}
|
|
|
|
|
|
function InitGLUTFromLibrary(libname: PChar): Boolean;
|
|
|
|
// determines automatically which library to use:
|
|
function InitGLUT: Boolean;
|
|
|
|
|
|
var
|
|
GLUTDumpUnresolvedFunctions,
|
|
GLUTInitialized: Boolean;
|
|
|
|
|
|
%GLUTDeclsIF
|
|
|
|
var
|
|
%GLUTProcsPD
|
|
|
|
|
|
implementation
|
|
|
|
|
|
type
|
|
HInstance = LongWord;
|
|
|
|
var
|
|
libGLUT: HInstance;
|
|
|
|
function GetProc(handle: HInstance; name: PChar): Pointer;
|
|
begin
|
|
Result := GetProcAddress(handle, name);
|
|
if (Result = nil) and GLUTDumpUnresolvedFunctions then
|
|
WriteLn('Unresolved: ', name);
|
|
end;
|
|
|
|
function InitGLUTFromLibrary(libname: PChar): Boolean;
|
|
begin
|
|
Result := False;
|
|
libGLUT := LoadLibrary(libname);
|
|
if libGLUT = 0 then exit;
|
|
|
|
%GLUTProcsPL
|
|
|
|
GLUTInitialized := True;
|
|
Result := True;
|
|
end;
|
|
|
|
|
|
function InitGLUT: Boolean;
|
|
begin
|
|
Result := InitGLUTFromLibrary('glut32.dll');
|
|
end;
|
|
|
|
|
|
initialization
|
|
InitGLUT;
|
|
finalization
|
|
if libGLUT <> 0 then FreeLibrary(libGLUT);
|
|
end.
|