diff --git a/Language/CMakeLists.txt b/.wip/Language/CMakeLists.txt similarity index 100% rename from Language/CMakeLists.txt rename to .wip/Language/CMakeLists.txt diff --git a/Language/private/Grammar.cpp b/.wip/Language/private/Grammar.cpp similarity index 100% rename from Language/private/Grammar.cpp rename to .wip/Language/private/Grammar.cpp diff --git a/Language/private/LanguageCommon.cpp b/.wip/Language/private/LanguageCommon.cpp similarity index 100% rename from Language/private/LanguageCommon.cpp rename to .wip/Language/private/LanguageCommon.cpp diff --git a/Language/public/Automata.hpp b/.wip/Language/public/Automata.hpp similarity index 100% rename from Language/public/Automata.hpp rename to .wip/Language/public/Automata.hpp diff --git a/Language/public/ContextFreeAutomata.hpp b/.wip/Language/public/ContextFreeAutomata.hpp similarity index 100% rename from Language/public/ContextFreeAutomata.hpp rename to .wip/Language/public/ContextFreeAutomata.hpp diff --git a/Language/public/ContextFreeCompiler.hpp b/.wip/Language/public/ContextFreeCompiler.hpp similarity index 100% rename from Language/public/ContextFreeCompiler.hpp rename to .wip/Language/public/ContextFreeCompiler.hpp diff --git a/Language/public/Grammar.hpp b/.wip/Language/public/Grammar.hpp similarity index 100% rename from Language/public/Grammar.hpp rename to .wip/Language/public/Grammar.hpp diff --git a/Language/public/LanguageCommon.hpp b/.wip/Language/public/LanguageCommon.hpp similarity index 100% rename from Language/public/LanguageCommon.hpp rename to .wip/Language/public/LanguageCommon.hpp diff --git a/Language/public/Parser.hpp b/.wip/Language/public/Parser.hpp similarity index 100% rename from Language/public/Parser.hpp rename to .wip/Language/public/Parser.hpp diff --git a/Language/public/RegularAutomata.hpp b/.wip/Language/public/RegularAutomata.hpp similarity index 100% rename from Language/public/RegularAutomata.hpp rename to .wip/Language/public/RegularAutomata.hpp diff --git a/Language/public/RegularCompiler.hpp b/.wip/Language/public/RegularCompiler.hpp similarity index 100% rename from Language/public/RegularCompiler.hpp rename to .wip/Language/public/RegularCompiler.hpp diff --git a/Language/public/SimpleParser.hpp b/.wip/Language/public/SimpleParser.hpp similarity index 100% rename from Language/public/SimpleParser.hpp rename to .wip/Language/public/SimpleParser.hpp diff --git a/Language/tests/Test.hpp b/.wip/Language/tests/Test.hpp similarity index 100% rename from Language/tests/Test.hpp rename to .wip/Language/tests/Test.hpp diff --git a/Language/tests/Tests.cpp b/.wip/Language/tests/Tests.cpp similarity index 100% rename from Language/tests/Tests.cpp rename to .wip/Language/tests/Tests.cpp diff --git a/Allocators/private/HeapAllocatorGlobal.cpp b/Allocators/private/HeapAllocatorGlobal.cpp index 98b1c53..c46df45 100644 --- a/Allocators/private/HeapAllocatorGlobal.cpp +++ b/Allocators/private/HeapAllocatorGlobal.cpp @@ -32,6 +32,7 @@ tp::MemHead* tp::HeapAllocGlobal::mEntry = nullptr; tp::ualni tp::HeapAllocGlobal::mNumAllocations = 0; std::mutex tp::HeapAllocGlobal::mMutex; bool tp::HeapAllocGlobal::mIgnore = true; +bool tp::HeapAllocGlobal::mEnableCallstack = false; #ifdef MEM_STACK_TRACE tp::CallStackCapture tp::HeapAllocGlobal::mCallstack; @@ -109,7 +110,7 @@ ALLOCATE: // 3) Trace the stack #ifdef MEM_STACK_TRACE // check if somewhat decides to call new within static variable initialization - head->mCallStack = mCallstack.getSnapshot(); + head->mCallStack = (mEnableCallstack && mCallstack.initialized) ? mCallstack.getSnapshot() : nullptr; #endif mMutex.unlock(); @@ -144,20 +145,19 @@ void HeapAllocGlobal::deallocate(void* aPtr) { if (head == mEntry) { mEntry = head->mPrev; } - mMutex.unlock(); - + if (!head->mIgnored) { // 3) Check the wrap if (memCompareVal(wrap_top, WRAP_SIZE, WRAP_VAL)) { #ifdef MEM_STACK_TRACE - mCallstack.printSnapshot(head->mCallStack); + if (head->mCallStack) mCallstack.printSnapshot(head->mCallStack); #endif ASSERT(!"Allocated Block Wrap Corrupted!") } if (memCompareVal(wrap_bottom, WRAP_SIZE, WRAP_VAL)) { #ifdef MEM_STACK_TRACE - mCallstack.printSnapshot(head->mCallStack); + if (head->mCallStack) mCallstack.printSnapshot(head->mCallStack); #endif ASSERT(!"Allocated Block Wrap Corrupted!") } @@ -168,6 +168,8 @@ void HeapAllocGlobal::deallocate(void* aPtr) { #endif } + mMutex.unlock(); + // 5) free the block free(head); } @@ -183,7 +185,7 @@ bool HeapAllocGlobal::checkLeaks() { #ifdef MEM_STACK_TRACE for (auto iter = mEntry; iter; iter = iter->mPrev) { - if (!iter->mIgnored) mCallstack.printSnapshot(iter->mCallStack); + if (!iter->mIgnored && iter->mCallStack) mCallstack.printSnapshot(iter->mCallStack); } #endif @@ -211,6 +213,18 @@ ualni HeapAllocGlobal::getNAllocations() { return mNumAllocations; } +void HeapAllocGlobal::enableCallstack() { + mMutex.lock(); + mEnableCallstack = true; + mMutex.unlock(); +} + +void HeapAllocGlobal::disableCallstack() { + mMutex.lock(); + mEnableCallstack = false; + mMutex.unlock(); +} + HeapAllocGlobal::~HeapAllocGlobal() = default; #endif diff --git a/Allocators/public/HeapAllocatorGlobal.hpp b/Allocators/public/HeapAllocatorGlobal.hpp index fa4d43c..8c8b892 100644 --- a/Allocators/public/HeapAllocatorGlobal.hpp +++ b/Allocators/public/HeapAllocatorGlobal.hpp @@ -12,6 +12,7 @@ namespace tp { static struct MemHead* mEntry; static std::mutex mMutex; static bool mIgnore; + static bool mEnableCallstack; #ifdef MEM_STACK_TRACE // Save stack on allocation call static CallStackCapture mCallstack; #endif @@ -29,7 +30,10 @@ namespace tp { static void startIgnore(); static void stopIgnore(); static ualni getNAllocations(); - + + static void enableCallstack(); + static void disableCallstack(); + public: [[nodiscard]] bool checkWrap() const { return false; } void checkValid() {} diff --git a/CMakeLists.txt b/CMakeLists.txt index 7cfe586..989e7e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,9 +15,9 @@ add_subdirectory(Modules) add_subdirectory(Callstack) add_subdirectory(Containers) add_subdirectory(Math) -add_subdirectory(Allocators) add_subdirectory(Strings) -add_subdirectory(Language) +add_subdirectory(Allocators) +# add_subdirectory(Language) add_subdirectory(Externals) add_subdirectory(Connection) add_subdirectory(Graphics) diff --git a/Callstack/private/Callstack.cpp b/Callstack/private/Callstack.cpp index 93df3cd..eb1f68c 100644 --- a/Callstack/private/Callstack.cpp +++ b/Callstack/private/Callstack.cpp @@ -59,6 +59,8 @@ CallStackCapture::CallStackCapture() { platformInit(); + + initialized = true; } const CallStackCapture::CallStack* CallStackCapture::getSnapshot() { @@ -101,7 +103,10 @@ void CallStackCapture::clear() { mSymbols.removeAll(); } -CallStackCapture::~CallStackCapture() { free(mBuff); } +CallStackCapture::~CallStackCapture() { + free(mBuff); + initialized = false; +} // ---------------------------------- Platform Depended ---------------------------------- // diff --git a/Callstack/public/Callstack.hpp b/Callstack/public/Callstack.hpp index fd0406d..aac0e3c 100644 --- a/Callstack/public/Callstack.hpp +++ b/Callstack/public/Callstack.hpp @@ -9,6 +9,8 @@ namespace tp { public: typedef tp::alni FramePointer; + bool initialized = false; + enum { MAX_CALL_DEPTH_CAPTURE = 16, MAX_CALL_CAPTURES_MEM_SIZE_MB = 32, diff --git a/Connection/CMakeLists.txt b/Connection/CMakeLists.txt index ed81180..a4487b7 100644 --- a/Connection/CMakeLists.txt +++ b/Connection/CMakeLists.txt @@ -8,11 +8,11 @@ file(GLOB HEADERS "./public/*.hpp") add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS}) target_include_directories(${PROJECT_NAME} PUBLIC ./public/) target_include_directories(${PROJECT_NAME} PRIVATE ${BINDINGS_INCLUDE}) -target_link_libraries(${PROJECT_NAME} PUBLIC Strings) +target_link_libraries(${PROJECT_NAME} PUBLIC Modules) ### -------------------------- Tests -------------------------- ### enable_testing() file(GLOB TEST_SOURCES "./tests/*.cpp") -add_executable(${PROJECT_NAME}Tests ${TEST_SOURCES}) -target_link_libraries(${PROJECT_NAME}Tests ${PROJECT_NAME} UnitTest++) -add_test(NAME ${PROJECT_NAME}Tests COMMAND ${PROJECT_NAME}Tests) \ No newline at end of file +add_executable(Test${PROJECT_NAME} ${TEST_SOURCES}) +target_link_libraries(Test${PROJECT_NAME} ${PROJECT_NAME} UnitTest++) +add_test(NAME Test${PROJECT_NAME} COMMAND Test${PROJECT_NAME}) \ No newline at end of file diff --git a/Connection/private/ConnectionCommon.cpp b/Connection/private/ConnectionCommon.cpp deleted file mode 100644 index d9a05fe..0000000 --- a/Connection/private/ConnectionCommon.cpp +++ /dev/null @@ -1,6 +0,0 @@ - -#include "ConnectionCommon.hpp" - -static tp::ModuleManifest* sModuleDependencies[] = { &tp::gModuleStrings, nullptr }; - -tp::ModuleManifest tp::gModuleConnection = ModuleManifest("Storage", nullptr, nullptr, sModuleDependencies); \ No newline at end of file diff --git a/Connection/private/LocalConnection.cpp b/Connection/private/LocalConnection.cpp index 7689181..efe7648 100644 --- a/Connection/private/LocalConnection.cpp +++ b/Connection/private/LocalConnection.cpp @@ -7,7 +7,8 @@ using namespace tp; bool LocalConnection::Location::exists() const { - FILE* file = fopen(mLocation.read(), "r"); + // TODO : fixme + FILE* file = fopen(mLocation.c_str(), "r"); if (file) { // File exists, close it and return 1 fclose(file); @@ -23,10 +24,8 @@ bool LocalConnection::connect(const Location& location, const Type& connectionIn auto handle = new LocalConnectionContext(); switch (connectionInfo.getType()) { - case Type::READ: handle->open(location.getLocation().read(), true); break; - - case Type::WRITE: handle->open(location.getLocation().read(), false); break; - + case Type::READ: handle->open(location.getLocation().c_str(), true); break; + case Type::WRITE: handle->open(location.getLocation().c_str(), false); break; default: break; }; diff --git a/Connection/public/ConnectionCommon.hpp b/Connection/public/ConnectionCommon.hpp index 9d8f1f4..5014f4a 100644 --- a/Connection/public/ConnectionCommon.hpp +++ b/Connection/public/ConnectionCommon.hpp @@ -1,10 +1,9 @@ #pragma once -#include "Strings.hpp" +#include "Module.hpp" +#include namespace tp { - extern ModuleManifest gModuleConnection; - class Connection { public: typedef ualni SizeBytes; diff --git a/Connection/public/LocalConnection.hpp b/Connection/public/LocalConnection.hpp index 2e6dbbf..bdde90b 100644 --- a/Connection/public/LocalConnection.hpp +++ b/Connection/public/LocalConnection.hpp @@ -9,20 +9,20 @@ namespace tp { class LocalConnection : public Connection { public: class Location { - String mLocation; + std::string mLocation; public: Location() : mLocation("tmp"){}; - explicit Location(const String& location) : + explicit Location(const std::string& location) : mLocation(location) {} - void setLocation(const String& location) { mLocation = location; } - [[nodiscard]] const String& getLocation() const { return mLocation; } + void setLocation(const std::string& location) { mLocation = location; } + [[nodiscard]] const std::string& getLocation() const { return mLocation; } [[nodiscard]] bool exists() const; }; public: - LocalConnection(){ MODULE_SANITY_CHECK(gModuleConnection) }; + LocalConnection() = default; virtual ~LocalConnection() { if (mStatus.isOpened()) LocalConnection::disconnect(); diff --git a/Connection/public/Network.hpp b/Connection/public/Network.hpp index 604e0b2..215de31 100644 --- a/Connection/public/Network.hpp +++ b/Connection/public/Network.hpp @@ -1,6 +1,6 @@ #pragma once -#include "Common.hpp" +#include "Module.hpp" namespace tp { class ServerContext; diff --git a/Connection/public/RemoteConnection.hpp b/Connection/public/RemoteConnection.hpp index 13c3f5e..4bb7ed2 100644 --- a/Connection/public/RemoteConnection.hpp +++ b/Connection/public/RemoteConnection.hpp @@ -1,7 +1,6 @@ #pragma once #include "ConnectionCommon.hpp" -#include "List.hpp" namespace tp { @@ -17,7 +16,7 @@ namespace tp { }; public: - RemoteConnection(){ MODULE_SANITY_CHECK(gModuleConnection) }; + RemoteConnection() = default; virtual ~RemoteConnection() { if (mStatus.isOpened()) RemoteConnection::disconnect(); diff --git a/Connection/tests/Test.cpp b/Connection/tests/Test.cpp index 92542be..5c180af 100644 --- a/Connection/tests/Test.cpp +++ b/Connection/tests/Test.cpp @@ -14,14 +14,14 @@ SUITE(Connection) { { LocalConnection file; - file.connect(LocalConnection::Location(String("tmp2.txt")), LocalConnection::Type(false)); + file.connect(LocalConnection::Location(std::string("tmp2.txt")), LocalConnection::Type(false)); file.writeBytes(data, 6); file.disconnect(); } { LocalConnection file; - file.connect(LocalConnection::Location(String("tmp2.txt")), LocalConnection::Type(true)); + file.connect(LocalConnection::Location(std::string("tmp2.txt")), LocalConnection::Type(true)); file.readBytes(dataRead, 6); file.disconnect(); } @@ -35,17 +35,5 @@ SUITE(Connection) { } int main() { - - tp::ModuleManifest* deps[] = { &tp::gModuleConnection, nullptr }; - tp::ModuleManifest testModule("ConnectionTest", nullptr, nullptr, deps); - - if (!testModule.initialize()) { - return 1; - } - - bool res = UnitTest::RunAllTests(); - - testModule.deinitialize(); - - return res; + return UnitTest::RunAllTests(); } \ No newline at end of file diff --git a/Containers/public/Buffer2D.hpp b/Containers/public/Buffer2D.hpp index cb34689..e3d8e23 100644 --- a/Containers/public/Buffer2D.hpp +++ b/Containers/public/Buffer2D.hpp @@ -8,16 +8,17 @@ namespace tp { template using ConstSizeBuffer2D = ConstSizeBuffer, tSizeY>; + + typedef ualni Index; + + struct Index2D { + Index x = 0; + Index y = 0; + }; template class Buffer2D { public: - typedef ualni Index; - - struct Index2D { - Index x = 0; - Index y = 0; - }; typedef SelectValueOrReference tTypeArg; diff --git a/DataAnalysis/CMakeLists.txt b/DataAnalysis/CMakeLists.txt index dcfff1e..1463460 100644 --- a/DataAnalysis/CMakeLists.txt +++ b/DataAnalysis/CMakeLists.txt @@ -22,11 +22,8 @@ add_executable(NumRecApp applications/NumRecApp.cpp) target_link_libraries(NumRecApp ${PROJECT_NAME} Connection ImageIO) ### -------------------------- Tests -------------------------- ### -enable_testing() file(GLOB TEST_SOURCES "./tests/*.cpp" "./tests/*/*.cpp") -add_executable(${PROJECT_NAME}Tests ${TEST_SOURCES}) - -target_include_directories(${PROJECT_NAME}Tests PUBLIC ./applications/) - -target_link_libraries(${PROJECT_NAME}Tests ${PROJECT_NAME} UnitTest++) -add_test(NAME ${PROJECT_NAME}Tests COMMAND ${PROJECT_NAME}Tests) +add_executable(Test${PROJECT_NAME} ${TEST_SOURCES}) +target_include_directories(Test${PROJECT_NAME} PUBLIC ./applications/) +target_link_libraries(Test${PROJECT_NAME} ${PROJECT_NAME} UnitTest++) +add_test(NAME Test${PROJECT_NAME} COMMAND Test${PROJECT_NAME}) diff --git a/DataAnalysis/applications/NumRecApp.cpp b/DataAnalysis/applications/NumRecApp.cpp index 081c622..421612a 100644 --- a/DataAnalysis/applications/NumRecApp.cpp +++ b/DataAnalysis/applications/NumRecApp.cpp @@ -62,16 +62,7 @@ int main(int argc, char** argv) { imageName = argv[1]; } - ModuleManifest* deps[] = { &gModuleDataAnalysis, &gModuleConnection, nullptr }; - ModuleManifest module = ModuleManifest("NumRec", nullptr, nullptr, deps); - - if (!module.initialize()) { - return 1; - } - executeCmd(imageName); - module.deinitialize(); - return 0; } \ No newline at end of file diff --git a/DataAnalysis/applications/NumRecTraining.cpp b/DataAnalysis/applications/NumRecTraining.cpp index f7e3050..69cd71c 100644 --- a/DataAnalysis/applications/NumRecTraining.cpp +++ b/DataAnalysis/applications/NumRecTraining.cpp @@ -24,12 +24,12 @@ void writeImage(const Buffer& image, const char* name) { struct Dataset { ualni length = 0; - Pair imageSize = { 0, 0 }; + std::pair imageSize = { 0, 0 }; Buffer labels; Buffer> images; }; -bool loadDataset(Dataset& out, const String& location) { +bool loadDataset(Dataset& out, const std::string& location) { LocalConnection dataset; dataset.connect(LocalConnection::Location(location), LocalConnection::Type(true)); @@ -207,51 +207,38 @@ public: }; int main() { - ModuleManifest* deps[] = { &gModuleDataAnalysis, &gModuleConnection, nullptr }; - ModuleManifest module = ModuleManifest("NumRec", nullptr, nullptr, deps); + NumberRec app; - if (!module.initialize()) { - return 1; - } + auto numBatches = 10; + auto trainRange = Range(0, 50000); + auto testRange = Range(50000, 70000); - { - NumberRec app; + auto batchSize = trainRange.idxDiff() / numBatches; - auto numBatches = 10; - auto trainRange = Range(0, 50000); - auto testRange = Range(50000, 70000); + for (auto epoch : Range(1)) { + printf("Epoch %i\n", epoch.index()); - auto batchSize = trainRange.idxDiff() / numBatches; + for (auto batchIdx : Range(trainRange.idxDiff() / batchSize)) { + printf(" - Batch :%i \n", batchIdx.index()); - for (auto epoch : Range(1)) { - printf("Epoch %i\n", epoch.index()); + auto batchRange = Range(trainRange.idxBegin() + batchSize * batchIdx, trainRange.idxBegin() + batchSize * (batchIdx + 1)); - for (auto batchIdx : Range(trainRange.idxDiff() / batchSize)) { - printf(" - Batch :%i \n", batchIdx.index()); + app.trainStep(batchRange); - auto batchRange = Range(trainRange.idxBegin() + batchSize * batchIdx, trainRange.idxBegin() + batchSize * (batchIdx + 1)); - - app.trainStep(batchRange); - - printf("Cost on batch data : %f\n", app.test(batchRange)); - } - - printf("Cost on test data : %f\n\n", app.test(testRange)); + printf("Cost on batch data : %f\n", app.test(batchRange)); } - auto errors = 0; - for (auto i : testRange) { - if (app.testIncorrect(i)) { - errors++; - } - // app.debLog(i); - // app.displayImage(i); - } - - printf("\n\nIncorrect - %i out of %i (%f)\n\n", errors, testRange.idxDiff(), (halnf) errors / (halnf) testRange.idxDiff()); + printf("Cost on test data : %f\n\n", app.test(testRange)); } - module.deinitialize(); + auto errors = 0; + for (auto i : testRange) { + if (app.testIncorrect(i)) { + errors++; + } + // app.debLog(i); + // app.displayImage(i); + } - return 0; + printf("\n\nIncorrect - %i out of %i (%f)\n\n", errors, testRange.idxDiff(), (halnf) errors / (halnf) testRange.idxDiff()); } \ No newline at end of file diff --git a/DataAnalysis/private/DataAnalysisCommon.cpp b/DataAnalysis/private/DataAnalysisCommon.cpp index d128c83..1085e20 100644 --- a/DataAnalysis/private/DataAnalysisCommon.cpp +++ b/DataAnalysis/private/DataAnalysisCommon.cpp @@ -4,6 +4,6 @@ #include "MathCommon.hpp" namespace tp { - static ModuleManifest* deps[] = { &gModuleMath, &gModuleContainers, &gModuleAllocators, nullptr }; + static ModuleManifest* deps[] = { &gModuleAllocators, nullptr }; ModuleManifest gModuleDataAnalysis = ModuleManifest("DataAnalysis", nullptr, nullptr, deps); } diff --git a/DataAnalysis/tests/Tests.cpp b/DataAnalysis/tests/Tests.cpp index 739bca3..95eeec1 100644 --- a/DataAnalysis/tests/Tests.cpp +++ b/DataAnalysis/tests/Tests.cpp @@ -24,22 +24,27 @@ SUITE(FCNN) { } FCNN nn(layers); - halnf steppingValue = 100; + halnf steppingValue = 0.01; - for (auto i : Range(50)) { + halnf cost = 0; + + for (auto i : Range(150)) { nn.evaluate(input, output); nn.calcGrad(outputExpected); nn.applyGrad(steppingValue); + cost = nn.calcCost(outputExpected); printf("Loss %f \n", nn.calcCost(outputExpected)); } + + CHECK(cost < 0.1f); } } int main() { - tp::ModuleManifest* deps[] = { &tp::gModuleDataAnalysis, &tp::gModuleUtils, nullptr }; + tp::ModuleManifest* deps[] = { &tp::gModuleDataAnalysis, nullptr }; tp::ModuleManifest testModule("DataAnalysisTest", nullptr, nullptr, deps); if (!testModule.initialize()) { diff --git a/Externals/CMakeLists.txt b/Externals/CMakeLists.txt index a1a21d8..01dd9da 100644 --- a/Externals/CMakeLists.txt +++ b/Externals/CMakeLists.txt @@ -32,7 +32,6 @@ endif() #add_subdirectory(unittest-cpp) add_subdirectory(lalr) - add_subdirectory(glfw) project(Imgui) diff --git a/Externals/asio b/Externals/asio index 3a7078a..ed5db1b 160000 --- a/Externals/asio +++ b/Externals/asio @@ -1 +1 @@ -Subproject commit 3a7078a2002c670d98ee3044802a5086f3e49634 +Subproject commit ed5db1b50136bace796062c1a6eab0df9a74f8fa diff --git a/Graphics/CMakeLists.txt b/Graphics/CMakeLists.txt index c0174f8..47a1788 100644 --- a/Graphics/CMakeLists.txt +++ b/Graphics/CMakeLists.txt @@ -10,11 +10,14 @@ file(GLOB HEADERS "./public/*.hpp") add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS}) target_include_directories(${PROJECT_NAME} PUBLIC ./public/) target_include_directories(${PROJECT_NAME} PRIVATE ${BINDINGS_INCLUDE}) -target_link_libraries(${PROJECT_NAME} PUBLIC Strings Math Utils) +target_link_libraries(${PROJECT_NAME} PUBLIC Strings Math Allocators) target_link_libraries(${PROJECT_NAME} PRIVATE ${BINDINGS_LIBS}) ### -------------------------- Examples -------------------------- ### -add_executable(${PROJECT_NAME}Example ./examples/Example.cpp) -target_link_libraries(${PROJECT_NAME}Example ${PROJECT_NAME} ${BINDINGS_LIBS}) -target_include_directories(${PROJECT_NAME}Example PRIVATE ${BINDINGS_INCLUDE}) +add_executable(Example${PROJECT_NAME} ./examples/Example.cpp) +target_link_libraries(Example${PROJECT_NAME} ${PROJECT_NAME} ${BINDINGS_LIBS}) +target_include_directories(Example${PROJECT_NAME} PRIVATE ${BINDINGS_INCLUDE}) + + +file(COPY "examples/Font.ttf" DESTINATION "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/") diff --git a/Graphics/examples/Font.ttf b/Graphics/examples/Font.ttf new file mode 100644 index 0000000..8a63054 Binary files /dev/null and b/Graphics/examples/Font.ttf differ diff --git a/Graphics/private/GraphicsCommon.cpp b/Graphics/private/GraphicsCommon.cpp index c9fa3ef..c6161f1 100644 --- a/Graphics/private/GraphicsCommon.cpp +++ b/Graphics/private/GraphicsCommon.cpp @@ -1,6 +1,7 @@ #include "GraphicsCommon.hpp" +#include "MathCommon.hpp" namespace tp { - static ModuleManifest* deps[] = { &gModuleStrings, &gModuleMath, nullptr }; + static ModuleManifest* deps[] = { &gModuleAllocators, nullptr }; ModuleManifest gModuleGraphics = ModuleManifest("Graphics", nullptr, nullptr, deps); } \ No newline at end of file diff --git a/Graphics/private/bindings/Canvas.cpp b/Graphics/private/bindings/Canvas.cpp index 9a56e61..15e0117 100644 --- a/Graphics/private/bindings/Canvas.cpp +++ b/Graphics/private/bindings/Canvas.cpp @@ -71,7 +71,7 @@ void Graphics::Canvas::popClamp() { } void Graphics::Canvas::text( - const String& string, const RectF& aRec, halnf size, Align align, halnf marging, const RGBA& col + const char* string, const RectF& aRec, halnf size, Align align, halnf marging, const RGBA& col ) { RectF rec = { aRec.x + marging, aRec.y + marging, aRec.z - marging * 2, aRec.w - marging * 2 }; @@ -107,7 +107,7 @@ void Graphics::Canvas::text( nvgTextAlign(mContext->vg, alignNVG); - nvgText(mContext->vg, centerX, centerY, string.read(), nullptr); + nvgText(mContext->vg, centerX, centerY, string, nullptr); popClamp(); } diff --git a/Graphics/public/Graphics.hpp b/Graphics/public/Graphics.hpp index ff7bea3..4885b90 100644 --- a/Graphics/public/Graphics.hpp +++ b/Graphics/public/Graphics.hpp @@ -2,7 +2,7 @@ #include "GraphicsCommon.hpp" -// TODO : fix this ugly shit +// TODO : ugly namespace tp { class Window; @@ -85,7 +85,7 @@ namespace tp { void pushClamp(const RectF& rec); void popClamp(); void rect(const RectF& rec, const RGBA& col, halnf round = 0); - void text(const String&, const RectF&, halnf size, Align, halnf marging, const RGBA&); + void text(const char*, const RectF&, halnf size, Align, halnf marging, const RGBA&); // TODO : API diff --git a/Graphics/public/GraphicsCommon.hpp b/Graphics/public/GraphicsCommon.hpp index 33466d6..df31c8f 100644 --- a/Graphics/public/GraphicsCommon.hpp +++ b/Graphics/public/GraphicsCommon.hpp @@ -2,9 +2,10 @@ #include "Color.hpp" #include "Rect.hpp" -#include "Strings.hpp" #include "Timing.hpp" +#include "Allocators.hpp" + namespace tp { extern ModuleManifest gModuleGraphics; } \ No newline at end of file diff --git a/LibraryViewer/CMakeLists.txt b/LibraryViewer/CMakeLists.txt index becb208..10494b8 100644 --- a/LibraryViewer/CMakeLists.txt +++ b/LibraryViewer/CMakeLists.txt @@ -11,7 +11,7 @@ file(GLOB HEADERS "./public/*.hpp" "./public/*/*.hpp" "./applications/*.hpp") add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS}) target_include_directories(${PROJECT_NAME} PUBLIC ./public/ ${BINDINGS_INCLUDE} ./ext/) -target_link_libraries(${PROJECT_NAME} PUBLIC Graphics Connection Widgets) +target_link_libraries(${PROJECT_NAME} PUBLIC Graphics Connection Widgets Strings) target_link_libraries(${PROJECT_NAME} PUBLIC ${BINDINGS_LIBS}) file(COPY "library" DESTINATION "${CMAKE_BINARY_DIR}/${PROJECT_NAME}") diff --git a/LibraryViewer/applications/Entry.cpp b/LibraryViewer/applications/Entry.cpp index b394300..696073c 100644 --- a/LibraryViewer/applications/Entry.cpp +++ b/LibraryViewer/applications/Entry.cpp @@ -33,7 +33,7 @@ void runApp() { auto area = window->getCanvas().getAvaliableArea(); - gui.proc(window->getEvents(), {}, { area.x, area.y, area.z, area.w }); + gui.proc(window->getEvents(), { area.x, area.y, area.z, area.w }, { area.x, area.y, area.z, area.w }); gui.draw(window->getCanvas()); // tp::sleep(100); @@ -54,6 +54,8 @@ int main() { return 1; } + tp::HeapAllocGlobal::disableCallstack(); + runApp(); binModule.deinitialize(); diff --git a/LibraryViewer/private/Library.cpp b/LibraryViewer/private/Library.cpp index 70fb249..2d63696 100644 --- a/LibraryViewer/private/Library.cpp +++ b/LibraryViewer/private/Library.cpp @@ -7,7 +7,7 @@ #include namespace tp { - static ModuleManifest* deps[] = { &gModuleGraphics, &gModuleConnection, &gModuleWidgets, nullptr }; + static ModuleManifest* deps[] = { &gModuleGraphics, &gModuleStrings, &gModuleAllocators, nullptr }; ModuleManifest gModuleLibraryViewer = ModuleManifest("LibraryViewer", nullptr, nullptr, deps); } @@ -51,7 +51,7 @@ bool Library::loadJson(const String& path) { LocalConnection libraryFile; Buffer libraryFileMem; - if (!libraryFile.connect(LocalConnection::Location(path), LocalConnection::Type(true))) return false; + if (!libraryFile.connect(LocalConnection::Location(path.read()), LocalConnection::Type(true))) return false; libraryFileMem.reserve(libraryFile.size()); libraryFile.readBytes(libraryFileMem.getBuff(), libraryFile.size()); diff --git a/LibraryViewer/public/Library.hpp b/LibraryViewer/public/Library.hpp index dba60f7..41e900d 100644 --- a/LibraryViewer/public/Library.hpp +++ b/LibraryViewer/public/Library.hpp @@ -1,6 +1,7 @@ #pragma once #include "Window.hpp" +#include "Strings.hpp" typedef tp::ualni SongId; enum class SONG_FORMAT { WAV, FLAC, NONE }; diff --git a/Math/CMakeLists.txt b/Math/CMakeLists.txt index cff35d3..919e11c 100644 --- a/Math/CMakeLists.txt +++ b/Math/CMakeLists.txt @@ -5,11 +5,10 @@ file(GLOB SOURCES "./private/*.cpp") file(GLOB HEADERS "./public/*.hpp") add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS}) target_include_directories(${PROJECT_NAME} PUBLIC ./public/) -target_link_libraries(${PROJECT_NAME} PUBLIC Allocators) +target_link_libraries(${PROJECT_NAME} PUBLIC Containers) ### -------------------------- Tests -------------------------- ### -enable_testing() file(GLOB TEST_SOURCES "./tests/*.cpp") -add_executable(${PROJECT_NAME}Tests ${TEST_SOURCES}) -target_link_libraries(${PROJECT_NAME}Tests ${PROJECT_NAME} UnitTest++) -add_test(NAME ${PROJECT_NAME}Tests COMMAND ${PROJECT_NAME}Tests) +add_executable(Test${PROJECT_NAME} ${TEST_SOURCES}) +target_link_libraries(Test${PROJECT_NAME} ${PROJECT_NAME} UnitTest++) +add_test(NAME Test${PROJECT_NAME} COMMAND Test${PROJECT_NAME}) diff --git a/Math/private/MathCommon.cpp b/Math/private/MathCommon.cpp deleted file mode 100644 index 405c761..0000000 --- a/Math/private/MathCommon.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -/// whoaoao wtf - -#include "MathCommon.hpp" -#include "Allocators.hpp" - -static tp::ModuleManifest* sModuleDependencies[] = { &tp::gModuleAllocators, nullptr }; - -tp::ModuleManifest tp::gModuleMath = ModuleManifest("Math", nullptr, nullptr, sModuleDependencies); - -tp::alnf std_sin(tp::alnf radians); -tp::alnf std_tan(tp::alnf radians); -tp::alnf std_cos(tp::alnf radians); -tp::alnf std_acos(tp::alnf val); -tp::alnf std_sqrt(tp::alnf val); -tp::alnf std_rad(tp::alnf val); -tp::alnf std_deg(tp::alnf val); -tp::alnf std_atan2(tp::alnf X, tp::alnf Y); -tp::alnf std_atan(tp::alnf val); -tp::alnf std_log2(tp::alnf val); - -tp::alnf tp::sin(const tp::alnf radians) { return std_sin((halnf) radians); } -tp::alnf tp::tan(const tp::alnf radians) { return std_tan((halnf) radians); } -tp::alnf tp::cos(const tp::alnf radians) { return std_cos((halnf) radians); } -tp::alnf tp::acos(const tp::alnf val) { return std_acos((halnf) val); } -tp::alnf tp::sqrt(const tp::alnf val) { return std_sqrt((halnf) val); } -tp::alnf tp::rad(const tp::alnf val) { return val * (PI / 180.f); } -tp::alnf tp::deg(const tp::alnf val) { return val * (180.f / PI); } -tp::alnf tp::atan2(const tp::alnf X, const tp::alnf Y) { return std_atan2((halnf) X, (halnf) Y); } -tp::alnf tp::atan(const tp::alnf val) { return std_atan((halnf) val); } -tp::alnf tp::log2(alnf val) { return std_log2(val); } - -#include - -tp::alnf std_sin(const tp::alnf radians) { return sinf((tp::halnf) radians); } -tp::alnf std_tan(const tp::alnf radians) { return tanf((tp::halnf) radians); } -tp::alnf std_cos(const tp::alnf radians) { return cosf((tp::halnf) radians); } -tp::alnf std_acos(const tp::alnf val) { return acos((tp::halnf) val); } -tp::alnf std_sqrt(const tp::alnf val) { return sqrt((tp::halnf) val); } -tp::alnf std_rad(const tp::alnf val) { return val * (PI / 180.f); } -tp::alnf std_deg(const tp::alnf val) { return val * (180.f / PI); } -tp::alnf std_atan2(const tp::alnf X, const tp::alnf Y) { return atan2((tp::halnf) X, (tp::halnf) Y); } -tp::alnf std_atan(const tp::alnf val) { return atan((tp::halnf) val); } -tp::alnf std_log2(const tp::alnf val) { return log2((tp::halnf) val); } diff --git a/Math/private/Topology.cpp b/Math/private/Topology.cpp index 336a5a6..7ce89df 100644 --- a/Math/private/Topology.cpp +++ b/Math/private/Topology.cpp @@ -1,8 +1,6 @@ #include "Topology.hpp" -#include "NewPlacement.hpp" - using namespace tp; Vec3F TrigCache::gHitPos; diff --git a/Math/private/Trig.cpp b/Math/private/Trig.cpp index 3bd22db..4ba274d 100644 --- a/Math/private/Trig.cpp +++ b/Math/private/Trig.cpp @@ -6,7 +6,6 @@ using namespace tp; Trig::Trig() { - MODULE_SANITY_CHECK(gModuleMath) p1.assign(0.f, 0.f, 0.f); p2.assign(0.f, 0.f, 0.f); p3.assign(0.f, 0.f, 0.f); diff --git a/Math/public/ComplexNumbers.hpp b/Math/public/ComplexNumbers.hpp index 35a6c57..acb4b23 100644 --- a/Math/public/ComplexNumbers.hpp +++ b/Math/public/ComplexNumbers.hpp @@ -18,7 +18,7 @@ namespace tp { [[nodiscard]] ComplexCart operator-(const ComplexCart& in) const { return { in.r - r, in.i - i }; } - [[nodiscard]] Number mod() const { return tp::sqrt(i * i + r * r); } + [[nodiscard]] Number mod() const { return sqrt(i * i + r * r); } [[nodiscard]] Number arg() const { return atan2(r, i); } diff --git a/Math/public/MathCommon.hpp b/Math/public/MathCommon.hpp index b38adc2..e7b74ce 100644 --- a/Math/public/MathCommon.hpp +++ b/Math/public/MathCommon.hpp @@ -13,17 +13,7 @@ #define SQRT2 1.4142135623730950488016887242 #define EXP 2.7182818284590452353602874714 -namespace tp { - extern ModuleManifest gModuleMath; +#include - alnf sin(alnf radians); - alnf tan(alnf radians); - alnf atan2(alnf X, alnf Y); - alnf atan(alnf val); - alnf cos(alnf radians); - alnf acos(alnf val); - alnf sqrt(alnf val); - alnf rad(alnf val); - alnf deg(alnf val); - alnf log2(alnf val); -} \ No newline at end of file +#define RAD(val) (val * (PI / 180.f)) +#define DEG(val) (val * (180.f / PI)) \ No newline at end of file diff --git a/Math/public/Vec.hpp b/Math/public/Vec.hpp index a904869..3e682e2 100644 --- a/Math/public/Vec.hpp +++ b/Math/public/Vec.hpp @@ -16,7 +16,7 @@ namespace tp { inline Type& set(ualni i, TypeArg arg) { return mBuff[i] = arg; } public: - Vec() { MODULE_SANITY_CHECK(gModuleMath) } + Vec() = default; explicit Vec(TypeArg val) { assign(val); } diff --git a/Math/tests/Tests.cpp b/Math/tests/Tests.cpp index b080b6e..ed6ed21 100644 --- a/Math/tests/Tests.cpp +++ b/Math/tests/Tests.cpp @@ -44,16 +44,5 @@ SUITE(Math) { } int main() { - tp::ModuleManifest* deps[] = { &tp::gModuleMath, &tp::gModuleUtils, nullptr }; - tp::ModuleManifest testModule("MathTest", nullptr, nullptr, deps); - - if (!testModule.initialize()) { - return 1; - } - - bool res = UnitTest::RunAllTests(); - - testModule.deinitialize(); - - return res; + return UnitTest::RunAllTests(); } diff --git a/Modules/private/Utils.cpp b/Modules/private/Utils.cpp index 1649628..2cef92c 100644 --- a/Modules/private/Utils.cpp +++ b/Modules/private/Utils.cpp @@ -9,7 +9,7 @@ void deinitializeCallStackCapture(); static bool initialize(const tp::ModuleManifest*) { initializeCallStackCapture(); - std::srand(std::time(nullptr)); + // std::srand(std::time(nullptr)); return true; } diff --git a/Modules/public/Archiver.hpp b/Modules/public/Archiver.hpp index 806230f..3e41897 100644 --- a/Modules/public/Archiver.hpp +++ b/Modules/public/Archiver.hpp @@ -2,6 +2,8 @@ #include "Common.hpp" +#include + namespace tp { // Used to transfer data to or from some sort of archive @@ -130,4 +132,29 @@ namespace tp { ualni mAddress = 0; ualni mFirstNotWritten = 0; }; + + struct StringArchiver { + std::string* val; + + StringArchiver(std::string& val) { this->val = &val; } + + template + void archiveRead(tArchiver& ar) { + ualni len; + ar >> len; + val->resize(len); + for (ualni i = 0; i < len; i++) { + ar >> (*val)[i]; + } + } + + template + void archiveWrite(tArchiver& ar) const { + ualni len = val->size(); + ar << len; + for (ualni i = 0; i < len; i++) { + ar << (*val)[i]; + } + } + }; } \ No newline at end of file diff --git a/Modules/public/Module.hpp b/Modules/public/Module.hpp index 06d29a7..c036678 100644 --- a/Modules/public/Module.hpp +++ b/Modules/public/Module.hpp @@ -2,6 +2,7 @@ #pragma once #include "Assert.hpp" +#include "Utils.hpp" #include "Common.hpp" #define MODULE_SANITY_CHECK(name) DEBUG_ASSERT(name.isInitialized() && "Modules Is Not Initialized" && #name) diff --git a/Modules/tests/Test.cpp b/Modules/tests/Test.cpp index 91714bb..0dee468 100644 --- a/Modules/tests/Test.cpp +++ b/Modules/tests/Test.cpp @@ -216,7 +216,7 @@ struct HasArchive()().archive(DeclareVal SUITE(BaseModule) { TEST(Basic) { - tp::ModuleManifest* ModuleDependencies[] = { &tp::gModuleBase, nullptr }; + tp::ModuleManifest* ModuleDependencies[] = { nullptr }; tp::ModuleManifest TestModule("Test", nullptr, nullptr, ModuleDependencies); REQUIRE CHECK(TestModule.initialize()); diff --git a/Objects/CMakeLists.txt b/Objects/CMakeLists.txt index 04c7e83..0af6b78 100644 --- a/Objects/CMakeLists.txt +++ b/Objects/CMakeLists.txt @@ -7,7 +7,7 @@ file(GLOB HEADERS "./public/*.hpp" "./public/*/*.hpp" "./applications/*.hpp") add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS}) target_include_directories(${PROJECT_NAME} PUBLIC ./public/ ${BINDINGS_INCLUDE}) -target_link_libraries(${PROJECT_NAME} PUBLIC Strings Math Connection LALR) +target_link_libraries(${PROJECT_NAME} PUBLIC Strings Math Connection LALR Strings) target_compile_definitions(${PROJECT_NAME} PUBLIC USERDATA_DESTROY_FAILED_TREE_ROOTS) ### -------------------------- Applications -------------------------- ### @@ -23,6 +23,6 @@ file(COPY "rsc/Font.ttf" DESTINATION "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/") ### -------------------------- Tests -------------------------- ### file(GLOB TEST_SOURCES "./tests/*.cpp" "./tests/*/*.cpp") -add_executable(${PROJECT_NAME}Tests ${TEST_SOURCES}) -target_link_libraries(${PROJECT_NAME}Tests ${PROJECT_NAME} UnitTest++) -add_test(NAME ${PROJECT_NAME}Tests COMMAND ${PROJECT_NAME}Tests) \ No newline at end of file +add_executable(Test${PROJECT_NAME} ${TEST_SOURCES}) +target_link_libraries(Test${PROJECT_NAME} ${PROJECT_NAME} UnitTest++) +add_test(NAME Test${PROJECT_NAME} COMMAND Test${PROJECT_NAME}) \ No newline at end of file diff --git a/Objects/private/core/module.cpp b/Objects/private/core/module.cpp index 464f4c5..faf2e44 100644 --- a/Objects/private/core/module.cpp +++ b/Objects/private/core/module.cpp @@ -77,9 +77,7 @@ static void deinit(const tp::ModuleManifest*) { static tp::ModuleManifest* sModuleDependencies[] = { // &tp::gModuleCompressor, - &tp::gModuleMath, &tp::gModuleStrings, - &tp::gModuleConnection, nullptr }; diff --git a/RayTracer/CMakeLists.txt b/RayTracer/CMakeLists.txt index 31d5a22..d40c663 100644 --- a/RayTracer/CMakeLists.txt +++ b/RayTracer/CMakeLists.txt @@ -3,26 +3,18 @@ project(RayTracer) ### ---------------------- Static Library --------------------- ### file(GLOB SOURCES "./private/*.cpp" "./private/*/*.cpp") file(GLOB HEADERS "./public/*.hpp" "./public/*/*.hpp" "./applications/*.hpp") - add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS}) - target_include_directories(${PROJECT_NAME} PUBLIC ./public/) target_link_libraries(${PROJECT_NAME} PUBLIC Math Connection) ### -------------------------- Applications -------------------------- ### -add_executable(rayt ./applications/Rayt.cpp applications/SceneLoad.cpp - applications/Rayt.hpp) - +add_executable(rayt ./applications/Rayt.cpp applications/SceneLoad.cpp applications/Rayt.hpp) target_link_libraries(rayt ${PROJECT_NAME} Lua ImageIO) - file(COPY "applications/rsc" DESTINATION "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/") ### -------------------------- Tests -------------------------- ### -enable_testing() file(GLOB TEST_SOURCES "./tests/*.cpp" "./tests/*/*.cpp") -add_executable(${PROJECT_NAME}Tests ${TEST_SOURCES}) - -target_include_directories(${PROJECT_NAME}Tests PUBLIC ./applications/) - -target_link_libraries(${PROJECT_NAME}Tests ${PROJECT_NAME} UnitTest++ ImageIO) -add_test(NAME ${PROJECT_NAME}Tests COMMAND ${PROJECT_NAME}Tests) +add_executable(Test${PROJECT_NAME} ${TEST_SOURCES}) +target_include_directories(Test${PROJECT_NAME} PUBLIC ./applications/) +target_link_libraries(Test${PROJECT_NAME} ${PROJECT_NAME} UnitTest++ ImageIO) +add_test(NAME Test${PROJECT_NAME} COMMAND Test${PROJECT_NAME}) diff --git a/RayTracer/applications/Rayt.cpp b/RayTracer/applications/Rayt.cpp index cdb66f2..fb13aeb 100644 --- a/RayTracer/applications/Rayt.cpp +++ b/RayTracer/applications/Rayt.cpp @@ -23,8 +23,8 @@ void writeImage(const RayTracer::RenderBuffer& output, const char* name) { Buffer2D converted; converted.reserve(output.size()); - for (RayTracer::RenderBuffer::Index i = 0; i < output.size().x; i++) { - for (RayTracer::RenderBuffer::Index j = 0; j < output.size().y; j++) { + for (Index i = 0; i < output.size().x; i++) { + for (Index j = 0; j < output.size().y; j++) { converted.get({ i, j }).r = uint1(output.get({ i, j }).r * 255); converted.get({ i, j }).g = uint1(output.get({ i, j }).g * 255); converted.get({ i, j }).b = uint1(output.get({ i, j }).b * 255); @@ -51,7 +51,7 @@ void printStatus(const halnf* percentage) { } } -void renderCommand(const String& scenePath) { +void renderCommand(const std::string& scenePath) { Scene scene; RayTracer::RenderSettings settings; @@ -80,14 +80,6 @@ void renderCommand(const String& scenePath) { } int main(int argc, const char** argv) { - tp::ModuleManifest* deps[] = { &gModuleRayTracer, nullptr }; - tp::ModuleManifest module("Rayt", nullptr, nullptr, deps); - - if (module.initialize()) { - renderCommand("scene.lua"); - - module.deinitialize(); - } - + renderCommand("scene.lua"); return 0; } \ No newline at end of file diff --git a/RayTracer/applications/Rayt.hpp b/RayTracer/applications/Rayt.hpp index b5202b7..ad43ea5 100644 --- a/RayTracer/applications/Rayt.hpp +++ b/RayTracer/applications/Rayt.hpp @@ -1,6 +1,7 @@ #pragma once #include "RayTracer.hpp" -#include "Strings.hpp" -void loadScene(tp::Scene& scene, const tp::String& scenePath, tp::RayTracer::RenderSettings& settings); +#include + +void loadScene(tp::Scene& scene, const std::string& scenePath, tp::RayTracer::RenderSettings& settings); diff --git a/RayTracer/applications/SceneLoad.cpp b/RayTracer/applications/SceneLoad.cpp index 6b31e6d..a17e760 100644 --- a/RayTracer/applications/SceneLoad.cpp +++ b/RayTracer/applications/SceneLoad.cpp @@ -8,12 +8,12 @@ extern "C" { #include "OBJ_Loader.h" -bool loadMeshes(tp::Scene& scene, const tp::String& objetsPath) { +bool loadMeshes(tp::Scene& scene, const std::string& objetsPath) { using namespace tp; objl::Loader Loader; - if (!Loader.LoadFile(objetsPath.read())) { + if (!Loader.LoadFile(objetsPath.c_str())) { std::cout << "Failed to Load File. May have failed to find it or it was not an .obj file.\n"; return false; } @@ -123,7 +123,7 @@ int readLight(lua_State* L, tp::PointLight* light) { return 1; // Success } -void loadScene(tp::Scene& scene, const tp::String& scenePath, tp::RayTracer::RenderSettings& settings) { +void loadScene(tp::Scene& scene, const std::string& scenePath, tp::RayTracer::RenderSettings& settings) { lua_State* L = luaL_newstate(); luaL_openlibs(L); @@ -136,7 +136,7 @@ void loadScene(tp::Scene& scene, const tp::String& scenePath, tp::RayTracer::Ren lua_getglobal(L, "Meshes"); if (lua_isstring(L, -1)) { - tp::String meshesPath = lua_tostring(L, -1); + std::string meshesPath = lua_tostring(L, -1); if (!loadMeshes(scene, meshesPath)) { printf("No 'meshes' loaded - check ur .obj path and validate content of .obj .\n"); diff --git a/RayTracer/private/RayTracer.cpp b/RayTracer/private/RayTracer.cpp index 43cc16d..870ec6c 100644 --- a/RayTracer/private/RayTracer.cpp +++ b/RayTracer/private/RayTracer.cpp @@ -43,10 +43,6 @@ normal = n1 * barycentric.x + n2 * barycentric.y + n3 * barycentric.z; using namespace tp; -ModuleManifest* sDependencies[] = { &gModuleMath, &gModuleConnection, nullptr }; - -ModuleManifest tp::gModuleRayTracer = ModuleManifest("RayTracer", nullptr, nullptr, sDependencies); - void RayTracer::castRay(const Ray& ray, RayCastData& out, alnf farVal) { out.hit = false; @@ -167,8 +163,8 @@ void RayTracer::render(const Scene& scene, OutputBuffers& out, const RenderSetti col.b /= num; }; - for (auto i = 0; i < mSettings.size.x; i++) { - for (auto j = 0; j < mSettings.size.y; j++) { + for (ualni i = 0; i < mSettings.size.x; i++) { + for (ualni j = 0; j < mSettings.size.y; j++) { for (auto sample = 0; sample < mSettings.multisampling; sample++) { auto randX = randomFloat(); auto randY = randomFloat(); diff --git a/RayTracer/public/RayTracer.hpp b/RayTracer/public/RayTracer.hpp index 555fa9e..08ea94e 100644 --- a/RayTracer/public/RayTracer.hpp +++ b/RayTracer/public/RayTracer.hpp @@ -49,7 +49,7 @@ namespace tp { uhalni depth = 2; uhalni spray = 1; ualni multisampling = 1; - Vec2I size; + Vec2 size; }; struct OutputBuffers { diff --git a/RayTracer/tests/Test.cpp b/RayTracer/tests/Test.cpp index 3c1e2a2..170ef1c 100644 --- a/RayTracer/tests/Test.cpp +++ b/RayTracer/tests/Test.cpp @@ -18,8 +18,8 @@ void writeImage(const RayTracer::RenderBuffer& output) { Buffer2D converted; converted.reserve(output.size()); - for (RayTracer::RenderBuffer::Index i = 0; i < output.size().x; i++) { - for (RayTracer::RenderBuffer::Index j = 0; j < output.size().y; j++) { + for (Index i = 0; i < output.size().x; i++) { + for (Index j = 0; j < output.size().y; j++) { converted.get({ i, j }).r = uint1(output.get({ i, j }).r * 255); converted.get({ i, j }).g = uint1(output.get({ i, j }).g * 255); converted.get({ i, j }).b = uint1(output.get({ i, j }).b * 255); @@ -101,8 +101,8 @@ SUITE(RayTracer) { if (0) { writeImage(output.color); - for (auto i = 0; i < output.color.size().x; i++) { - for (auto j = 0; j < output.color.size().y; j++) { + for (Index i = 0; i < output.color.size().x; i++) { + for (Index j = 0; j < output.color.size().y; j++) { auto tmp = output.color.get({ i, j }); printf( "TEST(compareCols(output.get({%i, %i}), RGBA{ %ff, %ff, %ff, %ff }));\n", i, j, tmp.r, tmp.g, tmp.b, tmp.a @@ -114,16 +114,5 @@ SUITE(RayTracer) { } int main(int argc, char* argv[]) { - tp::ModuleManifest* ModuleDependencies[] = { &tp::gModuleRayTracer, nullptr }; - tp::ModuleManifest TestModule("TokenizerTest", nullptr, nullptr, ModuleDependencies); - - if (!TestModule.initialize()) { - return 1; - } - - bool res = UnitTest::RunAllTests(); - - TestModule.deinitialize(); - - return res; + return UnitTest::RunAllTests(); } diff --git a/Strings/CMakeLists.txt b/Strings/CMakeLists.txt index 1950322..f5577a7 100644 --- a/Strings/CMakeLists.txt +++ b/Strings/CMakeLists.txt @@ -10,6 +10,6 @@ target_link_libraries(${PROJECT_NAME} PUBLIC Allocators Containers) ### -------------------------- Tests -------------------------- ### enable_testing() file(GLOB TEST_SOURCES "./tests/*.cpp") -add_executable(${PROJECT_NAME}Tests ${TEST_SOURCES}) -target_link_libraries(${PROJECT_NAME}Tests ${PROJECT_NAME} UnitTest++) -add_test(NAME ${PROJECT_NAME}Tests COMMAND ${PROJECT_NAME}Tests) \ No newline at end of file +add_executable(Test${PROJECT_NAME} ${TEST_SOURCES}) +target_link_libraries(Test${PROJECT_NAME} ${PROJECT_NAME} UnitTest++) +add_test(NAME Test${PROJECT_NAME} COMMAND Test${PROJECT_NAME}) \ No newline at end of file diff --git a/Strings/private/Strings.cpp b/Strings/private/Strings.cpp index 760d413..ef8c81e 100644 --- a/Strings/private/Strings.cpp +++ b/Strings/private/Strings.cpp @@ -12,6 +12,6 @@ bool initialize(const ModuleManifest*) { void deinitialize(const ModuleManifest*) { Logger::deinitializeGlobal(); } -static tp::ModuleManifest* sModuleDependencies[] = { &tp::gModuleContainers, &tp::gModuleAllocators, nullptr }; +static tp::ModuleManifest* sModuleDependencies[] = { &tp::gModuleAllocators, nullptr }; ModuleManifest tp::gModuleStrings = ModuleManifest("Strings", initialize, deinitialize, sModuleDependencies); \ No newline at end of file diff --git a/Strings/tests/Test.cpp b/Strings/tests/Test.cpp index bac008c..a70ee65 100644 --- a/Strings/tests/Test.cpp +++ b/Strings/tests/Test.cpp @@ -229,7 +229,7 @@ SUITE(Strings) { int main() { - tp::ModuleManifest* deps[] = { &tp::gModuleStrings, &tp::gModuleUtils, nullptr }; + tp::ModuleManifest* deps[] = { &tp::gModuleStrings, nullptr }; tp::ModuleManifest testModule("StringsTest", nullptr, nullptr, deps); if (!testModule.initialize()) { diff --git a/Widgets/CMakeLists.txt b/Widgets/CMakeLists.txt index 2909374..4253461 100644 --- a/Widgets/CMakeLists.txt +++ b/Widgets/CMakeLists.txt @@ -11,15 +11,13 @@ target_link_libraries(${PROJECT_NAME} PUBLIC Math Strings) ### -------------------------- Tests -------------------------- ### enable_testing() file(GLOB TEST_SOURCES "./tests/*.cpp") -add_executable(${PROJECT_NAME}Tests ${TEST_SOURCES}) -target_link_libraries(${PROJECT_NAME}Tests ${PROJECT_NAME} UnitTest++) -add_test(NAME ${PROJECT_NAME}Tests COMMAND ${PROJECT_NAME}Tests) +add_executable(Test${PROJECT_NAME} ${TEST_SOURCES}) +target_link_libraries(Test${PROJECT_NAME} ${PROJECT_NAME} UnitTest++) +add_test(NAME Test${PROJECT_NAME} COMMAND Test${PROJECT_NAME}) ### -------------------------- Applications -------------------------- ### add_executable(ExampleGui examples/Entry.cpp) - target_link_libraries(ExampleGui ${PROJECT_NAME} Graphics Imgui Nanovg glfw ${GLEW_LIB}) target_include_directories(ExampleGui PUBLIC ../Externals/glfw/include ${GLEW_INCLUDE_DIR}) - file(COPY "examples/Font.ttf" DESTINATION "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/") \ No newline at end of file diff --git a/Widgets/private/WidgetConfig.cpp b/Widgets/private/WidgetConfig.cpp index be45cf5..87543d7 100644 --- a/Widgets/private/WidgetConfig.cpp +++ b/Widgets/private/WidgetConfig.cpp @@ -4,6 +4,6 @@ namespace tp { GlobalGUIConfig* gGlobalGUIConfig = nullptr; - ModuleManifest* deps[] = { &gModuleMath, &gModuleStrings, nullptr }; + ModuleManifest* deps[] = { &gModuleStrings, nullptr }; ModuleManifest gModuleWidgets = ModuleManifest("Widgets", nullptr, nullptr, deps); } \ No newline at end of file