blob: 06ca1634be71d1f74411cbcc552e94eb9749b7cc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
/*
* ============================================================
* FILE: window.h
*
* PURPOSE: Public interface for the OS window, the OpenGL context and the
* clock. Hides GLFW/GLEW setup from the rest of the game.
*
* FITS IN: Called by main.c (lifecycle, loop), render.c (aspect ratio /
* framebuffer size), and controls.c (window handle, only for
* the keyboard fallback).
*
* INTERFACE: Use these exact signatures:
*
* bool window_init(void);
* Creates the window + GL 3.3 core context, loads GL via GLEW.
* Returns false (after printing why to stderr) on failure.
* void window_shutdown(void);
* bool window_should_close(void);
* void window_request_close(void); e.g. when Start/Esc is pressed
* void window_poll_events(void); once per display frame
* void window_swap(void); present the finished frame
* double window_time(void); seconds since start (double for
* precision over long sessions)
* void window_framebuffer_size(int *w, int *h); in PIXELS (for glViewport)
* float window_aspect(void); framebuffer width / height
* void window_set_title(const char *title); used for a debug readout
* struct GLFWwindow *window_handle(void); ONLY controls.c may use this
*
* Include <stdbool.h>. Forward-declare `struct GLFWwindow;` rather than
* including GLFW here, so files that include window.h don't pull in GLFW.
*
* CONVENTIONS: Include guard: WINDOW_H.
*
* NOT IN SCOPE: Fullscreen toggle, multiple windows, mouse capture.
*
* DONE WHEN: The header compiles on its own and main.c can drive the whole
* window lifecycle through it.
* ============================================================
*/
#ifndef WINDOW_H
#define WINDOW_H
#include <stdbool.h>
/* Forward declaration, so including window.h doesn't pull in GLFW. */
struct GLFWwindow;
bool window_init(void);
void window_shutdown(void);
bool window_should_close(void);
void window_request_close(void);
void window_poll_events(void);
void window_swap(void);
double window_time(void);
void window_framebuffer_size(int *w, int *h);
float window_aspect(void);
void window_set_title(const char *title);
struct GLFWwindow *window_handle(void); /* ONLY controls.c may use this */
#endif /* WINDOW_H */
|