diff --git a/include/CLCaster.h b/include/CLCaster.h index f193449..82cac44 100644 --- a/include/CLCaster.h +++ b/include/CLCaster.h @@ -151,9 +151,9 @@ public: // Save the chosen device config to a file void save_config(); - // Set a - void - + // Set a define + void setDefine(std::string name, std::string value); + void removeDefine(std::string name); // ================================== DEBUG ======================================= @@ -287,7 +287,7 @@ private: // Containers holding the kernels and buffers std::map kernel_map; std::map buffer_map; - std::vector> settings_index_map; + std::map defines_map; std::unordered_map>> image_map; // Hardware caster holds and renders its own textures diff --git a/kernels/ray_caster_kernel.cl b/kernels/ray_caster_kernel.cl index e1df386..06e91fd 100644 --- a/kernels/ray_caster_kernel.cl +++ b/kernels/ray_caster_kernel.cl @@ -463,7 +463,7 @@ __kernel void raycaster( break; } - constant int vox_dim = OCTDIM; + int vox_dim = OCTDIM; // If we hit a voxel // if (voxel.x < (*map_dim).x && voxel.y < (*map_dim).x && voxel.z < (*map_dim).x){ diff --git a/src/Application.cpp b/src/Application.cpp index 60029d5..2e869e9 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -26,6 +26,7 @@ bool Application::init_clcaster() { // Start up the raycaster raycaster = std::make_shared(); + raycaster->setDefine("OCTDIM", std::to_string(MAP_X)); if (!raycaster->init()) abort(); @@ -41,6 +42,9 @@ bool Application::init_clcaster() { raycaster->assign_octree(map); raycaster->assign_map(map); + + + camera = std::make_shared( sf::Vector3f(3.5f, 3.5f, 3.5f), // Starting position sf::Vector2f(1.57f, 0.0f), // Direction @@ -52,6 +56,7 @@ bool Application::init_clcaster() { raycaster->create_viewport(WINDOW_X, WINDOW_Y, 0.625f * 90.0f, 90.0f); // Initialize the light controller and link it to the GPU + // TODO: Bad behaviour when raycaster has errors!!!! light_controller = std::make_shared(raycaster); // Create a light prototype, send it to the controller, and get the handle back diff --git a/src/CLCaster.cpp b/src/CLCaster.cpp index 89d48f4..c8146da 100644 --- a/src/CLCaster.cpp +++ b/src/CLCaster.cpp @@ -723,11 +723,11 @@ bool CLCaster::compile_kernel(std::string kernel_source, bool is_path, std::stri std::stringstream build_string_stream; // walk the settings index's and add them to the defines - for (auto i: settings_index_map){ - build_string_stream << " -D" << i.first << "=" << std::to_string(i.second); + for (auto const& define : defines_map){ + build_string_stream << " -D" << define.first << "=" << define.second; } - build_string_stream << "-DOCTDIM=" << std::to_string(Application::MAP_X); + //build_string_stream << "-DOCTDIM=" << std::to_string(Application::MAP_X); build_string_stream << " -cl-finite-math-only -cl-fast-relaxed-math -cl-unsafe-math-optimizations"; std::string build_string = build_string_stream.str(); @@ -745,8 +745,8 @@ bool CLCaster::compile_kernel(std::string kernel_source, bool is_path, std::stri // Grab the log clGetProgramBuildInfo(program, device_id, CL_PROGRAM_BUILD_LOG, log_size, log, NULL); - Logger::log("Failed at clBuildProgram() : " + cl_err_lookup(error), Logger::LogLevel::ERROR, __LINE__, __FILE__); - Logger::log(log, Logger::LogLevel::ERROR, __LINE__, __FILE__); + Logger::log("Failed at clBuildProgram() with " + cl_err_lookup(error), Logger::LogLevel::ERROR, __LINE__, __FILE__); + Logger::log("CL_ERROR -->" + std::string(log), Logger::LogLevel::ERROR, __LINE__, __FILE__); return false; } @@ -1177,6 +1177,14 @@ std::string CLCaster::cl_err_lookup(int error_code) { } +void CLCaster::setDefine(std::string name, std::string value) { + defines_map[name] = value; +} + +void CLCaster::removeDefine(std::string name) { + defines_map.erase(name); +} + CLCaster::device::device(cl_device_id device_id, cl_platform_id platform_id) { diff --git a/src/Pub_Sub.cpp b/src/Pub_Sub.cpp index d69cf5a..a2c621f 100644 --- a/src/Pub_Sub.cpp +++ b/src/Pub_Sub.cpp @@ -47,7 +47,7 @@ VrEventPublisher::~VrEventPublisher() { // And one by one remove the for (auto subscriber: subscriber_bucket.second){ - subscriber. + //subscriber. } } }