diff --git a/CMakeLists.txt b/CMakeLists.txt index f8c5e607..9e948292 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,11 +10,46 @@ set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/") +set(DAWN_PROJECT_NAME "Dawn") +set(DAWN_PROJECT_VERSION "01.00") + # Variable Caches set(DAWN_CACHE_TARGET "dawn-target") -# CMake tools -add_subdirectory(cmake) +# Build target +if(DEFINED ENV{DAWN_BUILD_SYSTEM}) + set(DAWN_BUILD_SYSTEM $ENV{DAWN_BUILD_SYSTEM} CACHE INTERNAL ${DAWN_CACHE_TARGET}) +else() + set(DAWN_BUILD_SYSTEM "linux" CACHE INTERNAL ${DAWN_CACHE_TARGET}) +endif() + +# Build tools specifics +if(DAWN_BUILD_SYSTEM STREQUAL "vita") + if(NOT DEFINED CMAKE_TOOLCHAIN_FILE) + if(DEFINED ENV{VITASDK}) + set(CMAKE_TOOLCHAIN_FILE "$ENV{VITASDK}/share/vita.toolchain.cmake" CACHE PATH "toolchain file") + else() + message(FATAL_ERROR "Please define VITASDK to point to your SDK path!") + endif() + endif() + + include("$ENV{VITASDK}/share/vita.cmake" REQUIRED) + + set(DAWN_VITA_APP_NAME "${DAWN_PROJECT_NAME}" CACHE INTERNAL ${DAWN_CACHE_TARGET}) + set(DAWN_VITA_TITLEID "YWSH00001" CACHE INTERNAL ${DAWN_CACHE_TARGET}) + set(DAWN_VITA_VERSION "${DAWN_PROJECT_VERSION}" CACHE INTERNAL ${DAWN_CACHE_TARGET}) + set(VITA_MKSFOEX_FLAGS "${VITA_MKSFOEX_FLAGS} -d PARENTAL_LEVEL=1" CACHE INTERNAL ${DAWN_CACHE_TARGET}) +elseif(DAWN_BUILD_SYSTEM STREQUAL "psp") + if(NOT DEFINED CMAKE_TOOLCHAIN_FILE) + if(DEFINED ENV{PSPDEV}) + set(CMAKE_TOOLCHAIN_FILE "$ENV{PSPDEV}/psp/share/pspdev.cmake" CACHE PATH "toolchain file") + else() + message(FATAL_ERROR "Please define PSPDEV to point to your SDK path!") + endif() + endif() + + include("$ENV{PSPDEV}/psp/share/pspdev.cmake" REQUIRED) +endif() # Set Common Build Variables set(DAWN_ROOT_DIR "${CMAKE_SOURCE_DIR}") @@ -31,8 +66,8 @@ set(DAWN_ASSETS "" CACHE INTERNAL ${DAWN_CACHE_TARGET}) set(DAWN_BUILD_BINARY ${DAWN_BUILD_DIR}/Dawn CACHE INTERNAL ${DAWN_CACHE_TARGET}) # Initialize Project First. -project(Dawn - VERSION 1.0.0 +project("${DAWN_PROJECT_NAME}" + VERSION "${DAWN_PROJECT_VERSION}" LANGUAGES C CXX ) @@ -59,4 +94,13 @@ if(DAWN_BUILD_SYSTEM STREQUAL "vita") VERSION ${DAWN_VITA_VERSION} NAME ${DAWN_VITA_APP_NAME} ) +elseif(DAWN_BUILD_SYSTEM STREQUAL "psp") + create_pbp_file( + TARGET ${PROJECT_NAME} + ICON_PATH NULL + BACKGROUND_PATH NULL + PREVIEW_PATH NULL + TITLE ${PROJECT_NAME} + VERSION ${DAWN_PROJECT_VERSION} + ) endif() \ No newline at end of file diff --git a/ci/build-tools.sh b/ci/build-tools.sh deleted file mode 100755 index 1e2f793d..00000000 --- a/ci/build-tools.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -mkdir tools -cd tools -cmake .. -DDAWN_BUILD_TARGET=target-tools -make \ No newline at end of file diff --git a/ci/install-libraries.sh b/ci/install-libraries.sh deleted file mode 100755 index 1b0c74c9..00000000 --- a/ci/install-libraries.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -git submodule update --init --recursive \ No newline at end of file diff --git a/ci/install-linux-toolchain.sh b/ci/install-linux-toolchain.sh deleted file mode 100755 index 0485dc71..00000000 --- a/ci/install-linux-toolchain.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -sudo apt install build-essential \ No newline at end of file diff --git a/ci/install-vita-toolchain.sh b/ci/install-vita-toolchain.sh deleted file mode 100755 index a77d03eb..00000000 --- a/ci/install-vita-toolchain.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -sudo apt-get install cmake libarchive-tools -git clone https://github.com/vitasdk/vdpm ~/vdpm -cd ~/vdpm -./bootstrap-vitasdk.sh -export PATH=$VITASDK/bin:$PATH - -git clone https://github.com/vitasdk/packages.git ~/vitapackages -cd ~/vitapackages - -dir_array=( - zlib - bzip2 - henkaku - taihen - kubridge - openal-soft - openssl - curl - curlpp - expat - opus - opusfile - glm - kuio - vitaShaRK - libmathneon - vitaGL - SceShaccCgExt -) - -curdir=$(pwd) -for d in "${dir_array[@]}";do - echo "${curdir}${d}" - cd "${curdir}/${d}" - vita-makepkg - vdpm *-arm.tar.xz -done \ No newline at end of file diff --git a/ci/psp/Dockerfile b/ci/psp/Dockerfile new file mode 100644 index 00000000..a418eb70 --- /dev/null +++ b/ci/psp/Dockerfile @@ -0,0 +1,3 @@ +FROM pspdev/pspdev +RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python +RUN psp-pacman -Sy pspgl glm \ No newline at end of file diff --git a/ci/psp/docker-compose.yml b/ci/psp/docker-compose.yml new file mode 100644 index 00000000..9389204d --- /dev/null +++ b/ci/psp/docker-compose.yml @@ -0,0 +1,14 @@ +services: + dawn-psp: + build: . + volumes: + - ./../../:/Dawn + working_dir: /Dawn + command: + - /bin/bash + - -c + - | + mkdir -p ./build/psp + cd ./build/psp + psp-cmake ../.. -DDAWN_BUILD_SYSTEM=psp -DCMAKE_BUILD_TYPE=Debug + make \ No newline at end of file diff --git a/ci/quick-vita-build.sh b/ci/quick-vita-build.sh deleted file mode 100755 index 6b3cbce6..00000000 --- a/ci/quick-vita-build.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -mkdir -p vita/build -cd vita/build -if [ ! -d "src" ] -then - cmake ../.. -DDAWN_BUILD_TARGET=target-helloworld-vita -DCMAKE_BUILD_TYPE=Debug -fi -make -cp ./src/dawnvita/*.vpk ../ -cd ../.. \ No newline at end of file diff --git a/ci/vita/docker-compose.yml b/ci/vita/docker-compose.yml new file mode 100644 index 00000000..c77781ca --- /dev/null +++ b/ci/vita/docker-compose.yml @@ -0,0 +1,15 @@ +services: + dawn-vita: + image: gnuton/vitasdk-docker + volumes: + - ./../../:/Dawn + working_dir: /Dawn + command: + - /bin/bash + - -c + - | + rm -rf ./build/vita + mkdir -p ./build/vita + cd ./build/vita + cmake ../.. -DDAWN_BUILD_SYSTEM=vita -DCMAKE_BUILD_TYPE=Debug + make \ No newline at end of file diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt deleted file mode 100644 index 1652f4ee..00000000 --- a/cmake/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory(targets) \ No newline at end of file diff --git a/cmake/targets/CMakeLists.txt b/cmake/targets/CMakeLists.txt deleted file mode 100644 index f304b14b..00000000 --- a/cmake/targets/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -if(DEFINED ENV{DAWN_BUILD_SYSTEM}) - set(DAWN_BUILD_SYSTEM $ENV{DAWN_BUILD_SYSTEM} CACHE INTERNAL ${DAWN_CACHE_TARGET}) -else() - set(DAWN_BUILD_SYSTEM "linux" CACHE INTERNAL ${DAWN_CACHE_TARGET}) -endif() - -add_subdirectory(${DAWN_BUILD_SYSTEM}) \ No newline at end of file diff --git a/cmake/targets/linux/CMakeLists.txt b/cmake/targets/linux/CMakeLists.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/cmake/targets/vita/CMakeLists.txt b/cmake/targets/vita/CMakeLists.txt deleted file mode 100644 index f1f87c0d..00000000 --- a/cmake/targets/vita/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -if(NOT DEFINED CMAKE_TOOLCHAIN_FILE) - if(DEFINED ENV{VITASDK}) - set(CMAKE_TOOLCHAIN_FILE "$ENV{VITASDK}/share/vita.toolchain.cmake" CACHE PATH "toolchain file") - else() - message(FATAL_ERROR "Please define VITASDK to point to your SDK path!") - endif() -endif() - -include("$ENV{VITASDK}/share/vita.cmake" REQUIRED) - -set(DAWN_VITA_APP_NAME "Hello World" CACHE INTERNAL ${DAWN_CACHE_TARGET}) -# Unique ID must be exactly 9 characters. Recommended: XXXXYYYYY where X = -# unique string of developer and Y = a unique number for this app -set(DAWN_VITA_TITLEID "VSDK00006" CACHE INTERNAL ${DAWN_CACHE_TARGET}) -# Optional version string to show in LiveArea's more info screen -set(DAWN_VITA_VERSION "01.00" CACHE INTERNAL ${DAWN_CACHE_TARGET}) -# Optional. You can specify more param.sfo flags this way. -set(VITA_MKSFOEX_FLAGS "${VITA_MKSFOEX_FLAGS} -d PARENTAL_LEVEL=1" CACHE INTERNAL ${DAWN_CACHE_TARGET}) \ No newline at end of file diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index e866b8d1..ef4b0f5a 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -24,5 +24,8 @@ if(DAWN_BUILD_SYSTEM STREQUAL "linux") elseif(DAWN_BUILD_SYSTEM STREQUAL "vita") add_subdirectory(glm) - + +elseif(DAWN_BUILD_SYSTEM STREQUAL "psp") + add_subdirectory(glm) + endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index aa1500c8..c581a851 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,9 +9,16 @@ if(DAWN_BUILD_SYSTEM STREQUAL "linux") add_subdirectory(dawnglfw) add_subdirectory(dawnlinux) add_subdirectory(dawnopengl) - add_subdirectory(dawnrpg) elseif(DAWN_BUILD_SYSTEM STREQUAL "vita") add_subdirectory(dawn) add_subdirectory(dawnvita) add_subdirectory(dawnopengl) +elseif(DAWN_BUILD_SYSTEM STREQUAL "psp") + set(DAWN_OPENGL_SHADERS FALSE CACHE INTERNAL "${DAWN_CACHE_TARGET}") + set(DAWN_OPENGL_FRAMEBUFFERS FALSE CACHE INTERNAL "${DAWN_CACHE_TARGET}") + set(DAWN_OPENGL_MIPMAPS FALSE CACHE INTERNAL "${DAWN_CACHE_TARGET}") + add_subdirectory(dawn) + add_subdirectory(dawnpsp) +else() + message(FATAL_ERROR "Unknown build system: ${DAWN_BUILD_SYSTEM}") endif() \ No newline at end of file diff --git a/src/dawn/CMakeLists.txt b/src/dawn/CMakeLists.txt index 8546cec8..7a52bb17 100644 --- a/src/dawn/CMakeLists.txt +++ b/src/dawn/CMakeLists.txt @@ -6,7 +6,6 @@ # Libraries target_link_libraries(${DAWN_TARGET_NAME} PUBLIC - glm ) # Includes @@ -22,7 +21,6 @@ target_sources(${DAWN_TARGET_NAME} ) # Subdirs -add_subdirectory(display) add_subdirectory(error) add_subdirectory(game) add_subdirectory(locale) diff --git a/src/dawn/dawn.hpp b/src/dawn/dawn.hpp index 3ee04f6c..97e65305 100644 --- a/src/dawn/dawn.hpp +++ b/src/dawn/dawn.hpp @@ -25,10 +25,10 @@ #include #include -#define GLM_ENABLE_EXPERIMENTAL -#include -#include -#include +// #define GLM_ENABLE_EXPERIMENTAL +// #include +// #include +// #include typedef char char_t; typedef char8_t u8char_t; diff --git a/src/dawn/game/Game.cpp b/src/dawn/game/Game.cpp index 0ae4d690..f12e2188 100644 --- a/src/dawn/game/Game.cpp +++ b/src/dawn/game/Game.cpp @@ -8,64 +8,16 @@ using namespace Dawn; -Game::Game() : - renderManager() -{ - -} - -std::shared_ptr Game::getCurrentScene() { - return currentScene; -} - -void Game::setCurrentScene(std::shared_ptr scene) { - currentScene = scene; +Game::Game() { } void Game::init() { - renderManager.init(*this); - - this->shader = std::make_shared(); - this->shader->init(); - this->shader->bind(); - - this->mesh = std::make_shared(); - this->mesh->createBuffers(QUAD_VERTICE_COUNT, QUAD_INDICE_COUNT); - QuadMesh::buffer(this->mesh, glm::vec4(-0.5f, -0.5f, 0.5f, 0.5f), glm::vec4(0.0f, 0.0f, 0.0f, 0.0f), 0, 0); + } void Game::update() { - renderManager.update(*this); - glm::mat4 view = glm::lookAt( - glm::vec3(3, 3, 3), - glm::vec3(0, 0, 0), - glm::vec3(0, 1, 0) - ); - - glm::mat4 proj = glm::perspective( - glm::radians(45.0f), - 800.0f / 600.0f, - 0.1f, - 100.0f - ); - - glm::mat4 model = glm::mat4(1.0f); - - this->shader->bind(); - this->shader->setData(SimpleTexturedShaderData { - .projection = proj, - .view = view, - .model = model, - .color = COLOR_WHITE, - .hasTexture = false, - .texture = 0 - }); - this->shader->upload(); - this->mesh->draw(MeshDrawMode::TRIANGLES, 0, QUAD_INDICE_COUNT); } Game::~Game() { - shader = nullptr; - mesh = nullptr; } \ No newline at end of file diff --git a/src/dawn/game/Game.hpp b/src/dawn/game/Game.hpp index 395613ea..e96357cc 100644 --- a/src/dawn/game/Game.hpp +++ b/src/dawn/game/Game.hpp @@ -5,23 +5,14 @@ #pragma once #include "dawn.hpp" -#include "display/RenderManager.hpp" - -#include "display/mesh/QuadMesh.hpp" -#include "display/shader/SimpleTexturedShader.hpp" +#include "world/Map.hpp" namespace Dawn { - class Scene; - class Game { private: - std::shared_ptr currentScene; - std::shared_ptr mesh; - std::shared_ptr shader; + std::shared_ptr map; public: - RenderManager renderManager; - /** * Constructs a new instance of Game, the class majorily responsible for * handling all internal dawn functions outside of platform-centric things @@ -29,20 +20,6 @@ namespace Dawn { */ Game(); - /** - * Gets the current scene. - * - * @return The current scene. - */ - std::shared_ptr getCurrentScene(); - - /** - * Sets the current scene to the provided scene. - * - * @param scene The scene to set as the current scene. - */ - void setCurrentScene(std::shared_ptr scene); - /** * Initializes the game and all sub managers used by game. */ diff --git a/src/dawnrpg/scene/RPGScene.hpp b/src/dawn/world/Map.hpp similarity index 53% rename from src/dawnrpg/scene/RPGScene.hpp rename to src/dawn/world/Map.hpp index 05e09c08..3eccd413 100644 --- a/src/dawnrpg/scene/RPGScene.hpp +++ b/src/dawn/world/Map.hpp @@ -4,10 +4,19 @@ // https://opensource.org/licenses/MIT #pragma once -#include "scene/Scene.hpp" +#include "dawn.hpp" namespace Dawn { - class RPGScene : public Scene { + class Map { public: + /** + * Creates Map object. + */ + Map(); + + /** + * Destroys Map object. + */ + ~Map(); }; } \ No newline at end of file diff --git a/src/dawnglfw/host/DawnGLFWHost.cpp b/src/dawnglfw/host/DawnGLFWHost.cpp index d9696d72..1b04de4f 100644 --- a/src/dawnglfw/host/DawnGLFWHost.cpp +++ b/src/dawnglfw/host/DawnGLFWHost.cpp @@ -95,7 +95,8 @@ DawnGLFWInitResult DawnGLFWHost::init( this->game = std::make_shared(); this->game->init(); - auto backBuffer = this->game->renderManager.getBackBufferRenderTarget(); + // Backbuffer + backBuffer = std::make_shared(); backBuffer->setSize((float_t)fbWidth, (float_t)fbHeight); // Set up callbacks @@ -108,8 +109,7 @@ DawnGLFWInitResult DawnGLFWHost::init( if(host == nullptr) return; host->windowWidth = width; host->windowHeight = height; - auto backBuffer = host->game->renderManager.getBackBufferRenderTarget(); - backBuffer->setSize((float_t)width, (float_t)height); + host->backBuffer->setSize((float_t)width, (float_t)height); }); return DawnGLFWInitResult::SUCCESS; @@ -140,6 +140,7 @@ void DawnGLFWHost::start() { } DawnGLFWHost::~DawnGLFWHost() { + this->backBuffer = nullptr; this->game = nullptr; // Terminate GLFW diff --git a/src/dawnglfw/host/DawnGLFWHost.hpp b/src/dawnglfw/host/DawnGLFWHost.hpp index 50d2ac27..19b8cfdb 100644 --- a/src/dawnglfw/host/DawnGLFWHost.hpp +++ b/src/dawnglfw/host/DawnGLFWHost.hpp @@ -8,6 +8,7 @@ #include "dawn.hpp" #include #include "game/Game.hpp" +#include "display/BackBuffer.hpp" #define DAWN_GLFW_WIDTH_DEFAULT 800 #define DAWN_GLFW_HEIGHT_DEFAULT 600 @@ -26,6 +27,7 @@ namespace Dawn { GLFWwindow *window; int32_t windowWidth, windowHeight; std::shared_ptr game; + std::shared_ptr backBuffer; public: /** @@ -38,6 +40,7 @@ namespace Dawn { * * @param argc The number of arguments. * @param argv The arguments. + * @return The result of the initialization. */ DawnGLFWInitResult init(const int32_t argc, const char_t **argv); diff --git a/src/dawnlinux/main.cpp b/src/dawnlinux/main.cpp index b30af03b..bbdfbb20 100644 --- a/src/dawnlinux/main.cpp +++ b/src/dawnlinux/main.cpp @@ -12,8 +12,15 @@ using namespace Dawn; int32_t main(const int32_t argc, const char_t **argv) { std::shared_ptr host = std::make_shared(); - host->init(argc, argv); + + auto result = host->init(argc, argv); + if(result != DawnGLFWInitResult::SUCCESS) { + return (int32_t)result; + } + host->start(); + host = nullptr; + return 0; } \ No newline at end of file diff --git a/src/dawnopengl/CMakeLists.txt b/src/dawnopengl/CMakeLists.txt index f90ad507..f3f22134 100644 --- a/src/dawnopengl/CMakeLists.txt +++ b/src/dawnopengl/CMakeLists.txt @@ -3,6 +3,20 @@ # This software is released under the MIT License. # https://opensource.org/licenses/MIT +# Setup options +if(NOT DEFINED DAWN_OPENGL_SHADERS) + set(DAWN_OPENGL_SHADERS TRUE CACHE INTERNAL "${DAWN_CACHE_TARGET}") +endif() + +if(NOT DEFINED DAWN_OPENGL_FRAMEBUFFERS) + set(DAWN_OPENGL_FRAMEBUFFERS TRUE CACHE INTERNAL "${DAWN_CACHE_TARGET}") +endif() + +if(NOT DEFINED DAWN_OPENGL_MIPMAPS) + set(DAWN_OPENGL_MIPMAPS TRUE CACHE INTERNAL "${DAWN_CACHE_TARGET}") +endif() + + # Includes target_include_directories(${DAWN_TARGET_NAME} PUBLIC diff --git a/src/dawnopengl/display/BackBuffer.cpp b/src/dawnopengl/display/BackBuffer.cpp index f5bb5cb6..5cfc7ec7 100644 --- a/src/dawnopengl/display/BackBuffer.cpp +++ b/src/dawnopengl/display/BackBuffer.cpp @@ -61,8 +61,10 @@ void BackBuffer::clear(const int32_t clearFlags) { } void BackBuffer::bind() { - glBindFramebuffer(GL_FRAMEBUFFER, 0); - assertNoGLError(); + #if DAWN_OPENGL_FRAMEBUFFERS + glBindFramebuffer(GL_FRAMEBUFFER, 0); + assertNoGLError(); + #endif glViewport(0, 0, (GLsizei)this->width, (GLsizei)this->height); assertNoGLError(); } \ No newline at end of file diff --git a/src/dawnopengl/display/CMakeLists.txt b/src/dawnopengl/display/CMakeLists.txt index 5d3e1368..4588a38b 100644 --- a/src/dawnopengl/display/CMakeLists.txt +++ b/src/dawnopengl/display/CMakeLists.txt @@ -6,11 +6,15 @@ # Sources target_sources(${DAWN_TARGET_NAME} PRIVATE + Color.cpp BackBuffer.cpp Texture.cpp RenderManager.cpp ) # Subdirs -add_subdirectory(mesh) -add_subdirectory(shader) \ No newline at end of file +# add_subdirectory(mesh) +if(DAWN_OPENGL_SHADERS EQUAL TRUE) + message(FATAL_ERROR "DAWN_OPENGL_SHADERS: ${DAWN_OPENGL_SHADERS}") + add_subdirectory(shader) +endif() \ No newline at end of file diff --git a/src/dawn/display/Color.cpp b/src/dawnopengl/display/Color.cpp similarity index 100% rename from src/dawn/display/Color.cpp rename to src/dawnopengl/display/Color.cpp diff --git a/src/dawn/display/Color.hpp b/src/dawnopengl/display/Color.hpp similarity index 100% rename from src/dawn/display/Color.hpp rename to src/dawnopengl/display/Color.hpp diff --git a/src/dawnopengl/display/RenderManager.cpp b/src/dawnopengl/display/RenderManager.cpp index 9bb4f834..e437f4af 100644 --- a/src/dawnopengl/display/RenderManager.cpp +++ b/src/dawnopengl/display/RenderManager.cpp @@ -8,9 +8,7 @@ using namespace Dawn; -RenderManager::RenderManager() : - shaderManager() -{ +RenderManager::RenderManager() { } void RenderManager::init(const Game &game) { diff --git a/src/dawnopengl/display/RenderManager.hpp b/src/dawnopengl/display/RenderManager.hpp index c5b1847c..7f03217c 100644 --- a/src/dawnopengl/display/RenderManager.hpp +++ b/src/dawnopengl/display/RenderManager.hpp @@ -6,9 +6,12 @@ #pragma once #include "dawn.hpp" #include "display/RenderTarget.hpp" -#include "display/shader/ShaderManager.hpp" #include "display/BackBuffer.hpp" +#if DAWN_OPENGL_SHADERS + #include "display/shader/ShaderManager.hpp" +#endif + namespace Dawn { class Game; @@ -17,7 +20,9 @@ namespace Dawn { std::shared_ptr backBuffer = nullptr; public: - ShaderManager shaderManager; + #if DAWN_OPENGL_SHADERS + ShaderManager shaderManager; + #endif /** * Creates a render manager. diff --git a/src/dawnopengl/display/Texture.cpp b/src/dawnopengl/display/Texture.cpp index f3f53752..7576063c 100644 --- a/src/dawnopengl/display/Texture.cpp +++ b/src/dawnopengl/display/Texture.cpp @@ -42,7 +42,7 @@ void Texture::setSize( this->id = -1; } - int32_t maxSize; + GLint maxSize; glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxSize); assertTrue(width > 0 && width <= maxSize, "Width is out of bounds!"); assertTrue(height > 0 && height <= maxSize, "Height is out of bounds!"); @@ -64,26 +64,7 @@ void Texture::setSize( void Texture::updateTextureProperties() { auto setWrapMode = [](GLenum axis, enum TextureWrapMode wm) { - switch(wm) { - case TextureWrapMode::REPEAT: - glTexParameteri(GL_TEXTURE_2D, axis, GL_REPEAT); - break; - - case TextureWrapMode::MIRRORED_REPEAT: - glTexParameteri(GL_TEXTURE_2D, axis, GL_MIRRORED_REPEAT); - break; - - case TextureWrapMode::CLAMP_TO_EDGE: - glTexParameteri(GL_TEXTURE_2D, axis, GL_CLAMP_TO_EDGE); - break; - - case TextureWrapMode::CLAMP_TO_BORDER: - glTexParameteri(GL_TEXTURE_2D, axis, GL_CLAMP_TO_BORDER); - break; - - default: - assertUnreachable("Unknown wrap mode!"); - } + glTexParameteri(GL_TEXTURE_2D, axis, (GLint)wm); assertNoGLError(); }; @@ -124,28 +105,7 @@ void Texture::updateTextureProperties() { void Texture::bufferRaw(const void *data) { assertTrue(this->id != -1, "Texture is not ready!"); - GLenum format; - switch(this->format) { - case TextureFormat::R: - format = GL_RED; - break; - - case TextureFormat::RG: - format = GL_RG; - break; - - case TextureFormat::RGB: - format = GL_RGB; - break; - - case TextureFormat::RGBA: - format = GL_RGBA; - break; - - default: - assertUnreachable("Unknown texture format!"); - } - + GLenum format = (GLenum)this->format; GLenum dataFormat; switch(this->dataFormat) { case TextureDataFormat::UNSIGNED_BYTE: @@ -168,8 +128,11 @@ void Texture::bufferRaw(const void *data) { 0, format, dataFormat, data ); assertNoGLError(); - glGenerateMipmap(GL_TEXTURE_2D); - assertNoGLError(); + + #if DAWN_OPENGL_MIPMAPS + glGenerateMipmap(GL_TEXTURE_2D); + assertNoGLError(); + #endif } void Texture::buffer(const struct ColorU8 pixels[]) { diff --git a/src/dawnopengl/display/Texture.hpp b/src/dawnopengl/display/Texture.hpp index 34d42492..67572b33 100644 --- a/src/dawnopengl/display/Texture.hpp +++ b/src/dawnopengl/display/Texture.hpp @@ -13,17 +13,21 @@ namespace Dawn { typedef GLuint textureslot_t; enum class TextureFormat { - R = 1, - RG = 2, - RGB = 3, - RGBA = 4 + R = GL_RED, + #ifdef GL_RG + RG = GL_RG, + #endif + RGB = GL_RGB, + RGBA = GL_RGBA }; enum class TextureWrapMode { - REPEAT = 0, - MIRRORED_REPEAT = 1, - CLAMP_TO_EDGE = 2, - CLAMP_TO_BORDER = 3 + REPEAT = GL_REPEAT, + MIRRORED_REPEAT = GL_MIRRORED_REPEAT, + CLAMP_TO_EDGE = GL_CLAMP_TO_EDGE, + #ifdef GL_CLAMP_TO_BORDER + CLAMP_TO_BORDER = GL_CLAMP_TO_BORDER + #endif }; enum class TextureFilterMode { diff --git a/src/dawnopengl/error/assertgl.cpp b/src/dawnopengl/error/assertgl.cpp index 128c3359..4679320e 100644 --- a/src/dawnopengl/error/assertgl.cpp +++ b/src/dawnopengl/error/assertgl.cpp @@ -40,9 +40,11 @@ void assertNotGLErrorCheck(const char *file, int32_t line) { error += "\nOUT_OF_MEMORY"; break; - case GL_INVALID_FRAMEBUFFER_OPERATION: - error += "\nINVALID_FRAMEBUFFER_OPERATION"; - break; + #ifdef GL_INVALID_FRAMEBUFFER_OPERATION + case GL_INVALID_FRAMEBUFFER_OPERATION: + error += "\nINVALID_FRAMEBUFFER_OPERATION"; + break; + #endif default: error += "\nUNKNOWN GL ERROR ERROR"; diff --git a/src/dawnopengl/error/erroropengl.cpp b/src/dawnopengl/error/erroropengl.cpp index f3bfe84d..137c66df 100644 --- a/src/dawnopengl/error/erroropengl.cpp +++ b/src/dawnopengl/error/erroropengl.cpp @@ -26,9 +26,11 @@ void errorCheckOpenGL() { buffer << "INVALID_OPERATION" << std::endl; break; - case GL_INVALID_FRAMEBUFFER_OPERATION: - buffer << "INVALID_FRAMEBUFFER_OPERATION" << std::endl; - break; + #ifdef GL_INVALID_FRAMEBUFFER_OPERATION + case GL_INVALID_FRAMEBUFFER_OPERATION: + buffer << "INVALID_FRAMEBUFFER_OPERATION" << std::endl; + break; + #endif case GL_OUT_OF_MEMORY: buffer << "OUT_OF_MEMORY" << std::endl; diff --git a/src/dawnrpg/CMakeLists.txt b/src/dawnpsp/CMakeLists.txt similarity index 52% rename from src/dawnrpg/CMakeLists.txt rename to src/dawnpsp/CMakeLists.txt index e2290236..68b290b2 100644 --- a/src/dawnrpg/CMakeLists.txt +++ b/src/dawnpsp/CMakeLists.txt @@ -1,21 +1,37 @@ -# Copyright (c) 2024 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -# Libraries - -# Includes -target_include_directories(${DAWN_TARGET_NAME} - PUBLIC - ${CMAKE_CURRENT_LIST_DIR} -) - -# Sources -target_sources(${DAWN_TARGET_NAME} - PRIVATE - -) - -# Subdirs -add_subdirectory(scene) \ No newline at end of file +# Copyright (c) 2024 Dominic Masters +# +# This software is released under the MIT License. +# https://opensource.org/licenses/MIT + +# Libraries +target_link_libraries(${DAWN_TARGET_NAME} + PUBLIC + m + c + psputility + pspdebug + pspge + pspdisplay + pspctrl + pspsdk + pspuser + psprtc + pspvfpu + GL +) + +# Includes +target_include_directories(${DAWN_TARGET_NAME} + PUBLIC + ${CMAKE_CURRENT_LIST_DIR} +) + +# Sources +target_sources(${DAWN_TARGET_NAME} + PRIVATE + main.cpp +) + +# Subdirs +add_subdirectory(error) +add_subdirectory(host) \ No newline at end of file diff --git a/src/dawnrpg/scene/CMakeLists.txt b/src/dawnpsp/error/CMakeLists.txt similarity index 87% rename from src/dawnrpg/scene/CMakeLists.txt rename to src/dawnpsp/error/CMakeLists.txt index ffee787e..770176ba 100644 --- a/src/dawnrpg/scene/CMakeLists.txt +++ b/src/dawnpsp/error/CMakeLists.txt @@ -6,5 +6,5 @@ # Sources target_sources(${DAWN_TARGET_NAME} PRIVATE - RPGScene.cpp + error.cpp ) \ No newline at end of file diff --git a/src/dawnpsp/error/error.cpp b/src/dawnpsp/error/error.cpp new file mode 100644 index 00000000..872515b0 --- /dev/null +++ b/src/dawnpsp/error/error.cpp @@ -0,0 +1,31 @@ +// Copyright (c) 2024 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#include "error/error.hpp" +#include +#include +#include +#include + +void errorMessageBox(const std::u8string &message) { + // c8string to cstring + std::string messageStr = ( + message.length() > 0 ? + std::string(message.cbegin(), message.cend()) : + std::string() + ); + + // Print Hello World! on a debug screen on a loop + pspDebugScreenInit(); + while(1) { + pspDebugScreenSetXY(0, 0); + pspDebugScreenPrintf(messageStr.c_str()); + sceDisplayWaitVblankStart(); + } +} + +void errorLog(const std::string &message) { + std::cerr << message << std::endl; +} \ No newline at end of file diff --git a/src/dawn/display/CMakeLists.txt b/src/dawnpsp/host/CMakeLists.txt similarity index 69% rename from src/dawn/display/CMakeLists.txt rename to src/dawnpsp/host/CMakeLists.txt index 36a4895e..37a82794 100644 --- a/src/dawn/display/CMakeLists.txt +++ b/src/dawnpsp/host/CMakeLists.txt @@ -1,10 +1,10 @@ -# Copyright (c) 2022 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -# Sources -target_sources(${DAWN_TARGET_NAME} - PRIVATE - Color.cpp +# Copyright (c) 2024 Dominic Masters +# +# This software is released under the MIT License. +# https://opensource.org/licenses/MIT + +# Sources +target_sources(${DAWN_TARGET_NAME} + PRIVATE + DawnPSPHost.cpp ) \ No newline at end of file diff --git a/src/dawnpsp/host/DawnPSPHost.cpp b/src/dawnpsp/host/DawnPSPHost.cpp new file mode 100644 index 00000000..573ddffb --- /dev/null +++ b/src/dawnpsp/host/DawnPSPHost.cpp @@ -0,0 +1,27 @@ +// Copyright (c) 2024 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#include "DawnPSPHost.hpp" +#include "error/error.hpp" + +using namespace Dawn; + +DawnPSPHost::DawnPSPHost() { + +} + +DawnPSPHostResult DawnPSPHost::init() { + return DawnPSPHostResult::SUCCESS; +} + +void DawnPSPHost::start() { + while(this->shouldGameRun) { + // Do stuff + } +} + +DawnPSPHost::~DawnPSPHost() { + +} \ No newline at end of file diff --git a/src/dawnpsp/host/DawnPSPHost.hpp b/src/dawnpsp/host/DawnPSPHost.hpp new file mode 100644 index 00000000..e830e8a7 --- /dev/null +++ b/src/dawnpsp/host/DawnPSPHost.hpp @@ -0,0 +1,43 @@ +// Copyright (c) 2024 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#pragma once +#include "game/Game.hpp" + +namespace Dawn { + enum class DawnPSPHostResult { + SUCCESS = 0, + }; + + class DawnPSPHost { + private: + std::shared_ptr game; + + public: + bool_t shouldGameRun = true; + + /** + * Creates a new PSP Host. + */ + DawnPSPHost(); + + /** + * Initializes the PSP Host. + * + * @return The result of the initialization. + */ + DawnPSPHostResult init(); + + /** + * Starts the PSP Host, called after the PSP Host has been initialized. + */ + void start(); + + /** + * Destroys the PSP Host. + */ + ~DawnPSPHost(); + }; +} \ No newline at end of file diff --git a/src/dawnpsp/main.cpp b/src/dawnpsp/main.cpp new file mode 100644 index 00000000..ce49c9e9 --- /dev/null +++ b/src/dawnpsp/main.cpp @@ -0,0 +1,52 @@ +// Copyright (c) 2024 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#include "main.hpp" +#include "host/DawnPSPHost.hpp" + +using namespace Dawn; + +std::shared_ptr host; + +int callbackOnExit(int arg1, int arg2, void *common) { + sceKernelExitGame(); + host->shouldGameRun = false; + host = nullptr; + return 0; +} + +int callbackThread(SceSize args, void *argp) { + int cbid = sceKernelCreateCallback("Exit Callback", callbackOnExit, NULL); + sceKernelRegisterExitCallback(cbid); + sceKernelSleepThreadCB(); + return 0; +} + +int main(void) { + // Setup PSP Callbacks + int thid = sceKernelCreateThread( + "update_thread", + callbackThread, + 0x11, + 0xFA0, + 0, + 0 + ); + if(thid >= 0) sceKernelStartThread(thid, 0, 0); + + // + host = std::make_shared(); + + auto ret = host->init(); + if(ret != DawnPSPHostResult::SUCCESS) { + host = nullptr; + return (int)ret; + } + + host->start(); + host = nullptr; + + return 0; +} \ No newline at end of file diff --git a/src/dawnpsp/main.hpp b/src/dawnpsp/main.hpp new file mode 100644 index 00000000..307bda8d --- /dev/null +++ b/src/dawnpsp/main.hpp @@ -0,0 +1,21 @@ +// Copyright (c) 2024 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#pragma once +#include "dawn.hpp" +#include +#include +#include +#include + +PSP_MODULE_INFO("Controller", 0, 1, 1); +PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER); + +/** + * Main entry to the program. + * + * @return The exit code of the program. + */ +int main(void); \ No newline at end of file diff --git a/src/dawnrpg/scene/RPGScene.cpp b/src/dawnrpg/scene/RPGScene.cpp deleted file mode 100644 index 9ba8dcfb..00000000 --- a/src/dawnrpg/scene/RPGScene.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) 2024 Dominic Masters -// -// This software is released under the MIT License. -// https://opensource.org/licenses/MIT - -#include "RPGScene.hpp" - -using namespace Dawn; \ No newline at end of file diff --git a/src/dawnvita/CMakeLists.txt b/src/dawnvita/CMakeLists.txt index a2d88e3e..d758a006 100644 --- a/src/dawnvita/CMakeLists.txt +++ b/src/dawnvita/CMakeLists.txt @@ -9,24 +9,25 @@ target_link_libraries(${DAWN_TARGET_NAME} m stdc++ vitaGL - # mathneon - # vitashark + mathneon + vitashark # kubridge_stub - # SceAppMgr_stub + SceAppMgr_stub # SceAudio_stub # SceCtrl_stub - # SceCommonDialog_stub - # SceDisplay_stub - # SceKernelDmacMgr_stub - # SceGxm_stub - # SceShaccCg_stub + SceCommonDialog_stub + SceDisplay_stub + SceKernelDmacMgr_stub + SceGxm_stub + SceShaccCg_stub # SceSysmodule_stub # ScePower_stub # SceTouch_stub # SceVshBridge_stub # SceIofilemgr_stub - # SceShaccCgExt - # libtaihen_stub.a + SceShaccCgExt + # ScePvf_stub + libtaihen_stub.a ) # Includes diff --git a/src/dawnvita/duskopengl.h b/src/dawnvita/dawnopengl.hpp similarity index 100% rename from src/dawnvita/duskopengl.h rename to src/dawnvita/dawnopengl.hpp diff --git a/src/dawnvita/host/DawnVitaHost.cpp b/src/dawnvita/host/DawnVitaHost.cpp new file mode 100644 index 00000000..a29e2716 --- /dev/null +++ b/src/dawnvita/host/DawnVitaHost.cpp @@ -0,0 +1,38 @@ +// Copyright (c) 2024 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#include "DawnVitaHost.hpp" + +using namespace Dawn; + +DawnVitaHost::DawnVitaHost() { + +} + +DawnVitaInitResult DawnVitaHost::init() { + return DawnVitaInitResult::SUCCESS; +} + +void DawnVitaHost::start() { + + std::stringstream output; + std::vector hello = { "Hello" }; + hello.push_back(","); + hello.push_back(" C++ "); + hello.push_back("world!"); + for (auto &s : hello) { + // std::cout does't work ATM :( + output << s; + } + output << std::endl; + psvDebugScreenInit(); + printf("%s\n", output.str().c_str()); + sceKernelDelayThread(3*1000000); // Wait for 3 seconds + sceKernelExitProcess(0); +} + +DawnVitaHost::~DawnVitaHost() { + +} \ No newline at end of file diff --git a/src/dawnvita/host/DawnVitaHost.hpp b/src/dawnvita/host/DawnVitaHost.hpp new file mode 100644 index 00000000..66f2f109 --- /dev/null +++ b/src/dawnvita/host/DawnVitaHost.hpp @@ -0,0 +1,42 @@ +// Copyright (c) 2024 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#pragma once +#include "dawnopengl.hpp" +#include "dawn.hpp" + +namespace Dawn { + enum class DawnVitaInitResult { + SUCCESS = 0, + FAILURE = 1 + }; + + class DawnVitaHost { + private: + + public: + /** + * Creates a new Vita Host. + */ + DawnVitaHost(); + + /** + * Initializes the Vita Host. + * + * @return The result of the initialization. + */ + DawnVitaInitResult init(); + + /** + * Starts the Vita Host, called after the Vita Host has been initialized. + */ + void start(); + + /** + * Destroys the Vita Host. + */ + ~DawnVitaHost(); + }; +} \ No newline at end of file diff --git a/src/dawnvita/main.cpp b/src/dawnvita/main.cpp index c26bc358..befba30c 100644 --- a/src/dawnvita/main.cpp +++ b/src/dawnvita/main.cpp @@ -4,9 +4,21 @@ // https://opensource.org/licenses/MIT #include "main.hpp" +#include "host/DawnVitaHost.hpp" using namespace Dawn; +GLfloat alpha_ref = 0.0f; + +int32_t main(void) { + std::shared_ptr host = std::make_shared(); + + auto result = host->init(); + if(result != DawnVitaInitResult::SUCCESS) { + return (int32_t)result; + } + + host->start(); + host = nullptr; -int32_t main(const int32_t argc, const char_t **argv) { return 0; } \ No newline at end of file diff --git a/tools/assetstool/assetstool.py b/tools/assetstool/assetstool.py index 6519617c..69d50f8f 100755 --- a/tools/assetstool/assetstool.py +++ b/tools/assetstool/assetstool.py @@ -55,7 +55,7 @@ for foldername, subfolders, filenames in os.walk(args.input): continue # No, add it - print(f"Archiving asset {filename}...") + # print(f"Archiving asset {filename}...") archive.add(absolute_path, arcname=relative_path) # Close the archive