src/ascension/texture.h

Thu, 18 Apr 2024 22:53:55 +0200

author
Mike Becker <universe@uap-core.de>
date
Thu, 18 Apr 2024 22:53:55 +0200
changeset 65
9c44c55d327a
parent 50
d8d2e4817db1
permissions
-rw-r--r--

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@50 1 /*
universe@50 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
universe@50 3 * Copyright 2024 Mike Becker. All rights reserved.
universe@50 4 *
universe@50 5 * Redistribution and use in source and binary forms, with or without
universe@50 6 * modification, are permitted provided that the following conditions are met:
universe@50 7 *
universe@50 8 * 1. Redistributions of source code must retain the above copyright
universe@50 9 * notice, this list of conditions and the following disclaimer.
universe@50 10 *
universe@50 11 * 2. Redistributions in binary form must reproduce the above copyright
universe@50 12 * notice, this list of conditions and the following disclaimer in the
universe@50 13 * documentation and/or other materials provided with the distribution.
universe@50 14 *
universe@50 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
universe@50 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
universe@50 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
universe@50 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
universe@50 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
universe@50 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
universe@50 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
universe@50 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
universe@50 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
universe@50 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
universe@50 25 * POSSIBILITY OF SUCH DAMAGE.
universe@50 26 */
universe@50 27
universe@50 28 #ifndef ASCENSION_TEXTURE_H
universe@50 29 #define ASCENSION_TEXTURE_H
universe@50 30
universe@50 31 #include <SDL2/SDL_surface.h>
universe@50 32
universe@50 33 typedef struct AscTexture AscTexture;
universe@50 34
universe@50 35 struct AscTexture {
universe@50 36 unsigned target;
universe@50 37 unsigned tex_id;
universe@50 38 };
universe@50 39
universe@50 40 #define asc_texture_uninitialized(tex) ((tex)->tex_id == 0)
universe@50 41
universe@50 42 enum asc_texture_target {
universe@50 43 ASC_TEXTURE_RECTANGLE
universe@50 44 };
universe@50 45
universe@50 46 enum asc_texture_min_filter {
universe@50 47 ASC_TEXTURE_MIN_FILTER_NEAREST,
universe@50 48 ASC_TEXTURE_MIN_FILTER_LINEAR,
universe@50 49 ASC_TEXTURE_MIN_FILTER_NEAREST_MIPMAP_NEAREST,
universe@50 50 ASC_TEXTURE_MIN_FILTER_LINEAR_MIPMAP_NEAREST,
universe@50 51 ASC_TEXTURE_MIN_FILTER_NEAREST_MIPMAP_LINEAR,
universe@50 52 ASC_TEXTURE_MIN_FILTER_LINEAR_MIPMAP_LINEAR
universe@50 53 };
universe@50 54
universe@50 55 enum asc_texture_mag_filter {
universe@50 56 ASC_TEXTURE_MAG_FILTER_NEAREST,
universe@50 57 ASC_TEXTURE_MAG_FILTER_LINEAR
universe@50 58 };
universe@50 59
universe@50 60 __attribute__((__nonnull__))
universe@50 61 void asc_texture_init(
universe@50 62 AscTexture *tex,
universe@50 63 enum asc_texture_target target,
universe@50 64 enum asc_texture_min_filter min_filter,
universe@50 65 enum asc_texture_mag_filter mag_filter
universe@50 66 );
universe@50 67
universe@50 68 __attribute__((__nonnull__))
universe@50 69 void asc_texture_destroy(AscTexture *tex);
universe@50 70
universe@50 71 #define asc_texture_init_rectangle(tex) \
universe@50 72 asc_texture_init(tex, ASC_TEXTURE_RECTANGLE, \
universe@50 73 ASC_TEXTURE_MIN_FILTER_LINEAR, ASC_TEXTURE_MAG_FILTER_LINEAR)
universe@50 74
universe@50 75 __attribute__((__nonnull__))
universe@50 76 void asc_texture_bind(AscTexture const *tex, int uniform_location, int unit);
universe@50 77
universe@50 78 __attribute__((__nonnull__))
universe@50 79 void asc_texture_from_surface(AscTexture *tex, SDL_Surface const *surface);
universe@50 80
universe@50 81 #endif //ASCENSION_TEXTURE_H

mercurial