src/window.c

Sun, 11 Aug 2024 15:43:01 +0200

author
Mike Becker <universe@uap-core.de>
date
Sun, 11 Aug 2024 15:43:01 +0200
changeset 67
0b96fe6d6b5e
parent 65
9c44c55d327a
child 68
823c03733e42
permissions
-rw-r--r--

update to recent snapshot of UCX 3.1

0
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1 /*
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
3 * Copyright 2023 Mike Becker. All rights reserved.
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
4 *
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
5 * Redistribution and use in source and binary forms, with or without
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
6 * modification, are permitted provided that the following conditions are met:
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
7 *
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
8 * 1. Redistributions of source code must retain the above copyright
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
9 * notice, this list of conditions and the following disclaimer.
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
10 *
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
11 * 2. Redistributions in binary form must reproduce the above copyright
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
12 * notice, this list of conditions and the following disclaimer in the
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
13 * documentation and/or other materials provided with the distribution.
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
14 *
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
25 * POSSIBILITY OF SUCH DAMAGE.
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
26 */
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
27
6
302971e8599b move window related stuff to its own unit
Mike Becker <universe@uap-core.de>
parents: 3
diff changeset
28 #include "ascension/window.h"
7
9dd76cbd6c90 improve code structure
Mike Becker <universe@uap-core.de>
parents: 6
diff changeset
29 #include "ascension/context.h"
9dd76cbd6c90 improve code structure
Mike Becker <universe@uap-core.de>
parents: 6
diff changeset
30 #include "ascension/error.h"
9
6ad1a4213954 use the context flag to quit the application
Mike Becker <universe@uap-core.de>
parents: 7
diff changeset
31 #include "ascension/utils.h"
0
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
32
6
302971e8599b move window related stuff to its own unit
Mike Becker <universe@uap-core.de>
parents: 3
diff changeset
33 #include <GL/glew.h>
302971e8599b move window related stuff to its own unit
Mike Becker <universe@uap-core.de>
parents: 3
diff changeset
34
0
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
35 void asc_window_settings_init_defaults(AscWindowSettings* settings) {
3
1efd6da2ad53 add datatypes.h
Mike Becker <universe@uap-core.de>
parents: 2
diff changeset
36 settings->dimensions.width = 800;
1efd6da2ad53 add datatypes.h
Mike Becker <universe@uap-core.de>
parents: 2
diff changeset
37 settings->dimensions.height = 600;
0
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
38 settings->fullscreen = 0;
44
b3da4096c607 create own compilation unit for GL context - fixes shader not being created per context
Mike Becker <universe@uap-core.de>
parents: 41
diff changeset
39 settings->glsettings.depth_size = 24;
b3da4096c607 create own compilation unit for GL context - fixes shader not being created per context
Mike Becker <universe@uap-core.de>
parents: 41
diff changeset
40 settings->glsettings.vsync = 1;
b3da4096c607 create own compilation unit for GL context - fixes shader not being created per context
Mike Becker <universe@uap-core.de>
parents: 41
diff changeset
41 settings->glsettings.gl_major_version = 4;
b3da4096c607 create own compilation unit for GL context - fixes shader not being created per context
Mike Becker <universe@uap-core.de>
parents: 41
diff changeset
42 settings->glsettings.gl_minor_version = 0;
0
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
43 settings->title = "Ascended Window";
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
44 }
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
45
65
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
46 void asc_window_initialize(unsigned int index, AscWindowSettings const *settings) {
7
9dd76cbd6c90 improve code structure
Mike Becker <universe@uap-core.de>
parents: 6
diff changeset
47 if (index >= ASC_MAX_WINDOWS) {
9dd76cbd6c90 improve code structure
Mike Becker <universe@uap-core.de>
parents: 6
diff changeset
48 asc_error("Maximum number of windows exceeded.");
65
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
49 return;
7
9dd76cbd6c90 improve code structure
Mike Becker <universe@uap-core.de>
parents: 6
diff changeset
50 }
9dd76cbd6c90 improve code structure
Mike Becker <universe@uap-core.de>
parents: 6
diff changeset
51 AscWindow *window = &asc_context.windows[index];
9dd76cbd6c90 improve code structure
Mike Becker <universe@uap-core.de>
parents: 6
diff changeset
52 if (window->id > 0) {
9dd76cbd6c90 improve code structure
Mike Becker <universe@uap-core.de>
parents: 6
diff changeset
53 asc_error("Cannot create window - slot already occupied.");
47
44457f6cb0a2 remove unnecessary scene container
Mike Becker <universe@uap-core.de>
parents: 44
diff changeset
54 asc_dprintf("Tried to create window with index %u twice", index);
65
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
55 return;
7
9dd76cbd6c90 improve code structure
Mike Becker <universe@uap-core.de>
parents: 6
diff changeset
56 }
47
44457f6cb0a2 remove unnecessary scene container
Mike Becker <universe@uap-core.de>
parents: 44
diff changeset
57 if (window->ui != NULL) {
44457f6cb0a2 remove unnecessary scene container
Mike Becker <universe@uap-core.de>
parents: 44
diff changeset
58 asc_dprintf("Window with index %u has a dangling UI pointer", index);
44457f6cb0a2 remove unnecessary scene container
Mike Becker <universe@uap-core.de>
parents: 44
diff changeset
59 asc_scene_node_free(window->ui);
44457f6cb0a2 remove unnecessary scene container
Mike Becker <universe@uap-core.de>
parents: 44
diff changeset
60 }
7
9dd76cbd6c90 improve code structure
Mike Becker <universe@uap-core.de>
parents: 6
diff changeset
61
0
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
62 Uint32 flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN;
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
63 flags |= settings->fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : SDL_WINDOW_RESIZABLE;
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
64
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
65 window->window = SDL_CreateWindow(
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
66 settings->title,
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
67 SDL_WINDOWPOS_CENTERED,
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
68 SDL_WINDOWPOS_CENTERED,
3
1efd6da2ad53 add datatypes.h
Mike Becker <universe@uap-core.de>
parents: 2
diff changeset
69 settings->dimensions.width,
1efd6da2ad53 add datatypes.h
Mike Becker <universe@uap-core.de>
parents: 2
diff changeset
70 settings->dimensions.height,
0
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
71 flags
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
72 );
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
73 if (window->window == NULL) {
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
74 asc_error(SDL_GetError());
65
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
75 return;
0
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
76 }
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
77
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
78 window->id = SDL_GetWindowID(window->window);
3
1efd6da2ad53 add datatypes.h
Mike Becker <universe@uap-core.de>
parents: 2
diff changeset
79 SDL_GetWindowSize(window->window,
1efd6da2ad53 add datatypes.h
Mike Becker <universe@uap-core.de>
parents: 2
diff changeset
80 &window->dimensions.width,
1efd6da2ad53 add datatypes.h
Mike Becker <universe@uap-core.de>
parents: 2
diff changeset
81 &window->dimensions.height
1efd6da2ad53 add datatypes.h
Mike Becker <universe@uap-core.de>
parents: 2
diff changeset
82 );
37
8a8cc6725b48 add camera and render groups
Mike Becker <universe@uap-core.de>
parents: 34
diff changeset
83 window->resized = true; // count initial sizing as resize
0
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
84
44
b3da4096c607 create own compilation unit for GL context - fixes shader not being created per context
Mike Becker <universe@uap-core.de>
parents: 41
diff changeset
85 if (asc_gl_context_initialize(&window->glctx, window->window, &settings->glsettings)) {
47
44457f6cb0a2 remove unnecessary scene container
Mike Becker <universe@uap-core.de>
parents: 44
diff changeset
86 window->ui = asc_scene_node_empty();
44
b3da4096c607 create own compilation unit for GL context - fixes shader not being created per context
Mike Becker <universe@uap-core.de>
parents: 41
diff changeset
87 asc_dprintf("Window %u initialized", window->id);
65
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
88 asc_context.active_window = index;
0
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
89 } else {
44
b3da4096c607 create own compilation unit for GL context - fixes shader not being created per context
Mike Becker <universe@uap-core.de>
parents: 41
diff changeset
90 asc_dprintf("Creating GL context failed for window %u", window->id);
b3da4096c607 create own compilation unit for GL context - fixes shader not being created per context
Mike Becker <universe@uap-core.de>
parents: 41
diff changeset
91 // cleanup on error
b3da4096c607 create own compilation unit for GL context - fixes shader not being created per context
Mike Becker <universe@uap-core.de>
parents: 41
diff changeset
92 SDL_DestroyWindow(window->window);
b3da4096c607 create own compilation unit for GL context - fixes shader not being created per context
Mike Becker <universe@uap-core.de>
parents: 41
diff changeset
93 window->window = NULL;
b3da4096c607 create own compilation unit for GL context - fixes shader not being created per context
Mike Becker <universe@uap-core.de>
parents: 41
diff changeset
94 window->id = 0;
0
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
95 }
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
96 }
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
97
65
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
98 void asc_window_destroy(unsigned int index) {
7
9dd76cbd6c90 improve code structure
Mike Becker <universe@uap-core.de>
parents: 6
diff changeset
99 // safeguard
65
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
100 if (asc_context.windows[index].id == 0) return;
7
9dd76cbd6c90 improve code structure
Mike Becker <universe@uap-core.de>
parents: 6
diff changeset
101
16
c5dde81b6fb2 add text rendering and demo FPS counter
Mike Becker <universe@uap-core.de>
parents: 13
diff changeset
102 // this window cannot be active anymore
65
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
103 if (asc_context.active_window == index) {
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
104 asc_context.active_window = ASC_MAX_WINDOWS;
16
c5dde81b6fb2 add text rendering and demo FPS counter
Mike Becker <universe@uap-core.de>
parents: 13
diff changeset
105 }
c5dde81b6fb2 add text rendering and demo FPS counter
Mike Becker <universe@uap-core.de>
parents: 13
diff changeset
106
65
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
107 // pointer to the window
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
108 AscWindow *window = &asc_context.windows[index];
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
109
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
110 // for releasing OpenGL resources, we need to make the context current
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
111 asc_gl_context_activate(&window->glctx);
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
112
29
1d001eb694dc bring first scene graph to live
Mike Becker <universe@uap-core.de>
parents: 16
diff changeset
113 // destroy all scenes
47
44457f6cb0a2 remove unnecessary scene container
Mike Becker <universe@uap-core.de>
parents: 44
diff changeset
114 asc_scene_node_free(window->ui);
44457f6cb0a2 remove unnecessary scene container
Mike Becker <universe@uap-core.de>
parents: 44
diff changeset
115 window->ui = NULL;
29
1d001eb694dc bring first scene graph to live
Mike Becker <universe@uap-core.de>
parents: 16
diff changeset
116
44
b3da4096c607 create own compilation unit for GL context - fixes shader not being created per context
Mike Becker <universe@uap-core.de>
parents: 41
diff changeset
117 // release context related data
b3da4096c607 create own compilation unit for GL context - fixes shader not being created per context
Mike Becker <universe@uap-core.de>
parents: 41
diff changeset
118 asc_gl_context_destroy(&window->glctx);
16
c5dde81b6fb2 add text rendering and demo FPS counter
Mike Becker <universe@uap-core.de>
parents: 13
diff changeset
119
44
b3da4096c607 create own compilation unit for GL context - fixes shader not being created per context
Mike Becker <universe@uap-core.de>
parents: 41
diff changeset
120 // destroy window
0
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
121 if (window->window != NULL) {
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
122 SDL_DestroyWindow(window->window);
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
123 }
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
124
16
c5dde81b6fb2 add text rendering and demo FPS counter
Mike Becker <universe@uap-core.de>
parents: 13
diff changeset
125 // if another window was active, make the other context current again
65
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
126 if (asc_context.active_window < ASC_MAX_WINDOWS) {
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
127 asc_gl_context_activate(&asc_active_window->glctx);
16
c5dde81b6fb2 add text rendering and demo FPS counter
Mike Becker <universe@uap-core.de>
parents: 13
diff changeset
128 }
c5dde81b6fb2 add text rendering and demo FPS counter
Mike Becker <universe@uap-core.de>
parents: 13
diff changeset
129
0
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
130 // clean the data
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
131 asc_dprintf("Window %u and its OpenGL context destroyed.", window->id);
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
132 memset(window, 0, sizeof(AscWindow));
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
133 }
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
134
65
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
135 void asc_window_sync(unsigned int index) {
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
136 // necessary safeguard
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
137 if (asc_context.windows[index].id == 0) return;
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
138
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
139 // active the window that shall be synced temporarily
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
140 unsigned int active_index = asc_context.active_window;
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
141 if (index != active_index) {
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
142 asc_window_activate(index);
16
c5dde81b6fb2 add text rendering and demo FPS counter
Mike Becker <universe@uap-core.de>
parents: 13
diff changeset
143 }
29
1d001eb694dc bring first scene graph to live
Mike Becker <universe@uap-core.de>
parents: 16
diff changeset
144
47
44457f6cb0a2 remove unnecessary scene container
Mike Becker <universe@uap-core.de>
parents: 44
diff changeset
145 // Clear the color buffer for the window frame
65
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
146 int window_width = asc_active_window->dimensions.width;
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
147 int window_height = asc_active_window->dimensions.height;
47
44457f6cb0a2 remove unnecessary scene container
Mike Becker <universe@uap-core.de>
parents: 44
diff changeset
148 glViewport(0, 0, window_width, window_height);
44457f6cb0a2 remove unnecessary scene container
Mike Becker <universe@uap-core.de>
parents: 44
diff changeset
149 glClear(GL_COLOR_BUFFER_BIT);
44457f6cb0a2 remove unnecessary scene container
Mike Becker <universe@uap-core.de>
parents: 44
diff changeset
150 asc_recti viewport = {0, 0, window_width, window_height};
44457f6cb0a2 remove unnecessary scene container
Mike Becker <universe@uap-core.de>
parents: 44
diff changeset
151
29
1d001eb694dc bring first scene graph to live
Mike Becker <universe@uap-core.de>
parents: 16
diff changeset
152 // Draw the UI
47
44457f6cb0a2 remove unnecessary scene container
Mike Becker <universe@uap-core.de>
parents: 44
diff changeset
153 AscCamera ui_camera;
44457f6cb0a2 remove unnecessary scene container
Mike Becker <universe@uap-core.de>
parents: 44
diff changeset
154 asc_camera_ortho(&ui_camera, viewport);
65
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
155 asc_scene_draw(asc_active_window->ui, viewport, &ui_camera);
29
1d001eb694dc bring first scene graph to live
Mike Becker <universe@uap-core.de>
parents: 16
diff changeset
156
1d001eb694dc bring first scene graph to live
Mike Becker <universe@uap-core.de>
parents: 16
diff changeset
157 // Swap Buffers
65
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
158 SDL_GL_SwapWindow(asc_active_window->window);
29
1d001eb694dc bring first scene graph to live
Mike Becker <universe@uap-core.de>
parents: 16
diff changeset
159
37
8a8cc6725b48 add camera and render groups
Mike Becker <universe@uap-core.de>
parents: 34
diff changeset
160 // Clear Flags
65
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
161 asc_active_window->resized = false;
37
8a8cc6725b48 add camera and render groups
Mike Becker <universe@uap-core.de>
parents: 34
diff changeset
162
65
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
163 if (index != active_index) {
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
164 asc_window_activate(active_index);
16
c5dde81b6fb2 add text rendering and demo FPS counter
Mike Becker <universe@uap-core.de>
parents: 13
diff changeset
165 }
0
593b60458157 initial commit
Mike Becker <universe@uap-core.de>
parents:
diff changeset
166 }
16
c5dde81b6fb2 add text rendering and demo FPS counter
Mike Becker <universe@uap-core.de>
parents: 13
diff changeset
167
65
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
168 void asc_window_activate(unsigned int index) {
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
169 asc_context.active_window = index;
9c44c55d327a consistently refer to windows by ID - fixes #381
Mike Becker <universe@uap-core.de>
parents: 64
diff changeset
170 asc_gl_context_activate(&asc_active_window->glctx);
16
c5dde81b6fb2 add text rendering and demo FPS counter
Mike Becker <universe@uap-core.de>
parents: 13
diff changeset
171 }

mercurial