rasteriver.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef RASTERIVER_H
  2. #define RASTERIVER_H
  3. #include "functions.h"
  4. #include "values.h"
  5. #include "custom_types.h"
  6. #include "math.h"
  7. #include "sourparse.h"
  8. #include <SDL2/SDL.h>
  9. #include <CL/cl.h>
  10. typedef struct {
  11. // rendering (non SDL)
  12. RI_texture *frame_buffer;
  13. double *z_buffer;
  14. RI_vector_2 z_buffer_resolution;
  15. double (*default_fragment_shader) (int pixel_x, int pixel_y, RI_vector_3f v_pos_0, RI_vector_3f v_pos_1, RI_vector_3f v_pos_2, RI_vector_3f normal, RI_vector_2f uv, uint32_t color);
  16. void (*default_vertex_shader) (RI_vector_3f *v_pos_0, RI_vector_3f *v_pos_1, RI_vector_3f *v_pos_2, double horizontal_fov_factor, double vertical_fov_factor);
  17. void (*perspective_vertex_shader) (RI_vector_3f *v_pos_0, RI_vector_3f *v_pos_1, RI_vector_3f *v_pos_2, double horizontal_fov_factor, double vertical_fov_factor);
  18. void (*orthographic_vertex_shader) (RI_vector_3f *v_pos_0, RI_vector_3f *v_pos_1, RI_vector_3f *v_pos_2, double horizontal_fov_factor, double vertical_fov_factor);
  19. int window_width;
  20. int window_height;
  21. char *window_title;
  22. // SDL specific
  23. SDL_Window *window;
  24. SDL_Renderer *renderer;
  25. SDL_Texture *texture;
  26. SDL_Event event;
  27. // RasterIver
  28. RI_mesh *loaded_meshes;
  29. RI_texture *loaded_textures;
  30. RI_material *materials;
  31. RI_actor *actors;
  32. RI_scene *scenes;
  33. RI_texture error_texture;
  34. RI_texture error_bump_map;
  35. RI_texture error_normal_map;
  36. RI_material error_material;
  37. RI_mesh error_mesh;
  38. // miscellaneous
  39. int loaded_mesh_count;
  40. int loaded_texture_count;
  41. int material_count;
  42. int actor_count;
  43. int scene_count;
  44. int running;
  45. int frame;
  46. char* prefix;
  47. // memory manager
  48. RI_memory_allocation* allocation_table;
  49. int debug_memory;
  50. int allocation_search_limit;
  51. int current_allocation_index;
  52. int allocation_table_length;
  53. // OpenCL
  54. cl_platform_id cl_platform;
  55. cl_uint cl_number_of_platforms;
  56. cl_device_id cl_device;
  57. cl_uint cl_number_of_devices;
  58. cl_context cl_context;
  59. cl_command_queue cl_command_queue;
  60. } RasterIver;
  61. RasterIver* RI_get_ri();
  62. #endif