From 1fb8f9cb8608ef03ce3e6dfed99498e72176ea1d Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 16 Jan 2002 10:36:20 +0000 Subject: [PATCH] First batch of changes required for MacOS X build. Orignal submission from Phil Atkin, merged by Robert Osfield. --- Make/makerules.macosx | 12 ++++++------ include/osg/GL | 2 +- include/osg/GLU | 2 +- include/osg/Timer | 4 ++-- include/osgText/Font | 6 ++++++ src/Demos/hangglide/Makefile | 5 +++++ src/Demos/osgconv/Makefile | 3 +++ src/Demos/osgcube/Makefile | 4 ++++ src/Demos/osgimpostor/Makefile | 3 +++ src/Demos/osgimpostor/osgimpostor.cpp | 2 +- src/Demos/osgreflect/Makefile | 4 ++++ src/Demos/osgtext/Makefile | 3 ++- src/Demos/osgtext/main.cpp | 6 +++--- src/Demos/osgtexture/Makefile | 4 ++++ src/Demos/osgviews/Makefile | 3 +++ src/Demos/sgv/Makefile | 4 ++++ src/osg/Makefile | 1 + src/osg/Timer.cpp | 4 ++-- src/osgDB/Makefile | 1 + src/osgGLUT/Makefile | 2 ++ src/osgPlugins/Makefile | 3 +++ src/osgPlugins/dw/ReaderWriterDW.cpp | 2 +- src/osgPlugins/flt/Input.cpp | 2 +- src/osgPlugins/flt/Record.cpp | 2 +- src/osgPlugins/obj/glm.cpp | 5 +++++ src/osgText/FTGL.h | 2 +- src/osgText/FTGLTextureFont.cpp | 10 ++++++++++ src/osgText/FTGLTextureFont.h | 1 + src/osgText/Font.cpp | 25 +++++++++++++++++++++---- src/osgText/Makefile | 1 + src/osgUtil/DepthSortedBin.cpp | 5 +++++ src/osgUtil/Makefile | 1 + src/osgUtil/RenderBin.cpp | 8 +++++++- 33 files changed, 116 insertions(+), 26 deletions(-) diff --git a/Make/makerules.macosx b/Make/makerules.macosx index eacf7e98e..e2ece450b 100644 --- a/Make/makerules.macosx +++ b/Make/makerules.macosx @@ -1,14 +1,14 @@ -all : $(MAKEDEPEND) $(TARGET) $(LIB) $(DYLIB) +all : $(MAKEDEPEND) $(TARGET) $(LOADABLE) $(LIB) -$(TARGET) : $(OBJS) $(PLUGINLIBS) $(MACOSXLIBS) - $(C++) $(LDFLAGS) $(MACOSXLIBS) $(OBJS) $(PLUGINS) -o $@ +$(TARGET) : $(OBJS) + $(CC) $(LDFLAGS) $(OBJS) $(FRAMEWORKS) $(MACOSXLIBS) -o $@ $(LIB) : $(OBJS) - $(LIBTOOL) -static -o $@ $(OBJS) + $(CC) -dynamiclib -o $@ $(OBJS) $(MACOSXLIBS) $(FRAMEWORKS) -$(DYLIB) : $(OBJS) - $(LIBTOOL) -static -o $@ $(OBJS) +$(LOADABLE) : $(OBJS) + $(CC) -bundle -o $@ $(OBJS) $(MACOSXLIBS) $(FRAMEWORKS) clean : rm -f $(OBJS) core $(TARGET) $(MAKEDEPEND) diff --git a/include/osg/GL b/include/osg/GL index 11b9e1612..fce999a27 100644 --- a/include/osg/GL +++ b/include/osg/GL @@ -9,7 +9,7 @@ // non windows, doesn't require nonsense as seen below :-) #ifndef __gl_h_ - #ifdef __APPLE_CC__ + #ifdef __DARWIN_OSX__ #include #else #include diff --git a/include/osg/GLU b/include/osg/GLU index 9fc6b130a..ec165970e 100644 --- a/include/osg/GLU +++ b/include/osg/GLU @@ -5,7 +5,7 @@ #ifndef OSG_GLU #define OSG_GLU 1 -#ifdef __APPLE_CC__ +#ifdef __DARWIN_OSX__ #include #else #include diff --git a/include/osg/Timer b/include/osg/Timer index 9f83621b2..cd167cd01 100644 --- a/include/osg/Timer +++ b/include/osg/Timer @@ -33,7 +33,7 @@ class SG_EXPORT Timer { Timer(); ~Timer() {} - #if defined __APPLE__ || defined macintosh + #if defined __DARWIN_OSX__ || defined macintosh // PJA MAC OSX - inline Tick() pollutes namespace so badly // we cant compile, due to Carbon.h ... Timer_t tick(); @@ -150,7 +150,7 @@ namespace osg{ } }; -#elif !defined (__APPLE_CC__) && !defined (macintosh) +#elif !defined (__DARWIN_OSX__) && !defined (macintosh) // no choice, always use std::clock() diff --git a/include/osgText/Font b/include/osgText/Font index b0b5f41c0..2af07500a 100644 --- a/include/osgText/Font +++ b/include/osgText/Font @@ -56,6 +56,7 @@ public: virtual int getAscender() const; int getPointSize(void) const { return _pointSize; } + int getTextureSize(void) const { return _textureSize; } const std::string& getFontName(); FTFont* getFont(void) { return _font; } @@ -77,6 +78,7 @@ protected: std::string _fontName; int _pointSize; int _res; + int _textureSize; }; // Font /////////////////////////////////////////////////////////////////////////////// @@ -167,6 +169,10 @@ public: TextureFont(const std::string& font, int point_size); + + TextureFont(const std::string& font, + int point_size, + int textureSize ); META_Object(TextureFont); diff --git a/src/Demos/hangglide/Makefile b/src/Demos/hangglide/Makefile index e757dd1a8..1f51b4510 100644 --- a/src/Demos/hangglide/Makefile +++ b/src/Demos/hangglide/Makefile @@ -21,6 +21,11 @@ TARGET_BIN_FILES = hangglide #note, standard library list. LIBS = -losgGLUT -losgUtil -losgDB -losg $(GLUTLIB) $(GL_LIBS) $(X_LIBS) + +#under Darwin we have to use the framework stuff to get GLUT OpenGL etc. +MACOSXLIBS = -losgGLUT -losgUtil -losgDB -losg -lm -ldl -lstdc++ -lobjc + + # $(OSGDB_LIBS) C++FLAGS += -I. -I$(OSGHOME)/include LDFLAGS += -L$(OSGHOME)/lib diff --git a/src/Demos/osgconv/Makefile b/src/Demos/osgconv/Makefile index 739ba36f4..c925aa568 100644 --- a/src/Demos/osgconv/Makefile +++ b/src/Demos/osgconv/Makefile @@ -16,6 +16,9 @@ TARGET_BIN_FILES = osgconv #note, standard library list. LIBS = -losgDB -losg $(GL_LIBS) $(X_LIBS) +#under Darwin we have to use the framework stuff to get GLUT OpenGL etc. +MACOSXLIBS = -losgGLUT -losgUtil -losgDB -losg -lm -ldl -lstdc++ -lobjc + C++FLAGS += -I$(OSGHOME)/include LDFLAGS += -L$(OSGHOME)/lib diff --git a/src/Demos/osgcube/Makefile b/src/Demos/osgcube/Makefile index 70e7d5c13..d3a74d783 100644 --- a/src/Demos/osgcube/Makefile +++ b/src/Demos/osgcube/Makefile @@ -9,6 +9,10 @@ TARGET = $(OSGHOME)/bin/osgcube TARGET_BIN_FILES = osgcube LIBS = -losgGLUT -losgDB -losgUtil -losg $(GLUTLIB) $(GL_LIBS) $(X_LIBS) + +#under Darwin we have to use the framework stuff to get GLUT OpenGL etc. +MACOSXLIBS = -losgGLUT -losgUtil -losgDB -losg -lm -ldl -lstdc++ -lobjc + C++FLAGS += -I$(OSGHOME)/include LDFLAGS += -L$(OSGHOME)/lib diff --git a/src/Demos/osgimpostor/Makefile b/src/Demos/osgimpostor/Makefile index 82f24eef6..723fce1b5 100644 --- a/src/Demos/osgimpostor/Makefile +++ b/src/Demos/osgimpostor/Makefile @@ -14,6 +14,9 @@ TARGET_BIN_FILES = osgimpostor #note, standard library list. LIBS = -losgGLUT -losgUtil -losgDB -losg $(GLUTLIB) $(GL_LIBS) $(X_LIBS) +#under Darwin we have to use the framework stuff to get GLUT OpenGL etc. +MACOSXLIBS = -losgGLUT -losgUtil -losgDB -losg -lm -ldl -lstdc++ -lobjc + C++FLAGS += -I$(OSGHOME)/include LDFLAGS += -L$(OSGHOME)/lib diff --git a/src/Demos/osgimpostor/osgimpostor.cpp b/src/Demos/osgimpostor/osgimpostor.cpp index d6d42b858..083251e7b 100644 --- a/src/Demos/osgimpostor/osgimpostor.cpp +++ b/src/Demos/osgimpostor/osgimpostor.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include diff --git a/src/Demos/osgreflect/Makefile b/src/Demos/osgreflect/Makefile index bf04d7fbf..8785e214b 100644 --- a/src/Demos/osgreflect/Makefile +++ b/src/Demos/osgreflect/Makefile @@ -14,6 +14,10 @@ TARGET_BIN_FILES = osgreflect #note, standard library list. LIBS = -losgGLUT -losgUtil -losgDB -losg $(GLUTLIB) $(GL_LIBS) $(X_LIBS) +#under Darwin we have to use the framework stuff to get GLUT OpenGL etc. +MACOSXLIBS = -losgGLUT -losgUtil -losgDB -losg -lm -ldl -lstdc++ -lobjc + + C++FLAGS += -I$(OSGHOME)/include LDFLAGS += -L$(OSGHOME)/lib diff --git a/src/Demos/osgtext/Makefile b/src/Demos/osgtext/Makefile index d4be5d9c8..0e32e0fe6 100644 --- a/src/Demos/osgtext/Makefile +++ b/src/Demos/osgtext/Makefile @@ -13,8 +13,9 @@ TARGET_BIN_FILES = osgtext #note, standard library list. LIBS = -losgGLUT -losgText -losgUtil -losgDB -losg $(GLUTLIB) $(GL_LIBS) $(X_LIBS) +MACOSXLIBS = -losgGLUT -losgText -losgUtil -losgDB -losg -lfreetype -ldl -lobjc -lstdc++ -C++FLAGS += -I$(OSGHOME)/include -g +C++FLAGS += -I$(OSGHOME)/include -I. LDFLAGS += -L$(OSGHOME)/lib -L/usr/freeware/lib32 include $(OSGHOME)/Make/makerules diff --git a/src/Demos/osgtext/main.cpp b/src/Demos/osgtext/main.cpp index 5a6a6ca4b..d1501ae0f 100644 --- a/src/Demos/osgtext/main.cpp +++ b/src/Demos/osgtext/main.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include @@ -45,8 +45,8 @@ using namespace osgGLUT; #define TEXT_COL_3D osg::Vec4(.99,.3,.2,1) -std::string ttfPath("fonts/dirtydoz.ttf"); -std::string ttfPath1("fonts/fudd.ttf"); +std::string ttfPath("fonts/times.ttf"); +std::string ttfPath1("fonts/arial.ttf"); int gFontSize=18; int gFontSize1=24; diff --git a/src/Demos/osgtexture/Makefile b/src/Demos/osgtexture/Makefile index 7be1cf3bb..9aeca9907 100644 --- a/src/Demos/osgtexture/Makefile +++ b/src/Demos/osgtexture/Makefile @@ -14,6 +14,10 @@ TARGET_BIN_FILES = osgtexture #note, standard library list. LIBS = -losgGLUT -losgUtil -losgDB -losg $(GLUTLIB) $(GL_LIBS) $(X_LIBS) +#under Darwin we have to use the framework stuff to get GLUT OpenGL etc. +MACOSXLIBS = -losgGLUT -losgUtil -losgDB -losg -lm -ldl -lstdc++ -lobjc + + C++FLAGS += -I$(OSGHOME)/include LDFLAGS += -L$(OSGHOME)/lib diff --git a/src/Demos/osgviews/Makefile b/src/Demos/osgviews/Makefile index 6792fd3ab..aa7cdb667 100644 --- a/src/Demos/osgviews/Makefile +++ b/src/Demos/osgviews/Makefile @@ -14,6 +14,9 @@ TARGET_BIN_FILES = osgviews #note, standard library list. LIBS = -losgGLUT -losgUtil -losgDB -losg $(GLUTLIB) $(GL_LIBS) $(X_LIBS) +#under Darwin we have to use the framework stuff to get GLUT OpenGL etc. +MACOSXLIBS = -losgGLUT -losgUtil -losgDB -losg -lm -ldl -lstdc++ -lobjc + C++FLAGS += -I$(OSGHOME)/include LDFLAGS += -L$(OSGHOME)/lib diff --git a/src/Demos/sgv/Makefile b/src/Demos/sgv/Makefile index 465fc4852..2bbfc0c8d 100644 --- a/src/Demos/sgv/Makefile +++ b/src/Demos/sgv/Makefile @@ -11,6 +11,10 @@ TARGET_BIN_FILES = sgv #note, standard library list. LIBS = -losgGLUT -losgUtil -losgDB -losg $(GLUTLIB) $(GL_LIBS) $(X_LIBS) +#under Darwin we have to use the framework stuff to get GLUT OpenGL etc. +MACOSXLIBS = -losgGLUT -losgUtil -losgDB -losg -lm -ldl -lstdc++ -lobjc + + C++FLAGS += -I$(OSGHOME)/include LDFLAGS += -L$(OSGHOME)/lib diff --git a/src/osg/Makefile b/src/osg/Makefile index 022904714..a41558010 100644 --- a/src/osg/Makefile +++ b/src/osg/Makefile @@ -135,6 +135,7 @@ TARGET_INCLUDE_FILES = \ LIBS = $(GL_LIBS) +MACOSXLIBS = -lm -ldl -lstdc++ LIB = $(OSGHOME)/lib/lib$(TARGET_BASENAME).$(SO_EXT) #LIB = $(OSGHOME)/lib/lib$(TARGET_BASENAME).a diff --git a/src/osg/Timer.cpp b/src/osg/Timer.cpp index fa02575d5..7832d81a8 100644 --- a/src/osg/Timer.cpp +++ b/src/osg/Timer.cpp @@ -197,9 +197,9 @@ using namespace osg; } } -#elif defined (__APPLE_CC__) || defined (macintosh) +#elif defined (__DARWIN_OSX__) || defined (macintosh) -#if defined (__APPLE_CC__) +#if defined (__DARWIN_OSX__) #include // do I really have to link against the Carbon framework just for this? #else #include diff --git a/src/osgDB/Makefile b/src/osgDB/Makefile index e1686d191..84869ef61 100644 --- a/src/osgDB/Makefile +++ b/src/osgDB/Makefile @@ -41,6 +41,7 @@ TARGET_INCLUDE_FILES = \ #LIBS = -L$(OSGHOME)/lib -losg -lGLU -lGL -lm -ldl LIBS = -L$(OSGHOME)/lib -losg $(GL_LIBS) $(DYNAMICLIBRARYLIB) +MACOSXLIBS = -L$(OSGHOME)/lib -losg -ldl -lm -lstdc++ $(DYNAMICLIBRARYLIB) LIB = $(OSGHOME)/lib/lib$(TARGET_BASENAME).$(SO_EXT) #LIB = $(OSGHOME)/lib/lib$(TARGET_BASENAME).a diff --git a/src/osgGLUT/Makefile b/src/osgGLUT/Makefile index ee54d9654..62996e582 100644 --- a/src/osgGLUT/Makefile +++ b/src/osgGLUT/Makefile @@ -11,6 +11,8 @@ TARGET_BASENAME = osgGLUT LIBS = -L$(OSGHOME)/lib -losgDB -losgUtil -losg $(GLUTLIB) $(GL_LIBS) +MACOSXLIBS = -L../../lib -losgDB -losgUtil -losg -ldl -lm -lstdc++ + LIB = $(OSGHOME)/lib/lib$(TARGET_BASENAME).$(SO_EXT) #LIB = $(OSGHOME)/lib/lib$(TARGET_BASENAME).a diff --git a/src/osgPlugins/Makefile b/src/osgPlugins/Makefile index 27dfccf81..f146999ad 100644 --- a/src/osgPlugins/Makefile +++ b/src/osgPlugins/Makefile @@ -6,6 +6,9 @@ DIRS = osg rgb lib3ds flt obj lwo dw bmp pic tga osgtgz tgz zip # comment in if you have Performer installed. # DIRS += pfb +# comment in if you have Performer installed. +# DIRS += quicktime + # comment in if you have libpng installed. DIRS += png diff --git a/src/osgPlugins/dw/ReaderWriterDW.cpp b/src/osgPlugins/dw/ReaderWriterDW.cpp index 92c110e08..f949f2493 100644 --- a/src/osgPlugins/dw/ReaderWriterDW.cpp +++ b/src/osgPlugins/dw/ReaderWriterDW.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include using namespace osg; diff --git a/src/osgPlugins/flt/Input.cpp b/src/osgPlugins/flt/Input.cpp index e740be574..9e73407fc 100644 --- a/src/osgPlugins/flt/Input.cpp +++ b/src/osgPlugins/flt/Input.cpp @@ -1,7 +1,7 @@ // Input.cpp #include -#include +// #include #include #include diff --git a/src/osgPlugins/flt/Record.cpp b/src/osgPlugins/flt/Record.cpp index d01b50063..18c499e47 100644 --- a/src/osgPlugins/flt/Record.cpp +++ b/src/osgPlugins/flt/Record.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include diff --git a/src/osgPlugins/obj/glm.cpp b/src/osgPlugins/obj/glm.cpp index 31a160101..ffc6ad5df 100644 --- a/src/osgPlugins/obj/glm.cpp +++ b/src/osgPlugins/obj/glm.cpp @@ -12,7 +12,12 @@ #include #include #include +#include +#ifdef __DARWIN_OSX__ +#include +#else #include +#endif #include "glm.h" diff --git a/src/osgText/FTGL.h b/src/osgText/FTGL.h index c78e1fa4c..8d3dc752d 100644 --- a/src/osgText/FTGL.h +++ b/src/osgText/FTGL.h @@ -15,7 +15,7 @@ // non windows, doesn't require nonesense as seen below :-) #ifndef __gl_h_ - #ifdef __APPLE_CC__ + #ifdef __DARWIN_OSX__ #include #include #else diff --git a/src/osgText/FTGLTextureFont.cpp b/src/osgText/FTGLTextureFont.cpp index 858ec3d4f..2695f41ed 100644 --- a/src/osgText/FTGLTextureFont.cpp +++ b/src/osgText/FTGLTextureFont.cpp @@ -27,6 +27,16 @@ FTGLTextureFont::FTGLTextureFont() padding(1) {} +FTGLTextureFont::FTGLTextureFont(int textureSize) +: maxTextSize(textureSize), + textureWidth(0), + textureHeight(0), + numTextures(1), + textMem(0), + glyphHeight(0), + glyphWidth(0), + padding(1) +{} FTGLTextureFont::~FTGLTextureFont() { diff --git a/src/osgText/FTGLTextureFont.h b/src/osgText/FTGLTextureFont.h index 31f8def69..7610e3364 100644 --- a/src/osgText/FTGLTextureFont.h +++ b/src/osgText/FTGLTextureFont.h @@ -19,6 +19,7 @@ class FTGL_EXPORT FTGLTextureFont : public FTFont * Default Constructor */ FTGLTextureFont(); + FTGLTextureFont(int textureSize); /** * Destructor diff --git a/src/osgText/Font.cpp b/src/osgText/Font.cpp index 1a4d3a882..034b21ee3 100644 --- a/src/osgText/Font.cpp +++ b/src/osgText/Font.cpp @@ -31,7 +31,7 @@ using namespace osgText; // define the default paths to look for fonts. // note delimator is : for unix, ; for windows. -#if defined(__linux) || defined(__FreeBSD__) || defined (__sgi) +#if defined(__linux) || defined(__FreeBSD__) || defined (__sgi) || defined (__DARWIN_OSX__) static char* s_FontFilePath = ".:/usr/share/fonts/ttf:/usr/share/fonts/ttf/western:/usr/share/fonts/ttf/decoratives"; #elif defined(WIN32) static char* s_FontFilePath = ".;C:/windows/fonts"; @@ -67,6 +67,7 @@ Font() _created=false; _pointSize=14; + _textureSize=0; _res=72; } @@ -246,13 +247,28 @@ createFontObj(void) /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -// PixmapFont +// TextureFont TextureFont:: TextureFont(const std::string& font, int point_size): RasterFont(font) { + _textureSize=0; + if(init(font)) + { + } + _pointSize=point_size; +} + + +TextureFont:: +TextureFont(const std::string& font, + int point_size, + int textureSize ): +RasterFont(font) +{ + _textureSize=textureSize; if(init(font)) { } @@ -260,13 +276,14 @@ RasterFont(font) } + FTFont* TextureFont:: createFontObj(void) { - return (FTFont*)(new FTGLTextureFont); + return (FTFont*)(new FTGLTextureFont(_textureSize)); } -// PixmapFont +// TextureFont /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// diff --git a/src/osgText/Makefile b/src/osgText/Makefile index 018d91e44..db37a2955 100644 --- a/src/osgText/Makefile +++ b/src/osgText/Makefile @@ -30,6 +30,7 @@ TARGET_BASENAME = osgText LIBS = -L$(OSGHOME)/lib -lfreetype -losgDB -losg $(GL_LIBS) +MACOSXLIBS = -L$(OSGHOME)/lib -lfreetype -losgDB -losg -lstdc++ LIB = $(OSGHOME)/lib/lib$(TARGET_BASENAME).$(SO_EXT) #LIB = $(OSGHOME)/lib/lib$(TARGET_BASENAME).a diff --git a/src/osgUtil/DepthSortedBin.cpp b/src/osgUtil/DepthSortedBin.cpp index c73946a6c..8b649d1ef 100644 --- a/src/osgUtil/DepthSortedBin.cpp +++ b/src/osgUtil/DepthSortedBin.cpp @@ -6,8 +6,13 @@ using namespace osg; using namespace osgUtil; + +#ifndef __DARWIN_OSX__ +// this is a hack to test OS X .... // register a RenderStage prototype with the RenderBin prototype list. RegisterRenderBinProxy s_registerDepthSortedBinProxy; +#endif + DepthSortedBin::DepthSortedBin() { diff --git a/src/osgUtil/Makefile b/src/osgUtil/Makefile index a73985c31..3d2ae2926 100644 --- a/src/osgUtil/Makefile +++ b/src/osgUtil/Makefile @@ -36,6 +36,7 @@ TARGET_BASENAME = osgUtil LIBS = -L$(OSGHOME)/lib -losg $(GL_LIBS) +MACOSXLIBS = -L$(OSGHOME)/lib -losg -ldl -lm -lstdc++ LIB = $(OSGHOME)/lib/lib$(TARGET_BASENAME).$(SO_EXT) #LIB = $(OSGHOME)/lib/lib$(TARGET_BASENAME).a diff --git a/src/osgUtil/RenderBin.cpp b/src/osgUtil/RenderBin.cpp index 6ae5918d1..6881d69c1 100644 --- a/src/osgUtil/RenderBin.cpp +++ b/src/osgUtil/RenderBin.cpp @@ -6,10 +6,16 @@ using namespace osg; using namespace osgUtil; - // register a RenderStage prototype with the RenderBin prototype list. RegisterRenderBinProxy s_registerRenderBinProxy; +#ifdef __DARWIN_OSX__ +// PJA 10/1/02 - this is a hack to get OS X to build, if this code is included in DepthSortedBin.cpp it isnt executed +// register a RenderStage prototype with the RenderBin prototype list. +#include +RegisterRenderBinProxy s_registerDepthSortedBinProxy; +#endif + typedef std::map< std::string, osg::ref_ptr > RenderBinPrototypeList; RenderBinPrototypeList* renderBinPrototypeList()