Merge branch 'master' into nazara-next
This commit is contained in:
commit
b2a7e620e0
|
|
@ -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 libxcb-ewmh-dev libx11-dev libfreetype6-dev mesa-common-dev libgl1-mesa-dev
|
||||
|
||||
RUN mkdir /NazaraEngine
|
||||
WORKDIR /NazaraEngine
|
||||
|
|
@ -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",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,4 +18,3 @@ MODULE.OsFiles.Posix = {
|
|||
"../src/Nazara/Renderer/GLX/**.hpp",
|
||||
"../src/Nazara/Renderer/GLX/**.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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ namespace Nz
|
|||
|
||||
T SquaredMagnitude() const;
|
||||
|
||||
RadianAngle<T> To2DAngle() const;
|
||||
EulerAngles<T> ToEulerAngles() const;
|
||||
//Matrix3<T> ToRotationMatrix() const;
|
||||
String ToString() const;
|
||||
|
|
|
|||
|
|
@ -463,13 +463,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<typename T>
|
||||
RadianAngle<T> Quaternion<T>::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<typename T>
|
||||
EulerAngles<T> Quaternion<T>::ToEulerAngles() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace Nz
|
|||
{
|
||||
enum class WindowManager
|
||||
{
|
||||
None,
|
||||
Invalid,
|
||||
|
||||
X11,
|
||||
Wayland,
|
||||
|
|
@ -23,14 +23,14 @@ namespace Nz
|
|||
|
||||
struct WindowHandle
|
||||
{
|
||||
WindowManager type = WindowManager::None;
|
||||
WindowManager type = WindowManager::Invalid;
|
||||
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
void* display; //< Display*
|
||||
void* window; //< Window
|
||||
unsigned long window; //< Window
|
||||
} x11;
|
||||
|
||||
struct
|
||||
|
|
|
|||
|
|
@ -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__)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -126,7 +126,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;
|
||||
|
|
@ -286,7 +286,8 @@ namespace Nz
|
|||
|
||||
void WindowImpl::ProcessEvents(bool block)
|
||||
{
|
||||
SDL_PumpEvents();
|
||||
if (m_ownsWindow)
|
||||
SDL_PumpEvents();
|
||||
|
||||
|
||||
/*if (m_ownsWindow)
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <Nazara/Renderer/GLX/Display.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Renderer/GLX/ScopedXCB.hpp>
|
||||
#include <xcb/xcb_keysyms.h>
|
||||
#include <unordered_map>
|
||||
#include <Nazara/Renderer/Debug.hpp>
|
||||
|
||||
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<std::string, xcb_atom_t>;
|
||||
AtomMap atoms;
|
||||
}
|
||||
|
||||
bool X11::CheckCookie(xcb_connection_t* connection, xcb_void_cookie_t cookie)
|
||||
{
|
||||
ScopedXCB<xcb_generic_error_t> 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<xcb_generic_error_t> error(nullptr);
|
||||
|
||||
xcb_connection_t* connection = OpenConnection();
|
||||
|
||||
ScopedXCB<xcb_intern_atom_reply_t> 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;
|
||||
}
|
||||
|
|
@ -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 <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Platform/Config.hpp>
|
||||
#include <string>
|
||||
#include <xcb/xcb.h>
|
||||
#include <xcb/xcb_ewmh.h>
|
||||
|
||||
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
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
// 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 <Nazara/Renderer/GLX/ScopedXCB.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Renderer/GLX/Display.hpp>
|
||||
#include <Nazara/Renderer/Debug.hpp>
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
// 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 <Nazara/Prerequisites.hpp>
|
||||
#include <xcb/xcb.h>
|
||||
#include <xcb/xcb_ewmh.h>
|
||||
#include <cstdlib>
|
||||
|
||||
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 <typename T>
|
||||
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 <Nazara/Renderer/GLX/ScopedXCB.inl>
|
||||
|
||||
#endif // NAZARA_SCOPEDXCB_HPP
|
||||
|
|
@ -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 <Nazara/Renderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
template <typename T>
|
||||
ScopedXCB<T>::ScopedXCB(T* pointer) :
|
||||
m_pointer(pointer)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
ScopedXCB<T>::~ScopedXCB()
|
||||
{
|
||||
std::free(m_pointer);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T* ScopedXCB<T>::operator ->() const
|
||||
{
|
||||
return m_pointer;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T** ScopedXCB<T>::operator &()
|
||||
{
|
||||
return &m_pointer;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
ScopedXCB<T>::operator bool() const
|
||||
{
|
||||
return m_pointer != nullptr;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T* ScopedXCB<T>::get() const
|
||||
{
|
||||
return m_pointer;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/DebugOff.hpp>
|
||||
|
|
@ -51,9 +51,15 @@ namespace Ndk
|
|||
|
||||
m_object = std::make_unique<Nz::RigidBody2D>(&world, 1.f, geom);
|
||||
m_object->SetPositionOffset(positionOffset);
|
||||
m_object->SetPosition(Nz::Vector2f(matrix.GetTranslation()));
|
||||
m_object->SetUserdata(reinterpret_cast<void*>(static_cast<std::ptrdiff_t>(m_entity->GetId())));
|
||||
|
||||
if (m_entity->HasComponent<NodeComponent>())
|
||||
{
|
||||
auto& entityNode = m_entity->GetComponent<NodeComponent>();
|
||||
m_object->SetPosition(Nz::Vector2f(entityNode.GetPosition()));
|
||||
m_object->SetRotation(entityNode.GetRotation().To2DAngle());
|
||||
}
|
||||
|
||||
if (m_pendingStates.valid)
|
||||
ApplyPhysicsState(*m_object);
|
||||
}
|
||||
|
|
@ -111,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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue