Jelajahi Sumber

Render backend chooser

Karl Zylinski 4 bulan lalu
induk
melakukan
a5fb964449
4 mengubah file dengan 25 tambahan dan 25 penghapusan
  1. 2 2
      .github/workflows/build.yml
  2. 0 22
      config.odin
  3. 1 1
      karl2d.odin
  4. 22 0
      render_backend_chooser.odin

+ 2 - 2
.github/workflows/build.yml

@@ -27,10 +27,10 @@ jobs:
         run: odin build examples/minimal -vet -strict-style -debug
 
       - name: minimal (gl)
-        run: odin build examples/minimal -vet -strict-style -define:KARL2D_BACKEND=gl
+        run: odin build examples/minimal -vet -strict-style -define:KARL2D_RENDER_BACKEND=gl
 
       - name: minimal (gl, debug)
-        run: odin build examples/minimal -vet -strict-style -debug -define:KARL2D_BACKEND=gl
+        run: odin build examples/minimal -vet -strict-style -debug -define:KARL2D_RENDER_BACKEND=gl
 
       - name: snake
         run: odin build examples/snake -vet -strict-style

+ 0 - 22
config.odin

@@ -1,22 +0,0 @@
-package karl2d
-
-when ODIN_OS == .Windows {
-	DEFAULT_BACKEND :: RENDER_BACKEND_INTERFACE_D3D11
-} else {
-	DEFAULT_BACKEND :: RENDER_BACKEND_INTERFACE_GL
-}
-
-CUSTOM_BACKEND_STR :: #config(KARL2D_BACKEND, "")
-
-when CUSTOM_BACKEND_STR != "" {
-	when CUSTOM_BACKEND_STR == "gl" {
-		BACKEND :: RENDER_BACKEND_INTERFACE_GL
-	} else when CUSTOM_BACKEND_STR == "d3d11" {
-		BACKEND :: RENDER_BACKEND_INTERFACE_D3D11
-	} else {
-		#panic(CUSTOM_BACKEND_STR + " is not a valid value for KARL2D_BACKEND. Available backends are: gl, d3d11")
-		BACKEND :: DEFAULT_BACKEND
-	}
-} else {
-	BACKEND :: DEFAULT_BACKEND
-}

+ 1 - 1
karl2d.odin

@@ -59,7 +59,7 @@ init :: proc(window_width: int, window_height: int, window_title: string,
 	s.window = win.window_handle()
 
 	// See `config.odin` for how this is picked.
-	s.rb = BACKEND
+	s.rb = RENDER_BACKEND
 
 	// Depending on backend the depth is counted in one of two ways. It can be counted from `1` and
 	// to lower numbers. Or from `-1` and to higher numbers.

+ 22 - 0
render_backend_chooser.odin

@@ -0,0 +1,22 @@
+package karl2d
+
+when ODIN_OS == .Windows {
+	DEFAULT_RENDER_BACKEND :: RENDER_BACKEND_INTERFACE_D3D11
+} else {
+	DEFAULT_RENDER_BACKEND :: RENDER_BACKEND_INTERFACE_GL
+}
+
+CUSTOM_RENDER_BACKEND_STR :: #config(KARL2D_RENDER_BACKEND, "")
+
+when CUSTOM_RENDER_BACKEND_STR != "" {
+	when CUSTOM_RENDER_BACKEND_STR == "gl" {
+		RENDER_BACKEND :: RENDER_BACKEND_INTERFACE_GL
+	} else when CUSTOM_RENDER_BACKEND_STR == "d3d11" {
+		RENDER_BACKEND :: RENDER_BACKEND_INTERFACE_D3D11
+	} else {
+		#panic(CUSTOM_RENDER_BACKEND_STR + " is not a valid value for KARL2D_BACKEND. Available backends are: gl, d3d11")
+		RENDER_BACKEND :: DEFAULT_RENDER_BACKEND
+	}
+} else {
+	RENDER_BACKEND :: DEFAULT_RENDER_BACKEND
+}