aboutsummaryrefslogtreecommitdiff
path: root/src/render.c
blob: 69b46e0013c34ea947a70f92fe668a76e60eeef6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 * render.c
 *
 *  Created on: 15.01.2018
 *      Author: Superleo1810
 */

#include "render.h"
#define HAVE_STRUCT_TIMESPEC
#include <pthread.h>

void init_render(Config *config)
{
	s_arr = (u32 *) malloc((_config->width) * (_config->height) * sizeof(u32));
	//glutInit(0, NULL);
	glutInitWindowPosition(0, 0);
	glutInitWindowSize(_config->width, _config->height);
	glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
	glutCreateWindow("Renderer");

	if (_config->mode)
	{
		glutDisplayFunc(render_cpu);
		glutIdleFunc(idle_cpu);
		init_cpu(&_config->config_cpu);
	}
	else
	{
		glutDisplayFunc(render_opencl);
		glutIdleFunc(idle_opencl);
		init_opencl(&_config->config_opencl);
	}

	glGenTextures(1, &tex);
	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->width, _config->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, s_arr);
	glBindTexture(GL_TEXTURE_2D, 0);
	//glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _config->width, _config->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, s_arr);

	glMatrixMode(GL_PROJECTION);
	glOrtho(0, _config->width, 0, _config->height, -1, 1);
	glMatrixMode(GL_MODELVIEW);
	glutMainLoop();
}

void show_render()
{

}