Forráskód Böngészése

more clear screen_width/height name

Karl Zylinski 2 hónapja
szülő
commit
1c4ab18c9b
2 módosított fájl, 10 hozzáadás és 7 törlés
  1. 5 2
      karl2d.odin
  2. 5 5
      window_win32.odin

+ 5 - 2
karl2d.odin

@@ -30,7 +30,10 @@ import hm "handle_map"
 // Opens a window and initializes some internal state. The internal state will use `allocator` for
 // all dynamically allocated memory. The return value can be ignored unless you need to later call
 // `set_internal_state`.
-init :: proc(window_width: int, window_height: int, window_title: string,
+//
+// `screen_width` and `screen_height` refer to the the resolution of the drawable area of the
+// window. The window might be slightly larger due borders and headers.
+init :: proc(screen_width: int, screen_height: int, window_title: string,
             window_creation_flags := Window_Flags {},
             allocator := context.allocator, loc := #caller_location) -> ^State {
 	assert(s == nil, "Don't call 'init' twice.")
@@ -54,7 +57,7 @@ init :: proc(window_width: int, window_height: int, window_title: string,
 	s.window_state, window_state_alloc_error = mem.alloc(win.state_size(), allocator = allocator)
 	log.assertf(window_state_alloc_error == nil, "Failed allocating memory for window state: %v", window_state_alloc_error)
 
-	win.init(s.window_state, window_width, window_height, window_title, window_creation_flags, allocator)
+	win.init(s.window_state, screen_width, screen_height, window_title, window_creation_flags, allocator)
 
 	// This is a OS-independent handle that we can pass to any rendering backend.
 	s.window = win.window_handle()

+ 5 - 5
window_win32.odin

@@ -32,14 +32,14 @@ win32_state_size :: proc() -> int {
 	return size_of(Win32_State)
 }
 
-win32_init :: proc(window_state: rawptr, window_width: int, window_height: int, window_title: string,
+win32_init :: proc(window_state: rawptr, screen_width: int, screen_height: int, window_title: string,
 	               flags: Window_Flags, allocator: runtime.Allocator) {
 	assert(window_state != nil)
 	s = (^Win32_State)(window_state)
 	s.allocator = allocator
 	s.events = make([dynamic]Window_Event, allocator)
-	s.width = window_width
-	s.height = window_height
+	s.width = screen_width
+	s.height = screen_height
 	s.custom_context = context
 	
 	win32.SetProcessDpiAwarenessContext(win32.DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2)
@@ -58,8 +58,8 @@ win32_init :: proc(window_state: rawptr, window_width: int, window_height: int,
 	win32.RegisterClassW(&cls)
 
 	r: win32.RECT
-	r.right = i32(window_width)
-	r.bottom = i32(window_height)
+	r.right = i32(screen_width)
+	r.bottom = i32(screen_height)
 
 	s.flags = flags