diff options
Diffstat (limited to 'src/render_cpu.c')
-rw-r--r-- | src/render_cpu.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/src/render_cpu.c b/src/render_cpu.c index f3bf28e..5065d4d 100644 --- a/src/render_cpu.c +++ b/src/render_cpu.c @@ -11,10 +11,9 @@ void init_cpu(CpuConfig *config) { config_cpu = config; - delta = glutGet(GLUT_ELAPSED_TIME); x_min_s = -2.0; x_max_s = 1.0; - y_min_s= -1.0; + y_min_s = -1.0; y_max_s = 1.0; x_min = x_min_s; x_max = x_max_s; @@ -27,7 +26,7 @@ void init_cpu(CpuConfig *config) void render_cpu(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glBindTexture(GL_TEXTURE_2D, tex); + glBindTexture(GL_TEXTURE_2D, config_cpu->tex); glEnable(GL_TEXTURE_2D); glBegin(GL_QUADS); @@ -52,6 +51,7 @@ void calculate(d64 x_min, d64 y_min, d64 x_max, d64 y_max, u32 (*sfunc) (d64, d6 pthread_create(&thread, NULL, calculate_t, (void *)&args[i]); } pthread_join(thread, NULL); + free(args); } void calculate_t(void *args) @@ -71,27 +71,29 @@ void calculate_t(void *args) } } -long double zoom_func(d64 ft, d64 s) -{ - return (s - expl(-ft)); -} - void idle_cpu(void) { + static int t_old; + int t = 0, delta = 0; + do + { + t = glutGet(GLUT_ELAPSED_TIME); + delta = t - t_old; + } + while(delta < 16); // TODO: Hardcoded FPS + t_old = t; + calculate(x_min, y_min, x_max, y_max, config_cpu->set_func, config_cpu->arr); //glGenTextures(1, &tex); - glBindTexture(GL_TEXTURE_2D, tex); + glBindTexture(GL_TEXTURE_2D, config_cpu->tex); //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, config_cpu->width, config_cpu->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, config_cpu->arr); glBindTexture(GL_TEXTURE_2D, 0); - int t = glutGet(GLUT_ELAPSED_TIME); - dt = (t - delta) / 1000.0; - delta = t; - ft+=(config_cpu->speed*dt); - x_min = x_min_s + zoom_func(ft, (d64)2.0 + config_cpu->to_x); - y_min = y_min_s + zoom_func(ft, (d64)1.0 + config_cpu->to_y); - x_max = x_max_s - zoom_func(ft, (d64)1.0 - config_cpu->to_x); - y_max = y_max_s - zoom_func(ft, (d64)1.0 - config_cpu->to_y); + ft+=(config_cpu->speed*(delta/1000.0)); + x_min = x_min_s + config_cpu->zoom_func(ft, (d64)2.0 + config_cpu->to_x); + y_min = y_min_s + config_cpu->zoom_func(ft, (d64)1.0 + config_cpu->to_y); + x_max = x_max_s - config_cpu->zoom_func(ft, (d64)1.0 - config_cpu->to_x); + y_max = y_max_s - config_cpu->zoom_func(ft, (d64)1.0 - config_cpu->to_y); glutPostRedisplay(); } |