Sat, 19 Apr 2025 11:42:53 +0200
add generic mesh draw function and move sprite draw function to separate unit
3 | 1 | /* |
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | |
3 | * Copyright 2023 Mike Becker. All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms, with or without | |
6 | * modification, are permitted provided that the following conditions are met: | |
7 | * | |
8 | * 1. Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | |
14 | * | |
15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | |
19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
25 | * POSSIBILITY OF SUCH DAMAGE. | |
26 | */ | |
27 | ||
16
c5dde81b6fb2
add text rendering and demo FPS counter
Mike Becker <universe@uap-core.de>
parents:
14
diff
changeset
|
28 | #ifndef ASCENSION_MESH_H |
c5dde81b6fb2
add text rendering and demo FPS counter
Mike Becker <universe@uap-core.de>
parents:
14
diff
changeset
|
29 | #define ASCENSION_MESH_H |
4
b7acda6a4476
add simple color data types
Mike Becker <universe@uap-core.de>
parents:
3
diff
changeset
|
30 | |
16
c5dde81b6fb2
add text rendering and demo FPS counter
Mike Becker <universe@uap-core.de>
parents:
14
diff
changeset
|
31 | typedef struct AscMesh { |
c5dde81b6fb2
add text rendering and demo FPS counter
Mike Becker <universe@uap-core.de>
parents:
14
diff
changeset
|
32 | unsigned vbo; |
c5dde81b6fb2
add text rendering and demo FPS counter
Mike Becker <universe@uap-core.de>
parents:
14
diff
changeset
|
33 | unsigned vao; |
c5dde81b6fb2
add text rendering and demo FPS counter
Mike Becker <universe@uap-core.de>
parents:
14
diff
changeset
|
34 | unsigned vertices; |
c5dde81b6fb2
add text rendering and demo FPS counter
Mike Becker <universe@uap-core.de>
parents:
14
diff
changeset
|
35 | } AscMesh; |
11 | 36 | |
81
84a546e282b7
create catch-all util for GL errors + refactors mesh creation
Mike Becker <universe@uap-core.de>
parents:
16
diff
changeset
|
37 | /** |
84a546e282b7
create catch-all util for GL errors + refactors mesh creation
Mike Becker <universe@uap-core.de>
parents:
16
diff
changeset
|
38 | * Allocates VBO and VAO for one or more meshes. |
84a546e282b7
create catch-all util for GL errors + refactors mesh creation
Mike Becker <universe@uap-core.de>
parents:
16
diff
changeset
|
39 | * |
84a546e282b7
create catch-all util for GL errors + refactors mesh creation
Mike Becker <universe@uap-core.de>
parents:
16
diff
changeset
|
40 | * @param mesh pointer to a mesh or an array of meshes |
84a546e282b7
create catch-all util for GL errors + refactors mesh creation
Mike Becker <universe@uap-core.de>
parents:
16
diff
changeset
|
41 | * @param count the number of meshes (maximum 32) |
84a546e282b7
create catch-all util for GL errors + refactors mesh creation
Mike Becker <universe@uap-core.de>
parents:
16
diff
changeset
|
42 | */ |
84a546e282b7
create catch-all util for GL errors + refactors mesh creation
Mike Becker <universe@uap-core.de>
parents:
16
diff
changeset
|
43 | void asc_mesh_allocate_buffers(AscMesh *mesh, unsigned count); |
84a546e282b7
create catch-all util for GL errors + refactors mesh creation
Mike Becker <universe@uap-core.de>
parents:
16
diff
changeset
|
44 | |
84a546e282b7
create catch-all util for GL errors + refactors mesh creation
Mike Becker <universe@uap-core.de>
parents:
16
diff
changeset
|
45 | /** |
84a546e282b7
create catch-all util for GL errors + refactors mesh creation
Mike Becker <universe@uap-core.de>
parents:
16
diff
changeset
|
46 | * Frees VBO and VAO for one or more meshes. |
84a546e282b7
create catch-all util for GL errors + refactors mesh creation
Mike Becker <universe@uap-core.de>
parents:
16
diff
changeset
|
47 | * |
84a546e282b7
create catch-all util for GL errors + refactors mesh creation
Mike Becker <universe@uap-core.de>
parents:
16
diff
changeset
|
48 | * @param mesh pointer to a mesh or an array of meshes |
84a546e282b7
create catch-all util for GL errors + refactors mesh creation
Mike Becker <universe@uap-core.de>
parents:
16
diff
changeset
|
49 | * @param count the number of meshes (maximum 32) |
84a546e282b7
create catch-all util for GL errors + refactors mesh creation
Mike Becker <universe@uap-core.de>
parents:
16
diff
changeset
|
50 | */ |
84a546e282b7
create catch-all util for GL errors + refactors mesh creation
Mike Becker <universe@uap-core.de>
parents:
16
diff
changeset
|
51 | void asc_mesh_free_buffers(AscMesh *mesh, unsigned count); |
84a546e282b7
create catch-all util for GL errors + refactors mesh creation
Mike Becker <universe@uap-core.de>
parents:
16
diff
changeset
|
52 | |
82
4e1e698f4b0d
add generic mesh draw function and move sprite draw function to separate unit
Mike Becker <universe@uap-core.de>
parents:
81
diff
changeset
|
53 | /** |
4e1e698f4b0d
add generic mesh draw function and move sprite draw function to separate unit
Mike Becker <universe@uap-core.de>
parents:
81
diff
changeset
|
54 | * Draws the mesh as a triangle strip. |
4e1e698f4b0d
add generic mesh draw function and move sprite draw function to separate unit
Mike Becker <universe@uap-core.de>
parents:
81
diff
changeset
|
55 | * |
4e1e698f4b0d
add generic mesh draw function and move sprite draw function to separate unit
Mike Becker <universe@uap-core.de>
parents:
81
diff
changeset
|
56 | * @param mesh the mesh to draw |
4e1e698f4b0d
add generic mesh draw function and move sprite draw function to separate unit
Mike Becker <universe@uap-core.de>
parents:
81
diff
changeset
|
57 | */ |
4e1e698f4b0d
add generic mesh draw function and move sprite draw function to separate unit
Mike Becker <universe@uap-core.de>
parents:
81
diff
changeset
|
58 | void asc_mesh_draw_triangle_strip(AscMesh *mesh); |
4e1e698f4b0d
add generic mesh draw function and move sprite draw function to separate unit
Mike Becker <universe@uap-core.de>
parents:
81
diff
changeset
|
59 | |
16
c5dde81b6fb2
add text rendering and demo FPS counter
Mike Becker <universe@uap-core.de>
parents:
14
diff
changeset
|
60 | #endif //ASCENSION_MESH_H |