Hi Richard,

On Tue, 2004-09-21 at 20:58, Richard Boyce wrote:
> 
> Yes, I found that the Mesa headers were used for compilation while
> NVidia's libGL.so was called. I placed NVidia's headers in the
> appropriate directory and recompiled OpenSG. Furthermore, I
> reinstalled NVIdia's drivers just to make there was no problem.  Now
> things are in line but the same problem occurs. 

:(

> I have found that the R version only works if I set
> OSG_IGNORE_EXTENSIONS to all extensions listed. While I am glad it
> works, this is odd because the executable finds all extensions and
> runs fine. 

If you set OSG_IGNORE_EXTENSIONS, they will just be ignored. It still
works, but some features are not available.

> Could this have something to do with the way dlopen and dlsym are used
> in OSGWindow.cpp? 
> 
> Window::getFunctionByName(const Char8 *s) for linux/sgi/etc.. uses:
> 
>     libHandle = dlopen(NULL, RTLD_NOW | RTLD_LOCAL);
> 
> this causes libHandle to be assigned he handle to the "main program",
> it is clear to me what is main in an executable but not in a shared
> lib. 

Given that you're the first to do that, I hadn't though about that.

> I tested the section of Window::getFunctionByName that attempts to
> load the extension function in the R shared object and found a couple
> of small problems:
> 
> 1. no warnings were generated when glXGetProcAddress and
> glXGetProcAddressARB failed to load because dlerror should be saved to
> a variable before written. The warning appears with the following
> changes:
> if ((error = dlerror()) != NULL)  {
>           FWARNING (("Window::getFunctionByName error locating
> glXGetProcAddress: %s\n", error));

I can't find that part in OSGWindow.cpp.

> This told me that libHandle = dlopen(NULL, RTLD_NOW | RTLD_LOCAL)
> assigned the address of the shared lib I made from the OpenSGNav app
> and thus could not find the Gl symbols (I am not clear on why since
> -lGL is linked Wl,-Bdynamic but will study this more)

Yup, that's what it looks like.

> 2. Window::frameInit() proceeds with  _extFunctions.push_back(func)
> even when  (void*)getFunctionByName(s) returns NULL. This seems
> intended but causes the error in my case where the extensions are
> registered but are not correctly loaded causing a crash when on of the
> extensions are called by the scenegraph.

Yeah, the case that the extensions are there but the functions are not
shouldn't happen, so there are no precautions against that.

> I saw the thread on "Proper use of OpenGL-extensions". Since I can get
> the extensions from the libraries by explicitly loading them w/ dlopen
> (e.g.  libHandle = dlopen("libGL.so.1", RTLD_NOW | RTLD_LOCAL);)
> Should I use the Window API to manually insert any desired extensions
> for windows in the R programs init method? 

No, that wouldn't help, as they would still go through the same
mechanism. But given that you can get them by explicitly specifying the
name of the OpenGL library, I added an option that allows you to set
that (Window::setGLLibraryName(const Char8 *name);) before any extension
functions are resolved. It's safe to call that before osgInit, or
shortly after it. I appended a diff to the current CVS with that change.

Hope it helps

        Dirk



Index: OSGWindow.h
===================================================================
RCS file: /cvsroot/opensg/OpenSG/Source/System/Window/OSGWindow.h,v
retrieving revision 1.19
diff -u -3 -p -r1.19 OSGWindow.h
--- OSGWindow.h 4 Aug 2004 23:04:58 -0000       1.19
+++ OSGWindow.h 22 Sep 2004 03:50:44 -0000
@@ -150,6 +150,9 @@ class OSG_SYSTEMLIB_DLLMAPPING Window :
     /*!
\{                                                                 */
  
     static
+    inline void                 setGLLibraryName  (const Char8  *s   );
+
+    static
     inline Int32                getExtensionId    (const Char8  *s   );
     inline bool                 hasExtension      (      UInt32  id  );
            bool                 hasExtension      (const Char8  *s   );
@@ -366,6 +369,8 @@ class OSG_SYSTEMLIB_DLLMAPPING Window :
     /*! \name        GL Object / Extension
variables                       */
     /*!
\{                                                                 */
  
+    static const Char8      *_glLibraryName;
+
     std::vector<UInt32     > _lastValidate;
     std::vector<UInt32     > _ids;
  
Index: OSGWindow.cpp
===================================================================
RCS file: /cvsroot/opensg/OpenSG/Source/System/Window/OSGWindow.cpp,v
retrieving revision 1.37
diff -u -3 -p -r1.37 OSGWindow.cpp
--- OSGWindow.cpp       20 Aug 2004 11:25:25 -0000      1.37
+++ OSGWindow.cpp       22 Sep 2004 03:50:44 -0000
@@ -221,6 +221,11 @@ std::vector<OSG::Window::GLObject *>  OS
  
 // GL extension handling
  
+// The name of the dynamic library for OpenGL extension functions
+// By default it's NULL, which tries to find them in the current
+// executable
+const Char8 *OSG::Window::_glLibraryName = NULL;
+
 std::vector<std::string            > 
OSG::Window::_registeredExtensions;
 std::vector<std::string            >  OSG::Window::_ignoredExtensions;
 std::vector<bool                   >  OSG::Window::_commonExtensions;

  

/***************************************************************************\
@@ -1238,7 +1241,7 @@ OSG::Window::GLExtensionFunction OSG::Wi
  
     if(libHandle == NULL)
     {
-        libHandle = dlopen(NULL, RTLD_NOW | RTLD_LOCAL);
+        libHandle = dlopen(_glLibraryName, RTLD_NOW | RTLD_LOCAL);
  
         if(!libHandle)
         {
@@ -1254,6 +1257,15 @@ OSG::Window::GLExtensionFunction OSG::Wi
         if(__GetProcAddress == NULL)
         {
             __GetProcAddress = (void (*(*)(const GLubyte*))())
dlsym(libHandle, "glXGetProcAddressARB");
+
+            if(__GetProcAddress == NULL)
+            {
+                FWARNING(("Neither glXGetProcAddress nor "
+                        "glXGetProcAddressARB found! Disabling all "
+                        " extensions for Window %p!"));
+                _availExtensions.clear();
+                _availExtensions.resize(_registeredExtensions.size(),
false);
+            }
         }
     }
  
Index: OSGWindow.inl
===================================================================
RCS file: /cvsroot/opensg/OpenSG/Source/System/Window/OSGWindow.inl,v
retrieving revision 1.12
diff -u -3 -p -r1.12 OSGWindow.inl
--- OSGWindow.inl       5 Jul 2004 11:39:54 -0000       1.12
+++ OSGWindow.inl       22 Sep 2004 03:50:44 -0000
@@ -113,6 +113,15 @@ inline Real32 Window::getConstantValue(G
     return getConstantValuev(id)[0];
 }
  
+/*! Set the library name where to find OpenGL extension functions. This
has
+    to be called before the first extension function is accessed, and
it's
+    safe to call it before osgInit().
+*/
+inline void Window::setGLLibraryName(const Char8  *s)
+{
+    _glLibraryName = s;
+}
+
 /*! Find the id of a registered extension. Return -1 if extension not
     registered.
 */




-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to