- More implementations and dependencies for Linux Wayland support
This commit is contained in:
22
include/fennec/concurrency/atomic.h
Normal file
22
include/fennec/concurrency/atomic.h
Normal file
@@ -0,0 +1,22 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef FENNEC_CONCURRENCY_ATOMIC_H
|
||||
#define FENNEC_CONCURRENCY_ATOMIC_H
|
||||
|
||||
#endif // FENNEC_CONCURRENCY_ATOMIC_H
|
||||
22
include/fennec/concurrency/mutex.h
Normal file
22
include/fennec/concurrency/mutex.h
Normal file
@@ -0,0 +1,22 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef FENNEC_CONCURRENCY_MUTEX_H
|
||||
#define FENNEC_CONCURRENCY_MUTEX_H
|
||||
|
||||
#endif // FENNEC_CONCURRENCY_MUTEX_H
|
||||
22
include/fennec/concurrency/thread.h
Normal file
22
include/fennec/concurrency/thread.h
Normal file
@@ -0,0 +1,22 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef FENNEC_CONCURRENCY_THREAD_H
|
||||
#define FENNEC_CONCURRENCY_THREAD_H
|
||||
|
||||
#endif // FENNEC_CONCURRENCY_THREAD_H
|
||||
@@ -42,7 +42,9 @@ namespace fennec
|
||||
///
|
||||
/// \brief wrapper for fixed size arrays
|
||||
///
|
||||
/// \details
|
||||
/// \details | | |
|
||||
/// |-|-|
|
||||
/// | | |
|
||||
/// \tparam ValueT value type
|
||||
/// \tparam ElemV number of elements
|
||||
template<typename ValueT, size_t ElemV>
|
||||
@@ -78,6 +80,12 @@ struct array
|
||||
return elements[i];
|
||||
}
|
||||
|
||||
constexpr ValueT* begin() { return elements; }
|
||||
constexpr ValueT* end() { return elements + ElemV; }
|
||||
|
||||
constexpr const ValueT* begin() const { return elements; }
|
||||
constexpr const ValueT* end() const { return elements + ElemV; }
|
||||
|
||||
/// @}
|
||||
|
||||
|
||||
|
||||
@@ -39,8 +39,7 @@ namespace fennec
|
||||
{
|
||||
|
||||
template<class TypeT, class Alloc = allocator<TypeT>>
|
||||
class dynarray
|
||||
{
|
||||
class dynarray {
|
||||
public:
|
||||
using element_t = TypeT;
|
||||
using alloc_t = Alloc;
|
||||
@@ -95,6 +94,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
constexpr dynarray(size_t n, TypeT&&) = delete;
|
||||
|
||||
template<typename...ArgsT>
|
||||
constexpr dynarray(size_t n, ArgsT&&...args) {
|
||||
element_t* addr = _alloc.data();
|
||||
@@ -130,6 +131,12 @@ public:
|
||||
assertd(i < _size, "Array Out of Bounds"); return _alloc.data()[i];
|
||||
}
|
||||
|
||||
constexpr TypeT* begin() { return _alloc.data(); }
|
||||
constexpr TypeT* end() { return begin() + _size; }
|
||||
|
||||
constexpr const TypeT* begin() const { return _alloc; }
|
||||
constexpr const TypeT* end() const { return begin() + _size; }
|
||||
|
||||
constexpr TypeT& back() {
|
||||
return this->operator[](size() - 1);
|
||||
}
|
||||
@@ -138,26 +145,6 @@ public:
|
||||
return this->operator[](size() - 1);
|
||||
}
|
||||
|
||||
constexpr void insert(size_t i, const TypeT& val) {
|
||||
|
||||
// Grow if the size has reached the capacity of the allocation
|
||||
if(_size == capacity()) {
|
||||
_grow();
|
||||
}
|
||||
|
||||
// Move the data if we are not inserting at the end of the array
|
||||
if((i = min(i, _size)) < _size) {
|
||||
fennec::memmove(
|
||||
_alloc.data() + i
|
||||
, _alloc.data() + i + 1
|
||||
, (_size - i) * sizeof(TypeT));
|
||||
}
|
||||
|
||||
// Insert the element
|
||||
fennec::construct(_alloc.data() + i, val);
|
||||
++_size;
|
||||
}
|
||||
|
||||
constexpr void insert(size_t i, TypeT&& val) {
|
||||
|
||||
// Grow if the size has reached the capacity of the allocation
|
||||
@@ -168,8 +155,8 @@ public:
|
||||
// Move the data if we are not inserting at the end of the array
|
||||
if((i = min(i, _size)) < _size) {
|
||||
fennec::memmove(
|
||||
_alloc.data() + i + 1
|
||||
, _alloc.data() + i
|
||||
(void*)(_alloc.data() + i + 1)
|
||||
, (void*)(_alloc.data() + i)
|
||||
, (_size - i) * sizeof(TypeT));
|
||||
}
|
||||
|
||||
@@ -178,6 +165,26 @@ public:
|
||||
++_size;
|
||||
}
|
||||
|
||||
constexpr void insert(size_t i, const TypeT& val) {
|
||||
|
||||
// Grow if the size has reached the capacity of the allocation
|
||||
if(_size == capacity()) {
|
||||
_grow();
|
||||
}
|
||||
|
||||
// Move the data if we are not inserting at the end of the array
|
||||
if((i = min(i, _size)) < _size) {
|
||||
fennec::memmove(
|
||||
(void*)(_alloc.data() + i)
|
||||
, (void*)(_alloc.data() + i + 1)
|
||||
, (_size - i) * sizeof(TypeT));
|
||||
}
|
||||
|
||||
// Insert the element
|
||||
fennec::construct(_alloc.data() + i, val);
|
||||
++_size;
|
||||
}
|
||||
|
||||
template<typename...ArgsT>
|
||||
constexpr void emplace(size_t i, ArgsT&&...args) {
|
||||
|
||||
@@ -189,8 +196,8 @@ public:
|
||||
// Move the data if we are not inserting at the end of the array
|
||||
if((i = min(i, _size)) < _size) {
|
||||
fennec::memmove(
|
||||
_alloc.data() + i
|
||||
, _alloc.data() + i + 1
|
||||
(void*)(_alloc.data() + i)
|
||||
, (void*)(_alloc.data() + i + 1)
|
||||
, (_size - i) * sizeof(TypeT));
|
||||
}
|
||||
|
||||
@@ -208,7 +215,7 @@ public:
|
||||
}
|
||||
|
||||
constexpr void pop_back() {
|
||||
_alloc[_size--].~TypeT();
|
||||
fennec::destruct(&_alloc[_size--]);
|
||||
}
|
||||
|
||||
template<typename...ArgsT>
|
||||
@@ -218,6 +225,15 @@ public:
|
||||
|
||||
constexpr void resize(size_t n) {
|
||||
_alloc.reallocate(n);
|
||||
|
||||
if (_size < n) {
|
||||
_size = n;
|
||||
return;
|
||||
}
|
||||
|
||||
while (_size < n) {
|
||||
emplace_back();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -20,9 +20,14 @@
|
||||
#define FENNEC_CONTAINERS_LIST_H
|
||||
|
||||
#include <fennec/containers/dynarray.h>
|
||||
#include <fennec/containers/list.h>
|
||||
#include <fennec/containers/optional.h>
|
||||
#include <fennec/memory/allocator.h>
|
||||
|
||||
#include <fennec/math/common.h>
|
||||
|
||||
#include <fennec/platform/interface/window.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
@@ -33,6 +38,8 @@ public:
|
||||
using value_t = TypeT;
|
||||
static constexpr size_t npos = -1;
|
||||
|
||||
class iterator;
|
||||
|
||||
private:
|
||||
struct node {
|
||||
optional<value_t> data;
|
||||
@@ -82,20 +89,21 @@ private:
|
||||
return n;
|
||||
}
|
||||
|
||||
size_t _next_free(size_t i) {
|
||||
size_t _next_free() {
|
||||
if (not _freed.empty()) {
|
||||
size_t n = _freed.back();
|
||||
_freed.pop_back();
|
||||
return n;
|
||||
}
|
||||
_table[_size];
|
||||
return _size;
|
||||
}
|
||||
|
||||
public:
|
||||
using elem_t = node;
|
||||
|
||||
constexpr list()
|
||||
: _table(), _root(npos), _last(npos), _freed(), _size(0) {
|
||||
: _table(), _freed(), _root(npos), _last(npos), _size(0) {
|
||||
}
|
||||
|
||||
constexpr ~list() = default;
|
||||
@@ -108,14 +116,14 @@ public:
|
||||
assertd(i >= 0, "Index out of Bounds");
|
||||
size_t n = _walk(i);
|
||||
assertd(n != npos, "Index out of Bounds");
|
||||
return _table[n].data;
|
||||
return *_table[n].data;
|
||||
}
|
||||
|
||||
constexpr const value_t& operator[](int i) const {
|
||||
assertd(i >= 0, "Index out of Bounds");
|
||||
size_t n = _walk(i);
|
||||
assertd(n != npos, "Index out of Bounds");
|
||||
return _table[n].data;
|
||||
return *_table[n].data;
|
||||
}
|
||||
|
||||
void insert(size_t i, value_t&& x) {
|
||||
@@ -123,20 +131,25 @@ public:
|
||||
if (size() == capacity()) {
|
||||
_expand();
|
||||
}
|
||||
size_t n = _walk(min(i, size() - 1));
|
||||
size_t p = _next_free(i);
|
||||
size_t n = _walk(min(i, size_t(size() - 1)));
|
||||
size_t p = _next_free();
|
||||
if (n == npos) {
|
||||
_root = p;
|
||||
_table[p].data = fennec::forward<value_t>(x);
|
||||
_table[p].next = npos;
|
||||
_table[p].prev = npos;
|
||||
return;
|
||||
}
|
||||
_table[p].data = fennec::forward<value_t>(x);
|
||||
_table[p].next = n;
|
||||
_table[p].prev = _prev(p);
|
||||
_table[n].prev = p;
|
||||
if (i == size()) {
|
||||
_table[p].next = n;
|
||||
_table[p].prev = _prev(n);
|
||||
_table[n].prev = p;
|
||||
}
|
||||
else {
|
||||
_table[p].prev = n;
|
||||
}
|
||||
++_size;
|
||||
|
||||
_last = (n == npos) ? p : _last;
|
||||
}
|
||||
|
||||
void insert(size_t i, const value_t& x) {
|
||||
@@ -175,8 +188,9 @@ public:
|
||||
|
||||
// Fix prev and next nodes
|
||||
if (p != npos) _table[p].next = n;
|
||||
else _root = n;
|
||||
if (n != npos) _table[n].prev = p;
|
||||
else _last = j;
|
||||
else _last = p;
|
||||
|
||||
// Mark node as freed
|
||||
_freed.push_back(j);
|
||||
@@ -190,11 +204,75 @@ public:
|
||||
erase(_size - 1);
|
||||
}
|
||||
|
||||
constexpr value_t& back() {
|
||||
return this->operator[](size() - 1);
|
||||
}
|
||||
|
||||
constexpr const value_t& back() const {
|
||||
return this->operator[](size() - 1);
|
||||
}
|
||||
|
||||
// ITERATOR ============================================================================================================
|
||||
|
||||
class iterator {
|
||||
public:
|
||||
~iterator() {
|
||||
_list = nullptr;
|
||||
}
|
||||
|
||||
// prefix operator
|
||||
constexpr friend iterator& operator++(iterator& rhs) {
|
||||
if (rhs._list->_next(rhs._n) < rhs._list->capacity()) {
|
||||
return rhs;
|
||||
}
|
||||
rhs._n = npos;
|
||||
return rhs;
|
||||
}
|
||||
|
||||
constexpr friend iterator operator++(iterator& lhs, int) {
|
||||
iterator prev = lhs;
|
||||
++lhs;
|
||||
return prev;
|
||||
}
|
||||
|
||||
constexpr value_t& operator*() {
|
||||
return *(_list->_table[_n].data);
|
||||
}
|
||||
|
||||
constexpr bool operator==(const iterator& it) {
|
||||
return _list == it._list and _n == it._n;
|
||||
}
|
||||
|
||||
constexpr bool operator!=(const iterator& it) {
|
||||
return _list != it._list or _n != it._n;
|
||||
}
|
||||
|
||||
private:
|
||||
list* _list;
|
||||
size_t _n;
|
||||
friend list;
|
||||
|
||||
iterator(list* ls, size_t n)
|
||||
: _list(ls)
|
||||
, _n(n) {
|
||||
}
|
||||
};
|
||||
|
||||
constexpr iterator begin() {
|
||||
return iterator(this, _root);
|
||||
}
|
||||
|
||||
constexpr iterator end() {
|
||||
return iterator(this, npos);
|
||||
}
|
||||
|
||||
private:
|
||||
allocation<elem_t, alloc_t> _table;
|
||||
dynarray<size_t> _freed;
|
||||
size_t _root, _last, _size;
|
||||
|
||||
friend class iterator;
|
||||
|
||||
constexpr void _expand() {
|
||||
_table.reallocate(_table.capacity() * 2);
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
pair<KeyT, ValueT> val;
|
||||
|
||||
~U() {
|
||||
root.~pair<KeyT, char[sizeof(ValueT)]>();
|
||||
fennec::destruct(&root);
|
||||
}
|
||||
} trick = { .root = { key, 0 } };
|
||||
auto it = _set.find(trick.val);
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
pair<KeyT, ValueT> val;
|
||||
|
||||
~U() {
|
||||
root.~pair<KeyT, char[sizeof(ValueT)]>();
|
||||
fennec::destruct(&root);
|
||||
}
|
||||
} trick = { .root = { key, 0 } }; // Only initialize root
|
||||
auto it = _set.find(trick.val);
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
pair<KeyT, ValueT> val;
|
||||
|
||||
~U() {
|
||||
root.~pair<KeyT, char[sizeof(ValueT)]>();
|
||||
fennec::destruct(&root);
|
||||
}
|
||||
} trick = { .root = { key_t(fennec::forward<ArgsT>(args)...), 0 } }; // Only initialize root
|
||||
auto it = _set.find(trick.val);
|
||||
@@ -127,7 +127,7 @@ public:
|
||||
pair<KeyT, ValueT> val;
|
||||
|
||||
~U() {
|
||||
root.~pair<KeyT, char[sizeof(ValueT)]>();
|
||||
fennec::destruct(&root);
|
||||
}
|
||||
} trick = { .root = { key_t(fennec::forward<ArgsT>(args)...), 0 } }; // Only initialize root
|
||||
auto it = _set.find(trick.val);
|
||||
@@ -157,7 +157,7 @@ public:
|
||||
pair<KeyT, ValueT> val;
|
||||
|
||||
~U() {
|
||||
root.~pair<KeyT, char[sizeof(ValueT)]>();
|
||||
fennec::destruct(&root);
|
||||
}
|
||||
} trick = { .root = { fennec::forward<KeyT>(key), 0 } };
|
||||
_set.erase(trick.val);
|
||||
@@ -175,7 +175,7 @@ public:
|
||||
pair<KeyT, ValueT> val;
|
||||
|
||||
~U() {
|
||||
root.~pair<KeyT, char[sizeof(ValueT)]>();
|
||||
fennec::destruct(&root);
|
||||
}
|
||||
} trick = { .root = { KeyT(fennec::forward<ArgsT>(args)...), 0 } };
|
||||
_set.erase(trick.val);
|
||||
|
||||
@@ -40,9 +40,9 @@ struct optional {
|
||||
public:
|
||||
// Constructors ========================================================================================================
|
||||
using reference_t = T&;
|
||||
using pointer_t = add_pointer_t<remove_reference_t<T>>;
|
||||
using const_reference_t = const T&;
|
||||
using const_pointer_t = const add_pointer_t<remove_reference_t<T>>;
|
||||
using pointer_t = T*;
|
||||
using const_reference_t = T&;
|
||||
using const_pointer_t = const T*;
|
||||
|
||||
///
|
||||
/// \brief Default Constructor
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
///
|
||||
/// \brief Fundamental Type Constructor
|
||||
/// \param val the value to initialize the underlying object with
|
||||
constexpr optional(T val) requires is_fundamental_v<T>
|
||||
constexpr optional(T val) requires(is_fundamental_v<T> or is_pointer_v<T>)
|
||||
: _val(val)
|
||||
, _set(true) {
|
||||
}
|
||||
@@ -102,7 +102,7 @@ public:
|
||||
return;
|
||||
}
|
||||
if (_set) {
|
||||
_val.~T();
|
||||
fennec::destruct(&_val);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public:
|
||||
constexpr optional& operator=(nullopt_t) {
|
||||
if constexpr(not is_fundamental_v<T>) {
|
||||
if (_set) {
|
||||
_val.~T();
|
||||
fennec::destruct(&_val);
|
||||
}
|
||||
}
|
||||
_root = '\0';
|
||||
@@ -158,7 +158,7 @@ public:
|
||||
if (_set) { // Construct
|
||||
fennec::construct(&_val, opt._val);
|
||||
} else { // Destruct
|
||||
_val.~T();
|
||||
fennec::destruct(&_val);
|
||||
_root = 0;
|
||||
}
|
||||
} else if (_set) { // Copy Assignment
|
||||
@@ -176,7 +176,7 @@ public:
|
||||
if (_set) { // Construct
|
||||
fennec::construct(&_val, fennec::move(opt._val));
|
||||
} else { // Destruct
|
||||
_val.~T();
|
||||
fennec::destruct(&_val);
|
||||
_root = 0;
|
||||
}
|
||||
} else if (_set) { // Copy Assignment
|
||||
@@ -211,7 +211,7 @@ public:
|
||||
return _set ? &_val : nullptr;
|
||||
}
|
||||
|
||||
constexpr const pointer_t operator->() const noexcept {
|
||||
constexpr const_pointer_t operator->() const noexcept {
|
||||
return _set ? &_val : nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -238,19 +238,14 @@ public:
|
||||
|
||||
class iterator {
|
||||
public:
|
||||
constexpr iterator(const set* set, size_t i)
|
||||
: _set(set)
|
||||
, _i(i) {
|
||||
}
|
||||
|
||||
constexpr ~iterator() {
|
||||
_set = nullptr;
|
||||
}
|
||||
|
||||
// prefix operator
|
||||
constexpr friend iterator& operator++(iterator& rhs) {
|
||||
while (++rhs._i < capacity()) {
|
||||
if (rhs._set->_alloc[rhs._i]) {
|
||||
while (++rhs._i < rhs._set->capacity()) {
|
||||
if (rhs._set->_alloc[rhs._i].value) {
|
||||
return rhs;
|
||||
}
|
||||
}
|
||||
@@ -280,6 +275,11 @@ public:
|
||||
const set* _set;
|
||||
size_t _i;
|
||||
friend set;
|
||||
|
||||
constexpr iterator(const set* set, size_t i)
|
||||
: _set(set)
|
||||
, _i(i) {
|
||||
}
|
||||
};
|
||||
|
||||
constexpr iterator begin() const {
|
||||
|
||||
@@ -51,8 +51,9 @@
|
||||
///
|
||||
/// | Library | Brief |
|
||||
/// | :------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
/// | \subpage fennec_lang | Implementation for functions and classes related to the C++ Language, including base types, common utility functions, and metaprogramming templates |
|
||||
/// | \subpage fennec_math | Implementation of math functions according to the [OpenGL 4.6 Shading Language Specification](https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.pdf). Additional extensions are provided for other common math functions. |
|
||||
/// | \subpage fennec_lang | Implementation for functions and classes related to the C++ Language, including base types, common utility functions, and metaprogramming templates |
|
||||
/// | \subpage fennec_math | Implementation of math functions according to the [OpenGL 4.6 Shading Language Specification](https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.pdf). Additional extensions are provided for other common math functions. |
|
||||
/// | \subpage fennec_memory | Implementation of functions related to memory management. |
|
||||
|
||||
#ifndef FENNEC_CORE_ENGINE_H
|
||||
#define FENNEC_CORE_ENGINE_H
|
||||
|
||||
61
include/fennec/core/event.h
Normal file
61
include/fennec/core/event.h
Normal file
@@ -0,0 +1,61 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef FENNEC_CORE_EVENT_H
|
||||
#define FENNEC_CORE_EVENT_H
|
||||
|
||||
#include <fennec/lang/types.h>
|
||||
#include <fennec/lang/typeuuid.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
struct event;
|
||||
|
||||
class event_listener {
|
||||
public:
|
||||
virtual ~event_listener() = default;
|
||||
virtual void handle_event(event* event) = 0;
|
||||
};
|
||||
|
||||
struct event {
|
||||
const uint64_t type;
|
||||
|
||||
event() = delete;
|
||||
|
||||
template<typename EventT>
|
||||
event() : type(typeuuid<EventT>()) { }
|
||||
|
||||
template<typename EventT>
|
||||
static void add_listener(event_listener* listener) {
|
||||
event::add_listener(listener, typeuuid<EventT, event>());
|
||||
}
|
||||
|
||||
template<typename EventT>
|
||||
static void dispatch(EventT* event) {
|
||||
dispatch(event);
|
||||
}
|
||||
|
||||
static void add_listener(event_listener* listener, uint64_t type);
|
||||
static void remove_listener(event_listener* listener);
|
||||
static void dispatch(event* event);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_CORE_EVENT_H
|
||||
@@ -149,7 +149,7 @@ public:
|
||||
bool empty() {
|
||||
size_t size = _str.size();
|
||||
if (size == 0) return true;
|
||||
#ifdef _WIN32
|
||||
#if FENNEC_PLATFORM_WINDOWS
|
||||
return (_str[1] == ':' && size == 3);
|
||||
#else
|
||||
return (_str[0] == '/' && size == 1);
|
||||
@@ -157,7 +157,7 @@ public:
|
||||
}
|
||||
|
||||
path parent() const {
|
||||
#ifdef _WIN32
|
||||
#ifdef FENNEC_PLATFORM_WINDOWS
|
||||
size_t start = _str.size() - 1;
|
||||
start = _str[start] == '/' || _str[start] == '\\' ? start - 1 : start;
|
||||
|
||||
@@ -185,7 +185,7 @@ public:
|
||||
path working; working._str.resize(0);
|
||||
|
||||
// Check if this is a rooted path;
|
||||
#ifdef _WIN32
|
||||
#ifdef FENNEC_PLATFORM_WINDOWS
|
||||
if (_str[1] != ':') {
|
||||
#else
|
||||
if (_str[0] != '/') {
|
||||
|
||||
@@ -67,6 +67,12 @@ public:
|
||||
: _str(nullptr), _size(0), _const(true) {
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Default Constructor, initializes with nullptr
|
||||
constexpr cstring(nullptr_t)
|
||||
: _str(nullptr), _size(0), _const(true) {
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Buffer Constructor, wraps the provided C-Style string
|
||||
/// \param str the buffer to wrap
|
||||
@@ -129,11 +135,16 @@ public:
|
||||
constexpr cstring(const cstring&) = delete;
|
||||
constexpr ~cstring() = default;
|
||||
|
||||
constexpr cstring& operator=(nullptr_t) {
|
||||
_str = nullptr, _size = 0, _const = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// TODO: Document
|
||||
template<size_t n>
|
||||
constexpr cstring& operator=(char(&str)[n]) {
|
||||
assert(_str[n - 1] == '\0', "Invalid NTBS.");
|
||||
_str = str; _size = n - 1; _const = false;
|
||||
_str = str, _size = n - 1, _const = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -160,6 +171,10 @@ public:
|
||||
/// \returns the size of the string excluding its null terminator, i.e. `(*str)[size()] == '\0'`
|
||||
constexpr size_t size() const { return _size; }
|
||||
|
||||
constexpr bool empty() const {
|
||||
return _cstr == nullptr || _size == 0;
|
||||
}
|
||||
|
||||
|
||||
// Access ==============================================================================================================
|
||||
|
||||
@@ -220,6 +235,15 @@ public:
|
||||
return ::strncmp(_cstr + i, str, n);
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief String Equality
|
||||
/// \param str the string to compare against
|
||||
/// \returns True if all characters are equal, false otherwise
|
||||
template<size_t n>
|
||||
constexpr bool operator==(const char (&str)[n]) const {
|
||||
return compare(cstring(str)) == 0;
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief String Equality
|
||||
/// \param str the string to compare against
|
||||
|
||||
@@ -78,18 +78,6 @@ public:
|
||||
fennec::memset(_str.data(), c, n);
|
||||
_str[n] = '\0';
|
||||
}
|
||||
///
|
||||
/// \brief Buffer Copy Constructor
|
||||
/// \param str the buffer to copy
|
||||
/// \tparam n number of characters in the buffer
|
||||
///
|
||||
/// \details adds additional character for null termination. Ignores whether str is null-terminated.
|
||||
/// This constructor makes the assumption that `len` is the intended number of characters.
|
||||
template<size_t n>
|
||||
constexpr _string(const char str[n])
|
||||
: _str(str, n + 1) {
|
||||
_str[n] = '\0';
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Buffer Copy Constructor
|
||||
@@ -327,6 +315,10 @@ public:
|
||||
/// \param str the string to copy
|
||||
/// \returns a reference to `this`
|
||||
constexpr _string& operator=(const cstring& str) {
|
||||
if (str.empty()) {
|
||||
_str.deallocate();
|
||||
return *this;
|
||||
}
|
||||
resize(str.size());
|
||||
fennec::memcpy(_str.data(), str, str.size());
|
||||
_str[str.size()] = '\0';
|
||||
|
||||
@@ -71,6 +71,12 @@ public:
|
||||
, _const(true) {
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Default Constructor, initializes with nullptr
|
||||
constexpr wcstring(nullptr_t)
|
||||
: _str(nullptr), _size(0), _const(true) {
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Buffer Constructor, wraps the provided C-Style string
|
||||
/// \param str the buffer to wrap
|
||||
@@ -133,6 +139,11 @@ public:
|
||||
constexpr wcstring(const wcstring&) = delete;
|
||||
constexpr ~wcstring() = default;
|
||||
|
||||
constexpr wcstring& operator=(nullptr_t) {
|
||||
_str = nullptr, _size = 0, _const = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// TODO: Document
|
||||
template<size_t n>
|
||||
constexpr wcstring& operator=(wchar_t(&str)[n]) {
|
||||
@@ -164,6 +175,10 @@ public:
|
||||
/// \returns the size of the string excluding its null terminator, i.e. `(*str)[size()] == '\0'`
|
||||
constexpr size_t size() const { return _size; }
|
||||
|
||||
constexpr bool empty() const {
|
||||
return _cstr == nullptr || _size == 0;
|
||||
}
|
||||
|
||||
|
||||
// Access ==============================================================================================================
|
||||
|
||||
|
||||
@@ -59,45 +59,32 @@ public:
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Sized Constructor, initializes a null-terminated string of size `n` with null wchar_tacters
|
||||
/// \param n the number of wchar_tacters
|
||||
/// \brief Sized Constructor, initializes a null-terminated string of size `n` with null characters
|
||||
/// \param n the number of characters
|
||||
///
|
||||
/// \details adds additional wchar_tacter for null termination.
|
||||
/// \details adds additional character for null termination.
|
||||
constexpr _wstring(size_t n)
|
||||
: _wstring('\0', n) {
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Sized Constructor, initializes a null-terminated string of size `n` filled with the wchar_tacter `c`
|
||||
/// \param c the wchar_tacter to fill with
|
||||
/// \param n the number of wchar_tacters
|
||||
/// \brief Sized Constructor, initializes a null-terminated string of size `n` filled with the character `c`
|
||||
/// \param c the characters to fill with
|
||||
/// \param n the number of characters
|
||||
///
|
||||
/// \details adds additional wchar_tacter for null termination.
|
||||
/// \details adds additional character for null termination.
|
||||
constexpr _wstring(wchar_t c, size_t n)
|
||||
: _str(n + 1) {
|
||||
fennec::wmemset(_str.data(), c, n); _str[n] = '\0';
|
||||
}
|
||||
///
|
||||
/// \brief Buffer Copy Constructor
|
||||
/// \param str the buffer to copy
|
||||
/// \param len number of wchar_tacters in the buffer
|
||||
///
|
||||
/// \details adds additional wchar_tacter for null termination. Ignores whether str is null-terminated.
|
||||
/// This constructor makes the assumption that `len` is the intended number of wchar_tacters.
|
||||
template<size_t n>
|
||||
constexpr _wstring(const wchar_t str[n])
|
||||
: _str(str, n + 1) {
|
||||
::wcsncpy(_str.data(), str, n);
|
||||
_str[n] = '\0';
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Buffer Copy Constructor
|
||||
/// \param str the buffer to copy
|
||||
/// \param len number of wchar_tacters in the buffer
|
||||
/// \param len number of characters in the buffer
|
||||
///
|
||||
/// \details adds additional wchar_tacter for null termination. Ignores whether str is null-terminated.
|
||||
/// This constructor makes the assumption that `len` is the intended number of wchar_tacters.
|
||||
/// \details adds additional character for null termination. Ignores whether str is null-terminated.
|
||||
/// This constructor makes the assumption that `len` is the intended number of characters.
|
||||
constexpr _wstring(const wchar_t* str, size_t n)
|
||||
: _str(str, n + 1) {
|
||||
::wcsncpy(_str.data(), str, n);
|
||||
@@ -107,10 +94,10 @@ public:
|
||||
///
|
||||
/// \brief Buffer Copy Constructor
|
||||
/// \param str the buffer to copy
|
||||
/// \param len number of wchar_tacters in the buffer
|
||||
/// \param len number of characters in the buffer
|
||||
///
|
||||
/// \details adds additional wchar_tacter for null termination. Ignores whether str is null-terminated.
|
||||
/// This constructor makes the assumption that `len` is the intended number of wchar_tacters.
|
||||
/// \details adds additional character for null termination. Ignores whether str is null-terminated.
|
||||
/// This constructor makes the assumption that `len` is the intended number of characters.
|
||||
constexpr _wstring(const wcstring& str)
|
||||
: _str(str, str.size() + 1) {
|
||||
_str[str.size()] = '\0';
|
||||
@@ -149,7 +136,7 @@ public:
|
||||
///
|
||||
/// \brief Array Access Operator
|
||||
/// \param i the index to access
|
||||
/// \returns a reference to the wchar_tacter
|
||||
/// \returns a reference to the character
|
||||
constexpr wchar_t& operator[](int i) {
|
||||
return _str[i];
|
||||
}
|
||||
@@ -157,7 +144,7 @@ public:
|
||||
///
|
||||
/// \brief Const-Array Access Operator
|
||||
/// \param i the index to access
|
||||
/// \returns a copy of the wchar_tacter
|
||||
/// \returns a copy of the character
|
||||
constexpr wchar_t operator[](int i) const {
|
||||
assertd(i >= 0 && i < size(), "Array Out of Bounds");
|
||||
return _str[i];
|
||||
@@ -219,7 +206,7 @@ public:
|
||||
|
||||
///
|
||||
/// \brief Finds the index of the first occurrence of `c` in the string
|
||||
/// \param c the wchar_tacter to find
|
||||
/// \param c the character to find
|
||||
/// \returns The index of `c` if it occurs in the string, otherwise returns `size()`
|
||||
constexpr size_t find(wchar_t c, size_t i = 0) const {
|
||||
if (i >= size()) { // bounds check
|
||||
@@ -332,6 +319,10 @@ public:
|
||||
/// \param str the string to copy
|
||||
/// \returns a reference to `this`
|
||||
constexpr wstring& operator=(const wcstring& str) {
|
||||
if (str.empty()) {
|
||||
_str.deallocate();
|
||||
return *this;
|
||||
}
|
||||
if (str.size() > size()) resize(str.size());
|
||||
fennec::wmemcpy(_str.data(), str, str.size());
|
||||
_str[str.size()] = L'\0';
|
||||
@@ -361,7 +352,7 @@ public:
|
||||
///
|
||||
/// \brief Retrieve a substring of a string
|
||||
/// \param i the start index
|
||||
/// \param n the number of wchar_tacters
|
||||
/// \param n the number of characters
|
||||
/// \return
|
||||
constexpr wstring substring(size_t i, size_t n = npos) const {
|
||||
if (i >= size()) {
|
||||
@@ -378,7 +369,7 @@ public:
|
||||
constexpr wstring operator+(wchar_t c) const {
|
||||
// Copy contents with one additional byte.
|
||||
wstring res(_str, _str.size());
|
||||
res[size()] = c; // Set the last wchar_tacter to c
|
||||
res[size()] = c; // Set the last character to c
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
///
|
||||
///
|
||||
|
||||
#if _MSC_VER
|
||||
#if FENNEC_COMPILER_MSVC
|
||||
#define __PRETTY_FUNCTION__ __FUNCSIG__
|
||||
#endif
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
#ifndef FENNEC_LANG_CONSTANTS_H
|
||||
#define FENNEC_LANG_CONSTANTS_H
|
||||
|
||||
#include <fennec/lang/types.h>
|
||||
|
||||
///
|
||||
///
|
||||
/// \page fennec_lang_constants Constants
|
||||
@@ -61,8 +63,6 @@
|
||||
/// </table>
|
||||
///
|
||||
|
||||
#include <fennec/lang/types.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#ifndef FENNEC_LANG_DETAIL_INT_H
|
||||
#define FENNEC_LANG_DETAIL_INT_H
|
||||
|
||||
#if _MSC_VER
|
||||
#if FENNEC_COMPILER_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4117)
|
||||
|
||||
|
||||
@@ -16,12 +16,20 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_SYM_DEF_H
|
||||
#define FENNEC_PLATFORM_LINUX_WAYLAND_SYM_DEF_H
|
||||
#ifndef FENNEC_LANG_DETAIL_TYPEUUID_H
|
||||
#define FENNEC_LANG_DETAIL_TYPEUUID_H
|
||||
|
||||
#define FENNEC_LIB(name) inline bool FENNEC_HAS_LIB_##name = false;
|
||||
#define FENNEC_SYMBOL(ret, fn, ...) using sym_##fn = ret(*)(__VA_ARGS__); \
|
||||
inline sym_##fn fn = nullptr;
|
||||
#include <fennec/platform/linux/wayland/lib/sym.h>
|
||||
#include <fennec/lang/types.h>
|
||||
|
||||
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_SYM_DEF_H
|
||||
namespace fennec::detail
|
||||
{
|
||||
|
||||
template<typename RootT>
|
||||
FENNEC_NO_INLINE uint64_t __typeuuid() {
|
||||
static uint64_t i = 0;
|
||||
return ++i;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_LANG_DETAIL_TYPEUUID_H
|
||||
@@ -54,8 +54,10 @@ struct hash<IntT> : hash<uint64_t> {
|
||||
|
||||
// Wrapper for pointers
|
||||
template<typename PtrT>
|
||||
requires is_pointer_v<PtrT>
|
||||
struct hash<PtrT> : hash<uintptr_t> {
|
||||
struct hash<PtrT*> : hash<uintptr_t> {
|
||||
constexpr size_t operator()(PtrT* ptr) const {
|
||||
return hash<uintptr_t>::operator()((uintptr_t)(const void*)ptr);
|
||||
}
|
||||
};
|
||||
|
||||
// Float
|
||||
|
||||
@@ -251,7 +251,7 @@
|
||||
|
||||
// TODO: More compiler support
|
||||
|
||||
#if _MSC_VER
|
||||
#if FENNEC_COMPILER_MSVC
|
||||
|
||||
# define FENNEC_HAS_BUILTIN_ADDRESS_OF 1
|
||||
# define FENNEC_BUILTIN_ADDRESS_OF(arg) __builtin_addressof(arg)
|
||||
|
||||
@@ -119,6 +119,14 @@ template<typename T> auto declval() noexcept -> decltype(detail::__declval<T>(0)
|
||||
return detail::__declval<T>(0);
|
||||
}
|
||||
|
||||
constexpr inline bool is_constant_evaluated() noexcept {
|
||||
if consteval {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// fennec::is_void =====================================================================================================
|
||||
|
||||
|
||||
@@ -263,15 +263,15 @@ namespace fennec
|
||||
/// \name Sized Integer Types
|
||||
/// @{
|
||||
|
||||
using int8_t = schar_t; ///< \brief Signed 8-bit integer
|
||||
using int16_t = short_t; ///< \brief Signed 16-bit integer
|
||||
using int32_t = conditional_t<sizeof(int_t) == 4, int_t, long_t>; ///< \brief Signed 32-bit integer
|
||||
using int64_t = conditional_t<sizeof(long_t) == 8, long_t, llong_t>; ///< \brief Signed 64-bit integer
|
||||
using int8_t = ::int8_t; ///< \brief Signed 8-bit integer
|
||||
using int16_t = ::int16_t; ///< \brief Signed 16-bit integer
|
||||
using int32_t = ::int32_t; ///< \brief Signed 32-bit integer
|
||||
using int64_t = ::int64_t; ///< \brief Signed 64-bit integer
|
||||
|
||||
using uint8_t = uchar_t; ///< \brief Unsigned 8-bit integer
|
||||
using uint16_t = ushort_t; ///< \brief Unsigned 16-bit integer
|
||||
using uint32_t = conditional_t<sizeof(uint_t) == 4, uint_t, ulong_t>; ///< \brief Unsigned 32-bit integer
|
||||
using uint64_t = conditional_t<sizeof(ulong_t) == 8, ulong_t, ullong_t>; ///< \brief Unsigned 64-bit integer
|
||||
using uint8_t = ::uint8_t; ///< \brief Unsigned 8-bit integer
|
||||
using uint16_t = ::uint16_t; ///< \brief Unsigned 16-bit integer
|
||||
using uint32_t = ::uint32_t; ///< \brief Unsigned 32-bit integer
|
||||
using uint64_t = ::uint64_t; ///< \brief Unsigned 64-bit integer
|
||||
|
||||
/// @}
|
||||
|
||||
|
||||
47
include/fennec/lang/typeuuid.h
Normal file
47
include/fennec/lang/typeuuid.h
Normal file
@@ -0,0 +1,47 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef FENNEC_LANG_TYPEUUID_H
|
||||
#define FENNEC_LANG_TYPEUUID_H
|
||||
|
||||
#include <fennec/lang/assert.h>
|
||||
#include <fennec/lang/types.h>
|
||||
#include <fennec/lang/type_traits.h>
|
||||
|
||||
#include <fennec/lang/detail/__typeuuid.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
constexpr uint64_t nullid = 0;
|
||||
|
||||
template<typename TypeT, typename RootT = void>
|
||||
FENNEC_NO_INLINE uint64_t typeuuid() {
|
||||
assertf(not is_constant_evaluated(), "Type UUIDs Cannot Be Obtained at Compile Time");
|
||||
|
||||
static bool init = false;
|
||||
static uint64_t id = nullid;
|
||||
|
||||
if (init) return id;
|
||||
init = true;
|
||||
return id = detail::__typeuuid<RootT>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_LANG_TYPEUUID_H
|
||||
@@ -275,7 +275,7 @@
|
||||
|
||||
#include <fennec/math/vector.h>
|
||||
|
||||
#if _MSC_VER
|
||||
#if FENNEC_COMPILER_MSVC
|
||||
#define isnanf(x) isnan(x)
|
||||
#define isinff(x) isinf(x)
|
||||
#endif
|
||||
|
||||
@@ -531,7 +531,7 @@
|
||||
///
|
||||
///
|
||||
|
||||
#if _MSC_VER
|
||||
#if FENNEC_COMPILER_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4305)
|
||||
#endif
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
#endif
|
||||
|
||||
#if _MSC_VER
|
||||
#if FENNEC_COMPILER_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4201)
|
||||
#endif
|
||||
@@ -606,7 +606,7 @@ namespace fennec::detail
|
||||
|
||||
}
|
||||
|
||||
#ifdef __GNUC__
|
||||
#ifdef FENNEC_COMPILER_GCC
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include <fennec/math/common.h>
|
||||
|
||||
|
||||
#ifdef __GNUC__
|
||||
#ifdef FENNEC_COMPILER_GCC
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wchanges-meaning"
|
||||
#endif
|
||||
@@ -302,20 +302,20 @@ public:
|
||||
///
|
||||
/// \brief Default Constructor, initializes internal data to `null` and the capacity to `0`
|
||||
constexpr allocation() noexcept
|
||||
: _data(nullptr), _capacity(0) {
|
||||
: _data(nullptr), _capacity(0), _alignment(zero<align_t>()) {
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Sized Constructor, initializes the allocation with a block of size `n * sizeof(T)` bytes
|
||||
/// \param n The number of elements of type `T` to allocate for
|
||||
constexpr allocation(size_t n) noexcept
|
||||
: _data(nullptr), _capacity(0) {
|
||||
explicit constexpr allocation(size_t n) noexcept
|
||||
: _data(nullptr), _capacity(0), _alignment(zero<align_t>()) {
|
||||
allocate(n);
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Buffer Copy Constructor, initializes the allocation with a block of size `n * sizeof(T)` bytes.
|
||||
/// Then, the contents of data are copied into the allocation.
|
||||
/// Then, the contents of data are byte copied into the allocation.
|
||||
/// \param data the buffer to copy
|
||||
/// \param n the number of elements
|
||||
constexpr allocation(const T* data, size_t n)
|
||||
@@ -330,13 +330,13 @@ public:
|
||||
constexpr allocation(size_t n, align_t align) noexcept
|
||||
: _data(nullptr)
|
||||
, _capacity(0)
|
||||
, _alignment(zero<align_t>()) {
|
||||
, _alignment(align) {
|
||||
allocate(n, align);
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Buffer Copy Constructor, initializes the allocation with a block of size `n * sizeof(T)` bytes.
|
||||
/// Then, the contents of data are copied into the allocation.
|
||||
/// Then, the contents of data are byte copied into the allocation.
|
||||
/// \param data the buffer to copy
|
||||
/// \param n the number of elements
|
||||
/// \param align The alignment of the allocation
|
||||
@@ -350,10 +350,11 @@ public:
|
||||
/// \param alloc The allocation object to copy.
|
||||
///
|
||||
/// \details This constructor should be used when the type `AllocT` needs internal data.
|
||||
constexpr allocation(const alloc_t& alloc) noexcept
|
||||
explicit constexpr allocation(const alloc_t& alloc) noexcept
|
||||
: _alloc(alloc)
|
||||
, _data(nullptr)
|
||||
, _capacity(0) {
|
||||
, _capacity(0)
|
||||
, _alignment(zero<align_t>()){
|
||||
}
|
||||
|
||||
///
|
||||
@@ -417,7 +418,8 @@ public:
|
||||
constexpr allocation(const allocation& alloc) noexcept
|
||||
: _alloc(alloc._alloc)
|
||||
, _data(_alloc.allocate(alloc._capacity))
|
||||
, _capacity(alloc._capacity) {
|
||||
, _capacity(alloc._capacity)
|
||||
, _alignment(alloc._alignment) {
|
||||
fennec::memcpy(_data, alloc._data, alloc._capacity * sizeof(T));
|
||||
}
|
||||
|
||||
@@ -428,7 +430,8 @@ public:
|
||||
constexpr allocation(allocation&& alloc) noexcept
|
||||
: _alloc(alloc._alloc)
|
||||
, _data(alloc._data)
|
||||
, _capacity(alloc._capacity) {
|
||||
, _capacity(alloc._capacity)
|
||||
, _alignment(alloc._alignment) {
|
||||
alloc._data = nullptr; alloc._capacity = 0;
|
||||
}
|
||||
|
||||
@@ -524,7 +527,7 @@ public:
|
||||
|
||||
value_t* old = _data;
|
||||
_data = _alloc.allocate(n);
|
||||
fennec::memcpy(_data, old, min(_capacity, n) * sizeof(T));
|
||||
fennec::memcpy(static_cast<void*>(_data), old, min(_capacity, n) * sizeof(T));
|
||||
_alloc.deallocate(old);
|
||||
_capacity = n;
|
||||
}
|
||||
@@ -591,7 +594,7 @@ private:
|
||||
align_t _alignment; // Alignment information
|
||||
};
|
||||
|
||||
#ifdef __GNUC__
|
||||
#ifdef FENNEC_COMPILER_GCC
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
/// \param arr the buffer to wrap
|
||||
/// \tparam n the size of the buffer in elements
|
||||
template<typename T, size_t n>
|
||||
constexpr byte_array(T arr[n])
|
||||
constexpr byte_array(T (&arr)[n])
|
||||
: byte_array(arr, n * sizeof(T)) {
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
/// \param arr the buffer to wrap
|
||||
/// \tparam n the size of the buffer in elements
|
||||
template<typename T, size_t n>
|
||||
constexpr byte_array(const T arr[n])
|
||||
constexpr byte_array(const T (&arr)[n])
|
||||
: byte_array(arr, n * sizeof(T)) {
|
||||
}
|
||||
|
||||
|
||||
@@ -23,14 +23,14 @@
|
||||
// see https://git.mslockbo.org/mslockbo/fennec/src/commit/0eeb7ae3cff9d78e98dc5d9fc09bcb98b10986b9 for previous
|
||||
// implementation
|
||||
|
||||
#if __GNUC__
|
||||
#if FENNEC_COMPILER_GCC
|
||||
#define __OPTIMIZE__
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#if __GNUC__
|
||||
#if FENNEC_COMPILER_GCC
|
||||
#undef __OPTIMIZE__
|
||||
#endif
|
||||
|
||||
|
||||
@@ -101,5 +101,8 @@ void operator delete[](void* ptr, fennec::size_t, fennec::align_t) noexcept;
|
||||
void operator delete (void* ptr, fennec::align_t, const fennec::nothrow_t&) noexcept;
|
||||
void operator delete[](void* ptr, fennec::align_t, const fennec::nothrow_t&) noexcept;
|
||||
|
||||
template<typename TypeT> constexpr void* operator new (fennec::size_t, TypeT* ptr) { return ptr; }
|
||||
template<typename TypeT> constexpr void* operator new[](fennec::size_t, TypeT* ptr) { return ptr; }
|
||||
|
||||
|
||||
#endif // FENNEC_MEMORY_NEW_H
|
||||
|
||||
71
include/fennec/platform/interface/displaydev.h
Normal file
71
include/fennec/platform/interface/displaydev.h
Normal file
@@ -0,0 +1,71 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef FENNEC_PLATFORM_INTERFACE_DISPLAYDEV_H
|
||||
#define FENNEC_PLATFORM_INTERFACE_DISPLAYDEV_H
|
||||
|
||||
#include <fennec/platform/interface/fwd.h>
|
||||
#include <fennec/platform/interface/window.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
///
|
||||
/// \brief Interface for display management
|
||||
class displaydev
|
||||
{
|
||||
public:
|
||||
struct pixel_format {
|
||||
uint8_t depth;
|
||||
uint8_t r, g, b;
|
||||
};
|
||||
|
||||
struct config {
|
||||
pixel_format format;
|
||||
};
|
||||
|
||||
virtual bool connected() const = 0;
|
||||
virtual ~displaydev() = default;
|
||||
|
||||
virtual window* create_window() = 0;
|
||||
|
||||
const pixel_format& get_color_format() const {
|
||||
return _config.format;
|
||||
}
|
||||
|
||||
template<typename ContextT>
|
||||
ContextT* get_context() {
|
||||
return static_cast<ContextT*>(_context);
|
||||
}
|
||||
|
||||
template<typename PlatformT>
|
||||
PlatformT* get_platform() {
|
||||
return static_cast<PlatformT*>(_platform);
|
||||
}
|
||||
|
||||
protected:
|
||||
platform* _platform;
|
||||
gfxcontext* _context;
|
||||
config _config;
|
||||
|
||||
displaydev(platform* platform);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_PLATFORM_INTERFACE_DISPLAYDEV_H
|
||||
@@ -22,8 +22,11 @@
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class platform;
|
||||
class window;
|
||||
class display;
|
||||
class displaydev;
|
||||
class gfxcontext;
|
||||
class gfxsurface;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -16,30 +16,28 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef FENNEC_PLATFORM_INTERFACE_DISPLAY_H
|
||||
#define FENNEC_PLATFORM_INTERFACE_DISPLAY_H
|
||||
#ifndef FENNEC_PLATFORM_INTERFACE_GFXCONTEXT_H
|
||||
#define FENNEC_PLATFORM_INTERFACE_GFXCONTEXT_H
|
||||
|
||||
#include <fennec/platform/interface/fwd.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
///
|
||||
/// \brief Interface for display management
|
||||
class display
|
||||
{
|
||||
class gfxcontext {
|
||||
public:
|
||||
struct config {
|
||||
template<typename TypeT>
|
||||
TypeT* get_device() {
|
||||
return static_cast<TypeT*>(_device);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
virtual bool connected() const = 0;
|
||||
virtual ~display() = default;
|
||||
protected:
|
||||
gfxcontext(displaydev* device);
|
||||
|
||||
private:
|
||||
config _config;
|
||||
displaydev* _device;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_PLATFORM_INTERFACE_DISPLAY_H
|
||||
#endif // FENNEC_PLATFORM_INTERFACE_GFXCONTEXT_H
|
||||
48
include/fennec/platform/interface/gfxsurface.h
Normal file
48
include/fennec/platform/interface/gfxsurface.h
Normal file
@@ -0,0 +1,48 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef FENNEC_PLATFORM_INTERFACE_GFXSURFACE_H
|
||||
#define FENNEC_PLATFORM_INTERFACE_GFXSURFACE_H
|
||||
|
||||
#include <fennec/platform/interface/fwd.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class gfxsurface {
|
||||
template<typename ContextT>
|
||||
ContextT* get_context() {
|
||||
return static_cast<ContextT*>(_context);
|
||||
}
|
||||
|
||||
template<typename WindowT>
|
||||
WindowT* get_window() {
|
||||
return static_cast<WindowT*>(_window);
|
||||
}
|
||||
|
||||
protected:
|
||||
gfxsurface(window* window, gfxcontext* context);
|
||||
|
||||
private:
|
||||
window* _window;
|
||||
gfxcontext* _context;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_PLATFORM_INTERFACE_GFXSURFACE_H
|
||||
@@ -16,31 +16,21 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_DISPLAY_H
|
||||
#define FENNEC_PLATFORM_LINUX_WAYLAND_DISPLAY_H
|
||||
|
||||
#include <fennec/fproc/strings/cstring.h>
|
||||
#include <fennec/platform/interface/display.h>
|
||||
|
||||
#include <fennec/platform/linux/platform.h>
|
||||
#include <fennec/platform/linux/wayland/lib/fwd.h>
|
||||
#ifndef FENNEC_PLATFORM_INTERFACE_INPUTDEVICE_H
|
||||
#define FENNEC_PLATFORM_INTERFACE_INPUTDEVICE_H
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class wayland_display : public display {
|
||||
class inputdevice {
|
||||
public:
|
||||
wayland_display(linux_platform* platform);
|
||||
wayland_display(linux_platform* platform, const cstring& drv);
|
||||
~wayland_display() override;
|
||||
|
||||
bool connected() const override;
|
||||
virtual bool has_keyboard() = 0;
|
||||
virtual bool has_mouse() = 0;
|
||||
virtual bool has_touch() = 0;
|
||||
|
||||
private:
|
||||
struct wl_display* _handle;
|
||||
linux_platform* _platform;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_DISPLAY_H
|
||||
#endif // FENNEC_PLATFORM_INTERFACE_INPUTDEVICE_H
|
||||
@@ -29,19 +29,14 @@ class platform {
|
||||
public:
|
||||
using shared_object = struct shared_object;
|
||||
using function_pointer = void (*)(void);
|
||||
using global = void*;
|
||||
|
||||
struct shared_lib {
|
||||
shared_object* _lib;
|
||||
const cstring _name;
|
||||
};
|
||||
|
||||
enum class user {
|
||||
client,
|
||||
server
|
||||
};
|
||||
|
||||
struct config {
|
||||
user type;
|
||||
};
|
||||
|
||||
// Functions with default implementations
|
||||
@@ -52,17 +47,18 @@ public:
|
||||
|
||||
// Pure Virtual Functions
|
||||
|
||||
virtual display* get_display() = 0;
|
||||
virtual displaydev* get_display() = 0;
|
||||
|
||||
virtual shared_object* load_object(const cstring& file) = 0;
|
||||
virtual void unload_object(shared_object* obj) = 0;
|
||||
|
||||
virtual function_pointer find_symbol(shared_object* hndl, const cstring& name) = 0;
|
||||
virtual global find_global(shared_object* hndl, const cstring& name) = 0;
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
platform(user t);
|
||||
platform();
|
||||
virtual ~platform() = default;
|
||||
|
||||
private:
|
||||
|
||||
@@ -19,8 +19,10 @@
|
||||
#ifndef FENNEC_PLATFORM_INTERFACE_WINDOW_H
|
||||
#define FENNEC_PLATFORM_INTERFACE_WINDOW_H
|
||||
|
||||
#include <fennec/containers/optional.h>
|
||||
#include <fennec/fproc/strings/string.h>
|
||||
#include <fennec/platform/interface/fwd.h>
|
||||
#include <fennec/platform/interface/gfxsurface.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
@@ -45,19 +47,18 @@ public:
|
||||
flags_block_screensaver = 0x1 << 4,
|
||||
};
|
||||
|
||||
union bits {
|
||||
uint32_t depth;
|
||||
uint8_t r, g, b, a;
|
||||
};
|
||||
|
||||
struct config {
|
||||
string title;
|
||||
uint32_t flags;
|
||||
size_t width, height;
|
||||
fullscreen_mode fullscreen;
|
||||
bits bit_depth;
|
||||
};
|
||||
|
||||
virtual bool running() = 0;
|
||||
virtual void configure(const config& config) = 0;
|
||||
virtual bool initialize(bool modal) = 0;
|
||||
virtual bool shutdown() = 0;
|
||||
|
||||
virtual bool set_title(const cstring& title) = 0;
|
||||
virtual bool set_title(const string& title) = 0;
|
||||
|
||||
@@ -74,60 +75,76 @@ public:
|
||||
virtual bool block_screensaver(bool e) = 0;
|
||||
|
||||
bool is_child() const {
|
||||
return _config.flags & flags_child;
|
||||
if (not _config) return false;
|
||||
return _config->flags & flags_child;
|
||||
}
|
||||
|
||||
bool is_modal() const {
|
||||
return _config.flags & flags_modal;
|
||||
if (not _config) return false;
|
||||
return _config->flags & flags_modal;
|
||||
}
|
||||
|
||||
display* get_display() {
|
||||
displaydev* get_display() {
|
||||
return _display;
|
||||
}
|
||||
|
||||
const display* get_display() const {
|
||||
const displaydev* get_display() const {
|
||||
return _display;
|
||||
}
|
||||
|
||||
|
||||
const string& get_title() const {
|
||||
return _config.title;
|
||||
static const string _null = { "null" };
|
||||
if (not _config) return _null;
|
||||
return _config->title;
|
||||
}
|
||||
|
||||
|
||||
size_t get_width() const {
|
||||
return _config.width;
|
||||
if (not _config) return false;
|
||||
return _config->width;
|
||||
}
|
||||
|
||||
size_t get_height() const {
|
||||
return _config.height;
|
||||
if (not _config) return false;
|
||||
return _config->height;
|
||||
}
|
||||
|
||||
|
||||
fullscreen_mode get_fullscreen_mode() const {
|
||||
return _config.fullscreen;
|
||||
if (not _config) return fullscreen_mode::windowed;
|
||||
return _config->fullscreen;
|
||||
}
|
||||
|
||||
|
||||
bool is_keyboard_grabbed() const {
|
||||
return _config.flags & flags_grab_keyboard;
|
||||
if (not _config) return false;
|
||||
return _config->flags & flags_grab_keyboard;
|
||||
}
|
||||
|
||||
bool is_mouse_grabbed() const {
|
||||
return _config.flags & flags_grab_mouse;
|
||||
if (not _config) return false;
|
||||
return _config->flags & flags_grab_mouse;
|
||||
}
|
||||
|
||||
bool is_screensaver_blocked() const {
|
||||
return _config.flags & flags_block_screensaver;
|
||||
if (not _config) return false;
|
||||
return _config->flags & flags_block_screensaver;
|
||||
}
|
||||
|
||||
template<class DisplayT>
|
||||
DisplayT* get_display() {
|
||||
return static_cast<DisplayT*>(_display);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ~window() = default;
|
||||
window(display* display, window* parent, bool modal);
|
||||
window(displaydev* display, window* parent);
|
||||
|
||||
display* _display;
|
||||
window* _parent;
|
||||
config _config;
|
||||
displaydev* _display;
|
||||
window* _parent;
|
||||
optional<config> _config;
|
||||
gfxsurface* _context;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#define FENNEC_PLATFORM_LINUX_PLATFORM_H
|
||||
|
||||
#include <fennec/containers/set.h>
|
||||
#include <fennec/platform/interface/display.h>
|
||||
#include <fennec/platform/interface/displaydev.h>
|
||||
#include <fennec/platform/interface/platform.h>
|
||||
|
||||
namespace fennec
|
||||
@@ -34,18 +34,20 @@ public:
|
||||
display_wayland,
|
||||
};
|
||||
|
||||
linux_platform(user type);
|
||||
linux_platform();
|
||||
~linux_platform() override;
|
||||
|
||||
shared_object* load_object(const cstring& file) override;
|
||||
void unload_object(shared_object* obj) override;
|
||||
function_pointer find_symbol(shared_object* hndl, const cstring& name) override;
|
||||
void unload_object(shared_object* obj) override;
|
||||
|
||||
display* get_display() override;
|
||||
function_pointer find_symbol(shared_object* hndl, const cstring& name) override;
|
||||
global find_global(shared_object* hndl, const cstring& name) override;
|
||||
|
||||
displaydev* get_display() override;
|
||||
|
||||
|
||||
private:
|
||||
display* _display;
|
||||
displaydev* _display;
|
||||
int_t _display_driver;
|
||||
|
||||
void _runtime_client_checks();
|
||||
|
||||
71
include/fennec/platform/linux/wayland/displaydev.h
Normal file
71
include/fennec/platform/linux/wayland/displaydev.h
Normal file
@@ -0,0 +1,71 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_DISPLAY_H
|
||||
#define FENNEC_PLATFORM_LINUX_WAYLAND_DISPLAY_H
|
||||
|
||||
#include <fennec/containers/list.h>
|
||||
#include <fennec/fproc/strings/cstring.h>
|
||||
|
||||
#include <fennec/platform/interface/displaydev.h>
|
||||
|
||||
#include <fennec/platform/linux/platform.h>
|
||||
#include <fennec/platform/linux/wayland/fwd.h>
|
||||
#include <fennec/platform/linux/wayland/lib/wayland-client.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class wayland_display : public displaydev {
|
||||
public:
|
||||
wayland_display(linux_platform* platform);
|
||||
wayland_display(linux_platform* platform, const cstring& drv);
|
||||
~wayland_display() override;
|
||||
|
||||
bool connected() const override;
|
||||
|
||||
window* create_window() override;
|
||||
|
||||
inline wl_display* get_handle() { return _handle; }
|
||||
inline wl_registry* get_registry() { return _registry; }
|
||||
inline wl_compositor* get_compositor() { return _compositor; }
|
||||
inline wl_shell* get_shell() { return _shell; }
|
||||
inline wl_seat* get_seat() { return _seat; }
|
||||
inline wl_pointer* get_pointer() { return _pointer; }
|
||||
inline wl_keyboard* get_keyboard() { return _keyboard; }
|
||||
inline wl_shm* get_shm() { return _shm; }
|
||||
|
||||
private:
|
||||
wl_display* _handle;
|
||||
wl_registry* _registry;
|
||||
wl_compositor* _compositor;
|
||||
wl_shell* _shell;
|
||||
wl_seat* _seat;
|
||||
wl_pointer* _pointer;
|
||||
wl_keyboard* _keyboard;
|
||||
wl_shm* _shm;
|
||||
list<wayland_window*> _windows;
|
||||
|
||||
static void listen_global(void*, wl_registry*, uint32_t, const char*, uint32_t);
|
||||
static void listen_global_remove(void*, wl_registry*, uint32_t);
|
||||
static void listen_seat(void*, wl_seat*, uint32_t);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_DISPLAY_H
|
||||
30
include/fennec/platform/linux/wayland/fwd.h
Normal file
30
include/fennec/platform/linux/wayland/fwd.h
Normal file
@@ -0,0 +1,30 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_FWD_H
|
||||
#define FENNEC_PLATFORM_LINUX_WAYLAND_FWD_H
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class wayland_display;
|
||||
class wayland_window;
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_FWD_H
|
||||
@@ -16,9 +16,46 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_FWD_H
|
||||
#define FENNEC_PLATFORM_LINUX_WAYLAND_FWD_H
|
||||
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_LIB_FWD_H
|
||||
#define FENNEC_PLATFORM_LINUX_WAYLAND_LIB_FWD_H
|
||||
|
||||
#include <fennec/lang/types.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
struct wl_object;
|
||||
struct wl_proxy;
|
||||
struct wl_display;
|
||||
struct wl_event_queue;
|
||||
struct wl_buffer;
|
||||
struct wl_callback;
|
||||
struct wl_compositor;
|
||||
struct wl_data_device;
|
||||
struct wl_data_device_manager;
|
||||
struct wl_data_offer;
|
||||
struct wl_data_source;
|
||||
struct wl_keyboard;
|
||||
struct wl_output;
|
||||
struct wl_pointer;
|
||||
struct wl_region;
|
||||
struct wl_registry;
|
||||
struct wl_seat;
|
||||
struct wl_shell;
|
||||
struct wl_shell_surface;
|
||||
struct wl_shm;
|
||||
struct wl_shm_pool;
|
||||
struct wl_subcompositor;
|
||||
struct wl_subsurface;
|
||||
struct wl_surface;
|
||||
struct wl_touch;
|
||||
|
||||
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_FWD_H
|
||||
struct wl_egl_window;
|
||||
struct wl_surface;
|
||||
|
||||
typedef int32_t wl_fixed_t;
|
||||
|
||||
#define WL_PRINTF(x, y) __attribute__((__format__(__printf__, x, y)))
|
||||
typedef void (*wl_log_func_t)(const char *fmt, va_list args) WL_PRINTF(1, 0);
|
||||
|
||||
#define WL_MARSHAL_FLAG_DESTROY (1 << 0)
|
||||
|
||||
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_LIB_FWD_H
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#include <fennec/lang/types.h>
|
||||
#include <fennec/platform/linux/wayland/lib/fwd.h>
|
||||
|
||||
#ifndef FENNEC_LIB
|
||||
@@ -26,12 +27,87 @@
|
||||
#define FENNEC_SYMBOL(...)
|
||||
#endif
|
||||
|
||||
#ifndef FENNEC_GLOBAL
|
||||
#define FENNEC_GLOBAL(...)
|
||||
#endif
|
||||
|
||||
|
||||
FENNEC_LIB(WAYLAND);
|
||||
|
||||
FENNEC_SYMBOL(struct wl_display*, wl_display_connect, const char* name);
|
||||
FENNEC_SYMBOL(void, wl_display_disconnect, wl_display* name);
|
||||
FENNEC_SYMBOL(void, wl_proxy_marshal, struct wl_proxy*, uint32_t, ...);
|
||||
FENNEC_SYMBOL(struct wl_proxy*, wl_proxy_marshal_flags, struct wl_proxy *proxy, uint32_t opcode, const struct wl_interface *interface, uint32_t version, uint32_t flags, ...);
|
||||
FENNEC_SYMBOL(struct wl_proxy*, wl_proxy_create, struct wl_proxy*, const struct wl_interface*);
|
||||
FENNEC_SYMBOL(void, wl_proxy_destroy, struct wl_proxy*);
|
||||
FENNEC_SYMBOL(int, wl_proxy_add_listener, struct wl_proxy*, void (**)(void), void*);
|
||||
FENNEC_SYMBOL(void, wl_proxy_set_user_data, struct wl_proxy*, void*);
|
||||
FENNEC_SYMBOL(void*, wl_proxy_get_user_data, struct wl_proxy*);
|
||||
FENNEC_SYMBOL(uint32_t, wl_proxy_get_version, struct wl_proxy*);
|
||||
FENNEC_SYMBOL(uint32_t, wl_proxy_get_id, struct wl_proxy*);
|
||||
FENNEC_SYMBOL(const char*, wl_proxy_get_class, struct wl_proxy*);
|
||||
FENNEC_SYMBOL(void, wl_proxy_set_queue, struct wl_proxy*, struct wl_event_queue*);
|
||||
FENNEC_SYMBOL(void*, wl_proxy_create_wrapper, void*);
|
||||
FENNEC_SYMBOL(void, wl_proxy_wrapper_destroy, void*);
|
||||
FENNEC_SYMBOL(struct wl_display*, wl_display_connect, const char*);
|
||||
FENNEC_SYMBOL(struct wl_display*, wl_display_connect_to_fd, int);
|
||||
FENNEC_SYMBOL(void, wl_display_disconnect, struct wl_display*);
|
||||
FENNEC_SYMBOL(int, wl_display_get_fd, struct wl_display*);
|
||||
FENNEC_SYMBOL(int, wl_display_dispatch, struct wl_display*);
|
||||
FENNEC_SYMBOL(int, wl_display_dispatch_queue, struct wl_display*, struct wl_event_queue*);
|
||||
FENNEC_SYMBOL(int, wl_display_dispatch_queue_pending, struct wl_display*, struct wl_event_queue*);
|
||||
FENNEC_SYMBOL(int, wl_display_dispatch_pending, struct wl_display*);
|
||||
FENNEC_SYMBOL(int, wl_display_prepare_read, struct wl_display*);
|
||||
FENNEC_SYMBOL(int, wl_display_prepare_read_queue, struct wl_display*, struct wl_event_queue*);
|
||||
FENNEC_SYMBOL(int, wl_display_read_events, struct wl_display*);
|
||||
FENNEC_SYMBOL(void, wl_display_cancel_read, struct wl_display*);
|
||||
FENNEC_SYMBOL(int, wl_display_get_error, struct wl_display*);
|
||||
FENNEC_SYMBOL(int, wl_display_flush, struct wl_display*);
|
||||
FENNEC_SYMBOL(int, wl_display_roundtrip, struct wl_display*);
|
||||
FENNEC_SYMBOL(struct wl_event_queue*, wl_display_create_queue, struct wl_display*);
|
||||
FENNEC_SYMBOL(void, wl_event_queue_destroy, struct wl_event_queue*);
|
||||
FENNEC_SYMBOL(void, wl_log_set_handler_client, wl_log_func_t);
|
||||
FENNEC_SYMBOL(void, wl_list_init, struct wl_list*);
|
||||
FENNEC_SYMBOL(void, wl_list_insert, struct wl_list*, struct wl_list*) ;
|
||||
FENNEC_SYMBOL(void, wl_list_remove, struct wl_list*);
|
||||
FENNEC_SYMBOL(int, wl_list_length, const struct wl_list*);
|
||||
FENNEC_SYMBOL(int, wl_list_empty, const struct wl_list*);
|
||||
FENNEC_SYMBOL(void, wl_list_insert_list, struct wl_list*, struct wl_list*);
|
||||
FENNEC_SYMBOL(struct wl_proxy*, wl_proxy_marshal_constructor, struct wl_proxy*, uint32_t opcode, const struct wl_interface*interface, ...);
|
||||
FENNEC_SYMBOL(struct wl_proxy*, wl_proxy_marshal_constructor_versioned, struct wl_proxy*proxy, uint32_t opcode, const struct wl_interface*interface, uint32_t version, ...);
|
||||
FENNEC_SYMBOL(void, wl_proxy_set_tag, struct wl_proxy*, const char* const*);
|
||||
FENNEC_SYMBOL(const char* const*, wl_proxy_get_tag, struct wl_proxy*);
|
||||
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_display_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_registry_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_callback_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_compositor_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_shm_pool_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_shm_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_buffer_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_data_offer_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_data_source_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_data_device_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_data_device_manager_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_shell_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_shell_surface_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_surface_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_seat_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_pointer_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_keyboard_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_touch_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_output_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_region_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_subcompositor_interface);
|
||||
FENNEC_GLOBAL(const struct wl_interface, wl_subsurface_interface);
|
||||
|
||||
FENNEC_LIB(WAYLAND_EGL);
|
||||
|
||||
FENNEC_SYMBOL(struct wl_egl_window*, wl_egl_window_create, struct wl_surface *surface, int width, int height);
|
||||
FENNEC_SYMBOL(void, wl_egl_window_destroy, struct wl_egl_window *egl_window);
|
||||
FENNEC_SYMBOL(void, wl_egl_window_resize, struct wl_egl_window *egl_window, int width, int height, int dx, int dy);
|
||||
FENNEC_SYMBOL(void, wl_egl_window_get_attached_size, struct wl_egl_window *egl_window, int *width, int *height);
|
||||
|
||||
#undef FENNEC_LIB
|
||||
#undef FENNEC_SYMBOL
|
||||
#undef FENNEC_GLOBAL
|
||||
|
||||
|
||||
|
||||
2004
include/fennec/platform/linux/wayland/lib/wayland-client.h
Normal file
2004
include/fennec/platform/linux/wayland/lib/wayland-client.h
Normal file
File diff suppressed because it is too large
Load Diff
198
include/fennec/platform/linux/wayland/lib/wayland-util.h
Normal file
198
include/fennec/platform/linux/wayland/lib/wayland-util.h
Normal file
@@ -0,0 +1,198 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_LIB_WAYLAND_UTIL_H
|
||||
#define FENNEC_PLATFORM_LINUX_WAYLAND_LIB_WAYLAND_UTIL_H
|
||||
|
||||
/*
|
||||
* Copyright © 2008 Kristian Høgsberg
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial
|
||||
* portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ >= 4
|
||||
#define WL_EXPORT __attribute__ ((visibility("default")))
|
||||
#else
|
||||
#define WL_EXPORT
|
||||
#endif
|
||||
|
||||
#if __STDC_VERSION__ >= 202311L
|
||||
#define WL_DEPRECATED [[deprecated]]
|
||||
#elif defined(__GNUC__) && __GNUC__ >= 4
|
||||
#define WL_DEPRECATED __attribute__ ((deprecated))
|
||||
#else
|
||||
#define WL_DEPRECATED
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ >= 4
|
||||
#define WL_PRINTF(x, y) __attribute__((__format__(__printf__, x, y)))
|
||||
#else
|
||||
#define WL_PRINTF(x, y)
|
||||
#endif
|
||||
|
||||
#if __STDC_VERSION__ >= 202311L
|
||||
#define WL_TYPEOF(expr) typeof(expr)
|
||||
#else
|
||||
#define WL_TYPEOF(expr) __typeof__(expr)
|
||||
#endif
|
||||
|
||||
struct wl_message {
|
||||
const char *name;
|
||||
const char *signature;
|
||||
const struct wl_interface **types;
|
||||
};
|
||||
|
||||
struct wl_interface {
|
||||
const char *name;
|
||||
int version;
|
||||
int method_count;
|
||||
const struct wl_message *methods;
|
||||
int event_count;
|
||||
const struct wl_message *events;
|
||||
};
|
||||
|
||||
struct wl_list {
|
||||
struct wl_list *prev;
|
||||
struct wl_list *next;
|
||||
};
|
||||
|
||||
#define wl_container_of(ptr, sample, member) \
|
||||
(WL_TYPEOF(sample))((char *)(ptr) - \
|
||||
offsetof(WL_TYPEOF(*sample), member))
|
||||
|
||||
#define wl_list_for_each(pos, head, member) \
|
||||
for (pos = wl_container_of((head)->next, pos, member); \
|
||||
&pos->member != (head); \
|
||||
pos = wl_container_of(pos->member.next, pos, member))
|
||||
|
||||
#define wl_list_for_each_safe(pos, tmp, head, member) \
|
||||
for (pos = wl_container_of((head)->next, pos, member), \
|
||||
tmp = wl_container_of((pos)->member.next, tmp, member); \
|
||||
&pos->member != (head); \
|
||||
pos = tmp, \
|
||||
tmp = wl_container_of(pos->member.next, tmp, member))
|
||||
|
||||
#define wl_list_for_each_reverse(pos, head, member) \
|
||||
for (pos = wl_container_of((head)->prev, pos, member); \
|
||||
&pos->member != (head); \
|
||||
pos = wl_container_of(pos->member.prev, pos, member))
|
||||
|
||||
#define wl_list_for_each_reverse_safe(pos, tmp, head, member) \
|
||||
for (pos = wl_container_of((head)->prev, pos, member), \
|
||||
tmp = wl_container_of((pos)->member.prev, tmp, member); \
|
||||
&pos->member != (head); \
|
||||
pos = tmp, \
|
||||
tmp = wl_container_of(pos->member.prev, tmp, member))
|
||||
|
||||
struct wl_array {
|
||||
size_t size;
|
||||
size_t alloc;
|
||||
void *data;
|
||||
};
|
||||
|
||||
void
|
||||
wl_array_init(struct wl_array *array);
|
||||
|
||||
void
|
||||
wl_array_release(struct wl_array *array);
|
||||
|
||||
void *
|
||||
wl_array_add(struct wl_array *array, size_t size);
|
||||
|
||||
int
|
||||
wl_array_copy(struct wl_array *array, struct wl_array *source);
|
||||
|
||||
#define wl_array_for_each(pos, array) \
|
||||
for (pos = (array)->data; \
|
||||
(array)->size != 0 && \
|
||||
(const char *) pos < ((const char *) (array)->data + (array)->size); \
|
||||
(pos)++)
|
||||
|
||||
typedef int32_t wl_fixed_t;
|
||||
|
||||
static inline double
|
||||
wl_fixed_to_double(wl_fixed_t f)
|
||||
{
|
||||
return f / 256.0;
|
||||
}
|
||||
|
||||
static inline wl_fixed_t
|
||||
wl_fixed_from_double(double d)
|
||||
{
|
||||
return (wl_fixed_t) (d * 256.0);
|
||||
}
|
||||
|
||||
static inline int
|
||||
wl_fixed_to_int(wl_fixed_t f)
|
||||
{
|
||||
return f / 256;
|
||||
}
|
||||
|
||||
static inline wl_fixed_t
|
||||
wl_fixed_from_int(int i)
|
||||
{
|
||||
return i * 256;
|
||||
}
|
||||
|
||||
union wl_argument {
|
||||
int32_t i;
|
||||
uint32_t u;
|
||||
wl_fixed_t f;
|
||||
const char *s;
|
||||
struct wl_object *o;
|
||||
uint32_t n;
|
||||
struct wl_array *a;
|
||||
int32_t h;
|
||||
};
|
||||
|
||||
typedef int (*wl_dispatcher_func_t)(const void *user_data, void *target,
|
||||
uint32_t opcode, const struct wl_message *msg,
|
||||
union wl_argument *args);
|
||||
|
||||
typedef void (*wl_log_func_t)(const char *fmt, va_list args) WL_PRINTF(1, 0);
|
||||
|
||||
enum wl_iterator_result {
|
||||
WL_ITERATOR_STOP,
|
||||
WL_ITERATOR_CONTINUE
|
||||
};
|
||||
|
||||
|
||||
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_LIB_WAYLAND_UTIL_H
|
||||
@@ -19,13 +19,40 @@
|
||||
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_WINDOW_H
|
||||
#define FENNEC_PLATFORM_LINUX_WAYLAND_WINDOW_H
|
||||
|
||||
#include <fennec/platform/interface/window.h>
|
||||
|
||||
#include <fennec/platform/linux/wayland/fwd.h>
|
||||
#include <fennec/platform/linux/wayland/lib/fwd.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class wayland_window {
|
||||
class wayland_window : window {
|
||||
public:
|
||||
bool running() override;
|
||||
void configure(const config& config) override;
|
||||
bool initialize(bool modal) override;
|
||||
bool shutdown() override;
|
||||
|
||||
bool set_title(const cstring& title) override;
|
||||
bool set_title(const string& title) override;
|
||||
bool set_width(size_t w) override;
|
||||
bool set_height(size_t h) override;
|
||||
bool set_size(size_t w, size_t h) override;
|
||||
bool set_fullscreen_mode(fullscreen_mode mode) override;
|
||||
bool set_resizable(bool e) override;
|
||||
bool grab_keyboard(bool e) override;
|
||||
bool grab_mouse(bool e) override;
|
||||
bool block_screensaver(bool e) override;
|
||||
|
||||
wayland_window(wayland_display* display, wayland_window* parent);
|
||||
~wayland_window() override;
|
||||
|
||||
private:
|
||||
wl_surface* _surface;
|
||||
wl_shell_surface* _shell;
|
||||
wl_callback* _callback;
|
||||
gfxcontext* _context;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
44
include/fennec/platform/opengl/egl/context.h
Normal file
44
include/fennec/platform/opengl/egl/context.h
Normal file
@@ -0,0 +1,44 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef FENNEC_PLATFORM_EGL_CONTEXT_H
|
||||
#define FENNEC_PLATFORM_EGL_CONTEXT_H
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <fennec/platform/interface/displaydev.h>
|
||||
#include <fennec/platform/interface/gfxcontext.h>
|
||||
|
||||
#if FENNEC_HAS_WAYLAND
|
||||
#include <fennec/platform/linux/wayland/fwd.h>
|
||||
#endif
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class eglcontext : gfxcontext {
|
||||
public:
|
||||
eglcontext(displaydev* device);
|
||||
|
||||
EGLDisplay display;
|
||||
EGLContext context;
|
||||
EGLConfig config;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_PLATFORM_EGL_CONTEXT_H
|
||||
43
include/fennec/platform/opengl/egl/surface.h
Normal file
43
include/fennec/platform/opengl/egl/surface.h
Normal file
@@ -0,0 +1,43 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef FENNEC_PLATFORM_OPENGL_EGL_SURFACE_H
|
||||
#define FENNEC_PLATFORM_OPENGL_EGL_SURFACE_H
|
||||
|
||||
#include <EGL/egl.h>
|
||||
|
||||
#include <fennec/platform/interface/gfxsurface.h>
|
||||
#include <fennec/platform/opengl/egl/context.h>
|
||||
|
||||
#if FENNEC_HAS_WAYLAND
|
||||
|
||||
#endif
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class eglsurface : gfxsurface {
|
||||
public:
|
||||
eglsurface(eglcontext* context);
|
||||
|
||||
EGLSurface surface;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_PLATFORM_OPENGL_EGL_SURFACE_H
|
||||
Reference in New Issue
Block a user