Merge remote-tracking branch 'upstream/master'

Former-commit-id: 124b89e1c31a7b907f88d8c7a234473274d5a0f6
This commit is contained in:
Gawaboumga 2014-06-28 09:05:16 +02:00
commit 1aebcd83b0
14 changed files with 14 additions and 125 deletions

View File

@ -18,7 +18,7 @@ void NzMixToMono(T* input, T* output, unsigned int channelCount, unsigned int fr
for (unsigned int j = 0; j < channelCount; ++j)
acc += input[i*channelCount + j];
output[i] = acc/channelCount;
output[i] = static_cast<T>(acc/channelCount);
}
}

View File

@ -57,9 +57,6 @@ class NzVector2
operator T*();
operator const T*() const;
T& operator[](unsigned int i);
T operator[](unsigned int i) const;
const NzVector2& operator+() const;
NzVector2 operator-() const;

View File

@ -235,40 +235,6 @@ NzVector2<T>::operator const T*() const
return &x;
}
template<typename T>
T& NzVector2<T>::operator[](unsigned int i)
{
#if NAZARA_MATH_SAFE
if (i >= 2)
{
NzStringStream ss;
ss << "Index out of range: (" << i << " >= 2)";
NazaraError(ss);
throw std::domain_error(ss.ToString());
}
#endif
return *(&x+i);
}
template<typename T>
T NzVector2<T>::operator[](unsigned int i) const
{
#if NAZARA_MATH_SAFE
if (i >= 2)
{
NzStringStream ss;
ss << "Index out of range: (" << i << " >= 2)";
NazaraError(ss);
throw std::domain_error(ss.ToString());
}
#endif
return *(&x+i);
}
template<typename T>
const NzVector2<T>& NzVector2<T>::operator+() const
{

View File

@ -69,9 +69,6 @@ template<typename T> class NzVector3
operator T*();
operator const T*() const;
T& operator[](unsigned int i);
T operator[](unsigned int i) const;
const NzVector3& operator+() const;
NzVector3 operator-() const;

View File

@ -330,40 +330,6 @@ NzVector3<T>::operator const T*() const
return &x;
}
template<typename T>
T& NzVector3<T>::operator[](unsigned int i)
{
#if NAZARA_MATH_SAFE
if (i >= 3)
{
NzStringStream ss;
ss << "Index out of range: (" << i << " >= 3)";
NazaraError(ss);
throw std::out_of_range(ss.ToString());
}
#endif
return *(&x+i);
}
template<typename T>
T NzVector3<T>::operator[](unsigned int i) const
{
#if NAZARA_MATH_SAFE
if (i >= 3)
{
NzStringStream ss;
ss << "Index out of range: (" << i << " >= 3)";
NazaraError(ss);
throw std::out_of_range(ss.ToString());
}
#endif
return *(&x+i);
}
template<typename T>
const NzVector3<T>& NzVector3<T>::operator+() const
{

View File

@ -50,9 +50,6 @@ template<typename T> class NzVector4
operator T*();
operator const T*() const;
T& operator[](unsigned int i);
T operator[](unsigned int i) const;
const NzVector4& operator+() const;
NzVector4 operator-() const;

View File

@ -233,40 +233,6 @@ NzVector4<T>::operator const T*() const
return &x;
}
template<typename T>
T& NzVector4<T>::operator[](unsigned int i)
{
#if NAZARA_MATH_SAFE
if (i >= 4)
{
NzStringStream ss;
ss << "Index out of range: (" << i << " >= 4)";
NazaraError(ss);
throw std::domain_error(ss.ToString());
}
#endif
return *(&x+i);
}
template<typename T>
T NzVector4<T>::operator[](unsigned int i) const
{
#if NAZARA_MATH_SAFE
if (i >= 4)
{
NzStringStream ss;
ss << "Index out of range: (" << i << " >= 4)";
NazaraError(ss);
throw std::domain_error(ss.ToString());
}
#endif
return *(&x+i);
}
template<typename T>
const NzVector4<T>& NzVector4<T>::operator+() const
{

View File

@ -44,13 +44,13 @@ void NzError::Error(nzErrorType type, const NzString& error, unsigned int line,
s_lastErrorFunction = function;
s_lastErrorLine = line;
if (type != nzErrorType_Warning && (s_flags & nzErrorFlag_ThrowException) != 0 && (s_flags & nzErrorFlag_ThrowExceptionDisabled) == 0)
throw std::runtime_error(error);
#if NAZARA_CORE_EXIT_ON_ASSERT_FAILURE
if (type == nzErrorType_AssertFailed)
std::exit(EXIT_FAILURE);
#endif
if (type != nzErrorType_Warning && (s_flags & nzErrorFlag_ThrowException) != 0 && (s_flags & nzErrorFlag_ThrowExceptionDisabled) == 0)
throw std::runtime_error(error);
}
nzUInt32 NzError::GetFlags()

View File

@ -10,7 +10,7 @@
NzSemaphoreImpl::NzSemaphoreImpl(unsigned int count)
{
m_semaphore = CreateSemaphore(nullptr, count, std::numeric_limits<LONG>::max(), nullptr);
m_semaphore = CreateSemaphoreW(nullptr, count, std::numeric_limits<LONG>::max(), nullptr);
if (!m_semaphore)
NazaraError("Failed to create semaphore: " + NzError::GetLastSystemError());
}

View File

@ -34,11 +34,11 @@ bool NzTaskSchedulerImpl::Initialize(unsigned int workerCount)
{
Worker& worker = s_workers[i];
InitializeCriticalSection(&worker.queueMutex);
worker.wakeEvent = CreateEventA(nullptr, false, false, nullptr);
worker.wakeEvent = CreateEventW(nullptr, false, false, nullptr);
worker.running = true;
worker.workCount = 0;
s_doneEvents[i] = CreateEventA(nullptr, true, false, nullptr);
s_doneEvents[i] = CreateEventW(nullptr, true, false, nullptr);
workerIDs[i] = i;
s_workerThreads[i] = reinterpret_cast<HANDLE>(_beginthreadex(nullptr, 0, &WorkerProc, &workerIDs[i], 0, nullptr));
@ -149,7 +149,8 @@ NzFunctor* NzTaskSchedulerImpl::StealTask(unsigned int workerID)
if (worker.workCount > 0)
{
NzFunctor* task;
NzFunctor* task = nullptr;
if (TryEnterCriticalSection(&worker.queueMutex))
{
if (!worker.queue.empty())
@ -158,8 +159,6 @@ NzFunctor* NzTaskSchedulerImpl::StealTask(unsigned int workerID)
worker.queue.pop();
worker.workCount = worker.queue.size();
}
else
task = nullptr;
LeaveCriticalSection(&worker.queueMutex);
}

View File

@ -289,7 +289,7 @@ bool NzRenderWindow::OnWindowCreated()
std::unique_ptr<NzContext> context(new NzContext);
if (!context->Create(m_parameters))
{
NazaraError("Failed not create context");
NazaraError("Failed to create context");
return false;
}

View File

@ -795,7 +795,7 @@ bool NzRenderer::Initialize()
{
try
{
NzErrorFlags errFlags(nzErrorFlag_ThrowException);
NzErrorFlags errFlags(nzErrorFlag_ThrowException, true);
s_instanceBuffer.Reset(nullptr, NAZARA_RENDERER_INSTANCE_BUFFER_SIZE, nzBufferStorage_Hardware, nzBufferUsage_Dynamic);
}
catch (const std::exception& e)

View File

@ -11,6 +11,7 @@
#include <Nazara/Utility/Debug.hpp>
///TODO: Rajouter des warnings (Formats compressés avec les méthodes Copy/Update, tests taille dans Copy)
///TODO: Rendre les méthodes exception-safe
namespace
{
@ -768,7 +769,7 @@ nzUInt8* NzImage::GetPixels(unsigned int x, unsigned int y, unsigned int z, nzUI
EnsureOwnership();
return GetPixelPtr(m_sharedImage->pixels[level], NzPixelFormat::GetBytesPerPixel(m_sharedImage->format), x, y, z, m_sharedImage->width, m_sharedImage->height);
return GetPixelPtr(m_sharedImage->pixels[level], NzPixelFormat::GetBytesPerPixel(m_sharedImage->format), x, y, z, width, height);
}
unsigned int NzImage::GetSize() const

View File

@ -335,7 +335,7 @@ void NzWindowImpl::SetCursor(nzWindowCursor cursor)
if (cursor > nzWindowCursor_Max)
{
NazaraError("Window cursor out of enum");
return false;
return;
}
#endif