Window
Typedefs
-
typedef struct binocle_window binocle_window
This is the representation of the app/window. Currently an app can only have one window
Functions
-
binocle_window *binocle_window_new(uint32_t width, uint32_t height, char *title)
Creates a new window.
- Parameters:
width – the width of the window
height – the height of the window
title – the title of the window
- Returns:
a window instance
-
void binocle_window_destroy(binocle_window *win)
Destroys an initialized window.
- Parameters:
win – the window to destroy
-
void binocle_window_create(binocle_window *win, char *title, uint32_t width, uint32_t height)
Create a window and sets the title.
- Parameters:
win – the original window
title – the new title
width – the new width
height – the new height
-
void binocle_window_set_background_color(binocle_window *win, sg_color color)
Sets the background color of the window.
- Parameters:
win – the window
color – the color
-
void binocle_window_refresh(binocle_window *win)
Switches the buffers as needed to show the new frame in the given window.
- Parameters:
win – the window
-
void binocle_window_set_title(binocle_window *win, char *title)
Sets the title of a window.
- Parameters:
win – the window
title – the title
-
void binocle_window_toggle_fullscreen(binocle_window *win)
Toggles fullscreen.
- Parameters:
win – the window
-
void binocle_window_minimize(binocle_window *win)
Minimizes the window.
- Parameters:
win – the window
-
void binocle_window_maximize(binocle_window *win)
Maximizes the window.
- Parameters:
win – the window
-
void binocle_window_restore(binocle_window *win)
Restores the size and position of a minimized or maximized window.
- Parameters:
win – the window
-
void binocle_window_delay_framerate_if_needed(binocle_window *win)
Delays the current thread to meet the frame rate requirements, if needed.
- Parameters:
win – the window
-
uint32_t binocle_window_get_delta(binocle_window *win)
Gets the delta time since the last frame in ticks (ms)
- Parameters:
win – the window
- Returns:
the delta time in ticks (ms)
-
void binocle_window_set_minimum_size(binocle_window *win, int width, int height)
Sets the minimum size of the window.
- Parameters:
win – the window
width – the minimum width
height – the minimum height
-
void binocle_window_set_target_fps(binocle_window *win, uint64_t fps)
Sets the target FPS for the application When this is called, the main loop will try to meet the desired FPS and delay the main thread if needed.
- Parameters:
win – the window
fps – the FPS
-
uint64_t binocle_window_get_fps(binocle_window *win)
Gets the current FPS.
- Parameters:
win – the window
- Returns:
the FPS
-
uint32_t binocle_window_get_frame_time(binocle_window *win)
Gets how long the last frame took, in ticks (ms)
- Parameters:
win – the window
- Returns:
how long the last frame took, in ticks (ms)
-
void binocle_window_begin_frame(binocle_window *win)
Instructs the application that we are about to start a new frame. This is needed if we want to keep a steady frame rate and should be called at the beginning of your game loop.
- Parameters:
win – the window
-
void binocle_window_end_frame(binocle_window *win)
Instructs the application that we have just finished with the current frame. This is needed if we want to keep a steady frame rate and should be called at the end of your game loop.
- Parameters:
win – the window
-
void binocle_window_get_real_size(binocle_window *win, uint32_t *w, uint32_t *h)
Gets the size of the window client area.
- Parameters:
win – the window
w – a pointer to the width where this value will be written to
h – a pointer to the height where this value will be written to
-
bool binocle_window_get_display_size(uint32_t *w, uint32_t *h)
Gets the size of the display this window is being displayed on. Warning: this currently takes into account only the first display.
- Parameters:
w – a pointer to the width where this value will be written to
h – a pointer to the height where this value will be written to
- Returns:
true if the operation finished successfully
-
sg_environment binocle_window_get_environment(binocle_window *window)
Build the environment to pass to Sokol.
- Parameters:
window – a pointer to the window
- Returns:
the environment
-
sg_swapchain binocle_window_get_swapchain(binocle_window *window)
Build the swapchain data to pass to Sokol.
- Parameters:
window – a pointer to the window
- Returns:
the swapchain data
-
struct binocle_window
- #include <binocle_window.h>
This is the representation of the app/window. Currently an app can only have one window
Public Members
-
uint32_t width
-
uint32_t height
-
char *title
-
uint32_t original_width
-
uint32_t original_height
-
bool is_fullscreen
-
sg_color bg_color
-
uint64_t target_fps
-
uint32_t current_time
-
uint32_t previous_time
-
uint32_t update_time
-
uint32_t draw_time
-
uint32_t frame_time
-
uint32_t target_time
-
binocle_timer framerate_timer
-
uint32_t current_frame_delta
-
SDL_Window *window
-
bool has_depth_buffer
-
uint32_t sample_count
-
uint32_t width