Merge remote-tracking branch 'refs/remotes/origin/master' into gui

This commit is contained in:
Lynix
2016-11-30 13:08:08 +01:00
227 changed files with 9347 additions and 4815 deletions

View File

@@ -38,9 +38,6 @@
// Lors du parsage d'une ressource, déclenche un avertissement si une erreur non-critique est repérée dans une ressource (Plus lent)
#define NAZARA_UTILITY_STRICT_RESOURCE_PARSING 1
// Fait tourner chaque fenêtre dans un thread séparé si le système le supporte
#define NAZARA_UTILITY_THREADED_WINDOW 0
// Protège les classes des accès concurrentiels
//#define NAZARA_UTILITY_THREADSAFE 1

View File

@@ -7,6 +7,8 @@
#ifndef NAZARA_ENUMS_UTILITY_HPP
#define NAZARA_ENUMS_UTILITY_HPP
#include <Nazara/Core/Flags.hpp>
namespace Nz
{
enum AnimationType
@@ -430,18 +432,29 @@ namespace Nz
WindowEventType_Max = WindowEventType_TextEntered
};
enum WindowStyleFlags
enum WindowStyle
{
WindowStyle_None = 0x0,
WindowStyle_Fullscreen = 0x1,
WindowStyle_None, ///< Window has no border nor titlebar.
WindowStyle_Fullscreen, ///< At the window creation, the OS tries to set it in fullscreen.
WindowStyle_Closable = 0x2,
WindowStyle_Resizable = 0x4,
WindowStyle_Titlebar = 0x8,
WindowStyle_Closable, ///< Allows the window to be closed by a button in the titlebar, generating a Quit event.
WindowStyle_Resizable, ///< Allows the window to be resized by dragging its corners or by a button of the titlebar.
WindowStyle_Titlebar, ///< Adds a titlebar to the window, this option is automatically enabled if buttons of the titlebar are enabled.
WindowStyle_Default = WindowStyle_Closable | WindowStyle_Resizable | WindowStyle_Titlebar,
WindowStyle_Max = WindowStyle_Titlebar*2-1
WindowStyle_Threaded, ///< Runs the window into a thread, allowing the application to keep updating while resizing/dragging the window.
WindowStyle_Max = WindowStyle_Threaded
};
template<>
struct EnableFlagsOperators<WindowStyle>
{
static constexpr bool value = true;
};
using WindowStyleFlags = Flags<WindowStyle>;
constexpr WindowStyleFlags WindowStyle_Default = WindowStyle_Closable | WindowStyle_Resizable | WindowStyle_Titlebar;
}
#endif // NAZARA_ENUMS_UTILITY_HPP

View File

@@ -24,6 +24,9 @@ namespace Nz
inline void Dispatch(const WindowEvent& event);
EventHandler& operator=(const EventHandler&) = delete;
EventHandler& operator=(EventHandler&&) = default;
NazaraSignal(OnEvent, const EventHandler* /*eventHandler*/, const WindowEvent& /*event*/);
NazaraSignal(OnGainedFocus, const EventHandler* /*eventHandler*/);
NazaraSignal(OnLostFocus, const EventHandler* /*eventHandler*/);

View File

@@ -91,6 +91,8 @@ namespace Nz
ImageType GetType() const;
unsigned int GetWidth(UInt8 level = 0) const;
bool HasAlpha() const;
bool IsValid() const;
// Load

View File

@@ -28,25 +28,15 @@ namespace Nz
{
struct NAZARA_UTILITY_API MeshParams : ResourceParameters
{
MeshParams(); // Vérifie que le storage par défaut est supporté (software autrement)
MeshParams();
// La transformation appliquée à tous les sommets du mesh
Matrix4f matrix = Matrix4f::Identity();
// Si ceci sera le stockage utilisé par les buffers
UInt32 storage = DataStorage_Hardware;
// Charger une version animée du mesh si possible ?
bool animated = true;
// Faut-il centrer le mesh autour de l'origine ?
bool center = false;
// Faut-il retourner les UV ?
bool flipUVs = false;
// Faut-il optimiser les index buffers ? (Rendu plus rapide, mais le chargement dure plus longtemps)
bool optimizeIndexBuffers = true;
Matrix4f matrix = Matrix4f::Identity(); ///< A matrix which will transform every vertex position
UInt32 storage = DataStorage_Hardware; ///< The place where the buffers will be allocated
Vector2f texCoordOffset = {0.f, 0.f}; ///< Offset to apply on the texture coordinates (not scaled)
Vector2f texCoordScale = {1.f, 1.f}; ///< Scale to apply on the texture coordinates
bool animated = true; ///< If true, will load an animated version of the model if possible
bool center = false; ///< If true, will center the mesh vertices around the origin
bool optimizeIndexBuffers = true; ///< Optimize the index buffers after loading, improve cache locality (and thus rendering speed) but increase loading time.
bool IsValid() const;
};

View File

@@ -39,18 +39,8 @@ namespace Nz
}
inline PixelFormatInfo::PixelFormatInfo(const String& formatName, PixelFormatContent formatContent, Bitset<> rMask, Bitset<> gMask, Bitset<> bMask, Bitset<> aMask, PixelFormatSubType subType) :
redMask(rMask),
greenMask(gMask),
blueMask(bMask),
alphaMask(aMask),
content(formatContent),
redType(subType),
greenType(subType),
blueType(subType),
alphaType(subType),
name(formatName)
PixelFormatInfo(formatName, formatContent, subType, rMask, subType, gMask, subType, bMask, subType, aMask)
{
RecomputeBitsPerPixel();
}
inline PixelFormatInfo::PixelFormatInfo(const String& formatName, PixelFormatContent formatContent, PixelFormatSubType rType, Bitset<> rMask, PixelFormatSubType gType, Bitset<> gMask, PixelFormatSubType bType, Bitset<> bMask, PixelFormatSubType aType, Bitset<> aMask, UInt8 bpp) :
@@ -65,6 +55,11 @@ namespace Nz
alphaType(aType),
name(formatName)
{
redMask.Reverse();
greenMask.Reverse();
blueMask.Reverse();
alphaMask.Reverse();
if (bpp == 0)
RecomputeBitsPerPixel();
}
@@ -123,6 +118,9 @@ namespace Nz
if (usedBits > bitsPerPixel)
return false;
if (usedBits > 64) //< Currently, formats with over 64 bits per component are not supported
return false;
switch (types[i])
{
case PixelFormatSubType_Half:

View File

@@ -19,6 +19,7 @@ namespace Nz
{
public:
VideoMode();
VideoMode(unsigned int w, unsigned int h);
VideoMode(unsigned int w, unsigned int h, UInt8 bpp);
bool IsFullscreenValid() const;

View File

@@ -10,6 +10,8 @@
#define NAZARA_WINDOW_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ConditionVariable.hpp>
#include <Nazara/Core/Mutex.hpp>
#include <Nazara/Core/String.hpp>
#include <Nazara/Math/Vector2.hpp>
#include <Nazara/Utility/Config.hpp>
@@ -19,11 +21,6 @@
#include <Nazara/Utility/WindowHandle.hpp>
#include <queue>
#if NAZARA_UTILITY_THREADED_WINDOW
#include <Nazara/Core/ConditionVariable.hpp>
#include <Nazara/Core/Mutex.hpp>
#endif
namespace Nz
{
class Cursor;
@@ -39,7 +36,7 @@ namespace Nz
public:
inline Window();
inline Window(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default);
inline Window(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default);
inline Window(WindowHandle handle);
Window(const Window&) = delete;
inline Window(Window&& window) noexcept;
@@ -47,7 +44,7 @@ namespace Nz
inline void Close();
bool Create(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default);
bool Create(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default);
bool Create(WindowHandle handle);
void Destroy();
@@ -65,7 +62,7 @@ namespace Nz
unsigned int GetHeight() const;
Vector2i GetPosition() const;
Vector2ui GetSize() const;
UInt32 GetStyle() const;
WindowStyleFlags GetStyle() const;
String GetTitle() const;
unsigned int GetWidth() const;
@@ -114,23 +111,24 @@ namespace Nz
private:
void IgnoreNextMouseEvent(int mouseX, int mouseY) const;
inline void HandleEvent(const WindowEvent& event);
inline void PushEvent(const WindowEvent& event);
static bool Initialize();
static void Uninitialize();
std::queue<WindowEvent> m_events;
#if NAZARA_UTILITY_THREADED_WINDOW
std::vector<WindowEvent> m_pendingEvents;
ConditionVariable m_eventCondition;
EventHandler m_eventHandler;
Mutex m_eventMutex;
Mutex m_eventConditionMutex;
bool m_waitForEvent;
#endif
EventHandler m_eventHandler;
bool m_asyncWindow;
bool m_closed;
bool m_closeOnQuit;
bool m_eventPolling;
bool m_ownsWindow;
bool m_waitForEvent;
};
}

View File

@@ -4,6 +4,7 @@
#include <Nazara/Utility/Window.hpp>
#include <Nazara/Core/ErrorFlags.hpp>
#include <Nazara/Core/LockGuard.hpp>
#include <Nazara/Utility/Debug.hpp>
namespace Nz
@@ -13,15 +14,14 @@ namespace Nz
*/
inline Window::Window() :
m_impl(nullptr),
#if NAZARA_UTILITY_THREADED_WINDOW
m_waitForEvent(false),
#endif
m_asyncWindow(false),
m_closeOnQuit(true),
m_eventPolling(false)
m_eventPolling(false),
m_waitForEvent(false)
{
}
inline Window::Window(VideoMode mode, const String& title, UInt32 style) :
inline Window::Window(VideoMode mode, const String& title, WindowStyleFlags style) :
Window()
{
ErrorFlags flags(ErrorFlag_ThrowException, true);
@@ -41,16 +41,16 @@ namespace Nz
inline Window::Window(Window&& window) noexcept :
m_impl(window.m_impl),
m_events(std::move(window.m_events)),
#if NAZARA_UTILITY_THREADED_WINDOW
m_pendingEvents(std::move(window.m_pendingEvents)),
m_eventCondition(std::move(window.m_eventCondition)),
m_eventHandler(std::move(window.m_eventHandler)),
m_eventMutex(std::move(window.m_eventMutex)),
m_eventConditionMutex(std::move(window.m_eventConditionMutex)),
m_waitForEvent(window.m_waitForEvent),
#endif
m_closed(window.m_closed),
m_closeOnQuit(window.m_closeOnQuit),
m_eventPolling(window.m_eventPolling),
m_ownsWindow(window.m_ownsWindow)
m_ownsWindow(window.m_ownsWindow),
m_waitForEvent(window.m_waitForEvent)
{
window.m_impl = nullptr;
}
@@ -104,12 +104,8 @@ namespace Nz
return m_impl != nullptr;
}
inline void Window::PushEvent(const WindowEvent& event)
inline void Window::HandleEvent(const WindowEvent& event)
{
#if NAZARA_UTILITY_THREADED_WINDOW
m_eventMutex.Lock();
#endif
if (m_eventPolling)
m_events.push(event);
@@ -120,17 +116,27 @@ namespace Nz
if (event.type == WindowEventType_Quit && m_closeOnQuit)
Close();
}
#if NAZARA_UTILITY_THREADED_WINDOW
m_eventMutex.Unlock();
if (m_waitForEvent)
inline void Window::PushEvent(const WindowEvent& event)
{
if (!m_asyncWindow)
HandleEvent(event);
else
{
m_eventConditionMutex.Lock();
m_eventCondition.Signal();
m_eventConditionMutex.Unlock();
{
LockGuard eventLock(m_eventMutex);
m_pendingEvents.push_back(event);
}
if (m_waitForEvent)
{
m_eventConditionMutex.Lock();
m_eventCondition.Signal();
m_eventConditionMutex.Unlock();
}
}
#endif
}
/*!
@@ -141,22 +147,21 @@ namespace Nz
{
Destroy();
m_closed = window.m_closed;
m_closeOnQuit = window.m_closeOnQuit;
m_eventPolling = window.m_eventPolling;
m_impl = window.m_impl;
m_events = std::move(window.m_events);
m_ownsWindow = window.m_ownsWindow;
m_closed = window.m_closed;
m_closeOnQuit = window.m_closeOnQuit;
m_eventCondition = std::move(window.m_eventCondition);
m_eventConditionMutex = std::move(window.m_eventConditionMutex);
m_eventHandler = std::move(window.m_eventHandler);
m_eventMutex = std::move(window.m_eventMutex);
m_eventPolling = window.m_eventPolling;
m_impl = window.m_impl;
m_events = std::move(window.m_events);
m_pendingEvents = std::move(window.m_pendingEvents);
m_ownsWindow = window.m_ownsWindow;
m_waitForEvent = window.m_waitForEvent;
window.m_impl = nullptr;
#if NAZARA_UTILITY_THREADED_WINDOW
m_eventCondition = std::move(window.m_eventCondition);
m_eventMutex = std::move(window.m_eventMutex);
m_eventConditionMutex = std::move(window.m_eventConditionMutex);
m_waitForEvent = window.m_waitForEvent;
#endif
return *this;
}
}