aboutsummaryrefslogtreecommitdiff
path: root/src/render_cpu.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/render_cpu.c')
-rw-r--r--src/render_cpu.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/render_cpu.c b/src/render_cpu.c
index 9370461..f3bf28e 100644
--- a/src/render_cpu.c
+++ b/src/render_cpu.c
@@ -5,12 +5,23 @@
* Author: Superleo1810
*/
-#include "render.h"
+#include "render_cpu.h"
#define HAVE_STRUCT_TIMESPEC
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_max_s = 1.0;
+ x_min = x_min_s;
+ x_max = x_max_s;
+ y_min = y_min_s;
+ y_max = y_max_s;
+
+ calculate(x_min, y_min, x_max, y_max, config_cpu->set_func, config_cpu->arr);
}
void render_cpu(void)
@@ -21,9 +32,9 @@ void render_cpu(void)
glBegin(GL_QUADS);
glTexCoord2i(0, 0); glVertex2i(0, 0);
- glTexCoord2i(0, 1); glVertex2i(0, _config->height);
- glTexCoord2i(1, 1); glVertex2i(_config->width, _config->height);
- glTexCoord2i(1, 0); glVertex2i(_config->width, 0);
+ glTexCoord2i(0, 1); glVertex2i(0, config_cpu->height);
+ glTexCoord2i(1, 1); glVertex2i(config_cpu->width, config_cpu->height);
+ glTexCoord2i(1, 0); glVertex2i(config_cpu->width, 0);
glEnd();
glDisable(GL_TEXTURE_2D);
@@ -50,7 +61,7 @@ void calculate_t(void *args)
u32 iterations;
for (u32 y = (config_cpu->height/_args->tc)*(_args->tid); y < config_cpu->height; y++)
{
- for (u32 x = 0; x < _config->width; x++)
+ for (u32 x = 0; x < config_cpu->width; x++)
{
x_math = _args->x_min + ((d64) x * (_args->x_max - _args->x_min)) / config_cpu->width;
y_math = _args->y_min + ((d64) (config_cpu->height - y) * (_args->y_max - _args->y_min)) / config_cpu->height;
@@ -72,7 +83,7 @@ void idle_cpu(void)
glBindTexture(GL_TEXTURE_2D, 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, s_arr);
+ 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;