|
@@ -13,22 +13,32 @@ init :: proc(window_width: int, window_height: int, window_title: string,
|
|
|
window_creation_flags := Window_Flags {},
|
|
window_creation_flags := Window_Flags {},
|
|
|
allocator := context.allocator, loc := #caller_location) -> ^State
|
|
allocator := context.allocator, loc := #caller_location) -> ^State
|
|
|
|
|
|
|
|
-// Returns true if the program wants to shut down. This happens when for example pressing the close
|
|
|
|
|
-// button on the window. The application can decide if it wants to shut down or if it wants to show
|
|
|
|
|
-// some kind of confirmation dialogue and shut down later.
|
|
|
|
|
|
|
+// Returns true the user has pressed the close button on the window, or used a key stroke such as
|
|
|
|
|
+// ALT+F4 on Windows. The application can decide if it wants to shut down or if it wants to show
|
|
|
|
|
+// some kind of confirmation dialogue.
|
|
|
//
|
|
//
|
|
|
-// Commonly used for creating the "main loop" of a game.
|
|
|
|
|
|
|
+// Commonly used for creating the "main loop" of a game: `for k2.shutdown_wanted {}`
|
|
|
shutdown_wanted :: proc() -> bool
|
|
shutdown_wanted :: proc() -> bool
|
|
|
|
|
|
|
|
// Closes the window and cleans up the internal state.
|
|
// Closes the window and cleans up the internal state.
|
|
|
shutdown :: proc()
|
|
shutdown :: proc()
|
|
|
|
|
|
|
|
-// Clear the backbuffer with supplied color.
|
|
|
|
|
|
|
+// Clear the "screen" with the supplied color. By default this will clear your window. But if you
|
|
|
|
|
+// have set a Render Texture using `set_render_texture` procedure, then that Render Texture will be
|
|
|
|
|
+// cleared instead.
|
|
|
clear :: proc(color: Color)
|
|
clear :: proc(color: Color)
|
|
|
|
|
|
|
|
-// Present the backbuffer. Call at end of frame to make everything you've drawn appear on the
|
|
|
|
|
-// screen. Also clears the frame_allocator that Karl2D uses for allocations that have the lifetime
|
|
|
|
|
-// of a single frame.
|
|
|
|
|
|
|
+// "Flips the backbuffer": Call at end of frame to make everything you've drawn appear on the screen.
|
|
|
|
|
+//
|
|
|
|
|
+// When you draw using for example `draw_texture`, then that stuff is drawn to an invisible texture
|
|
|
|
|
+// called a "backbuffer". This makes sure that we don't see half-drawn frames. So when you are happy
|
|
|
|
|
+// with a frame and want to show it to the player, use this procedure.
|
|
|
|
|
+//
|
|
|
|
|
+// Also, this procedure clears the frame_allocator that Karl2D uses for internal allocations that
|
|
|
|
|
+// have the lifetime of a single frame.
|
|
|
|
|
+//
|
|
|
|
|
+// WebGL note: WebGL does the backbuffer flipping automatically. But you should still call this to
|
|
|
|
|
+// make Karl2D clear its frame allocator.
|
|
|
present :: proc()
|
|
present :: proc()
|
|
|
|
|
|
|
|
// Call at start or end of frame to process all events that have arrived to the window. This
|
|
// Call at start or end of frame to process all events that have arrived to the window. This
|
|
@@ -37,12 +47,21 @@ present :: proc()
|
|
|
// WARNING: Not calling this will make your program impossible to interact with.
|
|
// WARNING: Not calling this will make your program impossible to interact with.
|
|
|
process_events :: proc()
|
|
process_events :: proc()
|
|
|
|
|
|
|
|
|
|
+// Gets the width of the drawing area within the window. The returned number is not scaled by any
|
|
|
|
|
+// monitor DPI scaling. You do that manually using the number returned by `get_window_scale()`.
|
|
|
get_screen_width :: proc() -> int
|
|
get_screen_width :: proc() -> int
|
|
|
|
|
|
|
|
|
|
+// Gets the height of the drawing area within the window. The returned number is not scaled by any
|
|
|
|
|
+// monitor DPI scaling. You do that manually using the number returned by `get_window_scale()`.
|
|
|
get_screen_height :: proc() -> int
|
|
get_screen_height :: proc() -> int
|
|
|
|
|
|
|
|
|
|
+// Moves the window.
|
|
|
|
|
+//
|
|
|
|
|
+// WebGL note: This moves the canvas within the window, which may not be what you want.
|
|
|
set_window_position :: proc(x: int, y: int)
|
|
set_window_position :: proc(x: int, y: int)
|
|
|
|
|
|
|
|
|
|
+// Resize the window to a new size. If the window has the flag Resizable set, then the backbuffer
|
|
|
|
|
+// will also be resized.
|
|
|
set_window_size :: proc(width: int, height: int)
|
|
set_window_size :: proc(width: int, height: int)
|
|
|
|
|
|
|
|
// Fetch the scale of the window. This usually comes from some DPI scaling setting in the OS.
|
|
// Fetch the scale of the window. This usually comes from some DPI scaling setting in the OS.
|