SDL_GL_LoadLibrary and win32

We’re having problems using SDL_GL_LoadLibrary on win32 systems. It works
fine here in Linux, but nothing we’ve tried has worked for win32 yet.
What we have is very similar to what SDL itself uses, which is even more
infuriating. Our native win32 porting person hasn’t a clue how any of
this works. =/ I’d greatly appreciate it if someone could explain where
we are going wrong here.

First, the list of functions:

#ifndef TWIGL_DONT_NEED
#define TWIGL_DONT_NEED(ret, func, params)
#define UNDEF_TWIGL_DONT_NEED
#endif

TWIGL_DONT_NEED (void, glAccum, (GLenum op, GLfloat value));
TWIGL_DONT_NEED (void, glActiveTextureARB, (GLenum texture));
TWIGL_NEED (void, glAlphaFunc, (GLenum func, GLclampf ref));
:

#ifdef UNDEF_TWIGL_DONT_NEED
#undef TWIGL_DONT_NEED
#endif

Then the externs:

#define TWIGL_NEED(ret, name, args) extern ret (* q##name) args
#include “TGL_funcs_list.h”
#undef TWIGL_NEED

Then in a .c file:

// First we need all the function pointers.
#define TWIGL_NEED(ret, name, args)
ret APIENTRY (* q##name) args = NULL;
#include “TGL_funcs_list.h”
#undef TWIGL_NEED

and an init function:

{
… SDL_GL_LoadLibrary ( … ) …

#define TWIGL_NEED(ret, name, args)                 \
	if (!(q##name = SDL_GL_GetProcAddress(#name))) {    \
		Sys_Error ("Can't load func %s: %s\n", #name, \
		SDL_GetError()); \
		return false; \
	}

#include "TGL_funcs_list.h"
#undef TWIGL_NEED

return true;

}

Is there anything inherently wrong with this? It works fine for Linux, as
I said. It works in win32 if APIENTRY is defined to nothing but then will
not run. If APIENTRY is defined to __stdcall it will not compile due to a
syntax error.

I wish I could offer more than that to help debug the problem. Our win32
guy unfortunately has not been able to really provide me with anything
else useful to debug the problem. If it’d be better to try and compile
it, the code’s in CVS on sourceforge (http://sf.net/projects/twilight/),
but I can make a zip of my working directory if it’s really needed.

At this point, I’m probably even more frustrated with it than Vic is.
Win32 compiler issues are outside my field, so there’s nothing I can do to
fix it.–
Joseph Carter Free software developer

  • joeyh_ runs ps and sees 10 lines of awk code
  • joeyh_ recoils in horror

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20010813/efffe4e7/attachment.pgp

Problem found… The solution is explained by these patchlets nicely:

-#define TWIGL_NEED(ret, name, args) extern ret (* q##name) args
+#define TWIGL_NEED(ret, name, args) extern ret (APIENTRY * q##name) args

-#define TWIGL_NEED(ret, name, args)
-ret APIENTRY (* q##name) args = NULL;
+#define TWIGL_NEED(ret, name, args) ret (APIENTRY * q##name) args = NULL;

We’re all going to be kicking ourselves for some time over this one.–
Joseph Carter Free software developer

As a computer, I find your faith in technology amusing.

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20010813/a16dfa31/attachment.pgp