diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Buffer.inl b/include/Nazara/OpenGLRenderer/Wrapper/Buffer.inl index 943369d0e..094cefb4e 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Buffer.inl +++ b/include/Nazara/OpenGLRenderer/Wrapper/Buffer.inl @@ -40,7 +40,7 @@ namespace Nz::GL return context.glUnmapBuffer(ToOpenGL(m_target)) == GL_TRUE; } - inline GLuint Buffer::CreateHelper(OpenGLDevice& device, const Context& context) + inline GLuint Buffer::CreateHelper(OpenGLDevice& /*device*/, const Context& context) { GLuint sampler = 0; context.glGenBuffers(1U, &sampler); diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Loader.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Loader.hpp index 2db76c99c..8b0a73b62 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Loader.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Loader.hpp @@ -22,7 +22,7 @@ namespace Nz::GL { class Context; - using GLFunction = int(*)(); + using GLFunction = void(*)(void); class NAZARA_OPENGLRENDERER_API Loader { diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Texture.inl b/include/Nazara/OpenGLRenderer/Wrapper/Texture.inl index b94bbe5d4..62de24b8d 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Texture.inl +++ b/include/Nazara/OpenGLRenderer/Wrapper/Texture.inl @@ -67,7 +67,7 @@ namespace Nz::GL //< TODO: Handle errors } - inline GLuint Texture::CreateHelper(OpenGLDevice& device, const Context& context) + inline GLuint Texture::CreateHelper(OpenGLDevice& /*device*/, const Context& context) { GLuint texture = 0; context.glGenTextures(1U, &texture); diff --git a/include/Nazara/OpenGLRenderer/Wrapper/VertexArray.inl b/include/Nazara/OpenGLRenderer/Wrapper/VertexArray.inl index 91bbe698b..0d57e64e5 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/VertexArray.inl +++ b/include/Nazara/OpenGLRenderer/Wrapper/VertexArray.inl @@ -9,7 +9,7 @@ namespace Nz::GL { template - static VertexArray VertexArray::Build(const Context& context, F&& callback) + VertexArray VertexArray::Build(const Context& context, F&& callback) { VertexArray vao; if (!vao.Create(context)) diff --git a/include/Nazara/Renderer/RenderBufferView.inl b/include/Nazara/Renderer/RenderBufferView.inl index a0cb08aa5..846c97695 100644 --- a/include/Nazara/Renderer/RenderBufferView.inl +++ b/include/Nazara/Renderer/RenderBufferView.inl @@ -14,9 +14,9 @@ namespace Nz } inline RenderBufferView::RenderBufferView(AbstractBuffer* buffer, UInt64 offset, UInt64 size) : - m_buffer(buffer), m_offset(offset), - m_size(size) + m_size(size), + m_buffer(buffer) { } diff --git a/include/Nazara/Utility/VertexDeclaration.hpp b/include/Nazara/Utility/VertexDeclaration.hpp index 513cc5367..418861f46 100644 --- a/include/Nazara/Utility/VertexDeclaration.hpp +++ b/include/Nazara/Utility/VertexDeclaration.hpp @@ -44,6 +44,7 @@ namespace Nz inline const Component& GetComponent(std::size_t componentIndex) const; inline std::size_t GetComponentCount() const; + inline const std::vector& GetComponents() const; inline VertexInputRate GetInputRate() const; inline std::size_t GetStride() const; diff --git a/include/Nazara/Utility/VertexDeclaration.inl b/include/Nazara/Utility/VertexDeclaration.inl index 1722e3936..df4e9b5a1 100644 --- a/include/Nazara/Utility/VertexDeclaration.inl +++ b/include/Nazara/Utility/VertexDeclaration.inl @@ -33,6 +33,11 @@ namespace Nz return m_components.size(); } + inline auto VertexDeclaration::GetComponents() const -> const std::vector& + { + return m_components; + } + inline VertexInputRate VertexDeclaration::GetInputRate() const { return m_inputRate; @@ -84,19 +89,4 @@ namespace Nz } } -namespace std -{ - inline const Nz::VertexDeclaration::Component* begin(const Nz::VertexDeclaration& declaration) - { - assert(declaration.GetComponentCount() != 0); - return &declaration.GetComponent(0); - } - - inline const Nz::VertexDeclaration::Component* end(const Nz::VertexDeclaration& declaration) - { - assert(declaration.GetComponentCount() != 0); - return (&declaration.GetComponent(declaration.GetComponentCount() - 1) + 1); - } -} - #include diff --git a/src/Nazara/Core/EmptyStream.cpp b/src/Nazara/Core/EmptyStream.cpp index e30345294..571c5de6e 100644 --- a/src/Nazara/Core/EmptyStream.cpp +++ b/src/Nazara/Core/EmptyStream.cpp @@ -56,7 +56,7 @@ namespace Nz * * \param offset Offset according to the beginning of the stream */ - bool EmptyStream::SetCursorPos(UInt64 offset) + bool EmptyStream::SetCursorPos(UInt64 /*offset*/) { return true; } @@ -78,7 +78,7 @@ namespace Nz * \param buffer Preallocated buffer to contain information read * \param size Size of the read and thus of the buffer */ - std::size_t EmptyStream::ReadBlock(void* buffer, std::size_t size) + std::size_t EmptyStream::ReadBlock(void* /*buffer*/, std::size_t /*size*/) { return 0; } diff --git a/src/Nazara/OpenGLRenderer/OpenGLCommandBuffer.cpp b/src/Nazara/OpenGLRenderer/OpenGLCommandBuffer.cpp index 1f9f06546..40171f442 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLCommandBuffer.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLCommandBuffer.cpp @@ -57,7 +57,7 @@ namespace Nz { const GL::Context* context = GL::Context::GetCurrentContext(); - for (const auto& command : m_commands) + for (const auto& commandVariant : m_commands) { std::visit([&](auto&& command) { @@ -98,7 +98,7 @@ namespace Nz else static_assert(AlwaysFalse::value, "non-exhaustive visitor"); - }, command); + }, commandVariant); } } @@ -126,7 +126,7 @@ namespace Nz GLsizei stride = GLsizei(bufferData.declaration->GetStride()); - for (const auto& componentInfo : *bufferData.declaration) + for (const auto& componentInfo : bufferData.declaration->GetComponents()) { auto& bufferAttribute = vaoSetup.vertexAttribs[locationIndex++].emplace(); BuildAttrib(bufferAttribute, componentInfo.type); diff --git a/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp b/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp index 4590e144e..a1c8e2b0d 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -52,9 +53,9 @@ namespace Nz return std::make_unique(*this, type); } - std::unique_ptr OpenGLDevice::InstantiateCommandPool(QueueType queueType) + std::unique_ptr OpenGLDevice::InstantiateCommandPool(QueueType /*queueType*/) { - return {}; + return std::make_unique(*this); } std::unique_ptr OpenGLDevice::InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) diff --git a/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp b/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp index a0b561eda..510e18f80 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp @@ -59,7 +59,7 @@ namespace Nz return true; } - std::unique_ptr OpenGLRenderWindow::CreateCommandPool(QueueType queueType) + std::unique_ptr OpenGLRenderWindow::CreateCommandPool(QueueType /*queueType*/) { return std::make_unique(); } diff --git a/src/Nazara/OpenGLRenderer/OpenGLShaderBinding.cpp b/src/Nazara/OpenGLRenderer/OpenGLShaderBinding.cpp index b73dd76d2..a236d81c7 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLShaderBinding.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLShaderBinding.cpp @@ -15,20 +15,17 @@ namespace Nz { void OpenGLShaderBinding::Apply(const GL::Context& context) const { - std::size_t textureDescriptorCount = m_owner.GetTextureDescriptorCount(); - std::size_t uniformBufferDescriptorCount = m_owner.GetUniformBufferDescriptorCount(); - - for (std::size_t i = 0; i < textureDescriptorCount; ++i) + for (std::size_t i = 0; i < m_owner.GetTextureDescriptorCount(); ++i) { const auto& textureDescriptor = m_owner.GetTextureDescriptor(m_poolIndex, m_bindingIndex, i); UInt32 textureIndex = textureDescriptor.bindingIndex; context.BindSampler(textureIndex, textureDescriptor.sampler); - context.BindTexture(textureIndex, textureDescriptor.textureTarget, textureDescriptor.texture); + context.BindTexture(textureIndex, textureDescriptor.textureTarget, textureDescriptor.texture); } - for (std::size_t i = 0; i < textureDescriptorCount; ++i) + for (std::size_t i = 0; i < m_owner.GetUniformBufferDescriptorCount(); ++i) { const auto& uboDescriptor = m_owner.GetUniformBufferDescriptor(m_poolIndex, m_bindingIndex, i); @@ -62,8 +59,8 @@ namespace Nz const TextureBinding& texBinding = std::get(binding.content); - OpenGLTexture& glTexture = *static_cast(texBinding.texture); - OpenGLTextureSampler& glSampler = *static_cast(texBinding.sampler); + OpenGLTexture& glTexture = static_cast(*texBinding.texture); + OpenGLTextureSampler& glSampler = static_cast(*texBinding.sampler); auto& textureDescriptor = m_owner.GetTextureDescriptor(m_poolIndex, m_bindingIndex, resourceIndex); textureDescriptor.bindingIndex = binding.bindingIndex; diff --git a/src/Nazara/Renderer/GLX/ContextImpl.cpp b/src/Nazara/Renderer/GLX/ContextImpl.cpp deleted file mode 100644 index 572c6eace..000000000 --- a/src/Nazara/Renderer/GLX/ContextImpl.cpp +++ /dev/null @@ -1,302 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -// Code inspiré de NeHe (Lesson1) et de la SFML par Laurent Gomila - -#include -#include -#include -#include -#include - -using namespace GLX; - -namespace Nz -{ - namespace - { - Display* m_display; - int m_sharedDisplay = 0; - - bool ctxErrorOccurred = false; - int ctxErrorHandler( Display* /*dpy*/, XErrorEvent* /*ev*/ ) - { - ctxErrorOccurred = true; - return 0; - } - } - - ContextImpl::ContextImpl() : - m_colormap(0), - m_context(0), - m_window(0), - m_ownsWindow(false) - { - if (m_sharedDisplay == 0) - m_display = XOpenDisplay(nullptr); - - ++m_sharedDisplay; - } - - ContextImpl::~ContextImpl() - { - Destroy(); - - if (--m_sharedDisplay == 0) - { - XCloseDisplay(m_display); - m_display = nullptr; - } - } - - bool ContextImpl::Activate() const - { - return glXMakeCurrent(m_display, m_window, m_context) == true; - } - - bool ContextImpl::Create(ContextParameters& parameters) - { - // En cas d'exception, la ressource sera quand même libérée - CallOnExit onExit([this] () - { - Destroy(); - }); - - // Get a matching FB config - static int visual_attribs[] = - { - GLX_X_RENDERABLE, True, - GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, - GLX_RENDER_TYPE, GLX_RGBA_BIT, - GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR, - GLX_BUFFER_SIZE, parameters.bitsPerPixel, - GLX_ALPHA_SIZE, (parameters.bitsPerPixel == 32) ? 8 : 0, - GLX_DEPTH_SIZE, parameters.depthBits, - GLX_STENCIL_SIZE, parameters.stencilBits, - GLX_DOUBLEBUFFER, True, - GLX_SAMPLE_BUFFERS, (parameters.antialiasingLevel > 0) ? True : False, - GLX_SAMPLES, parameters.antialiasingLevel, - None - }; - - int glx_major = 0; - int glx_minor = 0; - // FBConfigs were added in GLX version 1.3. - if (!glXQueryVersion(m_display, &glx_major, &glx_minor) || ((glx_major == 1) && (glx_minor < 3)) || (glx_major < 1)) - { - NazaraError("Invalid GLX version, version > 1.3 is required."); - return false; - } - - int fbcount; - GLXFBConfig* fbc = glXChooseFBConfig(m_display, XDefaultScreen(m_display), visual_attribs, &fbcount); - if (!fbc) - { - NazaraError("Failed to retrieve a framebuffer config"); - return false; - } - - // Pick the FB config/visual with the most samples per pixel - int best_fbc = -1; - int worst_fbc = -1; - int best_num_samp = -1; - int worst_num_samp = 999; - - for (int i = 0; i < fbcount; ++i) - { - XVisualInfo* vi = glXGetVisualFromFBConfig(m_display, fbc[i]); - - if (vi) - { - int samp_buf = 0, samples = 0; - glXGetFBConfigAttrib(m_display, fbc[i], GLX_SAMPLE_BUFFERS, &samp_buf); - glXGetFBConfigAttrib(m_display, fbc[i], GLX_SAMPLES , &samples ); - - if ((best_fbc < 0) || (samp_buf && (samples > best_num_samp))) - { - best_fbc = i; - best_num_samp = samples; - } - if ((worst_fbc < 0) || !samp_buf || (samples < worst_num_samp)) - { - worst_fbc = i; - worst_num_samp = samples; - } - } - XFree(vi); - } - - GLXFBConfig bestFbc = fbc[best_fbc]; - - // Be sure to free the FBConfig list allocated by glXChooseFBConfig() - XFree(fbc); - - // Get a visual - XVisualInfo* vi = glXGetVisualFromFBConfig(m_display, bestFbc); - if (!vi) - { - NazaraError("Failed to get best VisualInfo"); - return false; - } - - // If context is shared by multiple windows - if (parameters.window.type != WindowManager::Invalid) - { - NazaraAssert(parameters.window.type == WindowManager::X11, "Cannot create a context for a non-x11 window"); - - m_window = static_cast(parameters.window.x11.window); - m_ownsWindow = false; - } - else - { - XSetWindowAttributes swa; - swa.colormap = m_colormap = XCreateColormap( - m_display, - XRootWindow( - m_display, - vi->screen), - vi->visual, - AllocNone - ); - - swa.background_pixmap = None; - swa.border_pixel = 0; - swa.event_mask = StructureNotifyMask; - - if (!m_colormap) - { - NazaraError("Failed to create colormap for context"); - return false; - } - - m_window = XCreateWindow( - m_display, - XRootWindow( - m_display, - vi->screen), - 0, 0, // X, Y - 1, 1, // W H - 0, - vi->depth, - InputOutput, - vi->visual, - CWBorderPixel | CWColormap | CWEventMask, - &swa - ); - - m_ownsWindow = true; - } - - if (!m_window) - { - NazaraError("Failed to create window"); - return false; - } - - // Done with the visual info data - XFree(vi); - - // Install an X error handler so the application won't exit if GL 3.0 - // context allocation fails. - // - // Note this error handler is global. All display connections in all threads - // of a process use the same error handler, so be sure to guard against other - // threads issuing X commands while this code is running. - ctxErrorOccurred = false; - int (*oldHandler)(Display*, XErrorEvent*) = - XSetErrorHandler(&ctxErrorHandler); - - // Check for the GLX_ARB_create_context extension string and the function. - // If either is not present, use GLX 1.3 context creation method. - if (!glXCreateContextAttribs) - { - NazaraWarning("glXCreateContextAttribs() not found. Using old-style GLX context"); - m_context = glXCreateNewContext(m_display, bestFbc, GLX_RGBA_TYPE, parameters.shared ? parameters.shareContext->m_impl->m_context : 0, True); - } - // If it does, try to get a GL 3.0 context! - else - { - int profile = parameters.compatibilityProfile ? GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB : GLX_CONTEXT_CORE_PROFILE_BIT_ARB; - int debug = parameters.debugMode ? GLX_CONTEXT_DEBUG_BIT_ARB : 0; - - int major = 3;//parameters.majorVersion; - int minor = 3;//parameters.minorVersion; - - int context_attribs[] = - { - GLX_CONTEXT_MAJOR_VERSION_ARB, major, - GLX_CONTEXT_MINOR_VERSION_ARB, minor, - GLX_CONTEXT_PROFILE_MASK_ARB, profile, - GLX_CONTEXT_FLAGS_ARB, debug, - None, None - }; - - m_context = glXCreateContextAttribs( - m_display, - bestFbc, - parameters.shared ? parameters.shareContext->m_impl->m_context : 0, - True, - context_attribs - ); - } - - // Sync to ensure any errors generated are processed. - XSync(m_display, False); - XSetErrorHandler(oldHandler); - if (ctxErrorOccurred || !m_context) - { - NazaraError("Failed to create context, check the version"); - return false; - } - - onExit.Reset(); - - return true; - } - - void ContextImpl::Destroy() - { - // Destroy the context - if (m_context) - { - if (glXGetCurrentContext() == m_context) - glXMakeCurrent(m_display, None, nullptr); - glXDestroyContext(m_display, m_context); - m_context = nullptr; - } - - // Destroy the window if we own it - if (m_ownsWindow && m_window) - { - XFreeColormap(m_display, m_colormap); - XDestroyWindow(m_display, m_window); - m_ownsWindow = false; - m_window = 0; - XFlush(m_display); - } - } - - void ContextImpl::EnableVerticalSync(bool enabled) - { - if (glXSwapIntervalEXT) - glXSwapIntervalEXT(m_display, glXGetCurrentDrawable(), enabled ? 1 : 0); - else if (NzglXSwapIntervalMESA) - NzglXSwapIntervalMESA(enabled ? 1 : 0); - else if (glXSwapIntervalSGI) - glXSwapIntervalSGI(enabled ? 1 : 0); - else - NazaraError("Vertical sync not supported"); - } - - void ContextImpl::SwapBuffers() - { - if (m_window) - glXSwapBuffers(m_display, m_window); - } - - bool ContextImpl::Desactivate() - { - return glXMakeCurrent(m_display, None, nullptr) == true; - } -} diff --git a/src/Nazara/Renderer/GLX/Display.cpp b/src/Nazara/Renderer/GLX/Display.cpp deleted file mode 100644 index 647e22f19..000000000 --- a/src/Nazara/Renderer/GLX/Display.cpp +++ /dev/null @@ -1,246 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - namespace - { - // The shared display and its reference counter - xcb_connection_t* sharedConnection = nullptr; - int screen_nbr = 0; - unsigned int referenceCountConnection = 0; - - xcb_key_symbols_t* sharedkeySymbol = nullptr; - unsigned int referenceCountKeySymbol = 0; - - xcb_ewmh_connection_t* sharedEwmhConnection = nullptr; - unsigned int referenceCountEwmhConnection = 0; - - using AtomMap = std::unordered_map; - AtomMap atoms; - } - - bool X11::CheckCookie(xcb_connection_t* connection, xcb_void_cookie_t cookie) - { - ScopedXCB error(xcb_request_check( - connection, - cookie - )); - - if (error) - return false; - else - return true; - } - - void X11::CloseConnection(xcb_connection_t* connection) - { - NazaraAssert(connection == sharedConnection, "The model is meant for one connection to X11 server"); - --referenceCountConnection; - } - - void X11::CloseEWMHConnection(xcb_ewmh_connection_t* ewmh_connection) - { - NazaraAssert(ewmh_connection == sharedEwmhConnection, "The model is meant for one connection to X11 server"); - --referenceCountEwmhConnection; - } - - xcb_atom_t X11::GetAtom(const std::string& name, bool onlyIfExists) - { - auto iter = atoms.find(name); - - if (iter != atoms.end()) - return iter->second; - - ScopedXCB error(nullptr); - - xcb_connection_t* connection = OpenConnection(); - - ScopedXCB reply(xcb_intern_atom_reply( - connection, - xcb_intern_atom( - connection, - onlyIfExists, - name.size(), - name.data() - ), - &error - )); - - CloseConnection(connection); - - if (error || !reply) - { - NazaraError("Failed to get " + name + " atom."); - return XCB_ATOM_NONE; - } - - atoms[name] = reply->atom; - - return reply->atom; - } - - bool X11::Initialize() - { - if (IsInitialized()) - { - s_moduleReferenceCounter++; - return true; // Déjà initialisé - } - - s_moduleReferenceCounter++; - - NazaraAssert(referenceCountConnection == 0, "Initialize should be called before anything"); - NazaraAssert(referenceCountKeySymbol == 0, "Initialize should be called before anything"); - NazaraAssert(referenceCountEwmhConnection == 0, "Initialize should be called before anything"); - - { - sharedConnection = xcb_connect(nullptr, &screen_nbr); - - // Opening display failed: The best we can do at the moment is to output a meaningful error message - if (!sharedConnection || xcb_connection_has_error(sharedConnection)) - { - NazaraError("Failed to open xcb connection"); - return false; - } - - OpenConnection(); - } - - { - sharedkeySymbol = xcb_key_symbols_alloc(sharedConnection); - - XCBKeySymbolsAlloc(sharedConnection); - } - - { - sharedEwmhConnection = new xcb_ewmh_connection_t; - xcb_intern_atom_cookie_t* ewmh_cookie = xcb_ewmh_init_atoms(sharedConnection, sharedEwmhConnection); - - if(!xcb_ewmh_init_atoms_replies(sharedEwmhConnection, ewmh_cookie, nullptr)) - { - NazaraError("Could not initialize EWMH Connection"); - sharedEwmhConnection = nullptr; - } - - OpenEWMHConnection(sharedConnection); - } - - return true; - } - - bool X11::IsInitialized() - { - return s_moduleReferenceCounter != 0; - } - - xcb_key_symbols_t* X11::XCBKeySymbolsAlloc(xcb_connection_t* connection) - { - NazaraAssert(connection == sharedConnection, "The model is meant for one connection to X11 server"); - - ++referenceCountKeySymbol; - return sharedkeySymbol; - } - - void X11::XCBKeySymbolsFree(xcb_key_symbols_t* keySymbols) - { - NazaraAssert(keySymbols == sharedkeySymbol, "The model is meant for one connection to X11 server"); - - --referenceCountKeySymbol; - } - - xcb_connection_t* X11::OpenConnection() - { - ++referenceCountConnection; - return sharedConnection; - } - - xcb_ewmh_connection_t* X11::OpenEWMHConnection(xcb_connection_t* connection) - { - NazaraAssert(connection == sharedConnection, "The model is meant for one connection to X11 server"); - - ++referenceCountEwmhConnection; - return sharedEwmhConnection; - } - - void X11::Uninitialize() - { - if (s_moduleReferenceCounter != 1) - { - // Le module est soit encore utilisé, soit pas initialisé - if (s_moduleReferenceCounter > 1) - s_moduleReferenceCounter--; - - return; - } - - s_moduleReferenceCounter = 0; - - { - NazaraAssert(referenceCountEwmhConnection == 1, "Uninitialize should be called after anything or a close is missing"); - CloseEWMHConnection(sharedEwmhConnection); - - xcb_ewmh_connection_wipe(sharedEwmhConnection); - delete sharedEwmhConnection; - } - - { - NazaraAssert(referenceCountKeySymbol == 1, "Uninitialize should be called after anything or a free is missing"); - XCBKeySymbolsFree(sharedkeySymbol); - - xcb_key_symbols_free(sharedkeySymbol); - } - - { - NazaraAssert(referenceCountConnection == 1, "Uninitialize should be called after anything or a close is missing"); - CloseConnection(sharedConnection); - - xcb_disconnect(sharedConnection); - } - } - - xcb_window_t X11::XCBDefaultRootWindow(xcb_connection_t* connection) - { - NazaraAssert(connection == sharedConnection, "The model is meant for one connection to X11 server"); - xcb_screen_t* screen = XCBDefaultScreen(connection); - if (screen) - return screen->root; - return XCB_NONE; - } - - xcb_screen_t* X11::XCBDefaultScreen(xcb_connection_t* connection) - { - NazaraAssert(connection == sharedConnection, "The model is meant for one connection to X11 server"); - return XCBScreenOfDisplay(connection, screen_nbr); - } - - int X11::XCBScreen(xcb_connection_t* connection) - { - NazaraAssert(connection == sharedConnection, "The model is meant for one connection to X11 server"); - return 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"); - xcb_screen_iterator_t iter = xcb_setup_roots_iterator(xcb_get_setup(connection)); - - for (; iter.rem; --screenIndex, xcb_screen_next (&iter)) - { - if (screenIndex == 0) - return iter.data; - } - - return nullptr; - } - - unsigned int X11::s_moduleReferenceCounter = 0; -} diff --git a/src/Nazara/Renderer/GLX/Display.hpp b/src/Nazara/Renderer/GLX/Display.hpp deleted file mode 100644 index 95161914f..000000000 --- a/src/Nazara/Renderer/GLX/Display.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_X11DISPLAY_HPP -#define NAZARA_X11DISPLAY_HPP - -#include -#include -#include -#include -#include - -typedef struct _XCBKeySymbols xcb_key_symbols_t; - -namespace Nz -{ - class NAZARA_PLATFORM_API X11 - { - public: - X11() = delete; - ~X11() = delete; - - static bool CheckCookie(xcb_connection_t* connection, xcb_void_cookie_t cookie); - static void CloseConnection(xcb_connection_t* connection); - static void CloseEWMHConnection(xcb_ewmh_connection_t* ewmh_connection); - - static xcb_atom_t GetAtom(const std::string& name, bool onlyIfExists = false); - - static bool Initialize(); - static bool IsInitialized(); - - static xcb_key_symbols_t* XCBKeySymbolsAlloc(xcb_connection_t* connection); - static void XCBKeySymbolsFree(xcb_key_symbols_t* keySymbols); - - static xcb_connection_t* OpenConnection(); - static xcb_ewmh_connection_t* OpenEWMHConnection(xcb_connection_t* connection); - - static void Uninitialize(); - - static xcb_screen_t* XCBDefaultScreen(xcb_connection_t* connection); - static xcb_window_t XCBDefaultRootWindow(xcb_connection_t* connection); - static int XCBScreen(xcb_connection_t* connection); - static xcb_screen_t* XCBScreenOfDisplay(xcb_connection_t* connection, int screen_nbr); - - private: - static unsigned int s_moduleReferenceCounter; - }; -} - -#endif // NAZARA_X11DISPLAY_HPP diff --git a/src/Nazara/Renderer/GLX/ScopedXCB.cpp b/src/Nazara/Renderer/GLX/ScopedXCB.cpp deleted file mode 100644 index 35e19cd79..000000000 --- a/src/Nazara/Renderer/GLX/ScopedXCB.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - /*********************************************** - ScopedXCBConnection - ***********************************************/ - - ScopedXCBConnection::ScopedXCBConnection() : - m_connection(nullptr) - { - m_connection = X11::OpenConnection(); - } - - ScopedXCBConnection::~ScopedXCBConnection() - { - X11::CloseConnection(m_connection); - } - - ScopedXCBConnection::operator xcb_connection_t*() const - { - return m_connection; - } - - /*********************************************** - ScopedXCBEWMHConnection - ***********************************************/ - - ScopedXCBEWMHConnection::ScopedXCBEWMHConnection(xcb_connection_t* connection) : - m_ewmhConnection(nullptr) - { - m_ewmhConnection = X11::OpenEWMHConnection(connection); - } - - ScopedXCBEWMHConnection::~ScopedXCBEWMHConnection() - { - X11::CloseEWMHConnection(m_ewmhConnection); - } - - xcb_ewmh_connection_t* ScopedXCBEWMHConnection::operator ->() const - { - return m_ewmhConnection; - } - - ScopedXCBEWMHConnection::operator xcb_ewmh_connection_t*() const - { - return m_ewmhConnection; - } - - /*********************************************** - XCBGContext - ***********************************************/ - - XCBGContext::XCBGContext(xcb_connection_t* connection) : - m_connection(connection), - m_gcontext(XCB_NONE) - { - NazaraAssert(connection, "Connection must have been established"); - } - - XCBGContext::~XCBGContext() - { - Destroy(); - } - - bool XCBGContext::Create(xcb_drawable_t drawable, uint32_t value_mask, const uint32_t* value_list) - { - NazaraAssert(m_gcontext == XCB_NONE, "Context must have been destroyed before or just created"); - - m_gcontext = xcb_generate_id(m_connection); - - return X11::CheckCookie( - m_connection, - xcb_create_gc( - m_connection, - m_gcontext, - drawable, - value_mask, - value_list - )); - } - - void XCBGContext::Destroy() - { - if (m_gcontext == XCB_NONE) - return; - - if (!X11::CheckCookie( - m_connection, - xcb_free_gc( - m_connection, - m_gcontext - )) - ) - NazaraError("Failed to free gcontext"); - - m_gcontext = XCB_NONE; - } - - XCBGContext::operator xcb_gcontext_t() const - { - return m_gcontext; - } -} diff --git a/src/Nazara/Renderer/GLX/ScopedXCB.hpp b/src/Nazara/Renderer/GLX/ScopedXCB.hpp deleted file mode 100644 index b7c2c1fd2..000000000 --- a/src/Nazara/Renderer/GLX/ScopedXCB.hpp +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_SCOPEDXCB_HPP -#define NAZARA_SCOPEDXCB_HPP - -#include -#include -#include -#include - -namespace Nz -{ - class ScopedXCBConnection - { - public: - ScopedXCBConnection(); - ~ScopedXCBConnection(); - - operator xcb_connection_t*() const; - - private: - xcb_connection_t* m_connection; - }; - - class ScopedXCBEWMHConnection - { - public: - ScopedXCBEWMHConnection(xcb_connection_t* connection); - ~ScopedXCBEWMHConnection(); - - xcb_ewmh_connection_t* operator ->() const; - - operator xcb_ewmh_connection_t*() const; - - private: - xcb_ewmh_connection_t* m_ewmhConnection; - }; - - template - class ScopedXCB - { - public: - ScopedXCB(T* pointer); - ~ScopedXCB(); - - T* operator ->() const; - T** operator &(); - - operator bool() const; - - T* get() const; - - private: - T* m_pointer; - }; - - class XCBGContext - { - public: - XCBGContext(xcb_connection_t* connection); - ~XCBGContext(); - - bool Create(xcb_drawable_t drawable, uint32_t value_mask, const uint32_t* value_list); - - void Destroy(); - - operator xcb_gcontext_t() const; - - private: - xcb_connection_t* m_connection; - xcb_gcontext_t m_gcontext; - }; -} - -#include - -#endif // NAZARA_SCOPEDXCB_HPP diff --git a/src/Nazara/Renderer/GLX/ScopedXCB.inl b/src/Nazara/Renderer/GLX/ScopedXCB.inl deleted file mode 100644 index b25ae1178..000000000 --- a/src/Nazara/Renderer/GLX/ScopedXCB.inl +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include - -namespace Nz -{ - template - ScopedXCB::ScopedXCB(T* pointer) : - m_pointer(pointer) - { - } - - template - ScopedXCB::~ScopedXCB() - { - std::free(m_pointer); - } - - template - T* ScopedXCB::operator ->() const - { - return m_pointer; - } - - template - T** ScopedXCB::operator &() - { - return &m_pointer; - } - - template - ScopedXCB::operator bool() const - { - return m_pointer != nullptr; - } - - template - T* ScopedXCB::get() const - { - return m_pointer; - } -} - -#include diff --git a/src/Nazara/Shader/GlslWriter.cpp b/src/Nazara/Shader/GlslWriter.cpp index 39f2ec3ce..7be512c28 100644 --- a/src/Nazara/Shader/GlslWriter.cpp +++ b/src/Nazara/Shader/GlslWriter.cpp @@ -70,9 +70,9 @@ namespace Nz glslVersion = 320; else if (m_environment.glMajorVersion >= 3 && m_environment.glMinorVersion >= 1) glslVersion = 310; - else if (m_environment.glMajorVersion >= 3 && m_environment.glMinorVersion >= 0) + else if (m_environment.glMajorVersion >= 3) glslVersion = 300; - else if (m_environment.glMajorVersion >= 2 && m_environment.glMinorVersion >= 0) + else if (m_environment.glMajorVersion >= 2) glslVersion = 100; else throw std::runtime_error("This version of OpenGL ES does not support shaders"); @@ -85,11 +85,11 @@ namespace Nz glslVersion = 150; else if (m_environment.glMajorVersion >= 3 && m_environment.glMinorVersion >= 1) glslVersion = 140; - else if (m_environment.glMajorVersion >= 3 && m_environment.glMinorVersion >= 0) + else if (m_environment.glMajorVersion >= 3) glslVersion = 130; else if (m_environment.glMajorVersion >= 2 && m_environment.glMinorVersion >= 1) glslVersion = 120; - else if (m_environment.glMajorVersion >= 2 && m_environment.glMinorVersion >= 0) + else if (m_environment.glMajorVersion >= 2) glslVersion = 110; else throw std::runtime_error("This version of OpenGL does not support shaders"); diff --git a/src/Nazara/Shader/ShaderAstVisitorExcept.cpp b/src/Nazara/Shader/ShaderAstVisitorExcept.cpp index e61fcdb8c..419d073bb 100644 --- a/src/Nazara/Shader/ShaderAstVisitorExcept.cpp +++ b/src/Nazara/Shader/ShaderAstVisitorExcept.cpp @@ -8,67 +8,67 @@ namespace Nz { - void ShaderAstVisitorExcept::Visit(ShaderNodes::AccessMember& node) + void ShaderAstVisitorExcept::Visit(ShaderNodes::AccessMember& /*node*/) { throw std::runtime_error("unhandled AccessMember node"); } - void ShaderAstVisitorExcept::Visit(ShaderNodes::AssignOp& node) + void ShaderAstVisitorExcept::Visit(ShaderNodes::AssignOp& /*node*/) { throw std::runtime_error("unhandled AssignOp node"); } - void ShaderAstVisitorExcept::Visit(ShaderNodes::BinaryOp& node) + void ShaderAstVisitorExcept::Visit(ShaderNodes::BinaryOp& /*node*/) { throw std::runtime_error("unhandled AccessMember node"); } - void ShaderAstVisitorExcept::Visit(ShaderNodes::Branch& node) + void ShaderAstVisitorExcept::Visit(ShaderNodes::Branch& /*node*/) { throw std::runtime_error("unhandled Branch node"); } - void ShaderAstVisitorExcept::Visit(ShaderNodes::Cast& node) + void ShaderAstVisitorExcept::Visit(ShaderNodes::Cast& /*node*/) { throw std::runtime_error("unhandled Cast node"); } - void ShaderAstVisitorExcept::Visit(ShaderNodes::Constant& node) + void ShaderAstVisitorExcept::Visit(ShaderNodes::Constant& /*node*/) { throw std::runtime_error("unhandled Constant node"); } - void ShaderAstVisitorExcept::Visit(ShaderNodes::DeclareVariable& node) + void ShaderAstVisitorExcept::Visit(ShaderNodes::DeclareVariable& /*node*/) { throw std::runtime_error("unhandled DeclareVariable node"); } - void ShaderAstVisitorExcept::Visit(ShaderNodes::ExpressionStatement& node) + void ShaderAstVisitorExcept::Visit(ShaderNodes::ExpressionStatement& /*node*/) { throw std::runtime_error("unhandled ExpressionStatement node"); } - void ShaderAstVisitorExcept::Visit(ShaderNodes::Identifier& node) + void ShaderAstVisitorExcept::Visit(ShaderNodes::Identifier& /*node*/) { throw std::runtime_error("unhandled Identifier node"); } - void ShaderAstVisitorExcept::Visit(ShaderNodes::IntrinsicCall& node) + void ShaderAstVisitorExcept::Visit(ShaderNodes::IntrinsicCall& /*node*/) { throw std::runtime_error("unhandled IntrinsicCall node"); } - void ShaderAstVisitorExcept::Visit(ShaderNodes::Sample2D& node) + void ShaderAstVisitorExcept::Visit(ShaderNodes::Sample2D& /*node*/) { throw std::runtime_error("unhandled Sample2D node"); } - void ShaderAstVisitorExcept::Visit(ShaderNodes::StatementBlock& node) + void ShaderAstVisitorExcept::Visit(ShaderNodes::StatementBlock& /*node*/) { throw std::runtime_error("unhandled StatementBlock node"); } - void ShaderAstVisitorExcept::Visit(ShaderNodes::SwizzleOp& node) + void ShaderAstVisitorExcept::Visit(ShaderNodes::SwizzleOp& /*node*/) { throw std::runtime_error("unhandled SwizzleOp node"); } diff --git a/src/Nazara/Shader/ShaderVarVisitorExcept.cpp b/src/Nazara/Shader/ShaderVarVisitorExcept.cpp index 57b5bdddc..3629f86d1 100644 --- a/src/Nazara/Shader/ShaderVarVisitorExcept.cpp +++ b/src/Nazara/Shader/ShaderVarVisitorExcept.cpp @@ -8,32 +8,32 @@ namespace Nz { - void ShaderVarVisitorExcept::Visit(ShaderNodes::BuiltinVariable& var) + void ShaderVarVisitorExcept::Visit(ShaderNodes::BuiltinVariable& /*var*/) { throw std::runtime_error("unhandled BuiltinVariable"); } - void ShaderVarVisitorExcept::Visit(ShaderNodes::InputVariable& var) + void ShaderVarVisitorExcept::Visit(ShaderNodes::InputVariable& /*var*/) { throw std::runtime_error("unhandled InputVariable"); } - void ShaderVarVisitorExcept::Visit(ShaderNodes::LocalVariable& var) + void ShaderVarVisitorExcept::Visit(ShaderNodes::LocalVariable& /*var*/) { throw std::runtime_error("unhandled LocalVariable"); } - void ShaderVarVisitorExcept::Visit(ShaderNodes::OutputVariable& var) + void ShaderVarVisitorExcept::Visit(ShaderNodes::OutputVariable& /*var*/) { throw std::runtime_error("unhandled OutputVariable"); } - void ShaderVarVisitorExcept::Visit(ShaderNodes::ParameterVariable& var) + void ShaderVarVisitorExcept::Visit(ShaderNodes::ParameterVariable& /*var*/) { throw std::runtime_error("unhandled ParameterVariable"); } - void ShaderVarVisitorExcept::Visit(ShaderNodes::UniformVariable& var) + void ShaderVarVisitorExcept::Visit(ShaderNodes::UniformVariable& /*var*/) { throw std::runtime_error("unhandled UniformVariable"); } diff --git a/src/Nazara/Shader/SpirvAstVisitor.cpp b/src/Nazara/Shader/SpirvAstVisitor.cpp index 6cf45cee7..e066337a9 100644 --- a/src/Nazara/Shader/SpirvAstVisitor.cpp +++ b/src/Nazara/Shader/SpirvAstVisitor.cpp @@ -88,6 +88,8 @@ namespace Nz case ShaderNodes::BasicType::Void: break; } + + break; } case ShaderNodes::BinaryType::Substract: @@ -116,6 +118,8 @@ namespace Nz case ShaderNodes::BasicType::Void: break; } + + break; } case ShaderNodes::BinaryType::Divide: @@ -146,6 +150,8 @@ namespace Nz case ShaderNodes::BasicType::Void: break; } + + break; } case ShaderNodes::BinaryType::Equality: @@ -176,6 +182,8 @@ namespace Nz case ShaderNodes::BasicType::Void: break; } + + break; } case ShaderNodes::BinaryType::Multiply: @@ -258,6 +266,7 @@ namespace Nz default: break; } + break; } } diff --git a/src/Nazara/Shader/SpirvConstantCache.cpp b/src/Nazara/Shader/SpirvConstantCache.cpp index 03611c8cd..256cc73b7 100644 --- a/src/Nazara/Shader/SpirvConstantCache.cpp +++ b/src/Nazara/Shader/SpirvConstantCache.cpp @@ -483,7 +483,7 @@ namespace Nz void SpirvConstantCache::Write(SpirvSection& annotations, SpirvSection& constants, SpirvSection& debugInfos) { - for (auto&& [type, id] : m_internal->ids) + for (auto&& [object, id] : m_internal->ids) { UInt32 resultId = id; @@ -491,7 +491,7 @@ namespace Nz { [&](const AnyConstant& constant) { Write(constant, resultId, constants); }, [&](const AnyType& type) { Write(type, resultId, annotations, constants, debugInfos); }, - }, type); + }, object); } for (auto&& [variable, id] : m_internal->variableIds) @@ -677,51 +677,51 @@ namespace Nz void SpirvConstantCache::Write(const AnyConstant& constant, UInt32 resultId, SpirvSection& constants) { - std::visit([&](auto&& arg) + std::visit([&](auto&& constant) { - using T = std::decay_t; + using ConstantType = std::decay_t; - if constexpr (std::is_same_v) - constants.Append((arg.value) ? SpirvOp::OpConstantTrue : SpirvOp::OpConstantFalse, resultId); - else if constexpr (std::is_same_v) + if constexpr (std::is_same_v) + constants.Append((constant.value) ? SpirvOp::OpConstantTrue : SpirvOp::OpConstantFalse, resultId); + else if constexpr (std::is_same_v) { constants.AppendVariadic(SpirvOp::OpConstantComposite, [&](const auto& appender) { - appender(GetId(arg.type->type)); + appender(GetId(constant.type->type)); appender(resultId); - for (const auto& value : arg.values) + for (const auto& value : constant.values) appender(GetId(value->constant)); }); } - else if constexpr (std::is_same_v) + else if constexpr (std::is_same_v) { - std::visit([&](auto&& arg) + std::visit([&](auto&& value) { - using T = std::decay_t; + using ValueType = std::decay_t; UInt32 typeId; - if constexpr (std::is_same_v) + if constexpr (std::is_same_v) typeId = GetId({ Float{ 64 } }); - else if constexpr (std::is_same_v) + else if constexpr (std::is_same_v) typeId = GetId({ Float{ 32 } }); - else if constexpr (std::is_same_v) + else if constexpr (std::is_same_v) typeId = GetId({ Integer{ 32, 1 } }); - else if constexpr (std::is_same_v) + else if constexpr (std::is_same_v) typeId = GetId({ Integer{ 64, 1 } }); - else if constexpr (std::is_same_v) + else if constexpr (std::is_same_v) typeId = GetId({ Integer{ 32, 0 } }); - else if constexpr (std::is_same_v) + else if constexpr (std::is_same_v) typeId = GetId({ Integer{ 64, 0 } }); else - static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); - constants.Append(SpirvOp::OpConstant, typeId, resultId, SpirvSection::Raw{ &arg, sizeof(arg) }); + constants.Append(SpirvOp::OpConstant, typeId, resultId, SpirvSection::Raw{ &value, sizeof(value) }); - }, arg.value); + }, constant.value); } else - static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); }, constant); } diff --git a/src/Nazara/Utility/RichTextDrawer.cpp b/src/Nazara/Utility/RichTextDrawer.cpp index 2c4ef43c2..7f42ff235 100644 --- a/src/Nazara/Utility/RichTextDrawer.cpp +++ b/src/Nazara/Utility/RichTextDrawer.cpp @@ -14,10 +14,10 @@ namespace Nz m_defaultOutlineColor(Color::Black), m_defaultStyle(TextStyle_Regular), m_glyphUpdated(false), - m_maxLineWidth(std::numeric_limits::infinity()), m_defaultCharacterSpacingOffset(0.f), m_defaultLineSpacingOffset(0.f), m_defaultOutlineThickness(0.f), + m_maxLineWidth(std::numeric_limits::infinity()), m_defaultCharacterSize(24) { SetDefaultFont(Font::GetDefault()); diff --git a/src/Nazara/Utility/UniformBuffer.cpp b/src/Nazara/Utility/UniformBuffer.cpp index 8e3d58668..4e0d83f15 100644 --- a/src/Nazara/Utility/UniformBuffer.cpp +++ b/src/Nazara/Utility/UniformBuffer.cpp @@ -97,11 +97,11 @@ namespace Nz m_buffer = Buffer::New(BufferType_Uniform, m_endOffset, storage, usage); } - void UniformBuffer::Reset(const UniformBuffer& UniformBuffer) + void UniformBuffer::Reset(const UniformBuffer& uniformBuffer) { - m_buffer = UniformBuffer.m_buffer; - m_endOffset = UniformBuffer.m_endOffset; - m_startOffset = UniformBuffer.m_startOffset; + m_buffer = uniformBuffer.m_buffer; + m_endOffset = uniformBuffer.m_endOffset; + m_startOffset = uniformBuffer.m_startOffset; } void UniformBuffer::Unmap() const