diff options
author | Leonard Kugis <leonardkugis@gmail.com> | 2018-01-27 02:03:31 +0100 |
---|---|---|
committer | Leonard Kugis <leonardkugis@gmail.com> | 2018-01-27 02:03:31 +0100 |
commit | c8a38bd8ad66eb0b35f08a4733fdee37a888b83c (patch) | |
tree | 63f730553e879f5e14f0dc5e3cbb92ce771ae43f /src/mandelbrot-zoom.c | |
parent | 3d162bbcc92b22e6b00ee80194214c393770adb7 (diff) |
OpenCL rendering added, not working properly
Diffstat (limited to 'src/mandelbrot-zoom.c')
-rw-r--r-- | src/mandelbrot-zoom.c | 95 |
1 files changed, 45 insertions, 50 deletions
diff --git a/src/mandelbrot-zoom.c b/src/mandelbrot-zoom.c index f54a2ab..72b54ba 100644 --- a/src/mandelbrot-zoom.c +++ b/src/mandelbrot-zoom.c @@ -17,6 +17,7 @@ int main(int argc, char **argv) ui_settings.settings = GTK_WINDOW(gtk_builder_get_object(builder, "settings")); //gtk_builder_connect_signals(builder, NULL); + ui_settings.setCombo = GTK_COMBO_BOX_TEXT(gtk_builder_get_object(builder, "setCombo")); ui_settings.iterationsSp = GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "iterationsSp")); ui_settings.threadsSp = GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "threadsSp")); ui_settings.colorFromBtn = GTK_BUTTON(gtk_builder_get_object(builder, "colorFromBtn")); @@ -26,6 +27,8 @@ int main(int argc, char **argv) ui_settings.speedEntry = GTK_ENTRY(gtk_builder_get_object(builder, "speedEntry")); ui_settings.modeCPURd = GTK_RADIO_BUTTON(gtk_builder_get_object(builder, "modeCPURd")); ui_settings.modeGPURd = GTK_RADIO_BUTTON(gtk_builder_get_object(builder, "modeGPURd")); + ui_settings.fpuCombo = GTK_COMBO_BOX_TEXT(gtk_builder_get_object(builder, "fpuCombo")); + ui_settings.fmaCb = GTK_COMBO_BOX_TEXT(gtk_builder_get_object(builder, "fmaCb")); ui_settings.exportCb = GTK_CHECK_BUTTON(gtk_builder_get_object(builder, "exportCb")); ui_settings.gifRd = GTK_RADIO_BUTTON(gtk_builder_get_object(builder, "gifRd")); ui_settings.widthSp = GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "widthSp")); @@ -62,17 +65,15 @@ int main(int argc, char **argv) gtk_spin_button_set_range(ui_settings.fpsVideoSp, 1, 60); gtk_spin_button_set_range(ui_settings.bitrateSp, 1, 65535); - g_signal_connect(ui_settings.iterationsSp, "value-changed", G_CALLBACK(on_iterationsSp_valueChanged), NULL); - g_signal_connect(ui_settings.threadsSp, "value-changed", G_CALLBACK(on_threadsSp_valueChanged), NULL); + gtk_combo_box_text_append(ui_settings.setCombo, NULL, "Mandelbrot"); + gtk_combo_box_text_append(ui_settings.setCombo, NULL, "Julia"); + + gtk_combo_box_text_append(ui_settings.fpuCombo, NULL, "32 bit"); + gtk_combo_box_text_append(ui_settings.fpuCombo, NULL, "64 bit"); + gtk_combo_box_text_append(ui_settings.fpuCombo, NULL, "128 bit"); + g_signal_connect(ui_settings.colorFromBtn, "clicked", G_CALLBACK(on_colorFromBtn_clicked), NULL); g_signal_connect(ui_settings.colorToBtn, "clicked", G_CALLBACK(on_colorToBtn_clicked), NULL); - g_signal_connect(ui_settings.exportCb, "toggled", G_CALLBACK(on_exportCb_toggled), NULL); - g_signal_connect(ui_settings.widthSp, "value-changed", G_CALLBACK(on_widthSp_valueChanged), NULL); - g_signal_connect(ui_settings.heightSp, "value-changed", G_CALLBACK(on_heightSp_valueChanged), NULL); - g_signal_connect(ui_settings.fpsRenderSp, "value-changed", G_CALLBACK(on_fpsRenderSp_valueChanged), NULL); - g_signal_connect(ui_settings.fpsVideoSp, "value-changed", G_CALLBACK(on_fpsVideoSp_valueChanged), NULL); - g_signal_connect(ui_settings.bitrateSp, "value-changed", G_CALLBACK(on_bitrateSp_valueChanged), NULL); - g_signal_connect(ui_settings.exportTf, "changed", G_CALLBACK(on_exportTf_changed), NULL); g_signal_connect(ui_settings.startBtn, "clicked", G_CALLBACK(on_startBtn_clicked), NULL); g_signal_connect(ui_settings.exitBtn, "clicked", G_CALLBACK(on_exitBtn_clicked), NULL); @@ -82,17 +83,6 @@ int main(int argc, char **argv) return 0; } -void on_iterationsSp_valueChanged() -{ - config.config_cpu.iterations = gtk_spin_button_get_value(ui_settings.iterationsSp); - config.config_opencl.iterations = gtk_spin_button_get_value(ui_settings.iterationsSp); -} - -void on_threadsSp_valueChanged() -{ - config.config_cpu.threads = gtk_spin_button_get_value(ui_settings.threadsSp); -} - void on_colorFromBtn_clicked() { currentColor = COLOR_FROM; @@ -105,48 +95,34 @@ void on_colorToBtn_clicked() gtk_dialog_run(ui_settings.colorDialog); } -void on_exportCb_toggled() +void on_startBtn_clicked() { - config.video = gtk_toggle_button_get_active(ui_settings.exportCb); -} + config.config_cpu.iterations = gtk_spin_button_get_value(ui_settings.iterationsSp); + config.config_opencl.iterations = gtk_spin_button_get_value(ui_settings.iterationsSp); + + config.config_cpu.threads = gtk_spin_button_get_value(ui_settings.threadsSp); + + config.config_opencl.fma = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ui_settings.fmaCb)); + + config.video = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ui_settings.exportCb)); -void on_exportTf_changed() -{ config.path = CHAR_PTR(gtk_entry_get_text(ui_settings.exportTf)); -} -void on_widthSp_valueChanged() -{ config.width = gtk_spin_button_get_value(ui_settings.widthSp); config.config_cpu.width = gtk_spin_button_get_value(ui_settings.widthSp); config.config_opencl.width = gtk_spin_button_get_value(ui_settings.widthSp); -} -void on_heightSp_valueChanged() -{ config.height = gtk_spin_button_get_value(ui_settings.heightSp); config.config_cpu.height = gtk_spin_button_get_value(ui_settings.heightSp); config.config_opencl.height = gtk_spin_button_get_value(ui_settings.heightSp); -} -void on_fpsRenderSp_valueChanged() -{ config.config_cpu.renderFPS = gtk_spin_button_get_value(ui_settings.fpsRenderSp); config.config_opencl.renderFPS = gtk_spin_button_get_value(ui_settings.fpsRenderSp); -} -void on_fpsVideoSp_valueChanged() -{ config.videoFPS = gtk_spin_button_get_value(ui_settings.fpsVideoSp); -} -void on_bitrateSp_valueChanged() -{ config.bitrate = gtk_spin_button_get_value(ui_settings.bitrateSp); -} -void on_startBtn_clicked() -{ double x, y, speed; sscanf(gtk_entry_get_text(ui_settings.zoomToXEntry), "%lf", &x); sscanf(gtk_entry_get_text(ui_settings.zoomToYEntry), "%lf", &y); @@ -157,14 +133,33 @@ void on_startBtn_clicked() config.config_opencl.to_x = x; config.config_opencl.to_y = y; config.config_opencl.speed = speed; - //printf("config {\n\t.iterations = %u\n\t.tox = %f\n\t.toy = %f\n\t.video = %u\n\t.filetype = %u\n\t.width = %u\n\t.height = %u\n\t.renderFPS = %u\n\t.videoFPS = %u\n\t.bitrate = %u\n\t.path = %s\n}\n", config.iterations, x, y, config.video, 0, config.width, config.height, config.renderFPS, config.videoFPS, config.bitrate, config.path); - - // TODO: implement selection of sets correctly - config.config_cpu.set_func = mandelbrot_r; - config.config_opencl.set_func = mandelbrot_r; - // TODO: implement selection of render mode correctly - config.mode = MODE_CPU; + config.mode = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ui_settings.modeGPURd)); + //config.mode = MODE_CPU; + + if (strcmp(gtk_combo_box_text_get_active_text(ui_settings.setCombo), "Mandelbrot") == 0) + { + config.config_cpu.set_func = mandelbrot_r; + config.config_opencl.set_func = SFUNC_MANDELBROT; + } + else if (strcmp(gtk_combo_box_text_get_active_text(ui_settings.setCombo), "Julia") == 0) + { + config.config_cpu.set_func = julia; + config.config_opencl.set_func = SFUNC_JULIA; + } + + if (strcmp(gtk_combo_box_text_get_active_text(ui_settings.fpuCombo), "32 bit") == 0) + { + config.config_opencl.fpu = OPENCL_FPU_32; + } + else if (strcmp(gtk_combo_box_text_get_active_text(ui_settings.fpuCombo), "64 bit") == 0) + { + config.config_opencl.fpu = OPENCL_FPU_64; + } + else if (strcmp(gtk_combo_box_text_get_active_text(ui_settings.fpuCombo), "128 bit") == 0) + { + config.config_opencl.fpu = OPENCL_FPU_128; + } init_render(&config); show_render(); |