Thu, 29 May 2025 11:20:49 +0200
remove unused context variable
/* * 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_WINDOW_H #define ASCENSION_WINDOW_H #include <SDL2/SDL.h> #include "datatypes.h" #include "glcontext.h" #include "scene.h" #ifndef ASC_MAX_WINDOWS /** The maximum number of windows that can exist simultaneously. */ #define ASC_MAX_WINDOWS 4u #endif // ASC_MAX_WINDOWS #ifndef ASC_MAX_SCENES /** The maximum number of non-UI scenes per window. */ #define ASC_MAX_SCENES 8u #endif // ASC_MAX_SCENES typedef struct AscWindowSettings { AscGLContextSettings glsettings; asc_vec2i dimensions; char const* title; bool fullscreen; } AscWindowSettings; typedef struct AscWindow { Uint32 id; bool resized; bool focused; SDL_Window* window; asc_vec2u dimensions; AscGLContext glctx; AscScene ui; AscScene scenes[ASC_MAX_SCENES]; } AscWindow; /** * Initializes the settings structure with default values. * * @param settings an uninitialized settings object */ void asc_window_settings_init_defaults(AscWindowSettings* settings); /** * Creates and initializes a new window and a corresponding OpenGL context. * * The new window will also be automatically activated (see asc_window_activate()). * * The index specified must not be in use by another window already. * The maximum number of windows is defined by #ASC_MAX_WINDOWS. * * @param index the index of the new window * @param settings the settings to be used for initialization */ void asc_window_initialize(unsigned int index, AscWindowSettings const* settings); /** * Destroys the window and its OpenGL context. * * When this window is currently active, there * will be \em no active window afterwards. * * Still alive windows will also be destroyed by asc_context_destroy() * automatically. * * @param index the index of the window */ void asc_window_destroy(unsigned int index); /** * Swaps buffers and adjusts the viewport to the current window size. * * This function is automatically invoked by asc_loop_next(). * You usually should not call this function manually. * * If this function is invoked on a non-initialized window, nothing happens. * * @param index the index of the window */ void asc_window_sync(unsigned int index); /** * Switches the active window. * * In particular that makes the corresponding OpenGL context "current". * When you only want to draw into one window, you'll never need this. * * @param index the index of the window */ void asc_window_activate(unsigned int index); /** * Returns the index of the window with the specified SDL window ID. * * Returns #ASC_MAX_WINDOWS if no window with the specified ID exists. * * @param id the SDL window ID * @return the window index */ unsigned int asc_window_index(Uint32 id); /** * Returns a pointer to the scene within the currently active window with the specified index. * * If you want to use a scene, you need to initialize it first. * You can destroy the scene any time you want, but used scenes are also * destroyed automatically when the window gets destroyed. * * @param index an index less than #ASC_MAX_SCENES * @return a pointer to the scene */ AscScene *asc_window_scene(unsigned int index); void asc_add_ui_node(AscSceneNode *node); #endif /* ASCENSION_WINDOW_H */