render_backend_chooser.odin 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package karl2d
  2. CONFIG_RENDER_BACKEND_NAME :: #config(KARL2D_RENDER_BACKEND, "")
  3. when ODIN_OS == .Windows {
  4. DEFAULT_RENDER_BACKEND_NAME :: "d3d11"
  5. AVAILABLE_RENDER_BACKENDS :: "d3d11, gl"
  6. } else when ODIN_OS == .Linux || ODIN_OS == .Darwin {
  7. DEFAULT_RENDER_BACKEND_NAME :: "gl"
  8. AVAILABLE_RENDER_BACKENDS :: "gl"
  9. } else when ODIN_OS == .JS {
  10. DEFAULT_RENDER_BACKEND_NAME :: "webgl"
  11. AVAILABLE_RENDER_BACKENDS :: "webgl"
  12. } else {
  13. DEFAULT_RENDER_BACKEND_NAME :: "nil"
  14. AVAILABLE_RENDER_BACKENDS :: "nil"
  15. }
  16. when CONFIG_RENDER_BACKEND_NAME == "" {
  17. RENDER_BACKEND_NAME :: DEFAULT_RENDER_BACKEND_NAME
  18. } else {
  19. RENDER_BACKEND_NAME :: CONFIG_RENDER_BACKEND_NAME
  20. }
  21. when RENDER_BACKEND_NAME == "gl" {
  22. RENDER_BACKEND :: RENDER_BACKEND_GL
  23. } else when RENDER_BACKEND_NAME == "d3d11" {
  24. RENDER_BACKEND :: RENDER_BACKEND_D3D11
  25. } else when RENDER_BACKEND_NAME == "webgl" {
  26. RENDER_BACKEND :: RENDER_BACKEND_WEBGL
  27. } else when RENDER_BACKEND_NAME == "nil" {
  28. RENDER_BACKEND :: RENDER_BACKEND_NIL
  29. } else {
  30. #panic("'" + RENDER_BACKEND_NAME + "' is not a valid value for 'KARL2D_RENDER_BACKEND' on Operating System " + ODIN_OS_STRING + ". Available backends are: " + AVAILABLE_RENDER_BACKENDS)
  31. }