Commits

David Lin committed df8664c

VS 2011 fix

  • Participants
  • Parent commits 695fd0c

Comments (0)

Files changed (12)

File CMakeLists.txt

 MESSAGE("uname -r = ${CMAKE_SYSTEM_VERSION}")
 
 if(CMAKE_SYSTEM_PROCESSOR STREQUAL "i386" OR
-   CMAKE_SYSTEM_PROCESSOR STREQUAL "X86")
+   CMAKE_SYSTEM_PROCESSOR STREQUAL "x86")
   SET(TARGET_CPU_X86 TRUE)
 elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR
        CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64")

File engine/CMakeLists.txt

   
 endif()
 
-
+SET_TARGET_PROPERTIES(Mocha PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
+SET_TARGET_PROPERTIES(Mocha PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
 
 ################################################################################

File engine/include/Mocha/MochaLog.h

 
 #include "MochaPrerequisites.h"
 
+#pragma warning( push )
+#pragma warning( disable: 4251 )
+
 namespace Mocha{
   
   class Log;
   
   ////////
   
+  //MOCHA_EXPORT_TEMPLATE template class MOCHA_EXPORT std::ofstream;
+
 }
+
+#pragma warning( pop )

File engine/include/Mocha/MochaMath.h

   };
   
   template<> struct Const<F32>{
-    static const F32 ZERO = 0.0f;
-    static const F32 ONE = 1.0f;
-    static const F32 TWO = 2.0f;
-    static const F32 HALF = 0.5f;
-    static const F32 NEG_ONE = -1.0f;
-    static const F32 PI = 3.141592653589793f;
-    static const F32 HALF_PI = 1.570796326794897f;
-    static const F32 RECIP_PI = 0.318309886183791f;
+    static const F32 zero(){ return (0.0f); }
+    static const F32 one(){ return (1.0f); }
+    static const F32 half(){ return (0.5f); }
+    static const F32 negOne(){ return (-1.0f); }
+    //static const F32 PI = 3.141592653589793f;
   };
   
   template<typename T> class Vector3;

File engine/include/Mocha/MochaMathMatrix.h

     const T qyqw2 = mul( qw, qy2 );
     const T qzqz2 = mul( qz, qz2 ), qzqw2 = mul( qw, qz2 );
     
-    m_Col0 = Vector3<T>(sub( sub( Const<T>::ONE, qyqy2 ), qzqz2 ), 
+    m_Col0 = Vector3<T>(sub( sub( Const<T>::one(), qyqy2 ), qzqz2 ), 
                         add( qxqy2, qzqw2 ), 
                         sub( qxqz2, qyqw2 ) );
     
     m_Col1 = Vector3<T>(sub( qxqy2, qzqw2 ), 
-                        sub( sub( Const<T>::ONE, qxqx2 ), qzqz2 ), 
+                        sub( sub( Const<T>::one(), qxqx2 ), qzqz2 ), 
                         add( qyqz2, qxqw2 ) );
     m_Col2 = Vector3<T>(add( qxqz2, qyqw2 ), 
                         sub( qyqz2, qxqw2 ), 
-                        sub( sub( Const<T>::ONE, qxqx2 ), qyqy2 ) );
+                        sub( sub( Const<T>::one(), qxqx2 ), qyqy2 ) );
     
   }
   
   
   template<typename T>
   const Matrix3<T> Matrix3<T>::scale( const Vector3<T>& scaleVec ){
-    const Vector3<T> tmp0( scaleVec.getX(), Const<T>::ZERO, Const<T>::ZERO );
-    const Vector3<T> tmp1( Const<T>::ZERO, scaleVec.getY(), Const<T>::ZERO );
-    const Vector3<T> tmp2( Const<T>::ZERO, Const<T>::ZERO, scaleVec.getZ() );
+    const Vector3<T> tmp0( scaleVec.getX(), Const<T>::zero(), Const<T>::zero() );
+    const Vector3<T> tmp1( Const<T>::zero(), scaleVec.getY(), Const<T>::zero() );
+    const Vector3<T> tmp2( Const<T>::zero(), Const<T>::zero(), scaleVec.getZ() );
     return Matrix3<T>( tmp0, tmp1, tmp2 );
   }
   
     sincos( radians, s, c );
     const T x = unitVec.getX(), y = unitVec.getY(), z = unitVec.getZ();
     const T xy = mul( x, y ), yz = mul( y, z ), zx = mul( z, x );
-    const T oneMinusC = sub( Const<T>::ONE, c );
+    const T oneMinusC = sub( Const<T>::one(), c );
     return Matrix3(Vector3<T>(add( mul( mul( x, x ), oneMinusC ), c ), 
                               add( mul( xy, oneMinusC ), mul( z, s ) ), 
                               sub( mul( zx, oneMinusC ), mul( y, s ) ) ),
   template<typename T>
   inline Matrix4<T>::Matrix4(const Matrix3<T>& upperleftMat,
                              const Vector3<T>& transVec)
-  :m_Col0(upperleftMat.getCol0(), Const<T>::ZERO),
-  m_Col1(upperleftMat.getCol1(), Const<T>::ZERO),
-  m_Col2(upperleftMat.getCol2(), Const<T>::ZERO),
-  m_Col3(transVec, Const<T>::ONE)
+  :m_Col0(upperleftMat.getCol0(), Const<T>::zero()),
+  m_Col1(upperleftMat.getCol1(), Const<T>::zero()),
+  m_Col2(upperleftMat.getCol2(), Const<T>::zero()),
+  m_Col3(transVec, Const<T>::one())
   {
   }
   
     const T rl = recip(sub( xRight, xLeft ));
     const T tb = recip(sub( yTop, yBottom ));
     const T nf = recip(sub( zNear, zFar ));
-    const T zero = Const<T>::ZERO;
+    const T zero = Const<T>::zero();
     
     const Vector4<T> col0( mul(n2, rl), zero, zero, zero );
     
     const Vector4<T> col2(mul( add( xRight, xLeft ), rl ), 
                           mul( add( yTop, yBottom ), tb ),
                           mul( add( zFar, zNear ), nf ), 
-                          Const<T>::NEG_ONE );
+                          Const<T>::negOne() );
     
     const Vector4<T> col3( zero, zero, mul(mul(n2, zFar), nf), zero );
     

File engine/include/Mocha/MochaMathQuaternion.h

   
   template<typename T>
   const Quaternion<T> Quaternion<T>::identity(){
-    return Quaternion<T>( Vector3<T>::zero(), Const<T>::ONE );
+    return Quaternion<T>( Vector3<T>::zero(), Const<T>::one() );
   }
   
   template<typename T>
   const Quaternion<T> 
   Quaternion<T>::rotation( T radians, const Vector3<T>& vec ){
     T s, c;
-    sincos( mul(radians, Const<T>::HALF), s, c );
+    sincos( mul(radians, Const<T>::half()), s, c );
     return Quaternion<T>( vec * s, c );
   }
   
   template<typename T>
   inline const DualQuaternion<T> 
   DualQuaternion<T>::operator*(const DualQuaternion<T>& dq)const{
-    DualQuaternion<T>((m_Quat0 * dq.m_Quat0), 
-                      (m_Quat0 * dq.m_QuatE + m_QuatE * dq.m_Quat0));
+    return DualQuaternion<T>((m_Quat0 * dq.m_Quat0), 
+                             (m_Quat0 * dq.m_QuatE + m_QuatE * dq.m_Quat0));
   }
   
   template<typename T>
   const DualQuaternion<T> DualQuaternion<T>::build(const Quaternion<T>& rota,
                                                    const Vector3<T>& trans)
   {
-    const Quaternion<T> t( trans * Const<T>::HALF, Const<T>::ZERO );
+    const Quaternion<T> t( trans * Const<T>::half(), Const<T>::zero() );
     
     return DualQuaternion<T>( rota, t * rota );
     // q0 = rot, qE = 0.5 * trans * q0

File engine/include/Mocha/MochaMathVector.h

   
   template<typename T>
   const Vector3<T> Vector3<T>::zero(){
-    return Vector3<T>( Const<T>::ZERO );
+    return Vector3<T>( Const<T>::zero() );
   }
   
   template<typename T>
   const Vector3<T> Vector3<T>::xAxis(){
-    return Vector3<T>( Const<T>::ONE, Const<T>::ZERO, Const<T>::ZERO );
+    return Vector3<T>( Const<T>::one(), Const<T>::zero(), Const<T>::zero() );
   }
   
   template<typename T>
   const Vector3<T> Vector3<T>::yAxis(){
-    return Vector3<T>( Const<T>::ZERO, Const<T>::ONE, Const<T>::ZERO );
+    return Vector3<T>( Const<T>::zero(), Const<T>::one(), Const<T>::zero() );
   }
   
   template<typename T>
   const Vector3<T> Vector3<T>::zAxis(){
-    return Vector3<T>( Const<T>::ZERO, Const<T>::ZERO, Const<T>::ONE );
+    return Vector3<T>( Const<T>::zero(), Const<T>::zero(), Const<T>::one() );
   }
   
 }
   
   template<typename T>
   const Vector4<T> Vector4<T>::zero(){
-    return Vector4<T>( Const<T>::ZERO );
+    return Vector4<T>( Const<T>::zero() );
   }
   
   template<typename T>
   const Vector4<T> Vector4<T>::xAxis(){
-    return Vector4<T>( Const<T>::ONE, Const<T>::ZERO, 
-                      Const<T>::ZERO, Const<T>::ZERO );
+    return Vector4<T>( Const<T>::one(), Const<T>::zero(), 
+                      Const<T>::zero(), Const<T>::zero() );
   }
   
   template<typename T>
   const Vector4<T> Vector4<T>::yAxis(){
-    return Vector4<T>( Const<T>::ZERO, Const<T>::ONE, 
-                      Const<T>::ZERO, Const<T>::ZERO );
+    return Vector4<T>( Const<T>::zero(), Const<T>::one(), 
+                      Const<T>::zero(), Const<T>::zero() );
   }
   
   template<typename T>
   const Vector4<T> Vector4<T>::zAxis(){
-    return Vector4<T>( Const<T>::ZERO, Const<T>::ZERO, 
-                      Const<T>::ONE, Const<T>::ZERO );
+    return Vector4<T>( Const<T>::zero(), Const<T>::zero(), 
+                      Const<T>::one(), Const<T>::zero() );
   }
   
   template<typename T>
   const Vector4<T> Vector4<T>::wAxis(){
-    return Vector4<T>( Const<T>::ZERO, Const<T>::ZERO, 
-                      Const<T>::ZERO, Const<T>::ONE );
+    return Vector4<T>( Const<T>::zero(), Const<T>::zero(), 
+                      Const<T>::zero(), Const<T>::one() );
   }
   
 }

File engine/include/Mocha/MochaPlatform.h

 #if MOCHA_SYSTEM == MOCHA_SYSTEM_WINDOWS
 #  ifdef MOCHA_FRAMEWORK_BUILD
 #    define MOCHA_EXPORT __declspec(dllexport)
+//#    define MOCHA_EXPORT_TEMPLATE
 #  else
 #    define MOCHA_EXPORT __declspec(dllimport)
+//#    define MOCHA_EXPORT_TEMPLATE extern
 #  endif
 #elif defined(__GNUC__)
 #  ifdef MOCHA_FRAMEWORK_BUILD
 #    define MOCHA_EXPORT __attribute__((visibility("default")))
+//#    define MOCHA_EXPORT_TEMPLATE
 #  else
 #    define MOCHA_EXPORT __attribute__((visibility("default")))
+//#    define MOCHA_EXPORT_TEMPLATE
 #  endif
 #else
 #  define MOCHA_EXPORT

File engine/include/Mocha/MochaPrerequisites.h

 namespace Mocha{
   
   inline I32 atomicExchange( volatile I32* target, I32 value ){
-    return _InterlockedExchange( target, value );
+    return _InterlockedExchange( (long*)target, value );
   }
   
   inline I32 atomicExchangeAdd( volatile I32* target, I32 value ){
-    return _InterlockedExchangeAdd( target, value );
+    return _InterlockedExchangeAdd( (long*)target, value );
   }
   
-  inline I32 atomicCompareExchange( volatile I32* target, I32 exchg, I32 cmprnd ){
-    return _InterlockedCompareExchange( target, exchg, cmprnd );
+  inline I32 atomicCompareExchange( volatile I32* target, I32 exchg, I32 old ){
+    return _InterlockedCompareExchange( (long*)target, exchg, old );
   }
   
   inline I32 atomicAdd( volatile I32* target, I32 value ){
-    return _InterlockedExchangeAdd( target, value )+1;
+    return _InterlockedExchangeAdd( (long*)target, value )+1;
   }
   
   inline I32 atomicInc( volatile I32* target ){
-    return _InterlockedIncrement( target );
+    return _InterlockedIncrement( (long*)target );
   }
   
   inline I32 atomicDec( volatile I32* target ){
-    return _InterlockedDecrement( target );
+    return _InterlockedDecrement( (long*)target );
   }
   
 }
     return __sync_fetch_and_add( target, value );
   }
   
-  inline I32 atomicCompareExchange( volatile I32* target, I32 exchg, I32 cmprnd ){
-    return __sync_val_compare_and_swap( target, cmprnd, exchg );
+  inline I32 atomicCompareExchange( volatile I32* target, I32 exchg, I32 old ){
+    return __sync_val_compare_and_swap( target, old, exchg );
   }
   
   inline I32 atomicAdd( volatile I32* target, I32 value ){

File engine/include/Mocha/MochaString.h

     static inline char toLower( char ch ){
       if(ch>='A' && ch<='Z')
         return (char)(ch + ((int)'a'-(int)'A'));
+      return ch;
     }
     
     //
     static inline char toUpper( char ch ){
       if(ch>='a' && ch<='z')
         return (char)(ch + ((int)'A'-(int)'a'));
+      return ch;
     }
     
     

File engine/source/MochaString.cpp

 
 namespace Mocha{
   
-  static const char _prefix_mask[] = { 0x80, 0xE0, 0xF0, 0xF8 };
-  static const char _prefix_value[] = { 0x00, 0xC0, 0xE0, 0xF0 };
-  static const char _content_mask[] = { 0x7F, 0x1F, 0x0F, 0x07 };
-  static const char _char_bytes[] = { 1, 2, 2, 3 };
+  static const U32 _prefix_mask[] = { 0x80, 0xE0, 0xF0, 0xF8 };
+  static const U32 _prefix_value[] = { 0x00, 0xC0, 0xE0, 0xF0 };
+  static const U32 _content_mask[] = { 0x7F, 0x1F, 0x0F, 0x07 };
+  static const U32 _char_bytes[] = { 1, 2, 2, 3 };
   
   static inline int _utf8char_class( const char* ch ){
     const char c = *ch;

File test/TestResource.cpp

     return 0;
   }
   
-  TextResource* resources[ argc-1 ];
+  TextResource** resources = new TextResource*[ argc-1 ];
   
   for(int i=1; i < argc; i++){
     resources[i-1] = new TextResource( i, std::string(argv[i]) );
     resources[i-1]->release();
   }
   
+  delete[] resources;
+
   return 0;
 }