Merge branch 'master' into NDK-ShadowMapping
Former-commit-id: e2be28b65207dfbb81efe58f31ca31548afecee7
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
#include <Nazara/Core/ResourceManager.hpp>
|
||||
#include <Nazara/Core/ResourceParameters.hpp>
|
||||
#include <Nazara/Core/Signal.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
@@ -23,7 +24,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
struct NAZARA_UTILITY_API AnimationParams
|
||||
struct NAZARA_UTILITY_API AnimationParams : ResourceParameters
|
||||
{
|
||||
// La frame de fin à charger
|
||||
unsigned int endFrame = std::numeric_limits<unsigned int>::max();
|
||||
|
||||
@@ -14,13 +14,14 @@
|
||||
#include <Nazara/Core/ObjectRef.hpp>
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
#include <Nazara/Core/ResourceParameters.hpp>
|
||||
#include <Nazara/Utility/AbstractAtlas.hpp>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
struct NAZARA_UTILITY_API FontParams
|
||||
struct NAZARA_UTILITY_API FontParams : ResourceParameters
|
||||
{
|
||||
bool IsValid() const;
|
||||
};
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Nz
|
||||
const Vector3f* GetTexCoords() const;
|
||||
unsigned int GetTexCoordCount() const;
|
||||
|
||||
bool Parse();
|
||||
bool Parse(std::size_t reservedVertexCount = 100);
|
||||
|
||||
private:
|
||||
bool Advance(bool required = true);
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
#include <Nazara/Core/ResourceManager.hpp>
|
||||
#include <Nazara/Core/ResourceParameters.hpp>
|
||||
#include <Nazara/Core/ResourceSaver.hpp>
|
||||
#include <Nazara/Core/Signal.hpp>
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
#include <Nazara/Utility/AbstractImage.hpp>
|
||||
@@ -25,7 +27,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
struct NAZARA_UTILITY_API ImageParams
|
||||
struct NAZARA_UTILITY_API ImageParams : ResourceParameters
|
||||
{
|
||||
// Le format dans lequel l'image doit être chargée (Undefined pour le format le plus proche de l'original)
|
||||
PixelFormatType loadFormat = PixelFormatType_Undefined;
|
||||
@@ -43,12 +45,14 @@ namespace Nz
|
||||
using ImageLoader = ResourceLoader<Image, ImageParams>;
|
||||
using ImageManager = ResourceManager<Image, ImageParams>;
|
||||
using ImageRef = ObjectRef<Image>;
|
||||
using ImageSaver = ResourceSaver<Image, ImageParams>;
|
||||
|
||||
class NAZARA_UTILITY_API Image : public AbstractImage, public RefCounted, public Resource
|
||||
{
|
||||
friend ImageLibrary;
|
||||
friend ImageLoader;
|
||||
friend ImageManager;
|
||||
friend ImageSaver;
|
||||
friend class Utility;
|
||||
|
||||
public:
|
||||
@@ -107,6 +111,17 @@ namespace Nz
|
||||
bool LoadCubemapFromMemory(const void* data, std::size_t size, const ImageParams& imageParams = ImageParams(), const CubemapParams& cubemapParams = CubemapParams());
|
||||
bool LoadCubemapFromStream(Stream& stream, const ImageParams& imageParams = ImageParams(), const CubemapParams& cubemapParams = CubemapParams());
|
||||
|
||||
// LoadFace
|
||||
bool LoadFaceFromFile(CubemapFace face, const String& filePath, const ImageParams& params = ImageParams());
|
||||
bool LoadFaceFromMemory(CubemapFace face, const void* data, std::size_t size, const ImageParams& params = ImageParams());
|
||||
bool LoadFaceFromStream(CubemapFace face, Stream& stream, const ImageParams& params = ImageParams());
|
||||
|
||||
// Save
|
||||
bool SaveToFile(const String& filePath, const ImageParams& params = ImageParams());
|
||||
bool SaveToStream(Stream& stream, const String& format, const ImageParams& params = ImageParams());
|
||||
|
||||
//TODO: SaveArray, SaveCubemap, SaveFace
|
||||
|
||||
void SetLevelCount(UInt8 levelCount);
|
||||
bool SetPixelColor(const Color& color, unsigned int x, unsigned int y = 0, unsigned int z = 0);
|
||||
|
||||
@@ -165,6 +180,7 @@ namespace Nz
|
||||
static ImageLoader::LoaderList s_loaders;
|
||||
static ImageManager::ManagerMap s_managerMap;
|
||||
static ImageManager::ManagerParams s_managerParameters;
|
||||
static ImageSaver::SaverList s_savers;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
#include <Nazara/Core/ResourceManager.hpp>
|
||||
#include <Nazara/Core/ResourceParameters.hpp>
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
@@ -24,7 +25,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
struct NAZARA_UTILITY_API MeshParams
|
||||
struct NAZARA_UTILITY_API MeshParams : ResourceParameters
|
||||
{
|
||||
MeshParams(); // Vérifie que le storage par défaut est supporté (software autrement)
|
||||
|
||||
|
||||
@@ -24,7 +24,11 @@ namespace Nz
|
||||
SimpleTextDrawer(SimpleTextDrawer&& drawer);
|
||||
virtual ~SimpleTextDrawer();
|
||||
|
||||
const Rectui& GetBounds() const;
|
||||
void AppendText(const String& str);
|
||||
|
||||
void Clear();
|
||||
|
||||
const Rectui& GetBounds() const override;
|
||||
unsigned int GetCharacterSize() const;
|
||||
const Color& GetColor() const;
|
||||
Font* GetFont() const;
|
||||
@@ -48,11 +52,14 @@ namespace Nz
|
||||
static SimpleTextDrawer Draw(Font* font, const String& str, unsigned int characterSize, UInt32 style = TextStyle_Regular, const Color& color = Color::White);
|
||||
|
||||
private:
|
||||
void ClearGlyphs() const;
|
||||
void ConnectFontSlots();
|
||||
void DisconnectFontSlots();
|
||||
void GenerateGlyphs(const String& text) const;
|
||||
void OnFontAtlasLayerChanged(const Font* font, AbstractImage* oldLayer, AbstractImage* newLayer);
|
||||
void OnFontInvalidated(const Font* font);
|
||||
void OnFontRelease(const Font* object);
|
||||
void UpdateGlyphColor() const;
|
||||
void UpdateGlyphs() const;
|
||||
|
||||
NazaraSlot(Font, OnFontAtlasChanged, m_atlasChangedSlot);
|
||||
@@ -63,9 +70,13 @@ namespace Nz
|
||||
mutable std::vector<Glyph> m_glyphs;
|
||||
Color m_color;
|
||||
FontRef m_font;
|
||||
mutable Rectf m_workingBounds;
|
||||
mutable Rectui m_bounds;
|
||||
String m_text;
|
||||
mutable UInt32 m_previousCharacter;
|
||||
UInt32 m_style;
|
||||
mutable Vector2ui m_drawPos;
|
||||
mutable bool m_colorUpdated;
|
||||
mutable bool m_glyphUpdated;
|
||||
unsigned int m_characterSize;
|
||||
};
|
||||
|
||||
@@ -38,14 +38,14 @@ namespace Nz
|
||||
friend class Utility;
|
||||
|
||||
public:
|
||||
Window();
|
||||
Window(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default);
|
||||
Window(WindowHandle handle);
|
||||
inline Window();
|
||||
inline Window(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default);
|
||||
inline Window(WindowHandle handle);
|
||||
Window(const Window&) = delete;
|
||||
Window(Window&&) = delete; ///TODO
|
||||
inline Window(Window&& window) noexcept;
|
||||
virtual ~Window();
|
||||
|
||||
void Close();
|
||||
inline void Close();
|
||||
|
||||
bool Create(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default);
|
||||
bool Create(WindowHandle handle);
|
||||
@@ -66,9 +66,9 @@ namespace Nz
|
||||
bool HasFocus() const;
|
||||
|
||||
bool IsMinimized() const;
|
||||
bool IsOpen(bool checkClosed = true);
|
||||
bool IsOpen() const;
|
||||
bool IsValid() const;
|
||||
inline bool IsOpen(bool checkClosed = true);
|
||||
inline bool IsOpen() const;
|
||||
inline bool IsValid() const;
|
||||
bool IsVisible() const;
|
||||
|
||||
bool PollEvent(WindowEvent* event);
|
||||
@@ -93,7 +93,7 @@ namespace Nz
|
||||
bool WaitEvent(WindowEvent* event);
|
||||
|
||||
Window& operator=(const Window&) = delete;
|
||||
Window& operator=(Window&&) = delete; ///TODO
|
||||
inline Window& operator=(Window&& window);
|
||||
|
||||
protected:
|
||||
virtual bool OnWindowCreated();
|
||||
@@ -104,7 +104,7 @@ namespace Nz
|
||||
|
||||
private:
|
||||
void IgnoreNextMouseEvent(int mouseX, int mouseY) const;
|
||||
void PushEvent(const WindowEvent& event);
|
||||
inline void PushEvent(const WindowEvent& event);
|
||||
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
@@ -122,4 +122,6 @@ namespace Nz
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/Window.inl>
|
||||
|
||||
#endif // NAZARA_WINDOW_HPP
|
||||
|
||||
154
include/Nazara/Utility/Window.inl
Normal file
154
include/Nazara/Utility/Window.inl
Normal file
@@ -0,0 +1,154 @@
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Utility/Window.hpp>
|
||||
#include <Nazara/Core/ErrorFlags.hpp>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
/*!
|
||||
* \class Nz::Window
|
||||
*/
|
||||
|
||||
inline Window::Window() :
|
||||
#if NAZARA_UTILITY_THREADED_WINDOW
|
||||
m_impl(nullptr),
|
||||
m_eventListener(true),
|
||||
m_waitForEvent(false)
|
||||
#else
|
||||
m_impl(nullptr)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
inline Window::Window(VideoMode mode, const String& title, UInt32 style) :
|
||||
#if NAZARA_UTILITY_THREADED_WINDOW
|
||||
m_impl(nullptr),
|
||||
m_eventListener(true),
|
||||
m_waitForEvent(false)
|
||||
#else
|
||||
m_impl(nullptr)
|
||||
#endif
|
||||
{
|
||||
ErrorFlags flags(ErrorFlag_ThrowException, true);
|
||||
Create(mode, title, style);
|
||||
}
|
||||
|
||||
inline Window::Window(WindowHandle handle) :
|
||||
#if NAZARA_UTILITY_THREADED_WINDOW
|
||||
m_impl(nullptr),
|
||||
m_eventListener(true),
|
||||
m_waitForEvent(false)
|
||||
#else
|
||||
m_impl(nullptr)
|
||||
#endif
|
||||
{
|
||||
ErrorFlags flags(ErrorFlag_ThrowException, true);
|
||||
Create(handle);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Constructs a Window object by moving another one
|
||||
*/
|
||||
inline Window::Window(Window&& window) noexcept :
|
||||
m_impl(window.m_impl),
|
||||
m_events(std::move(window.m_events)),
|
||||
#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_eventListener(window.m_eventListener),
|
||||
m_waitForEvent(window.m_waitForEvent),
|
||||
#endif
|
||||
m_closed(window.m_closed),
|
||||
m_ownsWindow(window.m_ownsWindow)
|
||||
{
|
||||
window.m_impl = nullptr;
|
||||
}
|
||||
|
||||
inline Window::~Window()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
inline void Window::Close()
|
||||
{
|
||||
m_closed = true; // The window will be closed at the next non-const IsOpen() call
|
||||
}
|
||||
|
||||
inline bool Window::IsOpen(bool checkClosed)
|
||||
{
|
||||
if (!m_impl)
|
||||
return false;
|
||||
|
||||
if (checkClosed && m_closed)
|
||||
{
|
||||
Destroy();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool Window::IsOpen() const
|
||||
{
|
||||
return m_impl != nullptr;
|
||||
}
|
||||
|
||||
inline bool Window::IsValid() const
|
||||
{
|
||||
return m_impl != nullptr;
|
||||
}
|
||||
|
||||
inline void Window::PushEvent(const WindowEvent& event)
|
||||
{
|
||||
#if NAZARA_UTILITY_THREADED_WINDOW
|
||||
m_eventMutex.Lock();
|
||||
#endif
|
||||
|
||||
m_events.push(event);
|
||||
if (event.type == WindowEventType_Resized)
|
||||
OnWindowResized();
|
||||
|
||||
#if NAZARA_UTILITY_THREADED_WINDOW
|
||||
m_eventMutex.Unlock();
|
||||
|
||||
if (m_waitForEvent)
|
||||
{
|
||||
m_eventConditionMutex.Lock();
|
||||
m_eventCondition.Signal();
|
||||
m_eventConditionMutex.Unlock();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Moves a window to another window object
|
||||
* \return A reference to the object
|
||||
*/
|
||||
inline Window& Window::operator=(Window&& window)
|
||||
{
|
||||
Destroy();
|
||||
|
||||
m_closed = window.m_closed;
|
||||
m_impl = window.m_impl;
|
||||
m_events = std::move(window.m_events);
|
||||
m_ownsWindow = window.m_ownsWindow;
|
||||
|
||||
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_eventListener = window.m_eventListener;
|
||||
m_waitForEvent = window.m_waitForEvent;
|
||||
#endif
|
||||
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/DebugOff.hpp>
|
||||
Reference in New Issue
Block a user