render_backend_interface.odin 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package karl2d
  2. Shader_Constant_Desc :: struct {
  3. name: string,
  4. size: int,
  5. }
  6. Shader_Texture_Bindpoint_Desc :: struct {
  7. name: string,
  8. }
  9. Shader_Desc :: struct {
  10. constants: []Shader_Constant_Desc,
  11. texture_bindpoints: []Shader_Texture_Bindpoint_Desc,
  12. inputs: []Shader_Input,
  13. }
  14. Render_Backend_Interface :: struct {
  15. state_size: proc() -> int,
  16. init: proc(state: rawptr, window_handle: Window_Handle, swapchain_width, swapchain_height: int, allocator := context.allocator),
  17. shutdown: proc(),
  18. clear: proc(color: Color),
  19. present: proc(),
  20. draw: proc(shader: Shader, bound_textures: []Texture_Handle, scissor: Maybe(Rect), vertex_buffer: []u8),
  21. set_internal_state: proc(state: rawptr),
  22. create_texture: proc(width: int, height: int, format: Pixel_Format) -> Texture_Handle,
  23. load_texture: proc(data: []u8, width: int, height: int, format: Pixel_Format) -> Texture_Handle,
  24. update_texture: proc(handle: Texture_Handle, data: []u8, rect: Rect) -> bool,
  25. destroy_texture: proc(handle: Texture_Handle),
  26. set_texture_filter: proc(
  27. handle: Texture_Handle,
  28. scale_down_filter: Texture_Filter,
  29. scale_up_filter: Texture_Filter,
  30. mip_filter: Texture_Filter,
  31. ),
  32. load_shader: proc(vertex_shader_source: string, pixel_shader_source: string, desc_allocator := context.temp_allocator, layout_formats: []Pixel_Format = {}) -> (handle: Shader_Handle, desc: Shader_Desc),
  33. destroy_shader: proc(shader: Shader_Handle),
  34. resize_swapchain: proc(width, height: int),
  35. get_swapchain_width: proc() -> int,
  36. get_swapchain_height: proc() -> int,
  37. flip_z: proc() -> bool,
  38. default_shader_vertex_source: proc() -> string,
  39. default_shader_fragment_source: proc() -> string,
  40. }