Skip to content

Commit

Permalink
UPDATE
Browse files Browse the repository at this point in the history
  • Loading branch information
Caerind committed Aug 19, 2024
1 parent fdad8fe commit 866b0e2
Show file tree
Hide file tree
Showing 6,450 changed files with 53,609 additions and 1,876,341 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@


# Ignore 3rd party from the languages statistics
Enlivengine/EnlivengineThirdParty/** linguist-vendored
src/EnlivengineThirdParty/** linguist-vendored
*.c linguist-language=C++
*.h linguist-language=C++
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.12...3.15)

project(Enlivengine
VERSION 0.3
VERSION 0.0
DESCRIPTION "Enlivengine"
LANGUAGES CXX)

Expand All @@ -17,6 +17,12 @@ endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake")

include(FetchContent)
FetchContent_Declare(SFML
GIT_REPOSITORY https://github.com/SFML/SFML.git
GIT_TAG 2.6.x)
FetchContent_MakeAvailable(SFML)

add_subdirectory(src)

add_subdirectory(tests)
Expand Down
127 changes: 17 additions & 110 deletions UberScript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

Help()
{
echo "Syntax: UberScript [-c][-h|i|g|s|b|t|v|a]"
echo "Syntax: UberScript [-c][-h|i|g|b|t|v|a]"
echo "options:"
echo "c Config"
echo "h Help"
echo "i Install dependencies"
echo "g Generate project"
echo "s Shaders compilation"
echo "b Build engine"
echo "t Tests"
echo "v VisualStudio"
Expand All @@ -18,11 +17,21 @@ Help()

InstallDependencies()
{
git submodule update --init --recursive

if [[ "$platform" == "linux" ]]; then
sudo apt-get install -y cmake gcc-9 g++-9 build-essential mercurial make autoconf automake libtool libasound2-dev libpulse-dev libaudio-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libxxf86vm-dev libxss-dev libgl1-mesa-dev
fi
git submodule update --init --recursive

if [[ "$platform" == "linux" ]]; then
sudo apt-get install -y cmake gcc-9 g++-9 build-essential mercurial make autoconf automake
sudo apt install \
libxrandr-dev \
libxcursor-dev \
libudev-dev \
libfreetype-dev \
libopenal-dev \
libflac-dev \
libvorbis-dev \
libgl1-mesa-dev \
libegl1-mesa-dev
fi
}

GenerateProject()
Expand All @@ -32,97 +41,6 @@ GenerateProject()
cmake -S . -B build
}

CompileShaders()
{
path_shaderc=""
if [[ "$platform" == "windows" ]]; then
path_shaderc="./build/src/EnlivengineThirdParty/bgfx/Debug/shaderc.exe"
else
path_shaderc="./build/src/EnlivengineThirdParty/bgfx/shaderc"
fi
if [ ! -x "$path_shaderc" ]; then
cmake --build build --target shaderc --config Debug
fi

output_path="build/Shaders"
path_bgfx_include="src/EnlivengineThirdParty/bgfx/bgfx/src"

mkdir -p "$output_path"
mkdir -p "$output_path/dx9"
mkdir -p "$output_path/dx11"
mkdir -p "$output_path/essl"
mkdir -p "$output_path/glsl"
mkdir -p "$output_path/metal"
mkdir -p "$output_path/pssl"
mkdir -p "$output_path/spirv"

all_vertex_shaders="`find src/Enlivengine/Shaders -name *.vs`"
for vertex_shader in $all_vertex_shaders
do
basename="`basename $vertex_shader`"
basenamewoext="`echo $basename | cut -f 1 -d '.'`"

#TODO: platform asm.js ?

# DX9
$path_shaderc -f "${vertex_shader}" -o "${output_path}/dx9/${basenamewoext}.vs.bin" --platform windows -p vs_3_0 -O 3 --type vertex --verbose -i $path_bgfx_include

# DX11
$path_shaderc -f "${vertex_shader}" -o "${output_path}/dx11/${basenamewoext}.vs.bin" --platform windows -p vs_5_0 -O 3 --type vertex --verbose -i $path_bgfx_include

# NACL
$path_shaderc -f "${vertex_shader}" -o "${output_path}/essl/${basenamewoext}.vs.bin" --platform nacl --type vertex --verbose -i $path_bgfx_include

# Android
$path_shaderc -f "${vertex_shader}" -o "${output_path}/essl/${basenamewoext}.vs.bin" --platform android --type vertex --verbose -i $path_bgfx_include

# GLSL
$path_shaderc -f "${vertex_shader}" -o "${output_path}/glsl/${basenamewoext}.vs.bin" --platform linux -p 120 --type vertex --verbose -i $path_bgfx_include

# Metal
$path_shaderc -f "${vertex_shader}" -o "${output_path}/metal/${basenamewoext}.vs.bin" --platform osx -p metal --type vertex --verbose -i $path_bgfx_include

# PSSL
$path_shaderc -f "${vertex_shader}" -o "${output_path}/pssl/${basenamewoext}.vs.bin" --platform orbis -p pssl --type vertex --verbose -i $path_bgfx_include

# Spirv
$path_shaderc -f "${vertex_shader}" -o "${output_path}/spirv/${basenamewoext}.vs.bin" --platform linux -p spirv --type vertex --verbose -i $path_bgfx_include
done

all_fragment_shaders="`find src/Enlivengine/Shaders -name *.fs`"
for fragment_shader in $all_fragment_shaders
do
basename="`basename $fragment_shader`"
basenamewoext="`echo $basename | cut -f 1 -d '.'`"

#TODO: platform asm.js ?

# DX9
$path_shaderc -f "${fragment_shader}" -o "${output_path}/dx9/${basenamewoext}.fs.bin" --platform windows -p ps_3_0 -O 3 --type fragment --verbose -i $path_bgfx_include

# DX11
$path_shaderc -f "${fragment_shader}" -o "${output_path}/dx11/${basenamewoext}.fs.bin" --platform windows -p ps_5_0 -O 3 --type fragment --verbose -i $path_bgfx_include

# NACL
$path_shaderc -f "${fragment_shader}" -o "${output_path}/essl/${basenamewoext}.fs.bin" --platform nacl --type fragment --verbose -i $path_bgfx_include

# Android
$path_shaderc -f "${fragment_shader}" -o "${output_path}/essl/${basenamewoext}.fs.bin" --platform android --type fragment --verbose -i $path_bgfx_include

# GLSL
$path_shaderc -f "${fragment_shader}" -o "${output_path}/glsl/${basenamewoext}.fs.bin" --platform linux -p 120 --type fragment --verbose -i $path_bgfx_include

# Metal
$path_shaderc -f "${fragment_shader}" -o "${output_path}/metal/${basenamewoext}.fs.bin" --platform osx -p metal --type fragment --verbose -i $path_bgfx_include

# PSSL
$path_shaderc -f "${fragment_shader}" -o "${output_path}/pssl/${basenamewoext}.fs.bin" --platform orbis -p pssl --type fragment --verbose -i $path_bgfx_include

# Spirv
$path_shaderc -f "${fragment_shader}" -o "${output_path}/spirv/${basenamewoext}.fs.bin" --platform linux -p spirv --type fragment --verbose -i $path_bgfx_include
done
}

BuildEnlivengine()
{
cmake --build build --target Enlivengine --config $config
Expand Down Expand Up @@ -181,15 +99,14 @@ config="Debug"
help=false
install=false
generate=false
shaders=false
build=false
tests=false
visual=false

default=true

# Options parsing
while getopts c:higsbtva option
while getopts c:higbtva option
do
case $option in
c)
Expand All @@ -208,10 +125,6 @@ do
default=false
generate=true
;;
s)
default=false
shaders=true
;;
b)
default=false
build=true
Expand All @@ -228,7 +141,6 @@ do
default=false
install=true
generate=true
shaders=true
build=true
tests=true
;;
Expand All @@ -240,7 +152,6 @@ done
if $default; then
install=true
generate=true
shaders=true
build=true
tests=true
fi
Expand All @@ -255,10 +166,6 @@ fi
if $generate; then
GenerateProject
fi
if $shaders; then
CompileShaders
GenerateProject
fi
if $build; then
BuildEnlivengine
fi
Expand Down
78 changes: 41 additions & 37 deletions examples/3DSceneExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
#include <Enlivengine/Window/Controller.hpp>
#include <Enlivengine/Core/World.hpp>
#include <Enlivengine/Core/TransformComponent.hpp>
#include <Enlivengine/Core/CameraComponent.hpp>
#include <Enlivengine/Core/ViewComponent.hpp>
#include <Enlivengine/Core/Components.hpp>
#include <Enlivengine/Graphics/Camera.hpp>
#include <Enlivengine/Graphics/BgfxWrapper.hpp>
#include <Enlivengine/Graphics/View.hpp>
#include <Enlivengine/Tools/ImGuiEditor.hpp>

#include <Enlivengine/Audio/AudioManager.hpp>
Expand All @@ -23,41 +22,37 @@ class RenderSystem : public RenderSystemBase
bool Serialize(Serializer& serializer, const char* name) override;
bool Edit(ObjectEditor& objectEditor, const char* name) override;

void Render() override
void Render(RenderTarget& renderTarget) override
{
#ifdef ENLIVE_DEBUG
mWorld->GetDebugDraw().DrawCross(Vector3f(0.0f));
mWorld->GetDebugDraw().DrawGrid(Vector3f::Zero(), ENLIVE_DEFAULT_UP, -16, 16, 1, Colors::White);
// TODO
//mWorld->GetDebugDraw().DrawCross(Vector3f(0.0f));
//mWorld->GetDebugDraw().DrawGrid(Vector3f::Zero(), ENLIVE_DEFAULT_UP, -16, 16, 1, Colors::White);
#endif // ENLIVE_DEBUG

#ifdef ENLIVE_TOOL
Framebuffer& framebuffer = ImGuiEditor::GetFramebuffer();
Camera* camera = &ImGuiEditor::GetCamera();
#else
Framebuffer& framebuffer = Framebuffer::GetDefaultFramebuffer();
Camera* camera = Camera::GetMainCamera();
#endif // ENLIVE_TOOL
const View& currentView = GetCurrentView();

if (framebuffer.IsValid() && camera != nullptr)
if (renderTarget.IsValid())
{
const bgfx::ViewId mainViewID = 2;
BgfxWrapper::SetCurrentView(mainViewID);
const Vector2u& renderTargetSize = renderTarget.GetSize();
const F32 aspectRatio = static_cast<F32>(renderTargetSize.x) / static_cast<F32>(renderTargetSize.y);

const Vector2u& framebufferSize = framebuffer.GetSize();
const F32 aspectRatio = static_cast<F32>(framebufferSize.x) / static_cast<F32>(framebufferSize.y);
const Vector2f vpMin = camera->GetViewport().GetMin();
const Vector2f vpSize = camera->GetViewport().GetSize();
// TODO : Viewport
//const Vector2f vpMin = currentView.GetViewport().GetMin();
//const Vector2f vpSize = currentView.GetViewport().GetSize();

if (camera->GetAspect() != aspectRatio)
// TODO : Aspect
/*
if (currentView.GetAspect() != aspectRatio)
{
camera->SetAspect(aspectRatio);
currentView.SetAspect(aspectRatio);
}
*/

bgfx::setViewClear(mainViewID, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH, camera->GetClearColor().ToRGBA(), 1.0f, 0);
bgfx::setViewTransform(mainViewID, camera->GetViewMatrix().GetData(), camera->GetProjectionMatrix().GetData());
bgfx::setViewRect(mainViewID, static_cast<U16>(vpMin.x * framebufferSize.x), static_cast<U16>(vpMin.y * framebufferSize.y), static_cast<U16>(vpSize.x * framebufferSize.x), static_cast<U16>(vpSize.y * framebufferSize.y));
bgfx::setViewFrameBuffer(mainViewID, framebuffer.GetHandle());
bgfx::touch(mainViewID);
renderTarget.Clear();
// TODO : Set view from Camera
//bgfx::setViewTransform(mainViewID, camera->GetViewMatrix().GetData(), camera->GetProjectionMatrix().GetData());
//bgfx::setViewRect(mainViewID, static_cast<U16>(vpMin.x * renderTargetSize.x), static_cast<U16>(vpMin.y * renderTargetSize.y), static_cast<U16>(vpSize.x * renderTargetSize.x), static_cast<U16>(vpSize.y * renderTargetSize.y));

RenderWorld();

Expand All @@ -68,9 +63,8 @@ class RenderSystem : public RenderSystemBase
if (mWorld->IsDebugRendering())
#endif // ENLIVE_TOOL
{
mWorld->GetDebugDraw().Render();
mWorld->GetDebugDraw().Render(renderTarget);
}
mWorld->GetDebugDraw().Clear();
#endif // ENLIVE_DEBUG
}
}
Expand All @@ -88,27 +82,34 @@ class RenderSystem : public RenderSystemBase
const Matrix4f matrix = (entity.Has<TransformComponent>()) ? entity.Get<TransformComponent>().GetGlobalMatrix() : Matrix4f::Identity();
if (entity.Has<SpriteComponent>())
{
/*
Sprite& sprite = entity.Get<SpriteComponent>().sprite;
if (sprite.CanRender())
{
bgfx::setTransform(matrix.GetData());
// TODO : Transform
//bgfx::setTransform(matrix.GetData());
sprite.Render();
render = true;
}
*/
}
if (entity.Has<TilemapComponent>())
{
/*
Tilemap& tilemap = entity.Get<TilemapComponent>().tilemap;
if (tilemap.CanRender())
{
bgfx::setTransform(matrix.GetData());
{
// TODO : Transform
//bgfx::setTransform(matrix.GetData());
entity.Get<TilemapComponent>().tilemap.Render();
render = true;
}
*/
}
if (!render)
{
bgfx::setTransform(Matrix4f::Identity().GetData());
{
// TODO : Transform
//bgfx::setTransform(Matrix4f::Identity().GetData());
}
}
}
Expand Down Expand Up @@ -146,9 +147,12 @@ class DebugSystem : public System
void Update() override
{
#ifdef ENLIVE_DEBUG
mWorld->GetDebugDraw().DrawBox({ 1.0f, 0.5f, 1.0f }, { 2.0f, 1.5f, 2.0f }, Colors::Red);
mWorld->GetDebugDraw().DrawSphere({ -1.0f, 0.5f, -3.0f }, 0.5f, Colors::Red);
// TODO
//mWorld->GetDebugDraw().DrawBox({ 1.0f, 0.5f, 1.0f }, { 2.0f, 1.5f, 2.0f }, Colors::Red);
//mWorld->GetDebugDraw().DrawSphere({ -1.0f, 0.5f, -3.0f }, 0.5f, Colors::Red);

// TODO
/*
auto& entityManager = mWorld->GetEntityManager();
auto view = entityManager.View<en::CameraComponent>();
for (auto entt : view)
Expand All @@ -160,7 +164,7 @@ class DebugSystem : public System
mWorld->GetDebugDraw().DrawFrustum(cam.CreateFrustum());
}
}

*/
#endif // ENLIVE_DEBUG
}
};
Expand Down
Loading

0 comments on commit 866b0e2

Please sign in to comment.