glut_w32d.tem 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. {$MODE delphi}
  2. unit GLUT;
  3. interface
  4. {$MACRO ON}
  5. {$IFDEF Win32}
  6. {$DEFINE glut_dll := }
  7. {$DEFINE gldecl := stdcall;}
  8. {$DEFINE extdecl := stdcall;}
  9. uses windows, GL;
  10. {$ELSE}
  11. {$MESSAGE Unsupported platform.}
  12. {$ENDIF}
  13. function InitGLUTFromLibrary(libname: PChar): Boolean;
  14. // determines automatically which library to use:
  15. function InitGLUT: Boolean;
  16. var
  17. GLUTDumpUnresolvedFunctions,
  18. GLUTInitialized: Boolean;
  19. %GLUTDeclsIF
  20. var
  21. %GLUTProcsPD
  22. implementation
  23. type
  24. HInstance = LongWord;
  25. var
  26. libGLUT: HInstance;
  27. function GetProc(handle: HInstance; name: PChar): Pointer;
  28. begin
  29. Result := GetProcAddress(handle, name);
  30. if (Result = nil) and GLUDumpUnresolvedFunctions then
  31. WriteLn('Unresolved: ', name);
  32. end;
  33. function InitGLUTFromLibrary(libname: PChar): Boolean;
  34. begin
  35. Result := False;
  36. libGLUT := LoadLibrary(libname);
  37. if libGLUT = 0 then exit;
  38. %GLUTProcsPL
  39. GLUTInitialized := True;
  40. Result := True;
  41. end;
  42. function InitGLUT: Boolean;
  43. begin
  44. Result := InitGLUTFromLibrary('glut32.dll');
  45. end;
  46. initialization
  47. InitGLUT;
  48. finalization
  49. if libGLUT <> 0 then FreeLibrary(libGLUT);
  50. end.