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)
add_compile_definitions(VK_USE_PLATFORM_WIN32_KHR)
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()
target_link_directories(TechDemo PRIVATE "${USER_HOME_DIRECTORY}/Libraries/EHS/lib")
target_link_directories(TechDemo PRIVATE "${USER_HOME_DIRECTORY}/Libraries/LWE/lib")
target_include_directories(TechDemo PRIVATE "${USER_HOME_DIRECTORY}/Libraries/EHS/include")
target_include_directories(TechDemo PRIVATE "${USER_HOME_DIRECTORY}/Libraries/LWE/include")
target_link_directories(TechDemo PRIVATE "${USER_HOME_DIRECTORY}/.local/lib")
target_include_directories(TechDemo PRIVATE "${USER_HOME_DIRECTORY}/.local/include")
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
#include <LWE/LWE.h>
#include <LWE/Gui/CollectionGui.h>
#include <lwe/gui/CollectionGui.h>
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::RigidBodySystem());

View File

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

View File

@ -86,11 +86,10 @@ void TestLevel::SetupResources(lwe::GpuInterface* inf)
AddResource(arial_24);
lwe::GpuModel* vampire = new lwe::GpuModel("resources/models/Vampire.ehm", inf);
//vampire->Calculate();
AddResource(vampire);
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_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);
//portrait->Calculate();
@ -99,17 +98,17 @@ void TestLevel::SetupResources(lwe::GpuInterface* inf)
lwe::GpuMesh* portraitGUI = new lwe::GpuMesh(inf, ehs::portraitGui);
AddResource(portraitGUI);
AddResource(new lwe::GpuModel("Resources/Models/Cube.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/Cube.ehm", inf));
AddResource(new lwe::GpuModel("resources/models/Sphere.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(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();
if (!gl)
@ -275,7 +274,9 @@ void TestLevel::Setup()
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*>();
args.SetOffset(0);
@ -292,18 +293,18 @@ void TestLevel::Setup()
testPanel->SetPosition({300.0f, 200.0f, 0.0f});
testPanel->SetScale({400.0f, 400.0f});
guiSys->AddGui(testPanel);
*/
lwe::WindowGui* testWin = new lwe::WindowGui("TestWindow", "Hello world!");
testWin->SetPosition({300.0f, 200.0f, 0.0f});
testWin->SetScale({400.0f, 400.0f});
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::Point3D("Head", 1.0f, 1.0f));
player->AddComponent(new lwe::PlyController("Head"));
player.AddComponent(new lwe::Point3D("Head", 1.0f, 1.0f));
player.AddComponent(new lwe::PlyController("Head"));
//player->AddComponent(new lwe::Health(100, 100));
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);
lwe::Entity* plyPuppet = new lwe::Entity("Puppet");
plyPuppet->AddComponent(new lwe::OBB3D("Head", 1.0f, 1.0f));
plyPuppet->AddComponent(new lwe::Camera("Head"));
plyPuppet->AddComponent(new lwe::Health(100, 100));
lwe::Entity plyPuppet("Puppet");
plyPuppet.AddComponent(new lwe::OBB3D("Head", 1.0f, 1.0f));
plyPuppet.AddComponent(new lwe::Camera("Head"));
plyPuppet.AddComponent(new lwe::Health(100, 100));
lwe::SolidColor* puppetMdl = new lwe::SolidColor("Cube", {0.0f, 0.0f, 1.0f}, "Cube", "");
puppetMdl->SetDiffused(true);
@ -327,18 +328,18 @@ void TestLevel::Setup()
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");
skyboxEnt->AddComponent(skybox);
skyboxEnt.AddComponent(skybox);
AddEntity((lwe::Entity&&)skyboxEnt);
lwe::Entity* ent = new lwe::Entity("Main");
ent->SetScale({0.25f, 0.25f, 0.25f});
ent->SetPos({0.0f, -1.0f, 5.0f});
lwe::Entity ent("Main");
ent.SetScale({0.25f, 0.25f, 0.25f});
ent.SetPos({0.0f, -1.0f, 5.0f});
//ent->SetRot({-90.0f, 180.0f, 0.0f});
//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);
as->Pause();
as->EnableLoop(true);
as->EnableAutoDelete(false);
//as->EnablePanning(false);
//as->EnableAttenuation(false);
ent->AddComponent(as);
ent.AddComponent(as);
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);
entCollider->SetScale({1.0f, 2.0f, 1.0f});
@ -368,7 +370,7 @@ void TestLevel::Setup()
if (health->GetHealth() <= 0)
aOwner->Delete();
});
ent->AddComponent(entCollider);
ent.AddComponent(entCollider);
/*
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");
ph->SetAnimation("Test");
ent->AddComponent(ph);
ent.AddComponent(ph);
AddEntity((lwe::Entity&&)ent);
@ -391,33 +393,33 @@ void TestLevel::Setup()
AddEntity((lwe::Entity&&)sun);
lwe::Entity* emergency = new lwe::Entity("Emergency");
emergency->SetPos({5.0f, 0.0f, 5.0f});
lwe::Entity emergency("Emergency");
emergency.SetPos({5.0f, 0.0f, 5.0f});
lwe::PointLight* pl = new lwe::PointLight("Light");
pl->SetColor({1.0f, 0.0f, 0.0f});
emergency->AddComponent(pl);
emergency.AddComponent(pl);
AddEntity((lwe::Entity&&)emergency);
lwe::Entity* testEnt = new lwe::Entity("Test");
lwe::Entity testEnt("Test");
lwe::Billboard* testBb = new lwe::Billboard("TestBB", "Character_Diffuse");
testEnt->AddComponent(testBb);
testEnt.AddComponent(testBb);
AddEntity((lwe::Entity&&)testEnt);
lwe::Entity* bullet = new lwe::Entity("Bullet");
bullet->SetScale({0.1f, 0.1f, 0.1f});
lwe::Entity bullet("Bullet");
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);
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", "");
bullet->AddComponent(bulletMdl);
bullet.AddComponent(bulletMdl);
AddTemplate((lwe::Entity&&)bullet);
}
@ -538,7 +540,7 @@ void TestLevel::OnUpdate(lwe::RenderWindow* win, ehs::Input* input, const float
if (!source)
return;
lwe::Audio* audio = (lwe::Audio*)GetResource("Audio", source->GetAudioHashId());
ehs::Audio* audio = (ehs::Audio*)GetResource("Audio", source->GetAudioHashId());
if (!audio)
return;
@ -550,13 +552,11 @@ 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) +
" / " + 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.25f);
source->SetVolume(source->GetVolume() - 0.1f);
if (keyboard->IsJustReleased(ehs::Keyboard::Right))
source->SetVolume(source->GetVolume() + 0.25f);
source->SetVolume(source->GetVolume() + 0.1f);
lwe::LabelGui* volume = (lwe::LabelGui*)stats->GetChild("Volume");
volume->SetText("Volume: " + ehs::Str_8::FromNum(source->GetVolume()));
@ -571,5 +571,4 @@ void TestLevel::OnUpdate(lwe::RenderWindow* win, ehs::Input* input, const float
if (keyboard->IsJustReleased(ehs::Keyboard::Backspace))
source->Reset();
}
}

View File

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

View File

@ -18,46 +18,12 @@
#include "Levels/MainMenu.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)
{
*appName = "TechDemo";
*appVerId = "Release";
*appVer = {1, 0, 0};
ehs::Log::SetCallback(LogRaised);
ehs::File configFile("Config.json", ehs::Mode::READ_WRITE, ehs::Disposition::OPEN_PERSISTENT);
if (!configFile.Size())