switch to cmake
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
||||
[submodule "vendor/asset-packer"]
|
||||
path = vendor/asset-packer
|
||||
url = git@github.com:ShadesAndGrays/Asset-Packer.git
|
||||
[submodule "vendor/raylib"]
|
||||
path = vendor/raylib
|
||||
url = git@github.com:ShadesAndGrays/Asset-Packer.git
|
||||
[submodule "vendor/rlImGui"]
|
||||
path = vendor/rlImGui
|
||||
url = https://github.com/raylib-extras/rlImGui.git
|
||||
[submodule "vendor/imgui"]
|
||||
path = vendor/imgui
|
||||
url = https://github.com/ocornut/imgui.git
|
||||
+108
-11
@@ -1,11 +1,12 @@
|
||||
cmake_minimum_required(VERSION 4.4.0)
|
||||
|
||||
|
||||
project(my_app LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
# set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
file( GLOB_RECURSE
|
||||
SRC
|
||||
@@ -14,18 +15,114 @@ file( GLOB_RECURSE
|
||||
"src/*.hpp"
|
||||
)
|
||||
|
||||
message(VERBOSE ${SRC})
|
||||
|
||||
add_executable(my_app ${SRC})
|
||||
#------------------------------------------------------------------------------------------
|
||||
# Subdirectories
|
||||
#------------------------------------------------------------------------------------------
|
||||
|
||||
INCLUDE_DIRECTORIES("src")
|
||||
set(BUILD_EXAMPLES OFF)
|
||||
add_subdirectory(vendor/raylib)
|
||||
add_subdirectory(vendor/asset-packer)
|
||||
|
||||
set_target_properties( my_app PROPERTIES
|
||||
CXX_STANDARD 23
|
||||
CXX_STANDARD_REQUIRED ON
|
||||
CXX_EXTENXSIONS OFF
|
||||
|
||||
#------------------------------------------------------------------------------------------
|
||||
# GUI
|
||||
#------------------------------------------------------------------------------------------
|
||||
|
||||
#ImGui
|
||||
set(IMGUI_DIR "${CMAKE_CURRENT_SOURCE_DIR}/vendor/imgui")
|
||||
|
||||
add_library(imgui STATIC
|
||||
${IMGUI_DIR}/imgui.cpp
|
||||
${IMGUI_DIR}/imgui_demo.cpp
|
||||
${IMGUI_DIR}/imgui_draw.cpp
|
||||
${IMGUI_DIR}/imgui_tables.cpp
|
||||
${IMGUI_DIR}/imgui_widgets.cpp
|
||||
)
|
||||
|
||||
target_include_directories(imgui PUBLIC ${IMGUI_DIR})
|
||||
|
||||
# rlImGui
|
||||
set(RLIMGUI_DIR "${CMAKE_CURRENT_SOURCE_DIR}/vendor/rlImGui")
|
||||
|
||||
add_library(rlImGui STATIC
|
||||
${RLIMGUI_DIR}/rlImGui.cpp
|
||||
)
|
||||
|
||||
target_include_directories(rlImGui PUBLIC ${RLIMGUI_DIR})
|
||||
target_link_libraries(rlImGui PUBLIC imgui raylib)
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------------------
|
||||
# Executable
|
||||
#------------------------------------------------------------------------------------------
|
||||
|
||||
add_executable(${PROJECT_NAME} ${SRC})
|
||||
|
||||
|
||||
# Export ImGui headers so anything linking to 'imgui' gets them automatically
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE vendor/entt src)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
AssetPacker::assetpacker
|
||||
rlImGui
|
||||
imgui
|
||||
raylib
|
||||
)
|
||||
|
||||
#------------------------------------------------------------------------------------------
|
||||
# Make Assets
|
||||
#------------------------------------------------------------------------------------------
|
||||
|
||||
set(BUILD_ASSET_DIR "${CMAKE_CURRENT_BINARY_DIR}/assets")
|
||||
set(PACKED_DATA_FILE "${CMAKE_CURRENT_BINARY_DIR}/data.dat")
|
||||
|
||||
add_custom_target( pack-asset
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/assets"
|
||||
"${BUILD_ASSET_DIR}"
|
||||
|
||||
|
||||
# 2. Pass relative paths to assetpacker!
|
||||
# Because WORKING_DIRECTORY is ${CMAKE_CURRENT_BINARY_DIR},
|
||||
# 'assets' resolves to './assets' and 'data.dat' resolves to './data.dat'
|
||||
|
||||
# Set execution context so relative paths inside assetpacker work
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
|
||||
COMMAND AssetPacker::packer "assets/"
|
||||
|
||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/assets" AssetPacker::packer
|
||||
COMMENT "Copying assets folder and packing via relative paths..."
|
||||
VERBATIM
|
||||
|
||||
)
|
||||
|
||||
target_link_libraries(my_app PRIVATE stdc++exp )
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# WebAssembly / Emscripten Configurations
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
if(EMSCRIPTEN)
|
||||
# Output an HTML page instead of a raw binary
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||
OUTPUT_NAME "index"
|
||||
SUFFIX ".html"
|
||||
)
|
||||
|
||||
# Pass Emscripten linker flags
|
||||
target_link_options(${PROJECT_NAME} PRIVATE
|
||||
"-sUSE_GLFW=3" # Needed for Raylib web builds
|
||||
"-sASYNCIFY" # Allows main loop to yield to the browser
|
||||
"--shell-file" "${CMAKE_CURRENT_SOURCE_DIR}/html/shell_custom.html" # (Optional) Custom HTML shell
|
||||
# Pre-pack your assets directory into the WebAssembly virtual filesystem
|
||||
"--preload-file" "${CMAKE_CURRENT_BINARY_DIR}/data.dat@/data.dat"
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
add_custom_target( run
|
||||
COMMAND ${PROJECT_NAME}
|
||||
DEPENDS ${PROJECT_NAME}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
@@ -0,0 +1,8 @@
|
||||
[Window][Debug##Default]
|
||||
Pos=60,60
|
||||
Size=400,400
|
||||
|
||||
[Window][VBoxContainer]
|
||||
Pos=540,235
|
||||
Size=200,250
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <raylib.h>
|
||||
#include <asset_packer/asset.hpp>
|
||||
#include <asset-packer.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include <asset_packer/asset.hpp>
|
||||
#include <asset-packer.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <variant>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "engine/asset/raylib-asset.hpp"
|
||||
|
||||
#include "engine/scene/scene.hpp"
|
||||
#include "imgui.h"
|
||||
#include "raylib.h"
|
||||
#include "rlImGui.h"
|
||||
#include <memory>
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace varicle {
|
||||
// Window configuration variables that a derived game can tweak in its constructor
|
||||
int m_window_width = 1280;
|
||||
int m_window_height = 720;
|
||||
const char* m_window_title = "My Raylib Engine Game";
|
||||
const char* m_window_title = "Varicle Framework Prototype";
|
||||
|
||||
public:
|
||||
Application() = default;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "engine/core/service-locator.hpp"
|
||||
#include "engine/scene/scene.hpp"
|
||||
|
||||
#include "game/scenes/game-over-scene/game-over.hpp"
|
||||
#include "game/scenes/main-scene/main-scene.hpp"
|
||||
#include "game/scenes/menu-scene/menu.hpp"
|
||||
|
||||
#include <raylib.h>
|
||||
|
||||
@@ -1,15 +1,38 @@
|
||||
#include "menu.hpp"
|
||||
|
||||
#include "engine/asset/raylib-asset.hpp"
|
||||
#include "engine/core/service-locator.hpp"
|
||||
#include "raylib.h"
|
||||
#include "engine/ecs/components.hpp"
|
||||
#include "engine/render/render-system.hpp"
|
||||
|
||||
#include <imgui.h>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
void MenuScene::init() {}
|
||||
void MenuScene::init() {
|
||||
using namespace varicle;
|
||||
ServiceLocator::provide(std::make_unique<RaylibAssetLoader>());
|
||||
|
||||
|
||||
auto& asset_loader =ServiceLocator::get<RaylibAssetLoader>(); asset_loader.load_asset("assets/bird.png");
|
||||
auto x = asset_loader.get_reader().get_asset_list();
|
||||
for (auto i :x) {
|
||||
std::cout << i << std::endl;
|
||||
}
|
||||
|
||||
auto e = registry.create();
|
||||
registry.emplace<Position>(e,650.0f,150.0f);
|
||||
auto bird_texture = asset_loader.get_texture("assets/bird.png");
|
||||
registry.emplace<Sprite>(e,bird_texture,0.0f,0.f,100.f,100.f,false,false,0.f);
|
||||
auto img = LoadImageFromTexture(*bird_texture);
|
||||
SetWindowIcon(img);
|
||||
UnloadImage(img);
|
||||
|
||||
}
|
||||
|
||||
void MenuScene::update(float dt) {}
|
||||
|
||||
void MenuScene::render() {}
|
||||
void MenuScene::render() { varicle::update_render_system(registry); }
|
||||
|
||||
void MenuScene::ui() {
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "engine/scene/scene.hpp"
|
||||
#include <entt/entt.hpp>
|
||||
|
||||
namespace v = varicle;
|
||||
|
||||
class MenuScene : public v::Scene {
|
||||
public:
|
||||
entt::registry registry;
|
||||
void init() override;
|
||||
void update(float dt) override;
|
||||
void render() override;
|
||||
+1
Submodule vendor/asset-packer added at 674c7d1dae
Vendored
+95903
File diff suppressed because it is too large
Load Diff
+1
Submodule vendor/imgui added at 8936b58fe2
Vendored
+25526
File diff suppressed because it is too large
Load Diff
+1
Submodule vendor/raylib added at aa4cf20eae
+1
Submodule vendor/rlImGui added at ef129d1858
Reference in New Issue
Block a user