glut_linux.tpl 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. {
  2. $Id$
  3. Translation of the GLUT 3.7 headers for Free Pascal, Linux version
  4. Copyright (C) 1999-2000 Sebastian Guenther, [email protected]
  5. Copyright (c) Mark J. Kilgard, 1994, 1995, 1996, 1998.
  6. This program is freely distributable without licensing fees and is
  7. provided without guarantee or warrantee expressed or implied. This
  8. program is -not- in the public domain.
  9. }
  10. unit GLUT;
  11. {$MODE delphi}
  12. interface
  13. uses GL;
  14. function InitGLUTFromLibrary(const libname: PChar): Boolean;
  15. // determines automatically which library to use:
  16. function InitGLUT: Boolean;
  17. var
  18. GLUTInitialized: Boolean;
  19. { Set the following value to True if you want to have a list of all
  20. unresolved GLUT functions dumped to the console }
  21. GLUTDumpUnresolvedFunctions: Boolean;
  22. %GLUTDecls
  23. { The following stuff does not exist in the Win32 version: }
  24. (* commented out because cvars don't work in Delphi mode...
  25. // Stroke font opaque addresses (use constants instead in source code).
  26. var
  27. glutStrokeRoman, glutStrokeMonoRoman: Pointer; cvar; external;
  28. // Stroke font constants (use these in GLUT program).
  29. const
  30. GLUT_STROKE_ROMAN = @glutStrokeRoman;
  31. GLUT_STROKE_MONO_ROMAN = @glutStrokeMonoRoman;
  32. // Bitmap font opaque addresses (use constants instead in source code).
  33. var
  34. glutBitmap9By15, glutBitmap8By13, glutBitmapTimesRoman10,
  35. glutBitmapTimesRoman24, glutBitmapHelvetica10, glutBitmapHelvetica12,
  36. glutBitmapHelvetica18: Pointer; cdecl; external;
  37. // Bitmap font constants (use these in GLUT program).
  38. const
  39. GLUT_BITMAP_9_BY_15 = @glutBitmap9By15;
  40. GLUT_BITMAP_8_BY_13 = @glutBitmap8By13;
  41. GLUT_BITMAP_TIMES_ROMAN_10 = @glutBitmapTimesRoman10;
  42. GLUT_BITMAP_TIMES_ROMAN_24 = @glutBitmapTimesRoman24;
  43. GLUT_BITMAP_HELVETICA_10 = @glutBitmapHelvetica10;
  44. GLUT_BITMAP_HELVETICA_12 = @glutBitmapHelvetica12;
  45. GLUT_BITMAP_HELVETICA_18 = @glutBitmapHelvetica18;*)
  46. %GLUTProcs1
  47. implementation
  48. {$LINKLIB Xmu}
  49. function dlopen(const AFile: PChar; mode: LongInt): Pointer; external 'dl';
  50. function dlclose(handle: Pointer): LongInt; external 'dl';
  51. function dlsym(handle: Pointer; const name: PChar): Pointer; external 'dl';
  52. function LoadLibrary(const name: PChar): Pointer;
  53. begin
  54. Result := dlopen(name, $101 {RTLD_GLOBAL or RTLD_LAZY});
  55. end;
  56. procedure FreeLibrary(handle: Pointer);
  57. begin
  58. dlclose(handle);
  59. end;
  60. function GetProc(handle: Pointer; const name: PChar): Pointer;
  61. begin
  62. Result := dlsym(handle, name);
  63. if not Assigned(Result) and GLUTDumpUnresolvedFunctions then
  64. WriteLn('Unresolved: ', name);
  65. end;
  66. var
  67. libGLUT: Pointer;
  68. function InitGLUTFromLibrary(const libname: PChar): Boolean;
  69. begin
  70. Result := False;
  71. libGLUT := LoadLibrary(libname);
  72. if not Assigned(libGLUT) then
  73. exit;
  74. %GLUTProcs2
  75. GLUTInitialized := True;
  76. Result := True;
  77. end;
  78. function InitGLUT: Boolean;
  79. begin
  80. Result := InitGLUTFromLibrary('libglut.so') or InitGLUTFromLibrary('libglut.so.3');
  81. end;
  82. finalization
  83. if Assigned(libGLUT) then
  84. FreeLibrary(libGLUT);
  85. end.