This commit is contained in:
Ilusha 2024-03-16 12:07:49 +03:00
parent 65cb26a627
commit 1ead32d84a
71 changed files with 199 additions and 282 deletions

View file

@ -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;
}

View file

@ -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);

View file

@ -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");