Jump to content
  • Advertisement
Sign in to follow this  
kRogue

ltdl issues.

This topic is 4148 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to keep my code OS agnostic, so I have been using ltdl to load both GL and GLU functions at runtime... under Linux this is all fine, but under Windows loading GL functions can be flaky: Init code:
void kgl_InitSystem(const char *gl, const char *glu)
{
  lt_dlinit();

  if(dlHandleGLU==NULL and glu!=NULL)
    {
      LogStream(UtilityLog, "Loading glu library " << glu << "\n");    
      dlHandleGLU=lt_dlopen(glu);
      if(dlHandleGLU==NULL)
      {
        ErrorStream("Failed to open GLU library! " << glu << "\n");
      }
      gluName=glu;
    }

  if(dlHandleGL==NULL and gl!=NULL)
    {
      LogStream(UtilityLog, "Loading gl library " << gl << "\n");
      dlHandleGL=lt_dlopen(gl);
      if(dlHandleGL==NULL)
      {
        ErrorStream("Failed to open GL library! " << gl << "\n");
      }
      glName=gl;
      SDL_GL_LoadLibrary(glName.c_str());
    }


}

to fetch functions:
void *kgl_loadGLUfunction(const char *name)
{
  
  if(dlHandleGLU==NULL)
    {
      ErrorStream("Unable to load glu function " << name 
		  << " because library is not inited yet\n");
      return NULL;
    }
  LogStream(UtilityLog,"Loading glu function \"" << name << "\" from library \"" << gluName << "\"\n");
  
  return lt_dlsym(dlHandleGLU,name);
}

void *kgl_loadGLfunction(const char *name)
{
  LogStream(UtilityLog,"Loading gl function \"" << name << "\" from library \"" << glName << "\"\n");
  
#if 1 
  //under windows, using SDL is more reliable than lt_dlsym.
  //under windows  SDL_GL_GetProcAddress calls wglGetProcAddress,
  //but one would *think* that lt_dlsym would be fine.
  return SDL_GL_GetProcAddress(name);

#else
  if(dlHandleGL==NULL)
    {
      ErrorStream("Unable to load gl function " << name 
		  << " because library is not inited yet\n");
      return NULL;
    }
   return lt_dlsym(dlHandleGL,name);
#endif

 
}

if I put "#if 0" to use the ltdl system, it fails to load some GL functions, but not all... if I put #if 0# and thus use SDL_GL_GetProcAddress, all is cool, but eh big question is WHY?! (in Windows SDL_GL_GetProcAddress just calls wglGetProcAddress) anyone know?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!