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

This commit is contained in:
Lynix 2017-02-17 00:39:19 +01:00
commit 902949549c
15 changed files with 124 additions and 116 deletions

View File

@ -54,13 +54,13 @@ namespace Nz
private: private:
BitField m_value; BitField m_value;
}; };
template<typename E> constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator~(E lhs);
template<typename E> constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator|(E lhs, E rhs);
template<typename E> constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator&(E lhs, E rhs);
template<typename E> constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator^(E lhs, E rhs);
} }
template<typename E> constexpr std::enable_if_t<Nz::EnumAsFlags<E>::value, Nz::Flags<E>> operator~(E lhs);
template<typename E> constexpr std::enable_if_t<Nz::EnumAsFlags<E>::value, Nz::Flags<E>> operator|(E lhs, E rhs);
template<typename E> constexpr std::enable_if_t<Nz::EnumAsFlags<E>::value, Nz::Flags<E>> operator&(E lhs, E rhs);
template<typename E> constexpr std::enable_if_t<Nz::EnumAsFlags<E>::value, Nz::Flags<E>> operator^(E lhs, E rhs);
#include <Nazara/Core/Flags.inl> #include <Nazara/Core/Flags.inl>
#endif // NAZARA_FLAGS_HPP #endif // NAZARA_FLAGS_HPP

View File

@ -209,7 +209,7 @@ namespace Nz
{ {
return 1U << static_cast<BitField>(enumValue); return 1U << static_cast<BitField>(enumValue);
} }
}
/*! /*!
* \brief Override binary NOT operator on enum to turns into a Flags object. * \brief Override binary NOT operator on enum to turns into a Flags object.
@ -220,9 +220,9 @@ namespace Nz
* Returns a Flags object with all state enabled except for the enum one. * Returns a Flags object with all state enabled except for the enum one.
*/ */
template<typename E> template<typename E>
constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator~(E lhs) constexpr std::enable_if_t<Nz::EnumAsFlags<E>::value, Nz::Flags<E>> operator~(E lhs)
{ {
return ~Flags<E>(lhs); return ~Nz::Flags<E>(lhs);
} }
/*! /*!
@ -235,9 +235,9 @@ namespace Nz
* Returns a Flags object with combined states from the two enumeration values. * Returns a Flags object with combined states from the two enumeration values.
*/ */
template<typename E> template<typename E>
constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator|(E lhs, E rhs) constexpr std::enable_if_t<Nz::EnumAsFlags<E>::value, Nz::Flags<E>> operator|(E lhs, E rhs)
{ {
return Flags<E>(lhs) | rhs; return Nz::Flags<E>(lhs) | rhs;
} }
/*! /*!
@ -251,9 +251,9 @@ namespace Nz
* In this case, only one flag will be enabled if both enumeration values are the same. * In this case, only one flag will be enabled if both enumeration values are the same.
*/ */
template<typename E> template<typename E>
constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator&(E lhs, E rhs) constexpr std::enable_if_t<Nz::EnumAsFlags<E>::value, Nz::Flags<E>> operator&(E lhs, E rhs)
{ {
return Flags<E>(lhs) & rhs; return Nz::Flags<E>(lhs) & rhs;
} }
/*! /*!
@ -267,10 +267,9 @@ namespace Nz
* In this case, two flags will be enabled if both the enumeration values are different. * In this case, two flags will be enabled if both the enumeration values are different.
*/ */
template<typename E> template<typename E>
constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator^(E lhs, E rhs) constexpr std::enable_if_t<Nz::EnumAsFlags<E>::value, Nz::Flags<E>> operator^(E lhs, E rhs)
{ {
return Flags<E>(lhs) ^ rhs; return Nz::Flags<E>(lhs) ^ rhs;
}
} }
#include <Nazara/Core/DebugOff.hpp> #include <Nazara/Core/DebugOff.hpp>

View File

@ -68,7 +68,7 @@ namespace Nz
* \param sceneData Data of the scene * \param sceneData Data of the scene
*/ */
void DepthRenderTechnique::Clear(const SceneData& sceneData) const void DepthRenderTechnique::Clear(const SceneData& /*sceneData*/) const
{ {
Renderer::Enable(RendererParameter_DepthBuffer, true); Renderer::Enable(RendererParameter_DepthBuffer, true);
Renderer::Enable(RendererParameter_DepthWrite, true); Renderer::Enable(RendererParameter_DepthWrite, true);

View File

@ -990,7 +990,6 @@ namespace Nz
if (uniforms.locations.shadowMapping != -1) if (uniforms.locations.shadowMapping != -1)
shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr); shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr);
unsigned int textureUnit = Material::GetTextureUnit(static_cast<TextureMap>(TextureMap_ShadowCube_1 + index));
if (light.shadowMap) if (light.shadowMap)
{ {
unsigned int textureUnitCube = Material::GetTextureUnit(static_cast<TextureMap>(TextureMap_ShadowCube_1 + index)); unsigned int textureUnitCube = Material::GetTextureUnit(static_cast<TextureMap>(TextureMap_ShadowCube_1 + index));
@ -1014,7 +1013,6 @@ namespace Nz
if (uniforms.locations.shadowMapping != -1) if (uniforms.locations.shadowMapping != -1)
shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr); shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr);
unsigned int textureUnit = Material::GetTextureUnit(static_cast<TextureMap>(TextureMap_Shadow2D_1 + index));
if (light.shadowMap) if (light.shadowMap)
{ {
unsigned int textureUnit2D = Material::GetTextureUnit(static_cast<TextureMap>(TextureMap_Shadow2D_1 + index)); unsigned int textureUnit2D = Material::GetTextureUnit(static_cast<TextureMap>(TextureMap_Shadow2D_1 + index));

View File

@ -40,9 +40,9 @@ namespace Nz
ParticleGroup::ParticleGroup(unsigned int maxParticleCount, ParticleDeclarationConstRef declaration) : ParticleGroup::ParticleGroup(unsigned int maxParticleCount, ParticleDeclarationConstRef declaration) :
m_declaration(std::move(declaration)), m_declaration(std::move(declaration)),
m_processing(false),
m_maxParticleCount(maxParticleCount), m_maxParticleCount(maxParticleCount),
m_particleCount(0) m_particleCount(0),
m_processing(false)
{ {
// In case of error, the constructor can only throw an exception // In case of error, the constructor can only throw an exception
ErrorFlags flags(ErrorFlag_ThrowException, true); ErrorFlags flags(ErrorFlag_ThrowException, true);
@ -64,10 +64,10 @@ namespace Nz
m_generators(system.m_generators), m_generators(system.m_generators),
m_declaration(system.m_declaration), m_declaration(system.m_declaration),
m_renderer(system.m_renderer), m_renderer(system.m_renderer),
m_processing(false),
m_maxParticleCount(system.m_maxParticleCount), m_maxParticleCount(system.m_maxParticleCount),
m_particleCount(system.m_particleCount), m_particleCount(system.m_particleCount),
m_particleSize(system.m_particleSize) m_particleSize(system.m_particleSize),
m_processing(false)
{ {
ErrorFlags flags(ErrorFlag_ThrowException, true); ErrorFlags flags(ErrorFlag_ThrowException, true);

View File

@ -36,7 +36,7 @@ namespace Nz
unsigned int width; unsigned int width;
}; };
unsigned int attachmentIndex[AttachmentPoint_Max+1] = unsigned int s_attachmentIndex[AttachmentPoint_Max+1] =
{ {
3, // AttachmentPoint_Color 3, // AttachmentPoint_Color
0, // AttachmentPoint_Depth 0, // AttachmentPoint_Depth
@ -117,7 +117,7 @@ namespace Nz
return false; return false;
} }
unsigned int depthStencilIndex = attachmentIndex[AttachmentPoint_DepthStencil]; unsigned int depthStencilIndex = s_attachmentIndex[AttachmentPoint_DepthStencil];
if (m_impl->attachments.size() > depthStencilIndex && m_impl->attachments[depthStencilIndex].isUsed) if (m_impl->attachments.size() > depthStencilIndex && m_impl->attachments[depthStencilIndex].isUsed)
{ {
if (attachmentPoint == AttachmentPoint_Depth) if (attachmentPoint == AttachmentPoint_Depth)
@ -154,7 +154,7 @@ namespace Nz
Unlock(); Unlock();
unsigned int attachIndex = attachmentIndex[attachmentPoint] + index; unsigned int attachIndex = s_attachmentIndex[attachmentPoint] + index;
if (attachIndex >= m_impl->attachments.size()) if (attachIndex >= m_impl->attachments.size())
m_impl->attachments.resize(attachIndex+1); m_impl->attachments.resize(attachIndex+1);
@ -223,7 +223,7 @@ namespace Nz
return false; return false;
} }
unsigned int depthStencilIndex = attachmentIndex[AttachmentPoint_DepthStencil]; unsigned int depthStencilIndex = s_attachmentIndex[AttachmentPoint_DepthStencil];
if (attachmentPoint == AttachmentPoint_Depth && m_impl->attachments.size() > depthStencilIndex && if (attachmentPoint == AttachmentPoint_Depth && m_impl->attachments.size() > depthStencilIndex &&
m_impl->attachments[depthStencilIndex].isUsed) m_impl->attachments[depthStencilIndex].isUsed)
{ {
@ -288,7 +288,7 @@ namespace Nz
Unlock(); Unlock();
unsigned int attachIndex = attachmentIndex[attachmentPoint] + index; unsigned int attachIndex = s_attachmentIndex[attachmentPoint] + index;
if (attachIndex >= m_impl->attachments.size()) if (attachIndex >= m_impl->attachments.size())
m_impl->attachments.resize(attachIndex+1); m_impl->attachments.resize(attachIndex+1);
@ -394,7 +394,7 @@ namespace Nz
} }
#endif #endif
unsigned int attachIndex = attachmentIndex[attachmentPoint] + index; unsigned int attachIndex = s_attachmentIndex[attachmentPoint] + index;
if (attachIndex >= m_impl->attachments.size()) if (attachIndex >= m_impl->attachments.size())
return; return;
@ -575,7 +575,7 @@ namespace Nz
#if NAZARA_RENDERER_SAFE #if NAZARA_RENDERER_SAFE
for (unsigned int i = 0; i < targetCount; ++i) for (unsigned int i = 0; i < targetCount; ++i)
{ {
unsigned int index = attachmentIndex[AttachmentPoint_Color] + targets[i]; unsigned int index = s_attachmentIndex[AttachmentPoint_Color] + targets[i];
if (index >= m_impl->attachments.size() || !m_impl->attachments[index].isUsed) if (index >= m_impl->attachments.size() || !m_impl->attachments[index].isUsed)
{ {
NazaraError("Target " + String::Number(targets[i]) + " not attached"); NazaraError("Target " + String::Number(targets[i]) + " not attached");
@ -598,7 +598,7 @@ namespace Nz
#if NAZARA_RENDERER_SAFE #if NAZARA_RENDERER_SAFE
for (UInt8 target : targets) for (UInt8 target : targets)
{ {
unsigned int index = attachmentIndex[AttachmentPoint_Color] + target; unsigned int index = s_attachmentIndex[AttachmentPoint_Color] + target;
if (index >= m_impl->attachments.size() || !m_impl->attachments[index].isUsed) if (index >= m_impl->attachments.size() || !m_impl->attachments[index].isUsed)
{ {
NazaraError("Target " + String::Number(target) + " not attached"); NazaraError("Target " + String::Number(target) + " not attached");
@ -752,7 +752,7 @@ namespace Nz
for (UInt8 index : m_impl->colorTargets) for (UInt8 index : m_impl->colorTargets)
{ {
Attachment& attachment = m_impl->attachments[attachmentIndex[AttachmentPoint_Color] + index]; Attachment& attachment = m_impl->attachments[s_attachmentIndex[AttachmentPoint_Color] + index];
if (!attachment.isBuffer) if (!attachment.isBuffer)
attachment.texture->InvalidateMipmaps(); attachment.texture->InvalidateMipmaps();
} }
@ -833,7 +833,7 @@ namespace Nz
m_impl->colorTargets.clear(); m_impl->colorTargets.clear();
unsigned int colorIndex = 0; unsigned int colorIndex = 0;
for (unsigned int index = attachmentIndex[AttachmentPoint_Color]; index < m_impl->attachments.size(); ++index) for (unsigned int index = s_attachmentIndex[AttachmentPoint_Color]; index < m_impl->attachments.size(); ++index)
m_impl->colorTargets.push_back(colorIndex++); m_impl->colorTargets.push_back(colorIndex++);
} }

View File

@ -93,7 +93,7 @@ namespace Nz
} }
catch (const std::exception&) catch (const std::exception&)
{ {
ErrorFlags errFlags(ErrorFlag_ThrowExceptionDisabled); ErrorFlags errFlags2(ErrorFlag_ThrowExceptionDisabled);
NazaraError("Shader code failed to compile (" + stage.GetLog() + ")\n" + code.ToString()); NazaraError("Shader code failed to compile (" + stage.GetLog() + ")\n" + code.ToString());
throw; throw;

View File

@ -835,7 +835,6 @@ namespace Nz
if (!PixelFormat::IsCompressed(m_sharedImage->format)) if (!PixelFormat::IsCompressed(m_sharedImage->format))
{ {
const PixelFormatInfo& info = PixelFormat::GetInfo(m_sharedImage->format); const PixelFormatInfo& info = PixelFormat::GetInfo(m_sharedImage->format);
const UInt8* pixel = GetConstPixels();
Bitset<> workingBitset; Bitset<> workingBitset;
std::size_t pixelCount = m_sharedImage->width * m_sharedImage->height * ((m_sharedImage->type == ImageType_Cubemap) ? 6 : m_sharedImage->depth); std::size_t pixelCount = m_sharedImage->width * m_sharedImage->height * ((m_sharedImage->type == ImageType_Cubemap) ? 6 : m_sharedImage->depth);

View File

@ -35,10 +35,10 @@ namespace Nz
IndexBuffer::IndexBuffer(const IndexBuffer& indexBuffer) : IndexBuffer::IndexBuffer(const IndexBuffer& indexBuffer) :
RefCounted(), RefCounted(),
m_buffer(indexBuffer.m_buffer), m_buffer(indexBuffer.m_buffer),
m_largeIndices(indexBuffer.m_largeIndices),
m_endOffset(indexBuffer.m_endOffset), m_endOffset(indexBuffer.m_endOffset),
m_indexCount(indexBuffer.m_indexCount), m_indexCount(indexBuffer.m_indexCount),
m_startOffset(indexBuffer.m_startOffset) m_startOffset(indexBuffer.m_startOffset),
m_largeIndices(indexBuffer.m_largeIndices)
{ {
} }

View File

@ -365,12 +365,14 @@ namespace Nz
{ {
case '\n': case '\n':
{ {
// Extend the line bounding rect to the last glyph it contains, thus extending upon all glyphs of the line
if (!m_glyphs.empty()) if (!m_glyphs.empty())
{ {
Glyph& glyph = m_glyphs.back(); Glyph& lastGlyph = m_glyphs.back();
m_lines.back().bounds.ExtendTo(glyph.bounds); m_lines.back().bounds.ExtendTo(glyph.bounds);
} }
// Reset cursor
advance = 0; advance = 0;
m_drawPos.x = 0; m_drawPos.x = 0;
m_drawPos.y += sizeInfo.lineHeight; m_drawPos.y += sizeInfo.lineHeight;

View File

@ -31,10 +31,10 @@ namespace Nz
VertexBuffer::VertexBuffer(const VertexBuffer& vertexBuffer) : VertexBuffer::VertexBuffer(const VertexBuffer& vertexBuffer) :
RefCounted(), RefCounted(),
m_buffer(vertexBuffer.m_buffer), m_buffer(vertexBuffer.m_buffer),
m_vertexDeclaration(vertexBuffer.m_vertexDeclaration),
m_endOffset(vertexBuffer.m_endOffset), m_endOffset(vertexBuffer.m_endOffset),
m_startOffset(vertexBuffer.m_startOffset), m_startOffset(vertexBuffer.m_startOffset),
m_vertexCount(vertexBuffer.m_vertexCount) m_vertexCount(vertexBuffer.m_vertexCount),
m_vertexDeclaration(vertexBuffer.m_vertexDeclaration)
{ {
} }

View File

@ -164,8 +164,19 @@ namespace Nz
ScopedXCBConnection connection; ScopedXCBConnection connection;
xcb_screen_t* screen = X11::XCBDefaultScreen(connection); xcb_screen_t* screen = X11::XCBDefaultScreen(connection);
const char* cursorName = s_systemCursorIds[cursor];
if (cursorName)
{
if (xcb_cursor_context_new(connection, screen, &m_cursorContext) >= 0) if (xcb_cursor_context_new(connection, screen, &m_cursorContext) >= 0)
m_cursor = xcb_cursor_load_cursor(m_cursorContext, s_systemCursorIds[cursor]); m_cursor = xcb_cursor_load_cursor(m_cursorContext, cursorName);
else
{
NazaraError("Failed to create cursor context");
return false;
}
}
else
m_cursor = s_hiddenCursor;
return true; return true;
} }
@ -231,6 +242,7 @@ namespace Nz
xcb_cursor_t CursorImpl::s_hiddenCursor = 0; xcb_cursor_t CursorImpl::s_hiddenCursor = 0;
std::array<const char*, SystemCursor_Max + 1> CursorImpl::s_systemCursorIds = std::array<const char*, SystemCursor_Max + 1> CursorImpl::s_systemCursorIds =
{
{ {
// http://gnome-look.org/content/preview.php?preview=1&id=128170&file1=128170-1.png&file2=&file3=&name=Dummy+X11+cursors&PHPSESSID=6 // http://gnome-look.org/content/preview.php?preview=1&id=128170&file1=128170-1.png&file2=&file3=&name=Dummy+X11+cursors&PHPSESSID=6
"crosshair", // SystemCursor_Crosshair "crosshair", // SystemCursor_Crosshair
@ -251,6 +263,7 @@ namespace Nz
"left_side", // SystemCursor_ResizeW "left_side", // SystemCursor_ResizeW
"xterm", // SystemCursor_Text "xterm", // SystemCursor_Text
"watch" // SystemCursor_Wait "watch" // SystemCursor_Wait
}
}; };
static_assert(SystemCursor_Max + 1 == 18, "System cursor array is incomplete"); static_assert(SystemCursor_Max + 1 == 18, "System cursor array is incomplete");

View File

@ -229,14 +229,14 @@ namespace Nz
return screen_nbr; return screen_nbr;
} }
xcb_screen_t* X11::XCBScreenOfDisplay(xcb_connection_t* connection, int screen_nbr) xcb_screen_t* X11::XCBScreenOfDisplay(xcb_connection_t* connection, int screenIndex)
{ {
NazaraAssert(connection == sharedConnection, "The model is meant for one connection to X11 server"); NazaraAssert(connection == sharedConnection, "The model is meant for one connection to X11 server");
xcb_screen_iterator_t iter = xcb_setup_roots_iterator(xcb_get_setup(connection)); xcb_screen_iterator_t iter = xcb_setup_roots_iterator(xcb_get_setup(connection));
for (; iter.rem; --screen_nbr, xcb_screen_next (&iter)) for (; iter.rem; --screenIndex, xcb_screen_next (&iter))
{ {
if (screen_nbr == 0) if (screenIndex == 0)
return iter.data; return iter.data;
} }

View File

@ -58,7 +58,6 @@ namespace Nz
m_style(0), m_style(0),
m_parent(parent), m_parent(parent),
m_smoothScrolling(false), m_smoothScrolling(false),
m_scrolling(0),
m_mousePos(0, 0), m_mousePos(0, 0),
m_keyRepeat(true) m_keyRepeat(true)
{ {
@ -1134,7 +1133,6 @@ namespace Nz
// if (std::isprint(codePoint)) Is not working ? + handle combining ? // if (std::isprint(codePoint)) Is not working ? + handle combining ?
{ {
WindowEvent event;
event.type = Nz::WindowEventType_TextEntered; event.type = Nz::WindowEventType_TextEntered;
event.text.character = codePoint; event.text.character = codePoint;
event.text.repeated = false; event.text.repeated = false;
@ -1396,7 +1394,7 @@ namespace Nz
hints.functions |= MWM_FUNC_CLOSE; hints.functions |= MWM_FUNC_CLOSE;
} }
ScopedXCB<xcb_generic_error_t> error(xcb_request_check( ScopedXCB<xcb_generic_error_t> propertyError(xcb_request_check(
connection, connection,
xcb_change_property_checked( xcb_change_property_checked(
connection, connection,
@ -1410,7 +1408,7 @@ namespace Nz
) )
)); ));
if (error) if (propertyError)
NazaraError("xcb_change_property failed, could not set window hints"); NazaraError("xcb_change_property failed, could not set window hints");
} }
else else

View File

@ -111,7 +111,6 @@ namespace Nz
bool m_ownsWindow; bool m_ownsWindow;
bool m_smoothScrolling; bool m_smoothScrolling;
bool m_threadActive; bool m_threadActive;
short m_scrolling;
Vector2i m_mousePos; Vector2i m_mousePos;
bool m_keyRepeat; bool m_keyRepeat;