...
 
Commits (8)
......@@ -10,7 +10,7 @@ struct IGraphicsDataFactory;
class IGraphicsContext {
friend class WindowCocoa;
friend class WindowXCB;
virtual void _setCallback(class IWindowCallback* cb) { (void)cb; }
virtual void _setCallback([[maybe_unused]] class IWindowCallback* cb) {}
public:
enum class EGraphicsAPI {
......
#pragma once
#include <algorithm>
#include <array>
#include <memory>
#include <cstring>
#include "boo/System.hpp"
......@@ -17,36 +17,30 @@ struct IAudioVoiceEngine;
enum class EMouseButton { None = 0, Primary = 1, Secondary = 2, Middle = 3, Aux1 = 4, Aux2 = 5 };
struct SWindowCoord {
int pixel[2];
int virtualPixel[2];
float norm[2];
std::array<int, 2> pixel;
std::array<int, 2> virtualPixel;
std::array<float, 2> norm;
};
struct SWindowRect {
int location[2];
int size[2];
std::array<int, 2> location{};
std::array<int, 2> size{};
SWindowRect() { std::memset(this, 0, sizeof(SWindowRect)); }
constexpr SWindowRect() noexcept = default;
constexpr SWindowRect(int x, int y, int w, int h) noexcept : location{x, y}, size{w, h} {}
SWindowRect(int x, int y, int w, int h) {
location[0] = x;
location[1] = y;
size[0] = w;
size[1] = h;
constexpr bool operator==(const SWindowRect& other) const noexcept {
return location[0] == other.location[0] && location[1] == other.location[1] && size[0] == other.size[0] &&
size[1] == other.size[1];
}
constexpr bool operator!=(const SWindowRect& other) const noexcept { return !operator==(other); }
bool operator!=(const SWindowRect& other) const {
return location[0] != other.location[0] || location[1] != other.location[1] || size[0] != other.size[0] ||
size[1] != other.size[1];
}
bool operator==(const SWindowRect& other) const { return !(*this != other); }
bool coordInRect(const SWindowCoord& coord) const {
constexpr bool coordInRect(const SWindowCoord& coord) const noexcept {
return coord.pixel[0] >= location[0] && coord.pixel[0] < location[0] + size[0] && coord.pixel[1] >= location[1] &&
coord.pixel[1] < location[1] + size[1];
}
SWindowRect intersect(const SWindowRect& other) const {
constexpr SWindowRect intersect(const SWindowRect& other) const noexcept {
if (location[0] < other.location[0] + other.size[0] && location[0] + size[0] > other.location[0] &&
location[1] < other.location[1] + other.size[1] && location[1] + size[1] > other.location[1]) {
SWindowRect ret;
......@@ -61,15 +55,15 @@ struct SWindowRect {
};
struct STouchCoord {
double coord[2];
std::array<double, 2> coord;
};
struct SScrollDelta {
double delta[2] = {};
std::array<double, 2> delta{};
bool isFine = false; /* Use system-scale fine-scroll (for scrollable-trackpads) */
bool isAccelerated = false; /* System performs acceleration computation */
SScrollDelta operator+(const SScrollDelta& other) const {
constexpr SScrollDelta operator+(const SScrollDelta& other) const noexcept {
SScrollDelta ret;
ret.delta[0] = delta[0] + other.delta[0];
ret.delta[1] = delta[1] + other.delta[1];
......@@ -77,7 +71,7 @@ struct SScrollDelta {
ret.isAccelerated = isAccelerated || other.isAccelerated;
return ret;
}
SScrollDelta operator-(const SScrollDelta& other) const {
constexpr SScrollDelta operator-(const SScrollDelta& other) const noexcept {
SScrollDelta ret;
ret.delta[0] = delta[0] - other.delta[0];
ret.delta[1] = delta[1] - other.delta[1];
......@@ -85,18 +79,15 @@ struct SScrollDelta {
ret.isAccelerated = isAccelerated || other.isAccelerated;
return ret;
}
SScrollDelta& operator+=(const SScrollDelta& other) {
constexpr SScrollDelta& operator+=(const SScrollDelta& other) noexcept {
delta[0] += other.delta[0];
delta[1] += other.delta[1];
isFine |= other.isFine;
isAccelerated |= other.isAccelerated;
return *this;
}
void zeroOut() {
delta[0] = 0.0;
delta[1] = 0.0;
}
bool isZero() const { return delta[0] == 0.0 && delta[1] == 0.0; }
constexpr void zeroOut() noexcept { delta = {}; }
constexpr bool isZero() const noexcept { return delta[0] == 0.0 && delta[1] == 0.0; }
};
enum class ESpecialKey {
......@@ -155,67 +146,34 @@ struct ITextInputCallback {
class IWindowCallback {
public:
virtual void resized(const SWindowRect& rect, bool sync) { (void)rect; }
virtual void mouseDown(const SWindowCoord& coord, EMouseButton button, EModifierKey mods) {
(void)coord;
(void)button;
(void)mods;
}
virtual void mouseUp(const SWindowCoord& coord, EMouseButton button, EModifierKey mods) {
(void)coord;
(void)button;
(void)mods;
}
virtual void mouseMove(const SWindowCoord& coord) { (void)coord; }
virtual void mouseEnter(const SWindowCoord& coord) { (void)coord; }
virtual void mouseLeave(const SWindowCoord& coord) { (void)coord; }
virtual void scroll(const SWindowCoord& coord, const SScrollDelta& scroll) {
(void)coord;
(void)scroll;
}
virtual void touchDown(const STouchCoord& coord, uintptr_t tid) {
(void)coord;
(void)tid;
}
virtual void touchUp(const STouchCoord& coord, uintptr_t tid) {
(void)coord;
(void)tid;
}
virtual void touchMove(const STouchCoord& coord, uintptr_t tid) {
(void)coord;
(void)tid;
}
virtual void charKeyDown(unsigned long charCode, EModifierKey mods, bool isRepeat) {
(void)charCode;
(void)mods;
(void)isRepeat;
}
virtual void charKeyUp(unsigned long charCode, EModifierKey mods) {
(void)charCode;
(void)mods;
}
virtual void specialKeyDown(ESpecialKey key, EModifierKey mods, bool isRepeat) {
(void)key;
(void)mods;
(void)isRepeat;
}
virtual void specialKeyUp(ESpecialKey key, EModifierKey mods) {
(void)key;
(void)mods;
}
virtual void modKeyDown(EModifierKey mod, bool isRepeat) {
(void)mod;
(void)isRepeat;
}
virtual void modKeyUp(EModifierKey mod) { (void)mod; }
virtual void resized([[maybe_unused]] const SWindowRect& rect, [[maybe_unused]] bool sync) {}
virtual void mouseDown([[maybe_unused]] const SWindowCoord& coord, [[maybe_unused]] EMouseButton button,
[[maybe_unused]] EModifierKey mods) {}
virtual void mouseUp([[maybe_unused]] const SWindowCoord& coord, [[maybe_unused]] EMouseButton button,
[[maybe_unused]] EModifierKey mods) {}
virtual void mouseMove([[maybe_unused]] const SWindowCoord& coord) {}
virtual void mouseEnter([[maybe_unused]] const SWindowCoord& coord) {}
virtual void mouseLeave([[maybe_unused]] const SWindowCoord& coord) {}
virtual void scroll([[maybe_unused]] const SWindowCoord& coord, [[maybe_unused]] const SScrollDelta& scroll) {}
virtual void touchDown([[maybe_unused]] const STouchCoord& coord, [[maybe_unused]] uintptr_t tid) {}
virtual void touchUp([[maybe_unused]] const STouchCoord& coord, [[maybe_unused]] uintptr_t tid) {}
virtual void touchMove([[maybe_unused]] const STouchCoord& coord, [[maybe_unused]] uintptr_t tid) {}
virtual void charKeyDown([[maybe_unused]] unsigned long charCode, [[maybe_unused]] EModifierKey mods,
[[maybe_unused]] bool isRepeat) {}
virtual void charKeyUp([[maybe_unused]] unsigned long charCode, [[maybe_unused]] EModifierKey mods) {}
virtual void specialKeyDown([[maybe_unused]] ESpecialKey key, [[maybe_unused]] EModifierKey mods,
[[maybe_unused]] bool isRepeat) {}
virtual void specialKeyUp([[maybe_unused]] ESpecialKey key, [[maybe_unused]] EModifierKey mods) {}
virtual void modKeyDown([[maybe_unused]] EModifierKey mod, [[maybe_unused]] bool isRepeat) {}
virtual void modKeyUp([[maybe_unused]] EModifierKey mod) {}
virtual ITextInputCallback* getTextInputCallback() { return nullptr; }
virtual void focusLost() {}
virtual void focusGained() {}
virtual void windowMoved(const SWindowRect& rect) { (void)rect; }
virtual void windowMoved([[maybe_unused]] const SWindowRect& rect) {}
virtual void destroyed() {}
};
......@@ -278,10 +236,7 @@ public:
virtual int waitForRetrace() = 0;
virtual uintptr_t getPlatformHandle() const = 0;
virtual bool _incomingEvent(void* event) {
(void)event;
return false;
}
virtual bool _incomingEvent([[maybe_unused]] void* event) { return false; }
virtual void _cleanup() {}
virtual ETouchType getTouchType() const = 0;
......@@ -289,7 +244,7 @@ public:
virtual void setStyle(EWindowStyle style) = 0;
virtual EWindowStyle getStyle() const = 0;
virtual void setTouchBarProvider(void*) {}
virtual void setTouchBarProvider([[maybe_unused]] void* provider) {}
virtual IGraphicsCommandQueue* getCommandQueue() = 0;
virtual IGraphicsDataFactory* getDataFactory() = 0;
......
......@@ -29,35 +29,34 @@ static inline ComPtr<T>* ReferenceComPtr(ComPtr<T>& ptr) {
#ifndef ENABLE_BITWISE_ENUM
#define ENABLE_BITWISE_ENUM(type) \
constexpr type operator|(type a, type b) { \
constexpr type operator|(type a, type b) noexcept { \
using T = std::underlying_type_t<type>; \
return type(static_cast<T>(a) | static_cast<T>(b)); \
} \
constexpr type operator&(type a, type b) { \
constexpr type operator&(type a, type b) noexcept { \
using T = std::underlying_type_t<type>; \
return type(static_cast<T>(a) & static_cast<T>(b)); \
} \
constexpr type& operator|=(type& a, type b) { \
constexpr type& operator|=(type& a, type b) noexcept { \
using T = std::underlying_type_t<type>; \
a = type(static_cast<T>(a) | static_cast<T>(b)); \
return a; \
} \
constexpr type& operator&=(type& a, type b) { \
constexpr type& operator&=(type& a, type b) noexcept { \
using T = std::underlying_type_t<type>; \
a = type(static_cast<T>(a) & static_cast<T>(b)); \
return a; \
} \
constexpr type operator~(type key) { \
constexpr type operator~(type key) noexcept { \
using T = std::underlying_type_t<type>; \
return type(~static_cast<T>(key)); \
} \
constexpr bool True(type key) { \
constexpr bool True(type key) noexcept { \
using T = std::underlying_type_t<type>; \
return static_cast<T>(key) != 0; \
} \
constexpr bool False(type key) { \
using T = std::underlying_type_t<type>; \
return static_cast<T>(key) == 0; \
constexpr bool False(type key) noexcept { \
return !True(key); \
}
#endif
......
......@@ -89,10 +89,7 @@ public:
void waitForRetrace() override {}
uintptr_t getPlatformHandle() const override { return 0; }
bool _incomingEvent(void* event) override {
(void)event;
return false;
}
bool _incomingEvent([[maybe_unused]] void* event) override { return false; }
void _cleanup() override {}
ETouchType getTouchType() const override { return ETouchType::Display; }
......
......@@ -859,18 +859,17 @@ public:
m_hwnd = CreateWindowW(L"BooWindow", title.data(), WS_OVERLAPPEDWINDOW, r.left, r.top, r.right - r.left,
r.bottom - r.top, nullptr, nullptr, nullptr, nullptr);
HINSTANCE wndInstance = HINSTANCE(GetWindowLongPtr(m_hwnd, GWLP_HINSTANCE));
m_imc = ImmGetContext(m_hwnd);
#if BOO_HAS_VULKAN
HINSTANCE wndInstance = HINSTANCE(GetWindowLongPtr(m_hwnd, GWLP_HINSTANCE));
if (b3dCtx.m_vulkanDxFactory) {
m_gfxCtx.reset(new GraphicsContextWin32Vulkan(this, wndInstance, m_hwnd, &g_VulkanContext, b3dCtx));
if (m_gfxCtx->initializeContext(nullptr))
return;
}
#else
(void)wndInstance;
#endif
IGraphicsContext::EGraphicsAPI api = IGraphicsContext::EGraphicsAPI::D3D11;
if (b3dCtx.m_ctxOgl.m_dxFactory) {
m_gfxCtx.reset(new GraphicsContextWin32GL(IGraphicsContext::EGraphicsAPI::OpenGL3_3, this, m_hwnd, b3dCtx));
......
......@@ -19,7 +19,7 @@ class ApplicationWayland final : public IApplication {
const std::vector<std::string> m_args;
bool m_singleInstance;
void _deletedWindow(IWindow* window) override { (void)window; }
void _deletedWindow([[maybe_unused]] IWindow* window) override {}
public:
ApplicationWayland(IApplicationCallback& callback, std::string_view uniqueName, std::string_view friendlyName,
......