Mon, 18 Dec 2023 19:05:30 +0100
use new cxBufferReset function
/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * Copyright 2023 Mike Becker. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifndef ASCENSION_CONTEXT_H #define ASCENSION_CONTEXT_H #include "datatypes.h" #include "window.h" #include "font.h" #include <cx/buffer.h> #include <cx/list.h> /** The flag for the overall initialized state. */ #define ASC_FLAG_INITILIZED 0x01u /** Flag is set, when error buffer contains new error information. */ #define ASC_FLAG_HAS_ERROR 0x02u /** Flag is set, when SDL wants to quit the application. */ #define ASC_FLAG_QUIT 0x80000000u /** * The global ascension context. */ typedef struct AscContext { unsigned int flags; CxBuffer error_buffer; AscWindow windows[ASC_MAX_WINDOWS]; AscWindow const *active_window; AscFont fonts[ASC_MAX_FONTS]; unsigned int fonts_loaded; AscFont const *active_font; asc_col4i ink; unsigned int elapsed_millis; float elapsed; } AscContext; /** Global ascension context. */ extern AscContext asc_context; void asc_context_initialize(void); void asc_context_destroy(void); /** * Dispatches events and synchronizes all initialized windows. * * @return false, if the application wants to quit, true otherwise */ bool asc_loop_next(void); /** * Sets the active drawing color. */ #define asc_ink(color) asc_context.ink = (color) #define asc_ink_rgba(r,g,b,a) asc_context.ink = (asc_col4i){(r),(g),(b),(a)} #define asc_ink_rgb(r,g,b) asc_context.ink = (asc_col4i){(r),(g),(b),255u} /** * Sets the active drawing font. */ #define asc_set_font(font) asc_context.active_font = (font) #endif /* ASCENSION_CONTEXT_H */