Thanks for this project, it has been a fun first exposure
to 3d/rendering for me.
I hope you will be able to adopt some of the below suggestions
to allow OSX users to benefit from this great project.
There were a few technical hurdles to getting it working on OSX,
1) windows line endings makes svn operations like diff problematic
on OSX (and Linux?), a temporary workaround is to use :
- Code: Select all
svn diff -x --ignore-eol-style
But a better solution is possible by setting some svn properties:
http://www.tribler.org/trac/wiki/svn:eol-style
2) SDL on OSX has special needs regarding initialization and the SDLMain.m
... without this get crashes regarding
2009-02-27 10:58:01.570 Python[31871:613] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error (1002) creating CGSWindow'
I tried a minimal solution, of adding :
- Code: Select all
os-x/include/SDLMain.h
os-x/src/SDLMAIN.m
os-x/SDLMain.nib
but came to the conclusion that is would be much easier to let another
project handle these niggles : namely pygame
http://www.pygame.org
Letting it take care of initializing SDL by changing main.py, adding :
- Code: Select all
import pygame
pygame.init()
The pygame installation I used is based on libsdl* Frameworks
rather than dylib ... requiring some include changes such as :
svn diff -x --ignore-eol-style include/glmodule.h
- Code: Select all
Index: include/glmodule.h
===================================================================
--- include/glmodule.h (revision 790)
+++ include/glmodule.h (working copy)
@@ -28,8 +28,16 @@
#ifndef GLMODULE_H
#define GLMODULE_H 1
+
+#ifdef __APPLE__
+#include <SDL/SDL.h>
+#include <SDL/SDL_opengl.h>
+#else
#include <SDL.h>
#include <SDL_opengl.h>
+#endif
+
+
#include "gltexture.h"
void mhDrawText(float x, float y, const char *message);
3) add support for "import mh" by adding to main.c :
- Code: Select all
+void initmh()
+{
+ printf("initmh\n");
+ Py_InitModule("mh", EmbMethods);
+ initGlobals(); /* initialize all our globals */
+#ifdef __APPLE__
+ initMouseScrollWheelTrap();
+#endif
+}
4) To allow zooming on OSX with : ctrl + cmd + mouse/tracpad
- Code: Select all
Index: src/glmodule.c
===================================================================
--- src/glmodule.c (revision 790)
+++ src/glmodule.c (working copy)
@@ -37,7 +37,7 @@
#include <SDL_syswm.h>
#elif __APPLE__
#include <AGL/agl.h>
-#include <Fonts.h>
+//#include <Fonts.h>
#else
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@@ -119,7 +119,10 @@
#ifdef __WIN32__
g_sdlImageHandle = SDL_LoadObject("SDL_image");
#elif __APPLE__
- g_sdlImageHandle = SDL_LoadObject("libSDL_image-1.2.0.dylib");
+ //g_sdlImageHandle = SDL_LoadObject("libSDL_image-1.2.0.dylib");
+ //g_sdlImageHandle = SDL_LoadObject("/opt/local/lib/libSDL_image-1.2.0.dylib");
+ g_sdlImageHandle = SDL_LoadObject("/Library/Frameworks/SDL_image.framework/SDL_image");
+
#else
g_sdlImageHandle = SDL_LoadObject("libSDL_image-1.2.so.0");
#endif
@@ -382,7 +385,8 @@
callMouseMotion(s);
mhGetPickedCoords(x,y);
- if (!(G.modifiersKeyState & KMOD_ALT) && !(G.modifiersKeyState & KMOD_CTRL) && !(G.modifiersKeyState & KMOD_SHIFT))
+ //if (!(G.modifiersKeyState & KMOD_ALT) && !(G.modifiersKeyState & KMOD_CTRL) && !(G.modifiersKeyState & KMOD_SHIFT))
+ if (!(G.modifiersKeyState & KMOD_ALT) && !(G.modifiersKeyState & KMOD_SHIFT))
{
if ( g_buttons[0] && g_buttons[2] )
{
@@ -400,8 +404,13 @@
{
if ( g_buttons[2] )
{
- G.translX += (float) 0.05f * G.diffx;
- G.translY -= (float) 0.05f * G.diffy;
+ // to give zoom on OS X
+ if(G.modifiersKeyState & KMOD_CTRL){
+ G.zoom -= (float) 0.05f * G.diffx;
+ } else {
+ G.translX += (float) 0.05f * G.diffx;
+ G.translY -= (float) 0.05f * G.diffy;
+ }
}
}
}
5) rendering missing .sdr ,
I found i had to shader compile (using pixies sdrc)
a few .sl into .sdr with :
- Code: Select all
sdrc *.sl
6) renderer operation requires $PIXIEHOME/bin in the environment PATH
I guess this needs to be more controlled for users without development experience ?
Notes on PyGame building :
PyGame is a mature xplatform python lib on top of SDL... so it
has mature solutions(and documentation) to the
xplatform SDL niggles to do with SDLMain and how
OSX needs that sorted out.
As I prefer to use macports distributions (not fink)
but like to keep using the system python ... I followed
http://www.pygame.org/wiki/MacSVNCompile
to install pygame from source , which uses the framework
installs of its dependencies :
- Code: Select all
sudo port install libsdl-framework
sudo port install libsdl_image-framework
sudo port install libsdl_ttf-framework
sudo port install libsdl_mixer-framework
...
(the first 2 are needed by MHPhoenix already )