window_structure
GLFW window of the application (size, title, aspect ratio).
Fields and methods
Members of the struct window_structure. Most of what you do with a CGP type goes through the free functions listed below.
Fields
GLFWwindow* glfw_window = nullptr | GLFW window handle, nullptr until create_window() is called. |
GLFWmonitor* monitor = nullptr | Primary monitor recorded by create_window(), used by set_full_screen(). |
int x_pos = 0 | Horizontal position of the window on screen in pixels, read at creation and when switching to full screen (restored by set_windowed_screen). |
int y_pos = 0 | Vertical position of the window on screen in pixels, read at creation and when switching to full screen (restored by set_windowed_screen). |
int width = 0 | Width of the window in pixels, set at creation and updated by the application on resize. |
int height = 0 | Height of the window in pixels, set at creation and updated by the application on resize. |
int screen_resolution_width = 0 | Width in pixels of the primary monitor video mode, read at window creation. |
int screen_resolution_height = 0 | Height in pixels of the primary monitor video mode, read at window creation. |
bool is_full_screen = false | Whether the window is in full screen mode, false by default; set by set_full_screen() and set_windowed_screen() (GUI checkbox or Shift+F in the template). |
int windowed_width = 0 | Width of the window in screen coordinates saved by set_full_screen() and restored by set_windowed_screen(), 0 until then. |
int windowed_height = 0 | Height of the window in screen coordinates saved by set_full_screen() and restored by set_windowed_screen(), 0 until then. |
Methods
| Initializes GLFW with a callback that prints its errors, and aborts with a message if no graphical server is available; call it once before create_window. src | |
| Creates the GLFW window and its OpenGL context (core 3.3 by default, 8x multisampling, vsync), loads the OpenGL functions, and stores the window position and size and the screen resolution; initialize_glfw must be called before. src | |
| Returns width / height. src | |
| Remembers the position and size of the window, switches it to full screen on monitor at screen_resolution_width x screen_resolution_height, and sets is_full_screen. src | |
| Switches the window back to windowed mode at the position and size it had before set_full_screen() (at (100,100) with half the screen resolution if unknown), and clears is_full_screen. src | |
| Converts a position in pixels (origin at the top left) into relative coordinates in [-1,1], x to the right and y upward. src | |
| Returns the current width in pixels of the primary monitor video mode. src | |
| Returns the current height in pixels of the primary monitor video mode. src |
Functions taking a window_structure
None.
Functions returning a window_structure
None.
Operators
None.