Merge branch 'master' into NDK
Former-commit-id: f118c029ca94296495957816f910d412ae8a56f2
This commit is contained in:
@@ -253,9 +253,9 @@ bool NzFont::Precache(unsigned int characterSize, nzUInt32 style, char32_t chara
|
||||
|
||||
bool NzFont::Precache(unsigned int characterSize, nzUInt32 style, const NzString& characterSet) const
|
||||
{
|
||||
unsigned int size;
|
||||
std::unique_ptr<char32_t[]> characters(characterSet.GetUtf32Buffer(&size));
|
||||
if (!characters)
|
||||
///TODO: Itération UTF-8 => UTF-32 sans allocation de buffer (Exposer utf8cpp ?)
|
||||
std::u32string set = characterSet.GetUtf32String();
|
||||
if (set.empty())
|
||||
{
|
||||
NazaraError("Invalid character set");
|
||||
return false;
|
||||
@@ -263,8 +263,8 @@ bool NzFont::Precache(unsigned int characterSize, nzUInt32 style, const NzString
|
||||
|
||||
nzUInt64 key = ComputeKey(characterSize, style);
|
||||
auto& glyphMap = m_glyphes[key];
|
||||
for (unsigned int i = 0; i < size; ++i)
|
||||
PrecacheGlyph(glyphMap, characterSize, style, characters[i]);
|
||||
for (char32_t character : set)
|
||||
PrecacheGlyph(glyphMap, characterSize, style, character);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -212,12 +212,12 @@ namespace
|
||||
|
||||
bool HasKerning() const override
|
||||
{
|
||||
return FT_HAS_KERNING(m_face);
|
||||
return FT_HAS_KERNING(m_face) != 0;
|
||||
}
|
||||
|
||||
bool IsScalable() const override
|
||||
{
|
||||
return FT_IS_SCALABLE(m_face);
|
||||
return FT_IS_SCALABLE(m_face) != 0;
|
||||
}
|
||||
|
||||
bool Open()
|
||||
|
||||
@@ -220,11 +220,12 @@ namespace
|
||||
|
||||
vertexMapper.Unmap();
|
||||
|
||||
subMesh->GenerateAABB();
|
||||
subMesh->GenerateTangents();
|
||||
subMesh->SetIndexBuffer(indexBuffer);
|
||||
subMesh->SetMaterialIndex(0);
|
||||
|
||||
subMesh->GenerateAABB();
|
||||
subMesh->GenerateTangents();
|
||||
|
||||
mesh->AddSubMesh(subMesh);
|
||||
|
||||
if (parameters.center)
|
||||
|
||||
@@ -41,7 +41,12 @@ m_transformMatrixUpdated(false)
|
||||
NzNode::~NzNode()
|
||||
{
|
||||
for (NzNode* child : m_childs)
|
||||
child->SetParent(nullptr);
|
||||
{
|
||||
// child->SetParent(nullptr); serait problématique car elle nous appellerait
|
||||
child->m_parent = nullptr;
|
||||
child->InvalidateNode();
|
||||
child->OnParenting(nullptr);
|
||||
}
|
||||
|
||||
SetParent(nullptr);
|
||||
}
|
||||
|
||||
@@ -192,9 +192,8 @@ void NzSimpleTextDrawer::UpdateGlyphs() const
|
||||
return;
|
||||
|
||||
///TODO: Itération UTF-8 => UTF-32 sans allocation de buffer (Exposer utf8cpp ?)
|
||||
unsigned int size;
|
||||
std::unique_ptr<char32_t[]> characters(m_text.GetUtf32Buffer(&size));
|
||||
if (!characters)
|
||||
std::u32string characters = m_text.GetUtf32String();
|
||||
if (characters.empty())
|
||||
{
|
||||
NazaraError("Invalid character set");
|
||||
return;
|
||||
@@ -208,12 +207,11 @@ void NzSimpleTextDrawer::UpdateGlyphs() const
|
||||
// On calcule les bornes en flottants pour accélérer les calculs (il est coûteux de changer de type trop souvent)
|
||||
bool firstGlyph = true;
|
||||
NzRectf textBounds = NzRectf::Zero();
|
||||
m_glyphs.reserve(size);
|
||||
nzUInt32 previousCharacter = 0;
|
||||
for (unsigned int i = 0; i < size; ++i)
|
||||
{
|
||||
char32_t character = characters[i];
|
||||
|
||||
m_glyphs.reserve(characters.size());
|
||||
for (char32_t character : characters)
|
||||
{
|
||||
if (previousCharacter != 0)
|
||||
drawPos.x += m_font->GetKerning(m_characterSize, previousCharacter, character);
|
||||
|
||||
@@ -291,12 +289,12 @@ void NzSimpleTextDrawer::UpdateGlyphs() const
|
||||
firstGlyph = false;
|
||||
}
|
||||
|
||||
for (unsigned int j = 0; j < 4; ++j)
|
||||
textBounds.ExtendTo(glyph.corners[j]);
|
||||
for (unsigned int i = 0; i < 4; ++i)
|
||||
textBounds.ExtendTo(glyph.corners[i]);
|
||||
|
||||
drawPos.x += advance;
|
||||
m_glyphs.push_back(glyph);
|
||||
}
|
||||
|
||||
m_bounds.Set(std::floor(textBounds.x), std::floor(textBounds.y), std::ceil(textBounds.width), std::ceil(textBounds.height));
|
||||
m_bounds.Set(NzRectf(std::floor(textBounds.x), std::floor(textBounds.y), std::ceil(textBounds.width), std::ceil(textBounds.height)));
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <Nazara/Utility/Win32/CursorImpl.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Utility/Image.hpp>
|
||||
#include <Nazara/Utility/PixelFormat.hpp>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
bool NzCursorImpl::Create(const NzImage& cursor, int hotSpotX, int hotSpotY)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <Nazara/Utility/Win32/IconImpl.hpp>
|
||||
#include <Nazara/Utility/Image.hpp>
|
||||
#include <Nazara/Utility/PixelFormat.hpp>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
bool NzIconImpl::Create(const NzImage& icon)
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#define GWL_USERDATA GWLP_USERDATA
|
||||
#endif
|
||||
|
||||
// N'est pas définit avec MinGW
|
||||
// N'est pas défini avec MinGW
|
||||
#ifndef MAPVK_VK_TO_VSC
|
||||
#define MAPVK_VK_TO_VSC 0
|
||||
#endif
|
||||
@@ -145,8 +145,6 @@ bool NzWindowImpl::Create(const NzVideoMode& mode, const NzString& title, nzUInt
|
||||
|
||||
m_callback = 0;
|
||||
|
||||
std::unique_ptr<wchar_t[]> wtitle(title.GetWideBuffer());
|
||||
|
||||
#if NAZARA_UTILITY_THREADED_WINDOW
|
||||
NzMutex mutex;
|
||||
NzConditionVariable condition;
|
||||
@@ -154,15 +152,18 @@ bool NzWindowImpl::Create(const NzVideoMode& mode, const NzString& title, nzUInt
|
||||
|
||||
// On attend que la fenêtre soit créée
|
||||
mutex.Lock();
|
||||
m_thread = new NzThread(WindowThread, &m_handle, win32StyleEx, wtitle.get(), win32Style, x, y, width, height, this, &mutex, &condition);
|
||||
m_thread = NzThread(WindowThread, &m_handle, win32StyleEx, title.GetWideString().data(), win32Style, x, y, width, height, this, &mutex, &condition);
|
||||
condition.Wait(&mutex);
|
||||
mutex.Unlock();
|
||||
#else
|
||||
m_handle = CreateWindowExW(win32StyleEx, className, wtitle.get(), win32Style, x, y, width, height, nullptr, nullptr, GetModuleHandle(nullptr), this);
|
||||
m_handle = CreateWindowExW(win32StyleEx, className, title.GetWideString().data(), win32Style, x, y, width, height, nullptr, nullptr, GetModuleHandle(nullptr), this);
|
||||
#endif
|
||||
|
||||
if (!m_handle)
|
||||
{
|
||||
NazaraError("Failed to create window: " + NzError::GetLastSystemError());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fullscreen)
|
||||
{
|
||||
@@ -220,13 +221,12 @@ void NzWindowImpl::Destroy()
|
||||
if (m_ownsWindow)
|
||||
{
|
||||
#if NAZARA_UTILITY_THREADED_WINDOW
|
||||
if (m_thread)
|
||||
if (m_thread.IsJoinable())
|
||||
{
|
||||
m_threadActive = false;
|
||||
PostMessageW(m_handle, WM_NULL, 0, 0); // Pour réveiller le thread
|
||||
|
||||
m_thread->Join();
|
||||
delete m_thread;
|
||||
m_thread.Join();
|
||||
}
|
||||
#else
|
||||
if (m_handle)
|
||||
@@ -445,8 +445,7 @@ void NzWindowImpl::SetStayOnTop(bool stayOnTop)
|
||||
|
||||
void NzWindowImpl::SetTitle(const NzString& title)
|
||||
{
|
||||
std::unique_ptr<wchar_t[]> wTitle(title.GetWideBuffer());
|
||||
SetWindowTextW(m_handle, wTitle.get());
|
||||
SetWindowTextW(m_handle, title.GetWideString().data());
|
||||
}
|
||||
|
||||
void NzWindowImpl::SetVisible(bool visible)
|
||||
@@ -1192,6 +1191,6 @@ void NzWindowImpl::WindowThread(HWND* handle, DWORD styleEx, const wchar_t* titl
|
||||
while (window->m_threadActive)
|
||||
window->ProcessEvents(true);
|
||||
|
||||
DestroyWindow(*handle);
|
||||
DestroyWindow(winHandle);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Core/Thread.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
#include <Nazara/Utility/Keyboard.hpp>
|
||||
@@ -22,7 +23,6 @@
|
||||
#if NAZARA_UTILITY_THREADED_WINDOW
|
||||
class NzConditionVariable;
|
||||
class NzMutex;
|
||||
class NzThread;
|
||||
#endif
|
||||
class NzWindow;
|
||||
|
||||
@@ -95,7 +95,7 @@ class NzWindowImpl : NzNonCopyable
|
||||
NzVector2i m_position;
|
||||
NzVector2ui m_size;
|
||||
#if NAZARA_UTILITY_THREADED_WINDOW
|
||||
NzThread* m_thread;
|
||||
NzThread m_thread;
|
||||
#endif
|
||||
NzWindow* m_parent;
|
||||
bool m_eventListener;
|
||||
|
||||
Reference in New Issue
Block a user