[Gtkradiant] [Bug 679] New: osx.diff for radiant 1.2.11
EvilTypeGuy
gtkradiant@zerowing.idsoftware.com
11 Nov 2002 17:51:20 -0600
On Mon, 2002-11-11 at 14:59, bugzilla-daemon@zerowing.idsoftware.com >
> the following diff is what I had to change to get GtkRadiant 1.2.11 to compile
> on Mac OS X 10.2.1 using the latest Project Builder...I am posting the Project
> Builder file to GtkRad-Macos cuz I'm not sure how to add an attachment with
> bugzilla...the project Builder file should be placed at the root of the
> GtkRadiant cvs checkout...
>
> osX.diff
> ------------------------------------
> Index: include/gtkr_list.h
> ===================================================================
> RCS file: /cvs/GtkRadiant/include/gtkr_list.h,v
> retrieving revision 1.1
> diff -u -r1.1 gtkr_list.h
> --- include/gtkr_list.h 31 May 2001 09:29:41 -0000 1.1
> +++ include/gtkr_list.h 6 Nov 2002 16:42:12 -0000
> @@ -31,3 +31,6 @@
>
> #include <list>
> #include "stl_check.h"
> +#ifdef __APPLE__ //tigital
> +using namespace std;
> +#endif
With the latest CVS of the stable 1_2 branch, you shouldn't have this
anywhere, instead make sure that Q_NO_STLPORT is defined, and make sure
you're NOT compiling with STL. The STL headers / libs included with Mac
OS X's GCC3 set should be sufficient.
> ===================================================================
> RCS file: /cvs/GtkRadiant/include/qerplugin.h,v
> retrieving revision 1.25.2.5
> diff -u -r1.25.2.5 qerplugin.h
> --- include/qerplugin.h 9 Oct 2002 12:11:45 -0000 1.25.2.5
> +++ include/qerplugin.h 6 Nov 2002 16:42:13 -0000
> @@ -67,13 +67,22 @@
> #define QER_PLUG_GAME_SURFACEFLAGS 0x0010 // renames surface/content names
>
> // basics
> +#ifndef __APPLE__ //tigital
> #define QERPLUG_INIT "QERPlug_Init"
> #define QERPLUG_GETNAME "QERPlug_GetName"
> #define QERPLUG_GETCOMMANDLIST "QERPlug_GetCommandList"
> #define QERPLUG_DISPATCH "QERPlug_Dispatch"
> #define QERPLUG_GETFUNCTABLE "QERPlug_GetFuncTable"
> +#else
> +#define QERPLUG_INIT "_QERPlug_Init"
> +#define QERPLUG_GETNAME "_QERPlug_GetName"
> +#define QERPLUG_GETCOMMANDLIST "_QERPlug_GetCommandList"
> +#define QERPLUG_DISPATCH "_QERPlug_Dispatch"
> +#define QERPLUG_GETFUNCTABLE "_QERPlug_GetFuncTable"
> +#endif
Icky, is there no way to change how dlopen works with their compiler?
This is going to add a huge amount of bloat if we have to add '_' to
every symbol. If we can't change it for MacOSX, then is it possible that
in the 1.3 branch we might just add the '_' for all platforms instead
TTimo (Since this would break stable)?
> Index: include/stl_check.h
> ===================================================================
> RCS file: /cvs/GtkRadiant/include/stl_check.h,v
> retrieving revision 1.4.12.1
> diff -u -r1.4.12.1 stl_check.h
> --- include/stl_check.h 2 Nov 2002 03:18:00 -0000 1.4.12.1
> +++ include/stl_check.h 6 Nov 2002 16:42:13 -0000
> @@ -35,7 +35,7 @@
> \todo NOTE linux we may want to use the STL provided with gcc instead of
> an STLPort distrib .. I know of some projects which had bugs on STLPort linux /
> gcc 2.95.4
> */
> -
> +#ifndef __APPLE__
> // check the basics
> #if defined (__linux__) || defined (__APPLE__)
> #define HAVE_GCC_VERSION(MAJOR, MINOR) \
> @@ -61,4 +61,6 @@
> #ifdef WIN32
> #pragma warning(disable : 4786)
> #endif
> +
> +#endif __APPLE__=======
> #endif
You shouldn't need this either now, with the latest CVS from Stable 1_2.
> Index: libs/mathlib/linear.c
> ===================================================================
> RCS file: /cvs/GtkRadiant/libs/mathlib/linear.c,v
> retrieving revision 1.2
> diff -u -r1.2 linear.c
> --- libs/mathlib/linear.c 3 Dec 2001 14:26:11 -0000 1.2
> +++ libs/mathlib/linear.c 6 Nov 2002 16:42:14 -0000
> @@ -1,4 +1,8 @@
> +#ifndef __APPLE__
> #include <malloc.h>
> +#else
> +#include <stdlib.h>
> +#endif
> #include <limits.h>
> #include <float.h>
Is there not a /usr/include/malloc.h on your platform? That's part of
libc afaik. I don't know what C library Apple provides you though.
> Index: plugins/imagepng/plugin.cpp
> ===================================================================
> RCS file: /cvs/GtkRadiant/radiant/glwidget.cpp,v
> retrieving revision 1.12.16.1
> diff -u -r1.12.16.1 glwidget.cpp
> --- radiant/glwidget.cpp 6 Jul 2002 18:15:09 -0000 1.12.16.1
> +++ radiant/glwidget.cpp 6 Nov 2002 16:42:15 -0000
> @@ -34,6 +34,12 @@
> // Leonardo Zide (leo@lokigames.com)
> //
>
> +#ifdef __APPLE__
> +#define _STLP_NO_EXCEPTIONS 1
> +#define _STLP_NO_NONAMESPACES 1
> +#define _STLP_NO_OWN_IOSTREAMS 1
> +#endif
> +
> #include "stdafx.h"
> #ifdef WIN32
> extern "C" {
Definitely shouldn't need this anymore as I mentioned in the first part
of my reply. You will need to make sure that you add -fno-rtti and
-fno-exceptions to your compiler command line options though.
> Index: radiant/gtkfilesel-darwin.c
> ===================================================================
> RCS file: /cvs/GtkRadiant/radiant/gtkfilesel-darwin.c,v
> retrieving revision 1.2
> diff -u -r1.2 gtkfilesel-darwin.c
> --- radiant/gtkfilesel-darwin.c 27 May 2001 13:40:55 -0000 1.2
> +++ radiant/gtkfilesel-darwin.c 6 Nov 2002 16:42:19 -0000
> @@ -519,11 +519,11 @@
> }
>
> static void
> -gtk_file_selection_class_init (GtkFileSelectionClass *class)
> +gtk_file_selection_class_init (GtkFileSelectionClass *klass) //tigital
> {
> GtkObjectClass *object_class;
>
> - object_class = (GtkObjectClass*) class;
> + object_class = (GtkObjectClass*) klass;
>
> parent_class = gtk_type_class (GTK_TYPE_WINDOW);
Err...I'm not sure of this change? This seems odd?
> Index: radiant/main.cpp
> ===================================================================
> RCS file: /cvs/GtkRadiant/radiant/main.cpp,v
> retrieving revision 1.40.2.13
> diff -u -r1.40.2.13 main.cpp
> --- radiant/main.cpp 28 Oct 2002 23:24:29 -0000 1.40.2.13
> +++ radiant/main.cpp 6 Nov 2002 16:42:20 -0000
> @@ -520,10 +520,14 @@
> libgl = "opengl32.dll";
> #endif
>
> -#if defined (__linux__) || defined (__APPLE__)
> +#if defined (__linux__)
> libgl = "libGL.so.1";
> #endif
>
> +#ifdef __APPLE__
> + libgl = "/usr/X11R6/lib/libGL.1.dylib";
> +#endif
> +
> gtk_init(&argc, &argv);
>
> if ((ptr = getenv ("Q3R_LIBGL")) != NULL)
> @@ -643,8 +647,13 @@
> realpath (loki_getdatapath(), real);
> if (real[strlen(real)-1] != '/')
> strcat(real, "/");
> +#ifndef __APPLE__ //tigital
> g_strAppPath = real;
> -#if 0
> +#else
> + g_strAppPath = "/Applications/quake3/";
> +#endif
> +
> +#if 1
> printf("g_strAppPath: %s\n", g_strAppPath.GetBuffer());
> #endif
Err...what's the #if 1 for?
> Index: radiant/qgl-mac.c
> ===================================================================
> RCS file: /cvs/GtkRadiant/radiant/qgl-mac.c,v
> retrieving revision 1.2
> diff -u -r1.2 qgl-mac.c
> --- radiant/qgl-mac.c 27 May 2001 13:40:56 -0000 1.2
> +++ radiant/qgl-mac.c 6 Nov 2002 16:42:40 -0000
> @@ -36,7 +36,7 @@
> #include <float.h>
> #include <string.h>
> #if defined (__linux__) || defined (__APPLE__)
> -//#include <dlfcn.h>
> +#include <dlfcn.h>
> #endif
> #ifdef _WIN32
> #include <windows.h>
> @@ -517,9 +517,9 @@
> FreeLibrary(g_hGLDLL);
> #endif
>
> -//#if defined (__linux__) || defined (__APPLE__)
> -// dlclose (g_hGLDLL);
> -//#endif
> +#if defined (__linux__) || defined (__APPLE__)
> + dlclose (g_hGLDLL);
> +#endif
>
> g_hGLDLL = NULL;
> }
> @@ -967,23 +967,23 @@
> */
> static int init_error;
>
> -//static void* safe_dlsym (void *handle, char *symbol)
> -//{
> +static void* safe_dlsym (void *handle, char *symbol)
> +{
> //#ifdef WIN32
> // return GetProcAddress (handle, symbol);
> //#endif
>
> -//#if defined (__linux__) || defined (__APPLE__)
> -// void* ret = dlsym (handle, symbol);
> -// char *err = dlerror();
> -// if (err)
> -//{
> -// init_error = 1;
> -// printf ("Error loading OpenGL libraries: %s %s\n", err, symbol);
> -// }
> -// return ret;
> -//#endif
> -//}
> +#if defined (__linux__) || defined (__APPLE__)
> + void* ret = dlsym (handle, symbol);
> + char *err = dlerror();
> + if (err)
> +{
> + init_error = 1;
> + printf ("Error loading OpenGL libraries: %s %s\n", err, symbol);
> + }
> + return ret;
> +#endif
> +}
These changes could affect Linux builds negatively. You may want to
change this to just the __APPLE__ case. TTimo?
> #include <math.h>
> #include <stdlib.h>
> @@ -1047,8 +1047,11 @@
> {
> int i, j;
> float sx, sy;
> -
> +#ifndef __APPLE__
> GLubyte* new_image = malloc (destw*desth*4*sizeof(GLubyte));
> +#else
> + GLubyte* new_image = (GLubyte *)malloc (destw*desth*4*sizeof(GLubyte));
> +#endif
You don't need to #ifndef this. This change seems like just a typecast.
AFAIK.
> @@ -1240,10 +1243,10 @@
> #endif
> init_error = 0;
>
> -#ifndef __APPLE__
> +//#ifndef __APPLE__
> if (g_hGLDLL == NULL)
> return 0;
> -#endif
> +//#endif
Seems like another change that might break non-__APPLE__ builds. Might
want to make that an #ifdef __APPLE__ instead.
> @@ -1675,7 +1678,7 @@
> qglXWaitGL = glXWaitGL;
> qglXWaitX = glXWaitX;
> qglXUseXFont = glXUseXFont;
> - qglXGetProcAddressARB = glXGetProcAddressARB; // Utah-GLX fix
> +// qglXGetProcAddressARB = glXGetProcAddressARB; // Utah-GLX fix
> #endif
>
> qglPointParameterfEXT = 0;
Might want to #ifndef __APPLE__ this one.
> @@ -1691,8 +1694,8 @@
>
> return 1;
> }
> -
> -static int GL_ExtensionSupported (const char *extension)
> +//static //tigital
> +int GL_ExtensionSupported (const char *extension)
> {
> const GLubyte *extensions = NULL;
> const GLubyte *start;
Yet another one you might want to #ifdef __APPLE__ #else.
> Index: radiant/qgl.c
> ===================================================================
> RCS file: /cvs/GtkRadiant/radiant/qgl.c,v
> retrieving revision 1.14.22.2
> diff -u -r1.14.22.2 qgl.c
> --- radiant/qgl.c 21 Oct 2002 22:34:16 -0000 1.14.22.2
> +++ radiant/qgl.c 6 Nov 2002 16:42:44 -0000
> @@ -35,7 +35,7 @@
> #include <stdio.h>
> #include <float.h>
> #include <string.h>
> -#ifdef __linux__
> +#if defined (__linux__) || defined (__APPLE__)
> #include <dlfcn.h>
> #endif
>
> @@ -86,7 +86,7 @@
> #define WINAPI
> #endif
>
> -#ifdef __linux__
> +#if defined (__linux__) || defined (__APPLE__)
> void* g_hGLDLL;
>
> XVisualInfo* (*qglXChooseVisual)(Display *dpy, int screen, int *attribList);
> @@ -518,7 +518,7 @@
> FreeLibrary(g_hGLDLL);
> #endif
>
> -#ifdef __linux__
> +#if defined (__linux__) || defined (__APPLE__)
> dlclose (g_hGLDLL);
> #endif
>
> @@ -929,7 +929,7 @@
> qwglSetDeviceGammaRampEXT = NULL;
> #endif
>
> -#ifdef __linux__
> +#if defined (__linux__) || defined (__APPLE__)
> qglXChooseVisual = NULL;
> qglXCreateContext = NULL;
> qglXDestroyContext = NULL;
> @@ -974,11 +974,11 @@
> return GetProcAddress (handle, symbol);
> #endif
>
> -#ifdef __linux__
> +#if defined (__linux__) || defined (__APPLE__)
> void* ret = dlsym (handle, symbol);
> char *err = dlerror();
> if (err)
> - {
> +{
> init_error = 1;
> printf ("Error loading OpenGL libraries: %s\n", err);
> }
> @@ -1048,8 +1048,11 @@
> {
> int i, j;
> float sx, sy;
> -
> +#ifndef __APPLE__
> GLubyte* new_image = malloc (destw*desth*4*sizeof(GLubyte));
> +#else
> + GLubyte* new_image = (GLubyte *)malloc (destw*desth*4*sizeof(GLubyte));
> +#endif
> if (new_image == NULL)
> return NULL;
> > Index: radiant/qgl.c
> ===================================================================
> RCS file: /cvs/GtkRadiant/radiant/qgl.c,v
> retrieving revision 1.14.22.2
> diff -u -r1.14.22.2 qgl.c
> --- radiant/qgl.c 21 Oct 2002 22:34:16 -0000 1.14.22.2
> +++ radiant/qgl.c 6 Nov 2002 16:42:44 -0000
> @@ -35,7 +35,7 @@
> #include <stdio.h>
> #include <float.h>
> #include <string.h>
> -#ifdef __linux__
> +#if defined (__linux__) || defined (__APPLE__)
> #include <dlfcn.h>
> #endif
>
> @@ -86,7 +86,7 @@
> #define WINAPI
> #endif
>
> -#ifdef __linux__
> +#if defined (__linux__) || defined (__APPLE__)
> void* g_hGLDLL;
>
> XVisualInfo* (*qglXChooseVisual)(Display *dpy, int screen, int *attribList);
> @@ -518,7 +518,7 @@
> FreeLibrary(g_hGLDLL);
> #endif
>
> -#ifdef __linux__
> +#if defined (__linux__) || defined (__APPLE__)
> dlclose (g_hGLDLL);
> #endif
>
> @@ -929,7 +929,7 @@
> qwglSetDeviceGammaRampEXT = NULL;
> #endif
>
> -#ifdef __linux__
> +#if defined (__linux__) || defined (__APPLE__)
> qglXChooseVisual = NULL;
> qglXCreateContext = NULL;
> qglXDestroyContext = NULL;
> @@ -974,11 +974,11 @@
> return GetProcAddress (handle, symbol);
> #endif
>
> -#ifdef __linux__
> +#if defined (__linux__) || defined (__APPLE__)
> void* ret = dlsym (handle, symbol);
> char *err = dlerror();
> if (err)
> - {
> +{
> init_error = 1;
> printf ("Error loading OpenGL libraries: %s\n", err);
> }
> @@ -1048,8 +1048,11 @@
> {
> int i, j;
> float sx, sy;
> -
> +#ifndef __APPLE__
> GLubyte* new_image = malloc (destw*desth*4*sizeof(GLubyte));
> +#else
> + GLubyte* new_image = (GLubyte *)malloc (destw*desth*4*sizeof(GLubyte));
> +#endif
> if (new_image == NULL)
> return NULL;
>
Again, just a harmless typecast here AFAIK, no need to #ifndef it.
Anyway, great work! Just a bit of commentary. I'm no expert, and my code
is far from perfect, but those are the changes I would make, TTimo's
comments would be greatly welcomed.
-eviltypeguy