Cross-Platform OpenGL Windowing Library
リビジョン | 48ce2df0e008b494439a5d82d131385b21b14227 (tree) |
---|---|
日時 | 2018-10-24 10:34:37 |
作者 | AlaskanEmily <emily@alas...> |
コミッター | AlaskanEmily |
Fix some formatting
@@ -48,6 +48,8 @@ static Display *glow_get_display(){ | ||
48 | 48 | return NULL; |
49 | 49 | } |
50 | 50 | |
51 | +/******************************************************************************/ | |
52 | + | |
51 | 53 | static const GLint glow_attribs[] = { |
52 | 54 | GLX_X_RENDERABLE, True, |
53 | 55 | GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, |
@@ -62,6 +64,8 @@ static const GLint glow_attribs[] = { | ||
62 | 64 | None |
63 | 65 | }; |
64 | 66 | |
67 | +/******************************************************************************/ | |
68 | + | |
65 | 69 | struct Glow_Context { |
66 | 70 | unsigned char gl[2]; |
67 | 71 | Display *dpy; |
@@ -69,6 +73,8 @@ struct Glow_Context { | ||
69 | 73 | GLXContext ctx; |
70 | 74 | }; |
71 | 75 | |
76 | +/******************************************************************************/ | |
77 | + | |
72 | 78 | struct Glow_Window{ |
73 | 79 | |
74 | 80 | Display *dpy; |
@@ -86,16 +92,22 @@ struct Glow_Window{ | ||
86 | 92 | int mouse_x, mouse_y; |
87 | 93 | }; |
88 | 94 | |
95 | +/******************************************************************************/ | |
96 | + | |
89 | 97 | unsigned Glow_WindowStructSize(){ |
90 | 98 | return sizeof(struct Glow_Window); |
91 | 99 | } |
92 | 100 | |
101 | +/******************************************************************************/ | |
102 | + | |
93 | 103 | void Glow_ViewportSize(unsigned w, unsigned h, |
94 | 104 | unsigned *out_w, unsigned *out_h){ |
95 | 105 | out_w[0] = w; |
96 | 106 | out_h[0] = h; |
97 | 107 | } |
98 | 108 | |
109 | +/******************************************************************************/ | |
110 | + | |
99 | 111 | void Glow_CreateWindow(struct Glow_Window *window, |
100 | 112 | unsigned w, unsigned h, const char *title, int flags){ |
101 | 113 |
@@ -192,6 +204,8 @@ void Glow_CreateWindow(struct Glow_Window *window, | ||
192 | 204 | XSync(window->dpy, False); |
193 | 205 | } |
194 | 206 | |
207 | +/******************************************************************************/ | |
208 | + | |
195 | 209 | void Glow_DestroyWindow(struct Glow_Window *window){ |
196 | 210 | XSync(window->dpy, False); |
197 | 211 |
@@ -205,10 +219,14 @@ void Glow_DestroyWindow(struct Glow_Window *window){ | ||
205 | 219 | XCloseDisplay(window->dpy); |
206 | 220 | } |
207 | 221 | |
222 | +/******************************************************************************/ | |
223 | + | |
208 | 224 | void Glow_SetTitle(struct Glow_Window *window, const char *title){ |
209 | 225 | XStoreName(window->dpy, window->wnd, title); |
210 | 226 | } |
211 | 227 | |
228 | +/******************************************************************************/ | |
229 | + | |
212 | 230 | void Glow_ShowWindow(struct Glow_Window *window){ |
213 | 231 | XClearWindow(window->dpy, window->wnd); |
214 | 232 | XMapRaised(window->dpy, window->wnd); |
@@ -220,16 +238,22 @@ void Glow_ShowWindow(struct Glow_Window *window){ | ||
220 | 238 | } |
221 | 239 | } |
222 | 240 | |
241 | +/******************************************************************************/ | |
242 | + | |
223 | 243 | void Glow_HideWindow(struct Glow_Window *window){ |
224 | 244 | XUnmapWindow(window->dpy, window->wnd); |
225 | 245 | } |
226 | 246 | |
247 | +/******************************************************************************/ | |
248 | + | |
227 | 249 | void Glow_GetWindowSize(const struct Glow_Window *window, |
228 | 250 | unsigned *out_w, unsigned *out_h){ |
229 | 251 | out_w[0] = window->w; |
230 | 252 | out_h[0] = window->h; |
231 | 253 | } |
232 | 254 | |
255 | +/******************************************************************************/ | |
256 | + | |
233 | 257 | void Glow_FlipScreen(struct Glow_Window *window){ |
234 | 258 | Glow_MakeCurrent(window->ctx); |
235 | 259 | glFlush(); |
@@ -237,6 +261,8 @@ void Glow_FlipScreen(struct Glow_Window *window){ | ||
237 | 261 | glClear(GL_COLOR_BUFFER_BIT); |
238 | 262 | } |
239 | 263 | |
264 | +/******************************************************************************/ | |
265 | + | |
240 | 266 | static unsigned glow_get_event(struct Glow_Window *window, |
241 | 267 | unsigned block, struct Glow_Event *out){ |
242 | 268 | glow_get_event_start: |
@@ -297,18 +323,27 @@ glow_get_event_start: | ||
297 | 323 | return 0; |
298 | 324 | } |
299 | 325 | |
326 | +/******************************************************************************/ | |
327 | + | |
300 | 328 | unsigned Glow_GetEvent(struct Glow_Window *window, |
301 | 329 | struct Glow_Event *out_event){ |
302 | 330 | return glow_get_event(window, 0, out_event); |
331 | + | |
303 | 332 | } |
333 | +/******************************************************************************/ | |
334 | + | |
304 | 335 | void Glow_WaitEvent(struct Glow_Window *window, struct Glow_Event *out_event){ |
305 | 336 | glow_get_event(window, 1, out_event); |
306 | 337 | } |
307 | 338 | |
339 | +/******************************************************************************/ | |
340 | + | |
308 | 341 | unsigned Glow_ContextStructSize(){ |
309 | 342 | return sizeof(struct Glow_Context); |
310 | 343 | } |
311 | 344 | |
345 | +/******************************************************************************/ | |
346 | + | |
312 | 347 | int Glow_CreateContext(struct Glow_Window *window, |
313 | 348 | struct Glow_Context *opt_share, |
314 | 349 | unsigned major, unsigned minor, |
@@ -360,20 +395,28 @@ int Glow_CreateContext(struct Glow_Window *window, | ||
360 | 395 | return 0; |
361 | 396 | } |
362 | 397 | |
398 | +/******************************************************************************/ | |
399 | + | |
363 | 400 | struct Glow_Context *Glow_GetContext( |
364 | 401 | struct Glow_Window *window){ |
365 | 402 | return window->ctx; |
366 | 403 | } |
367 | 404 | |
405 | +/******************************************************************************/ | |
406 | + | |
368 | 407 | void Glow_CreateLegacyContext(struct Glow_Window *window, |
369 | 408 | struct Glow_Context *out){ |
370 | 409 | Glow_CreateContext(window, NULL, 2, 1, out); |
371 | 410 | } |
372 | 411 | |
412 | +/******************************************************************************/ | |
413 | + | |
373 | 414 | void Glow_MakeCurrent(struct Glow_Context *ctx){ |
374 | 415 | glXMakeCurrent(ctx->dpy, ctx->wnd, ctx->ctx); |
375 | 416 | } |
376 | 417 | |
418 | +/******************************************************************************/ | |
419 | + | |
377 | 420 | struct Glow_Window *Glow_CreateLegacyWindow(unsigned w, unsigned h, |
378 | 421 | const char *title){ |
379 | 422 |