diff options
Diffstat (limited to 'gfx-app')
| -rw-r--r-- | gfx-app/src/gfx_app.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/gfx-app/src/gfx_app.c b/gfx-app/src/gfx_app.c index f3f0473..018e997 100644 --- a/gfx-app/src/gfx_app.c +++ b/gfx-app/src/gfx_app.c | |||
| @@ -9,11 +9,11 @@ | |||
| 9 | 9 | ||
| 10 | /// Application state. | 10 | /// Application state. |
| 11 | typedef struct GfxApp { | 11 | typedef struct GfxApp { |
| 12 | void* app_state; | 12 | void* app_state; |
| 13 | GfxAppCallbacks callbacks; | 13 | GfxAppCallbacks callbacks; |
| 14 | int max_fps; | 14 | int max_fps; |
| 15 | double update_delta_time; | 15 | double update_delta_time; |
| 16 | GLFWwindow* window; | 16 | GLFWwindow* window; |
| 17 | } GfxApp; | 17 | } GfxApp; |
| 18 | 18 | ||
| 19 | /// Storing the application state in a global variable so that we can call the | 19 | /// Storing the application state in a global variable so that we can call the |
| @@ -32,10 +32,10 @@ static void loop(GfxApp* app) { | |||
| 32 | 32 | ||
| 33 | const double min_frame_time = | 33 | const double min_frame_time = |
| 34 | app->max_fps > 0 ? 1.0 / (double)(app->max_fps) : 0.0; | 34 | app->max_fps > 0 ? 1.0 / (double)(app->max_fps) : 0.0; |
| 35 | const double update_dt = app->update_delta_time; | 35 | const double update_dt = app->update_delta_time; |
| 36 | double time = 0.0; | 36 | double time = 0.0; |
| 37 | double time_budget = 0.0; | 37 | double time_budget = 0.0; |
| 38 | Timer timer = timer_make(); | 38 | Timer timer = timer_make(); |
| 39 | 39 | ||
| 40 | // Warm up the rendering before entering the main loop. A renderer can compile | 40 | // Warm up the rendering before entering the main loop. A renderer can compile |
| 41 | // shaders and do other initialization the first time it renders a scene. | 41 | // shaders and do other initialization the first time it renders a scene. |
| @@ -57,7 +57,7 @@ static void loop(GfxApp* app) { | |||
| 57 | glfwSwapBuffers(app->window); | 57 | glfwSwapBuffers(app->window); |
| 58 | glfwPollEvents(); | 58 | glfwPollEvents(); |
| 59 | 59 | ||
| 60 | const time_point frame_end = time_now(); | 60 | const time_point frame_end = time_now(); |
| 61 | const time_delta frame_time = time_diff(timer.last_tick, frame_end); | 61 | const time_delta frame_time = time_diff(timer.last_tick, frame_end); |
| 62 | if (min_frame_time > 0.0 && frame_time < min_frame_time) { | 62 | if (min_frame_time > 0.0 && frame_time < min_frame_time) { |
| 63 | time_sleep(min_frame_time - frame_time); | 63 | time_sleep(min_frame_time - frame_time); |
| @@ -71,10 +71,10 @@ bool gfx_app_run(const GfxAppDesc* desc, const GfxAppCallbacks* callbacks) { | |||
| 71 | 71 | ||
| 72 | bool success = false; | 72 | bool success = false; |
| 73 | 73 | ||
| 74 | g_gfx_app.callbacks = *callbacks; | 74 | g_gfx_app.callbacks = *callbacks; |
| 75 | g_gfx_app.max_fps = desc->max_fps; | 75 | g_gfx_app.max_fps = desc->max_fps; |
| 76 | g_gfx_app.update_delta_time = desc->update_delta_time; | 76 | g_gfx_app.update_delta_time = desc->update_delta_time; |
| 77 | g_gfx_app.window = 0; | 77 | g_gfx_app.window = 0; |
| 78 | 78 | ||
| 79 | if (!glfwInit()) { | 79 | if (!glfwInit()) { |
| 80 | LOGE("glfwInit() failed"); | 80 | LOGE("glfwInit() failed"); |
| @@ -91,8 +91,8 @@ bool gfx_app_run(const GfxAppDesc* desc, const GfxAppCallbacks* callbacks) { | |||
| 91 | // TODO: Test antialiasing later on. | 91 | // TODO: Test antialiasing later on. |
| 92 | // glfwWindowHint(GLFW_SAMPLES, 4); | 92 | // glfwWindowHint(GLFW_SAMPLES, 4); |
| 93 | 93 | ||
| 94 | g_gfx_app.window = | 94 | g_gfx_app.window = glfwCreateWindow( |
| 95 | glfwCreateWindow(desc->width, desc->height, "space", NULL, NULL); | 95 | desc->width, desc->height, "Gfx Application", NULL, NULL); |
| 96 | if (!g_gfx_app.window) { | 96 | if (!g_gfx_app.window) { |
| 97 | LOGE("glfwCreateWindow() failed"); | 97 | LOGE("glfwCreateWindow() failed"); |
| 98 | goto cleanup; | 98 | goto cleanup; |
