Big f***ing cleanup part 1

This commit is contained in:
Lynix
2020-02-23 00:42:22 +01:00
parent 67d0e0a689
commit 3d22321109
178 changed files with 2190 additions and 5113 deletions

View File

@@ -5,10 +5,10 @@
#include <Nazara/Renderer/RenderWindow.hpp>
#include <Nazara/Core/Error.hpp>
#include <Nazara/Core/ErrorFlags.hpp>
#include <Nazara/Core/Thread.hpp>
#include <Nazara/Renderer/Context.hpp>
#include <Nazara/Renderer/OpenGL.hpp>
#include <Nazara/Renderer/Renderer.hpp>
#include <chrono>
#include <Nazara/Renderer/Debug.hpp>
namespace Nz
@@ -137,7 +137,7 @@ namespace Nz
{
int remainingTime = 1000/static_cast<int>(m_framerateLimit) - static_cast<int>(m_clock.GetMilliseconds());
if (remainingTime > 0)
Thread::Sleep(remainingTime);
std::this_thread::sleep_for(std::chrono::milliseconds(remainingTime));
m_clock.Restart();
}

View File

@@ -62,7 +62,7 @@ namespace Nz
m_attachedShaders[stage].push_back(shader);
}
bool Shader::AttachStageFromFile(ShaderStageType stage, const String& filePath)
bool Shader::AttachStageFromFile(ShaderStageType stage, const std::filesystem::path& filePath)
{
ShaderStage shaderStage(stage);
if (!shaderStage.IsValid())

View File

@@ -165,7 +165,7 @@ namespace Nz
glShaderSource(m_id, 1, &tmp, &length);
}
bool ShaderStage::SetSourceFromFile(const String& filePath)
bool ShaderStage::SetSourceFromFile(const std::filesystem::path& filePath)
{
#if NAZARA_RENDERER_SAFE
if (!m_id)
@@ -178,7 +178,7 @@ namespace Nz
File file(filePath);
if (!file.Open(OpenMode_ReadOnly | OpenMode_Text))
{
NazaraError("Failed to open \"" + filePath + '"');
NazaraError("Failed to open \"" + filePath.generic_u8string() + '"');
return false;
}

View File

@@ -483,7 +483,7 @@ namespace Nz
return m_impl != nullptr;
}
bool Texture::LoadFaceFromFile(CubemapFace face, const String& filePath, const ImageParams& params)
bool Texture::LoadFaceFromFile(CubemapFace face, const std::filesystem::path& filePath, const ImageParams& params)
{
#if NAZARA_RENDERER_SAFE
if (!m_impl)
@@ -601,7 +601,7 @@ namespace Nz
return Update(image, Rectui(0, 0, faceSize, faceSize), face);
}
bool Texture::SaveToFile(const String& filePath, const ImageParams& params)
bool Texture::SaveToFile(const std::filesystem::path& filePath, const ImageParams& params)
{
Image image;
if (!Download(&image))
@@ -613,7 +613,7 @@ namespace Nz
return image.SaveToFile(filePath, params);
}
bool Texture::SaveToStream(Stream& stream, const String& format, const ImageParams& params)
bool Texture::SaveToStream(Stream& stream, const std::string& format, const ImageParams& params)
{
Image image;
if (!Download(&image))
@@ -935,7 +935,7 @@ namespace Nz
return false;
}
TextureRef Texture::LoadFromFile(const String& filePath, const ImageParams& params, bool generateMipmaps)
TextureRef Texture::LoadFromFile(const std::filesystem::path& filePath, const ImageParams& params, bool generateMipmaps)
{
ImageRef image = Image::LoadFromFile(filePath, params);
if (!image)
@@ -1047,7 +1047,7 @@ namespace Nz
return LoadFromImage(image, generateMipmaps);
}
TextureRef Texture::LoadArrayFromFile(const String& filePath, const ImageParams& imageParams, bool generateMipmaps, const Vector2ui& atlasSize)
TextureRef Texture::LoadArrayFromFile(const std::filesystem::path& filePath, const ImageParams& imageParams, bool generateMipmaps, const Vector2ui& atlasSize)
{
ImageRef cubemap = Image::LoadArrayFromFile(filePath, imageParams, atlasSize);
if (!cubemap)
@@ -1095,7 +1095,7 @@ namespace Nz
return LoadFromImage(cubemap, generateMipmaps);
}
TextureRef Texture::LoadCubemapFromFile(const String& filePath, const ImageParams& imageParams, bool generateMipmaps, const CubemapParams& cubemapParams)
TextureRef Texture::LoadCubemapFromFile(const std::filesystem::path& filePath, const ImageParams& imageParams, bool generateMipmaps, const CubemapParams& cubemapParams)
{
ImageRef cubemap = Image::LoadCubemapFromFile(filePath, imageParams, cubemapParams);
if (!cubemap)

View File

@@ -166,12 +166,12 @@ namespace Nz
}
}
bool UberShaderPreprocessor::SetShaderFromFile(ShaderStageType stage, const String& filePath, const String& shaderFlags, const String& requiredFlags)
bool UberShaderPreprocessor::SetShaderFromFile(ShaderStageType stage, const std::filesystem::path& filePath, const String& shaderFlags, const String& requiredFlags)
{
File file(filePath);
if (!file.Open(OpenMode_ReadOnly | OpenMode_Text))
{
NazaraError("Failed to open \"" + filePath + '"');
NazaraError("Failed to open \"" + filePath.generic_u8string() + '"');
return false;
}

View File

@@ -7,11 +7,10 @@
#include <Nazara/Renderer/Win32/ContextImpl.hpp>
#include <Nazara/Core/CallOnExit.hpp>
#include <Nazara/Core/Error.hpp>
#include <Nazara/Core/LockGuard.hpp>
#include <Nazara/Core/Mutex.hpp>
#include <Nazara/Renderer/Context.hpp>
#include <Nazara/Renderer/OpenGL.hpp>
#include <cstring>
#include <mutex>
#include <Nazara/Renderer/Debug.hpp>
namespace Nz
@@ -185,8 +184,8 @@ namespace Nz
if (shareContext)
{
// wglShareLists n'est pas thread-safe (source: SFML)
static Mutex mutex;
LockGuard lock(mutex);
static std::mutex mutex;
std::lock_guard<std::mutex> lock(mutex);
if (!wglShareLists(shareContext, m_context))
NazaraWarning("Failed to share the context: " + Error::GetLastSystemError());