Quellcode durchsuchen

Some random format things

Karl Zylinski vor 6 Monaten
Ursprung
Commit
75aad76d41
3 geänderte Dateien mit 7 neuen und 15 gelöschten Zeilen
  1. 1 0
      README.md
  2. 3 9
      backend_d3d11.odin
  3. 3 6
      karl2d.odin

+ 1 - 0
README.md

@@ -16,6 +16,7 @@ Might not be included:
 
 Here follows my near-future TODO list
 
+* Fix the depedency on D3D stuff so we can move load_shader etc
 * Is the 1/zoom in set_camera wrong? Is the matrix multiply order wrong? Hmmmm...
 * Textures: Make the sampler state configurable
 * Textures D3D11: Do we need the SRV in the texture?

+ 3 - 9
backend_d3d11.odin

@@ -158,10 +158,6 @@ d3d11_init :: proc(state: rawptr, window_handle: Window_Handle, swapchain_width,
 		ComparisonFunc = .NEVER,
 	}
 	s.device->CreateSamplerState(&sampler_desc, &s.sampler_state)
-
-	
-
-	
 }
 
 d3d11_shutdown :: proc() {
@@ -270,10 +266,6 @@ D3D11_State :: struct {
 	vertex_buffer_gpu: ^d3d11.IBuffer,
 
 	vertex_buffer_offset: int,
-	
-	batch_shader: Shader_Handle,
-
-	view_proj: Mat4,
 }
 
 vec3_from_vec2 :: proc(v: Vec2) -> Vec3 {
@@ -627,7 +619,7 @@ d3d11_load_shader :: proc(shader: string, layout_formats: []Shader_Input_Format
 				switch i.type {
 				case .F32: i.format = .R32_Float
 				case .Vec2: i.format = .RG32_Float
-				case .Vec3: i.format = .RGBA32_Float
+				case .Vec3: i.format = .RGB32_Float
 				case .Vec4: i.format = .RGBA32_Float
 				}
 			}
@@ -688,6 +680,7 @@ dxgi_format_from_shader_input_format :: proc(f: Shader_Input_Format) -> dxgi.FOR
 	case .RGBA32_Float: return .R32G32B32A32_FLOAT
 	case .RGBA8_Norm: return .R8G8B8A8_UNORM
 	case .RGBA8_Norm_SRGB: return .R8G8B8A8_UNORM_SRGB
+	case .RGB32_Float: return .R32G32B32_FLOAT
 	case .RG32_Float: return .R32G32_FLOAT
 	case .R32_Float: return .R32_FLOAT
 	}
@@ -702,6 +695,7 @@ shader_input_format_size :: proc(f: Shader_Input_Format) -> int {
 	case .RGBA32_Float: return 32
 	case .RGBA8_Norm: return 4
 	case .RGBA8_Norm_SRGB: return 4
+	case .RGB32_Float: return 12
 	case .RG32_Float: return 8
 	case .R32_Float: return 4
 	}

+ 3 - 6
karl2d.odin

@@ -56,11 +56,7 @@ init :: proc(window_width: int, window_height: int, window_title: string,
 	slice.fill(white_rect[:], 255)
 	s.shape_drawing_texture = rb.load_texture(white_rect[:], 16, 16)
 
-	s.default_shader = rb.load_shader(string(DEFAULT_SHADER_SOURCE), {
-		.RG32_Float,
-		.RG32_Float,
-		.RGBA8_Norm,
-	})
+	s.default_shader = rb.load_shader(string(DEFAULT_SHADER_SOURCE))
 
 	return s
 }
@@ -622,7 +618,7 @@ _batch_vertex :: proc(v: Vec2, uv: Vec2, color: Color) {
 	mem.set(&s.vertex_buffer_cpu[base_offset], 0, shd.vertex_size)
 
 	if pos_offset != -1 {
-		(^Vec2)(&s.vertex_buffer_cpu[base_offset + pos_offset])^ = v
+		(^Vec2)(&s.vertex_buffer_cpu[base_offset + pos_offset])^ = {v.x, v.y}
 	}
 
 	if uv_offset != -1 {
@@ -694,6 +690,7 @@ Shader_Input_Format :: enum {
 	RGBA32_Float,
 	RGBA8_Norm,
 	RGBA8_Norm_SRGB,
+	RGB32_Float,
 	RG32_Float,
 	R32_Float,
 }