1.1 --- a/test/sandbox.c Mon Mar 04 21:16:46 2024 +0100 1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 1.3 @@ -1,80 +0,0 @@ 1.4 -/* 1.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 1.6 - * Copyright 2023 Mike Becker. All rights reserved. 1.7 - * 1.8 - * Redistribution and use in source and binary forms, with or without 1.9 - * modification, are permitted provided that the following conditions are met: 1.10 - * 1.11 - * 1. Redistributions of source code must retain the above copyright 1.12 - * notice, this list of conditions and the following disclaimer. 1.13 - * 1.14 - * 2. Redistributions in binary form must reproduce the above copyright 1.15 - * notice, this list of conditions and the following disclaimer in the 1.16 - * documentation and/or other materials provided with the distribution. 1.17 - * 1.18 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 1.19 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1.20 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1.21 - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 1.22 - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 1.23 - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 1.24 - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 1.25 - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 1.26 - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 1.27 - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 1.28 - * POSSIBILITY OF SUCH DAMAGE. 1.29 - */ 1.30 - 1.31 -#include <ascension/ascension.h> 1.32 -#include <cx/printf.h> 1.33 - 1.34 -static bool show_message_box_on_error(SDL_Window* window) { 1.35 - if (asc_has_error()) { 1.36 - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, 1.37 - "Fatal Error", 1.38 - asc_get_error(), 1.39 - window); 1.40 - asc_clear_error(); 1.41 - return true; 1.42 - } else { 1.43 - return false; 1.44 - } 1.45 -} 1.46 - 1.47 -int main(int argc, char** argv) { 1.48 - asc_context_initialize(); 1.49 - if (show_message_box_on_error(NULL)) return 1; 1.50 - 1.51 - AscWindowSettings settings; 1.52 - asc_window_settings_init_defaults(&settings); 1.53 - settings.title = "Sandbox Application"; 1.54 - 1.55 - AscWindow *window = asc_window_initialize(0, &settings); 1.56 - asc_shader_initialize_predefined(); 1.57 - 1.58 - // create fps counter and add it to the UI 1.59 - asc_set_font(asc_font(ASC_FONT_REGULAR, 24)); 1.60 - asc_ink_rgb(255, 0, 0); 1.61 - AscText *fps_counter = asc_text(50, 50, "XXXXX FPS"); 1.62 - unsigned last_fps = 0; 1.63 - asc_scene_add(&window->ui, asc_node(fps_counter)); 1.64 - 1.65 - do { 1.66 - // quit application on any error 1.67 - if (show_message_box_on_error(window->window)) break; 1.68 - 1.69 - // update fps counter 1.70 - if (asc_context.elapsed_millis > 0) { 1.71 - unsigned fps = 1000u / asc_context.elapsed_millis; 1.72 - if (fps != last_fps) { 1.73 - last_fps = fps; 1.74 - snprintf(fps_counter->text, 9, "%u FPS", fps); 1.75 - asc_node_update(fps_counter); 1.76 - } 1.77 - } 1.78 - } while (asc_loop_next()); 1.79 - 1.80 - asc_context_destroy(); 1.81 - return 0; 1.82 -} 1.83 -