/* * render.c * * Created on: 15.01.2018 * Author: Superleo1810 */ #include "render.h" //#define HAVE_STRUCT_TIMESPEC #include void init_render(config_t *config) { _config = config; s_arr = (u32 *) malloc((_config->width) * (_config->height) * sizeof(u32)); _config->arr = s_arr; //glutInit(0, NULL); glutInitWindowPosition(0, 0); glutInitWindowSize(_config->width, _config->height); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); glutCreateWindow("Renderer"); 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); _config->tex = tex; _config->zoom_func = zoom_func; switch(_config->mode) { case MODE_CPU: init_cpu(_config); glutDisplayFunc(render_cpu); if (_config->zoomSpecific) { glutIdleFunc(idle_cpu); } else { glutIdleFunc(idle_cpu_dummy); glutKeyboardFunc(keyboard_cpu); glutMouseFunc(mouse_cpu); } break; case MODE_OPENCL: init_opencl(_config); glutDisplayFunc(render_opencl); if (_config->zoomSpecific) { glutIdleFunc(idle_opencl); } else { glutIdleFunc(idle_opencl_dummy); glutKeyboardFunc(keyboard_opencl); glutMouseFunc(mouse_opencl); } break; } glutMainLoop(); } void show_render() { } d64 zoom_func(d64 ft, d64 s) { return (s - expl(-ft)); }