glu_linux.tem 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. {
  2. $Id$
  3. Translation of the Mesa GLU headers for FreePascal
  4. 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} // objfpc would not work because of direct proc var assignments
  21. {You have to enable Macros (compiler switch "-Sm") for compiling this unit!
  22. This is necessary for supporting different platforms with different calling
  23. conventions via a single unit.}
  24. unit GLU;
  25. interface
  26. {$MACRO ON}
  27. {$IFDEF Linux}
  28. uses GL;
  29. {$ELSE}
  30. {$MESSAGE Unsupported platform.}
  31. {$ENDIF}
  32. // =======================================================
  33. // Unit specific extensions
  34. // =======================================================
  35. function InitGLUFromLibrary(libname: PChar): Boolean;
  36. // determines automatically which libraries to use:
  37. function InitGLU: Boolean;
  38. var
  39. GLUDumpUnresolvedFunctions,
  40. GLUInitialized: Boolean;
  41. // =======================================================
  42. // GLU consts, types and functions
  43. // =======================================================
  44. %GLUDeclsIF
  45. var
  46. %GLUProcsPD
  47. // =======================================================
  48. //
  49. // =======================================================
  50. implementation
  51. {$LINKLIB m}
  52. function dlopen(AFile: PChar; mode: LongInt): Pointer; external 'dl';
  53. function dlclose(handle: Pointer): LongInt; external 'dl';
  54. function dlsym(handle: Pointer; name: PChar): Pointer; external 'dl';
  55. function LoadLibrary(name: PChar): Pointer;
  56. begin
  57. Result := dlopen(name, $101 {RTLD_GLOBAL or RTLD_LAZY});
  58. end;
  59. function GetProc(handle: Pointer; name: PChar): Pointer;
  60. begin
  61. Result := dlsym(handle, name);
  62. if (Result = nil) and GLUDumpUnresolvedFunctions then
  63. WriteLn('Unresolved: ', name);
  64. end;
  65. var
  66. libGLU : Pointer;
  67. function InitGLUFromLibrary(libname: PChar): Boolean;
  68. begin
  69. Result := False;
  70. libGLU := LoadLibrary(libname);
  71. if not Assigned(libGLU) then exit;
  72. %GLUProcsPL
  73. GLUInitialized := True;
  74. Result := True;
  75. end;
  76. function InitGLU: Boolean;
  77. begin
  78. Result := InitGLUFromLibrary('libGLU.so') or
  79. InitGLUFromLibrary('libGLU.so.1') or
  80. InitGLUFromLibrary('libMesaGLU.so') or
  81. InitGLUFromLibrary('libMesaGLU.so.3');
  82. end;
  83. initialization
  84. InitGlU;
  85. finalization
  86. if Assigned(libGLU) then dlclose(libGLU);
  87. end.
  88. {
  89. $Log$
  90. Revision 1.1 2000-09-03 21:25:45 peter
  91. * new updated version
  92. * gtkglarea unit and demo
  93. * win32 opengl headers
  94. * morph3d demo
  95. Revision 1.1 2000/07/13 06:34:18 michael
  96. + Initial import
  97. Revision 1.1 2000/05/31 00:35:14 alex
  98. added working templates
  99. }