More cleanup complete
This commit is contained in:
@ -3,75 +3,21 @@
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Custom variables
|
||||
set(
|
||||
DAWN_TARGET_DEPENDENCIES_LAST
|
||||
CACHE INTERNAL ${DAWN_CACHE_TARGET}
|
||||
)
|
||||
|
||||
# Build Project
|
||||
add_executable(${DAWN_TARGET_NAME})
|
||||
|
||||
# Change what we are building. Pulled from the cmake/targets dir.
|
||||
if(DEFINED DAWN_BUILDING)
|
||||
add_subdirectory(${DAWN_BUILDING})
|
||||
# Add in base library
|
||||
add_subdirectory(dawn)
|
||||
|
||||
# Compile entry targets
|
||||
if(DAWN_TARGET STREQUAL "linux-x64-glfw")
|
||||
add_subdirectory(dawnlinux)
|
||||
add_subdirectory(dawnglfw)
|
||||
add_subdirectory(dawnopengl)
|
||||
add_subdirectory(dawnpoker)
|
||||
else()
|
||||
message(FATAL_ERROR "You need to define an entry target")
|
||||
endif()
|
||||
|
||||
# Validate game project includes the target name
|
||||
if(DEFINED DAWN_TARGET_NAME)
|
||||
# Add in base library
|
||||
add_subdirectory(dawn)
|
||||
|
||||
# Compile entry targets
|
||||
if(DAWN_TARGET_WIN32)
|
||||
add_subdirectory(dawnwin32)
|
||||
elseif(DAWN_TARGET_LINUX)
|
||||
add_subdirectory(dawnlinux)
|
||||
elseif(DAWN_TARGET_OSX)
|
||||
add_subdirectory(dawnosx)
|
||||
elseif(DAWN_TARGET_VITA)
|
||||
add_subdirectory(dawnvita)
|
||||
elseif(DAWN_TARGET_EMSCRIPTEN)
|
||||
add_subdirectory(dawnemscripten)
|
||||
else()
|
||||
message(FATAL_ERROR "You need to define an entry target")
|
||||
endif()
|
||||
|
||||
# Host Libraries
|
||||
target_link_libraries(${DAWN_TARGET_NAME}
|
||||
PUBLIC
|
||||
${DAWN_BUILD_HOST_LIBS}
|
||||
)
|
||||
|
||||
# Compile support targets
|
||||
if(DAWN_TARGET_GLFW)
|
||||
add_subdirectory(dawnglfw)
|
||||
add_subdirectory(dawnopengl)
|
||||
endif()
|
||||
|
||||
if(DAWN_TARGET_TRUETYPE)
|
||||
add_subdirectory(dawntruetype)
|
||||
endif()
|
||||
|
||||
if(DAWN_TARGET_SDL2)
|
||||
add_subdirectory(dawnsdl2)
|
||||
add_subdirectory(dawnopengl)
|
||||
endif()
|
||||
|
||||
if(DAWN_TARGET_VITA)
|
||||
add_subdirectory(dawnopengl)
|
||||
endif()
|
||||
|
||||
if(DAWN_TARGET_OPENAL)
|
||||
add_subdirectory(dawnopenal)
|
||||
endif()
|
||||
|
||||
# Late definitions, used by tools
|
||||
if(NOT DAWN_TARGET_DEPENDENCIES_LAST)
|
||||
else()
|
||||
add_dependencies(${DAWN_TARGET_NAME} ${DAWN_TARGET_DEPENDENCIES_LAST})
|
||||
endif()
|
||||
|
||||
# Compress the game assets.
|
||||
add_dependencies(${DAWN_TARGET_NAME} dawnassets)
|
||||
endif()
|
||||
# Compress the game assets.
|
||||
add_dependencies(${DAWN_TARGET_NAME} dawnassets)
|
@ -18,8 +18,8 @@ void Game::init() {
|
||||
inputManager.init(shared_from_this());
|
||||
saveManager.init(shared_from_this());
|
||||
|
||||
auto initialScene = GameInit::getInitialScene();
|
||||
nextFrameScene = std::make_shared<Scene>(shared_from_this(), initialScene);
|
||||
auto initialScene = Scene::getInitialScene();
|
||||
this->nextFrameScene = std::make_shared<Scene>(shared_from_this(), initialScene);
|
||||
}
|
||||
|
||||
void Game::update() {
|
||||
|
@ -31,6 +31,13 @@ namespace Dawn {
|
||||
TimeoutEvent onTimeout;
|
||||
IntervalEvent onInterval;
|
||||
|
||||
/**
|
||||
* Returns the initial scene for the game.
|
||||
*
|
||||
* @return Initial scene function.
|
||||
*/
|
||||
static const std::function<void(Scene&)> getInitialScene();
|
||||
|
||||
/**
|
||||
* Constructs a scene object.
|
||||
*
|
||||
|
@ -9,9 +9,14 @@ target_include_directories(${DAWN_TARGET_NAME}
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
||||
|
||||
# Sources
|
||||
target_sources(${DAWN_TARGET_NAME}
|
||||
PRIVATE
|
||||
dawnpoker.cpp
|
||||
)
|
||||
|
||||
# Subdirs
|
||||
add_subdirectory(game)
|
||||
add_subdirectory(scene)
|
||||
add_subdirectory(scenes)
|
||||
|
||||
# Assets
|
||||
# include("${DAWN_ASSETS_SOURCE_DIR}/games/helloworld/CMakeLists.txt")
|
||||
# include("${DAWN_ASSETS_SOURCE_DIR}/games/dawnpoker/CMakeLists.txt")
|
12
src/dawnpoker/dawnpoker.cpp
Normal file
12
src/dawnpoker/dawnpoker.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
// Copyright (c) 2024 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "scenes/SceneList.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
const std::function<void(Scene&)> Scene::getInitialScene() {
|
||||
return Dawn::testScene;
|
||||
}
|
@ -5,5 +5,5 @@
|
||||
|
||||
target_sources(${DAWN_TARGET_NAME}
|
||||
PRIVATE
|
||||
GameInit.cpp
|
||||
TestScene.cpp
|
||||
)
|
@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
// Copyright (c) 2024 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
@ -7,5 +7,5 @@
|
||||
#include "scene/Scene.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
void helloWorldScene(Scene &s);
|
||||
}
|
||||
void testScene(Scene &scene);
|
||||
}
|
29
src/dawnpoker/scenes/TestScene.cpp
Normal file
29
src/dawnpoker/scenes/TestScene.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "scenes/SceneList.hpp"
|
||||
#include "component/display/Camera.hpp"
|
||||
#include "prefab/SimpleSpinningCube.hpp"
|
||||
#include "component/display/material/SimpleTexturedMaterial.hpp"
|
||||
#include "display/mesh/CubeMesh.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
void Dawn::testScene(Scene &s) {
|
||||
auto cameraItem = s.createSceneItem();
|
||||
auto camera = cameraItem->addComponent<Camera>();
|
||||
cameraItem->lookAt({ 3, 3, 3 }, { 0, 0, 0 }, { 0, 1, 0 });
|
||||
camera->clipFar = 99999.99f;
|
||||
|
||||
auto cube = s.createSceneItem();
|
||||
auto cubeMesh = std::make_shared<Mesh>();
|
||||
auto cubeRenderer = cube->addComponent<MeshRenderer>();
|
||||
auto cubeMaterial = cube->addComponent<SimpleTexturedMaterial>();
|
||||
|
||||
cubeRenderer->mesh = cubeMesh;
|
||||
cubeMesh->createBuffers(CUBE_VERTICE_COUNT, CUBE_INDICE_COUNT);
|
||||
CubeMesh::buffer(cubeMesh, glm::vec3(0,0,0), glm::vec3(1, 1, 1), 0, 0);
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "game/GameInit.hpp"
|
||||
#include "scene/SceneList.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
std::function<void(Scene&)> GameInit::getInitialScene() {
|
||||
return helloWorldScene;
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
# Copyright (c) 2023 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
target_sources(${DAWN_TARGET_NAME}
|
||||
PRIVATE
|
||||
HelloWorldScene.cpp
|
||||
)
|
@ -1,46 +0,0 @@
|
||||
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "scene/SceneList.hpp"
|
||||
#include "component/display/Camera.hpp"
|
||||
#include "prefab/SimpleSpinningCube.hpp"
|
||||
#include "component/display/material/SimpleTexturedMaterial.hpp"
|
||||
#include "display/mesh/QuadMesh.hpp"
|
||||
#include "component/ui/UICanvas.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
void Dawn::helloWorldScene(Scene &s) {
|
||||
// while(!s.getGame()->assetManager.isLoaded(font)) {
|
||||
// s.getGame()->assetManager.update();
|
||||
// }
|
||||
|
||||
auto cameraItem = s.createSceneItem();
|
||||
auto camera = cameraItem->addComponent<Camera>();
|
||||
cameraItem->lookAt({ 3, 3, 3 }, { 0, 0, 0 }, { 0, 1, 0 });
|
||||
camera->clipFar = 99999.99f;
|
||||
|
||||
glm::vec2 position = { 0, 0 };
|
||||
glm::vec2 size = { 1, 1 };
|
||||
auto quad = s.createSceneItem();
|
||||
auto quadMesh = std::make_shared<Mesh>();
|
||||
quadMesh->createBuffers(QUAD_VERTICE_COUNT, QUAD_INDICE_COUNT);
|
||||
QuadMesh::buffer(
|
||||
quadMesh,
|
||||
glm::vec4(position.x, position.y, size.x, size.y),
|
||||
glm::vec4(0, 0, 1, 1),
|
||||
0, 0, 0
|
||||
);
|
||||
|
||||
auto quadRenderer = quad->addComponent<MeshRenderer>();
|
||||
quadRenderer->mesh = quadMesh;
|
||||
|
||||
auto quadMaterial = quad->addComponent<SimpleTexturedMaterial>();
|
||||
quadMaterial->setColor(COLOR_WHITE);
|
||||
|
||||
auto uiCanvasItem = s.createSceneItem();
|
||||
auto uiCanvas = uiCanvasItem->addComponent<UICanvas>();
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "AssetManager.hpp"
|
||||
#include "asset/AssetManager.hpp"
|
||||
#include "loaders/TrueTypeLoader.hpp"
|
||||
|
||||
template<>
|
||||
|
Reference in New Issue
Block a user