From d743f936164b04fd60aa529775efd15c73dd22a6 Mon Sep 17 00:00:00 2001 From: sg Date: Thu, 16 Mar 2000 17:40:39 +0000 Subject: [PATCH] * Fixed GL* library loading functions --- packages/opengl/build/README | 6 +++--- packages/opengl/build/gl_linux.tpl | 16 ++++++++++++---- packages/opengl/build/glut_linux.tpl | 14 ++++++++++---- packages/opengl/examples/glutdemo.pp | 10 ++++++++++ packages/opengl/linux/gl.pp | 21 ++++++++++++++------- packages/opengl/linux/glut.pp | 19 ++++++++++++------- 6 files changed, 61 insertions(+), 25 deletions(-) diff --git a/packages/opengl/build/README b/packages/opengl/build/README index 27e09461ce..635f1c8ea9 100644 --- a/packages/opengl/build/README +++ b/packages/opengl/build/README @@ -1,5 +1,5 @@ Free Pascal GL* Units -(c) 1999 Sebastian Guenther +(c) 1999-2000 Sebastian Guenther, sg@freepascal.org buildgl.pp @@ -10,8 +10,8 @@ holds the informations in the read .def file. c_linuxd.pp ----------- -This program creates the dynamic Linux units "linuxd/gl.pp" and -"linuxd/glut.pp". +This program creates the Linux units "linux/gl.pp" and "linux/glut.pp". + *.def ----- diff --git a/packages/opengl/build/gl_linux.tpl b/packages/opengl/build/gl_linux.tpl index 30397661da..a78c14ee70 100644 --- a/packages/opengl/build/gl_linux.tpl +++ b/packages/opengl/build/gl_linux.tpl @@ -1,7 +1,7 @@ { $Id$ Translation of the Mesa GL, GLU and GLX headers for Free Pascal - Linux Version, Copyright (C) 1999 Sebastian Guenther + Linux Version, Copyright (C) 1999-2000 Sebastian Guenther Mesa 3-D graphics library @@ -47,6 +47,11 @@ function InitGLU: Boolean; var GLInitialized, GLUInitialized, GLXInitialized: Boolean; + { Set the following value to True if you want to have a list of all + unresolved GL/GLU/GLX functions dumped to the console } + GLDumpUnresolvedFunctions: Boolean; + + %GLDecls %GLProcs1 @@ -84,7 +89,8 @@ end; function GetProc(handle: Pointer; name: PChar): Pointer; begin Result := dlsym(handle, name); - if Result = nil then WriteLn('Unresolved: ', name); + if not Assigned(Result) and GLDumpUnresolvedFunctions then + WriteLn('Unresolved: ', name); end; var @@ -129,12 +135,14 @@ end; function InitGL: Boolean; begin - Result := InitGLFromLibrary('libGL.so.1') or InitGLFromLibrary('libMesaGL.so.1'); + Result := InitGLFromLibrary('libGL.so') or InitGLFromLibrary('libGL.so.1') or + InitGLFromLibrary('libMesaGL.so.3'); end; function InitGLU: Boolean; begin - Result := InitGLUFromLibrary('libGLU.so.1') or InitGLUFromLibrary('libMesaGLU.so.1'); + Result := InitGLUFromLibrary('libGLU.so') or + InitGLUFromLibrary('libGLU.so.1') or InitGLUFromLibrary('libMesaGLU.so.3'); end; diff --git a/packages/opengl/build/glut_linux.tpl b/packages/opengl/build/glut_linux.tpl index 1cfb6f5eb8..a0a1d4d626 100644 --- a/packages/opengl/build/glut_linux.tpl +++ b/packages/opengl/build/glut_linux.tpl @@ -2,7 +2,7 @@ $Id$ Translation of the Mesa GLUT headers for FreePascal - Linux Version, Copyright (C) 1999 Sebastian Guenther + Linux Version, Copyright (C) 1999-2000 Sebastian Guenther Mesa 3-D graphics library @@ -42,6 +42,10 @@ function InitGLUT: Boolean; var GLUTInitialized: Boolean; + { Set the following value to True if you want to have a list of all + unresolved GLUT functions dumped to the console } + GLUTDumpUnresolvedFunctions: Boolean; + @@ -229,7 +233,8 @@ end; function GetProc(handle: Pointer; name: PChar): Pointer; begin Result := dlsym(handle, name); -// if Result = nil then WriteLn('Unresolved: ', name); + if not Assigned(Result) and GLUTDumpUnresolvedFunctions then + WriteLn('Unresolved: ', name); end; var @@ -250,11 +255,12 @@ end; function InitGLUT: Boolean; begin - Result := InitGLUTFromLibrary('libglut.so.1'); + Result := InitGLUTFromLibrary('libglut.so') or InitGLUTFromLibrary('libglut.so.3'); end; finalization - if Assigned(libGLUT) then FreeLibrary(libGLUT); + if Assigned(libGLUT) then + FreeLibrary(libGLUT); end. diff --git a/packages/opengl/examples/glutdemo.pp b/packages/opengl/examples/glutdemo.pp index dd9daeec05..21059e0190 100644 --- a/packages/opengl/examples/glutdemo.pp +++ b/packages/opengl/examples/glutdemo.pp @@ -101,6 +101,15 @@ end; begin + WriteLn('Dumping unresolved GL* function names; having unresolved functions '); + WriteLn('is NOT a problem as long as the application doesn''t use them!'); + WriteLn('(Most unresolved functions will be propietary extensions which'); + WriteLn(' should be an official GL extension)'); + WriteLn; + + GLDumpUnresolvedFunctions := True; + GLUTDumpUnresolvedFunctions := True; + if not InitGl then begin WriteLn('OpenGL is not supported on this system'); Halt(2); @@ -127,6 +136,7 @@ begin glutTimerFunc(20, @OnTimer, 0); + WriteLn; WriteLn('GL info:'); WriteLn(' Vendor: ', glGetString(GL_VENDOR)); WriteLn(' Renderer: ', glGetString(GL_RENDERER)); diff --git a/packages/opengl/linux/gl.pp b/packages/opengl/linux/gl.pp index 2b0aa00832..b5b0330b5b 100644 --- a/packages/opengl/linux/gl.pp +++ b/packages/opengl/linux/gl.pp @@ -1,7 +1,7 @@ { $Id$ Translation of the Mesa GL, GLU and GLX headers for Free Pascal - Linux Version, Copyright (C) 1999 Sebastian Guenther + Linux Version, Copyright (C) 1999-2000 Sebastian Guenther Mesa 3-D graphics library @@ -47,6 +47,11 @@ function InitGLU: Boolean; var GLInitialized, GLUInitialized, GLXInitialized: Boolean; + { Set the following value to True if you want to have a list of all + unresolved GL/GLU/GLX functions dumped to the console } + GLDumpUnresolvedFunctions: Boolean; + + // =================================================================== // GL consts, types and functions // =================================================================== @@ -1677,7 +1682,8 @@ end; function GetProc(handle: Pointer; name: PChar): Pointer; begin Result := dlsym(handle, name); - if Result = nil then WriteLn('Unresolved: ', name); + if not Assigned(Result) and GLDumpUnresolvedFunctions then + WriteLn('Unresolved: ', name); end; var @@ -2122,12 +2128,14 @@ end; function InitGL: Boolean; begin - Result := InitGLFromLibrary('libGL.so.1') or InitGLFromLibrary('libMesaGL.so.1'); + Result := InitGLFromLibrary('libGL.so') or InitGLFromLibrary('libGL.so.1') or + InitGLFromLibrary('libMesaGL.so.3'); end; function InitGLU: Boolean; begin - Result := InitGLUFromLibrary('libGLU.so.1') or InitGLUFromLibrary('libMesaGLU.so.1'); + Result := InitGLUFromLibrary('libGLU.so') or + InitGLUFromLibrary('libGLU.so.1') or InitGLUFromLibrary('libMesaGLU.so.3'); end; @@ -2141,8 +2149,7 @@ end. { $Log$ - Revision 1.3 2000-01-26 21:21:49 peter - * link with .so.1 files, the .so files are for development only and - not available in runtime installs. + Revision 1.4 2000-03-16 17:40:39 sg + * Fixed GL* library loading functions } diff --git a/packages/opengl/linux/glut.pp b/packages/opengl/linux/glut.pp index 6a8b8fb18e..7e6f56ebe7 100644 --- a/packages/opengl/linux/glut.pp +++ b/packages/opengl/linux/glut.pp @@ -2,7 +2,7 @@ $Id$ Translation of the Mesa GLUT headers for FreePascal - Linux Version, Copyright (C) 1999 Sebastian Guenther + Linux Version, Copyright (C) 1999-2000 Sebastian Guenther Mesa 3-D graphics library @@ -42,6 +42,10 @@ function InitGLUT: Boolean; var GLUTInitialized: Boolean; + { Set the following value to True if you want to have a list of all + unresolved GLUT functions dumped to the console } + GLUTDumpUnresolvedFunctions: Boolean; + @@ -323,7 +327,8 @@ end; function GetProc(handle: Pointer; name: PChar): Pointer; begin Result := dlsym(handle, name); -// if Result = nil then WriteLn('Unresolved: ', name); + if not Assigned(Result) and GLUTDumpUnresolvedFunctions then + WriteLn('Unresolved: ', name); end; var @@ -384,20 +389,20 @@ end; function InitGLUT: Boolean; begin - Result := InitGLUTFromLibrary('libglut.so.1'); + Result := InitGLUTFromLibrary('libglut.so') or InitGLUTFromLibrary('libglut.so.3'); end; finalization - if Assigned(libGLUT) then FreeLibrary(libGLUT); + if Assigned(libGLUT) then + FreeLibrary(libGLUT); end. { $Log$ - Revision 1.3 2000-01-26 21:21:50 peter - * link with .so.1 files, the .so files are for development only and - not available in runtime installs. + Revision 1.4 2000-03-16 17:40:39 sg + * Fixed GL* library loading functions }