bsd ready

This commit is contained in:
XXTH 2023-05-10 14:58:47 +02:00
parent 0d981b62cf
commit e0ab3830af
9 changed files with 120 additions and 93 deletions

View file

@ -58,7 +58,7 @@ NvRemoveTjunctions.cpp : A code snippet to remove tjunctions from a triangle mes
#pragma warning(disable:4702) #pragma warning(disable:4702)
#pragma warning(disable:4127) //conditional expression is constant (because _HAS_EXCEPTIONS=0) #pragma warning(disable:4127) //conditional expression is constant (because _HAS_EXCEPTIONS=0)
#include <vector> #include <vector>
#ifdef __APPLE__ #if defined( __APPLE__ ) || defined( __FreeBSD__)
#include <ext/hash_map> #include <ext/hash_map>
#elif LINUX #elif LINUX
#include <hash_map> #include <hash_map>

View file

@ -57,11 +57,16 @@ NvSimpleTypes.h : Defines basic data types for integers and floats.
*/ */
#ifdef __APPLE__ #ifdef __APPLE__
#include <sys/malloc.h> #include <sys/malloc.h>
#else #else
#if defined( __FreeBSD__)
#include <stdlib.h>
#else
#include <malloc.h> #include <malloc.h>
#endif #endif
#endif
#include <assert.h> #include <assert.h>
#if defined(__APPLE__) || defined(__CELLOS_LV2__) || defined(LINUX) #if defined(__APPLE__) || defined(__CELLOS_LV2__) || defined(LINUX)
@ -87,7 +92,7 @@ NvSimpleTypes.h : Defines basic data types for integers and floats.
typedef float NxF32; typedef float NxF32;
typedef double NxF64; typedef double NxF64;
#elif defined(LINUX) #elif LINUX
typedef long long NxI64; typedef long long NxI64;
typedef signed int NxI32; typedef signed int NxI32;
typedef signed short NxI16; typedef signed short NxI16;
@ -101,7 +106,7 @@ NvSimpleTypes.h : Defines basic data types for integers and floats.
typedef float NxF32; typedef float NxF32;
typedef double NxF64; typedef double NxF64;
#elif defined(__APPLE__) #elif __APPLE__
typedef long long NxI64; typedef long long NxI64;
typedef signed int NxI32; typedef signed int NxI32;
typedef signed short NxI16; typedef signed short NxI16;
@ -115,7 +120,7 @@ NvSimpleTypes.h : Defines basic data types for integers and floats.
typedef float NxF32; typedef float NxF32;
typedef double NxF64; typedef double NxF64;
#elif defined(__CELLOS_LV2__) #elif __CELLOS_LV2__
typedef long long NxI64; typedef long long NxI64;
typedef signed int NxI32; typedef signed int NxI32;
typedef signed short NxI16; typedef signed short NxI16;
@ -129,7 +134,7 @@ NvSimpleTypes.h : Defines basic data types for integers and floats.
typedef float NxF32; typedef float NxF32;
typedef double NxF64; typedef double NxF64;
#elif defined(_XBOX) #elif _XBOX
typedef __int64 NxI64; typedef __int64 NxI64;
typedef signed int NxI32; typedef signed int NxI32;
typedef signed short NxI16; typedef signed short NxI16;

View file

@ -2656,7 +2656,7 @@ static NxI32 overhull(Plane *planes,NxI32 planes_count,float3 *verts, NxI32 vert
float3 *&verts_out, NxI32 &verts_count_out, NxI32 *&faces_out, NxI32 &faces_count_out ,NxF32 inflate) float3 *&verts_out, NxI32 &verts_count_out, NxI32 *&faces_out, NxI32 &faces_count_out ,NxF32 inflate)
{ {
NxI32 i,j; NxI32 i,j;
if(verts_count <4) return NULL; if (verts_count < 4) return 0; //XXTH NULL;
maxplanes = Min(maxplanes,planes_count); maxplanes = Min(maxplanes,planes_count);
float3 bmin(verts[0]),bmax(verts[0]); float3 bmin(verts[0]),bmax(verts[0]);
for(i=0;i<verts_count;i++) for(i=0;i<verts_count;i++)

View file

@ -71,7 +71,7 @@ NvThreadConfig.cpp : A simple wrapper class to define threading and mutex locks.
#include <xtl.h> #include <xtl.h>
#endif #endif
#if defined(__linux__) || defined( __APPLE__ ) #if defined(__linux__) || defined( __APPLE__ ) || defined( __FreeBSD__)
//#include <sys/time.h> //#include <sys/time.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
@ -79,15 +79,18 @@ NvThreadConfig.cpp : A simple wrapper class to define threading and mutex locks.
#define __stdcall #define __stdcall
#endif #endif
#if defined( __APPLE__ ) #if defined( __APPLE__ ) || defined( __FreeBSD__)
#include <sys/time.h> #include <sys/time.h>
#endif #endif
#if defined(__APPLE__) || defined(__linux__) #if defined(__APPLE__) || defined(__linux__) || defined( __FreeBSD__)
#include <pthread.h> #include <pthread.h>
#endif #endif
#if defined( __APPLE__ ) #if defined( __APPLE__ ) || defined( __FreeBSD__)
#define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
#endif #endif
@ -107,7 +110,8 @@ NxU32 tc_timeGetTime(void)
struct timespec ts; struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts); clock_gettime(CLOCK_REALTIME, &ts);
return ts.tv_sec * 1000 + ts.tv_nsec / 1000000; return ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
#elif defined( __APPLE__ ) #elif defined( __APPLE__ ) || defined( __FreeBSD__)
struct timeval tp; struct timeval tp;
gettimeofday(&tp, (struct timezone *)0); gettimeofday(&tp, (struct timezone *)0);
return tp.tv_sec * 1000 + tp.tv_usec / 1000; return tp.tv_sec * 1000 + tp.tv_usec / 1000;
@ -120,7 +124,7 @@ NxU32 tc_timeGetTime(void)
void tc_sleep(NxU32 ms) void tc_sleep(NxU32 ms)
{ {
#if defined(__linux__) || defined( __APPLE__ ) #if defined(__linux__) || defined( __APPLE__ ) || defined( __FreeBSD__)
usleep(ms * 1000); usleep(ms * 1000);
#else #else
Sleep(ms); Sleep(ms);
@ -129,26 +133,22 @@ void tc_sleep(NxU32 ms)
void tc_spinloop() void tc_spinloop()
{ {
#if defined( _XBOX ) #if defined(__linux__) || defined( __APPLE__ ) || defined( __FreeBSD__)
// Pause would do nothing on the Xbox. Threads are not scheduled.
#elif defined( _WIN64 ) asm ( "pause" );
YieldProcessor( ); #elif defined( _XBOX )
#elif defined( __APPLE__ ) // Pause would do nothing on the Xbox. Threads are not scheduled.
pthread_yield_np(); #elif defined( _WIN64 )
#elif defined(__linux__) YieldProcessor( );
#if defined(_POSIX_PRIORITY_SCHEDULING)
sched_yield();
#else #else
asm("pause"); __asm { pause };
#endif #endif
#elif
__asm { pause };
#endif
} }
void tc_interlockedExchange(void *dest, const int64_t exchange) void tc_interlockedExchange(void *dest, const int64_t exchange)
{ {
#if defined( __linux__ ) || defined( __APPLE__ ) #if defined( __linux__ ) || defined( __APPLE__ ) || defined( __FreeBSD__)
// not working // not working
assert(false); assert(false);
//__sync_lock_test_and_set((int64_t*)dest, exchange); //__sync_lock_test_and_set((int64_t*)dest, exchange);
@ -174,7 +174,8 @@ void tc_interlockedExchange(void *dest, const int64_t exchange)
NxI32 tc_interlockedCompareExchange(void *dest, NxI32 exchange, NxI32 compare) NxI32 tc_interlockedCompareExchange(void *dest, NxI32 exchange, NxI32 compare)
{ {
#if defined( __linux__ ) || defined( __APPLE__ ) #if defined( __linux__ ) || defined( __APPLE__ ) || defined( __FreeBSD__)
// not working // not working
assert(false); assert(false);
return 0; return 0;
@ -203,7 +204,7 @@ NxI32 tc_interlockedCompareExchange(void *dest, NxI32 exchange, NxI32 compare)
NxI32 tc_interlockedCompareExchange(void *dest, const NxI32 exchange1, const NxI32 exchange2, const NxI32 compare1, const NxI32 compare2) NxI32 tc_interlockedCompareExchange(void *dest, const NxI32 exchange1, const NxI32 exchange2, const NxI32 compare1, const NxI32 compare2)
{ {
#if defined( __linux__ ) || defined( __APPLE__ ) #if defined( __linux__ ) || defined( __APPLE__ ) || defined( __FreeBSD__)
// not working // not working
assert(false); assert(false);
return 0; return 0;
@ -239,7 +240,8 @@ public:
{ {
#if defined(WIN32) || defined(_XBOX) #if defined(WIN32) || defined(_XBOX)
InitializeCriticalSection(&m_Mutex); InitializeCriticalSection(&m_Mutex);
#elif defined(__APPLE__) || defined(__linux__) #elif defined(__APPLE__) || defined(__linux__) || defined( __FreeBSD__)
pthread_mutexattr_t mutexAttr; // Mutex Attribute pthread_mutexattr_t mutexAttr; // Mutex Attribute
VERIFY( pthread_mutexattr_init(&mutexAttr) == 0 ); VERIFY( pthread_mutexattr_init(&mutexAttr) == 0 );
VERIFY( pthread_mutexattr_settype(&mutexAttr, PTHREAD_MUTEX_RECURSIVE_NP) == 0 ); VERIFY( pthread_mutexattr_settype(&mutexAttr, PTHREAD_MUTEX_RECURSIVE_NP) == 0 );
@ -252,7 +254,8 @@ public:
{ {
#if defined(WIN32) || defined(_XBOX) #if defined(WIN32) || defined(_XBOX)
DeleteCriticalSection(&m_Mutex); DeleteCriticalSection(&m_Mutex);
#elif defined(__APPLE__) || defined(__linux__) #elif defined(__APPLE__) || defined(__linux__) || defined( __FreeBSD__)
VERIFY( pthread_mutex_destroy(&m_Mutex) == 0 ); VERIFY( pthread_mutex_destroy(&m_Mutex) == 0 );
#endif #endif
} }
@ -261,7 +264,8 @@ public:
{ {
#if defined(WIN32) || defined(_XBOX) #if defined(WIN32) || defined(_XBOX)
EnterCriticalSection(&m_Mutex); EnterCriticalSection(&m_Mutex);
#elif defined(__APPLE__) || defined(__linux__) #elif defined(__APPLE__) || defined(__linux__) || defined( __FreeBSD__)
VERIFY( pthread_mutex_lock(&m_Mutex) == 0 ); VERIFY( pthread_mutex_lock(&m_Mutex) == 0 );
#endif #endif
} }
@ -273,7 +277,8 @@ public:
//assert(("TryEnterCriticalSection seems to not work on XP???", 0)); //assert(("TryEnterCriticalSection seems to not work on XP???", 0));
bRet = TryEnterCriticalSection(&m_Mutex) ? true : false; bRet = TryEnterCriticalSection(&m_Mutex) ? true : false;
return bRet; return bRet;
#elif defined(__APPLE__) || defined(__linux__) #elif defined(__APPLE__) || defined(__linux__) || defined( __FreeBSD__)
NxI32 result = pthread_mutex_trylock(&m_Mutex); NxI32 result = pthread_mutex_trylock(&m_Mutex);
return (result == 0); return (result == 0);
#endif #endif
@ -283,7 +288,8 @@ public:
{ {
#if defined(WIN32) || defined(_XBOX) #if defined(WIN32) || defined(_XBOX)
LeaveCriticalSection(&m_Mutex); LeaveCriticalSection(&m_Mutex);
#elif defined(__APPLE__) || defined(__linux__) #elif defined(__APPLE__) || defined(__linux__) || defined( __FreeBSD__)
VERIFY( pthread_mutex_unlock(&m_Mutex) == 0 ); VERIFY( pthread_mutex_unlock(&m_Mutex) == 0 );
#endif #endif
} }
@ -291,7 +297,8 @@ public:
private: private:
#if defined(WIN32) || defined(_XBOX) #if defined(WIN32) || defined(_XBOX)
CRITICAL_SECTION m_Mutex; CRITICAL_SECTION m_Mutex;
#elif defined(__APPLE__) || defined(__linux__) #elif defined(__APPLE__) || defined(__linux__) || defined( __FreeBSD__)
pthread_mutex_t m_Mutex; pthread_mutex_t m_Mutex;
#endif #endif
}; };
@ -310,7 +317,8 @@ void tc_releaseThreadMutex(ThreadMutex *tm)
#if defined(WIN32) || defined(_XBOX) #if defined(WIN32) || defined(_XBOX)
static unsigned long __stdcall _ThreadWorkerFunc(LPVOID arg); static unsigned long __stdcall _ThreadWorkerFunc(LPVOID arg);
#elif defined(__APPLE__) || defined(__linux__) #elif defined(__APPLE__) || defined(__linux__) || defined( __FreeBSD__)
static void* _ThreadWorkerFunc(void* arg); static void* _ThreadWorkerFunc(void* arg);
#endif #endif
@ -322,7 +330,8 @@ public:
mInterface = iface; mInterface = iface;
#if defined(WIN32) || defined(_XBOX) #if defined(WIN32) || defined(_XBOX)
mThread = CreateThread(0, 0, _ThreadWorkerFunc, this, 0, 0); mThread = CreateThread(0, 0, _ThreadWorkerFunc, this, 0, 0);
#elif defined(__APPLE__) || defined(__linux__) #elif defined(__APPLE__) || defined(__linux__) || defined( __FreeBSD__)
VERIFY( pthread_create(&mThread, NULL, _ThreadWorkerFunc, this) == 0 ); VERIFY( pthread_create(&mThread, NULL, _ThreadWorkerFunc, this) == 0 );
#endif #endif
} }
@ -347,7 +356,8 @@ private:
ThreadInterface *mInterface; ThreadInterface *mInterface;
#if defined(WIN32) || defined(_XBOX) #if defined(WIN32) || defined(_XBOX)
HANDLE mThread; HANDLE mThread;
#elif defined(__APPLE__) || defined(__linux__) #elif defined(__APPLE__) || defined(__linux__) || defined( __FreeBSD__)
pthread_t mThread; pthread_t mThread;
#endif #endif
}; };
@ -367,7 +377,8 @@ void tc_releaseThread(Thread *t)
#if defined(WIN32) || defined(_XBOX) #if defined(WIN32) || defined(_XBOX)
static unsigned long __stdcall _ThreadWorkerFunc(LPVOID arg) static unsigned long __stdcall _ThreadWorkerFunc(LPVOID arg)
#elif defined(__APPLE__) || defined(__linux__) #elif defined(__APPLE__) || defined(__linux__) || defined( __FreeBSD__)
static void* _ThreadWorkerFunc(void* arg) static void* _ThreadWorkerFunc(void* arg)
#endif #endif
{ {
@ -384,7 +395,8 @@ public:
{ {
#if defined(WIN32) || defined(_XBOX) #if defined(WIN32) || defined(_XBOX)
mEvent = ::CreateEventA(NULL,TRUE,TRUE,"ThreadEvent"); mEvent = ::CreateEventA(NULL,TRUE,TRUE,"ThreadEvent");
#elif defined(__APPLE__) || defined(__linux__) #elif defined(__APPLE__) || defined(__linux__) || defined( __FreeBSD__)
pthread_mutexattr_t mutexAttr; // Mutex Attribute pthread_mutexattr_t mutexAttr; // Mutex Attribute
VERIFY( pthread_mutexattr_init(&mutexAttr) == 0 ); VERIFY( pthread_mutexattr_init(&mutexAttr) == 0 );
VERIFY( pthread_mutexattr_settype(&mutexAttr, PTHREAD_MUTEX_RECURSIVE_NP) == 0 ); VERIFY( pthread_mutexattr_settype(&mutexAttr, PTHREAD_MUTEX_RECURSIVE_NP) == 0 );
@ -401,7 +413,8 @@ public:
{ {
::CloseHandle(mEvent); ::CloseHandle(mEvent);
} }
#elif defined(__APPLE__) || defined(__linux__) #elif defined(__APPLE__) || defined(__linux__) || defined( __FreeBSD__)
VERIFY( pthread_cond_destroy(&mEvent) == 0 ); VERIFY( pthread_cond_destroy(&mEvent) == 0 );
VERIFY( pthread_mutex_destroy(&mEventMutex) == 0 ); VERIFY( pthread_mutex_destroy(&mEventMutex) == 0 );
#endif #endif
@ -414,7 +427,8 @@ public:
{ {
::SetEvent(mEvent); ::SetEvent(mEvent);
} }
#elif defined(__APPLE__) || defined(__linux__) #elif defined(__APPLE__) || defined(__linux__) || defined( __FreeBSD__)
VERIFY( pthread_mutex_lock(&mEventMutex) == 0 ); VERIFY( pthread_mutex_lock(&mEventMutex) == 0 );
VERIFY( pthread_cond_signal(&mEvent) == 0 ); VERIFY( pthread_cond_signal(&mEvent) == 0 );
VERIFY( pthread_mutex_unlock(&mEventMutex) == 0 ); VERIFY( pthread_mutex_unlock(&mEventMutex) == 0 );
@ -438,7 +452,8 @@ public:
{ {
::WaitForSingleObject(mEvent,ms); ::WaitForSingleObject(mEvent,ms);
} }
#elif defined(__APPLE__) || defined(__linux__) #elif defined(__APPLE__) || defined(__linux__) || defined( __FreeBSD__)
VERIFY( pthread_mutex_lock(&mEventMutex) == 0 ); VERIFY( pthread_mutex_lock(&mEventMutex) == 0 );
if (ms == 0xffffffff) if (ms == 0xffffffff)
{ {
@ -468,7 +483,8 @@ public:
private: private:
#if defined(WIN32) || defined(_XBOX) #if defined(WIN32) || defined(_XBOX)
HANDLE mEvent; HANDLE mEvent;
#elif defined(__APPLE__) || defined(__linux__) #elif defined(__APPLE__) || defined(__linux__) || defined( __FreeBSD__)
pthread_mutex_t mEventMutex; pthread_mutex_t mEventMutex;
pthread_cond_t mEvent; pthread_cond_t mEvent;
#endif #endif

View file

@ -43,7 +43,7 @@
#include <iosfwd> // for ostream forward-declaration #include <iosfwd> // for ostream forward-declaration
// Don't use bits/type_traits.h on Linux - Andrew Galante, GG 8/2/2009 // Don't use bits/type_traits.h on Linux - Andrew Galante, GG 8/2/2009
#if !defined(_MSC_VER) && !defined(__CELLOS_LV2__) && !defined(__APPLE__) && !defined(__linux__) #if !defined(_MSC_VER) && !defined(__CELLOS_LV2__) && !defined(__APPLE__) && !defined(__linux__) && !defined( __FreeBSD__)
#ifdef __MINGW32__ #ifdef __MINGW32__
#define HAVE_TYPE_TRAITS #define HAVE_TYPE_TRAITS
#include <bits/type_traits.h> #include <bits/type_traits.h>

View file

@ -56,8 +56,8 @@ GFXGLTextureObject::GFXGLTextureObject(GFXDevice * aDevice, GFXTextureProfile *p
glGenBuffers(1, &mBuffer); glGenBuffers(1, &mBuffer);
} }
GFXGLTextureObject::~GFXGLTextureObject() GFXGLTextureObject::~GFXGLTextureObject()
{ {
glDeleteTextures(1, &mHandle); glDeleteTextures(1, &mHandle);
glDeleteBuffers(1, &mBuffer); glDeleteBuffers(1, &mBuffer);
delete[] mZombieCache; delete[] mZombieCache;
@ -81,7 +81,7 @@ GFXLockedRect* GFXGLTextureObject::lock(U32 mipLevel, RectI *inRect)
{ {
mLockedRectRect = RectI(0, 0, width, height); mLockedRectRect = RectI(0, 0, width, height);
} }
mLockedRect.pitch = mLockedRectRect.extent.x * mBytesPerTexel; mLockedRect.pitch = mLockedRectRect.extent.x * mBytesPerTexel;
// CodeReview [ags 12/19/07] This one texel boundary is necessary to keep the clipmap code from crashing. Figure out why. // CodeReview [ags 12/19/07] This one texel boundary is necessary to keep the clipmap code from crashing. Figure out why.
@ -93,7 +93,7 @@ GFXLockedRect* GFXGLTextureObject::lock(U32 mipLevel, RectI *inRect)
#ifdef TORQUE_DEBUG #ifdef TORQUE_DEBUG
mFrameAllocatorMarkGuard = FrameAllocator::getWaterMark(); mFrameAllocatorMarkGuard = FrameAllocator::getWaterMark();
#endif #endif
if( !mLockedRect.bits ) if( !mLockedRect.bits )
return NULL; return NULL;
@ -117,12 +117,12 @@ void GFXGLTextureObject::unlock(U32 mipLevel)
glTexSubImage3D(mBinding, mipLevel, mLockedRectRect.point.x, mLockedRectRect.point.y, z, glTexSubImage3D(mBinding, mipLevel, mLockedRectRect.point.x, mLockedRectRect.point.y, z,
mLockedRectRect.extent.x, mLockedRectRect.extent.y, z, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], NULL); mLockedRectRect.extent.x, mLockedRectRect.extent.y, z, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], NULL);
else if(mBinding == GL_TEXTURE_2D) else if(mBinding == GL_TEXTURE_2D)
glTexSubImage2D(mBinding, mipLevel, mLockedRectRect.point.x, mLockedRectRect.point.y, glTexSubImage2D(mBinding, mipLevel, mLockedRectRect.point.x, mLockedRectRect.point.y,
mLockedRectRect.extent.x, mLockedRectRect.extent.y, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], NULL); mLockedRectRect.extent.x, mLockedRectRect.extent.y, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], NULL);
else if(mBinding == GL_TEXTURE_1D) else if(mBinding == GL_TEXTURE_1D)
glTexSubImage1D(mBinding, mipLevel, (mLockedRectRect.point.x > 1 ? mLockedRectRect.point.x : mLockedRectRect.point.y), glTexSubImage1D(mBinding, mipLevel, (mLockedRectRect.point.x > 1 ? mLockedRectRect.point.x : mLockedRectRect.point.y),
(mLockedRectRect.extent.x > 1 ? mLockedRectRect.extent.x : mLockedRectRect.extent.y), GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], NULL); (mLockedRectRect.extent.x > 1 ? mLockedRectRect.extent.x : mLockedRectRect.extent.y), GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], NULL);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
mLockedRect.bits = NULL; mLockedRect.bits = NULL;
@ -138,7 +138,7 @@ void GFXGLTextureObject::release()
{ {
glDeleteTextures(1, &mHandle); glDeleteTextures(1, &mHandle);
glDeleteBuffers(1, &mBuffer); glDeleteBuffers(1, &mBuffer);
mHandle = 0; mHandle = 0;
mBuffer = 0; mBuffer = 0;
} }
@ -174,7 +174,7 @@ bool GFXGLTextureObject::copyToBmp(GBitmap * bmp)
U8 srcBytesPerPixel = GFXFormat_getByteSize( mFormat ); U8 srcBytesPerPixel = GFXFormat_getByteSize( mFormat );
FrameAllocatorMarker mem; FrameAllocatorMarker mem;
U32 mipLevels = getMipLevels(); U32 mipLevels = getMipLevels();
for (U32 mip = 0; mip < mipLevels; mip++) for (U32 mip = 0; mip < mipLevels; mip++)
@ -204,7 +204,8 @@ bool GFXGLTextureObject::copyToBmp(GBitmap * bmp)
} }
} }
} }
glBindTexture(mBinding, NULL); //XXTH orig: glBindTexture(mBinding, NULL);
glBindTexture(mBinding, 0);
return true; return true;
} }
@ -236,8 +237,8 @@ U8* GFXGLTextureObject::getTextureData( U32 mip )
AssertFatal( mMipLevels, ""); AssertFatal( mMipLevels, "");
mip = (mip < mMipLevels) ? mip : 0; mip = (mip < mMipLevels) ? mip : 0;
const U32 dataSize = ImageUtil::isCompressedFormat(mFormat) const U32 dataSize = ImageUtil::isCompressedFormat(mFormat)
? getCompressedSurfaceSize( mFormat, mTextureSize.x, mTextureSize.y, mip ) ? getCompressedSurfaceSize( mFormat, mTextureSize.x, mTextureSize.y, mip )
: (mTextureSize.x >> mip) * (mTextureSize.y >> mip) * mBytesPerTexel; : (mTextureSize.x >> mip) * (mTextureSize.y >> mip) * mBytesPerTexel;
U8* data = new U8[dataSize]; U8* data = new U8[dataSize];
@ -258,10 +259,10 @@ void GFXGLTextureObject::copyIntoCache()
U32 cacheSize = mTextureSize.x * mTextureSize.y; U32 cacheSize = mTextureSize.x * mTextureSize.y;
if(mBinding == GL_TEXTURE_3D) if(mBinding == GL_TEXTURE_3D)
cacheSize *= mTextureSize.z; cacheSize *= mTextureSize.z;
cacheSize *= mBytesPerTexel; cacheSize *= mBytesPerTexel;
mZombieCache = new U8[cacheSize]; mZombieCache = new U8[cacheSize];
glGetTexImage(mBinding, 0, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], mZombieCache); glGetTexImage(mBinding, 0, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], mZombieCache);
} }
@ -269,7 +270,7 @@ void GFXGLTextureObject::reloadFromCache()
{ {
if(!mZombieCache) if(!mZombieCache)
return; return;
if(mBinding == GL_TEXTURE_3D) if(mBinding == GL_TEXTURE_3D)
{ {
static_cast<GFXGLTextureManager*>(TEXMGR)->_loadTexture(this, mZombieCache); static_cast<GFXGLTextureManager*>(TEXMGR)->_loadTexture(this, mZombieCache);
@ -277,7 +278,7 @@ void GFXGLTextureObject::reloadFromCache()
mZombieCache = NULL; mZombieCache = NULL;
return; return;
} }
PRESERVE_TEXTURE(mBinding); PRESERVE_TEXTURE(mBinding);
glBindTexture(mBinding, mHandle); glBindTexture(mBinding, mHandle);
@ -285,10 +286,10 @@ void GFXGLTextureObject::reloadFromCache()
glTexSubImage2D(mBinding, 0, 0, 0, mTextureSize.x, mTextureSize.y, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], mZombieCache); glTexSubImage2D(mBinding, 0, 0, 0, mTextureSize.x, mTextureSize.y, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], mZombieCache);
else if(mBinding == GL_TEXTURE_1D) else if(mBinding == GL_TEXTURE_1D)
glTexSubImage1D(mBinding, 0, 0, (mTextureSize.x > 1 ? mTextureSize.x : mTextureSize.y), GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], mZombieCache); glTexSubImage1D(mBinding, 0, 0, (mTextureSize.x > 1 ? mTextureSize.x : mTextureSize.y), GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], mZombieCache);
if(mMipLevels != 1) if(mMipLevels != 1)
glGenerateMipmap(mBinding); glGenerateMipmap(mBinding);
delete[] mZombieCache; delete[] mZombieCache;
mZombieCache = NULL; mZombieCache = NULL;
mIsZombie = false; mIsZombie = false;
@ -298,11 +299,11 @@ void GFXGLTextureObject::zombify()
{ {
if(mIsZombie) if(mIsZombie)
return; return;
mIsZombie = true; mIsZombie = true;
if(!mProfile->doStoreBitmap() && !mProfile->isRenderTarget() && !mProfile->isDynamic() && !mProfile->isZTarget()) if(!mProfile->doStoreBitmap() && !mProfile->isRenderTarget() && !mProfile->isDynamic() && !mProfile->isZTarget())
copyIntoCache(); copyIntoCache();
release(); release();
} }
@ -310,7 +311,7 @@ void GFXGLTextureObject::resurrect()
{ {
if(!mIsZombie) if(!mIsZombie)
return; return;
glGenTextures(1, &mHandle); glGenTextures(1, &mHandle);
glGenBuffers(1, &mBuffer); glGenBuffers(1, &mBuffer);
} }
@ -329,6 +330,6 @@ const String GFXGLTextureObject::describeSelf() const
{ {
String ret = Parent::describeSelf(); String ret = Parent::describeSelf();
ret += String::ToString(" GL Handle: %i", mHandle); ret += String::ToString(" GL Handle: %i", mHandle);
return ret; return ret;
} }

View file

@ -33,7 +33,7 @@ bool PopupMenu::smSelectionEventHandled = false;
/// Event class used to remove popup menus from the event notification in a safe way /// Event class used to remove popup menus from the event notification in a safe way
class PopUpNotifyRemoveEvent : public SimEvent class PopUpNotifyRemoveEvent : public SimEvent
{ {
public: public:
void process(SimObject *object) void process(SimObject *object)
{ {
@ -46,7 +46,8 @@ public:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
PopupMenu::PopupMenu() PopupMenu::PopupMenu()
{ {
mMenuItems = NULL; //XXTH orig mMenuItems = NULL;
mMenuItems = 0;
mMenuBarCtrl = nullptr; mMenuBarCtrl = nullptr;
mBarTitle = StringTable->EmptyString(); mBarTitle = StringTable->EmptyString();
@ -115,7 +116,7 @@ void PopupMenu::onMenuSelect()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void PopupMenu::handleSelectEvent(U32 popID, U32 command) void PopupMenu::handleSelectEvent(U32 popID, U32 command)
{ {
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -199,7 +200,7 @@ bool PopupMenu::setItem(S32 pos, const char *title, const char* accelerator, con
{ {
mMenuItems[i].mID = pos; mMenuItems[i].mID = pos;
mMenuItems[i].mCMD = cmd; mMenuItems[i].mCMD = cmd;
if (accelerator && accelerator[0]) if (accelerator && accelerator[0])
mMenuItems[i].mAccelerator = dStrdup(accelerator); mMenuItems[i].mAccelerator = dStrdup(accelerator);
else else
@ -207,7 +208,7 @@ bool PopupMenu::setItem(S32 pos, const char *title, const char* accelerator, con
return true; return true;
} }
} }
return false; return false;
} }

View file

@ -20,7 +20,8 @@
// IN THE SOFTWARE. // IN THE SOFTWARE.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifndef __APPLE__ //XXTH orig #ifndef __APPLE__
#if not defined (__APPLE__) //and not defined (__FreeBSD__)
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
@ -40,12 +41,15 @@ Platform::SystemInfo_struct Platform::SystemInfo;
static inline void rtrim(std::string &s) static inline void rtrim(std::string &s)
{ {
s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end()); //XXTH deprecated! s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
//FIXME !!!! s.erase(std::find_if(s.rbegin(), s.rend(), static_cast<int(*)(int)>(std::isspace).base(), s.end());
} }
static inline void ltrim(std::string &s) static inline void ltrim(std::string &s)
{ {
s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace)))); //XXTH deprecated! s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
//using lambada
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int c) {return !std::isspace(c);}));
} }
static void getCPUInformation() static void getCPUInformation()
@ -183,7 +187,7 @@ static void getCPUInformation()
SetProcessorInfo(Platform::SystemInfo.processor, vendorString.c_str(), brandString.c_str()); SetProcessorInfo(Platform::SystemInfo.processor, vendorString.c_str(), brandString.c_str());
} }
void Processor::init() void Processor::init()
{ {
getCPUInformation(); getCPUInformation();
@ -244,11 +248,11 @@ namespace CPUInfo
} }
else if (!Platform::SystemInfo.processor.isHyperThreaded && Platform::SystemInfo.processor.numPhysicalProcessors == 1) else if (!Platform::SystemInfo.processor.isHyperThreaded && Platform::SystemInfo.processor.numPhysicalProcessors == 1)
{ {
return CONFIG_SingleCoreAndHTNotCapable; return CONFIG_SingleCoreAndHTNotCapable;
} }
return CONFIG_MultiCoreAndHTEnabled; return CONFIG_MultiCoreAndHTEnabled;
} }
}; // namespace CPUInfo }; // namespace CPUInfo
#endif #endif

View file

@ -65,7 +65,7 @@ class TSCallback
{ {
public: public:
virtual ~TSCallback() {} virtual ~TSCallback() {}
virtual void setNodeTransform(TSShapeInstance * si, S32 nodeIndex, MatrixF & localTransform) = 0; virtual void setNodeTransform(TSShapeInstance * si, S32 nodeIndex, MatrixF & localTransform) = 0;
}; };
@ -114,13 +114,13 @@ class TSShapeInstance
struct ObjectInstance struct ObjectInstance
{ {
virtual ~ObjectInstance() {} virtual ~ObjectInstance() {}
/// this needs to be set before using an objectInstance...tells us where to /// this needs to be set before using an objectInstance...tells us where to
/// look for the transforms...gets set be shape instance 'setStatics' method /// look for the transforms...gets set be shape instance 'setStatics' method
const Vector<MatrixF> *mTransforms; const Vector<MatrixF> *mTransforms;
S32 nodeIndex; S32 nodeIndex;
/// Gets the transform of this object /// Gets the transform of this object
inline const MatrixF& getTransform() const inline const MatrixF& getTransform() const
{ {
@ -166,8 +166,8 @@ class TSShapeInstance
/// If true this mesh is forced to be hidden /// If true this mesh is forced to be hidden
/// regardless of the animation state. /// regardless of the animation state.
bool forceHidden; bool forceHidden;
/// The time at which this mesh /// The time at which this mesh
/// was last rendered. /// was last rendered.
U32 mLastTime; U32 mLastTime;
@ -248,7 +248,7 @@ class TSShapeInstance
static Vector<TSThread*> smTranslationThreads; static Vector<TSThread*> smTranslationThreads;
static Vector<TSThread*> smScaleThreads; static Vector<TSThread*> smScaleThreads;
/// @} /// @}
TSMaterialList* mMaterialList; ///< by default, points to hShape material list TSMaterialList* mMaterialList; ///< by default, points to hShape material list
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
// Misc. // Misc.
@ -333,17 +333,17 @@ protected:
TSShape* getShape() const { return mShape; } TSShape* getShape() const { return mShape; }
TSMaterialList* getMaterialList() const { return mMaterialList; } TSMaterialList* getMaterialList() const { return mMaterialList; }
/// Set the material list without taking ownership. /// Set the material list without taking ownership.
/// @see cloneMaterialList /// @see cloneMaterialList
void setMaterialList( TSMaterialList *matList ); void setMaterialList( TSMaterialList *matList );
/// Call this to own the material list -- i.e., we'll make a copy of the /// Call this to own the material list -- i.e., we'll make a copy of the
/// currently set material list and be responsible for deleting it. You /// currently set material list and be responsible for deleting it. You
/// can pass an optional feature set for initializing the cloned materials. /// can pass an optional feature set for initializing the cloned materials.
void cloneMaterialList( const FeatureSet *features = NULL ); void cloneMaterialList( const FeatureSet *features = NULL );
/// Initializes or re-initializes the material list with /// Initializes or re-initializes the material list with
/// an optional feature set. /// an optional feature set.
void initMaterialList( const FeatureSet *features = NULL ); void initMaterialList( const FeatureSet *features = NULL );
@ -469,7 +469,7 @@ protected:
static F32 smDetailAdjust; static F32 smDetailAdjust;
/// If this is set to a positive pixel value shapes /// If this is set to a positive pixel value shapes
/// with a smaller pixel size than this will skip /// with a smaller pixel size than this will skip
/// rendering entirely. /// rendering entirely.
static F32 smSmallestVisiblePixelSize; static F32 smSmallestVisiblePixelSize;
@ -490,7 +490,7 @@ protected:
void renderDebugNormals( F32 normalScalar, S32 dl ); void renderDebugNormals( F32 normalScalar, S32 dl );
/// Render all node transforms as small axis gizmos. It is recommended /// Render all node transforms as small axis gizmos. It is recommended
/// that prior to calling this, shapeInstance::animate is called so that /// that prior to calling this, shapeInstance::animate is called so that
/// nodes are in object space and that the GFX state is setup for /// nodes are in object space and that the GFX state is setup for
/// rendering in model space. /// rendering in model space.
void renderDebugNodes(); void renderDebugNodes();
@ -518,7 +518,7 @@ protected:
/// Sets the 'forceHidden' state on the named mesh. /// Sets the 'forceHidden' state on the named mesh.
/// @see MeshObjectInstance::forceHidden /// @see MeshObjectInstance::forceHidden
void setMeshForceHidden( const char *meshName, bool hidden ); void setMeshForceHidden( const char *meshName, bool hidden );
/// Sets the 'forceHidden' state on a mesh. /// Sets the 'forceHidden' state on a mesh.
/// @see MeshObjectInstance::forceHidden /// @see MeshObjectInstance::forceHidden
void setMeshForceHidden( S32 meshIndex, bool hidden ); void setMeshForceHidden( S32 meshIndex, bool hidden );
@ -558,8 +558,8 @@ protected:
void setCurrentDetail( S32 dl, F32 intraDL = 1.0f ); void setCurrentDetail( S32 dl, F32 intraDL = 1.0f );
/// Helper function which internally calls setDetailFromDistance. /// Helper function which internally calls setDetailFromDistance.
S32 setDetailFromPosAndScale( const SceneRenderState *state, S32 setDetailFromPosAndScale( const SceneRenderState *state,
const Point3F &pos, const Point3F &pos,
const Point3F &scale ); const Point3F &scale );
/// Selects the current detail level using the scaled /// Selects the current detail level using the scaled
@ -788,7 +788,7 @@ class TSThread
keyPos = 0; keyPos = 0;
mSeqPos = 0; mSeqPos = 0;
mShapeInstance = NULL; mShapeInstance = NULL;
makePath = NULL; makePath = false; //XXTH NULL;
priority = 0; priority = 0;
sequence = 0; sequence = 0;
timeScale = 1.0f; timeScale = 1.0f;