From 1734b8e5db030ebd53fedceded84c44f3fc06f37 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 27 May 2020 20:37:20 +0200 Subject: [PATCH 01/20] SDL fixes --- build/scripts/modules/platform.lua | 9 +++++++++ src/Nazara/Platform/SDL2/WindowImpl.cpp | 2 +- thirdparty/include/SDL2/SDL_config.h | 1 - 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/build/scripts/modules/platform.lua b/build/scripts/modules/platform.lua index 9a04ca3e8..e3be1e0be 100644 --- a/build/scripts/modules/platform.lua +++ b/build/scripts/modules/platform.lua @@ -16,3 +16,12 @@ MODULE.Files = { "../src/Nazara/Platform/SDL2/**.hpp", "../src/Nazara/Platform/SDL2/**.cpp" } + +MODULE.OsDefines.Windows = { + "SDL_VIDEO_DRIVER_WINDOWS=1" +} + +MODULE.OsDefines.Posix = { + "SDL_VIDEO_DRIVER_X11=1", + "SDL_VIDEO_DRIVER_WAYLAND=1", +} diff --git a/src/Nazara/Platform/SDL2/WindowImpl.cpp b/src/Nazara/Platform/SDL2/WindowImpl.cpp index acbbc8382..29ea02862 100644 --- a/src/Nazara/Platform/SDL2/WindowImpl.cpp +++ b/src/Nazara/Platform/SDL2/WindowImpl.cpp @@ -129,7 +129,7 @@ namespace Nz bool WindowImpl::Create(void* handle) { m_handle = SDL_CreateWindowFrom(handle); - if (!m_handle || !SDL_GetWindowID(m_handle)) + if (!m_handle) { NazaraError("Invalid handle"); return false; diff --git a/thirdparty/include/SDL2/SDL_config.h b/thirdparty/include/SDL2/SDL_config.h index f269bfc04..efebe9f02 100644 --- a/thirdparty/include/SDL2/SDL_config.h +++ b/thirdparty/include/SDL2/SDL_config.h @@ -214,7 +214,6 @@ typedef unsigned int uintptr_t; /* Enable various video drivers */ #define SDL_VIDEO_DRIVER_DUMMY 1 -#define SDL_VIDEO_DRIVER_WINDOWS 1 #ifndef SDL_VIDEO_RENDER_D3D #define SDL_VIDEO_RENDER_D3D 1 From 2efb6baaa625717315ca1814cbcbf7b41f362b54 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 27 May 2020 20:43:42 +0200 Subject: [PATCH 02/20] Linux fix --- include/Nazara/Platform/WindowHandle.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Platform/WindowHandle.hpp b/include/Nazara/Platform/WindowHandle.hpp index c6053f4bf..90815b021 100644 --- a/include/Nazara/Platform/WindowHandle.hpp +++ b/include/Nazara/Platform/WindowHandle.hpp @@ -30,7 +30,7 @@ namespace Nz struct { void* display; //< Display* - void* window; //< Window + unsigned long window; //< Window } x11; struct From 7ed0543ad2ae64ddb8e5598e6db271ed21bc7537 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 27 May 2020 20:52:04 +0200 Subject: [PATCH 03/20] Add NAZARA_PLATFORM_GLX back --- include/Nazara/Prerequisites.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/Nazara/Prerequisites.hpp b/include/Nazara/Prerequisites.hpp index 24bc14dc1..4187f4c3d 100644 --- a/include/Nazara/Prerequisites.hpp +++ b/include/Nazara/Prerequisites.hpp @@ -119,6 +119,8 @@ #define NAZARA_PLATFORM_LINUX #define NAZARA_PLATFORM_POSIX + #define NAZARA_PLATFORM_GLX + #define NAZARA_EXPORT __attribute__((visibility ("default"))) #define NAZARA_IMPORT __attribute__((visibility ("default"))) /*#elif defined(__APPLE__) && defined(__MACH__) From 4f9380da1199d15c67bb7f814300bafa5c6b8e63 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 27 May 2020 21:01:14 +0200 Subject: [PATCH 04/20] More Linux fixes --- include/Nazara/Platform/WindowHandle.hpp | 4 ++-- include/Nazara/Renderer/OpenGL.hpp | 3 ++- src/Nazara/Renderer/GLX/ContextImpl.cpp | 2 +- src/Nazara/Renderer/Win32/ContextImpl.cpp | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/Nazara/Platform/WindowHandle.hpp b/include/Nazara/Platform/WindowHandle.hpp index 90815b021..9dfb10bde 100644 --- a/include/Nazara/Platform/WindowHandle.hpp +++ b/include/Nazara/Platform/WindowHandle.hpp @@ -14,7 +14,7 @@ namespace Nz { enum class WindowManager { - None, + Invalid, X11, Wayland, @@ -23,7 +23,7 @@ namespace Nz struct WindowHandle { - WindowManager type = WindowManager::None; + WindowManager type = WindowManager::Invalid; union { diff --git a/include/Nazara/Renderer/OpenGL.hpp b/include/Nazara/Renderer/OpenGL.hpp index 77fe10ad3..f2dcd21ec 100644 --- a/include/Nazara/Renderer/OpenGL.hpp +++ b/include/Nazara/Renderer/OpenGL.hpp @@ -27,8 +27,9 @@ namespace GLX { #include // Defined in a namespace to avoid conflict -} #include +} + #endif namespace Nz diff --git a/src/Nazara/Renderer/GLX/ContextImpl.cpp b/src/Nazara/Renderer/GLX/ContextImpl.cpp index d7a4fa425..572c6eace 100644 --- a/src/Nazara/Renderer/GLX/ContextImpl.cpp +++ b/src/Nazara/Renderer/GLX/ContextImpl.cpp @@ -141,7 +141,7 @@ namespace Nz } // If context is shared by multiple windows - if (parameters.window) + if (parameters.window.type != WindowManager::Invalid) { NazaraAssert(parameters.window.type == WindowManager::X11, "Cannot create a context for a non-x11 window"); diff --git a/src/Nazara/Renderer/Win32/ContextImpl.cpp b/src/Nazara/Renderer/Win32/ContextImpl.cpp index 71aa5f1e1..1eec82fa6 100644 --- a/src/Nazara/Renderer/Win32/ContextImpl.cpp +++ b/src/Nazara/Renderer/Win32/ContextImpl.cpp @@ -25,7 +25,7 @@ namespace Nz bool ContextImpl::Create(ContextParameters& parameters) { - if (parameters.window.type != WindowManager::None) + if (parameters.window.type != WindowManager::Invalid) { NazaraAssert(parameters.window.type == WindowManager::Windows, "Cannot create a context for a non-win32 window"); From 3f5b041a8163733599932e6fd3549f59b73107b2 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 27 May 2020 21:16:59 +0200 Subject: [PATCH 05/20] Add some GLX files back --- src/Nazara/Renderer/GLX/Display.cpp | 246 ++++++++++++++++++++++++++ src/Nazara/Renderer/GLX/Display.hpp | 53 ++++++ src/Nazara/Renderer/GLX/ScopedXCB.cpp | 199 +++++++++++++++++++++ src/Nazara/Renderer/GLX/ScopedXCB.hpp | 101 +++++++++++ src/Nazara/Renderer/GLX/ScopedXCB.inl | 46 +++++ 5 files changed, 645 insertions(+) create mode 100644 src/Nazara/Renderer/GLX/Display.cpp create mode 100644 src/Nazara/Renderer/GLX/Display.hpp create mode 100644 src/Nazara/Renderer/GLX/ScopedXCB.cpp create mode 100644 src/Nazara/Renderer/GLX/ScopedXCB.hpp create mode 100644 src/Nazara/Renderer/GLX/ScopedXCB.inl diff --git a/src/Nazara/Renderer/GLX/Display.cpp b/src/Nazara/Renderer/GLX/Display.cpp new file mode 100644 index 000000000..e8c3b51cd --- /dev/null +++ b/src/Nazara/Renderer/GLX/Display.cpp @@ -0,0 +1,246 @@ +// 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.GetSize(), + name.GetConstBuffer() + ), + &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 new file mode 100644 index 000000000..95161914f --- /dev/null +++ b/src/Nazara/Renderer/GLX/Display.hpp @@ -0,0 +1,53 @@ +// 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 new file mode 100644 index 000000000..34725ec01 --- /dev/null +++ b/src/Nazara/Renderer/GLX/ScopedXCB.cpp @@ -0,0 +1,199 @@ +// 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 + +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; + } + + /*********************************************** + XCBPixmap + ***********************************************/ + + XCBPixmap::XCBPixmap() : + m_connection(nullptr), + m_pixmap(XCB_NONE) + { + } + + XCBPixmap::XCBPixmap(xcb_connection_t* connection) : + m_connection(connection), + m_pixmap(XCB_NONE) + { + } + + XCBPixmap::~XCBPixmap() + { + Destroy(); + } + + void XCBPixmap::Connect(xcb_connection_t* connection) + { + NazaraAssert(connection && !m_connection, "Connection must be established"); + + m_connection = connection; + } + + bool XCBPixmap::Create(uint8_t depth, xcb_drawable_t drawable, uint16_t width, uint16_t height) + { + NazaraAssert(m_pixmap == XCB_NONE, "Pixmap must have been destroyed before or just created"); + + m_pixmap = xcb_generate_id(m_connection); + + return X11::CheckCookie( + m_connection, + xcb_create_pixmap( + m_connection, + depth, + m_pixmap, + drawable, + width, + height + )); + } + + bool XCBPixmap::CreatePixmapFromBitmapData(xcb_drawable_t drawable, uint8_t* data, uint32_t width, uint32_t height, uint32_t depth, uint32_t fg, uint32_t bg, xcb_gcontext_t* gcp) + { + NazaraAssert(m_pixmap == XCB_NONE, "Pixmap must have been destroyed before or just created"); + + m_pixmap = xcb_create_pixmap_from_bitmap_data( + m_connection, + drawable, + data, + width, + height, + depth, + fg, + bg, + gcp + ); + + return m_pixmap != XCB_NONE; + } + + void XCBPixmap::Destroy() + { + if (m_pixmap == XCB_NONE) + return; + + if (!X11::CheckCookie( + m_connection, + xcb_free_pixmap( + m_connection, + m_pixmap + )) + ) + NazaraError("Failed to free pixmap"); + + m_pixmap = XCB_NONE; + } + + XCBPixmap::operator xcb_pixmap_t() const + { + return m_pixmap; + } +} diff --git a/src/Nazara/Renderer/GLX/ScopedXCB.hpp b/src/Nazara/Renderer/GLX/ScopedXCB.hpp new file mode 100644 index 000000000..5070cc666 --- /dev/null +++ b/src/Nazara/Renderer/GLX/ScopedXCB.hpp @@ -0,0 +1,101 @@ +// 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; + }; + + class XCBPixmap + { + public: + XCBPixmap(); + XCBPixmap(xcb_connection_t* connection); + ~XCBPixmap(); + + void Connect(xcb_connection_t* connection); + bool Create(uint8_t depth, xcb_drawable_t drawable, uint16_t width, uint16_t height); + bool CreatePixmapFromBitmapData(xcb_drawable_t drawable, uint8_t* data, uint32_t width, uint32_t height, uint32_t depth, uint32_t fg, uint32_t bg, xcb_gcontext_t* gcp); + + void Destroy(); + + operator xcb_pixmap_t() const; + + private: + xcb_connection_t* m_connection; + xcb_pixmap_t m_pixmap; + }; +} + +#include + +#endif // NAZARA_SCOPEDXCB_HPP diff --git a/src/Nazara/Renderer/GLX/ScopedXCB.inl b/src/Nazara/Renderer/GLX/ScopedXCB.inl new file mode 100644 index 000000000..b25ae1178 --- /dev/null +++ b/src/Nazara/Renderer/GLX/ScopedXCB.inl @@ -0,0 +1,46 @@ +// 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 From 89504de465b92e71d1464cf12efe880a3e278ddf Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 27 May 2020 21:24:56 +0200 Subject: [PATCH 06/20] More commits for science --- src/Nazara/Renderer/GLX/Display.cpp | 4 ++-- src/Nazara/Renderer/GLX/ScopedXCB.cpp | 4 ++-- src/Nazara/Renderer/GLX/ScopedXCB.hpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Nazara/Renderer/GLX/Display.cpp b/src/Nazara/Renderer/GLX/Display.cpp index e8c3b51cd..f9ffd14fa 100644 --- a/src/Nazara/Renderer/GLX/Display.cpp +++ b/src/Nazara/Renderer/GLX/Display.cpp @@ -2,9 +2,9 @@ // 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 #include #include diff --git a/src/Nazara/Renderer/GLX/ScopedXCB.cpp b/src/Nazara/Renderer/GLX/ScopedXCB.cpp index 34725ec01..576f918f2 100644 --- a/src/Nazara/Renderer/GLX/ScopedXCB.cpp +++ b/src/Nazara/Renderer/GLX/ScopedXCB.cpp @@ -2,9 +2,9 @@ // 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 #include diff --git a/src/Nazara/Renderer/GLX/ScopedXCB.hpp b/src/Nazara/Renderer/GLX/ScopedXCB.hpp index 5070cc666..dc9a4ff1d 100644 --- a/src/Nazara/Renderer/GLX/ScopedXCB.hpp +++ b/src/Nazara/Renderer/GLX/ScopedXCB.hpp @@ -96,6 +96,6 @@ namespace Nz }; } -#include +#include #endif // NAZARA_SCOPEDXCB_HPP From fc4189b47fc772bb71ed46193bef39c6da48b844 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 27 May 2020 21:30:46 +0200 Subject: [PATCH 07/20] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0b9ee6567..4e2c0f4d0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM debian:buster -RUN apt-get update && apt-get install -y build-essential clang libopenal-dev libsndfile1-dev libfreetype6-dev libassimp-dev libsdl2-dev +RUN apt-get update && apt-get install -y build-essential clang libopenal-dev libsndfile1-dev libfreetype6-dev libassimp-dev libsdl2-dev libxcb-keysyms1-dev libx11-dev libfreetype6-dev mesa-common-dev libgl1-mesa-dev RUN mkdir /NazaraEngine WORKDIR /NazaraEngine \ No newline at end of file From 16652f79ebb4257ca2e8351df84f9bdc0cca5dd6 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 27 May 2020 21:36:44 +0200 Subject: [PATCH 08/20] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4e2c0f4d0..b1ab55789 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM debian:buster -RUN apt-get update && apt-get install -y build-essential clang libopenal-dev libsndfile1-dev libfreetype6-dev libassimp-dev libsdl2-dev libxcb-keysyms1-dev libx11-dev libfreetype6-dev mesa-common-dev libgl1-mesa-dev +RUN apt-get update && apt-get install -y build-essential clang libopenal-dev libsndfile1-dev libfreetype6-dev libassimp-dev libsdl2-dev libxcb-keysyms1-dev libxcb-ewmh-dev libx11-dev libfreetype6-dev mesa-common-dev libgl1-mesa-dev RUN mkdir /NazaraEngine WORKDIR /NazaraEngine \ No newline at end of file From 85a5e8eeddd7a6796eefedaa1016909ff2bf4841 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 27 May 2020 22:57:32 +0200 Subject: [PATCH 09/20] Fix compilation --- src/Nazara/Renderer/GLX/Display.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Renderer/GLX/Display.cpp b/src/Nazara/Renderer/GLX/Display.cpp index f9ffd14fa..647e22f19 100644 --- a/src/Nazara/Renderer/GLX/Display.cpp +++ b/src/Nazara/Renderer/GLX/Display.cpp @@ -69,8 +69,8 @@ namespace Nz xcb_intern_atom( connection, onlyIfExists, - name.GetSize(), - name.GetConstBuffer() + name.size(), + name.data() ), &error )); From a1d7bc49c207ae579f88d006760a84629c10b82f Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 27 May 2020 23:45:31 +0200 Subject: [PATCH 10/20] Update ScopedXCB.cpp --- src/Nazara/Renderer/GLX/ScopedXCB.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Renderer/GLX/ScopedXCB.cpp b/src/Nazara/Renderer/GLX/ScopedXCB.cpp index 576f918f2..e92f8f382 100644 --- a/src/Nazara/Renderer/GLX/ScopedXCB.cpp +++ b/src/Nazara/Renderer/GLX/ScopedXCB.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include From 0f36131d9d5c9c0dd23fbf6d5d7afc86369d7194 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 28 May 2020 00:00:48 +0200 Subject: [PATCH 11/20] Remove dependency to xcb_image --- src/Nazara/Renderer/GLX/ScopedXCB.cpp | 88 --------------------------- src/Nazara/Renderer/GLX/ScopedXCB.hpp | 20 ------ 2 files changed, 108 deletions(-) diff --git a/src/Nazara/Renderer/GLX/ScopedXCB.cpp b/src/Nazara/Renderer/GLX/ScopedXCB.cpp index e92f8f382..35e19cd79 100644 --- a/src/Nazara/Renderer/GLX/ScopedXCB.cpp +++ b/src/Nazara/Renderer/GLX/ScopedXCB.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include namespace Nz @@ -109,91 +108,4 @@ namespace Nz { return m_gcontext; } - - /*********************************************** - XCBPixmap - ***********************************************/ - - XCBPixmap::XCBPixmap() : - m_connection(nullptr), - m_pixmap(XCB_NONE) - { - } - - XCBPixmap::XCBPixmap(xcb_connection_t* connection) : - m_connection(connection), - m_pixmap(XCB_NONE) - { - } - - XCBPixmap::~XCBPixmap() - { - Destroy(); - } - - void XCBPixmap::Connect(xcb_connection_t* connection) - { - NazaraAssert(connection && !m_connection, "Connection must be established"); - - m_connection = connection; - } - - bool XCBPixmap::Create(uint8_t depth, xcb_drawable_t drawable, uint16_t width, uint16_t height) - { - NazaraAssert(m_pixmap == XCB_NONE, "Pixmap must have been destroyed before or just created"); - - m_pixmap = xcb_generate_id(m_connection); - - return X11::CheckCookie( - m_connection, - xcb_create_pixmap( - m_connection, - depth, - m_pixmap, - drawable, - width, - height - )); - } - - bool XCBPixmap::CreatePixmapFromBitmapData(xcb_drawable_t drawable, uint8_t* data, uint32_t width, uint32_t height, uint32_t depth, uint32_t fg, uint32_t bg, xcb_gcontext_t* gcp) - { - NazaraAssert(m_pixmap == XCB_NONE, "Pixmap must have been destroyed before or just created"); - - m_pixmap = xcb_create_pixmap_from_bitmap_data( - m_connection, - drawable, - data, - width, - height, - depth, - fg, - bg, - gcp - ); - - return m_pixmap != XCB_NONE; - } - - void XCBPixmap::Destroy() - { - if (m_pixmap == XCB_NONE) - return; - - if (!X11::CheckCookie( - m_connection, - xcb_free_pixmap( - m_connection, - m_pixmap - )) - ) - NazaraError("Failed to free pixmap"); - - m_pixmap = XCB_NONE; - } - - XCBPixmap::operator xcb_pixmap_t() const - { - return m_pixmap; - } } diff --git a/src/Nazara/Renderer/GLX/ScopedXCB.hpp b/src/Nazara/Renderer/GLX/ScopedXCB.hpp index dc9a4ff1d..b7c2c1fd2 100644 --- a/src/Nazara/Renderer/GLX/ScopedXCB.hpp +++ b/src/Nazara/Renderer/GLX/ScopedXCB.hpp @@ -74,26 +74,6 @@ namespace Nz xcb_connection_t* m_connection; xcb_gcontext_t m_gcontext; }; - - class XCBPixmap - { - public: - XCBPixmap(); - XCBPixmap(xcb_connection_t* connection); - ~XCBPixmap(); - - void Connect(xcb_connection_t* connection); - bool Create(uint8_t depth, xcb_drawable_t drawable, uint16_t width, uint16_t height); - bool CreatePixmapFromBitmapData(xcb_drawable_t drawable, uint8_t* data, uint32_t width, uint32_t height, uint32_t depth, uint32_t fg, uint32_t bg, xcb_gcontext_t* gcp); - - void Destroy(); - - operator xcb_pixmap_t() const; - - private: - xcb_connection_t* m_connection; - xcb_pixmap_t m_pixmap; - }; } #include From f8779915d39c575807554a8a3eb8747a0ace71bc Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 28 May 2020 00:10:40 +0200 Subject: [PATCH 12/20] Update OpenGL.cpp --- src/Nazara/Renderer/OpenGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Renderer/OpenGL.cpp b/src/Nazara/Renderer/OpenGL.cpp index 1c6ac00dd..163a5f69b 100644 --- a/src/Nazara/Renderer/OpenGL.cpp +++ b/src/Nazara/Renderer/OpenGL.cpp @@ -10,7 +10,7 @@ #include #include #if defined(NAZARA_PLATFORM_GLX) -#include +#include #endif // NAZARA_PLATFORM_GLX #include #include From 2db78f5b103424ee4712726b037f4944703a9e42 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 28 May 2020 00:22:54 +0200 Subject: [PATCH 13/20] Seriously --- src/Nazara/Renderer/OpenGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Renderer/OpenGL.cpp b/src/Nazara/Renderer/OpenGL.cpp index 163a5f69b..608e50a34 100644 --- a/src/Nazara/Renderer/OpenGL.cpp +++ b/src/Nazara/Renderer/OpenGL.cpp @@ -10,7 +10,7 @@ #include #include #if defined(NAZARA_PLATFORM_GLX) -#include +#include #endif // NAZARA_PLATFORM_GLX #include #include From 296ef435298042f735927da76cd4cb2262142a03 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 28 May 2020 01:46:19 +0200 Subject: [PATCH 14/20] Update renderer.lua --- build/scripts/modules/renderer.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build/scripts/modules/renderer.lua b/build/scripts/modules/renderer.lua index df10e2910..af1061f45 100644 --- a/build/scripts/modules/renderer.lua +++ b/build/scripts/modules/renderer.lua @@ -30,6 +30,8 @@ MODULE.OsLibraries.Windows = { MODULE.OsLibraries.Posix = { "GL", - "X11" + "X11", + "xcb", + "xcb-ewmh", + "xcb-keysyms" } - From ad687b2afe33303be8d1cd786b0be8e4c91f830f Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 2 Jun 2020 16:24:31 +0200 Subject: [PATCH 15/20] Demo/SpaceBattle: Fix mouse --- examples/Particles/SpacebattleDemo.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/Particles/SpacebattleDemo.cpp b/examples/Particles/SpacebattleDemo.cpp index 3703c427d..2ebc0969f 100644 --- a/examples/Particles/SpacebattleDemo.cpp +++ b/examples/Particles/SpacebattleDemo.cpp @@ -674,10 +674,14 @@ void SpacebattleExample::Enter(Ndk::StateMachine& fsm) Nz::Boxf introAABB = introGfx.GetAABB(); introNode.SetPosition(cannonNode.GetForward() * 500.f + introNode.GetLeft() * introAABB.width / 2.f + introNode.GetUp() * introAABB.height / 2.f); + + Nz::Mouse::SetRelativeMouseMode(true); } void SpacebattleExample::Leave(Ndk::StateMachine& fsm) { + Nz::Mouse::SetRelativeMouseMode(false); + m_ambientMusic.Stop(); m_onMouseMoved.Disconnect(); if (m_shared.target) @@ -836,7 +840,4 @@ void SpacebattleExample::OnMouseMoved(const Nz::EventHandler* /*eventHandler*/, m_turretCannonBaseRotation = Nz::Clamp(m_turretCannonBaseRotation + speed * event.deltaY, -65.f, 40.f); m_turretBaseRotation -= event.deltaX * speed; - - Nz::Vector2ui size = m_shared.target->GetSize(); - Nz::Mouse::SetPosition(size.x / 2, size.y / 2, *m_shared.target); } From 1b4199c0a7a600be1dd1d59cae40ced1ef007ede Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 2 Jun 2020 16:40:08 +0200 Subject: [PATCH 16/20] Platform/SDL2: Don't SDL_PumpEvents when not owning Windows This is a temporary fix --- src/Nazara/Platform/SDL2/WindowImpl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Nazara/Platform/SDL2/WindowImpl.cpp b/src/Nazara/Platform/SDL2/WindowImpl.cpp index 29ea02862..e2a71f27b 100644 --- a/src/Nazara/Platform/SDL2/WindowImpl.cpp +++ b/src/Nazara/Platform/SDL2/WindowImpl.cpp @@ -289,7 +289,8 @@ namespace Nz void WindowImpl::ProcessEvents(bool block) { - SDL_PumpEvents(); + if (m_ownsWindow) + SDL_PumpEvents(); /*if (m_ownsWindow) From 52c24e76dbf2dcd1169c8a41e9bf59fe7b2573ea Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 2 Jun 2020 17:06:01 +0200 Subject: [PATCH 17/20] SDK/Physics2D: Fix entity rotation not being taken into account for static physics --- SDK/src/NDK/Components/PhysicsComponent2D.cpp | 8 +++++++- SDK/src/NDK/Systems/PhysicsSystem2D.cpp | 17 +++++++---------- include/Nazara/Math/Quaternion.hpp | 1 + include/Nazara/Math/Quaternion.inl | 16 +++++++++++++++- 4 files changed, 30 insertions(+), 12 deletions(-) diff --git a/SDK/src/NDK/Components/PhysicsComponent2D.cpp b/SDK/src/NDK/Components/PhysicsComponent2D.cpp index 871fa762e..3ad5616e6 100644 --- a/SDK/src/NDK/Components/PhysicsComponent2D.cpp +++ b/SDK/src/NDK/Components/PhysicsComponent2D.cpp @@ -51,9 +51,15 @@ namespace Ndk m_object = std::make_unique(&world, 1.f, geom); m_object->SetPositionOffset(positionOffset); - m_object->SetPosition(Nz::Vector2f(matrix.GetTranslation())); m_object->SetUserdata(reinterpret_cast(static_cast(m_entity->GetId()))); + if (m_entity->HasComponent()) + { + auto& entityNode = m_entity->GetComponent(); + m_object->SetPosition(Nz::Vector2f(entityNode.GetPosition())); + m_object->SetRotation(entityNode.GetRotation().To2DAngle()); + } + if (m_pendingStates.valid) ApplyPhysicsState(*m_object); } diff --git a/SDK/src/NDK/Systems/PhysicsSystem2D.cpp b/SDK/src/NDK/Systems/PhysicsSystem2D.cpp index 4b6386c74..53d2ec0d4 100644 --- a/SDK/src/NDK/Systems/PhysicsSystem2D.cpp +++ b/SDK/src/NDK/Systems/PhysicsSystem2D.cpp @@ -249,19 +249,16 @@ namespace Ndk else body->SetVelocity(Nz::Vector2f::Zero()); - /*if (newRotation != oldRotation) - { - Nz::Quaternionf transition = newRotation * oldRotation.GetConjugate(); - Nz::EulerAnglesf angles = transition.ToEulerAngles(); - Nz::Vector3f angularVelocity(Nz::ToRadians(angles.pitch * invElapsedTime), - Nz::ToRadians(angles.yaw * invElapsedTime), - Nz::ToRadians(angles.roll * invElapsedTime)); + Nz::RadianAnglef oldRotation = body->GetRotation(); + Nz::RadianAnglef newRotation = node.GetRotation(Nz::CoordSys_Global).To2DAngle(); - physObj->SetRotation(oldRotation); - physObj->SetAngularVelocity(angularVelocity); + if (newRotation != oldRotation) + { + body->SetRotation(oldRotation); + body->SetAngularVelocity((newRotation - oldRotation) * invElapsedTime); } else - physObj->SetAngularVelocity(Nz::Vector3f::Zero());*/ + body->SetAngularVelocity(Nz::RadianAnglef::Zero()); } } diff --git a/include/Nazara/Math/Quaternion.hpp b/include/Nazara/Math/Quaternion.hpp index 991b23b94..e26149573 100644 --- a/include/Nazara/Math/Quaternion.hpp +++ b/include/Nazara/Math/Quaternion.hpp @@ -60,6 +60,7 @@ namespace Nz T SquaredMagnitude() const; + RadianAngle To2DAngle() const; EulerAngles ToEulerAngles() const; //Matrix3 ToRotationMatrix() const; String ToString() const; diff --git a/include/Nazara/Math/Quaternion.inl b/include/Nazara/Math/Quaternion.inl index 6d8937566..68c088eec 100644 --- a/include/Nazara/Math/Quaternion.inl +++ b/include/Nazara/Math/Quaternion.inl @@ -462,13 +462,27 @@ namespace Nz return w * w + x * x + y * y + z * z; } + /*! + * \brief Returns the "roll angle" of this quaternion + * \return Roll rotation + * + * \remark This function only has sense when quaternion only represents a "roll rotation" + */ + template + RadianAngle Quaternion::To2DAngle() const + { + T siny_cosp = T(2.0) * (w * z + x * y); + T cosy_cosp = T(1.0) - T(2.0) * (y * y + z * z); + + return std::atan2(siny_cosp, cosy_cosp); + } + /*! * \brief Converts this quaternion to Euler angles representation * \return EulerAngles which is the representation of this rotation * * \remark Rotation are "left-handed" */ - template EulerAngles Quaternion::ToEulerAngles() const { From 83cf358d02ed02d87ed54c819948497cc64ebf35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Fri, 3 Jul 2020 16:27:14 +0200 Subject: [PATCH 18/20] Physics2D/RigidBody2D: Fix EnableSimulation --- src/Nazara/Physics2D/RigidBody2D.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Nazara/Physics2D/RigidBody2D.cpp b/src/Nazara/Physics2D/RigidBody2D.cpp index 1e3835bdd..6da6d12ad 100644 --- a/src/Nazara/Physics2D/RigidBody2D.cpp +++ b/src/Nazara/Physics2D/RigidBody2D.cpp @@ -168,9 +168,9 @@ namespace Nz void RigidBody2D::EnableSimulation(bool simulation) { - if (m_isRegistered != simulation) + if (m_isSimulationEnabled != simulation) { - m_isRegistered = simulation; + m_isSimulationEnabled = simulation; if (simulation) RegisterToSpace(); @@ -325,7 +325,7 @@ namespace Nz bool RigidBody2D::IsSimulationEnabled() const { - return m_isRegistered; + return m_isSimulationEnabled; } bool RigidBody2D::IsSleeping() const From 884a34704dd6ab7c11c220cbdd22bf686c47433c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Fri, 3 Jul 2020 16:27:30 +0200 Subject: [PATCH 19/20] PhysicsComponent2D: Disable simulation when entity is disabled --- SDK/include/NDK/Components/PhysicsComponent2D.hpp | 2 ++ SDK/src/NDK/Components/PhysicsComponent2D.cpp | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/SDK/include/NDK/Components/PhysicsComponent2D.hpp b/SDK/include/NDK/Components/PhysicsComponent2D.hpp index 3983c26a5..c12084116 100644 --- a/SDK/include/NDK/Components/PhysicsComponent2D.hpp +++ b/SDK/include/NDK/Components/PhysicsComponent2D.hpp @@ -99,6 +99,8 @@ namespace Ndk void OnComponentDetached(BaseComponent& component) override; void OnDetached() override; void OnEntityDestruction() override; + void OnEntityDisabled() override; + void OnEntityEnabled() override; struct PendingPhysObjectStates { diff --git a/SDK/src/NDK/Components/PhysicsComponent2D.cpp b/SDK/src/NDK/Components/PhysicsComponent2D.cpp index 3ad5616e6..e5b42e183 100644 --- a/SDK/src/NDK/Components/PhysicsComponent2D.cpp +++ b/SDK/src/NDK/Components/PhysicsComponent2D.cpp @@ -117,5 +117,19 @@ namespace Ndk m_object.reset(); } + void PhysicsComponent2D::OnEntityDisabled() + { + NazaraAssert(m_object, "Invalid physics object"); + + m_object->EnableSimulation(false); + } + + void PhysicsComponent2D::OnEntityEnabled() + { + NazaraAssert(m_object, "Invalid physics object"); + + m_object->EnableSimulation(true); + } + ComponentIndex PhysicsComponent2D::componentIndex; } From ee3b5347b8fc3132b2a1927b1f1110cdc19f3a1a Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Fri, 10 Jul 2020 19:50:21 +0200 Subject: [PATCH 20/20] Add a define on POSIX system for lua to silence a warning about tmpname vs mkstmp Since the define LUA_USE_MACOSX and LUA_USE_LINUX seems to lead to the same subdefine it will do the job --- thirdparty/build/lua.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/thirdparty/build/lua.lua b/thirdparty/build/lua.lua index eac1edcac..76281076a 100644 --- a/thirdparty/build/lua.lua +++ b/thirdparty/build/lua.lua @@ -8,3 +8,11 @@ LIBRARY.Files = { "../thirdparty/src/Lua/*.h", "../thirdparty/src/Lua/*.cpp" } + +LIBRARY.OsDefines.Windows = { + "LUA_USE_WINDOWS" +} + +LIBRARY.OsDefines.Posix = { + "LUA_USE_LINUX" +}