tmp
This commit is contained in:
parent
afab59eb21
commit
69a17a609e
71 changed files with 199 additions and 282 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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() {}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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 ---------------------------------- //
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
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})
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
|
||||
#include "ConnectionCommon.hpp"
|
||||
|
||||
static tp::ModuleManifest* sModuleDependencies[] = { &tp::gModuleStrings, nullptr };
|
||||
|
||||
tp::ModuleManifest tp::gModuleConnection = ModuleManifest("Storage", nullptr, nullptr, sModuleDependencies);
|
||||
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include "Strings.hpp"
|
||||
#include "Module.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace tp {
|
||||
extern ModuleManifest gModuleConnection;
|
||||
|
||||
class Connection {
|
||||
public:
|
||||
typedef ualni SizeBytes;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "Common.hpp"
|
||||
#include "Module.hpp"
|
||||
|
||||
namespace tp {
|
||||
class ServerContext;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
@ -8,16 +8,17 @@ namespace tp {
|
|||
|
||||
template <typename tType, ualni tSizeX, ualni tSizeY>
|
||||
using ConstSizeBuffer2D = ConstSizeBuffer<ConstSizeBuffer<tType, tSizeX>, tSizeY>;
|
||||
|
||||
typedef ualni Index;
|
||||
|
||||
struct Index2D {
|
||||
Index x = 0;
|
||||
Index y = 0;
|
||||
};
|
||||
|
||||
template <typename tType, class tAllocator = DefaultAllocator>
|
||||
class Buffer2D {
|
||||
public:
|
||||
typedef ualni Index;
|
||||
|
||||
struct Index2D {
|
||||
Index x = 0;
|
||||
Index y = 0;
|
||||
};
|
||||
|
||||
typedef SelectValueOrReference<tType> tTypeArg;
|
||||
|
||||
|
|
|
|||
|
|
@ -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})
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -24,12 +24,12 @@ void writeImage(const Buffer<halnf>& image, const char* name) {
|
|||
|
||||
struct Dataset {
|
||||
ualni length = 0;
|
||||
Pair<ualni, ualni> imageSize = { 0, 0 };
|
||||
std::pair<ualni, ualni> imageSize = { 0, 0 };
|
||||
Buffer<uint1> labels;
|
||||
Buffer<Buffer<uint1>> 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());
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()) {
|
||||
|
|
|
|||
1
Externals/CMakeLists.txt
vendored
1
Externals/CMakeLists.txt
vendored
|
|
@ -32,7 +32,6 @@ endif()
|
|||
#add_subdirectory(unittest-cpp)
|
||||
|
||||
add_subdirectory(lalr)
|
||||
|
||||
add_subdirectory(glfw)
|
||||
|
||||
project(Imgui)
|
||||
|
|
|
|||
2
Externals/asio
vendored
2
Externals/asio
vendored
|
|
@ -1 +1 @@
|
|||
Subproject commit 3a7078a2002c670d98ee3044802a5086f3e49634
|
||||
Subproject commit ed5db1b50136bace796062c1a6eab0df9a74f8fa
|
||||
|
|
@ -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}/")
|
||||
|
||||
|
|
|
|||
BIN
Graphics/examples/Font.ttf
Normal file
BIN
Graphics/examples/Font.ttf
Normal file
Binary file not shown.
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@
|
|||
|
||||
#include "Color.hpp"
|
||||
#include "Rect.hpp"
|
||||
#include "Strings.hpp"
|
||||
#include "Timing.hpp"
|
||||
|
||||
#include "Allocators.hpp"
|
||||
|
||||
namespace tp {
|
||||
extern ModuleManifest gModuleGraphics;
|
||||
}
|
||||
|
|
@ -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}")
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include <filesystem>
|
||||
|
||||
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<int1> 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());
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "Window.hpp"
|
||||
#include "Strings.hpp"
|
||||
|
||||
typedef tp::ualni SongId;
|
||||
enum class SONG_FORMAT { WAV, FLAC, NONE };
|
||||
|
|
|
|||
|
|
@ -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})
|
||||
|
|
|
|||
|
|
@ -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 <cmath>
|
||||
|
||||
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); }
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
|
||||
#include "Topology.hpp"
|
||||
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
using namespace tp;
|
||||
|
||||
Vec3F TrigCache::gHitPos;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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); }
|
||||
|
||||
|
|
|
|||
|
|
@ -13,17 +13,7 @@
|
|||
#define SQRT2 1.4142135623730950488016887242
|
||||
#define EXP 2.7182818284590452353602874714
|
||||
|
||||
namespace tp {
|
||||
extern ModuleManifest gModuleMath;
|
||||
#include <cmath>
|
||||
|
||||
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);
|
||||
}
|
||||
#define RAD(val) (val * (PI / 180.f))
|
||||
#define DEG(val) (val * (180.f / PI))
|
||||
|
|
@ -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); }
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include "Common.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
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 <typename tArchiver>
|
||||
void archiveRead(tArchiver& ar) {
|
||||
ualni len;
|
||||
ar >> len;
|
||||
val->resize(len);
|
||||
for (ualni i = 0; i < len; i++) {
|
||||
ar >> (*val)[i];
|
||||
}
|
||||
}
|
||||
|
||||
template <typename tArchiver>
|
||||
void archiveWrite(tArchiver& ar) const {
|
||||
ualni len = val->size();
|
||||
ar << len;
|
||||
for (ualni i = 0; i < len; i++) {
|
||||
ar << (*val)[i];
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ struct HasArchive<T, A, VoidType<decltype(DeclareValue<T>()().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());
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
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})
|
||||
|
|
@ -77,9 +77,7 @@ static void deinit(const tp::ModuleManifest*) {
|
|||
|
||||
static tp::ModuleManifest* sModuleDependencies[] = {
|
||||
// &tp::gModuleCompressor,
|
||||
&tp::gModuleMath,
|
||||
&tp::gModuleStrings,
|
||||
&tp::gModuleConnection,
|
||||
nullptr
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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})
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ void writeImage(const RayTracer::RenderBuffer& output, const char* name) {
|
|||
Buffer2D<urgb> 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;
|
||||
}
|
||||
|
|
@ -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 <string>
|
||||
|
||||
void loadScene(tp::Scene& scene, const std::string& scenePath, tp::RayTracer::RenderSettings& settings);
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ namespace tp {
|
|||
uhalni depth = 2;
|
||||
uhalni spray = 1;
|
||||
ualni multisampling = 1;
|
||||
Vec2I size;
|
||||
Vec2<ualni> size;
|
||||
};
|
||||
|
||||
struct OutputBuffers {
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ void writeImage(const RayTracer::RenderBuffer& output) {
|
|||
Buffer2D<urgb> 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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
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})
|
||||
|
|
@ -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);
|
||||
|
|
@ -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()) {
|
||||
|
|
|
|||
|
|
@ -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}/")
|
||||
|
|
@ -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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue