From 6d6a042e00eaa74f2d34fe636a27beec2fa3c5d9 Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 24 Sep 2007 17:49:30 +0000 Subject: [PATCH] --- .../juce_linux_Threads.cpp | 4 +-- .../juce_mac_Threads.cpp | 4 +-- .../juce_mac_Windowing.cpp | 6 ++--- .../juce_win32_SystemStats.cpp | 10 ++++--- .../juce_win32_Threads.cpp | 4 +-- .../special/juce_OpenGLComponent.cpp | 26 +++++++++++++++++++ .../components/special/juce_OpenGLComponent.h | 12 +++++++-- src/juce_core/basics/juce_PlatformDefs.h | 9 ++++++- src/juce_core/basics/juce_StandardHeader.h | 7 ----- src/juce_core/io/files/juce_File.cpp | 10 ++++++- src/juce_core/io/streams/zlib/zlib.h | 4 +-- src/juce_core/io/streams/zlib/zutil.c | 4 +-- src/juce_core/threads/juce_Process.h | 2 +- 13 files changed, 73 insertions(+), 29 deletions(-) diff --git a/build/linux/platform_specific_code/juce_linux_Threads.cpp b/build/linux/platform_specific_code/juce_linux_Threads.cpp index d6925ef8db..e4c3bc9911 100644 --- a/build/linux/platform_specific_code/juce_linux_Threads.cpp +++ b/build/linux/platform_specific_code/juce_linux_Threads.cpp @@ -341,7 +341,7 @@ void Process::terminate() exit (0); } -bool juce_isRunningUnderDebugger() throw() +bool JUCE_CALLTYPE juce_isRunningUnderDebugger() throw() { static char testResult = 0; @@ -356,7 +356,7 @@ bool juce_isRunningUnderDebugger() throw() return testResult > 0; } -bool Process::isRunningUnderDebugger() throw() +bool JUCE_CALLTYPE Process::isRunningUnderDebugger() throw() { return juce_isRunningUnderDebugger(); } diff --git a/build/macosx/platform_specific_code/juce_mac_Threads.cpp b/build/macosx/platform_specific_code/juce_mac_Threads.cpp index 8395d5bd17..9a589372b0 100644 --- a/build/macosx/platform_specific_code/juce_mac_Threads.cpp +++ b/build/macosx/platform_specific_code/juce_mac_Threads.cpp @@ -225,7 +225,7 @@ void JUCE_CALLTYPE Thread::sleep (int millisecs) throw() //============================================================================== -bool juce_isRunningUnderDebugger() throw() +bool JUCE_CALLTYPE juce_isRunningUnderDebugger() throw() { static char testResult = 0; @@ -240,7 +240,7 @@ bool juce_isRunningUnderDebugger() throw() return testResult > 0; } -bool Process::isRunningUnderDebugger() throw() +bool JUCE_CALLTYPE Process::isRunningUnderDebugger() throw() { return juce_isRunningUnderDebugger(); } diff --git a/build/macosx/platform_specific_code/juce_mac_Windowing.cpp b/build/macosx/platform_specific_code/juce_mac_Windowing.cpp index a1511f9935..d54cbb6351 100644 --- a/build/macosx/platform_specific_code/juce_mac_Windowing.cpp +++ b/build/macosx/platform_specific_code/juce_mac_Windowing.cpp @@ -650,7 +650,7 @@ public: { ProcessSerialNumber psn; GetCurrentProcess (&psn); - SetFrontProcess (&psn); + SetFrontProcessWithOptions (&psn, kSetFrontProcessFrontWindowOnly); } if (IsValidWindowPtr (windowRef)) @@ -1231,7 +1231,7 @@ public: { ProcessSerialNumber psn; GetCurrentProcess (&psn); - SetFrontProcess (&psn); + SetFrontProcessWithOptions (&psn, kSetFrontProcessFrontWindowOnly); toFront (true); } @@ -3403,7 +3403,7 @@ public: bool setSwapInterval (const int numFramesPerSwap) { - return aglSetInteger (renderContext, AGL_SWAP_INTERVAL, &numFramesPerSwap); + return aglSetInteger (renderContext, AGL_SWAP_INTERVAL, (const GLint*) &numFramesPerSwap); } int getSwapInterval() const diff --git a/build/win32/platform_specific_code/juce_win32_SystemStats.cpp b/build/win32/platform_specific_code/juce_win32_SystemStats.cpp index cbc6d07c7a..39a050e905 100644 --- a/build/win32/platform_specific_code/juce_win32_SystemStats.cpp +++ b/build/win32/platform_specific_code/juce_win32_SystemStats.cpp @@ -89,8 +89,6 @@ void Logger::outputDebugPrintf (const tchar* format, ...) throw() static int64 hiResTicksPerSecond; static double hiResTicksScaleFactor; -static SYSTEM_INFO systemInfo; - //============================================================================== #if JUCE_USE_INTRINSICS @@ -276,8 +274,6 @@ void SystemStats::initialiseStats() throw() String s (SystemStats::getJUCEVersion()); - GetSystemInfo (&systemInfo); - #ifdef JUCE_DEBUG const MMRESULT res = timeBeginPeriod (1); jassert (res == TIMERR_NOERROR); @@ -362,6 +358,9 @@ int SystemStats::getMemorySizeInMegabytes() throw() int SystemStats::getNumCpus() throw() { + SYSTEM_INFO systemInfo; + GetSystemInfo (&systemInfo); + return systemInfo.dwNumberOfProcessors; } @@ -488,6 +487,9 @@ bool Time::setSystemTimeToThisTime() const throw() int SystemStats::getPageSize() throw() { + SYSTEM_INFO systemInfo; + GetSystemInfo (&systemInfo); + return systemInfo.dwPageSize; } diff --git a/build/win32/platform_specific_code/juce_win32_Threads.cpp b/build/win32/platform_specific_code/juce_win32_Threads.cpp index ef42aef8d4..51661c0f5a 100644 --- a/build/win32/platform_specific_code/juce_win32_Threads.cpp +++ b/build/win32/platform_specific_code/juce_win32_Threads.cpp @@ -299,12 +299,12 @@ void Process::setPriority (ProcessPriority prior) } } -bool juce_isRunningUnderDebugger() throw() +bool JUCE_CALLTYPE juce_isRunningUnderDebugger() throw() { return IsDebuggerPresent() != FALSE; } -bool Process::isRunningUnderDebugger() throw() +bool JUCE_CALLTYPE Process::isRunningUnderDebugger() throw() { return juce_isRunningUnderDebugger(); } diff --git a/src/juce_appframework/gui/components/special/juce_OpenGLComponent.cpp b/src/juce_appframework/gui/components/special/juce_OpenGLComponent.cpp index 90eede3adb..a9f7859323 100644 --- a/src/juce_appframework/gui/components/special/juce_OpenGLComponent.cpp +++ b/src/juce_appframework/gui/components/special/juce_OpenGLComponent.cpp @@ -68,6 +68,32 @@ bool OpenGLPixelFormat::operator== (const OpenGLPixelFormat& other) const throw( return memcmp (this, &other, sizeof (other)) == 0; } +//============================================================================== +static VoidArray knownContexts; + +OpenGLContext::OpenGLContext() throw() +{ + knownContexts.add (this); +} + +OpenGLContext::~OpenGLContext() +{ + knownContexts.removeValue (this); +} + +OpenGLContext* OpenGLContext::getCurrentContext() throw() +{ + for (int i = knownContexts.size(); --i >= 0;) + { + OpenGLContext* const oglc = (OpenGLContext*) knownContexts.getUnchecked(i); + + if (oglc->isActive()) + return oglc; + } + + return 0; +} + //============================================================================== class OpenGLComponentWatcher : public ComponentMovementWatcher diff --git a/src/juce_appframework/gui/components/special/juce_OpenGLComponent.h b/src/juce_appframework/gui/components/special/juce_OpenGLComponent.h index 23182fee93..3dcad7740a 100644 --- a/src/juce_appframework/gui/components/special/juce_OpenGLComponent.h +++ b/src/juce_appframework/gui/components/special/juce_OpenGLComponent.h @@ -101,7 +101,7 @@ class OpenGLContext public: //============================================================================== /** Destructor. */ - virtual ~OpenGLContext() {} + virtual ~OpenGLContext(); //============================================================================== /** Makes this context the currently active one. */ @@ -162,11 +162,19 @@ public: const OpenGLPixelFormat& pixelFormat, const OpenGLContext* const contextToShareWith); + + //============================================================================== + /** Returns the context that's currently in active use by the calling thread. + + Returns 0 if there isn't an active context. + */ + static OpenGLContext* getCurrentContext() throw(); + //============================================================================== juce_UseDebuggingNewOperator protected: - OpenGLContext() throw() {}; + OpenGLContext() throw(); }; diff --git a/src/juce_core/basics/juce_PlatformDefs.h b/src/juce_core/basics/juce_PlatformDefs.h index 795fac039a..e4f2ef9618 100644 --- a/src/juce_core/basics/juce_PlatformDefs.h +++ b/src/juce_core/basics/juce_PlatformDefs.h @@ -155,6 +155,13 @@ #error unknown compiler #endif +/** This macro defines the C calling convention used as the standard for Juce calls. */ +#if JUCE_MSVC + #define JUCE_CALLTYPE __stdcall +#else + #define JUCE_CALLTYPE +#endif + //============================================================================== // Debugging and assertion macros @@ -191,7 +198,7 @@ // Assertions.. BEGIN_JUCE_NAMESPACE - extern bool juce_isRunningUnderDebugger() throw(); + extern bool JUCE_CALLTYPE juce_isRunningUnderDebugger() throw(); END_JUCE_NAMESPACE #if JUCE_MSVC || DOXYGEN diff --git a/src/juce_core/basics/juce_StandardHeader.h b/src/juce_core/basics/juce_StandardHeader.h index deaa5e2b94..92006ddc85 100644 --- a/src/juce_core/basics/juce_StandardHeader.h +++ b/src/juce_core/basics/juce_StandardHeader.h @@ -118,13 +118,6 @@ #define JUCE_API #endif -/** This macro defines the C calling convention used as the standard for Juce calls. */ -#if JUCE_MSVC - #define JUCE_CALLTYPE __stdcall -#else - #define JUCE_CALLTYPE -#endif - /** This macro is added to all juce public function declarations. */ #define JUCE_PUBLIC_FUNCTION JUCE_API JUCE_CALLTYPE diff --git a/src/juce_core/io/files/juce_File.cpp b/src/juce_core/io/files/juce_File.cpp index 77a8d949b6..b8eedf3c99 100644 --- a/src/juce_core/io/files/juce_File.cpp +++ b/src/juce_core/io/files/juce_File.cpp @@ -1065,7 +1065,15 @@ const String File::getRelativePathFrom (const File& dir) const throw() while (commonBitLength > 0 && thisPath [commonBitLength - 1] != File::separator) --commonBitLength; - if (commonBitLength <= 0) + // if the only common bit is the root, then just return the full path.. +#if JUCE_WIN32 + if (commonBitLength <= 0 + || (commonBitLength == 1 && thisPath [1] == File::separator) + || (commonBitLength <= 3 && thisPath [1] == T(':'))) +#else + if (commonBitLength <= 0 + || (commonBitLength == 1 && thisPath [1] == File::separator)) +#endif return fullPath; thisPath = thisPath.substring (commonBitLength); diff --git a/src/juce_core/io/streams/zlib/zlib.h b/src/juce_core/io/streams/zlib/zlib.h index 62d0e4675b..6652a0178e 100644 --- a/src/juce_core/io/streams/zlib/zlib.h +++ b/src/juce_core/io/streams/zlib/zlib.h @@ -209,7 +209,7 @@ typedef gz_header FAR *gz_headerp; /* basic functions */ -ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +//ZEXTERN const char * ZEXPORT zlibVersion OF((void)); /* The application can compare zlibVersion and ZLIB_VERSION for consistency. If the first character differs, the library code actually used is not compatible with the zlib.h header file used by the application. @@ -954,7 +954,7 @@ ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); state was inconsistent. */ -ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); +//ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); /* Return flags indicating compile-time options. Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: diff --git a/src/juce_core/io/streams/zlib/zutil.c b/src/juce_core/io/streams/zlib/zutil.c index 1e80fcf144..7a27d1e492 100644 --- a/src/juce_core/io/streams/zlib/zutil.c +++ b/src/juce_core/io/streams/zlib/zutil.c @@ -24,7 +24,7 @@ const char * const z_errmsg[10] = { ""}; -const char * ZEXPORT zlibVersion() +/*const char * ZEXPORT zlibVersion() { return ZLIB_VERSION; } @@ -110,7 +110,7 @@ uLong ZEXPORT zlibCompileFlags() # endif #endif return flags; -} +}*/ #ifdef DEBUG diff --git a/src/juce_core/threads/juce_Process.h b/src/juce_core/threads/juce_Process.h index 66cac9823e..0b52eef848 100644 --- a/src/juce_core/threads/juce_Process.h +++ b/src/juce_core/threads/juce_Process.h @@ -96,7 +96,7 @@ public: //============================================================================== /** Returns true if this process is being hosted by a debugger. */ - static bool isRunningUnderDebugger() throw(); + static bool JUCE_CALLTYPE isRunningUnderDebugger() throw(); //============================================================================== /** Loads a dynamically-linked library into the process's address space.