Finally moved screenshots and runtime compilation to GUI elements

master
MitchellHansen 8 years ago
parent 7e5d4ef947
commit 0d82cd5a20

@ -72,6 +72,9 @@ bool cast_light_intersection_ray(
){ ){
float distance_to_light = DistanceBetweenPoints(ray_pos, (float3)(lights[4], lights[5], lights[6])); float distance_to_light = DistanceBetweenPoints(ray_pos, (float3)(lights[4], lights[5], lights[6]));
if (distance_to_light > 200.0f){
return false;
}
// Setup the voxel step based on what direction the ray is pointing // Setup the voxel step based on what direction the ray is pointing
int3 voxel_step = { 1, 1, 1 }; int3 voxel_step = { 1, 1, 1 };
@ -148,11 +151,13 @@ __kernel void raycaster(
global int2 *tile_dim global int2 *tile_dim
){ ){
int global_id = get_global_id(0);
int x = get_global_id(0); int x = get_global_id(0);
int y = get_global_id(1); int y = get_global_id(1);
int global_id = x * y;
// Get and set the random seed from seed memory // Get and set the random seed from seed memory
int seed = seed_memory[global_id]; int seed = seed_memory[global_id];
int random_number = rand(&seed); int random_number = rand(&seed);

@ -46,8 +46,8 @@ const int WINDOW_X = 1440;
const int WINDOW_Y = 900; const int WINDOW_Y = 900;
const int WORK_SIZE = WINDOW_X * WINDOW_Y; const int WORK_SIZE = WINDOW_X * WINDOW_Y;
const int MAP_X = 256; const int MAP_X = 512;
const int MAP_Y = 256; const int MAP_Y = 512;
const int MAP_Z = 256; const int MAP_Z = 256;
float elap_time(){ float elap_time(){
@ -181,6 +181,7 @@ int main() {
float light_color[4] = { 0, 0, 0, 0 }; float light_color[4] = { 0, 0, 0, 0 };
float light_pos[4] = { 100, 100, 30 }; float light_pos[4] = { 100, 100, 30 };
char screenshot_buf[128]{0};
while (window.isOpen()) { while (window.isOpen()) {
@ -188,24 +189,6 @@ int main() {
input_handler.handle_held_keys(); input_handler.handle_held_keys();
input_handler.dispatch_events(); input_handler.dispatch_events();
if (sf::Keyboard::isKeyPressed(sf::Keyboard::F11)) {
while (raycaster->debug_quick_recompile() != 0);
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Num0)) {
std::string path = "../assets/";
std::string filename;
std::getline(std::cin, filename);
filename += ".png";
sf::Texture window_texture;
window_texture.create(window.getSize().x, window.getSize().y);
window_texture.update(window);
sf::Image image = window_texture.copyToImage();
image.saveToFile(path + filename);
}
// Time keeping // Time keeping
elapsed_time = elap_time(); elapsed_time = elap_time();
delta_time = elapsed_time - current_time; delta_time = elapsed_time - current_time;
@ -256,6 +239,29 @@ int main() {
ImGui::Text(std::to_string(pos.y).c_str()); ImGui::Text(std::to_string(pos.y).c_str());
ImGui::Text(std::to_string(pos.z).c_str()); ImGui::Text(std::to_string(pos.z).c_str());
ImGui::NextColumn();
ImGui::InputText("filename", screenshot_buf, 128);
if (ImGui::Button("Take Screen shot")) {
std::string path = "../assets/";
std::string filename(screenshot_buf);
filename += ".png";
sf::Texture window_texture;
window_texture.create(window.getSize().x, window.getSize().y);
window_texture.update(window);
sf::Image image = window_texture.copyToImage();
image.saveToFile(path + filename);
}
ImGui::NextColumn();
if (ImGui::Button("Recompile kernel")) {
while (raycaster->debug_quick_recompile() != 0);
}
ImGui::End(); ImGui::End();
ImGui::Begin("Lights"); ImGui::Begin("Lights");

@ -518,7 +518,7 @@ int Hardware_Caster::compile_kernel(std::string kernel_source, bool is_path, std
// Try and build the program // Try and build the program
error = clBuildProgram(program, 1, &device_id, NULL, NULL, NULL); error = clBuildProgram(program, 1, &device_id, "-cl-finite-math-only -cl-fast-relaxed-math -cl-unsafe-math-optimizations", NULL, NULL);
// Check to see if it errored out // Check to see if it errored out
if (vr_assert(error, "clBuildProgram")) { if (vr_assert(error, "clBuildProgram")) {
@ -665,10 +665,7 @@ int Hardware_Caster::store_buffer(cl_mem buffer, std::string buffer_name) {
int Hardware_Caster::run_kernel(std::string kernel_name, const int work_dim_x, const int work_dim_y) { int Hardware_Caster::run_kernel(std::string kernel_name, const int work_dim_x, const int work_dim_y) {
//size_t global_work_size[2] = { static_cast<size_t>(work_dim_x), static_cast<size_t>(work_dim_y)}; size_t global_work_size[2] = { static_cast<size_t>(work_dim_x), static_cast<size_t>(work_dim_y)};
size_t global_work_size[2] = { static_cast<size_t>(1440), static_cast<size_t>(900)};
//size_t global_work_size[1] = { static_cast<size_t>(1440*900) };
cl_kernel kernel = kernel_map.at(kernel_name); cl_kernel kernel = kernel_map.at(kernel_name);

Loading…
Cancel
Save