Fixed errors.

This commit is contained in:
Arron David Nelson 2024-02-20 23:07:28 -08:00
parent a075538238
commit 75b6eb66d3
7 changed files with 85 additions and 104 deletions

View File

@ -33,14 +33,31 @@ add_executable(TechDemo main.cpp Levels/TestLevel.cpp Levels/TestLevel.h Levels/
if (IS_OS_WINDOWS) if (IS_OS_WINDOWS)
add_compile_definitions(VK_USE_PLATFORM_WIN32_KHR) add_compile_definitions(VK_USE_PLATFORM_WIN32_KHR)
elseif (IS_OS_LINUX) elseif (IS_OS_LINUX)
add_compile_definitions(VK_USE_PLATFORM_XCB_KHR LWE_WS_XCB) add_compile_definitions(VK_USE_PLATFORM_XCB_KHR EHS_WS_XCB)
endif() endif()
target_link_directories(TechDemo PRIVATE "${USER_HOME_DIRECTORY}/Libraries/EHS/lib") target_link_directories(TechDemo PRIVATE "${USER_HOME_DIRECTORY}/.local/lib")
target_link_directories(TechDemo PRIVATE "${USER_HOME_DIRECTORY}/Libraries/LWE/lib") target_include_directories(TechDemo PRIVATE "${USER_HOME_DIRECTORY}/.local/include")
target_include_directories(TechDemo PRIVATE "${USER_HOME_DIRECTORY}/Libraries/EHS/include")
target_include_directories(TechDemo PRIVATE "${USER_HOME_DIRECTORY}/Libraries/LWE/include")
find_package(Vulkan REQUIRED) find_package(Vulkan REQUIRED)
if (Vulkan_FOUND)
message(STATUS "Vulkan was found.")
else ()
message(STATUS "Vulkan was not found.")
endif ()
target_link_libraries(TechDemo PRIVATE Vulkan::Headers Vulkan::Vulkan xcb xcb-cursor xcb-xfixes xcb-xinput wooting_analog_wrapper LWE z asound) find_package(ZLIB REQUIRED)
if (ZLIB_FOUND)
message(STATUS "ZLIB was found.")
else ()
message(STATUS "ZLIB was not found.")
endif ()
find_package(OpenSSL REQUIRED)
if (OpenSSL_FOUND)
message(STATUS "OpenSSL was found.")
else ()
message(STATUS "OpenSSL was not found.")
endif ()
target_link_libraries(TechDemo PRIVATE Vulkan::Headers Vulkan::Vulkan xcb xcb-cursor xcb-xfixes xcb-xinput OpenSSL::SSL OpenSSL::Crypto ZLIB::ZLIB asound LWE EHC EHE EHS)

View File

@ -1,7 +1,6 @@
#pragma once #pragma once
#include <LWE/LWE.h> #include <lwe/gui/CollectionGui.h>
#include <LWE/Gui/CollectionGui.h>
class HealthBarGui class HealthBarGui
{ {

View File

@ -23,9 +23,9 @@ void MainMenu::SetupResources(lwe::GpuInterface* inf)
} }
void MainMenu::Setup() void MainMenu::Setup(lwe::GpuInterface* inf)
{ {
Level::Setup(); Level::Setup(inf);
AddSystem(new lwe::CameraSystem()); AddSystem(new lwe::CameraSystem());
AddSystem(new lwe::RigidBodySystem()); AddSystem(new lwe::RigidBodySystem());

View File

@ -15,7 +15,7 @@ public:
void SetupResources(lwe::GpuInterface* inf) override; void SetupResources(lwe::GpuInterface* inf) override;
void Setup() override; void Setup(lwe::GpuInterface* inf) override;
void PostInitialize(lwe::GpuCmdBuffer* cmdBuffer) override; void PostInitialize(lwe::GpuCmdBuffer* cmdBuffer) override;

View File

@ -86,11 +86,10 @@ void TestLevel::SetupResources(lwe::GpuInterface* inf)
AddResource(arial_24); AddResource(arial_24);
lwe::GpuModel* vampire = new lwe::GpuModel("resources/models/Vampire.ehm", inf); lwe::GpuModel* vampire = new lwe::GpuModel("resources/models/Vampire.ehm", inf);
//vampire->Calculate();
AddResource(vampire); AddResource(vampire);
AddResource(new lwe::GpuImg("resources/textures/Character_Diffuse.png", inf, lwe::IMG_ASPECT_COLOR)); AddResource(new lwe::GpuImg("resources/textures/Character_Diffuse.png", inf, lwe::IMG_ASPECT_COLOR));
AddResource(new lwe::GpuImg("resources/textures/Character_Normal.png", inf, lwe::IMG_ASPECT_COLOR)); AddResource(new lwe::GpuImg("resources/textures/Character_Normal.png", inf, lwe::IMG_ASPECT_COLOR));
AddResource(new lwe::GpuImg("Resources/Textures/Character_Specular.png", inf, lwe::IMG_ASPECT_COLOR)); AddResource(new lwe::GpuImg("resources/textures/Character_Specular.png", inf, lwe::IMG_ASPECT_COLOR));
lwe::GpuMesh* portrait = new lwe::GpuMesh(inf, ehs::portrait); lwe::GpuMesh* portrait = new lwe::GpuMesh(inf, ehs::portrait);
//portrait->Calculate(); //portrait->Calculate();
@ -99,17 +98,17 @@ void TestLevel::SetupResources(lwe::GpuInterface* inf)
lwe::GpuMesh* portraitGUI = new lwe::GpuMesh(inf, ehs::portraitGui); lwe::GpuMesh* portraitGUI = new lwe::GpuMesh(inf, ehs::portraitGui);
AddResource(portraitGUI); AddResource(portraitGUI);
AddResource(new lwe::GpuModel("Resources/Models/Cube.ehm", inf)); AddResource(new lwe::GpuModel("resources/models/Cube.ehm", inf));
AddResource(new lwe::GpuModel("Resources/Models/Sphere.ehm", inf)); AddResource(new lwe::GpuModel("resources/models/Sphere.ehm", inf));
AddResource(new lwe::GpuModel("Resources/Models/PointLight.ehm", inf)); AddResource(new lwe::GpuModel("resources/models/PointLight.ehm", inf));
lwe::GpuCubeMap* cm = new lwe::GpuCubeMap(inf, "Resources/Textures/Skybox", "Skybox"); lwe::GpuCubeMap* cm = new lwe::GpuCubeMap(inf, "resources/textures/skybox", "Skybox");
AddResource(cm); AddResource(cm);
AddResource(lwe::Audio::FromFile_Heap("Resources/Audio/sample.wav", lwe::DataType::FLOAT)); AddResource(new ehs::Audio("resources/audio/sample.wav", ehs::DataType::FLOAT));
} }
void TestLevel::Setup() void TestLevel::Setup(lwe::GpuInterface* inf)
{ {
lwe::GameLoop* gl = (lwe::GameLoop*)GetParent(); lwe::GameLoop* gl = (lwe::GameLoop*)GetParent();
if (!gl) if (!gl)
@ -275,7 +274,9 @@ void TestLevel::Setup()
timerSys->Add({0, 1.0f, args, [](lwe::Timer* timer, ehs::Serializer<ehs::UInt_64>& args) timerSys->Add({0, 1.0f, args, [](lwe::Timer* timer, ehs::Serializer<ehs::UInt_64>& args)
{ {
lwe::GameLoop* gl = (lwe::GameLoop*)timer->GetParent("GameLoop"); lwe::TimerSystem* sys = timer->GetParent();
lwe::Level* lvl = sys->GetParent();
lwe::GameLoop* gl = lvl->GetParent();
lwe::CollectionGui* stats = args.Read<lwe::CollectionGui*>(); lwe::CollectionGui* stats = args.Read<lwe::CollectionGui*>();
args.SetOffset(0); args.SetOffset(0);
@ -292,18 +293,18 @@ void TestLevel::Setup()
testPanel->SetPosition({300.0f, 200.0f, 0.0f}); testPanel->SetPosition({300.0f, 200.0f, 0.0f});
testPanel->SetScale({400.0f, 400.0f}); testPanel->SetScale({400.0f, 400.0f});
guiSys->AddGui(testPanel); guiSys->AddGui(testPanel);
*/
lwe::WindowGui* testWin = new lwe::WindowGui("TestWindow", "Hello world!"); lwe::WindowGui* testWin = new lwe::WindowGui("TestWindow", "Hello world!");
testWin->SetPosition({300.0f, 200.0f, 0.0f}); testWin->SetPosition({300.0f, 200.0f, 0.0f});
testWin->SetScale({400.0f, 400.0f}); testWin->SetScale({400.0f, 400.0f});
guiSys->AddGui(testWin); guiSys->AddGui(testWin);
*/
lwe::Entity* player = new lwe::Entity("Player"); lwe::Entity player("Player");
//player->AddComponent(new lwe::Networked(true, false, lwe::EndpointOwner::ENDPOINT)); //player->AddComponent(new lwe::Networked(true, false, lwe::EndpointOwner::ENDPOINT));
player->AddComponent(new lwe::Point3D("Head", 1.0f, 1.0f)); player.AddComponent(new lwe::Point3D("Head", 1.0f, 1.0f));
player->AddComponent(new lwe::PlyController("Head")); player.AddComponent(new lwe::PlyController("Head"));
//player->AddComponent(new lwe::Health(100, 100)); //player->AddComponent(new lwe::Health(100, 100));
lwe::SolidColor* plyMdl = new lwe::SolidColor("Cube", {0.0f, 0.0f, 1.0f}, "Cube", ""); lwe::SolidColor* plyMdl = new lwe::SolidColor("Cube", {0.0f, 0.0f, 1.0f}, "Cube", "");
@ -314,10 +315,10 @@ void TestLevel::Setup()
AddTemplate((lwe::Entity&&)player); AddTemplate((lwe::Entity&&)player);
lwe::Entity* plyPuppet = new lwe::Entity("Puppet"); lwe::Entity plyPuppet("Puppet");
plyPuppet->AddComponent(new lwe::OBB3D("Head", 1.0f, 1.0f)); plyPuppet.AddComponent(new lwe::OBB3D("Head", 1.0f, 1.0f));
plyPuppet->AddComponent(new lwe::Camera("Head")); plyPuppet.AddComponent(new lwe::Camera("Head"));
plyPuppet->AddComponent(new lwe::Health(100, 100)); plyPuppet.AddComponent(new lwe::Health(100, 100));
lwe::SolidColor* puppetMdl = new lwe::SolidColor("Cube", {0.0f, 0.0f, 1.0f}, "Cube", ""); lwe::SolidColor* puppetMdl = new lwe::SolidColor("Cube", {0.0f, 0.0f, 1.0f}, "Cube", "");
puppetMdl->SetDiffused(true); puppetMdl->SetDiffused(true);
@ -327,18 +328,18 @@ void TestLevel::Setup()
AddTemplate((lwe::Entity&&)plyPuppet); AddTemplate((lwe::Entity&&)plyPuppet);
CreateEntity(player->GetHashId(), "Player"); CreateEntity("Player", "Player");
lwe::Entity* skyboxEnt = new lwe::Entity("Skybox"); lwe::Entity skyboxEnt("Skybox");
lwe::Skybox* skybox = new lwe::Skybox("Skybox", "Skybox"); lwe::Skybox* skybox = new lwe::Skybox("Skybox", "Skybox");
skyboxEnt->AddComponent(skybox); skyboxEnt.AddComponent(skybox);
AddEntity((lwe::Entity&&)skyboxEnt); AddEntity((lwe::Entity&&)skyboxEnt);
lwe::Entity* ent = new lwe::Entity("Main"); lwe::Entity ent("Main");
ent->SetScale({0.25f, 0.25f, 0.25f}); ent.SetScale({0.25f, 0.25f, 0.25f});
ent->SetPos({0.0f, -1.0f, 5.0f}); ent.SetPos({0.0f, -1.0f, 5.0f});
//ent->SetRot({-90.0f, 180.0f, 0.0f}); //ent->SetRot({-90.0f, 180.0f, 0.0f});
//ent->AddComponent(new lwe::Networked(false, false, lwe::EndpointOwner::SERVICE)); //ent->AddComponent(new lwe::Networked(false, false, lwe::EndpointOwner::SERVICE));
@ -346,12 +347,13 @@ void TestLevel::Setup()
lwe::AudioSource3D* as = new lwe::AudioSource3D("Song", "sample", 20.0f); lwe::AudioSource3D* as = new lwe::AudioSource3D("Song", "sample", 20.0f);
as->Pause(); as->Pause();
as->EnableLoop(true); as->EnableLoop(true);
as->EnableAutoDelete(false);
//as->EnablePanning(false); //as->EnablePanning(false);
//as->EnableAttenuation(false); //as->EnableAttenuation(false);
ent->AddComponent(as); ent.AddComponent(as);
lwe::Health* entHealth = new lwe::Health(100, 100); lwe::Health* entHealth = new lwe::Health(100, 100);
ent->AddComponent(entHealth); ent.AddComponent(entHealth);
lwe::OBB3D* entCollider = new lwe::OBB3D("Collider", 1.0f, 1.0f); lwe::OBB3D* entCollider = new lwe::OBB3D("Collider", 1.0f, 1.0f);
entCollider->SetScale({1.0f, 2.0f, 1.0f}); entCollider->SetScale({1.0f, 2.0f, 1.0f});
@ -368,7 +370,7 @@ void TestLevel::Setup()
if (health->GetHealth() <= 0) if (health->GetHealth() <= 0)
aOwner->Delete(); aOwner->Delete();
}); });
ent->AddComponent(entCollider); ent.AddComponent(entCollider);
/* /*
lwe::AudioSource* as2 = new lwe::AudioSource("Song2", "sample"); lwe::AudioSource* as2 = new lwe::AudioSource("Song2", "sample");
@ -378,7 +380,7 @@ void TestLevel::Setup()
lwe::Phong* ph = new lwe::Phong("Cube", "Vampire", "", "Character_Diffuse", "Character_Specular", "Character_Normal"); lwe::Phong* ph = new lwe::Phong("Cube", "Vampire", "", "Character_Diffuse", "Character_Specular", "Character_Normal");
ph->SetAnimation("Test"); ph->SetAnimation("Test");
ent->AddComponent(ph); ent.AddComponent(ph);
AddEntity((lwe::Entity&&)ent); AddEntity((lwe::Entity&&)ent);
@ -391,33 +393,33 @@ void TestLevel::Setup()
AddEntity((lwe::Entity&&)sun); AddEntity((lwe::Entity&&)sun);
lwe::Entity* emergency = new lwe::Entity("Emergency"); lwe::Entity emergency("Emergency");
emergency->SetPos({5.0f, 0.0f, 5.0f}); emergency.SetPos({5.0f, 0.0f, 5.0f});
lwe::PointLight* pl = new lwe::PointLight("Light"); lwe::PointLight* pl = new lwe::PointLight("Light");
pl->SetColor({1.0f, 0.0f, 0.0f}); pl->SetColor({1.0f, 0.0f, 0.0f});
emergency->AddComponent(pl); emergency.AddComponent(pl);
AddEntity((lwe::Entity&&)emergency); AddEntity((lwe::Entity&&)emergency);
lwe::Entity* testEnt = new lwe::Entity("Test"); lwe::Entity testEnt("Test");
lwe::Billboard* testBb = new lwe::Billboard("TestBB", "Character_Diffuse"); lwe::Billboard* testBb = new lwe::Billboard("TestBB", "Character_Diffuse");
testEnt->AddComponent(testBb); testEnt.AddComponent(testBb);
AddEntity((lwe::Entity&&)testEnt); AddEntity((lwe::Entity&&)testEnt);
lwe::Entity* bullet = new lwe::Entity("Bullet"); lwe::Entity bullet("Bullet");
bullet->SetScale({0.1f, 0.1f, 0.1f}); bullet.SetScale({0.1f, 0.1f, 0.1f});
bullet->AddComponent(new lwe::Projectile(25)); bullet.AddComponent(new lwe::Projectile(25));
lwe::OBB3D* bulletCollider = new lwe::OBB3D("Collider", 1.0f, 1.0f); lwe::OBB3D* bulletCollider = new lwe::OBB3D("Collider", 1.0f, 1.0f);
bulletCollider->SetScale(0.1f); bulletCollider->SetScale(0.1f);
bullet->AddComponent(bulletCollider); bullet.AddComponent(bulletCollider);
lwe::SolidColor* bulletMdl = new lwe::SolidColor("Mdl", {1.0f, 1.0f, 0.0f, 1.0f}, "Cube", ""); lwe::SolidColor* bulletMdl = new lwe::SolidColor("Mdl", {1.0f, 1.0f, 0.0f, 1.0f}, "Cube", "");
bullet->AddComponent(bulletMdl); bullet.AddComponent(bulletMdl);
AddTemplate((lwe::Entity&&)bullet); AddTemplate((lwe::Entity&&)bullet);
} }
@ -538,7 +540,7 @@ void TestLevel::OnUpdate(lwe::RenderWindow* win, ehs::Input* input, const float
if (!source) if (!source)
return; return;
lwe::Audio* audio = (lwe::Audio*)GetResource("Audio", source->GetAudioHashId()); ehs::Audio* audio = (ehs::Audio*)GetResource("Audio", source->GetAudioHashId());
if (!audio) if (!audio)
return; return;
@ -550,26 +552,23 @@ void TestLevel::OnUpdate(lwe::RenderWindow* win, ehs::Input* input, const float
playback->SetText("Playback: " + ehs::Str_8::FromNum(elapsed / 60) + ":" + ehs::Str_8::FromNum(elapsed % 60) + playback->SetText("Playback: " + ehs::Str_8::FromNum(elapsed / 60) + ":" + ehs::Str_8::FromNum(elapsed % 60) +
" / " + ehs::Str_8::FromNum(duration / 60) + ":" + ehs::Str_8::FromNum(duration % 60)); " / " + ehs::Str_8::FromNum(duration / 60) + ":" + ehs::Str_8::FromNum(duration % 60));
if (win->IsCursorConstrained() && !win->IsCursorVisible()) if (keyboard->IsJustReleased(ehs::Keyboard::Left))
source->SetVolume(source->GetVolume() - 0.1f);
if (keyboard->IsJustReleased(ehs::Keyboard::Right))
source->SetVolume(source->GetVolume() + 0.1f);
lwe::LabelGui* volume = (lwe::LabelGui*)stats->GetChild("Volume");
volume->SetText("Volume: " + ehs::Str_8::FromNum(source->GetVolume()));
if (keyboard->IsJustReleased(ehs::Keyboard::P))
{ {
if (keyboard->IsJustReleased(ehs::Keyboard::Left)) if (source->IsPlaying())
source->SetVolume(source->GetVolume() - 0.25f); source->Pause();
else
if (keyboard->IsJustReleased(ehs::Keyboard::Right)) source->Play();
source->SetVolume(source->GetVolume() + 0.25f);
lwe::LabelGui* volume = (lwe::LabelGui*)stats->GetChild("Volume");
volume->SetText("Volume: " + ehs::Str_8::FromNum(source->GetVolume()));
if (keyboard->IsJustReleased(ehs::Keyboard::P))
{
if (source->IsPlaying())
source->Pause();
else
source->Play();
}
if (keyboard->IsJustReleased(ehs::Keyboard::Backspace))
source->Reset();
} }
if (keyboard->IsJustReleased(ehs::Keyboard::Backspace))
source->Reset();
} }

View File

@ -21,7 +21,7 @@ public:
void SetupResources(lwe::GpuInterface* inf) override; void SetupResources(lwe::GpuInterface* inf) override;
void Setup() override; void Setup(lwe::GpuInterface* inf) override;
void PostInitialize(lwe::GpuCmdBuffer* cmdBuffer) override; void PostInitialize(lwe::GpuCmdBuffer* cmdBuffer) override;

View File

@ -18,46 +18,12 @@
#include "Levels/MainMenu.h" #include "Levels/MainMenu.h"
#include "Levels/TestLevel.h" #include "Levels/TestLevel.h"
void LogRaised(const ehs::Log& log)
{
ehs::Array<ehs::Str_8> tags = log.GetTags();
ehs::Str_8 result = "{";
if (log.HasTag("Info"))
{
result += "Info";
result += "}: " + log.GetMsg();
}
else
{
for (ehs::UInt_32 i = 0; i < tags.Size(); ++i)
{
result += tags[i];
if (i != tags.Size() - 1)
result += ", ";
}
result += "} (" + ehs::Str_8::FromNum(log.GetCode()) + "): " + log.GetMsg();
}
ehs::Console::Write_8(result);
if (log.HasTag("Error"))
{
ehs::Console::Read_8();
}
}
ehs::SInt_32 Main(ehs::Str_8* appName, ehs::Str_8* appVerId, ehs::Version* appVer) ehs::SInt_32 Main(ehs::Str_8* appName, ehs::Str_8* appVerId, ehs::Version* appVer)
{ {
*appName = "TechDemo"; *appName = "TechDemo";
*appVerId = "Release"; *appVerId = "Release";
*appVer = {1, 0, 0}; *appVer = {1, 0, 0};
ehs::Log::SetCallback(LogRaised);
ehs::File configFile("Config.json", ehs::Mode::READ_WRITE, ehs::Disposition::OPEN_PERSISTENT); ehs::File configFile("Config.json", ehs::Mode::READ_WRITE, ehs::Disposition::OPEN_PERSISTENT);
if (!configFile.Size()) if (!configFile.Size())