render_backend_interface.odin 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package karl2d
  2. Shader_Constant_Buffer_Desc :: struct {
  3. name: string,
  4. size: int,
  5. variables: []Shader_Constant_Buffer_Variable_Desc,
  6. }
  7. Shader_Constant_Buffer_Variable_Desc :: struct {
  8. name: string,
  9. loc: Shader_Constant_Location,
  10. }
  11. Shader_Desc :: struct {
  12. constant_buffers: []Shader_Constant_Buffer_Desc,
  13. inputs: []Shader_Input,
  14. }
  15. Render_Backend_Interface :: struct {
  16. state_size: proc() -> int,
  17. init: proc(state: rawptr, window_handle: Window_Handle, swapchain_width, swapchain_height: int, allocator := context.allocator),
  18. shutdown: proc(),
  19. clear: proc(color: Color),
  20. present: proc(),
  21. draw: proc(shader: Shader, texture: Texture_Handle, view_proj: Mat4, scissor: Maybe(Rect), vertex_buffer: []u8),
  22. set_internal_state: proc(state: rawptr),
  23. create_texture: proc(width: int, height: int, format: Pixel_Format) -> Texture_Handle,
  24. load_texture: proc(data: []u8, width: int, height: int, format: Pixel_Format) -> Texture_Handle,
  25. update_texture: proc(handle: Texture_Handle, data: []u8, rect: Rect) -> bool,
  26. destroy_texture: proc(handle: Texture_Handle),
  27. 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),
  28. destroy_shader: proc(shader: Shader_Handle),
  29. resize_swapchain: proc(width, height: int),
  30. get_swapchain_width: proc() -> int,
  31. get_swapchain_height: proc() -> int,
  32. batch_vertex: proc(v: Vec2, uv: Vec2, color: Color),
  33. default_shader_vertex_source: proc() -> string,
  34. default_shader_fragment_source: proc() -> string,
  35. }