Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

nomore_pf

OpenGL OpenGL Extensions with SDL

This topic is 5737 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

Hi people, I''m trying to get OpenGL Extensions working with SDL. I''m getting the function pointers via SDL_GL_GetProcAdress(). So far, receving the functions works. But when I want to call an extensions I''m getting a function pointer error.
typedef void (*GL_ActiveTextureARB_Func)(GLenum);
typedef void (*GL_MultiTexCoord2fARB_Func)(GLenum, GLfloat, GLfloat);

class tGLExtensions
{
public:
   tGLExtensions();
   ~tGLExtensions();

   void   initExtensions();

   //OpenGL Extensions
   GL_ActiveTextureARB_Func   glActiveTextureARB;
   GL_MultiTexCoord2fARB_Func   glMultiTexCoord2fARB;
private: 
 
tGLExtensions::tGLExtensions()
{
   glActiveTextureARB = NULL;
   glMultiTexCoord2fARB = NULL;
}

void tGLExtensions::initExtensions()
{
   tLogger::write(LLEVEL_NORMAL,"[-] initializing OpenGL extensions\n");

   
   //multitexuring extensions
   glActiveTextureARB =(GL_ActiveTextureARB_Func) SDL_GL_GetProcAddress("glActiveTextureARB");
   if(!glActiveTextureARB)
   {
      tLogger::write(LLEVEL_NORMAL,"[-] multitexturing is not available\n");
   }
   else
   {
      glMultiTexCoord2fARB = (GL_MultiTexCoord2fARB_Func) SDL_GL_GetProcAddress("glMultiTexCoord2fARB");
      if(!glMultiTexCoord2fARB)
         tLogger::write(LLEVEL_PANIC,"[!] failed to activate glMultiTexCoord2fARB\n");

      tLogger::write(LLEVEL_NORMAL,"[-] activated multitexturing extensions\n");
   }

   tLogger::write(LLEVEL_NORMAL,"[-] initialized OpenGL extensions\n");
} 
 
An example for calling an extension: tSystem::getInstance()->getRenderDevice()->glActiveTextureARB(GL_TEXTURE0_ARB); (RenderDevice inherits tGLExtensions...) I''m getting this error on VC6: "The value of ESD was not properbly saved across a function call...." does anyone know what I''m doing wrong ??

Share this post


Link to post
Share on other sites
Advertisement
> tSystem::getInstance()->getRenderDevice()->glActiveTextureARB(GL_TEXTURE0_ARB);
OMFG that''s awful - gone a bit overboard there, eh?
Seriously, though, I think your problem is that the pointers are called with __thiscall convention, while normal C functions are __cdecl. The this parameter isn''t cleaned up, so esp is off by 4. Not good.
Why not do the sensible thing and make those function pointers global (like all other gl functions)?

Share this post


Link to post
Share on other sites

  • 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!