Merge branch 'master' into vulkan

This commit is contained in:
Lynix
2020-05-27 19:48:22 +02:00
179 changed files with 41359 additions and 5418 deletions

View File

@@ -136,6 +136,8 @@ namespace Nz
{
friend CullingList;
using ParentType = Entry<CullTest::Box>;
public:
BoxEntry();
BoxEntry(BoxEntry&&) = default;
@@ -154,6 +156,8 @@ namespace Nz
{
friend CullingList;
using ParentType = Entry<CullTest::NoTest>;
public:
NoTestEntry();
NoTestEntry(NoTestEntry&&) = default;
@@ -170,6 +174,8 @@ namespace Nz
{
friend CullingList;
using ParentType = Entry<CullTest::Sphere>;
public:
SphereEntry();
SphereEntry(SphereEntry&&) = default;
@@ -188,6 +194,8 @@ namespace Nz
{
friend CullingList;
using ParentType = Entry<CullTest::Volume>;
public:
VolumeEntry();
VolumeEntry(VolumeEntry&&) = default;

View File

@@ -424,13 +424,13 @@ namespace Nz
template<typename T>
CullingList<T>::BoxEntry::BoxEntry() :
Entry<CullTest::Box>()
ParentType()
{
}
template<typename T>
CullingList<T>::BoxEntry::BoxEntry(CullingList* parent, std::size_t index) :
Entry<CullTest::Box>(parent, index)
ParentType(parent, index)
{
}
@@ -444,13 +444,13 @@ namespace Nz
template<typename T>
CullingList<T>::NoTestEntry::NoTestEntry() :
Entry<CullTest::NoTest>()
ParentType()
{
}
template<typename T>
CullingList<T>::NoTestEntry::NoTestEntry(CullingList* parent, std::size_t index) :
Entry<CullTest::NoTest>(parent, index)
ParentType(parent, index)
{
}
@@ -458,13 +458,13 @@ namespace Nz
template<typename T>
CullingList<T>::SphereEntry::SphereEntry() :
Entry<CullTest::Sphere>()
ParentType()
{
}
template<typename T>
CullingList<T>::SphereEntry::SphereEntry(CullingList* parent, std::size_t index) :
Entry<CullTest::Sphere>(parent, index)
ParentType(parent, index)
{
}
@@ -478,13 +478,13 @@ namespace Nz
template<typename T>
CullingList<T>::VolumeEntry::VolumeEntry() :
Entry<CullTest::Volume>()
ParentType()
{
}
template<typename T>
CullingList<T>::VolumeEntry::VolumeEntry(CullingList* parent, std::size_t index) :
Entry<CullTest::Volume>(parent, index)
ParentType(parent, index)
{
}

View File

@@ -51,6 +51,7 @@ namespace Nz
WindowEventType_Moved,
WindowEventType_Quit,
WindowEventType_Resized,
WindowEventType_TextEdited,
WindowEventType_TextEntered,
WindowEventType_Max = WindowEventType_TextEntered

View File

@@ -9,6 +9,8 @@
#ifndef NAZARA_EVENT_HPP
#define NAZARA_EVENT_HPP
#include <array>
#include <Nazara/Platform/Enums.hpp>
#include <Nazara/Platform/Keyboard.hpp>
#include <Nazara/Platform/Mouse.hpp>
@@ -22,7 +24,8 @@ namespace Nz
// -WindowEventType_KeyReleased
struct KeyEvent
{
Keyboard::Key code;
Keyboard::Scancode scancode;
Keyboard::VKey virtualKey;
bool alt;
bool control;
bool repeated;
@@ -83,6 +86,14 @@ namespace Nz
char32_t character;
};
// Used by:
// -WindowEventType_TextEdited
struct EditEvent
{
int length;
std::array<char, 32> text;
};
WindowEventType type;
union
@@ -116,6 +127,10 @@ namespace Nz
// Used by:
// -WindowEventType_TextEntered
TextEvent text;
// Used by:
// -WindowEventType_TextEntered
EditEvent edit;
};
};
}

View File

@@ -49,6 +49,7 @@ namespace Nz
NazaraSignal(OnQuit, const EventHandler* /*eventHandler*/);
NazaraSignal(OnResized, const EventHandler* /*eventHandler*/, const WindowEvent::SizeEvent& /*event*/);
NazaraSignal(OnTextEntered, const EventHandler* /*eventHandler*/, const WindowEvent::TextEvent& /*event*/);
NazaraSignal(OnTextEdited, const EventHandler* /*eventHandler*/, const WindowEvent::EditEvent& /*event*/);
};
}

View File

@@ -78,6 +78,10 @@ namespace Nz
case WindowEventType_TextEntered:
OnTextEntered(this, event.text);
break;
case WindowEventType_TextEdited:
OnTextEdited(this, event.edit);
break;
}
}
}

View File

@@ -18,7 +18,7 @@ namespace Nz
class NAZARA_PLATFORM_API Keyboard
{
public:
enum Key
enum class Scancode
{
Undefined = -1,
@@ -78,6 +78,7 @@ namespace Nz
Decimal,
Divide,
Multiply,
NumpadReturn,
Numpad0,
Numpad1,
Numpad2,
@@ -135,6 +136,8 @@ namespace Nz
Space,
Tab,
Tilde,
Menu,
ISOBackslash102,
// Navigator keys
Browser_Back,
@@ -161,14 +164,169 @@ namespace Nz
NumLock,
ScrollLock,
Count
Max = ScrollLock
};
enum class VKey
{
Undefined = -1,
// Lettres
A,
B,
C,
D,
E,
F,
G,
H,
I,
J,
K,
L,
M,
N,
O,
P,
Q,
R,
S,
T,
U,
V,
W,
X,
Y,
Z,
// Functional keys
F1,
F2,
F3,
F4,
F5,
F6,
F7,
F8,
F9,
F10,
F11,
F12,
F13,
F14,
F15,
// Directional keys
Down,
Left,
Right,
Up,
// Numerical pad
Add,
Decimal,
Divide,
Multiply,
NumpadReturn,
Numpad0,
Numpad1,
Numpad2,
Numpad3,
Numpad4,
Numpad5,
Numpad6,
Numpad7,
Numpad8,
Numpad9,
Subtract,
// Various
Backslash,
Backspace,
Clear,
Comma,
Dash,
Delete,
End,
Equal,
Escape,
Home,
Insert,
LAlt,
LBracket,
LControl,
LShift,
LSystem,
Num0,
Num1,
Num2,
Num3,
Num4,
Num5,
Num6,
Num7,
Num8,
Num9,
PageDown,
PageUp,
Pause,
Period,
Print,
PrintScreen,
Quote,
RAlt,
RBracket,
RControl,
Return,
RShift,
RSystem,
Semicolon,
Slash,
Space,
Tab,
Tilde,
Menu,
ISOBackslash102,
// Navigator keys
Browser_Back,
Browser_Favorites,
Browser_Forward,
Browser_Home,
Browser_Refresh,
Browser_Search,
Browser_Stop,
// Lecture control keys
Media_Next,
Media_Play,
Media_Previous,
Media_Stop,
// Volume control keys
Volume_Down,
Volume_Mute,
Volume_Up,
// Locking keys
CapsLock,
NumLock,
ScrollLock,
Max = ScrollLock
};
Keyboard() = delete;
~Keyboard() = delete;
static String GetKeyName(Key key);
static bool IsKeyPressed(Key key);
static String GetKeyName(Scancode scancode);
static String GetKeyName(VKey key);
static bool IsKeyPressed(Scancode scancode);
static bool IsKeyPressed(VKey key);
static void StartTextInput();
static void StopTextInput();
static Scancode ToScanCode(VKey key);
static VKey ToVirtualKey(Scancode key);
};
}

View File

@@ -37,6 +37,7 @@ namespace Nz
static Vector2i GetPosition();
static Vector2i GetPosition(const Window& relativeTo);
static bool IsButtonPressed(Button button);
static bool SetRelativeMouseMode(bool relativeMouseMode);
static void SetPosition(const Vector2i& position);
static void SetPosition(const Vector2i& position, const Window& relativeTo, bool ignoreEvent = true);
static void SetPosition(int x, int y);

View File

@@ -32,12 +32,12 @@ namespace Nz
static const std::vector<VideoMode>& GetFullscreenModes();
};
bool operator==(const VideoMode& left, const VideoMode& right);
bool operator!=(const VideoMode& left, const VideoMode& right);
bool operator<(const VideoMode& left, const VideoMode& right);
bool operator<=(const VideoMode& left, const VideoMode& right);
bool operator>(const VideoMode& left, const VideoMode& right);
bool operator>=(const VideoMode& left, const VideoMode& right);
bool NAZARA_PLATFORM_API operator==(const VideoMode& left, const VideoMode& right);
bool NAZARA_PLATFORM_API operator!=(const VideoMode& left, const VideoMode& right);
bool NAZARA_PLATFORM_API operator<(const VideoMode& left, const VideoMode& right);
bool NAZARA_PLATFORM_API operator<=(const VideoMode& left, const VideoMode& right);
bool NAZARA_PLATFORM_API operator>(const VideoMode& left, const VideoMode& right);
bool NAZARA_PLATFORM_API operator>=(const VideoMode& left, const VideoMode& right);
}
#endif // NAZARA_VIDEOMODE_HPP

View File

@@ -32,13 +32,14 @@ namespace Nz
class NAZARA_PLATFORM_API Window
{
friend WindowImpl;
friend class EventImpl;
friend class Mouse;
friend class Platform;
public:
Window();
inline Window(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default);
inline explicit Window(WindowHandle handle);
inline explicit Window(void* handle);
Window(const Window&) = delete;
Window(Window&& window);
virtual ~Window();
@@ -46,7 +47,7 @@ namespace Nz
inline void Close();
bool Create(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default);
bool Create(WindowHandle handle);
bool Create(void* handle);
void Destroy();
@@ -61,10 +62,10 @@ namespace Nz
inline const CursorRef& GetCursor() const;
inline CursorController& GetCursorController();
inline EventHandler& GetEventHandler();
WindowHandle GetHandle() const;
Vector2i GetPosition() const;
Vector2ui GetSize() const;
WindowStyleFlags GetStyle() const;
WindowHandle GetSystemHandle() const;
String GetTitle() const;
bool HasFocus() const;
@@ -106,6 +107,8 @@ namespace Nz
Window& operator=(Window&& window);
protected:
void* GetHandle();
virtual bool OnWindowCreated();
virtual void OnWindowDestroy();
virtual void OnWindowResized();
@@ -116,6 +119,9 @@ namespace Nz
void ConnectSlots();
void DisconnectSlots();
inline WindowImpl* GetImpl();
inline const WindowImpl* GetImpl() const;
void IgnoreNextMouseEvent(int mouseX, int mouseY) const;
void HandleEvent(const WindowEvent& event);

View File

@@ -19,7 +19,7 @@ namespace Nz
Create(mode, title, style);
}
inline Window::Window(WindowHandle handle) :
inline Window::Window(void* handle) :
Window()
{
ErrorFlags flags(ErrorFlag_ThrowException, true);
@@ -109,6 +109,16 @@ namespace Nz
}
}
}
inline WindowImpl* Window::GetImpl()
{
return m_impl;
}
inline const WindowImpl* Window::GetImpl() const
{
return m_impl;
}
}
#include <Nazara/Platform/DebugOff.hpp>

View File

@@ -8,21 +8,44 @@
#define NAZARA_WINDOWHANDLE_HPP
#include <Nazara/Prerequisites.hpp>
#if defined(NAZARA_PLATFORM_X11)
#include <xcb/xcb.h>
#endif
#include <Nazara/Utility/Config.hpp>
namespace Nz
{
#if defined(NAZARA_PLATFORM_WINDOWS)
// http://msdn.microsoft.com/en-us/library/aa383751(v=vs.85).aspx
using WindowHandle = void*;
#elif defined(NAZARA_PLATFORM_X11)
// http://en.wikipedia.org/wiki/Xlib#Data_types
using WindowHandle = xcb_window_t;
#else
#error Lack of implementation: WindowHandle
#endif
enum class WindowManager
{
None,
X11,
Wayland,
Windows
};
struct WindowHandle
{
WindowManager type = WindowManager::None;
union
{
struct
{
void* display; //< Display*
void* window; //< Window
} x11;
struct
{
void* display; //< wl_display*
void* surface; //< wl_surface*
void* shellSurface; //< wl_shell_surface*
} wayland;
struct
{
void* window; //< HWND
} windows;
};
};
}
#endif // NAZARA_WINDOWHANDLE_HPP

View File

@@ -117,21 +117,17 @@
#endif
#elif defined(__linux__) || defined(__unix__)
#define NAZARA_PLATFORM_LINUX
#define NAZARA_PLATFORM_GLX
#define NAZARA_PLATFORM_POSIX
#define NAZARA_PLATFORM_X11
#define NAZARA_EXPORT __attribute__((visibility ("default")))
#define NAZARA_IMPORT __attribute__((visibility ("default")))
/*#elif defined(__APPLE__) && defined(__MACH__)
#define NAZARA_CORE_API
#define NAZARA_PLATFORM_MACOSX
#define NAZARA_PLATFORM_POSIX*/
#define NAZARA_PLATFORM_MACOSX
#define NAZARA_PLATFORM_POSIX*/
#else
#error This operating system is not fully supported by the Nazara Engine
#define NAZARA_PLATFORM_UNKNOWN
#define NAZARA_CORE_API
#endif
// Detect 64 bits

View File

@@ -25,26 +25,26 @@ namespace Nz
{
public:
inline RenderWindow();
inline RenderWindow(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default, const RenderWindowParameters& parameters = RenderWindowParameters());
inline explicit RenderWindow(WindowHandle handle, const RenderWindowParameters& parameters = RenderWindowParameters());
inline RenderWindow(VideoMode mode, const String &title, WindowStyleFlags style = WindowStyle_Default, const RenderWindowParameters &parameters = RenderWindowParameters());
inline explicit RenderWindow(void *handle, const RenderWindowParameters &parameters = RenderWindowParameters());
inline ~RenderWindow();
inline bool Create(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default, const RenderWindowParameters& parameters = RenderWindowParameters());
inline bool Create(WindowHandle handle, const RenderWindowParameters& parameters = RenderWindowParameters());
inline bool Create(VideoMode mode, const String &title, WindowStyleFlags style = WindowStyle_Default, const RenderWindowParameters &parameters = RenderWindowParameters());
inline bool Create(void *handle, const RenderWindowParameters &parameters = RenderWindowParameters());
void Display();
void EnableVerticalSync(bool enabled);
inline RenderWindowImpl* GetImpl();
inline RenderWindowImpl *GetImpl();
std::shared_ptr<RenderDevice> GetRenderDevice();
inline bool IsValid() const;
inline void SetFramerateLimit(unsigned int limit);
RenderWindow& operator=(const RenderWindow&) = delete;
RenderWindow& operator=(RenderWindow&&) = delete; ///TODO
RenderWindow &operator=(const RenderWindow &) = delete;
RenderWindow &operator=(RenderWindow &&) = delete; ///TODO
protected:
bool OnWindowCreated() override;
@@ -57,8 +57,8 @@ namespace Nz
std::unique_ptr<RenderSurface> m_surface;
RenderWindowParameters m_parameters;
unsigned int m_framerateLimit;
};
}
};
} // namespace Nz
#include <Nazara/Renderer/RenderWindow.inl>

View File

@@ -24,11 +24,11 @@ namespace Nz
inline SimpleTextDrawer::SimpleTextDrawer(const SimpleTextDrawer& drawer) :
m_color(drawer.m_color),
m_outlineColor(drawer.m_outlineColor),
m_text(drawer.m_text),
m_style(drawer.m_style),
m_colorUpdated(false),
m_glyphUpdated(false),
m_outlineColor(drawer.m_outlineColor),
m_characterSpacingOffset(drawer.m_characterSpacingOffset),
m_lineSpacingOffset(drawer.m_lineSpacingOffset),
m_maxLineWidth(drawer.m_maxLineWidth),