- Moved OpenGL library wrapper into platform
- Finished reorganizing PLANNING.md
This commit is contained in:
@@ -1,188 +0,0 @@
|
||||
// =====================================================================================================================
|
||||
// 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_RENDERERS_INTERFACE_RENDERER_H
|
||||
#define FENNEC_RENDERERS_INTERFACE_RENDERER_H
|
||||
|
||||
#include <fennec/containers/dynarray.h>
|
||||
#include <fennec/lang/types.h>
|
||||
#include <fennec/langproc/strings/cstring.h>
|
||||
#include <fennec/math/matrix.h>
|
||||
#include <fennec/math/scalar.h>
|
||||
#include <fennec/math/ext/quaternion.h>
|
||||
|
||||
/*
|
||||
* Some ramblings on deciding what objects are needed to support the features in PLANNING.md
|
||||
*
|
||||
*
|
||||
* Definitions:
|
||||
* Static Mesh -> A mesh whose number of vertices and attributes does not change after creation
|
||||
* Object -> A static mesh instance
|
||||
* Skeletal Mesh -> A static mesh with support for skinned rigs
|
||||
* Animation -> A set of keys for a skeletal mesh
|
||||
* Puppet -> A skeletal mesh instance
|
||||
* Static Object -> An object whose transform does not change after scene start
|
||||
* Dynamic Object -> An object whose transform can change after scene start, all puppets must be dynamic objects
|
||||
* Static Light -> A light whose transform does not change after scene start. Other attributes may change, which will
|
||||
* be specified per light
|
||||
* Dynamic Light -> A light whose transform can change after scene start, including all attributes
|
||||
*
|
||||
* Static mesh rendering
|
||||
* Skeletal mesh rendering
|
||||
* Lights with or without shadows (PCSS for soft shadowing)
|
||||
* - Sun Light
|
||||
* - Skybox
|
||||
* - Point Light
|
||||
* - Spotlight
|
||||
* - Area light
|
||||
* Post-Processing
|
||||
*
|
||||
* Materials
|
||||
*/
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class renderer3d {
|
||||
public:
|
||||
// These refer to assets
|
||||
// texture -> 8-bit type, 24-bit id (256, 16,777,216)
|
||||
// mesh -> 32-bit id (4,294,967,296)
|
||||
// skeleton -> 32-bit id (4,294,967,296)
|
||||
// animation -> 32-bit id (4,294,967,296)
|
||||
// shader -> 32-bit id (4,294,967,296)
|
||||
|
||||
// model -> 8-bit flag, 24-bit id (8, 16,777,216)
|
||||
// puppet -> 32-bit id (4,294,967,296)
|
||||
// light -> 8-bit type, 24-bit id (256, 16,777,216)
|
||||
// material -> 32-bit id (4,294,967,296)
|
||||
|
||||
// TYPEDEFS & CONSTANTS ================================================================================================
|
||||
|
||||
using uid_t = uint32_t;
|
||||
|
||||
static constexpr uid_t null = -1;
|
||||
static constexpr uint_t max_bone_weights = 8;
|
||||
|
||||
|
||||
// ENUMS ===============================================================================================================
|
||||
|
||||
enum format_ : uint8_t {
|
||||
format_r = 0,
|
||||
format_rg,
|
||||
format_rgb,
|
||||
format_rgba,
|
||||
format_shadow, // TODO: decide whether end-users may create shadow buffers
|
||||
|
||||
format_count,
|
||||
format_last = format_count - 1,
|
||||
};
|
||||
|
||||
enum texture_ : uint8_t {
|
||||
texture_2d = 0,
|
||||
texture_3d,
|
||||
texture_cubemap,
|
||||
};
|
||||
|
||||
enum light_ : uint8_t {
|
||||
light_sun = 0,
|
||||
light_sky,
|
||||
light_point,
|
||||
light_spot,
|
||||
light_area,
|
||||
};
|
||||
|
||||
enum iterp_ : uint8_t {
|
||||
iterp_step = 0,
|
||||
iterp_linear,
|
||||
iterp_spherical,
|
||||
iterp_cubic,
|
||||
};
|
||||
|
||||
|
||||
// STRUCTURES ==========================================================================================================
|
||||
|
||||
struct mesh_vertex {
|
||||
vec3 location;
|
||||
vec3 normal;
|
||||
vec3 tangent;
|
||||
vec2 uv;
|
||||
};
|
||||
|
||||
struct skin_vertex {
|
||||
vec3 location;
|
||||
vec3 normal;
|
||||
vec3 tangent;
|
||||
vec2 uv;
|
||||
|
||||
uint32_t bones[max_bone_weights];
|
||||
uint32_t weights[max_bone_weights];
|
||||
};
|
||||
|
||||
struct bone {
|
||||
mat4 localSpace; // I was going to use quaternions, but Assimp, glTF, FBX, Unity, Unreal, and Godot all use matrices
|
||||
};
|
||||
|
||||
struct skeleton {
|
||||
mat4 root;
|
||||
uint boneStart, boneEnd; // APIs job to figure out how to store bones, should be in a SSBO regardless of API
|
||||
};
|
||||
|
||||
// Wrapper for animation keys
|
||||
template<typename ValueT>
|
||||
struct key {
|
||||
double time;
|
||||
ValueT val;
|
||||
uint8_t mode;
|
||||
};
|
||||
|
||||
// Wrapper for a track, essentially the keyframes for a single bone
|
||||
struct track {
|
||||
uint posStart, posEnd; // APIs job to figure out how to store keys, should be in a SSBO regardless of API
|
||||
uint rotStart, rotEnd;
|
||||
uint sclStart, sclEnd;
|
||||
};
|
||||
|
||||
struct animation {
|
||||
uint trkStart, trkEnd; // APIs job to figure out how to store tracks, should be in a SSBO regardless of API
|
||||
};
|
||||
|
||||
|
||||
// FUNCTIONS ===========================================================================================================
|
||||
|
||||
virtual uid_t create_mesh(const dynarray<uint32_t>& indices, const dynarray<mesh_vertex>& vertices) = 0;
|
||||
virtual void release_mesh(uid_t id);
|
||||
|
||||
// TODO: virtual uid_t create_skeleton()
|
||||
// TODO: virtual uid_t create_shader()
|
||||
|
||||
virtual uid_t create_texture(uint8_t type, uint8_t format, bool hdr) = 0;
|
||||
virtual void release_texture(uid_t);
|
||||
|
||||
|
||||
|
||||
// TODO: virtual uid_t create_light()
|
||||
|
||||
virtual ~renderer3d() = default;
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_RENDERERS_INTERFACE_RENDERER_H
|
||||
@@ -1,38 +0,0 @@
|
||||
// =====================================================================================================================
|
||||
// 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_RENDERERS_OPENGL_FALLBACK_H
|
||||
#define FENNEC_RENDERERS_OPENGL_FALLBACK_H
|
||||
|
||||
/*
|
||||
* This should be implemented using the OpenGL ES 3.2 profile
|
||||
* https://registry.khronos.org/OpenGL/specs/es/3.2/es_spec_3.2.pdf
|
||||
*
|
||||
* Requires the following:
|
||||
* OpenGL ES 3.2 / OpenGL 4.3 OR
|
||||
* - ARB_compute_shader
|
||||
* - ARB_shader_image_load_store
|
||||
* - ARB_shader_storage_buffer_object
|
||||
* - ARB_texture_cube_map_array
|
||||
* - ARB_texture_storage
|
||||
* - EXT_texture_array
|
||||
*
|
||||
* This will support all mobile devices since 2012
|
||||
*/
|
||||
|
||||
#endif // FENNEC_RENDERERS_OPENGL_FALLBACK_H
|
||||
@@ -1,38 +0,0 @@
|
||||
// =====================================================================================================================
|
||||
// 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_RENDERERS_OPENGL_MODERN_H
|
||||
#define FENNEC_RENDERERS_OPENGL_MODERN_H
|
||||
|
||||
/*
|
||||
*
|
||||
* Requires the following:
|
||||
* OpenGL 4.6 OR
|
||||
* - ARB_buffer_storage
|
||||
* - ARB_compute_shader
|
||||
* - ARB_multi_draw_indirect
|
||||
* - ARB_shader_draw_parameters
|
||||
* - ARB_shader_image_load_store
|
||||
* - ARB_texture_cube_map_array
|
||||
* - ARB_texture_storage
|
||||
* - EXT_texture_array
|
||||
*
|
||||
* This will support >91.31% of devices on Steam, including all Desktop GPUs and iGPUs since 2012
|
||||
*/
|
||||
|
||||
#endif // FENNEC_RENDERERS_OPENGL_MODERN_H
|
||||
Reference in New Issue
Block a user