Finally moved screenshots and runtime compilation to GUI elements

This commit is contained in:
MitchellHansen
2017-03-19 23:08:16 -07:00
parent 7e5d4ef947
commit 0d82cd5a20
3 changed files with 35 additions and 27 deletions

View File

@@ -46,8 +46,8 @@ const int WINDOW_X = 1440;
const int WINDOW_Y = 900;
const int WORK_SIZE = WINDOW_X * WINDOW_Y;
const int MAP_X = 256;
const int MAP_Y = 256;
const int MAP_X = 512;
const int MAP_Y = 512;
const int MAP_Z = 256;
float elap_time(){
@@ -181,6 +181,7 @@ int main() {
float light_color[4] = { 0, 0, 0, 0 };
float light_pos[4] = { 100, 100, 30 };
char screenshot_buf[128]{0};
while (window.isOpen()) {
@@ -188,24 +189,6 @@ int main() {
input_handler.handle_held_keys();
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
elapsed_time = elap_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.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::Begin("Lights");

View File

@@ -518,7 +518,7 @@ int Hardware_Caster::compile_kernel(std::string kernel_source, bool is_path, std
// 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
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) {
//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) };
size_t global_work_size[2] = { static_cast<size_t>(work_dim_x), static_cast<size_t>(work_dim_y)};
cl_kernel kernel = kernel_map.at(kernel_name);