First commit.

This commit is contained in:
Arron David Nelson 2024-07-27 10:18:00 -07:00
commit 1cbba8dc35
7 changed files with 287 additions and 0 deletions

13
.gitignore vendored Normal file
View File

@ -0,0 +1,13 @@
*.obj
*.cpp.obj
*.lib
*.exe
*.a
*.ninja_deps
*.ninja_log
*.ninja
*.cmake
*.log
/.idea/
/cmake-build-release/
/cmake-build-debug/

83
CMakeLists.txt Normal file
View File

@ -0,0 +1,83 @@
cmake_minimum_required(VERSION 3.18.4)
project(SpriteGen C CXX)
if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows")
set(IS_OS_WINDOWS TRUE)
set(USER_HOME_DIRECTORY $ENV{USERPROFILE})
string(REPLACE "\\" "/" USER_HOME_DIRECTORY "${USER_HOME_DIRECTORY}")
message("Building for the Windows operating system.")
elseif (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux")
set(IS_OS_LINUX TRUE)
set(USER_HOME_DIRECTORY $ENV{HOME})
add_compile_options(-Wno-stringop-overflow)
message("Building for the Linux operating system.")
elseif (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin")
set(IS_OS_MAC TRUE)
set(USER_HOME_DIRECTORY $ENV{HOME})
message("Building for the Mac operating system.")
endif ()
if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64" OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
message("Building for AMD64 architecture.")
set(IS_ARCH_AMD64 TRUE)
elseif ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "ARM64" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64")
message("Building for ARM64 architecture.")
set(IS_ARCH_ARM64 TRUE)
endif ()
message("Home Dir: ${USER_HOME_DIRECTORY}")
set(CMAKE_CXX_STANDARD 20)
add_executable(SpriteGen
main.cpp
MainLvl.h MainLvl.cpp
Sprite.cpp
Sprite.h
)
find_package(Vulkan REQUIRED)
if (Vulkan_FOUND)
message(STATUS "Vulkan was found.")
else ()
message(STATUS "Vulkan was not found.")
endif ()
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 ()
if (IS_OS_WINDOWS)
add_compile_definitions(VK_USE_PLATFORM_WIN32_KHR)
target_include_directories(SpriteGen PRIVATE "${USER_HOME_DIRECTORY}/EHS/include")
target_include_directories(SpriteGen PRIVATE "${USER_HOME_DIRECTORY}/EHE/include")
target_include_directories(SpriteGen PRIVATE "${USER_HOME_DIRECTORY}/EHC/include")
target_include_directories(SpriteGen PRIVATE "${USER_HOME_DIRECTORY}/LWE/include")
target_link_directories(SpriteGen PRIVATE "${USER_HOME_DIRECTORY}/EHS/lib")
target_link_directories(SpriteGen PRIVATE "${USER_HOME_DIRECTORY}/EHE/lib")
target_link_directories(SpriteGen PRIVATE "${USER_HOME_DIRECTORY}/EHC/lib")
target_link_directories(SpriteGen PRIVATE "${USER_HOME_DIRECTORY}/LWE/lib")
target_link_libraries(SpriteGen PRIVATE ws2_32 avrt)
elseif (IS_OS_LINUX)
add_compile_definitions(VK_USE_PLATFORM_WAYLAND_KHR EHS_WS_WAYLAND)
target_link_directories(SpriteGen PRIVATE "${USER_HOME_DIRECTORY}/.local/lib")
target_include_directories(SpriteGen PRIVATE "${USER_HOME_DIRECTORY}/.local/include")
target_link_libraries(SpriteGen PRIVATE wayland-client xcb xcb-cursor xcb-xfixes xcb-xinput asound)
endif()
target_link_libraries(SpriteGen PRIVATE Vulkan::Headers Vulkan::Vulkan OpenSSL::SSL OpenSSL::Crypto ZLIB::ZLIB LWE EHC EHE EHS_STC)

97
MainLvl.cpp Normal file
View File

@ -0,0 +1,97 @@
#include "MainLvl.h"
#include <lwe/systems/GuiSystem.h>
#include <lwe/gpu/GpuFontAtlas.h>
#include <lwe/gui/ButtonGui.h>
#include <lwe/gui/TextFieldGui.h>
#include <lwe/gui/LabelGui.h>
MainLvl::~MainLvl()
{
}
MainLvl::MainLvl()
: Level("Main")
{
}
MainLvl::MainLvl(MainLvl &&lvl) noexcept
: Level((Level &&) lvl)
{
}
MainLvl::MainLvl(const MainLvl &lvl)
: Level(lvl)
{
}
MainLvl &MainLvl::operator=(MainLvl &&lvl) noexcept
{
if (this == &lvl)
return *this;
Level::operator=((Level &&) lvl);
return *this;
}
MainLvl &MainLvl::operator=(const MainLvl &lvl)
{
if (this == &lvl)
return *this;
Level::operator=(lvl);
return *this;
}
void MainLvl::SetupResources(lwe::GpuInterface *inf)
{
Level::SetupResources(inf);
//Your resource setup code here.
}
void MainLvl::Setup(lwe::GpuInterface *inf)
{
Level::Setup(inf);
//Your setup code here.
lwe::GuiSystem *guiSys = new lwe::GuiSystem();
AddSystem(guiSys);
//Add Resources
lwe::GpuFontAtlas *arial_24 = new lwe::GpuFontAtlas("resources/fonts/Arial_24.ehf", inf);
guiSys->AddResource(arial_24);
//Add Gui
lwe::LabelGui *dirLabel = new lwe::LabelGui("DirLabel", "Arial_24", "Directory:");
guiSys->AddGui(dirLabel);
lwe::TextFieldGui *dirField = new lwe::TextFieldGui("DirField", "Test");
dirField->SetPosition({arial_24->CalculateWidth(dirLabel->GetText()), 0.0f, 0.0f});
dirField->SetScale({200.0f, (float)arial_24->GetGlyphScale() + 10.0f});
guiSys->AddGui(dirField);
}
void MainLvl::PostInitialize(lwe::GpuCmdBuffer *cmdBuffer)
{
Level::PostInitialize(cmdBuffer);
//Your post-initialize code here.
}
void MainLvl::OnUpdate(lwe::RenderWindow *win, ehs::Input *input, const float delta)
{
Level::OnUpdate(win, input, delta);
//Your on-update code here.
}
void MainLvl::PreRender(lwe::GpuCmdBuffer *cmdBuffer)
{
Level::PreRender(cmdBuffer);
//Your pre-render code here.
}

29
MainLvl.h Normal file
View File

@ -0,0 +1,29 @@
#pragma once
#include <lwe/Level.h>
class MainLvl : public lwe::Level
{
public:
~MainLvl() override;
MainLvl();
MainLvl(MainLvl &&lvl) noexcept;
MainLvl(const MainLvl &lvl);
MainLvl &operator=(MainLvl &&lvl) noexcept;
MainLvl &operator=(const MainLvl &lvl);
void SetupResources(lwe::GpuInterface *inf) override;
void Setup(lwe::GpuInterface *inf) override;
void PostInitialize(lwe::GpuCmdBuffer *cmdBuffer) override;
void OnUpdate(lwe::RenderWindow *win, ehs::Input *input, float delta) override;
void PreRender(lwe::GpuCmdBuffer *cmdBuffer) override;
};

5
Sprite.cpp Normal file
View File

@ -0,0 +1,5 @@
#include "Sprite.h"
namespace ehs
{
}

9
Sprite.h Normal file
View File

@ -0,0 +1,9 @@
#pragma once
namespace ehs
{
class Sprite
{
};
}

51
main.cpp Normal file
View File

@ -0,0 +1,51 @@
#include <ehs/EHS.h>
#include <ehs/Log.h>
#include <lwe/RenderWindow.h>
#include <lwe/GameLoop.h>
#include "MainLvl.h"
int main()
{
ehs::Initialize("SpriteGen", "Release", {1, 0, 0});
ehs::Log::EnableImmediateMode(true);
lwe::RenderWindow::AddExtensions();
lwe::GpuInstance::Initialize(true);
lwe::GpuDevice device = std::move(lwe::GpuDevice::GetBest());
lwe::GpuQueueFamily* family = device.GetQueueFamily(lwe::QueueType::GRAPHICS);
lwe::GpuInterface inf(&device);
lwe::RenderWindow::AddExtensions(&inf);
lwe::GpuQueue primary(family, &inf, 1.0f);
inf.Initialize();
lwe::RenderWindow win(&inf, &primary);
win.Create_8(ehs::GetAppName_8(), {0, 0}, {1024, 768});
win.Show();
lwe::GameLoop gl(&win, 0, 0);
gl.EnableTimeLock(true);
gl.SetMaxTPS(60);
gl.AddLevel(new MainLvl());
gl.Initialize();
gl.Start();
gl.UnInitialize();
win.Close();
inf.Release();
lwe::GpuInstance::Release();
ehs::Uninitialize();
return 0;
}