src/ascension/shader.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@15 1 /*
universe@15 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
universe@15 3 * Copyright 2023 Mike Becker. All rights reserved.
universe@15 4 *
universe@15 5 * Redistribution and use in source and binary forms, with or without
universe@15 6 * modification, are permitted provided that the following conditions are met:
universe@15 7 *
universe@15 8 * 1. Redistributions of source code must retain the above copyright
universe@15 9 * notice, this list of conditions and the following disclaimer.
universe@15 10 *
universe@15 11 * 2. Redistributions in binary form must reproduce the above copyright
universe@15 12 * notice, this list of conditions and the following disclaimer in the
universe@15 13 * documentation and/or other materials provided with the distribution.
universe@15 14 *
universe@15 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
universe@15 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
universe@15 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
universe@15 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
universe@15 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
universe@15 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
universe@15 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
universe@15 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
universe@15 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
universe@15 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
universe@15 25 * POSSIBILITY OF SUCH DAMAGE.
universe@15 26 */
universe@15 27
universe@15 28 #ifndef ASCENSION_SHADER_H
universe@15 29 #define ASCENSION_SHADER_H
universe@15 30
universe@15 31 typedef struct AscShader {
universe@15 32 unsigned int id;
universe@15 33 } AscShader;
universe@15 34
universe@15 35 typedef struct AscShaderProgram {
universe@15 36 unsigned int id;
universe@16 37 int model;
universe@16 38 int view;
universe@16 39 int projection;
universe@15 40 } AscShaderProgram;
universe@15 41
universe@40 42 typedef struct AscShaderSprite {
universe@16 43 AscShaderProgram base;
universe@41 44 int depth;
universe@50 45 int tex;
universe@40 46 } AscShaderSprite;
universe@15 47
universe@16 48
universe@15 49 /**
universe@15 50 * Compiles a shader from the given source code.
universe@15 51 *
universe@15 52 * The ID of the returned shader will be zero when something went wrong.
universe@15 53 *
universe@15 54 * @param type the shader type (use the GL enum)
universe@15 55 * @param code the source code
universe@15 56 * @param length the length of the source code
universe@15 57 * @return the compiled shader
universe@15 58 */
universe@15 59 AscShader asc_shader_compile(unsigned int type, char const *code, int length);
universe@15 60
universe@15 61 /**
universe@15 62 * Compiles a shader from the given source file.
universe@15 63 *
universe@15 64 * The ID of the returned shader will be zero when something went wrong.
universe@15 65 * The file is mapped into memory for compilation and then unmapped again.
universe@15 66 *
universe@15 67 * @param type the shader type (use the GL enum)
universe@15 68 * @param filename the path to the shader file
universe@15 69 * @return the compiled shader
universe@15 70 */
universe@15 71 AscShader asc_shader_compilef(unsigned int type, char const *filename);
universe@15 72
universe@15 73 /**
universe@15 74 * This function links shaders into a program.
universe@15 75 *
universe@15 76 * The ID of the returned program will be zero when something went wrong.
universe@15 77 *
universe@15 78 * @param vertex the vertex shader
universe@15 79 * @param fragment the fragment shader
universe@15 80 * @return a compiled program
universe@15 81 */
universe@15 82 AscShaderProgram asc_shader_link(AscShader vertex, AscShader fragment);
universe@15 83
universe@15 84 /**
universe@15 85 * Destroys the shader.
universe@15 86 *
universe@15 87 * @param shader the shader
universe@15 88 */
universe@15 89 void asc_shader_destroy(AscShader shader);
universe@15 90
universe@15 91 /**
universe@15 92 * Destroys the shader program.
universe@15 93 *
universe@15 94 * @param program the program
universe@15 95 */
universe@15 96 void asc_shader_program_destroy(AscShaderProgram program);
universe@15 97
universe@15 98
universe@44 99 AscShaderProgram asc_shader_easy_compile_and_link(
universe@44 100 char const *vtxName,
universe@44 101 char const *fragName
universe@44 102 );
universe@15 103
universe@15 104 #endif //ASCENSION_SHADER_H

mercurial