Browse Source

Merge pull request #6 from GarageGames/development

Development
Mike Lilligreen 12 years ago
parent
commit
6e29646816

+ 33 - 21
engine/compilers/Xcode/Torque2D.xcodeproj/project.pbxproj

@@ -54,7 +54,6 @@
 		8658B175165A7BFB0087ABC1 /* osxNetwork.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8658B172165A7BFB0087ABC1 /* osxNetwork.mm */; };
 		8658B176165A7BFB0087ABC1 /* osxString.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8658B173165A7BFB0087ABC1 /* osxString.mm */; };
 		865A20CA16515B1E00527C44 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 869FF8BF1651518C002FE082 /* AppKit.framework */; };
-		865A20CB16515B1E00527C44 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 865A20C116515ACE00527C44 /* AVFoundation.framework */; };
 		865A20CC16515B1E00527C44 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 869FF8BC1651518C002FE082 /* Cocoa.framework */; };
 		865A20CD16515B1E00527C44 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 869FF8C01651518C002FE082 /* CoreData.framework */; };
 		865A20CE16515B1E00527C44 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 865A20C216515ACE00527C44 /* CoreFoundation.framework */; };
@@ -454,6 +453,7 @@
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
+		04CC626B1795512500F9C119 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = ../../../../../../../System/Library/Frameworks/AVFoundation.framework; sourceTree = "<group>"; };
 		2A03300B165D1D2100E9CD70 /* unitTesting.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = unitTesting.cc; path = ../../../source/testing/unitTesting.cc; sourceTree = "<group>"; };
 		2A03300C165D1D2100E9CD70 /* unitTesting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = unitTesting.h; path = ../../../source/testing/unitTesting.h; sourceTree = "<group>"; };
 		2A033010165D1D4100E9CD70 /* platformFileIoTests.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = platformFileIoTests.cc; path = ../../../source/testing/tests/platformFileIoTests.cc; sourceTree = "<group>"; };
@@ -559,7 +559,7 @@
 		8609FE3016556E5A004662ED /* osxThread.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = osxThread.mm; sourceTree = "<group>"; };
 		8609FE3216556F22004662ED /* osxFileDialogs.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = osxFileDialogs.mm; sourceTree = "<group>"; };
 		8609FE351655716E004662ED /* osxPopupMenu.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = osxPopupMenu.mm; sourceTree = "<group>"; };
-		8609FE37165572EC004662ED /* osxFont.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = osxFont.mm; sourceTree = "<group>"; };
+		8609FE37165572EC004662ED /* osxFont.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 1; path = osxFont.mm; sourceTree = "<group>"; };
 		861CD8CE1678F6C200DAE1A0 /* fileDialog_ScriptBinding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fileDialog_ScriptBinding.h; sourceTree = "<group>"; };
 		861CD8CF1678F6C200DAE1A0 /* fileDialog.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = fileDialog.cc; sourceTree = "<group>"; };
 		864ECFEA1652795700012416 /* platform_ScriptBinding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = platform_ScriptBinding.h; sourceTree = "<group>"; };
@@ -1372,7 +1372,6 @@
 			buildActionMask = 2147483647;
 			files = (
 				865A20CA16515B1E00527C44 /* AppKit.framework in Frameworks */,
-				865A20CB16515B1E00527C44 /* AVFoundation.framework in Frameworks */,
 				865A20CC16515B1E00527C44 /* Cocoa.framework in Frameworks */,
 				865A20CD16515B1E00527C44 /* CoreData.framework in Frameworks */,
 				865A20CE16515B1E00527C44 /* CoreFoundation.framework in Frameworks */,
@@ -1836,6 +1835,7 @@
 		869FF8AD1651518C002FE082 = {
 			isa = PBXGroup;
 			children = (
+				04CC626B1795512500F9C119 /* AVFoundation.framework */,
 				8652F29F16C146CF00639EFE /* torque2d.icns */,
 				869FF8C21651518C002FE082 /* Torque2D */,
 				865A2351165188AF00527C44 /* platformOSX */,
@@ -3413,32 +3413,34 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ALWAYS_SEARCH_USER_PATHS = YES;
-				ARCHS = "$(NATIVE_ARCH_ACTUAL)";
+				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
 				CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
-				CLANG_CXX_LIBRARY = "libc++";
+				CLANG_CXX_LIBRARY = "libstdc++";
 				CLANG_WARN_EMPTY_BODY = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = YES;
 				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
 				"FRAMEWORK_SEARCH_PATHS[arch=*]" = "";
-				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_C_LANGUAGE_STANDARD = gnu89;
 				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
 				GCC_PREPROCESSOR_DEFINITIONS = TORQUE_SHIPPING;
+				GCC_VERSION = "";
 				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
 				GCC_WARN_UNINITIALIZED_AUTOS = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
 				HEADER_SEARCH_PATHS = "";
 				LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks";
-				MACOSX_DEPLOYMENT_TARGET = 10.7;
+				MACOSX_DEPLOYMENT_TARGET = 10.6;
 				SDKROOT = macosx;
+				VALID_ARCHS = i386;
 			};
 			name = Shipping;
 		};
 		865A20AF165152EA00527C44 /* Shipping */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				ARCHS = "$(NATIVE_ARCH)";
+				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
 				COMBINE_HIDPI_IMAGES = YES;
 				CONFIGURATION_BUILD_DIR = ../../..;
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
@@ -3447,6 +3449,7 @@
 					TORQUE_OS_OSX,
 					"$(inherited)",
 				);
+				GCC_VERSION = "";
 				HEADER_SEARCH_PATHS = (
 					../../source,
 					../../lib,
@@ -3460,9 +3463,10 @@
 				);
 				INFOPLIST_FILE = "Torque2D/Torque2D-Info.plist";
 				LIBRARY_SEARCH_PATHS = "$(inherited)";
-				MACOSX_DEPLOYMENT_TARGET = 10.7;
+				MACOSX_DEPLOYMENT_TARGET = 10.6;
 				OTHER_LDFLAGS = /usr/lib/libz.dylib;
 				PRODUCT_NAME = "$(TARGET_NAME)";
+				VALID_ARCHS = i386;
 				WRAPPER_EXTENSION = app;
 			};
 			name = Shipping;
@@ -3471,14 +3475,14 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ALWAYS_SEARCH_USER_PATHS = YES;
-				ARCHS = "$(NATIVE_ARCH_ACTUAL)";
+				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
 				CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
-				CLANG_CXX_LIBRARY = "libc++";
+				CLANG_CXX_LIBRARY = "libstdc++";
 				CLANG_WARN_EMPTY_BODY = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
 				"FRAMEWORK_SEARCH_PATHS[arch=*]" = "";
-				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_C_LANGUAGE_STANDARD = gnu89;
 				GCC_DYNAMIC_NO_PIC = NO;
 				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
 				GCC_OPTIMIZATION_LEVEL = 0;
@@ -3488,15 +3492,17 @@
 					"GTEST_USE_OWN_TR1_TUPLE=1",
 				);
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+				GCC_VERSION = "";
 				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
 				GCC_WARN_UNINITIALIZED_AUTOS = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
 				HEADER_SEARCH_PATHS = "";
 				LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks";
-				MACOSX_DEPLOYMENT_TARGET = 10.7;
+				MACOSX_DEPLOYMENT_TARGET = 10.6;
 				ONLY_ACTIVE_ARCH = NO;
 				SDKROOT = macosx;
+				VALID_ARCHS = i386;
 			};
 			name = Debug;
 		};
@@ -3504,36 +3510,38 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ALWAYS_SEARCH_USER_PATHS = YES;
-				ARCHS = "$(NATIVE_ARCH_ACTUAL)";
+				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
 				CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
-				CLANG_CXX_LIBRARY = "libc++";
+				CLANG_CXX_LIBRARY = "libstdc++";
 				CLANG_WARN_EMPTY_BODY = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = YES;
 				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
 				"FRAMEWORK_SEARCH_PATHS[arch=*]" = "";
-				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_C_LANGUAGE_STANDARD = gnu89;
 				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
 				GCC_PREPROCESSOR_DEFINITIONS = (
 					TORQUE_RELEASE,
 					GTEST_OS_MAC,
 					"GTEST_USE_OWN_TR1_TUPLE=1",
 				);
+				GCC_VERSION = "";
 				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
 				GCC_WARN_UNINITIALIZED_AUTOS = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
 				HEADER_SEARCH_PATHS = "";
 				LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks";
-				MACOSX_DEPLOYMENT_TARGET = 10.7;
+				MACOSX_DEPLOYMENT_TARGET = 10.6;
 				SDKROOT = macosx;
+				VALID_ARCHS = i386;
 			};
 			name = Release;
 		};
 		869FF8D71651518C002FE082 /* Debug */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				ARCHS = "$(NATIVE_ARCH)";
+				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
 				COMBINE_HIDPI_IMAGES = YES;
 				CONFIGURATION_BUILD_DIR = ../../..;
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
@@ -3542,6 +3550,7 @@
 					TORQUE_OS_OSX,
 					"$(inherited)",
 				);
+				GCC_VERSION = "";
 				HEADER_SEARCH_PATHS = (
 					../../source,
 					../../lib,
@@ -3557,9 +3566,10 @@
 				);
 				INFOPLIST_FILE = "Torque2D/Torque2D-Info.plist";
 				LIBRARY_SEARCH_PATHS = "$(inherited)";
-				MACOSX_DEPLOYMENT_TARGET = 10.7;
+				MACOSX_DEPLOYMENT_TARGET = 10.6;
 				OTHER_LDFLAGS = /usr/lib/libz.dylib;
 				PRODUCT_NAME = "$(TARGET_NAME)_DEBUG";
+				VALID_ARCHS = i386;
 				WRAPPER_EXTENSION = app;
 			};
 			name = Debug;
@@ -3567,7 +3577,7 @@
 		869FF8D81651518C002FE082 /* Release */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				ARCHS = "$(NATIVE_ARCH)";
+				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
 				COMBINE_HIDPI_IMAGES = YES;
 				CONFIGURATION_BUILD_DIR = ../../..;
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
@@ -3576,6 +3586,7 @@
 					TORQUE_OS_OSX,
 					"$(inherited)",
 				);
+				GCC_VERSION = "";
 				HEADER_SEARCH_PATHS = (
 					../../source,
 					../../lib,
@@ -3591,9 +3602,10 @@
 				);
 				INFOPLIST_FILE = "Torque2D/Torque2D-Info.plist";
 				LIBRARY_SEARCH_PATHS = "$(inherited)";
-				MACOSX_DEPLOYMENT_TARGET = 10.7;
+				MACOSX_DEPLOYMENT_TARGET = 10.6;
 				OTHER_LDFLAGS = /usr/lib/libz.dylib;
 				PRODUCT_NAME = "$(TARGET_NAME)";
+				VALID_ARCHS = i386;
 				WRAPPER_EXTENSION = app;
 			};
 			name = Release;

+ 2 - 3
engine/compilers/Xcode/Torque2D.xcodeproj/xcshareddata/xcschemes/Torque2D.xcscheme

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Scheme
    LastUpgradeVersion = "0460"
-   version = "1.3">
+   version = "1.8">
    <BuildAction
       parallelizeBuildables = "YES"
       buildImplicitDependencies = "YES">
@@ -44,8 +44,7 @@
       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
       launchStyle = "0"
       useCustomWorkingDirectory = "NO"
-      buildConfiguration = "Debug"
-      ignoresPersistentStateOnLaunch = "NO"
+      buildConfiguration = "Release"
       debugDocumentVersioning = "YES"
       allowLocationSimulation = "YES">
       <BuildableProductRunnable>

+ 1 - 1
engine/compilers/Xcode/Torque2D/Config.xcconfig

@@ -52,7 +52,7 @@ ConsoleMethod(PointForceController, setPosition, void, 3, 4,    "(float x, float
 
 //-----------------------------------------------------------------------------
 
-ConsoleMethod(PointForceController, PointForceController, const char*, 2, 2,    "() Gets the position of the force center.\n"
+ConsoleMethod(PointForceController, getPosition, const char*, 2, 2,    "() Gets the position of the force center.\n"
                                                                                 "@return (float x/float y) The x and y (horizontal and vertical) position of the force center.")
 {
     // Get position.

+ 2 - 29
engine/source/2d/gui/SceneWindow.cc

@@ -576,42 +576,15 @@ F32 SceneWindow::interpolate( F32 from, F32 to, F32 delta )
 {
     // Linear.
     if ( mCameraInterpolationMode == LINEAR )
-        return linearInterpolate( from, to, delta );
+        return mLerp( from, to, delta );
     // Sigmoid.
     else if ( mCameraInterpolationMode == SIGMOID )
-        return sigmoidInterpolate( from, to, delta );
+        return mSmoothStep( from, to, delta );
     // Hmmm...
     else
         return from;
 }
 
-//-----------------------------------------------------------------------------
-
-F32 SceneWindow::linearInterpolate( F32 from, F32 to, F32 delta )
-{
-    // Clamp if we're over/under time.
-    if ( delta <= 0.0f )
-        return from;
-    else if ( delta >= 1.0f )
-        return to;
-
-    // Calculate resultant interpolation.
-    return ( from * ( 1.0f - delta ) ) + ( to * delta );
-}
-
-//-----------------------------------------------------------------------------
-
-F32 SceneWindow::sigmoidInterpolate( F32 from, F32 to, F32 delta )
-{
-    // Range Expand/Clamp Delta to (-1 -> +1).
-    delta = mClampF( (delta - 0.5f) * 2.0f, -1.0f, 1.0f );
-
-    // Calculate interpolator value using sigmoid function.
-    F32 sigmoid = mClampF ( 1.0f / (1.0f + mPow(2.718282f, -15.0f * delta)), 0.0f, 1.0f );
-
-    // Calculate resultant interpolation.
-    return ( from * ( 1.0f - sigmoid ) ) + ( to * sigmoid );
-}
 
 //-----------------------------------------------------------------------------
 

+ 0 - 2
engine/source/2d/gui/SceneWindow.h

@@ -270,8 +270,6 @@ public:
     void completeCameraMove( void );
     void undoCameraMove( const F32 interpolationTime );
     F32 interpolate( F32 from, F32 to, F32 delta );
-    F32 linearInterpolate( F32 from, F32 to, F32 delta );
-    F32 sigmoidInterpolate( F32 from, F32 to, F32 delta );
     void updateCamera( void );
 
     inline Vector2 getCameraRenderPosition( void )                      { calculateCameraView( &mCameraCurrent ); return mCameraCurrent.mDestinationArea.centre(); }

+ 1 - 1
engine/source/2d/sceneobject/ShapeVector.h

@@ -117,7 +117,7 @@ protected:
     static bool writeFillColor( void* obj, StringTableEntry pFieldName ) { return static_cast<ShapeVector*>(obj)->mFillColor != ColorF(0.5f,0.5f,0.5f,1.0f); }
     static bool writeFillMode( void* obj, StringTableEntry pFieldName ) { return static_cast<ShapeVector*>(obj)->mFillMode == true; }
     static bool writeIsCircle( void* obj, StringTableEntry pFieldName ) { return static_cast<ShapeVector*>(obj)->mIsCircle == true; }
-    static bool writeCircleRadius( void* obj, StringTableEntry pFieldName ) { return static_cast<ShapeVector*>(obj)->mIsCircle != 1; }
+    static bool writeCircleRadius( void* obj, StringTableEntry pFieldName ) { return static_cast<ShapeVector*>(obj)->mCircleRadius != 1; }
 };
 
 #endif // _SHAPE_VECTOR_H_

+ 76 - 27
engine/source/audio/audio.cc

@@ -102,6 +102,7 @@ struct LoopingImage
 static F32 mMasterVolume = 1.f;           // traped from AL_LISTENER gain (miles has difficulties with 3d sources)
 
 static ALuint                 mSource[MAX_AUDIOSOURCES];                   // ALSources
+static ALint                  mResumePosition[MAX_AUDIOSOURCES];           // Ensures Pause resumes from the correct position
 static AUDIOHANDLE            mHandle[MAX_AUDIOSOURCES];                   // unique handles
 static Resource<AudioBuffer>  mBuffer[MAX_AUDIOSOURCES];                   // each of the playing buffers (needed for AudioThread)
 static F32                    mScore[MAX_AUDIOSOURCES];                    // for figuring out which sources to cull/uncull
@@ -580,6 +581,8 @@ static void alxSourcePlay(AudioStreamSource *streamSource)
    ALuint source = streamSource->mSource;
    Audio::Description& desc = streamSource->mDescription;
 
+   bool ret = streamSource->initStream();
+
    alSourcef(source, AL_GAIN, Audio::linearToDB(desc.mVolume * mAudioChannelVolumes[desc.mVolumeChannel] * mMasterVolume));
 //   alSourcei(source, AL_LOOPING, AL_FALSE);
    alSourcef(source, AL_PITCH, 1.f);
@@ -965,30 +968,17 @@ bool alxPause( AUDIOHANDLE handle )
 
     alSourcePause( mSource[index] );
 
-    ALenum error = 0;
-    if ( (error = alGetError()) == AL_NO_ERROR)
-        return true;
-    switch (error)
-    {
-        case AL_INVALID_NAME:
-            Con::errorf("alxPause - OpenAL AL_INVALID_NAME error code returned");
-            break;
-        case AL_INVALID_ENUM:
-            Con::errorf("alxPause - OpenAL AL_INVALID_ENUM error code returned");
-            break;
-        case AL_INVALID_VALUE:
-            Con::errorf("alxPause - OpenAL AL_INVALID_VALUE error code returned");
-            break;
-        case AL_INVALID_OPERATION:
-            Con::errorf("alxPause - OpenAL AL_INVALID_OPERATION error code returned");
-            break;
-        case AL_OUT_OF_MEMORY:
-            Con::errorf("alxPause - OpenAL AL_OUT_OF_MEMORY error code returned");
-            break;
-        default:
-            Con::errorf("alxPause - OpenAL has encountered a problem and won't tell us what it is.");
-    };
-    return false;
+    ALint state;
+	alGetSourcei(mSource[index], AL_SOURCE_STATE, &state);
+
+	if( state==AL_PAUSED)
+	{
+		mResumePosition[index] = -1;
+		return true;
+	}
+
+	alGetSourcei(mSource[index], AL_SAMPLE_OFFSET, &mResumePosition[index]);
+	return alxCheckError("alxPause()","alGetSourcei");
 }
 
 void alxUnPause( AUDIOHANDLE handle )
@@ -996,7 +986,18 @@ void alxUnPause( AUDIOHANDLE handle )
     if(handle == NULL_AUDIOHANDLE)
         return;
     
-    alxPlay( handle );
+	U32 index = alxFindIndex(handle);
+	ALuint source = mSource[index];
+
+	if( mResumePosition[index] != -1 )
+	{
+		alSourcei( source, AL_SAMPLE_OFFSET, mResumePosition[index]);
+		mResumePosition[index] = -1;
+	}
+	alxCheckError("alxUnPause()","alSourcei");
+
+	alSourcePlay( source );
+	alxCheckError("alxUnPause()","alSourcePlay");
 }
 //--------------------------------------------------------------------------
 void alxStop(AUDIOHANDLE handle)
@@ -1920,7 +1921,7 @@ void alxCloseHandles()
 
       ALint state = 0;
       alGetSourcei(mSource[i], AL_SOURCE_STATE, &state);
-      if(state == AL_PLAYING)
+      if(state == AL_PLAYING || state == AL_PAUSED)
          continue;
 
       if(!(mHandle[i] & AUDIOHANDLE_INACTIVE_BIT))
@@ -1979,6 +1980,11 @@ void alxUpdateScores(bool sourcesOnly)
          continue;
       }
 
+	  ALint state = 0;
+	  alGetSourcei(mSource[i], AL_SOURCE_STATE, &state);
+	  if(state==AL_PAUSED)
+		  continue;
+
       // grab the volume.. (not attenuated by master for score)
       F32 volume = mSourceVolume[i] * mAudioChannelVolumes[mType[i]];
 
@@ -2159,6 +2165,36 @@ ALuint alxGetWaveLen(ALuint buffer)
    return(len);
 }
 
+bool alxCheckError(const char* sourceFuncName, const char* alFuncName)
+{
+  ALenum errorVal = alGetError();
+  switch (errorVal)
+  {
+    case AL_NO_ERROR:
+      break;
+    case AL_INVALID_NAME:
+      Con::errorf("%s - %s OpenAL AL_INVALID_NAME error code returned", sourceFuncName, alFuncName);
+      break;
+    case AL_INVALID_ENUM:
+      Con::errorf("%s - %s OpenAL AL_INVALID_ENUM error code returned", sourceFuncName, alFuncName);
+      break;
+    case AL_INVALID_VALUE:
+      Con::errorf("%s - %s OpenAL AL_INVALID_VALUE error code returned", sourceFuncName, alFuncName);
+      break;
+    case AL_INVALID_OPERATION:
+      Con::errorf("%s - %s OpenAL AL_INVALID_OPERATION error code returned", sourceFuncName, alFuncName);
+      break;
+    case AL_OUT_OF_MEMORY:
+      Con::errorf("%s - %s OpenAL AL_OUT_OF_MEMORY error code returned", sourceFuncName, alFuncName);
+      break;
+    default:
+      Con::errorf("%s - %s OpenAL has encountered a problem and won't tell us what it is. %d", errorVal, sourceFuncName, alFuncName);
+  };
+  if (errorVal == AL_NO_ERROR)
+    return true;
+  else
+    return false;
+}
 
 //--------------------------------------------------------------------------
 // Environment:
@@ -2531,9 +2567,22 @@ void OpenALShutdown()
       delete mLoopingFreeList.last();
       mLoopingFreeList.pop_back();
    }
+   
+   //clear error buffer
+   alGetError();
 
    for(U32 i = 0; i < MAX_AUDIOSOURCES; i++)
-      mBuffer[i] = 0;
+   {
+	   ALint tempbuff = 0;
+	   alGetSourcei( mSource[i], AL_BUFFER, &tempbuff);
+
+	   if (alIsBuffer(tempbuff) && tempbuff !=0)
+	   {
+		   ALuint buffer = tempbuff;
+		   alSourceUnqueueBuffers( mSource[i], 1, &buffer);
+		   alxCheckError("OpenALShutdown()","alSourceUnqueueBuffers");
+	   }
+   }
 
    alDeleteSources(mNumSources, mSource);
 

+ 2 - 0
engine/source/audio/audio.h

@@ -38,5 +38,7 @@
 //-Mat default sample rate, change as needed
 #define DEFAULT_SOUND_OUTPUT_RATE		44100
 
+bool alxCheckError(const char*, const char*);
+
 
 #endif  // _H_AUDIO_

+ 31 - 8
engine/source/audio/audioBuffer.cc

@@ -110,14 +110,37 @@ AudioBuffer::AudioBuffer(StringTableEntry filename)
 
 AudioBuffer::~AudioBuffer()
 {
-   if( malBuffer != 0 ) 
-   {
-     alGetError();
-     alDeleteBuffers( 1, &malBuffer );
-     ALenum error;
-     error = alGetError();
-     AssertWarn( error == AL_NO_ERROR, "AudioBuffer::~AudioBuffer() - failed to release buffer" );
-   }
+   if( alIsBuffer(malBuffer) )
+  {
+    alGetError();
+    alDeleteBuffers( 1, &malBuffer );
+
+    ALenum error;
+    error = alGetError();
+    AssertWarn( error == AL_NO_ERROR, "AudioBuffer::~AudioBuffer() - failed to release buffer" );
+    switch (error)
+    {
+      case AL_NO_ERROR:
+        break;
+      case AL_INVALID_NAME:
+        Con::errorf("AudioBuffer::~AudioBuffer() - alDeleteBuffers OpenAL AL_INVALID_NAME error code returned");
+        break;
+      case AL_INVALID_ENUM:
+        Con::errorf("AudioBuffer::~AudioBuffer() - alDeleteBuffers OpenAL AL_INVALID_ENUM error code returned");
+        break;
+      case AL_INVALID_VALUE:
+        Con::errorf("AudioBuffer::~AudioBuffer() - alDeleteBuffers OpenAL AL_INVALID_VALUE error code returned");
+        break;
+      case AL_INVALID_OPERATION:
+        Con::errorf("AudioBuffer::~AudioBuffer() - alDeleteBuffers OpenAL AL_INVALID_OPERATION error code returned");
+        break;
+      case AL_OUT_OF_MEMORY:
+        Con::errorf("AudioBuffer::~AudioBuffer() - alDeleteBuffers OpenAL AL_OUT_OF_MEMORY error code returned");
+        break;
+      default:
+        Con::errorf("AudioBuffer::~AudioBuffer() - alDeleteBuffers OpenAL has encountered a problem and won't tell us what it is. %d", error);
+    };
+  }
 }
 
 //--------------------------------------

+ 6 - 3
engine/source/audio/audioFunctions.cc

@@ -92,6 +92,9 @@ static ALenum getEnum(const char * name, U32 flags)
       { "AL_CONE_INNER_ANGLE",            AL_CONE_INNER_ANGLE,             (Source|Get|Set|Int) },
       { "AL_CONE_OUTER_ANGLE",            AL_CONE_OUTER_ANGLE,             (Source|Get|Set|Int) },
       { "AL_LOOPING",                     AL_LOOPING,                      (Source|Get|Set|Int) },
+	  { "AL_SAMPLE_OFFSET",               AL_SAMPLE_OFFSET,                (Source|Get|Set|Int) },
+	  { "AL_SEC_OFFSET",                  AL_SEC_OFFSET,                   (Source|Get|Set|Int) },
+	  { "AL_BYTE_OFFSET",                 AL_BYTE_OFFSET,                  (Source|Get|Set|Int) },
       //{ "AL_STREAMING",                   AL_STREAMING,                    (Source|Get|Set|Int) },
       //{ "AL_BUFFER",                      AL_BUFFER,                       (Source|Get|Set|Int) },
 
@@ -342,7 +345,7 @@ ConsoleFunction(alxSourcei, void, 4, 4, "( handle , ALEnum , value ) Use the alx
       return;
    }
 
-   alxSourcei(dAtoi(argv[1]), e, dAtoi(argv[3]));
+   alxSourcei(dAtoi(argv[1]), e, static_cast<ALint>(dAtoi(argv[3])));
 }
 
 
@@ -406,9 +409,9 @@ ConsoleFunction(alxGetSourcei, S32, 3, 3, "( handle , ALEnum ) Use the alxGetSou
       return(0);
    }
 
-   S32 value;
+   ALint value;
    alxGetSourcei(dAtoi(argv[1]), e, &value);
-   return(value);
+   return(static_cast<S32>(value));
 }
 
 

+ 15 - 0
engine/source/math/mMathFn.h

@@ -365,6 +365,21 @@ inline U32 mMulDiv(S32 a, S32 b, U32 c)
    return m_mulDivU32(a, b, c);
 }
 
+/// Template function for doing a linear interpolation between any two
+/// types which implement operators for scalar multiply and addition.
+template <typename T>
+inline T mLerp( const T &v1, const T &v2, F32 factor )
+{
+   factor = mClampF( factor, 0.0f, 1.0f);
+   return ( v1 * ( 1.0f - factor ) ) + ( v2 * factor );
+}
+
+template <typename T>
+inline T mSmoothStep( const T &v1, const T &v2, F32 factor)
+{
+   factor = mClampF( factor, 0.0f, 1.0f);
+   return mLerp(v1, v2, (factor*factor*(3.0f-2.0f*factor)));
+}
 
 inline F32 mSin(const F32 angle)
 {

+ 6 - 1
engine/source/persistence/SimXMLDocument.cpp

@@ -1095,7 +1095,12 @@ const char* SimXMLDocument::getData()
    if(!pNode)
       return "";
 
-   TiXmlText* text = pNode->FirstChild()->ToText();
+   TiXmlNode * firstChild =  pNode->FirstChild();
+
+   if(!firstChild)
+	   return "";
+
+   TiXmlText* text = firstChild->ToText();
    if( !text )
       return "";
 

+ 251 - 241
engine/source/platformOSX/osxFont.mm

@@ -1,242 +1,252 @@
-//-----------------------------------------------------------------------------
-// Copyright (c) 2013 GarageGames, LLC
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//-----------------------------------------------------------------------------
-
-#import "platform/platform.h"
-#import "platformOSX/platformOSX.h"
-#import "platformOSX/osxFont.h"
-#import "string/Unicode.h"
-
-//------------------------------------------------------------------------------
-
-PlatformFont* createPlatformFont( const char* name, U32 size, U32 charset )
-{
-    PlatformFont* pFont = new OSXFont();
-    
-    if ( pFont->create(name, size, charset) )
-        return pFont;
-    
-    delete pFont;
-    
-    return NULL;
-}
-
-//------------------------------------------------------------------------------
-
-void PlatformFont::enumeratePlatformFonts( Vector<StringTableEntry>& fonts )
-{
-    // Fetch available fonts.
-    NSArray* availableFonts = [[NSFontManager sharedFontManager] availableFontNamesWithTraits:0];
-
-    // Enumerate font names.
-    for (id fontName in availableFonts)
-    {
-        fonts.push_back( StringTable->insert( [fontName UTF8String] ) );
-    }
-
-    // Release font name.
-    [availableFonts release];
-}
-
-//------------------------------------------------------------------------------
-
-OSXFont::OSXFont()
-{
-    // Reset the rendering color-space.
-    mColorSpace = NULL;
-}
-
-//------------------------------------------------------------------------------
-
-OSXFont::~OSXFont()
-{
-    // Destroy the rendering color-space.
-    CGColorSpaceRelease( mColorSpace );
-}
-
-//------------------------------------------------------------------------------
-
-bool OSXFont::create( const char* name, U32 size, U32 charset )
-{
-    // Sanity!
-    AssertFatal( name != NULL, "Cannot create a NULL font name." );
-
-    // Generate compatible font name.
-    CFStringRef fontName = CFStringCreateWithCString( kCFAllocatorDefault, name, kCFStringEncodingUTF8 );
-
-    // Sanity!
-    if ( !fontName )
-    {
-        Con::errorf("Could not handle font name of '%s'.", name );
-        return false;
-    }
-
-    // Use Windows as a baseline (96 DPI) and adjust accordingly.
-    F32 scaledSize = size * (72.0f/96.0f);
-    scaledSize = mRound(scaledSize);
-
-    // Create the font reference.
-    mFontRef = CTFontCreateWithName( fontName, scaledSize, NULL );
-
-    // Sanity!
-    if ( !mFontRef )
-    {
-        Con::errorf( "Could not generate a font reference to font name '%s' of size '%d'", name, size );
-        return false;
-    }
-
-    // Fetch font metrics.
-    CGFloat ascent = CTFontGetAscent( mFontRef );
-    CGFloat descent = CTFontGetDescent( mFontRef );
-
-    // Set baseline.
-    mBaseline = (U32)mRound(ascent);
-
-    // Set height.
-    mHeight = (U32)mRound( ascent + descent );
-
-    // Create a gray-scale color-space.
-    mColorSpace = CGColorSpaceCreateDeviceGray();
-
-    // Return status.
-    return true;
-}
-
-//------------------------------------------------------------------------------
-
-bool OSXFont::isValidChar( const UTF8* str ) const
-{
-    // since only low order characters are invalid, and since those characters
-    // are single codeunits in UTF8, we can safely cast here.
-    return isValidChar((UTF16)*str);
-}
-
-//------------------------------------------------------------------------------
-
-bool OSXFont::isValidChar( const UTF16 character) const
-{
-    // We cut out the ASCII control chars here. Only printable characters are valid.
-    // 0x20 == 32 == space
-    if( character < 0x20 )
-        return false;
-    
-    return true;
-}
-
-//------------------------------------------------------------------------------
-
-PlatformFont::CharInfo& OSXFont::getCharInfo(const UTF8 *str) const
-{
-    return getCharInfo( oneUTF32toUTF16(oneUTF8toUTF32(str,NULL)) );
-}
-
-//------------------------------------------------------------------------------
-
-PlatformFont::CharInfo& OSXFont::getCharInfo(const UTF16 character) const
-{
-    // Declare and clear out the CharInfo that will be returned.
-    static PlatformFont::CharInfo characterInfo;
-    dMemset(&characterInfo, 0, sizeof(characterInfo));
-    
-    // prep values for GFont::addBitmap()
-    characterInfo.bitmapIndex = 0;
-    characterInfo.xOffset = 0;
-    characterInfo.yOffset = 0;
-
-    CGGlyph characterGlyph;
-    CGRect characterBounds;
-    CGSize characterAdvances;
-    UniChar unicodeCharacter = character;
-
-    // Fetch font glyphs.
-    if ( !CTFontGetGlyphsForCharacters( mFontRef, &unicodeCharacter, &characterGlyph, (CFIndex)1) )
-    {
-        // Sanity!
-        AssertFatal( false, "Cannot create font glyph." );
-    }
-
-    // Fetch glyph bounding box.
-    CTFontGetBoundingRectsForGlyphs( mFontRef, kCTFontHorizontalOrientation, &characterGlyph, &characterBounds, (CFIndex)1 );
-
-    // Fetch glyph advances.
-    CTFontGetAdvancesForGlyphs( mFontRef, kCTFontHorizontalOrientation, &characterGlyph, &characterAdvances, (CFIndex)1 );
-
-    // Set character metrics,
-    characterInfo.xOrigin = (S32)mRound( characterBounds.origin.x );
-    characterInfo.yOrigin = (S32)mRound( characterBounds.origin.y );
-    characterInfo.width = (U32)mCeil( characterBounds.size.width ) + 2;
-    characterInfo.height = (U32)mCeil( characterBounds.size.height ) + 2;
-    characterInfo.xIncrement = (S32)mRound( characterAdvances.width );
-
-    // Finish if character is undrawable.
-    if ( characterInfo.width == 0 && characterInfo.height == 0 )
-        return characterInfo;
-
-    // Clamp character minimum width.
-    if ( characterInfo.width == 0 )
-        characterInfo.width = 2;
-
-    if ( characterInfo.height == 0 )
-        characterInfo.height = 1;
-
-
-    // Allocate a bitmap surface.
-    const U32 bitmapSize = characterInfo.width * characterInfo.height;
-    characterInfo.bitmapData = new U8[bitmapSize];
-    dMemset(characterInfo.bitmapData, 0x00, bitmapSize);
-
-    // Create a bitmap context.
-    CGContextRef bitmapContext = CGBitmapContextCreate( characterInfo.bitmapData, characterInfo.width, characterInfo.height, 8, characterInfo.width, mColorSpace, kCGImageAlphaNone );
-
-    // Sanity!
-    AssertFatal( bitmapContext != NULL, "Cannot create font context." );
-
-    // Render font anti-aliased if font is arbitrarily small.
-    CGContextSetShouldAntialias( bitmapContext, true);
-    CGContextSetShouldSmoothFonts( bitmapContext, true);
-    CGContextSetRenderingIntent( bitmapContext, kCGRenderingIntentAbsoluteColorimetric);
-    CGContextSetInterpolationQuality( bitmapContext, kCGInterpolationNone);
-    CGContextSetGrayFillColor( bitmapContext, 1.0, 1.0);
-    CGContextSetTextDrawingMode( bitmapContext,  kCGTextFill);
-
-    // Draw glyph.
-    CGPoint renderOrigin;
-    renderOrigin.x = -characterInfo.xOrigin;
-    renderOrigin.y = -characterInfo.yOrigin;
-    CTFontDrawGlyphs( mFontRef, &characterGlyph, &renderOrigin, 1, bitmapContext );
-
- #if 0
-    Con::printf("Width:%f, Height:%f, OriginX:%f, OriginY:%f",
-            characterBounds.size.width,
-            characterBounds.size.height,
-            characterBounds.origin.x,
-            characterBounds.origin.y );
-#endif
-
-    // Adjust the y origin for the glyph size.
-    characterInfo.yOrigin += characterInfo.height;// + mHeight;
-
-    // Release the bitmap context.
-    CGContextRelease( bitmapContext );
-
-    // Return character information.
-    return characterInfo;
+//-----------------------------------------------------------------------------
+// Copyright (c) 2013 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+ 
+#import "platform/platform.h"
+#import "platformOSX/platformOSX.h"
+#import "platformOSX/osxFont.h"
+#import "string/Unicode.h"
+
+//------------------------------------------------------------------------------
+
+PlatformFont* createPlatformFont( const char* name, U32 size, U32 charset )
+{
+    PlatformFont* pFont = new OSXFont();
+    
+    if ( pFont->create(name, size, charset) )
+        return pFont;
+    
+    delete pFont;
+    
+    return NULL;
+}
+
+//------------------------------------------------------------------------------
+
+void PlatformFont::enumeratePlatformFonts( Vector<StringTableEntry>& fonts )
+{
+    // Fetch available fonts.
+    NSArray* availableFonts = [[NSFontManager sharedFontManager] availableFontNamesWithTraits:0];
+
+    // Enumerate font names.
+    for (id fontName in availableFonts)
+    {
+        fonts.push_back( StringTable->insert( [fontName UTF8String] ) );
+    }
+
+    // Release font name.
+    [availableFonts release];
+}
+
+//------------------------------------------------------------------------------
+
+OSXFont::OSXFont()
+{
+    // Reset the rendering color-space.
+    mColorSpace = NULL;
+}
+
+//------------------------------------------------------------------------------
+
+OSXFont::~OSXFont()
+{
+    // Destroy the rendering color-space.
+    CGColorSpaceRelease( mColorSpace );
+}
+
+//------------------------------------------------------------------------------
+
+bool OSXFont::create( const char* name, U32 size, U32 charset )
+{
+    // Sanity!
+    AssertFatal( name != NULL, "Cannot create a NULL font name." );
+
+    // Generate compatible font name.
+    CFStringRef fontName = CFStringCreateWithCString( kCFAllocatorDefault, name, kCFStringEncodingUTF8 );
+
+    // Sanity!
+    if ( !fontName )
+    {
+        Con::errorf("Could not handle font name of '%s'.", name );
+        return false;
+    }
+
+    // Use Windows as a baseline (96 DPI) and adjust accordingly.
+    F32 scaledSize = size * (72.0f/96.0f);
+    scaledSize = mRound(scaledSize);
+
+    // Create the font reference.
+    mFontRef = CTFontCreateWithName( fontName, scaledSize, NULL );
+
+    // Sanity!
+    if ( !mFontRef )
+    {
+        Con::errorf( "Could not generate a font reference to font name '%s' of size '%d'", name, size );
+        return false;
+    }
+
+    // Fetch font metrics.
+    CGFloat ascent = CTFontGetAscent( mFontRef );
+    CGFloat descent = CTFontGetDescent( mFontRef );
+
+    // Set baseline.
+    mBaseline = (U32)mRound(ascent);
+
+    // Set height.
+    mHeight = (U32)mRound( ascent + descent );
+
+    // Create a gray-scale color-space.
+    mColorSpace = CGColorSpaceCreateDeviceGray();
+
+    // Return status.
+    return true;
+}
+
+//------------------------------------------------------------------------------
+
+bool OSXFont::isValidChar( const UTF8* str ) const
+{
+    // since only low order characters are invalid, and since those characters
+    // are single codeunits in UTF8, we can safely cast here.
+    return isValidChar((UTF16)*str);
+}
+
+//------------------------------------------------------------------------------
+
+bool OSXFont::isValidChar( const UTF16 character) const
+{
+    // We cut out the ASCII control chars here. Only printable characters are valid.
+    // 0x20 == 32 == space
+    if( character < 0x20 )
+        return false;
+    
+    return true;
+}
+
+//------------------------------------------------------------------------------
+
+PlatformFont::CharInfo& OSXFont::getCharInfo(const UTF8 *str) const
+{
+    return getCharInfo( oneUTF32toUTF16(oneUTF8toUTF32(str,NULL)) );
+}
+
+//------------------------------------------------------------------------------
+
+PlatformFont::CharInfo& OSXFont::getCharInfo(const UTF16 character) const
+{
+    // Declare and clear out the CharInfo that will be returned.
+    static PlatformFont::CharInfo characterInfo;
+    dMemset(&characterInfo, 0, sizeof(characterInfo));
+    
+    // prep values for GFont::addBitmap()
+    characterInfo.bitmapIndex = 0;
+    characterInfo.xOffset = 0;
+    characterInfo.yOffset = 0;
+
+    CGGlyph characterGlyph;
+    CGRect characterBounds;
+    CGSize characterAdvances;
+    UniChar unicodeCharacter = character;
+
+    // Fetch font glyphs.
+    if ( !CTFontGetGlyphsForCharacters( mFontRef, &unicodeCharacter, &characterGlyph, (CFIndex)1) )
+    {
+        // Sanity!
+        AssertFatal( false, "Cannot create font glyph." );
+    }
+
+    // Fetch glyph bounding box.
+    CTFontGetBoundingRectsForGlyphs( mFontRef, kCTFontHorizontalOrientation, &characterGlyph, &characterBounds, (CFIndex)1 );
+
+    // Fetch glyph advances.
+    CTFontGetAdvancesForGlyphs( mFontRef, kCTFontHorizontalOrientation, &characterGlyph, &characterAdvances, (CFIndex)1 );
+
+    // Set character metrics,
+    characterInfo.xOrigin = (S32)mRound( characterBounds.origin.x );
+    characterInfo.yOrigin = (S32)mRound( characterBounds.origin.y );
+    characterInfo.width = (U32)mCeil( characterBounds.size.width ) + 2;
+    characterInfo.height = (U32)mCeil( characterBounds.size.height ) + 2;
+    characterInfo.xIncrement = (S32)mRound( characterAdvances.width );
+
+    // Finish if character is undrawable.
+    if ( characterInfo.width == 0 && characterInfo.height == 0 )
+        return characterInfo;
+
+    // Clamp character minimum width.
+    if ( characterInfo.width == 0 )
+        characterInfo.width = 2;
+
+    if ( characterInfo.height == 0 )
+        characterInfo.height = 1;
+
+
+    // Allocate a bitmap surface.
+    const U32 bitmapSize = characterInfo.width * characterInfo.height;
+    characterInfo.bitmapData = new U8[bitmapSize];
+    dMemset(characterInfo.bitmapData, 0x00, bitmapSize);
+
+    // Create a bitmap context.
+    CGContextRef bitmapContext = CGBitmapContextCreate( characterInfo.bitmapData, characterInfo.width, characterInfo.height, 8, characterInfo.width, mColorSpace, kCGImageAlphaNone );
+
+    // Sanity!
+    AssertFatal( bitmapContext != NULL, "Cannot create font context." );
+
+    // Render font anti-aliased if font is arbitrarily small.
+    CGContextSetShouldAntialias( bitmapContext, true);
+    CGContextSetShouldSmoothFonts( bitmapContext, true);
+    CGContextSetRenderingIntent( bitmapContext, kCGRenderingIntentAbsoluteColorimetric);
+    CGContextSetInterpolationQuality( bitmapContext, kCGInterpolationNone);
+    CGContextSetGrayFillColor( bitmapContext, 1.0, 1.0);
+    CGContextSetTextDrawingMode( bitmapContext,  kCGTextFill);
+
+    // Draw glyph. 
+    CGPoint renderOrigin;
+    renderOrigin.x = -characterInfo.xOrigin;
+    renderOrigin.y = -characterInfo.yOrigin;
+    
+#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
+    CTFontDrawGlyphs( mFontRef, &characterGlyph, &renderOrigin, 1, bitmapContext );
+#else
+    CGFontRef cgFont = CTFontCopyGraphicsFont(mFontRef, NULL);
+    CGContextSetFont(bitmapContext, cgFont);
+    CGContextSetFontSize(bitmapContext, CTFontGetSize(mFontRef));
+    CGContextShowGlyphsAtPositions(bitmapContext, &characterGlyph, &renderOrigin, 1);
+    CFRelease(cgFont);
+#endif
+    
+     
+ #if 0
+    Con::printf("Width:%f, Height:%f, OriginX:%f, OriginY:%f",
+            characterBounds.size.width,
+            characterBounds.size.height,
+            characterBounds.origin.x,
+            characterBounds.origin.y );
+#endif
+
+    // Adjust the y origin for the glyph size.
+    characterInfo.yOrigin += characterInfo.height;// + mHeight;
+
+    // Release the bitmap context.
+    CGContextRelease( bitmapContext );
+
+    // Return character information.
+    return characterInfo;
 }

+ 14 - 0
engine/source/platformOSX/osxOpenGLDevice.mm

@@ -285,7 +285,21 @@ bool osxOpenGLDevice::setScreenMode( U32 width, U32 height, U32 bpp, bool fullSc
     }
     else
     {
+#if __MAC_OS_X_VERSION_MAX_ALLOWED < 1070
+        [[platState window] setStyleMask:NSTitledWindowMask | NSClosableWindowMask] ;
+        
+        // Calculate the actual center
+        CGFloat x = ([[NSScreen mainScreen] frame].size.width - width) / 2;
+        CGFloat y = ([[NSScreen mainScreen] frame].size.height - height) / 2;
+        
+        // Create a rect to send to the window
+        NSRect newFrame = NSMakeRect(x, y, width, height);
+        
+        // Send message to the window to resize/relocate
+        [[platState window] setFrame:newFrame display:YES animate:NO];
+#else
         [[platState window] setStyleMask:NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask];
+#endif
     }
     
     [[platState torqueView] createContextWithPixelFormat:pixelFormat];

+ 22 - 0
engine/source/platformOSX/platformOSX.mm

@@ -146,11 +146,33 @@ static osxPlatState * tempSharedPlatState = nil;
         
         // Get the new position of the title bar
         barOffset -= frame.size.height;
+        
+#if __MAC_OS_X_VERSION_MAX_ALLOWED < 1070
+        
+        // Update the frame of the torqueView to match the window
+        frame = NSMakeRect([_window frame].origin.x, [_window frame].origin.y, width, height);
+        NSRect viewFrame = NSMakeRect(0, 0, frame.size.width, frame.size.height);
+        [_torqueView setFrame:viewFrame];
+        [_torqueView updateContext];
+#endif
     }
     else
     {
+#if __MAC_OS_X_VERSION_MAX_ALLOWED < 1070
+        
+        NSRect mainDisplayRect = [[NSScreen mainScreen] frame];
+        // Update the frame of the torqueView to match the window
+        NSRect viewFrame = NSMakeRect(0, 0, mainDisplayRect.size.width, mainDisplayRect.size.height);
+        [_torqueView setFrame:viewFrame];
+        [_torqueView updateContext];
+        
+        // Otherwise, just go straight full screen
+        [_torqueView enterFullScreenMode:[NSScreen mainScreen] withOptions:nil];
+        
+#else
         // Otherwise, just go straight full screen
         [_window toggleFullScreen:self];
+#endif
     }
     
     // Update the frame of the torqueView to match the window

+ 2 - 2
engine/source/platformWin32/winWindow.cc

@@ -1494,9 +1494,9 @@ void Platform::init()
 //--------------------------------------
 void Platform::shutdown()
 {
-   sgQueueEvents = false;
-
+   sgQueueEvents = false;   
    setMouseLock( false );
+   Audio::OpenALShutdown();
    Video::destroy();
    Input::destroy();
    WinConsole::destroy();