Compare commits

...

2 Commits

Author SHA1 Message Date
4d26053a70 Merge branch 'opengl' of git.shimatta.de:mhu/mandelbrot into opengl 2019-09-30 22:19:05 +02:00
2b08a61fed Test 2019-09-26 18:58:49 +02:00
2 changed files with 20 additions and 10 deletions

View File

@ -10,8 +10,8 @@ pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
pkg_check_modules(CAIRO REQUIRED cairo)
find_package(OpenCL REQUIRED)
find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)
add_subdirectory(glade)
@ -34,3 +34,4 @@ message(STATUS "OpenCL found: ${OPENCL_FOUND}")
message(STATUS "OpenCL includes: ${OPENCL_INCLUDE_DIRS}")
message(STATUS "OpenCL CXX includes: ${OPENCL_HAS_CPP_BINDINGS}")
message(STATUS "OpenCL libraries: ${OPENCL_LIBRARIES}")
message(STATUS "OpenGL libraries: ${OPENGL_gl_LIBRARIES}")

View File

@ -48,13 +48,13 @@ static gboolean on_main_window_close(GtkWidget *window, gpointer data)
return FALSE;
}
void check_error(cl_int error)
{
if (error != CL_SUCCESS) {
printf("OpenCL call failed with error %d\n", (int)error);
exit(error);
}
}
#define check_error(error) \
do { \
if (error != CL_SUCCESS) { \
printf("OpenCL call failed with error %d. %s:%d\n", (int)error, __func__, __LINE__); \
exit(error); \
} } while(0)
void load_kernel_from_file(char *file, char **src)
{
@ -189,6 +189,8 @@ static int calculate_mandelbrot(struct canvas_buffer *buff)
clEnqueueReadBuffer(queue, dat_buff, CL_TRUE, 0, data_size*3, buff->mandelbrot_buffer, 0, NULL, NULL);
printf("Calculation finished!\n");
ret = clFlush(queue);
ret = clFinish(queue);
ret = clReleaseKernel(kernel);
@ -353,7 +355,14 @@ int main(int argc, char **argv)
mandelbrot_buff.height = 3000;
mandelbrot_buff.iterations = 200;
mandelbrot_buff.mandelbrot_buffer = NULL;
calculate_mandelbrot(&mandelbrot_buff);
//calculate_mandelbrot(&mandelbrot_buff);
gtk_gl_area_make_current(glarea);
GError *error = NULL;
g_signal_connect(glarea, "render", G_CALLBACK(render), NULL);