Thu, 18 Apr 2024 22:53:55 +0200
consistently refer to windows by ID - fixes #381
This change discovered that the font cache is completely broken. We created issue #387 for this.
universe@44 | 1 | /* |
universe@44 | 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
universe@44 | 3 | * Copyright 2023 Mike Becker. All rights reserved. |
universe@44 | 4 | * |
universe@44 | 5 | * Redistribution and use in source and binary forms, with or without |
universe@44 | 6 | * modification, are permitted provided that the following conditions are met: |
universe@44 | 7 | * |
universe@44 | 8 | * 1. Redistributions of source code must retain the above copyright |
universe@44 | 9 | * notice, this list of conditions and the following disclaimer. |
universe@44 | 10 | * |
universe@44 | 11 | * 2. Redistributions in binary form must reproduce the above copyright |
universe@44 | 12 | * notice, this list of conditions and the following disclaimer in the |
universe@44 | 13 | * documentation and/or other materials provided with the distribution. |
universe@44 | 14 | * |
universe@44 | 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
universe@44 | 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
universe@44 | 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
universe@44 | 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
universe@44 | 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
universe@44 | 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
universe@44 | 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
universe@44 | 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
universe@44 | 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
universe@44 | 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
universe@44 | 25 | * POSSIBILITY OF SUCH DAMAGE. |
universe@44 | 26 | */ |
universe@44 | 27 | |
universe@44 | 28 | #ifndef ASCENSION_GLCONTEXT_H |
universe@44 | 29 | #define ASCENSION_GLCONTEXT_H |
universe@44 | 30 | |
universe@44 | 31 | #include <SDL2/SDL.h> |
universe@44 | 32 | |
universe@44 | 33 | #include "primitives.h" |
universe@44 | 34 | #include "shader.h" |
universe@44 | 35 | |
universe@44 | 36 | typedef struct AscGLContextSettings { |
universe@44 | 37 | int gl_major_version; |
universe@44 | 38 | int gl_minor_version; |
universe@44 | 39 | int vsync; |
universe@44 | 40 | int depth_size; |
universe@44 | 41 | } AscGLContextSettings; |
universe@44 | 42 | |
universe@44 | 43 | typedef struct AscGLContext { |
universe@44 | 44 | SDL_Window *window; |
universe@44 | 45 | SDL_GLContext glctx; |
universe@44 | 46 | AscPrimitives primitives; |
universe@44 | 47 | struct { |
universe@44 | 48 | AscShaderSprite sprite; |
universe@44 | 49 | } shader; |
universe@44 | 50 | } AscGLContext; |
universe@44 | 51 | |
universe@44 | 52 | __attribute__((__nonnull__, __warn_unused_result__)) |
universe@44 | 53 | bool asc_gl_context_initialize( |
universe@44 | 54 | AscGLContext *ctx, |
universe@44 | 55 | SDL_Window *window, |
universe@44 | 56 | AscGLContextSettings const *settings |
universe@44 | 57 | ); |
universe@44 | 58 | |
universe@44 | 59 | __attribute__((__nonnull__)) |
universe@44 | 60 | void asc_gl_context_destroy(AscGLContext *ctx); |
universe@44 | 61 | |
universe@44 | 62 | __attribute__((__nonnull__)) |
universe@44 | 63 | static inline void asc_gl_context_activate(AscGLContext *ctx) { |
universe@44 | 64 | SDL_GL_MakeCurrent(ctx->window, ctx->glctx); |
universe@44 | 65 | } |
universe@44 | 66 | |
universe@44 | 67 | #endif //ASCENSION_GLCONTEXT_H |