Selaa lähdekoodia

Got rid of some old api -> backend aliases

Karl Zylinski 6 kuukautta sitten
vanhempi
sitoutus
79210632c2
2 muutettua tiedostoa jossa 54 lisäystä ja 128 poistoa
  1. 8 68
      backend_d3d11.odin
  2. 46 60
      karl2d.odin

+ 8 - 68
backend_d3d11.odin

@@ -269,9 +269,8 @@ D3D11_State :: struct {
 	framebuffer: ^d3d11.ITexture2D,
 	blend_state: ^d3d11.IBlendState,
 	sampler_state: ^d3d11.ISamplerState,
-	default_shader: Shader_Handle,
 
-	textures: hm.Handle_Map(_Texture, Texture_Handle, 1024*10),
+	textures: hm.Handle_Map(D3D11_Texture, Texture_Handle, 1024*10),
 	shaders: hm.Handle_Map(D3D11_Shader, Shader_Handle, 1024*10),
 
 	info_queue: ^d3d11.IInfoQueue,
@@ -284,8 +283,11 @@ D3D11_State :: struct {
 	view_proj: Mat4,
 }
 
-
-
+vec3_from_vec2 :: proc(v: Vec2) -> Vec3 {
+	return {
+		v.x, v.y, 0,
+	}
+}
 
 Color_F32 :: [4]f32
 
@@ -304,7 +306,7 @@ d3d11_clear :: proc(color: Color) {
 	s.device_context->ClearDepthStencilView(s.depth_buffer_view, {.DEPTH}, 1, 0)
 }
 
-_Texture :: struct {
+D3D11_Texture :: struct {
 	handle: Texture_Handle,
 	tex: ^d3d11.ITexture2D,
 	view: ^d3d11.IShaderResourceView,
@@ -334,7 +336,7 @@ d3d11_load_texture :: proc(data: []u8, width: int, height: int) -> Texture_Handl
 	texture_view: ^d3d11.IShaderResourceView
 	s.device->CreateShaderResourceView(texture, nil, &texture_view)
 
-	tex := _Texture {
+	tex := D3D11_Texture {
 		tex = texture,
 		view = texture_view,
 	}
@@ -364,62 +366,6 @@ create_vertex_input_override :: proc(val: $T) -> Shader_Input_Value_Override {
 	return res
 }
 
-
-_draw_circle :: proc(center: Vec2, radius: f32, color: Color) {
-}
-
-_draw_line :: proc(start: Vec2, end: Vec2, thickness: f32, color: Color) {
-}
-
-_get_default_shader :: proc() -> Shader_Handle {
-	return s.default_shader
-}
-
-_draw_text :: proc(text: string, pos: Vec2, font_size: f32, color: Color) {
-}
-
-_mouse_button_pressed  :: proc(button: Mouse_Button) -> bool {
-	return false
-}
-
-_mouse_button_released :: proc(button: Mouse_Button) -> bool {
-	return false
-}
-
-_mouse_button_held     :: proc(button: Mouse_Button) -> bool {
-	return false
-}
-
-_mouse_wheel_delta :: proc() -> f32 {
-	return 0
-}
-
-_mouse_position :: proc() -> Vec2 {
-	return {}
-}
-
-_enable_scissor :: proc(x, y, w, h: int) {
-}
-
-_disable_scissor :: proc() {
-}
-
-_screen_to_world :: proc(pos: Vec2, camera: Camera) -> Vec2 {
-	return pos
-}
-
-Vec3 :: [3]f32
-
-vec3_from_vec2 :: proc(v: Vec2) -> Vec3 {
-	return {
-		v.x, v.y, 0,
-	}
-}
-
-_set_scissor_rect :: proc(scissor_rect: Maybe(Rect)) {
-
-}
-
 d3d11_draw :: proc(shd: Shader, texture: Texture_Handle, vertex_buffer: []u8) {
 	if len(vertex_buffer) == 0 {
 		return
@@ -431,12 +377,6 @@ d3d11_draw :: proc(shd: Shader, texture: Texture_Handle, vertex_buffer: []u8) {
 		return
 	}
 
-	/*if shd == nil {
-		shd = hm.get(&s.shaders, s.default_shader)
-		assert(shd != nil, "Failed fetching default shader")
-	}*/
-
-
 	viewport := d3d11.VIEWPORT{
 		0, 0,
 		f32(s.width), f32(s.height),

+ 46 - 60
karl2d.odin

@@ -319,6 +319,14 @@ draw_rect_outline :: proc(r: Rect, thickness: f32, color: Color) {
 	draw_rect(right, color)
 }
 
+draw_circle :: proc(center: Vec2, radius: f32, color: Color) {
+	panic("not implemented")
+}
+
+draw_line :: proc(start: Vec2, end: Vec2, thickness: f32, color: Color) {
+	panic("not implemented")
+}
+
 draw_texture :: proc(tex: Texture, pos: Vec2, tint := WHITE) {
 	draw_texture_ex(
 		tex,
@@ -471,6 +479,43 @@ set_shader_constant_vec2 :: proc(shader: Shader, loc: Shader_Constant_Location,
 	set_shader_constant(shader, loc, val)
 }
 
+get_default_shader :: proc() -> Shader {
+	return s.default_shader
+}
+
+set_scissor_rect :: proc(scissor_rect: Maybe(Rect)) {
+	panic("not implemented")
+}
+
+
+screen_to_world :: proc(pos: Vec2, camera: Camera) -> Vec2 {
+	panic("not implemented")
+}
+
+draw_text :: proc(text: string, pos: Vec2, font_size: f32, color: Color) {
+	
+}
+
+mouse_button_went_down :: proc(button: Mouse_Button) -> bool {
+	panic("not implemented")
+}
+
+mouse_button_went_up :: proc(button: Mouse_Button) -> bool {
+	panic("not implemented")
+}
+
+mouse_button_is_held :: proc(button: Mouse_Button) -> bool {
+	panic("not implemented")
+}
+
+get_mouse_wheel_delta :: proc() -> f32 {
+	panic("not implemented")
+}
+
+get_mouse_position :: proc() -> Vec2 {
+	panic("not implemented")
+}
+
 _batch_vertex :: proc(v: Vec2, uv: Vec2, color: Color) {
 	v := v
 
@@ -511,31 +556,6 @@ _batch_vertex :: proc(v: Vec2, uv: Vec2, color: Color) {
 	
 	s.vertex_buffer_cpu_used += shd.vertex_size
 }
-
-Rendering_Backend :: struct {
-	state_size: proc() -> int,
-	init: proc(state: rawptr, window_handle: uintptr, swapchain_width, swapchain_height: int,
-		allocator := context.allocator, loc := #caller_location),
-	shutdown: proc(),
-	clear: proc(color: Color),
-	present: proc(),
-	draw: proc(shader: Shader, texture: Texture_Handle, vertex_buffer: []u8),
-	set_internal_state: proc(state: rawptr),
-
-	load_texture: proc(data: []u8, width: int, height: int) -> Texture_Handle,
-	destroy_texture: proc(handle: Texture_Handle),
-
-	load_shader: proc(shader: string, layout_formats: []Shader_Input_Format = {}) -> Shader,
-	destroy_shader: proc(shader: Shader),
-
-	get_swapchain_width: proc() -> int,
-	get_swapchain_height: proc() -> int,
-
-	set_view_projection_matrix: proc(m: Mat4),
-
-	batch_vertex: proc(v: Vec2, uv: Vec2, color: Color),
-}
-
 State :: struct {
 	allocator: runtime.Allocator,
 	custom_context: runtime.Context,
@@ -601,28 +621,6 @@ VK_MAP := [255]Keyboard_Key {
 @(private="file")
 s: ^State
 
-// --------------------------------
-// old, non migrated API below
-
-
-
-
-
-
-
-
-get_default_shader: proc() -> Shader_Handle : _get_default_shader
-
-
-
-set_scissor_rect: proc(scissor_rect: Maybe(Rect)) : _set_scissor_rect
-
-//set_vertex_value :: _set_vertex_value
-
-draw_circle: proc(center: Vec2, radius: f32, color: Color) : _draw_circle
-draw_line: proc(start: Vec2, end: Vec2, thickness: f32, color: Color) : _draw_line
-
-
 Shader_Input_Format :: enum {
 	Unknown,
 	RGBA32_Float,
@@ -632,22 +630,10 @@ Shader_Input_Format :: enum {
 	R32_Float,
 }
 
-
-// WARNING: Not proper text rendering yet... No font support etc
-draw_text: proc(text: string, pos: Vec2, font_size: f32, color: Color) : _draw_text
-
-screen_to_world: proc(pos: Vec2, camera: Camera) -> Vec2 : _screen_to_world
-
-
-mouse_button_went_down: proc(button: Mouse_Button) -> bool : _mouse_button_pressed
-mouse_button_went_up: proc(button: Mouse_Button) -> bool : _mouse_button_released
-mouse_button_is_held: proc(button: Mouse_Button) -> bool : _mouse_button_held
-get_mouse_wheel_delta: proc() -> f32 : _mouse_wheel_delta
-get_mouse_position: proc() -> Vec2 : _mouse_position
-
 Color :: [4]u8
 
 Vec2 :: [2]f32
+Vec3 :: [3]f32
 
 Mat4 :: matrix[4,4]f32