Sorry, my bad.  I didn't understand how Apple's gcc interacts with  
system frameworks (looks like I'm still a Unix guy ...), that's why I  
thought we'd have to use the include files from X11 (but then link  
against the framework libraries).

Apparently, gcc automatically locates header files in the system  
frameworks if the #include in C specifies a subdirectory that has the  
same name as the system framework.  That's why we need

        #include <GLUT/glut.h>

instead of <GL/glut.h> to build directly with the GLUT framework.  For  
OpenGL, the framework is called OpenGL, so we need includes

        #include <OpenGL/gl.h>
        #include <OpenGL/glu.h>

instead of <GL/gl.h> and <GL/glu.h>.  These includes are nicely  
encapsulated in the module's source code, so this would be a fairly  
easy change (I suggest using an #ifdef HAVE_AGL_GLUT, because that  
indicates we're building the AGL interface).


However, there are a few drawbacks:

1. Everything breaks down because of zillions of conflicting  
definitions.  Almost everything in "glext_procs.h" is also defined in  
Apple's <OpenGL/gl.h> (but doesn't seem to be in the X11 <GL/gl.h>  
header); a notable exception is the GLAPI macro.  Also, various  
functions like glUniformMatrix2x3fv() (from "gl_util.h") are also  
defined in <OpenGL/gl.h>.

2. This only works as long as people use the standard Perl and GCC  
that come with Mac OS X.  Antonio said he'd built his own Perl, and  
there's a chance he picked up a gcc installed with Fink, which won't  
automatically include the system frameworks (I think).

I suspect that problem 1 can be fixed, but it will probably take some  
patience and a few rounds of trial and error.  I don't understand  
enough about OpenGL to know where all these macros and functions  
should be declared.


When trying to track down the header files, I got very confused  
because the Perl build seemed to be picking up a <GL/gl.h> that it  
shouldn't be able to see.  It turned out that ON EVERY PLATFORM EXCEPT  
WINDOWS, the local file "include/GL/gl.h" is used instead of the  
system headers, by the following code on lines 16 .. 21 of "gl_util.h":

> /* Provide GL header files for Windows */
> #define INCLUDE_LOCAL_HEADER !defined(HAVE_W32API)
> #if INCLUDE_LOCAL_HEADER
> #include "./include/GL/gl.h"
> #else
> #include <GL/gl.h>
> #endif

I can't believe this is intentional, as it does the exact opposite of  
what the comment says.  The strange thing is that the module builds  
correctly without X11 if we include <OpenGL/glu.h> and <GLUT/glut.h>  
from the frameworks, but use local "include/GL/gl.h" instead of the  
system header.  But isn't that inviting disaster?  Can you be sure  
that this local header file is compatible with the actual OpenGL  
libraries?

Rather confusedly,
Stefan


PS: I'll send a patch for the messy version (GLU and GLUT from  
frameworks, local gl.h header) off list. It compiles and passes all  
tests on my machine, but I'm still worried about not using a system  
header file!

>

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to