render_backend_nil.odin 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #+build js
  2. #+private file
  3. package karl2d
  4. @(private="package")
  5. RENDER_BACKEND_NIL :: Render_Backend_Interface {
  6. state_size = rbnil_state_size,
  7. init = rbnil_init,
  8. shutdown = rbnil_shutdown,
  9. clear = rbnil_clear,
  10. present = rbnil_present,
  11. draw = rbnil_draw,
  12. resize_swapchain = rbnil_resize_swapchain,
  13. get_swapchain_width = rbnil_get_swapchain_width,
  14. get_swapchain_height = rbnil_get_swapchain_height,
  15. flip_z = rbnil_flip_z,
  16. set_internal_state = rbnil_set_internal_state,
  17. create_texture = rbnil_create_texture,
  18. load_texture = rbnil_load_texture,
  19. update_texture = rbnil_update_texture,
  20. destroy_texture = rbnil_destroy_texture,
  21. texture_needs_vertical_flip = rbnil_texture_needs_vertical_flip,
  22. create_render_texture = rbnil_create_render_texture,
  23. destroy_render_target = rbnil_destroy_render_target,
  24. set_texture_filter = rbnil_set_texture_filter,
  25. load_shader = rbnil_load_shader,
  26. destroy_shader = rbnil_destroy_shader,
  27. default_shader_vertex_source = rbnil_default_shader_vertex_source,
  28. default_shader_fragment_source = rbnil_default_shader_fragment_source,
  29. }
  30. import "core:log"
  31. rbnil_state_size :: proc() -> int {
  32. return 0
  33. }
  34. rbnil_init :: proc(state: rawptr, window_handle: Window_Handle, swapchain_width, swapchain_height: int, allocator := context.allocator) {
  35. log.info("Render Backend nil init")
  36. }
  37. rbnil_shutdown :: proc() {
  38. log.info("Render Backend nil shutdown")
  39. }
  40. rbnil_clear :: proc(render_texture: Render_Target_Handle, color: Color) {
  41. }
  42. rbnil_present :: proc() {
  43. }
  44. rbnil_draw :: proc(
  45. shd: Shader,
  46. render_texture: Render_Target_Handle,
  47. bound_textures: []Texture_Handle,
  48. scissor: Maybe(Rect),
  49. blend_mode: Blend_Mode,
  50. vertex_buffer: []u8,
  51. ) {
  52. }
  53. rbnil_resize_swapchain :: proc(w, h: int) {
  54. }
  55. rbnil_get_swapchain_width :: proc() -> int {
  56. return 0
  57. }
  58. rbnil_get_swapchain_height :: proc() -> int {
  59. return 0
  60. }
  61. rbnil_flip_z :: proc() -> bool {
  62. return false
  63. }
  64. rbnil_set_internal_state :: proc(state: rawptr) {
  65. }
  66. rbnil_create_texture :: proc(width: int, height: int, format: Pixel_Format) -> Texture_Handle {
  67. return {}
  68. }
  69. rbnil_load_texture :: proc(data: []u8, width: int, height: int, format: Pixel_Format) -> Texture_Handle {
  70. return {}
  71. }
  72. rbnil_update_texture :: proc(th: Texture_Handle, data: []u8, rect: Rect) -> bool {
  73. return true
  74. }
  75. rbnil_destroy_texture :: proc(th: Texture_Handle) {
  76. }
  77. rbnil_texture_needs_vertical_flip :: proc(th: Texture_Handle) -> bool {
  78. return false
  79. }
  80. rbnil_create_render_texture :: proc(width: int, height: int) -> (Texture_Handle, Render_Target_Handle) {
  81. return {}, {}
  82. }
  83. rbnil_destroy_render_target :: proc(render_target: Render_Target_Handle) {
  84. }
  85. rbnil_set_texture_filter :: proc(
  86. th: Texture_Handle,
  87. scale_down_filter: Texture_Filter,
  88. scale_up_filter: Texture_Filter,
  89. mip_filter: Texture_Filter,
  90. ) {
  91. }
  92. rbnil_load_shader :: proc(
  93. vs_source: []byte,
  94. fs_source: []byte,
  95. desc_allocator := frame_allocator,
  96. layout_formats: []Pixel_Format = {},
  97. ) -> (
  98. handle: Shader_Handle,
  99. desc: Shader_Desc,
  100. ) {
  101. return {}, {}
  102. }
  103. rbnil_destroy_shader :: proc(h: Shader_Handle) {
  104. }
  105. rbnil_default_shader_vertex_source :: proc() -> []byte {
  106. return {}
  107. }
  108. rbnil_default_shader_fragment_source :: proc() -> []byte {
  109. return {}
  110. }