Mercurial
annotate third_party/raylib/raylib-5.5_macos/include/rlgl.h @ 22:947b81010aba
[Dowa & Seobeo] Updated so that Dowa hashmaps can use arena and not be broken. Split up web so taht it can handle different paths. Also fixes issues with hash collisions which was pain in the ass.
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Tue, 07 Oct 2025 07:11:02 -0700 |
| parents | 5695ef413be0 |
| children |
| rev | line source |
|---|---|
|
0
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1 /********************************************************************************************** |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2 * |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3 * rlgl v5.0 - A multi-OpenGL abstraction layer with an immediate-mode style API |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4 * |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5 * DESCRIPTION: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
6 * An abstraction layer for multiple OpenGL versions (1.1, 2.1, 3.3 Core, 4.3 Core, ES 2.0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
7 * that provides a pseudo-OpenGL 1.1 immediate-mode style API (rlVertex, rlTranslate, rlRotate...) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
8 * |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
9 * ADDITIONAL NOTES: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
10 * When choosing an OpenGL backend different than OpenGL 1.1, some internal buffer are |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
11 * initialized on rlglInit() to accumulate vertex data |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
12 * |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
13 * When an internal state change is required all the stored vertex data is renderer in batch, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
14 * additionally, rlDrawRenderBatchActive() could be called to force flushing of the batch |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
15 * |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
16 * Some resources are also loaded for convenience, here the complete list: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
17 * - Default batch (RLGL.defaultBatch): RenderBatch system to accumulate vertex data |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
18 * - Default texture (RLGL.defaultTextureId): 1x1 white pixel R8G8B8A8 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
19 * - Default shader (RLGL.State.defaultShaderId, RLGL.State.defaultShaderLocs) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
20 * |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
21 * Internal buffer (and resources) must be manually unloaded calling rlglClose() |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
22 * |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
23 * CONFIGURATION: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
24 * #define GRAPHICS_API_OPENGL_11 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
25 * #define GRAPHICS_API_OPENGL_21 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
26 * #define GRAPHICS_API_OPENGL_33 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
27 * #define GRAPHICS_API_OPENGL_43 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
28 * #define GRAPHICS_API_OPENGL_ES2 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
29 * #define GRAPHICS_API_OPENGL_ES3 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
30 * Use selected OpenGL graphics backend, should be supported by platform |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
31 * Those preprocessor defines are only used on rlgl module, if OpenGL version is |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
32 * required by any other module, use rlGetVersion() to check it |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
33 * |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
34 * #define RLGL_IMPLEMENTATION |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
35 * Generates the implementation of the library into the included file |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
36 * If not defined, the library is in header only mode and can be included in other headers |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
37 * or source files without problems. But only ONE file should hold the implementation |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
38 * |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
39 * #define RLGL_RENDER_TEXTURES_HINT |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
40 * Enable framebuffer objects (fbo) support (enabled by default) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
41 * Some GPUs could not support them despite the OpenGL version |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
42 * |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
43 * #define RLGL_SHOW_GL_DETAILS_INFO |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
44 * Show OpenGL extensions and capabilities detailed logs on init |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
45 * |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
46 * #define RLGL_ENABLE_OPENGL_DEBUG_CONTEXT |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
47 * Enable debug context (only available on OpenGL 4.3) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
48 * |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
49 * rlgl capabilities could be customized just defining some internal |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
50 * values before library inclusion (default values listed): |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
51 * |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
52 * #define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 8192 // Default internal render batch elements limits |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
53 * #define RL_DEFAULT_BATCH_BUFFERS 1 // Default number of batch buffers (multi-buffering) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
54 * #define RL_DEFAULT_BATCH_DRAWCALLS 256 // Default number of batch draw calls (by state changes: mode, texture) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
55 * #define RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS 4 // Maximum number of textures units that can be activated on batch drawing (SetShaderValueTexture()) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
56 * |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
57 * #define RL_MAX_MATRIX_STACK_SIZE 32 // Maximum size of internal Matrix stack |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
58 * #define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
59 * #define RL_CULL_DISTANCE_NEAR 0.01 // Default projection matrix near cull distance |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
60 * #define RL_CULL_DISTANCE_FAR 1000.0 // Default projection matrix far cull distance |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
61 * |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
62 * When loading a shader, the following vertex attributes and uniform |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
63 * location names are tried to be set automatically: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
64 * |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
65 * #define RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION "vertexPosition" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
66 * #define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD "vertexTexCoord" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
67 * #define RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL "vertexNormal" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
68 * #define RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR "vertexColor" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_COLOR |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
69 * #define RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT "vertexTangent" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
70 * #define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2 "vertexTexCoord2" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
71 * #define RL_DEFAULT_SHADER_ATTRIB_NAME_BONEIDS "vertexBoneIds" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEIDS |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
72 * #define RL_DEFAULT_SHADER_ATTRIB_NAME_BONEWEIGHTS "vertexBoneWeights" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
73 * #define RL_DEFAULT_SHADER_UNIFORM_NAME_MVP "mvp" // model-view-projection matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
74 * #define RL_DEFAULT_SHADER_UNIFORM_NAME_VIEW "matView" // view matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
75 * #define RL_DEFAULT_SHADER_UNIFORM_NAME_PROJECTION "matProjection" // projection matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
76 * #define RL_DEFAULT_SHADER_UNIFORM_NAME_MODEL "matModel" // model matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
77 * #define RL_DEFAULT_SHADER_UNIFORM_NAME_NORMAL "matNormal" // normal matrix (transpose(inverse(matModelView))) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
78 * #define RL_DEFAULT_SHADER_UNIFORM_NAME_COLOR "colDiffuse" // color diffuse (base tint color, multiplied by texture color) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
79 * #define RL_DEFAULT_SHADER_UNIFORM_NAME_BONE_MATRICES "boneMatrices" // bone matrices |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
80 * #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE0 "texture0" // texture0 (texture slot active 0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
81 * #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE1 "texture1" // texture1 (texture slot active 1) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
82 * #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE2 "texture2" // texture2 (texture slot active 2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
83 * |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
84 * DEPENDENCIES: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
85 * - OpenGL libraries (depending on platform and OpenGL version selected) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
86 * - GLAD OpenGL extensions loading library (only for OpenGL 3.3 Core, 4.3 Core) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
87 * |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
88 * |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
89 * LICENSE: zlib/libpng |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
90 * |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
91 * Copyright (c) 2014-2024 Ramon Santamaria (@raysan5) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
92 * |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
93 * This software is provided "as-is", without any express or implied warranty. In no event |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
94 * will the authors be held liable for any damages arising from the use of this software. |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
95 * |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
96 * Permission is granted to anyone to use this software for any purpose, including commercial |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
97 * applications, and to alter it and redistribute it freely, subject to the following restrictions: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
98 * |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
99 * 1. The origin of this software must not be misrepresented; you must not claim that you |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
100 * wrote the original software. If you use this software in a product, an acknowledgment |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
101 * in the product documentation would be appreciated but is not required. |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
102 * |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
103 * 2. Altered source versions must be plainly marked as such, and must not be misrepresented |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
104 * as being the original software. |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
105 * |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
106 * 3. This notice may not be removed or altered from any source distribution. |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
107 * |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
108 **********************************************************************************************/ |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
109 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
110 #ifndef RLGL_H |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
111 #define RLGL_H |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
112 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
113 #define RLGL_VERSION "5.0" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
114 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
115 // Function specifiers in case library is build/used as a shared library |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
116 // NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
117 // NOTE: visibility(default) attribute makes symbols "visible" when compiled with -fvisibility=hidden |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
118 #if defined(_WIN32) && defined(BUILD_LIBTYPE_SHARED) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
119 #define RLAPI __declspec(dllexport) // We are building the library as a Win32 shared library (.dll) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
120 #elif defined(BUILD_LIBTYPE_SHARED) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
121 #define RLAPI __attribute__((visibility("default"))) // We are building the library as a Unix shared library (.so/.dylib) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
122 #elif defined(_WIN32) && defined(USE_LIBTYPE_SHARED) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
123 #define RLAPI __declspec(dllimport) // We are using the library as a Win32 shared library (.dll) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
124 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
125 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
126 // Function specifiers definition |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
127 #ifndef RLAPI |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
128 #define RLAPI // Functions defined as 'extern' by default (implicit specifiers) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
129 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
130 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
131 // Support TRACELOG macros |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
132 #ifndef TRACELOG |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
133 #define TRACELOG(level, ...) (void)0 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
134 #define TRACELOGD(...) (void)0 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
135 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
136 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
137 // Allow custom memory allocators |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
138 #ifndef RL_MALLOC |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
139 #define RL_MALLOC(sz) malloc(sz) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
140 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
141 #ifndef RL_CALLOC |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
142 #define RL_CALLOC(n,sz) calloc(n,sz) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
143 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
144 #ifndef RL_REALLOC |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
145 #define RL_REALLOC(n,sz) realloc(n,sz) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
146 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
147 #ifndef RL_FREE |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
148 #define RL_FREE(p) free(p) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
149 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
150 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
151 // Security check in case no GRAPHICS_API_OPENGL_* defined |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
152 #if !defined(GRAPHICS_API_OPENGL_11) && \ |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
153 !defined(GRAPHICS_API_OPENGL_21) && \ |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
154 !defined(GRAPHICS_API_OPENGL_33) && \ |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
155 !defined(GRAPHICS_API_OPENGL_43) && \ |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
156 !defined(GRAPHICS_API_OPENGL_ES2) && \ |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
157 !defined(GRAPHICS_API_OPENGL_ES3) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
158 #define GRAPHICS_API_OPENGL_33 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
159 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
160 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
161 // Security check in case multiple GRAPHICS_API_OPENGL_* defined |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
162 #if defined(GRAPHICS_API_OPENGL_11) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
163 #if defined(GRAPHICS_API_OPENGL_21) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
164 #undef GRAPHICS_API_OPENGL_21 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
165 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
166 #if defined(GRAPHICS_API_OPENGL_33) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
167 #undef GRAPHICS_API_OPENGL_33 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
168 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
169 #if defined(GRAPHICS_API_OPENGL_43) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
170 #undef GRAPHICS_API_OPENGL_43 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
171 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
172 #if defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
173 #undef GRAPHICS_API_OPENGL_ES2 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
174 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
175 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
176 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
177 // OpenGL 2.1 uses most of OpenGL 3.3 Core functionality |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
178 // WARNING: Specific parts are checked with #if defines |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
179 #if defined(GRAPHICS_API_OPENGL_21) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
180 #define GRAPHICS_API_OPENGL_33 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
181 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
182 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
183 // OpenGL 4.3 uses OpenGL 3.3 Core functionality |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
184 #if defined(GRAPHICS_API_OPENGL_43) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
185 #define GRAPHICS_API_OPENGL_33 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
186 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
187 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
188 // OpenGL ES 3.0 uses OpenGL ES 2.0 functionality (and more) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
189 #if defined(GRAPHICS_API_OPENGL_ES3) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
190 #define GRAPHICS_API_OPENGL_ES2 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
191 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
192 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
193 // Support framebuffer objects by default |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
194 // NOTE: Some driver implementation do not support it, despite they should |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
195 #define RLGL_RENDER_TEXTURES_HINT |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
196 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
197 //---------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
198 // Defines and Macros |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
199 //---------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
200 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
201 // Default internal render batch elements limits |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
202 #ifndef RL_DEFAULT_BATCH_BUFFER_ELEMENTS |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
203 #if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_33) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
204 // This is the maximum amount of elements (quads) per batch |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
205 // NOTE: Be careful with text, every letter maps to a quad |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
206 #define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 8192 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
207 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
208 #if defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
209 // We reduce memory sizes for embedded systems (RPI and HTML5) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
210 // NOTE: On HTML5 (emscripten) this is allocated on heap, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
211 // by default it's only 16MB!...just take care... |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
212 #define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 2048 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
213 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
214 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
215 #ifndef RL_DEFAULT_BATCH_BUFFERS |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
216 #define RL_DEFAULT_BATCH_BUFFERS 1 // Default number of batch buffers (multi-buffering) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
217 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
218 #ifndef RL_DEFAULT_BATCH_DRAWCALLS |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
219 #define RL_DEFAULT_BATCH_DRAWCALLS 256 // Default number of batch draw calls (by state changes: mode, texture) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
220 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
221 #ifndef RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
222 #define RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS 4 // Maximum number of textures units that can be activated on batch drawing (SetShaderValueTexture()) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
223 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
224 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
225 // Internal Matrix stack |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
226 #ifndef RL_MAX_MATRIX_STACK_SIZE |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
227 #define RL_MAX_MATRIX_STACK_SIZE 32 // Maximum size of Matrix stack |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
228 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
229 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
230 // Shader limits |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
231 #ifndef RL_MAX_SHADER_LOCATIONS |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
232 #define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
233 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
234 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
235 // Projection matrix culling |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
236 #ifndef RL_CULL_DISTANCE_NEAR |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
237 #define RL_CULL_DISTANCE_NEAR 0.01 // Default near cull distance |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
238 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
239 #ifndef RL_CULL_DISTANCE_FAR |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
240 #define RL_CULL_DISTANCE_FAR 1000.0 // Default far cull distance |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
241 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
242 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
243 // Texture parameters (equivalent to OpenGL defines) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
244 #define RL_TEXTURE_WRAP_S 0x2802 // GL_TEXTURE_WRAP_S |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
245 #define RL_TEXTURE_WRAP_T 0x2803 // GL_TEXTURE_WRAP_T |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
246 #define RL_TEXTURE_MAG_FILTER 0x2800 // GL_TEXTURE_MAG_FILTER |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
247 #define RL_TEXTURE_MIN_FILTER 0x2801 // GL_TEXTURE_MIN_FILTER |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
248 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
249 #define RL_TEXTURE_FILTER_NEAREST 0x2600 // GL_NEAREST |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
250 #define RL_TEXTURE_FILTER_LINEAR 0x2601 // GL_LINEAR |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
251 #define RL_TEXTURE_FILTER_MIP_NEAREST 0x2700 // GL_NEAREST_MIPMAP_NEAREST |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
252 #define RL_TEXTURE_FILTER_NEAREST_MIP_LINEAR 0x2702 // GL_NEAREST_MIPMAP_LINEAR |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
253 #define RL_TEXTURE_FILTER_LINEAR_MIP_NEAREST 0x2701 // GL_LINEAR_MIPMAP_NEAREST |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
254 #define RL_TEXTURE_FILTER_MIP_LINEAR 0x2703 // GL_LINEAR_MIPMAP_LINEAR |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
255 #define RL_TEXTURE_FILTER_ANISOTROPIC 0x3000 // Anisotropic filter (custom identifier) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
256 #define RL_TEXTURE_MIPMAP_BIAS_RATIO 0x4000 // Texture mipmap bias, percentage ratio (custom identifier) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
257 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
258 #define RL_TEXTURE_WRAP_REPEAT 0x2901 // GL_REPEAT |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
259 #define RL_TEXTURE_WRAP_CLAMP 0x812F // GL_CLAMP_TO_EDGE |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
260 #define RL_TEXTURE_WRAP_MIRROR_REPEAT 0x8370 // GL_MIRRORED_REPEAT |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
261 #define RL_TEXTURE_WRAP_MIRROR_CLAMP 0x8742 // GL_MIRROR_CLAMP_EXT |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
262 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
263 // Matrix modes (equivalent to OpenGL) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
264 #define RL_MODELVIEW 0x1700 // GL_MODELVIEW |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
265 #define RL_PROJECTION 0x1701 // GL_PROJECTION |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
266 #define RL_TEXTURE 0x1702 // GL_TEXTURE |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
267 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
268 // Primitive assembly draw modes |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
269 #define RL_LINES 0x0001 // GL_LINES |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
270 #define RL_TRIANGLES 0x0004 // GL_TRIANGLES |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
271 #define RL_QUADS 0x0007 // GL_QUADS |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
272 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
273 // GL equivalent data types |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
274 #define RL_UNSIGNED_BYTE 0x1401 // GL_UNSIGNED_BYTE |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
275 #define RL_FLOAT 0x1406 // GL_FLOAT |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
276 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
277 // GL buffer usage hint |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
278 #define RL_STREAM_DRAW 0x88E0 // GL_STREAM_DRAW |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
279 #define RL_STREAM_READ 0x88E1 // GL_STREAM_READ |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
280 #define RL_STREAM_COPY 0x88E2 // GL_STREAM_COPY |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
281 #define RL_STATIC_DRAW 0x88E4 // GL_STATIC_DRAW |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
282 #define RL_STATIC_READ 0x88E5 // GL_STATIC_READ |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
283 #define RL_STATIC_COPY 0x88E6 // GL_STATIC_COPY |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
284 #define RL_DYNAMIC_DRAW 0x88E8 // GL_DYNAMIC_DRAW |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
285 #define RL_DYNAMIC_READ 0x88E9 // GL_DYNAMIC_READ |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
286 #define RL_DYNAMIC_COPY 0x88EA // GL_DYNAMIC_COPY |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
287 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
288 // GL Shader type |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
289 #define RL_FRAGMENT_SHADER 0x8B30 // GL_FRAGMENT_SHADER |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
290 #define RL_VERTEX_SHADER 0x8B31 // GL_VERTEX_SHADER |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
291 #define RL_COMPUTE_SHADER 0x91B9 // GL_COMPUTE_SHADER |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
292 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
293 // GL blending factors |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
294 #define RL_ZERO 0 // GL_ZERO |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
295 #define RL_ONE 1 // GL_ONE |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
296 #define RL_SRC_COLOR 0x0300 // GL_SRC_COLOR |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
297 #define RL_ONE_MINUS_SRC_COLOR 0x0301 // GL_ONE_MINUS_SRC_COLOR |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
298 #define RL_SRC_ALPHA 0x0302 // GL_SRC_ALPHA |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
299 #define RL_ONE_MINUS_SRC_ALPHA 0x0303 // GL_ONE_MINUS_SRC_ALPHA |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
300 #define RL_DST_ALPHA 0x0304 // GL_DST_ALPHA |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
301 #define RL_ONE_MINUS_DST_ALPHA 0x0305 // GL_ONE_MINUS_DST_ALPHA |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
302 #define RL_DST_COLOR 0x0306 // GL_DST_COLOR |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
303 #define RL_ONE_MINUS_DST_COLOR 0x0307 // GL_ONE_MINUS_DST_COLOR |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
304 #define RL_SRC_ALPHA_SATURATE 0x0308 // GL_SRC_ALPHA_SATURATE |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
305 #define RL_CONSTANT_COLOR 0x8001 // GL_CONSTANT_COLOR |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
306 #define RL_ONE_MINUS_CONSTANT_COLOR 0x8002 // GL_ONE_MINUS_CONSTANT_COLOR |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
307 #define RL_CONSTANT_ALPHA 0x8003 // GL_CONSTANT_ALPHA |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
308 #define RL_ONE_MINUS_CONSTANT_ALPHA 0x8004 // GL_ONE_MINUS_CONSTANT_ALPHA |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
309 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
310 // GL blending functions/equations |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
311 #define RL_FUNC_ADD 0x8006 // GL_FUNC_ADD |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
312 #define RL_MIN 0x8007 // GL_MIN |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
313 #define RL_MAX 0x8008 // GL_MAX |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
314 #define RL_FUNC_SUBTRACT 0x800A // GL_FUNC_SUBTRACT |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
315 #define RL_FUNC_REVERSE_SUBTRACT 0x800B // GL_FUNC_REVERSE_SUBTRACT |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
316 #define RL_BLEND_EQUATION 0x8009 // GL_BLEND_EQUATION |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
317 #define RL_BLEND_EQUATION_RGB 0x8009 // GL_BLEND_EQUATION_RGB // (Same as BLEND_EQUATION) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
318 #define RL_BLEND_EQUATION_ALPHA 0x883D // GL_BLEND_EQUATION_ALPHA |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
319 #define RL_BLEND_DST_RGB 0x80C8 // GL_BLEND_DST_RGB |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
320 #define RL_BLEND_SRC_RGB 0x80C9 // GL_BLEND_SRC_RGB |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
321 #define RL_BLEND_DST_ALPHA 0x80CA // GL_BLEND_DST_ALPHA |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
322 #define RL_BLEND_SRC_ALPHA 0x80CB // GL_BLEND_SRC_ALPHA |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
323 #define RL_BLEND_COLOR 0x8005 // GL_BLEND_COLOR |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
324 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
325 #define RL_READ_FRAMEBUFFER 0x8CA8 // GL_READ_FRAMEBUFFER |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
326 #define RL_DRAW_FRAMEBUFFER 0x8CA9 // GL_DRAW_FRAMEBUFFER |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
327 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
328 // Default shader vertex attribute locations |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
329 #ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
330 #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION 0 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
331 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
332 #ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
333 #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD 1 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
334 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
335 #ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
336 #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL 2 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
337 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
338 #ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_COLOR |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
339 #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_COLOR 3 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
340 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
341 #ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
342 #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT 4 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
343 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
344 #ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
345 #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2 5 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
346 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
347 #ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_INDICES |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
348 #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_INDICES 6 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
349 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
350 #ifdef RL_SUPPORT_MESH_GPU_SKINNING |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
351 #ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEIDS |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
352 #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEIDS 7 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
353 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
354 #ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
355 #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS 8 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
356 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
357 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
358 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
359 //---------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
360 // Types and Structures Definition |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
361 //---------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
362 #if (defined(__STDC__) && __STDC_VERSION__ >= 199901L) || (defined(_MSC_VER) && _MSC_VER >= 1800) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
363 #include <stdbool.h> |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
364 #elif !defined(__cplusplus) && !defined(bool) && !defined(RL_BOOL_TYPE) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
365 // Boolean type |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
366 typedef enum bool { false = 0, true = !false } bool; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
367 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
368 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
369 #if !defined(RL_MATRIX_TYPE) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
370 // Matrix, 4x4 components, column major, OpenGL style, right handed |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
371 typedef struct Matrix { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
372 float m0, m4, m8, m12; // Matrix first row (4 components) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
373 float m1, m5, m9, m13; // Matrix second row (4 components) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
374 float m2, m6, m10, m14; // Matrix third row (4 components) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
375 float m3, m7, m11, m15; // Matrix fourth row (4 components) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
376 } Matrix; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
377 #define RL_MATRIX_TYPE |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
378 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
379 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
380 // Dynamic vertex buffers (position + texcoords + colors + indices arrays) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
381 typedef struct rlVertexBuffer { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
382 int elementCount; // Number of elements in the buffer (QUADS) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
383 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
384 float *vertices; // Vertex position (XYZ - 3 components per vertex) (shader-location = 0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
385 float *texcoords; // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
386 float *normals; // Vertex normal (XYZ - 3 components per vertex) (shader-location = 2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
387 unsigned char *colors; // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
388 #if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_33) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
389 unsigned int *indices; // Vertex indices (in case vertex data comes indexed) (6 indices per quad) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
390 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
391 #if defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
392 unsigned short *indices; // Vertex indices (in case vertex data comes indexed) (6 indices per quad) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
393 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
394 unsigned int vaoId; // OpenGL Vertex Array Object id |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
395 unsigned int vboId[5]; // OpenGL Vertex Buffer Objects id (5 types of vertex data) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
396 } rlVertexBuffer; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
397 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
398 // Draw call type |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
399 // NOTE: Only texture changes register a new draw, other state-change-related elements are not |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
400 // used at this moment (vaoId, shaderId, matrices), raylib just forces a batch draw call if any |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
401 // of those state-change happens (this is done in core module) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
402 typedef struct rlDrawCall { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
403 int mode; // Drawing mode: LINES, TRIANGLES, QUADS |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
404 int vertexCount; // Number of vertex of the draw |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
405 int vertexAlignment; // Number of vertex required for index alignment (LINES, TRIANGLES) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
406 //unsigned int vaoId; // Vertex array id to be used on the draw -> Using RLGL.currentBatch->vertexBuffer.vaoId |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
407 //unsigned int shaderId; // Shader id to be used on the draw -> Using RLGL.currentShaderId |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
408 unsigned int textureId; // Texture id to be used on the draw -> Use to create new draw call if changes |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
409 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
410 //Matrix projection; // Projection matrix for this draw -> Using RLGL.projection by default |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
411 //Matrix modelview; // Modelview matrix for this draw -> Using RLGL.modelview by default |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
412 } rlDrawCall; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
413 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
414 // rlRenderBatch type |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
415 typedef struct rlRenderBatch { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
416 int bufferCount; // Number of vertex buffers (multi-buffering support) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
417 int currentBuffer; // Current buffer tracking in case of multi-buffering |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
418 rlVertexBuffer *vertexBuffer; // Dynamic buffer(s) for vertex data |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
419 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
420 rlDrawCall *draws; // Draw calls array, depends on textureId |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
421 int drawCounter; // Draw calls counter |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
422 float currentDepth; // Current depth value for next draw |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
423 } rlRenderBatch; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
424 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
425 // OpenGL version |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
426 typedef enum { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
427 RL_OPENGL_11 = 1, // OpenGL 1.1 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
428 RL_OPENGL_21, // OpenGL 2.1 (GLSL 120) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
429 RL_OPENGL_33, // OpenGL 3.3 (GLSL 330) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
430 RL_OPENGL_43, // OpenGL 4.3 (using GLSL 330) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
431 RL_OPENGL_ES_20, // OpenGL ES 2.0 (GLSL 100) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
432 RL_OPENGL_ES_30 // OpenGL ES 3.0 (GLSL 300 es) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
433 } rlGlVersion; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
434 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
435 // Trace log level |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
436 // NOTE: Organized by priority level |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
437 typedef enum { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
438 RL_LOG_ALL = 0, // Display all logs |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
439 RL_LOG_TRACE, // Trace logging, intended for internal use only |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
440 RL_LOG_DEBUG, // Debug logging, used for internal debugging, it should be disabled on release builds |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
441 RL_LOG_INFO, // Info logging, used for program execution info |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
442 RL_LOG_WARNING, // Warning logging, used on recoverable failures |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
443 RL_LOG_ERROR, // Error logging, used on unrecoverable failures |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
444 RL_LOG_FATAL, // Fatal logging, used to abort program: exit(EXIT_FAILURE) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
445 RL_LOG_NONE // Disable logging |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
446 } rlTraceLogLevel; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
447 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
448 // Texture pixel formats |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
449 // NOTE: Support depends on OpenGL version |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
450 typedef enum { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
451 RL_PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1, // 8 bit per pixel (no alpha) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
452 RL_PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA, // 8*2 bpp (2 channels) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
453 RL_PIXELFORMAT_UNCOMPRESSED_R5G6B5, // 16 bpp |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
454 RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8, // 24 bpp |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
455 RL_PIXELFORMAT_UNCOMPRESSED_R5G5B5A1, // 16 bpp (1 bit alpha) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
456 RL_PIXELFORMAT_UNCOMPRESSED_R4G4B4A4, // 16 bpp (4 bit alpha) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
457 RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, // 32 bpp |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
458 RL_PIXELFORMAT_UNCOMPRESSED_R32, // 32 bpp (1 channel - float) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
459 RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32, // 32*3 bpp (3 channels - float) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
460 RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32A32, // 32*4 bpp (4 channels - float) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
461 RL_PIXELFORMAT_UNCOMPRESSED_R16, // 16 bpp (1 channel - half float) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
462 RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16, // 16*3 bpp (3 channels - half float) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
463 RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16, // 16*4 bpp (4 channels - half float) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
464 RL_PIXELFORMAT_COMPRESSED_DXT1_RGB, // 4 bpp (no alpha) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
465 RL_PIXELFORMAT_COMPRESSED_DXT1_RGBA, // 4 bpp (1 bit alpha) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
466 RL_PIXELFORMAT_COMPRESSED_DXT3_RGBA, // 8 bpp |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
467 RL_PIXELFORMAT_COMPRESSED_DXT5_RGBA, // 8 bpp |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
468 RL_PIXELFORMAT_COMPRESSED_ETC1_RGB, // 4 bpp |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
469 RL_PIXELFORMAT_COMPRESSED_ETC2_RGB, // 4 bpp |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
470 RL_PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA, // 8 bpp |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
471 RL_PIXELFORMAT_COMPRESSED_PVRT_RGB, // 4 bpp |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
472 RL_PIXELFORMAT_COMPRESSED_PVRT_RGBA, // 4 bpp |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
473 RL_PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA, // 8 bpp |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
474 RL_PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA // 2 bpp |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
475 } rlPixelFormat; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
476 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
477 // Texture parameters: filter mode |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
478 // NOTE 1: Filtering considers mipmaps if available in the texture |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
479 // NOTE 2: Filter is accordingly set for minification and magnification |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
480 typedef enum { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
481 RL_TEXTURE_FILTER_POINT = 0, // No filter, just pixel approximation |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
482 RL_TEXTURE_FILTER_BILINEAR, // Linear filtering |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
483 RL_TEXTURE_FILTER_TRILINEAR, // Trilinear filtering (linear with mipmaps) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
484 RL_TEXTURE_FILTER_ANISOTROPIC_4X, // Anisotropic filtering 4x |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
485 RL_TEXTURE_FILTER_ANISOTROPIC_8X, // Anisotropic filtering 8x |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
486 RL_TEXTURE_FILTER_ANISOTROPIC_16X, // Anisotropic filtering 16x |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
487 } rlTextureFilter; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
488 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
489 // Color blending modes (pre-defined) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
490 typedef enum { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
491 RL_BLEND_ALPHA = 0, // Blend textures considering alpha (default) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
492 RL_BLEND_ADDITIVE, // Blend textures adding colors |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
493 RL_BLEND_MULTIPLIED, // Blend textures multiplying colors |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
494 RL_BLEND_ADD_COLORS, // Blend textures adding colors (alternative) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
495 RL_BLEND_SUBTRACT_COLORS, // Blend textures subtracting colors (alternative) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
496 RL_BLEND_ALPHA_PREMULTIPLY, // Blend premultiplied textures considering alpha |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
497 RL_BLEND_CUSTOM, // Blend textures using custom src/dst factors (use rlSetBlendFactors()) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
498 RL_BLEND_CUSTOM_SEPARATE // Blend textures using custom src/dst factors (use rlSetBlendFactorsSeparate()) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
499 } rlBlendMode; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
500 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
501 // Shader location point type |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
502 typedef enum { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
503 RL_SHADER_LOC_VERTEX_POSITION = 0, // Shader location: vertex attribute: position |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
504 RL_SHADER_LOC_VERTEX_TEXCOORD01, // Shader location: vertex attribute: texcoord01 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
505 RL_SHADER_LOC_VERTEX_TEXCOORD02, // Shader location: vertex attribute: texcoord02 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
506 RL_SHADER_LOC_VERTEX_NORMAL, // Shader location: vertex attribute: normal |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
507 RL_SHADER_LOC_VERTEX_TANGENT, // Shader location: vertex attribute: tangent |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
508 RL_SHADER_LOC_VERTEX_COLOR, // Shader location: vertex attribute: color |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
509 RL_SHADER_LOC_MATRIX_MVP, // Shader location: matrix uniform: model-view-projection |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
510 RL_SHADER_LOC_MATRIX_VIEW, // Shader location: matrix uniform: view (camera transform) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
511 RL_SHADER_LOC_MATRIX_PROJECTION, // Shader location: matrix uniform: projection |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
512 RL_SHADER_LOC_MATRIX_MODEL, // Shader location: matrix uniform: model (transform) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
513 RL_SHADER_LOC_MATRIX_NORMAL, // Shader location: matrix uniform: normal |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
514 RL_SHADER_LOC_VECTOR_VIEW, // Shader location: vector uniform: view |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
515 RL_SHADER_LOC_COLOR_DIFFUSE, // Shader location: vector uniform: diffuse color |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
516 RL_SHADER_LOC_COLOR_SPECULAR, // Shader location: vector uniform: specular color |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
517 RL_SHADER_LOC_COLOR_AMBIENT, // Shader location: vector uniform: ambient color |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
518 RL_SHADER_LOC_MAP_ALBEDO, // Shader location: sampler2d texture: albedo (same as: RL_SHADER_LOC_MAP_DIFFUSE) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
519 RL_SHADER_LOC_MAP_METALNESS, // Shader location: sampler2d texture: metalness (same as: RL_SHADER_LOC_MAP_SPECULAR) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
520 RL_SHADER_LOC_MAP_NORMAL, // Shader location: sampler2d texture: normal |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
521 RL_SHADER_LOC_MAP_ROUGHNESS, // Shader location: sampler2d texture: roughness |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
522 RL_SHADER_LOC_MAP_OCCLUSION, // Shader location: sampler2d texture: occlusion |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
523 RL_SHADER_LOC_MAP_EMISSION, // Shader location: sampler2d texture: emission |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
524 RL_SHADER_LOC_MAP_HEIGHT, // Shader location: sampler2d texture: height |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
525 RL_SHADER_LOC_MAP_CUBEMAP, // Shader location: samplerCube texture: cubemap |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
526 RL_SHADER_LOC_MAP_IRRADIANCE, // Shader location: samplerCube texture: irradiance |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
527 RL_SHADER_LOC_MAP_PREFILTER, // Shader location: samplerCube texture: prefilter |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
528 RL_SHADER_LOC_MAP_BRDF // Shader location: sampler2d texture: brdf |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
529 } rlShaderLocationIndex; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
530 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
531 #define RL_SHADER_LOC_MAP_DIFFUSE RL_SHADER_LOC_MAP_ALBEDO |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
532 #define RL_SHADER_LOC_MAP_SPECULAR RL_SHADER_LOC_MAP_METALNESS |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
533 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
534 // Shader uniform data type |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
535 typedef enum { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
536 RL_SHADER_UNIFORM_FLOAT = 0, // Shader uniform type: float |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
537 RL_SHADER_UNIFORM_VEC2, // Shader uniform type: vec2 (2 float) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
538 RL_SHADER_UNIFORM_VEC3, // Shader uniform type: vec3 (3 float) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
539 RL_SHADER_UNIFORM_VEC4, // Shader uniform type: vec4 (4 float) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
540 RL_SHADER_UNIFORM_INT, // Shader uniform type: int |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
541 RL_SHADER_UNIFORM_IVEC2, // Shader uniform type: ivec2 (2 int) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
542 RL_SHADER_UNIFORM_IVEC3, // Shader uniform type: ivec3 (3 int) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
543 RL_SHADER_UNIFORM_IVEC4, // Shader uniform type: ivec4 (4 int) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
544 RL_SHADER_UNIFORM_UINT, // Shader uniform type: unsigned int |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
545 RL_SHADER_UNIFORM_UIVEC2, // Shader uniform type: uivec2 (2 unsigned int) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
546 RL_SHADER_UNIFORM_UIVEC3, // Shader uniform type: uivec3 (3 unsigned int) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
547 RL_SHADER_UNIFORM_UIVEC4, // Shader uniform type: uivec4 (4 unsigned int) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
548 RL_SHADER_UNIFORM_SAMPLER2D // Shader uniform type: sampler2d |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
549 } rlShaderUniformDataType; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
550 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
551 // Shader attribute data types |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
552 typedef enum { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
553 RL_SHADER_ATTRIB_FLOAT = 0, // Shader attribute type: float |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
554 RL_SHADER_ATTRIB_VEC2, // Shader attribute type: vec2 (2 float) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
555 RL_SHADER_ATTRIB_VEC3, // Shader attribute type: vec3 (3 float) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
556 RL_SHADER_ATTRIB_VEC4 // Shader attribute type: vec4 (4 float) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
557 } rlShaderAttributeDataType; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
558 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
559 // Framebuffer attachment type |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
560 // NOTE: By default up to 8 color channels defined, but it can be more |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
561 typedef enum { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
562 RL_ATTACHMENT_COLOR_CHANNEL0 = 0, // Framebuffer attachment type: color 0 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
563 RL_ATTACHMENT_COLOR_CHANNEL1 = 1, // Framebuffer attachment type: color 1 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
564 RL_ATTACHMENT_COLOR_CHANNEL2 = 2, // Framebuffer attachment type: color 2 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
565 RL_ATTACHMENT_COLOR_CHANNEL3 = 3, // Framebuffer attachment type: color 3 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
566 RL_ATTACHMENT_COLOR_CHANNEL4 = 4, // Framebuffer attachment type: color 4 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
567 RL_ATTACHMENT_COLOR_CHANNEL5 = 5, // Framebuffer attachment type: color 5 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
568 RL_ATTACHMENT_COLOR_CHANNEL6 = 6, // Framebuffer attachment type: color 6 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
569 RL_ATTACHMENT_COLOR_CHANNEL7 = 7, // Framebuffer attachment type: color 7 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
570 RL_ATTACHMENT_DEPTH = 100, // Framebuffer attachment type: depth |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
571 RL_ATTACHMENT_STENCIL = 200, // Framebuffer attachment type: stencil |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
572 } rlFramebufferAttachType; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
573 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
574 // Framebuffer texture attachment type |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
575 typedef enum { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
576 RL_ATTACHMENT_CUBEMAP_POSITIVE_X = 0, // Framebuffer texture attachment type: cubemap, +X side |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
577 RL_ATTACHMENT_CUBEMAP_NEGATIVE_X = 1, // Framebuffer texture attachment type: cubemap, -X side |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
578 RL_ATTACHMENT_CUBEMAP_POSITIVE_Y = 2, // Framebuffer texture attachment type: cubemap, +Y side |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
579 RL_ATTACHMENT_CUBEMAP_NEGATIVE_Y = 3, // Framebuffer texture attachment type: cubemap, -Y side |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
580 RL_ATTACHMENT_CUBEMAP_POSITIVE_Z = 4, // Framebuffer texture attachment type: cubemap, +Z side |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
581 RL_ATTACHMENT_CUBEMAP_NEGATIVE_Z = 5, // Framebuffer texture attachment type: cubemap, -Z side |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
582 RL_ATTACHMENT_TEXTURE2D = 100, // Framebuffer texture attachment type: texture2d |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
583 RL_ATTACHMENT_RENDERBUFFER = 200, // Framebuffer texture attachment type: renderbuffer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
584 } rlFramebufferAttachTextureType; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
585 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
586 // Face culling mode |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
587 typedef enum { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
588 RL_CULL_FACE_FRONT = 0, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
589 RL_CULL_FACE_BACK |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
590 } rlCullMode; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
591 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
592 //------------------------------------------------------------------------------------ |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
593 // Functions Declaration - Matrix operations |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
594 //------------------------------------------------------------------------------------ |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
595 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
596 #if defined(__cplusplus) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
597 extern "C" { // Prevents name mangling of functions |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
598 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
599 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
600 RLAPI void rlMatrixMode(int mode); // Choose the current matrix to be transformed |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
601 RLAPI void rlPushMatrix(void); // Push the current matrix to stack |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
602 RLAPI void rlPopMatrix(void); // Pop latest inserted matrix from stack |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
603 RLAPI void rlLoadIdentity(void); // Reset current matrix to identity matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
604 RLAPI void rlTranslatef(float x, float y, float z); // Multiply the current matrix by a translation matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
605 RLAPI void rlRotatef(float angle, float x, float y, float z); // Multiply the current matrix by a rotation matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
606 RLAPI void rlScalef(float x, float y, float z); // Multiply the current matrix by a scaling matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
607 RLAPI void rlMultMatrixf(const float *matf); // Multiply the current matrix by another matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
608 RLAPI void rlFrustum(double left, double right, double bottom, double top, double znear, double zfar); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
609 RLAPI void rlOrtho(double left, double right, double bottom, double top, double znear, double zfar); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
610 RLAPI void rlViewport(int x, int y, int width, int height); // Set the viewport area |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
611 RLAPI void rlSetClipPlanes(double nearPlane, double farPlane); // Set clip planes distances |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
612 RLAPI double rlGetCullDistanceNear(void); // Get cull plane distance near |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
613 RLAPI double rlGetCullDistanceFar(void); // Get cull plane distance far |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
614 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
615 //------------------------------------------------------------------------------------ |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
616 // Functions Declaration - Vertex level operations |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
617 //------------------------------------------------------------------------------------ |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
618 RLAPI void rlBegin(int mode); // Initialize drawing mode (how to organize vertex) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
619 RLAPI void rlEnd(void); // Finish vertex providing |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
620 RLAPI void rlVertex2i(int x, int y); // Define one vertex (position) - 2 int |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
621 RLAPI void rlVertex2f(float x, float y); // Define one vertex (position) - 2 float |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
622 RLAPI void rlVertex3f(float x, float y, float z); // Define one vertex (position) - 3 float |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
623 RLAPI void rlTexCoord2f(float x, float y); // Define one vertex (texture coordinate) - 2 float |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
624 RLAPI void rlNormal3f(float x, float y, float z); // Define one vertex (normal) - 3 float |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
625 RLAPI void rlColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a); // Define one vertex (color) - 4 byte |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
626 RLAPI void rlColor3f(float x, float y, float z); // Define one vertex (color) - 3 float |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
627 RLAPI void rlColor4f(float x, float y, float z, float w); // Define one vertex (color) - 4 float |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
628 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
629 //------------------------------------------------------------------------------------ |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
630 // Functions Declaration - OpenGL style functions (common to 1.1, 3.3+, ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
631 // NOTE: This functions are used to completely abstract raylib code from OpenGL layer, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
632 // some of them are direct wrappers over OpenGL calls, some others are custom |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
633 //------------------------------------------------------------------------------------ |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
634 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
635 // Vertex buffers state |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
636 RLAPI bool rlEnableVertexArray(unsigned int vaoId); // Enable vertex array (VAO, if supported) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
637 RLAPI void rlDisableVertexArray(void); // Disable vertex array (VAO, if supported) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
638 RLAPI void rlEnableVertexBuffer(unsigned int id); // Enable vertex buffer (VBO) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
639 RLAPI void rlDisableVertexBuffer(void); // Disable vertex buffer (VBO) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
640 RLAPI void rlEnableVertexBufferElement(unsigned int id); // Enable vertex buffer element (VBO element) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
641 RLAPI void rlDisableVertexBufferElement(void); // Disable vertex buffer element (VBO element) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
642 RLAPI void rlEnableVertexAttribute(unsigned int index); // Enable vertex attribute index |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
643 RLAPI void rlDisableVertexAttribute(unsigned int index); // Disable vertex attribute index |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
644 #if defined(GRAPHICS_API_OPENGL_11) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
645 RLAPI void rlEnableStatePointer(int vertexAttribType, void *buffer); // Enable attribute state pointer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
646 RLAPI void rlDisableStatePointer(int vertexAttribType); // Disable attribute state pointer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
647 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
648 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
649 // Textures state |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
650 RLAPI void rlActiveTextureSlot(int slot); // Select and active a texture slot |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
651 RLAPI void rlEnableTexture(unsigned int id); // Enable texture |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
652 RLAPI void rlDisableTexture(void); // Disable texture |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
653 RLAPI void rlEnableTextureCubemap(unsigned int id); // Enable texture cubemap |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
654 RLAPI void rlDisableTextureCubemap(void); // Disable texture cubemap |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
655 RLAPI void rlTextureParameters(unsigned int id, int param, int value); // Set texture parameters (filter, wrap) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
656 RLAPI void rlCubemapParameters(unsigned int id, int param, int value); // Set cubemap parameters (filter, wrap) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
657 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
658 // Shader state |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
659 RLAPI void rlEnableShader(unsigned int id); // Enable shader program |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
660 RLAPI void rlDisableShader(void); // Disable shader program |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
661 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
662 // Framebuffer state |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
663 RLAPI void rlEnableFramebuffer(unsigned int id); // Enable render texture (fbo) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
664 RLAPI void rlDisableFramebuffer(void); // Disable render texture (fbo), return to default framebuffer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
665 RLAPI unsigned int rlGetActiveFramebuffer(void); // Get the currently active render texture (fbo), 0 for default framebuffer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
666 RLAPI void rlActiveDrawBuffers(int count); // Activate multiple draw color buffers |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
667 RLAPI void rlBlitFramebuffer(int srcX, int srcY, int srcWidth, int srcHeight, int dstX, int dstY, int dstWidth, int dstHeight, int bufferMask); // Blit active framebuffer to main framebuffer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
668 RLAPI void rlBindFramebuffer(unsigned int target, unsigned int framebuffer); // Bind framebuffer (FBO) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
669 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
670 // General render state |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
671 RLAPI void rlEnableColorBlend(void); // Enable color blending |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
672 RLAPI void rlDisableColorBlend(void); // Disable color blending |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
673 RLAPI void rlEnableDepthTest(void); // Enable depth test |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
674 RLAPI void rlDisableDepthTest(void); // Disable depth test |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
675 RLAPI void rlEnableDepthMask(void); // Enable depth write |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
676 RLAPI void rlDisableDepthMask(void); // Disable depth write |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
677 RLAPI void rlEnableBackfaceCulling(void); // Enable backface culling |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
678 RLAPI void rlDisableBackfaceCulling(void); // Disable backface culling |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
679 RLAPI void rlColorMask(bool r, bool g, bool b, bool a); // Color mask control |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
680 RLAPI void rlSetCullFace(int mode); // Set face culling mode |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
681 RLAPI void rlEnableScissorTest(void); // Enable scissor test |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
682 RLAPI void rlDisableScissorTest(void); // Disable scissor test |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
683 RLAPI void rlScissor(int x, int y, int width, int height); // Scissor test |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
684 RLAPI void rlEnableWireMode(void); // Enable wire mode |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
685 RLAPI void rlEnablePointMode(void); // Enable point mode |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
686 RLAPI void rlDisableWireMode(void); // Disable wire (and point) mode |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
687 RLAPI void rlSetLineWidth(float width); // Set the line drawing width |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
688 RLAPI float rlGetLineWidth(void); // Get the line drawing width |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
689 RLAPI void rlEnableSmoothLines(void); // Enable line aliasing |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
690 RLAPI void rlDisableSmoothLines(void); // Disable line aliasing |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
691 RLAPI void rlEnableStereoRender(void); // Enable stereo rendering |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
692 RLAPI void rlDisableStereoRender(void); // Disable stereo rendering |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
693 RLAPI bool rlIsStereoRenderEnabled(void); // Check if stereo render is enabled |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
694 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
695 RLAPI void rlClearColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a); // Clear color buffer with color |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
696 RLAPI void rlClearScreenBuffers(void); // Clear used screen buffers (color and depth) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
697 RLAPI void rlCheckErrors(void); // Check and log OpenGL error codes |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
698 RLAPI void rlSetBlendMode(int mode); // Set blending mode |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
699 RLAPI void rlSetBlendFactors(int glSrcFactor, int glDstFactor, int glEquation); // Set blending mode factor and equation (using OpenGL factors) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
700 RLAPI void rlSetBlendFactorsSeparate(int glSrcRGB, int glDstRGB, int glSrcAlpha, int glDstAlpha, int glEqRGB, int glEqAlpha); // Set blending mode factors and equations separately (using OpenGL factors) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
701 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
702 //------------------------------------------------------------------------------------ |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
703 // Functions Declaration - rlgl functionality |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
704 //------------------------------------------------------------------------------------ |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
705 // rlgl initialization functions |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
706 RLAPI void rlglInit(int width, int height); // Initialize rlgl (buffers, shaders, textures, states) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
707 RLAPI void rlglClose(void); // De-initialize rlgl (buffers, shaders, textures) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
708 RLAPI void rlLoadExtensions(void *loader); // Load OpenGL extensions (loader function required) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
709 RLAPI int rlGetVersion(void); // Get current OpenGL version |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
710 RLAPI void rlSetFramebufferWidth(int width); // Set current framebuffer width |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
711 RLAPI int rlGetFramebufferWidth(void); // Get default framebuffer width |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
712 RLAPI void rlSetFramebufferHeight(int height); // Set current framebuffer height |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
713 RLAPI int rlGetFramebufferHeight(void); // Get default framebuffer height |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
714 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
715 RLAPI unsigned int rlGetTextureIdDefault(void); // Get default texture id |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
716 RLAPI unsigned int rlGetShaderIdDefault(void); // Get default shader id |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
717 RLAPI int *rlGetShaderLocsDefault(void); // Get default shader locations |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
718 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
719 // Render batch management |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
720 // NOTE: rlgl provides a default render batch to behave like OpenGL 1.1 immediate mode |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
721 // but this render batch API is exposed in case of custom batches are required |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
722 RLAPI rlRenderBatch rlLoadRenderBatch(int numBuffers, int bufferElements); // Load a render batch system |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
723 RLAPI void rlUnloadRenderBatch(rlRenderBatch batch); // Unload render batch system |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
724 RLAPI void rlDrawRenderBatch(rlRenderBatch *batch); // Draw render batch data (Update->Draw->Reset) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
725 RLAPI void rlSetRenderBatchActive(rlRenderBatch *batch); // Set the active render batch for rlgl (NULL for default internal) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
726 RLAPI void rlDrawRenderBatchActive(void); // Update and draw internal render batch |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
727 RLAPI bool rlCheckRenderBatchLimit(int vCount); // Check internal buffer overflow for a given number of vertex |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
728 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
729 RLAPI void rlSetTexture(unsigned int id); // Set current texture for render batch and check buffers limits |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
730 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
731 //------------------------------------------------------------------------------------------------------------------------ |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
732 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
733 // Vertex buffers management |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
734 RLAPI unsigned int rlLoadVertexArray(void); // Load vertex array (vao) if supported |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
735 RLAPI unsigned int rlLoadVertexBuffer(const void *buffer, int size, bool dynamic); // Load a vertex buffer object |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
736 RLAPI unsigned int rlLoadVertexBufferElement(const void *buffer, int size, bool dynamic); // Load vertex buffer elements object |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
737 RLAPI void rlUpdateVertexBuffer(unsigned int bufferId, const void *data, int dataSize, int offset); // Update vertex buffer object data on GPU buffer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
738 RLAPI void rlUpdateVertexBufferElements(unsigned int id, const void *data, int dataSize, int offset); // Update vertex buffer elements data on GPU buffer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
739 RLAPI void rlUnloadVertexArray(unsigned int vaoId); // Unload vertex array (vao) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
740 RLAPI void rlUnloadVertexBuffer(unsigned int vboId); // Unload vertex buffer object |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
741 RLAPI void rlSetVertexAttribute(unsigned int index, int compSize, int type, bool normalized, int stride, int offset); // Set vertex attribute data configuration |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
742 RLAPI void rlSetVertexAttributeDivisor(unsigned int index, int divisor); // Set vertex attribute data divisor |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
743 RLAPI void rlSetVertexAttributeDefault(int locIndex, const void *value, int attribType, int count); // Set vertex attribute default value, when attribute to provided |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
744 RLAPI void rlDrawVertexArray(int offset, int count); // Draw vertex array (currently active vao) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
745 RLAPI void rlDrawVertexArrayElements(int offset, int count, const void *buffer); // Draw vertex array elements |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
746 RLAPI void rlDrawVertexArrayInstanced(int offset, int count, int instances); // Draw vertex array (currently active vao) with instancing |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
747 RLAPI void rlDrawVertexArrayElementsInstanced(int offset, int count, const void *buffer, int instances); // Draw vertex array elements with instancing |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
748 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
749 // Textures management |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
750 RLAPI unsigned int rlLoadTexture(const void *data, int width, int height, int format, int mipmapCount); // Load texture data |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
751 RLAPI unsigned int rlLoadTextureDepth(int width, int height, bool useRenderBuffer); // Load depth texture/renderbuffer (to be attached to fbo) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
752 RLAPI unsigned int rlLoadTextureCubemap(const void *data, int size, int format, int mipmapCount); // Load texture cubemap data |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
753 RLAPI void rlUpdateTexture(unsigned int id, int offsetX, int offsetY, int width, int height, int format, const void *data); // Update texture with new data on GPU |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
754 RLAPI void rlGetGlTextureFormats(int format, unsigned int *glInternalFormat, unsigned int *glFormat, unsigned int *glType); // Get OpenGL internal formats |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
755 RLAPI const char *rlGetPixelFormatName(unsigned int format); // Get name string for pixel format |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
756 RLAPI void rlUnloadTexture(unsigned int id); // Unload texture from GPU memory |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
757 RLAPI void rlGenTextureMipmaps(unsigned int id, int width, int height, int format, int *mipmaps); // Generate mipmap data for selected texture |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
758 RLAPI void *rlReadTexturePixels(unsigned int id, int width, int height, int format); // Read texture pixel data |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
759 RLAPI unsigned char *rlReadScreenPixels(int width, int height); // Read screen pixel data (color buffer) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
760 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
761 // Framebuffer management (fbo) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
762 RLAPI unsigned int rlLoadFramebuffer(void); // Load an empty framebuffer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
763 RLAPI void rlFramebufferAttach(unsigned int fboId, unsigned int texId, int attachType, int texType, int mipLevel); // Attach texture/renderbuffer to a framebuffer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
764 RLAPI bool rlFramebufferComplete(unsigned int id); // Verify framebuffer is complete |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
765 RLAPI void rlUnloadFramebuffer(unsigned int id); // Delete framebuffer from GPU |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
766 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
767 // Shaders management |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
768 RLAPI unsigned int rlLoadShaderCode(const char *vsCode, const char *fsCode); // Load shader from code strings |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
769 RLAPI unsigned int rlCompileShader(const char *shaderCode, int type); // Compile custom shader and return shader id (type: RL_VERTEX_SHADER, RL_FRAGMENT_SHADER, RL_COMPUTE_SHADER) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
770 RLAPI unsigned int rlLoadShaderProgram(unsigned int vShaderId, unsigned int fShaderId); // Load custom shader program |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
771 RLAPI void rlUnloadShaderProgram(unsigned int id); // Unload shader program |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
772 RLAPI int rlGetLocationUniform(unsigned int shaderId, const char *uniformName); // Get shader location uniform |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
773 RLAPI int rlGetLocationAttrib(unsigned int shaderId, const char *attribName); // Get shader location attribute |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
774 RLAPI void rlSetUniform(int locIndex, const void *value, int uniformType, int count); // Set shader value uniform |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
775 RLAPI void rlSetUniformMatrix(int locIndex, Matrix mat); // Set shader value matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
776 RLAPI void rlSetUniformMatrices(int locIndex, const Matrix *mat, int count); // Set shader value matrices |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
777 RLAPI void rlSetUniformSampler(int locIndex, unsigned int textureId); // Set shader value sampler |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
778 RLAPI void rlSetShader(unsigned int id, int *locs); // Set shader currently active (id and locations) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
779 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
780 // Compute shader management |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
781 RLAPI unsigned int rlLoadComputeShaderProgram(unsigned int shaderId); // Load compute shader program |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
782 RLAPI void rlComputeShaderDispatch(unsigned int groupX, unsigned int groupY, unsigned int groupZ); // Dispatch compute shader (equivalent to *draw* for graphics pipeline) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
783 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
784 // Shader buffer storage object management (ssbo) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
785 RLAPI unsigned int rlLoadShaderBuffer(unsigned int size, const void *data, int usageHint); // Load shader storage buffer object (SSBO) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
786 RLAPI void rlUnloadShaderBuffer(unsigned int ssboId); // Unload shader storage buffer object (SSBO) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
787 RLAPI void rlUpdateShaderBuffer(unsigned int id, const void *data, unsigned int dataSize, unsigned int offset); // Update SSBO buffer data |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
788 RLAPI void rlBindShaderBuffer(unsigned int id, unsigned int index); // Bind SSBO buffer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
789 RLAPI void rlReadShaderBuffer(unsigned int id, void *dest, unsigned int count, unsigned int offset); // Read SSBO buffer data (GPU->CPU) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
790 RLAPI void rlCopyShaderBuffer(unsigned int destId, unsigned int srcId, unsigned int destOffset, unsigned int srcOffset, unsigned int count); // Copy SSBO data between buffers |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
791 RLAPI unsigned int rlGetShaderBufferSize(unsigned int id); // Get SSBO buffer size |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
792 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
793 // Buffer management |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
794 RLAPI void rlBindImageTexture(unsigned int id, unsigned int index, int format, bool readonly); // Bind image texture |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
795 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
796 // Matrix state management |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
797 RLAPI Matrix rlGetMatrixModelview(void); // Get internal modelview matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
798 RLAPI Matrix rlGetMatrixProjection(void); // Get internal projection matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
799 RLAPI Matrix rlGetMatrixTransform(void); // Get internal accumulated transform matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
800 RLAPI Matrix rlGetMatrixProjectionStereo(int eye); // Get internal projection matrix for stereo render (selected eye) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
801 RLAPI Matrix rlGetMatrixViewOffsetStereo(int eye); // Get internal view offset matrix for stereo render (selected eye) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
802 RLAPI void rlSetMatrixProjection(Matrix proj); // Set a custom projection matrix (replaces internal projection matrix) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
803 RLAPI void rlSetMatrixModelview(Matrix view); // Set a custom modelview matrix (replaces internal modelview matrix) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
804 RLAPI void rlSetMatrixProjectionStereo(Matrix right, Matrix left); // Set eyes projection matrices for stereo rendering |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
805 RLAPI void rlSetMatrixViewOffsetStereo(Matrix right, Matrix left); // Set eyes view offsets matrices for stereo rendering |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
806 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
807 // Quick and dirty cube/quad buffers load->draw->unload |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
808 RLAPI void rlLoadDrawCube(void); // Load and draw a cube |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
809 RLAPI void rlLoadDrawQuad(void); // Load and draw a quad |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
810 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
811 #if defined(__cplusplus) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
812 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
813 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
814 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
815 #endif // RLGL_H |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
816 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
817 /*********************************************************************************** |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
818 * |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
819 * RLGL IMPLEMENTATION |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
820 * |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
821 ************************************************************************************/ |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
822 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
823 #if defined(RLGL_IMPLEMENTATION) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
824 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
825 // Expose OpenGL functions from glad in raylib |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
826 #if defined(BUILD_LIBTYPE_SHARED) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
827 #define GLAD_API_CALL_EXPORT |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
828 #define GLAD_API_CALL_EXPORT_BUILD |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
829 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
830 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
831 #if defined(GRAPHICS_API_OPENGL_11) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
832 #if defined(__APPLE__) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
833 #include <OpenGL/gl.h> // OpenGL 1.1 library for OSX |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
834 #include <OpenGL/glext.h> // OpenGL extensions library |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
835 #else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
836 // APIENTRY for OpenGL function pointer declarations is required |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
837 #if !defined(APIENTRY) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
838 #if defined(_WIN32) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
839 #define APIENTRY __stdcall |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
840 #else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
841 #define APIENTRY |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
842 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
843 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
844 // WINGDIAPI definition. Some Windows OpenGL headers need it |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
845 #if !defined(WINGDIAPI) && defined(_WIN32) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
846 #define WINGDIAPI __declspec(dllimport) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
847 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
848 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
849 #include <GL/gl.h> // OpenGL 1.1 library |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
850 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
851 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
852 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
853 #if defined(GRAPHICS_API_OPENGL_33) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
854 #define GLAD_MALLOC RL_MALLOC |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
855 #define GLAD_FREE RL_FREE |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
856 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
857 #define GLAD_GL_IMPLEMENTATION |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
858 #include "external/glad.h" // GLAD extensions loading library, includes OpenGL headers |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
859 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
860 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
861 #if defined(GRAPHICS_API_OPENGL_ES3) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
862 #include <GLES3/gl3.h> // OpenGL ES 3.0 library |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
863 #define GL_GLEXT_PROTOTYPES |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
864 #include <GLES2/gl2ext.h> // OpenGL ES 2.0 extensions library |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
865 #elif defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
866 // NOTE: OpenGL ES 2.0 can be enabled on Desktop platforms, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
867 // in that case, functions are loaded from a custom glad for OpenGL ES 2.0 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
868 #if defined(PLATFORM_DESKTOP_GLFW) || defined(PLATFORM_DESKTOP_SDL) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
869 #define GLAD_GLES2_IMPLEMENTATION |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
870 #include "external/glad_gles2.h" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
871 #else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
872 #define GL_GLEXT_PROTOTYPES |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
873 //#include <EGL/egl.h> // EGL library -> not required, platform layer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
874 #include <GLES2/gl2.h> // OpenGL ES 2.0 library |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
875 #include <GLES2/gl2ext.h> // OpenGL ES 2.0 extensions library |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
876 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
877 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
878 // It seems OpenGL ES 2.0 instancing entry points are not defined on Raspberry Pi |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
879 // provided headers (despite being defined in official Khronos GLES2 headers) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
880 #if defined(PLATFORM_DRM) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
881 typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
882 typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
883 typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISOREXTPROC) (GLuint index, GLuint divisor); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
884 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
885 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
886 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
887 #include <stdlib.h> // Required for: malloc(), free() |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
888 #include <string.h> // Required for: strcmp(), strlen() [Used in rlglInit(), on extensions loading] |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
889 #include <math.h> // Required for: sqrtf(), sinf(), cosf(), floor(), log() |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
890 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
891 //---------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
892 // Defines and Macros |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
893 //---------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
894 #ifndef PI |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
895 #define PI 3.14159265358979323846f |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
896 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
897 #ifndef DEG2RAD |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
898 #define DEG2RAD (PI/180.0f) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
899 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
900 #ifndef RAD2DEG |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
901 #define RAD2DEG (180.0f/PI) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
902 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
903 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
904 #ifndef GL_SHADING_LANGUAGE_VERSION |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
905 #define GL_SHADING_LANGUAGE_VERSION 0x8B8C |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
906 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
907 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
908 #ifndef GL_COMPRESSED_RGB_S3TC_DXT1_EXT |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
909 #define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
910 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
911 #ifndef GL_COMPRESSED_RGBA_S3TC_DXT1_EXT |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
912 #define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
913 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
914 #ifndef GL_COMPRESSED_RGBA_S3TC_DXT3_EXT |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
915 #define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
916 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
917 #ifndef GL_COMPRESSED_RGBA_S3TC_DXT5_EXT |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
918 #define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
919 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
920 #ifndef GL_ETC1_RGB8_OES |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
921 #define GL_ETC1_RGB8_OES 0x8D64 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
922 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
923 #ifndef GL_COMPRESSED_RGB8_ETC2 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
924 #define GL_COMPRESSED_RGB8_ETC2 0x9274 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
925 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
926 #ifndef GL_COMPRESSED_RGBA8_ETC2_EAC |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
927 #define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
928 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
929 #ifndef GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
930 #define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
931 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
932 #ifndef GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
933 #define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
934 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
935 #ifndef GL_COMPRESSED_RGBA_ASTC_4x4_KHR |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
936 #define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93b0 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
937 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
938 #ifndef GL_COMPRESSED_RGBA_ASTC_8x8_KHR |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
939 #define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93b7 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
940 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
941 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
942 #ifndef GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
943 #define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
944 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
945 #ifndef GL_TEXTURE_MAX_ANISOTROPY_EXT |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
946 #define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
947 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
948 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
949 #ifndef GL_PROGRAM_POINT_SIZE |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
950 #define GL_PROGRAM_POINT_SIZE 0x8642 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
951 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
952 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
953 #ifndef GL_LINE_WIDTH |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
954 #define GL_LINE_WIDTH 0x0B21 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
955 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
956 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
957 #if defined(GRAPHICS_API_OPENGL_11) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
958 #define GL_UNSIGNED_SHORT_5_6_5 0x8363 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
959 #define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
960 #define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
961 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
962 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
963 #if defined(GRAPHICS_API_OPENGL_21) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
964 #define GL_LUMINANCE 0x1909 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
965 #define GL_LUMINANCE_ALPHA 0x190A |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
966 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
967 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
968 #if defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
969 #define glClearDepth glClearDepthf |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
970 #if !defined(GRAPHICS_API_OPENGL_ES3) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
971 #define GL_READ_FRAMEBUFFER GL_FRAMEBUFFER |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
972 #define GL_DRAW_FRAMEBUFFER GL_FRAMEBUFFER |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
973 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
974 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
975 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
976 // Default shader vertex attribute names to set location points |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
977 #ifndef RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
978 #define RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION "vertexPosition" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
979 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
980 #ifndef RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
981 #define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD "vertexTexCoord" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
982 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
983 #ifndef RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
984 #define RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL "vertexNormal" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
985 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
986 #ifndef RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
987 #define RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR "vertexColor" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
988 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
989 #ifndef RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
990 #define RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT "vertexTangent" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
991 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
992 #ifndef RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
993 #define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2 "vertexTexCoord2" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
994 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
995 #ifndef RL_DEFAULT_SHADER_ATTRIB_NAME_BONEIDS |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
996 #define RL_DEFAULT_SHADER_ATTRIB_NAME_BONEIDS "vertexBoneIds" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_NAME_BONEIDS |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
997 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
998 #ifndef RL_DEFAULT_SHADER_ATTRIB_NAME_BONEWEIGHTS |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
999 #define RL_DEFAULT_SHADER_ATTRIB_NAME_BONEWEIGHTS "vertexBoneWeights" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_NAME_BONEWEIGHTS |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1000 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1001 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1002 #ifndef RL_DEFAULT_SHADER_UNIFORM_NAME_MVP |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1003 #define RL_DEFAULT_SHADER_UNIFORM_NAME_MVP "mvp" // model-view-projection matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1004 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1005 #ifndef RL_DEFAULT_SHADER_UNIFORM_NAME_VIEW |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1006 #define RL_DEFAULT_SHADER_UNIFORM_NAME_VIEW "matView" // view matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1007 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1008 #ifndef RL_DEFAULT_SHADER_UNIFORM_NAME_PROJECTION |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1009 #define RL_DEFAULT_SHADER_UNIFORM_NAME_PROJECTION "matProjection" // projection matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1010 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1011 #ifndef RL_DEFAULT_SHADER_UNIFORM_NAME_MODEL |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1012 #define RL_DEFAULT_SHADER_UNIFORM_NAME_MODEL "matModel" // model matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1013 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1014 #ifndef RL_DEFAULT_SHADER_UNIFORM_NAME_NORMAL |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1015 #define RL_DEFAULT_SHADER_UNIFORM_NAME_NORMAL "matNormal" // normal matrix (transpose(inverse(matModelView)) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1016 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1017 #ifndef RL_DEFAULT_SHADER_UNIFORM_NAME_COLOR |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1018 #define RL_DEFAULT_SHADER_UNIFORM_NAME_COLOR "colDiffuse" // color diffuse (base tint color, multiplied by texture color) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1019 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1020 #ifndef RL_DEFAULT_SHADER_UNIFORM_NAME_BONE_MATRICES |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1021 #define RL_DEFAULT_SHADER_UNIFORM_NAME_BONE_MATRICES "boneMatrices" // bone matrices |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1022 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1023 #ifndef RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE0 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1024 #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE0 "texture0" // texture0 (texture slot active 0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1025 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1026 #ifndef RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE1 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1027 #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE1 "texture1" // texture1 (texture slot active 1) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1028 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1029 #ifndef RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE2 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1030 #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE2 "texture2" // texture2 (texture slot active 2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1031 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1032 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1033 //---------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1034 // Types and Structures Definition |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1035 //---------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1036 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1037 typedef struct rlglData { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1038 rlRenderBatch *currentBatch; // Current render batch |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1039 rlRenderBatch defaultBatch; // Default internal render batch |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1040 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1041 struct { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1042 int vertexCounter; // Current active render batch vertex counter (generic, used for all batches) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1043 float texcoordx, texcoordy; // Current active texture coordinate (added on glVertex*()) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1044 float normalx, normaly, normalz; // Current active normal (added on glVertex*()) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1045 unsigned char colorr, colorg, colorb, colora; // Current active color (added on glVertex*()) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1046 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1047 int currentMatrixMode; // Current matrix mode |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1048 Matrix *currentMatrix; // Current matrix pointer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1049 Matrix modelview; // Default modelview matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1050 Matrix projection; // Default projection matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1051 Matrix transform; // Transform matrix to be used with rlTranslate, rlRotate, rlScale |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1052 bool transformRequired; // Require transform matrix application to current draw-call vertex (if required) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1053 Matrix stack[RL_MAX_MATRIX_STACK_SIZE];// Matrix stack for push/pop |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1054 int stackCounter; // Matrix stack counter |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1055 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1056 unsigned int defaultTextureId; // Default texture used on shapes/poly drawing (required by shader) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1057 unsigned int activeTextureId[RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS]; // Active texture ids to be enabled on batch drawing (0 active by default) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1058 unsigned int defaultVShaderId; // Default vertex shader id (used by default shader program) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1059 unsigned int defaultFShaderId; // Default fragment shader id (used by default shader program) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1060 unsigned int defaultShaderId; // Default shader program id, supports vertex color and diffuse texture |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1061 int *defaultShaderLocs; // Default shader locations pointer to be used on rendering |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1062 unsigned int currentShaderId; // Current shader id to be used on rendering (by default, defaultShaderId) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1063 int *currentShaderLocs; // Current shader locations pointer to be used on rendering (by default, defaultShaderLocs) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1064 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1065 bool stereoRender; // Stereo rendering flag |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1066 Matrix projectionStereo[2]; // VR stereo rendering eyes projection matrices |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1067 Matrix viewOffsetStereo[2]; // VR stereo rendering eyes view offset matrices |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1068 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1069 // Blending variables |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1070 int currentBlendMode; // Blending mode active |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1071 int glBlendSrcFactor; // Blending source factor |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1072 int glBlendDstFactor; // Blending destination factor |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1073 int glBlendEquation; // Blending equation |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1074 int glBlendSrcFactorRGB; // Blending source RGB factor |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1075 int glBlendDestFactorRGB; // Blending destination RGB factor |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1076 int glBlendSrcFactorAlpha; // Blending source alpha factor |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1077 int glBlendDestFactorAlpha; // Blending destination alpha factor |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1078 int glBlendEquationRGB; // Blending equation for RGB |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1079 int glBlendEquationAlpha; // Blending equation for alpha |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1080 bool glCustomBlendModeModified; // Custom blending factor and equation modification status |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1081 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1082 int framebufferWidth; // Current framebuffer width |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1083 int framebufferHeight; // Current framebuffer height |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1084 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1085 } State; // Renderer state |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1086 struct { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1087 bool vao; // VAO support (OpenGL ES2 could not support VAO extension) (GL_ARB_vertex_array_object) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1088 bool instancing; // Instancing supported (GL_ANGLE_instanced_arrays, GL_EXT_draw_instanced + GL_EXT_instanced_arrays) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1089 bool texNPOT; // NPOT textures full support (GL_ARB_texture_non_power_of_two, GL_OES_texture_npot) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1090 bool texDepth; // Depth textures supported (GL_ARB_depth_texture, GL_OES_depth_texture) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1091 bool texDepthWebGL; // Depth textures supported WebGL specific (GL_WEBGL_depth_texture) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1092 bool texFloat32; // float textures support (32 bit per channel) (GL_OES_texture_float) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1093 bool texFloat16; // half float textures support (16 bit per channel) (GL_OES_texture_half_float) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1094 bool texCompDXT; // DDS texture compression support (GL_EXT_texture_compression_s3tc, GL_WEBGL_compressed_texture_s3tc, GL_WEBKIT_WEBGL_compressed_texture_s3tc) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1095 bool texCompETC1; // ETC1 texture compression support (GL_OES_compressed_ETC1_RGB8_texture, GL_WEBGL_compressed_texture_etc1) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1096 bool texCompETC2; // ETC2/EAC texture compression support (GL_ARB_ES3_compatibility) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1097 bool texCompPVRT; // PVR texture compression support (GL_IMG_texture_compression_pvrtc) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1098 bool texCompASTC; // ASTC texture compression support (GL_KHR_texture_compression_astc_hdr, GL_KHR_texture_compression_astc_ldr) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1099 bool texMirrorClamp; // Clamp mirror wrap mode supported (GL_EXT_texture_mirror_clamp) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1100 bool texAnisoFilter; // Anisotropic texture filtering support (GL_EXT_texture_filter_anisotropic) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1101 bool computeShader; // Compute shaders support (GL_ARB_compute_shader) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1102 bool ssbo; // Shader storage buffer object support (GL_ARB_shader_storage_buffer_object) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1103 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1104 float maxAnisotropyLevel; // Maximum anisotropy level supported (minimum is 2.0f) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1105 int maxDepthBits; // Maximum bits for depth component |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1106 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1107 } ExtSupported; // Extensions supported flags |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1108 } rlglData; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1109 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1110 typedef void *(*rlglLoadProc)(const char *name); // OpenGL extension functions loader signature (same as GLADloadproc) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1111 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1112 #endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1113 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1114 //---------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1115 // Global Variables Definition |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1116 //---------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1117 static double rlCullDistanceNear = RL_CULL_DISTANCE_NEAR; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1118 static double rlCullDistanceFar = RL_CULL_DISTANCE_FAR; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1119 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1120 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1121 static rlglData RLGL = { 0 }; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1122 #endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1123 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1124 #if defined(GRAPHICS_API_OPENGL_ES2) && !defined(GRAPHICS_API_OPENGL_ES3) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1125 // NOTE: VAO functionality is exposed through extensions (OES) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1126 static PFNGLGENVERTEXARRAYSOESPROC glGenVertexArrays = NULL; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1127 static PFNGLBINDVERTEXARRAYOESPROC glBindVertexArray = NULL; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1128 static PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArrays = NULL; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1129 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1130 // NOTE: Instancing functionality could also be available through extension |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1131 static PFNGLDRAWARRAYSINSTANCEDEXTPROC glDrawArraysInstanced = NULL; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1132 static PFNGLDRAWELEMENTSINSTANCEDEXTPROC glDrawElementsInstanced = NULL; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1133 static PFNGLVERTEXATTRIBDIVISOREXTPROC glVertexAttribDivisor = NULL; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1134 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1135 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1136 //---------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1137 // Module specific Functions Declaration |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1138 //---------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1139 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1140 static void rlLoadShaderDefault(void); // Load default shader |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1141 static void rlUnloadShaderDefault(void); // Unload default shader |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1142 #if defined(RLGL_SHOW_GL_DETAILS_INFO) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1143 static const char *rlGetCompressedFormatName(int format); // Get compressed format official GL identifier name |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1144 #endif // RLGL_SHOW_GL_DETAILS_INFO |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1145 #endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1146 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1147 static int rlGetPixelDataSize(int width, int height, int format); // Get pixel data size in bytes (image or texture) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1148 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1149 // Auxiliar matrix math functions |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1150 typedef struct rl_float16 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1151 float v[16]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1152 } rl_float16; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1153 static rl_float16 rlMatrixToFloatV(Matrix mat); // Get float array of matrix data |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1154 #define rlMatrixToFloat(mat) (rlMatrixToFloatV(mat).v) // Get float vector for Matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1155 static Matrix rlMatrixIdentity(void); // Get identity matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1156 static Matrix rlMatrixMultiply(Matrix left, Matrix right); // Multiply two matrices |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1157 static Matrix rlMatrixTranspose(Matrix mat); // Transposes provided matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1158 static Matrix rlMatrixInvert(Matrix mat); // Invert provided matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1159 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1160 //---------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1161 // Module Functions Definition - Matrix operations |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1162 //---------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1163 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1164 #if defined(GRAPHICS_API_OPENGL_11) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1165 // Fallback to OpenGL 1.1 function calls |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1166 //--------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1167 void rlMatrixMode(int mode) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1168 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1169 switch (mode) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1170 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1171 case RL_PROJECTION: glMatrixMode(GL_PROJECTION); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1172 case RL_MODELVIEW: glMatrixMode(GL_MODELVIEW); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1173 case RL_TEXTURE: glMatrixMode(GL_TEXTURE); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1174 default: break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1175 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1176 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1177 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1178 void rlFrustum(double left, double right, double bottom, double top, double znear, double zfar) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1179 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1180 glFrustum(left, right, bottom, top, znear, zfar); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1181 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1182 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1183 void rlOrtho(double left, double right, double bottom, double top, double znear, double zfar) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1184 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1185 glOrtho(left, right, bottom, top, znear, zfar); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1186 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1187 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1188 void rlPushMatrix(void) { glPushMatrix(); } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1189 void rlPopMatrix(void) { glPopMatrix(); } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1190 void rlLoadIdentity(void) { glLoadIdentity(); } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1191 void rlTranslatef(float x, float y, float z) { glTranslatef(x, y, z); } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1192 void rlRotatef(float angle, float x, float y, float z) { glRotatef(angle, x, y, z); } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1193 void rlScalef(float x, float y, float z) { glScalef(x, y, z); } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1194 void rlMultMatrixf(const float *matf) { glMultMatrixf(matf); } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1195 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1196 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1197 // Choose the current matrix to be transformed |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1198 void rlMatrixMode(int mode) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1199 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1200 if (mode == RL_PROJECTION) RLGL.State.currentMatrix = &RLGL.State.projection; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1201 else if (mode == RL_MODELVIEW) RLGL.State.currentMatrix = &RLGL.State.modelview; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1202 //else if (mode == RL_TEXTURE) // Not supported |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1203 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1204 RLGL.State.currentMatrixMode = mode; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1205 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1206 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1207 // Push the current matrix into RLGL.State.stack |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1208 void rlPushMatrix(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1209 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1210 if (RLGL.State.stackCounter >= RL_MAX_MATRIX_STACK_SIZE) TRACELOG(RL_LOG_ERROR, "RLGL: Matrix stack overflow (RL_MAX_MATRIX_STACK_SIZE)"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1211 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1212 if (RLGL.State.currentMatrixMode == RL_MODELVIEW) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1213 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1214 RLGL.State.transformRequired = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1215 RLGL.State.currentMatrix = &RLGL.State.transform; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1216 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1217 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1218 RLGL.State.stack[RLGL.State.stackCounter] = *RLGL.State.currentMatrix; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1219 RLGL.State.stackCounter++; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1220 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1221 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1222 // Pop lattest inserted matrix from RLGL.State.stack |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1223 void rlPopMatrix(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1224 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1225 if (RLGL.State.stackCounter > 0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1226 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1227 Matrix mat = RLGL.State.stack[RLGL.State.stackCounter - 1]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1228 *RLGL.State.currentMatrix = mat; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1229 RLGL.State.stackCounter--; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1230 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1231 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1232 if ((RLGL.State.stackCounter == 0) && (RLGL.State.currentMatrixMode == RL_MODELVIEW)) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1233 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1234 RLGL.State.currentMatrix = &RLGL.State.modelview; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1235 RLGL.State.transformRequired = false; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1236 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1237 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1238 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1239 // Reset current matrix to identity matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1240 void rlLoadIdentity(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1241 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1242 *RLGL.State.currentMatrix = rlMatrixIdentity(); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1243 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1244 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1245 // Multiply the current matrix by a translation matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1246 void rlTranslatef(float x, float y, float z) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1247 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1248 Matrix matTranslation = { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1249 1.0f, 0.0f, 0.0f, x, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1250 0.0f, 1.0f, 0.0f, y, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1251 0.0f, 0.0f, 1.0f, z, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1252 0.0f, 0.0f, 0.0f, 1.0f |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1253 }; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1254 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1255 // NOTE: We transpose matrix with multiplication order |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1256 *RLGL.State.currentMatrix = rlMatrixMultiply(matTranslation, *RLGL.State.currentMatrix); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1257 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1258 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1259 // Multiply the current matrix by a rotation matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1260 // NOTE: The provided angle must be in degrees |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1261 void rlRotatef(float angle, float x, float y, float z) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1262 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1263 Matrix matRotation = rlMatrixIdentity(); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1264 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1265 // Axis vector (x, y, z) normalization |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1266 float lengthSquared = x*x + y*y + z*z; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1267 if ((lengthSquared != 1.0f) && (lengthSquared != 0.0f)) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1268 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1269 float inverseLength = 1.0f/sqrtf(lengthSquared); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1270 x *= inverseLength; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1271 y *= inverseLength; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1272 z *= inverseLength; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1273 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1274 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1275 // Rotation matrix generation |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1276 float sinres = sinf(DEG2RAD*angle); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1277 float cosres = cosf(DEG2RAD*angle); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1278 float t = 1.0f - cosres; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1279 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1280 matRotation.m0 = x*x*t + cosres; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1281 matRotation.m1 = y*x*t + z*sinres; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1282 matRotation.m2 = z*x*t - y*sinres; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1283 matRotation.m3 = 0.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1284 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1285 matRotation.m4 = x*y*t - z*sinres; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1286 matRotation.m5 = y*y*t + cosres; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1287 matRotation.m6 = z*y*t + x*sinres; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1288 matRotation.m7 = 0.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1289 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1290 matRotation.m8 = x*z*t + y*sinres; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1291 matRotation.m9 = y*z*t - x*sinres; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1292 matRotation.m10 = z*z*t + cosres; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1293 matRotation.m11 = 0.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1294 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1295 matRotation.m12 = 0.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1296 matRotation.m13 = 0.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1297 matRotation.m14 = 0.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1298 matRotation.m15 = 1.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1299 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1300 // NOTE: We transpose matrix with multiplication order |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1301 *RLGL.State.currentMatrix = rlMatrixMultiply(matRotation, *RLGL.State.currentMatrix); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1302 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1303 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1304 // Multiply the current matrix by a scaling matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1305 void rlScalef(float x, float y, float z) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1306 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1307 Matrix matScale = { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1308 x, 0.0f, 0.0f, 0.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1309 0.0f, y, 0.0f, 0.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1310 0.0f, 0.0f, z, 0.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1311 0.0f, 0.0f, 0.0f, 1.0f |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1312 }; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1313 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1314 // NOTE: We transpose matrix with multiplication order |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1315 *RLGL.State.currentMatrix = rlMatrixMultiply(matScale, *RLGL.State.currentMatrix); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1316 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1317 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1318 // Multiply the current matrix by another matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1319 void rlMultMatrixf(const float *matf) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1320 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1321 // Matrix creation from array |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1322 Matrix mat = { matf[0], matf[4], matf[8], matf[12], |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1323 matf[1], matf[5], matf[9], matf[13], |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1324 matf[2], matf[6], matf[10], matf[14], |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1325 matf[3], matf[7], matf[11], matf[15] }; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1326 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1327 *RLGL.State.currentMatrix = rlMatrixMultiply(mat, *RLGL.State.currentMatrix); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1328 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1329 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1330 // Multiply the current matrix by a perspective matrix generated by parameters |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1331 void rlFrustum(double left, double right, double bottom, double top, double znear, double zfar) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1332 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1333 Matrix matFrustum = { 0 }; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1334 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1335 float rl = (float)(right - left); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1336 float tb = (float)(top - bottom); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1337 float fn = (float)(zfar - znear); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1338 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1339 matFrustum.m0 = ((float) znear*2.0f)/rl; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1340 matFrustum.m1 = 0.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1341 matFrustum.m2 = 0.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1342 matFrustum.m3 = 0.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1343 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1344 matFrustum.m4 = 0.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1345 matFrustum.m5 = ((float) znear*2.0f)/tb; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1346 matFrustum.m6 = 0.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1347 matFrustum.m7 = 0.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1348 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1349 matFrustum.m8 = ((float)right + (float)left)/rl; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1350 matFrustum.m9 = ((float)top + (float)bottom)/tb; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1351 matFrustum.m10 = -((float)zfar + (float)znear)/fn; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1352 matFrustum.m11 = -1.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1353 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1354 matFrustum.m12 = 0.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1355 matFrustum.m13 = 0.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1356 matFrustum.m14 = -((float)zfar*(float)znear*2.0f)/fn; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1357 matFrustum.m15 = 0.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1358 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1359 *RLGL.State.currentMatrix = rlMatrixMultiply(*RLGL.State.currentMatrix, matFrustum); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1360 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1361 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1362 // Multiply the current matrix by an orthographic matrix generated by parameters |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1363 void rlOrtho(double left, double right, double bottom, double top, double znear, double zfar) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1364 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1365 // NOTE: If left-right and top-botton values are equal it could create a division by zero, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1366 // response to it is platform/compiler dependant |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1367 Matrix matOrtho = { 0 }; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1368 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1369 float rl = (float)(right - left); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1370 float tb = (float)(top - bottom); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1371 float fn = (float)(zfar - znear); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1372 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1373 matOrtho.m0 = 2.0f/rl; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1374 matOrtho.m1 = 0.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1375 matOrtho.m2 = 0.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1376 matOrtho.m3 = 0.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1377 matOrtho.m4 = 0.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1378 matOrtho.m5 = 2.0f/tb; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1379 matOrtho.m6 = 0.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1380 matOrtho.m7 = 0.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1381 matOrtho.m8 = 0.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1382 matOrtho.m9 = 0.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1383 matOrtho.m10 = -2.0f/fn; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1384 matOrtho.m11 = 0.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1385 matOrtho.m12 = -((float)left + (float)right)/rl; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1386 matOrtho.m13 = -((float)top + (float)bottom)/tb; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1387 matOrtho.m14 = -((float)zfar + (float)znear)/fn; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1388 matOrtho.m15 = 1.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1389 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1390 *RLGL.State.currentMatrix = rlMatrixMultiply(*RLGL.State.currentMatrix, matOrtho); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1391 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1392 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1393 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1394 // Set the viewport area (transformation from normalized device coordinates to window coordinates) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1395 // NOTE: We store current viewport dimensions |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1396 void rlViewport(int x, int y, int width, int height) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1397 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1398 glViewport(x, y, width, height); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1399 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1400 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1401 // Set clip planes distances |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1402 void rlSetClipPlanes(double nearPlane, double farPlane) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1403 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1404 rlCullDistanceNear = nearPlane; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1405 rlCullDistanceFar = farPlane; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1406 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1407 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1408 // Get cull plane distance near |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1409 double rlGetCullDistanceNear(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1410 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1411 return rlCullDistanceNear; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1412 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1413 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1414 // Get cull plane distance far |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1415 double rlGetCullDistanceFar(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1416 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1417 return rlCullDistanceFar; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1418 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1419 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1420 //---------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1421 // Module Functions Definition - Vertex level operations |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1422 //---------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1423 #if defined(GRAPHICS_API_OPENGL_11) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1424 // Fallback to OpenGL 1.1 function calls |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1425 //--------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1426 void rlBegin(int mode) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1427 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1428 switch (mode) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1429 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1430 case RL_LINES: glBegin(GL_LINES); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1431 case RL_TRIANGLES: glBegin(GL_TRIANGLES); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1432 case RL_QUADS: glBegin(GL_QUADS); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1433 default: break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1434 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1435 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1436 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1437 void rlEnd(void) { glEnd(); } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1438 void rlVertex2i(int x, int y) { glVertex2i(x, y); } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1439 void rlVertex2f(float x, float y) { glVertex2f(x, y); } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1440 void rlVertex3f(float x, float y, float z) { glVertex3f(x, y, z); } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1441 void rlTexCoord2f(float x, float y) { glTexCoord2f(x, y); } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1442 void rlNormal3f(float x, float y, float z) { glNormal3f(x, y, z); } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1443 void rlColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a) { glColor4ub(r, g, b, a); } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1444 void rlColor3f(float x, float y, float z) { glColor3f(x, y, z); } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1445 void rlColor4f(float x, float y, float z, float w) { glColor4f(x, y, z, w); } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1446 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1447 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1448 // Initialize drawing mode (how to organize vertex) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1449 void rlBegin(int mode) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1450 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1451 // Draw mode can be RL_LINES, RL_TRIANGLES and RL_QUADS |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1452 // NOTE: In all three cases, vertex are accumulated over default internal vertex buffer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1453 if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode != mode) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1454 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1455 if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount > 0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1456 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1457 // Make sure current RLGL.currentBatch->draws[i].vertexCount is aligned a multiple of 4, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1458 // that way, following QUADS drawing will keep aligned with index processing |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1459 // It implies adding some extra alignment vertex at the end of the draw, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1460 // those vertex are not processed but they are considered as an additional offset |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1461 // for the next set of vertex to be drawn |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1462 if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_LINES) RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment = ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount < 4)? RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount : RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount%4); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1463 else if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_TRIANGLES) RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment = ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount < 4)? 1 : (4 - (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount%4))); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1464 else RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1465 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1466 if (!rlCheckRenderBatchLimit(RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment)) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1467 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1468 RLGL.State.vertexCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1469 RLGL.currentBatch->drawCounter++; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1470 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1471 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1472 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1473 if (RLGL.currentBatch->drawCounter >= RL_DEFAULT_BATCH_DRAWCALLS) rlDrawRenderBatch(RLGL.currentBatch); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1474 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1475 RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode = mode; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1476 RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1477 RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId = RLGL.State.defaultTextureId; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1478 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1479 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1480 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1481 // Finish vertex providing |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1482 void rlEnd(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1483 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1484 // NOTE: Depth increment is dependant on rlOrtho(): z-near and z-far values, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1485 // as well as depth buffer bit-depth (16bit or 24bit or 32bit) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1486 // Correct increment formula would be: depthInc = (zfar - znear)/pow(2, bits) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1487 RLGL.currentBatch->currentDepth += (1.0f/20000.0f); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1488 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1489 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1490 // Define one vertex (position) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1491 // NOTE: Vertex position data is the basic information required for drawing |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1492 void rlVertex3f(float x, float y, float z) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1493 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1494 float tx = x; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1495 float ty = y; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1496 float tz = z; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1497 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1498 // Transform provided vector if required |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1499 if (RLGL.State.transformRequired) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1500 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1501 tx = RLGL.State.transform.m0*x + RLGL.State.transform.m4*y + RLGL.State.transform.m8*z + RLGL.State.transform.m12; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1502 ty = RLGL.State.transform.m1*x + RLGL.State.transform.m5*y + RLGL.State.transform.m9*z + RLGL.State.transform.m13; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1503 tz = RLGL.State.transform.m2*x + RLGL.State.transform.m6*y + RLGL.State.transform.m10*z + RLGL.State.transform.m14; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1504 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1505 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1506 // WARNING: We can't break primitives when launching a new batch |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1507 // RL_LINES comes in pairs, RL_TRIANGLES come in groups of 3 vertices and RL_QUADS come in groups of 4 vertices |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1508 // We must check current draw.mode when a new vertex is required and finish the batch only if the draw.mode draw.vertexCount is %2, %3 or %4 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1509 if (RLGL.State.vertexCounter > (RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].elementCount*4 - 4)) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1510 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1511 if ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_LINES) && |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1512 (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount%2 == 0)) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1513 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1514 // Reached the maximum number of vertices for RL_LINES drawing |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1515 // Launch a draw call but keep current state for next vertices comming |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1516 // NOTE: We add +1 vertex to the check for security |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1517 rlCheckRenderBatchLimit(2 + 1); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1518 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1519 else if ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_TRIANGLES) && |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1520 (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount%3 == 0)) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1521 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1522 rlCheckRenderBatchLimit(3 + 1); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1523 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1524 else if ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_QUADS) && |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1525 (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount%4 == 0)) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1526 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1527 rlCheckRenderBatchLimit(4 + 1); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1528 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1529 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1530 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1531 // Add vertices |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1532 RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vertices[3*RLGL.State.vertexCounter] = tx; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1533 RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vertices[3*RLGL.State.vertexCounter + 1] = ty; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1534 RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vertices[3*RLGL.State.vertexCounter + 2] = tz; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1535 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1536 // Add current texcoord |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1537 RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].texcoords[2*RLGL.State.vertexCounter] = RLGL.State.texcoordx; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1538 RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].texcoords[2*RLGL.State.vertexCounter + 1] = RLGL.State.texcoordy; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1539 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1540 // Add current normal |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1541 RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].normals[3*RLGL.State.vertexCounter] = RLGL.State.normalx; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1542 RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].normals[3*RLGL.State.vertexCounter + 1] = RLGL.State.normaly; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1543 RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].normals[3*RLGL.State.vertexCounter + 2] = RLGL.State.normalz; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1544 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1545 // Add current color |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1546 RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].colors[4*RLGL.State.vertexCounter] = RLGL.State.colorr; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1547 RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].colors[4*RLGL.State.vertexCounter + 1] = RLGL.State.colorg; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1548 RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].colors[4*RLGL.State.vertexCounter + 2] = RLGL.State.colorb; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1549 RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].colors[4*RLGL.State.vertexCounter + 3] = RLGL.State.colora; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1550 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1551 RLGL.State.vertexCounter++; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1552 RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount++; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1553 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1554 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1555 // Define one vertex (position) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1556 void rlVertex2f(float x, float y) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1557 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1558 rlVertex3f(x, y, RLGL.currentBatch->currentDepth); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1559 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1560 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1561 // Define one vertex (position) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1562 void rlVertex2i(int x, int y) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1563 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1564 rlVertex3f((float)x, (float)y, RLGL.currentBatch->currentDepth); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1565 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1566 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1567 // Define one vertex (texture coordinate) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1568 // NOTE: Texture coordinates are limited to QUADS only |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1569 void rlTexCoord2f(float x, float y) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1570 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1571 RLGL.State.texcoordx = x; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1572 RLGL.State.texcoordy = y; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1573 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1574 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1575 // Define one vertex (normal) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1576 // NOTE: Normals limited to TRIANGLES only? |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1577 void rlNormal3f(float x, float y, float z) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1578 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1579 float normalx = x; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1580 float normaly = y; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1581 float normalz = z; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1582 if (RLGL.State.transformRequired) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1583 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1584 normalx = RLGL.State.transform.m0*x + RLGL.State.transform.m4*y + RLGL.State.transform.m8*z; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1585 normaly = RLGL.State.transform.m1*x + RLGL.State.transform.m5*y + RLGL.State.transform.m9*z; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1586 normalz = RLGL.State.transform.m2*x + RLGL.State.transform.m6*y + RLGL.State.transform.m10*z; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1587 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1588 float length = sqrtf(normalx*normalx + normaly*normaly + normalz*normalz); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1589 if (length != 0.0f) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1590 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1591 float ilength = 1.0f/length; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1592 normalx *= ilength; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1593 normaly *= ilength; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1594 normalz *= ilength; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1595 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1596 RLGL.State.normalx = normalx; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1597 RLGL.State.normaly = normaly; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1598 RLGL.State.normalz = normalz; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1599 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1600 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1601 // Define one vertex (color) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1602 void rlColor4ub(unsigned char x, unsigned char y, unsigned char z, unsigned char w) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1603 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1604 RLGL.State.colorr = x; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1605 RLGL.State.colorg = y; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1606 RLGL.State.colorb = z; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1607 RLGL.State.colora = w; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1608 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1609 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1610 // Define one vertex (color) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1611 void rlColor4f(float r, float g, float b, float a) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1612 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1613 rlColor4ub((unsigned char)(r*255), (unsigned char)(g*255), (unsigned char)(b*255), (unsigned char)(a*255)); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1614 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1615 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1616 // Define one vertex (color) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1617 void rlColor3f(float x, float y, float z) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1618 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1619 rlColor4ub((unsigned char)(x*255), (unsigned char)(y*255), (unsigned char)(z*255), 255); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1620 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1621 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1622 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1623 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1624 //-------------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1625 // Module Functions Definition - OpenGL style functions (common to 1.1, 3.3+, ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1626 //-------------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1627 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1628 // Set current texture to use |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1629 void rlSetTexture(unsigned int id) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1630 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1631 if (id == 0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1632 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1633 #if defined(GRAPHICS_API_OPENGL_11) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1634 rlDisableTexture(); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1635 #else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1636 // NOTE: If quads batch limit is reached, we force a draw call and next batch starts |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1637 if (RLGL.State.vertexCounter >= |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1638 RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].elementCount*4) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1639 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1640 rlDrawRenderBatch(RLGL.currentBatch); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1641 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1642 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1643 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1644 else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1645 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1646 #if defined(GRAPHICS_API_OPENGL_11) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1647 rlEnableTexture(id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1648 #else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1649 if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId != id) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1650 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1651 if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount > 0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1652 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1653 // Make sure current RLGL.currentBatch->draws[i].vertexCount is aligned a multiple of 4, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1654 // that way, following QUADS drawing will keep aligned with index processing |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1655 // It implies adding some extra alignment vertex at the end of the draw, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1656 // those vertex are not processed but they are considered as an additional offset |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1657 // for the next set of vertex to be drawn |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1658 if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_LINES) RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment = ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount < 4)? RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount : RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount%4); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1659 else if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_TRIANGLES) RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment = ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount < 4)? 1 : (4 - (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount%4))); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1660 else RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1661 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1662 if (!rlCheckRenderBatchLimit(RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment)) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1663 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1664 RLGL.State.vertexCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1665 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1666 RLGL.currentBatch->drawCounter++; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1667 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1668 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1669 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1670 if (RLGL.currentBatch->drawCounter >= RL_DEFAULT_BATCH_DRAWCALLS) rlDrawRenderBatch(RLGL.currentBatch); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1671 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1672 RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId = id; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1673 RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1674 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1675 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1676 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1677 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1678 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1679 // Select and active a texture slot |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1680 void rlActiveTextureSlot(int slot) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1681 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1682 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1683 glActiveTexture(GL_TEXTURE0 + slot); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1684 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1685 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1686 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1687 // Enable texture |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1688 void rlEnableTexture(unsigned int id) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1689 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1690 #if defined(GRAPHICS_API_OPENGL_11) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1691 glEnable(GL_TEXTURE_2D); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1692 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1693 glBindTexture(GL_TEXTURE_2D, id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1694 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1695 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1696 // Disable texture |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1697 void rlDisableTexture(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1698 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1699 #if defined(GRAPHICS_API_OPENGL_11) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1700 glDisable(GL_TEXTURE_2D); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1701 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1702 glBindTexture(GL_TEXTURE_2D, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1703 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1704 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1705 // Enable texture cubemap |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1706 void rlEnableTextureCubemap(unsigned int id) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1707 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1708 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1709 glBindTexture(GL_TEXTURE_CUBE_MAP, id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1710 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1711 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1712 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1713 // Disable texture cubemap |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1714 void rlDisableTextureCubemap(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1715 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1716 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1717 glBindTexture(GL_TEXTURE_CUBE_MAP, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1718 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1719 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1720 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1721 // Set texture parameters (wrap mode/filter mode) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1722 void rlTextureParameters(unsigned int id, int param, int value) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1723 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1724 glBindTexture(GL_TEXTURE_2D, id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1725 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1726 #if !defined(GRAPHICS_API_OPENGL_11) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1727 // Reset anisotropy filter, in case it was set |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1728 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1729 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1730 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1731 switch (param) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1732 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1733 case RL_TEXTURE_WRAP_S: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1734 case RL_TEXTURE_WRAP_T: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1735 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1736 if (value == RL_TEXTURE_WRAP_MIRROR_CLAMP) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1737 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1738 #if !defined(GRAPHICS_API_OPENGL_11) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1739 if (RLGL.ExtSupported.texMirrorClamp) glTexParameteri(GL_TEXTURE_2D, param, value); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1740 else TRACELOG(RL_LOG_WARNING, "GL: Clamp mirror wrap mode not supported (GL_MIRROR_CLAMP_EXT)"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1741 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1742 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1743 else glTexParameteri(GL_TEXTURE_2D, param, value); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1744 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1745 } break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1746 case RL_TEXTURE_MAG_FILTER: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1747 case RL_TEXTURE_MIN_FILTER: glTexParameteri(GL_TEXTURE_2D, param, value); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1748 case RL_TEXTURE_FILTER_ANISOTROPIC: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1749 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1750 #if !defined(GRAPHICS_API_OPENGL_11) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1751 if (value <= RLGL.ExtSupported.maxAnisotropyLevel) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)value); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1752 else if (RLGL.ExtSupported.maxAnisotropyLevel > 0.0f) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1753 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1754 TRACELOG(RL_LOG_WARNING, "GL: Maximum anisotropic filter level supported is %iX", id, (int)RLGL.ExtSupported.maxAnisotropyLevel); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1755 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)value); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1756 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1757 else TRACELOG(RL_LOG_WARNING, "GL: Anisotropic filtering not supported"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1758 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1759 } break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1760 #if defined(GRAPHICS_API_OPENGL_33) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1761 case RL_TEXTURE_MIPMAP_BIAS_RATIO: glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, value/100.0f); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1762 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1763 default: break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1764 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1765 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1766 glBindTexture(GL_TEXTURE_2D, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1767 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1768 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1769 // Set cubemap parameters (wrap mode/filter mode) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1770 void rlCubemapParameters(unsigned int id, int param, int value) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1771 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1772 #if !defined(GRAPHICS_API_OPENGL_11) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1773 glBindTexture(GL_TEXTURE_CUBE_MAP, id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1774 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1775 // Reset anisotropy filter, in case it was set |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1776 glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1777 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1778 switch (param) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1779 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1780 case RL_TEXTURE_WRAP_S: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1781 case RL_TEXTURE_WRAP_T: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1782 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1783 if (value == RL_TEXTURE_WRAP_MIRROR_CLAMP) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1784 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1785 if (RLGL.ExtSupported.texMirrorClamp) glTexParameteri(GL_TEXTURE_CUBE_MAP, param, value); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1786 else TRACELOG(RL_LOG_WARNING, "GL: Clamp mirror wrap mode not supported (GL_MIRROR_CLAMP_EXT)"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1787 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1788 else glTexParameteri(GL_TEXTURE_CUBE_MAP, param, value); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1789 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1790 } break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1791 case RL_TEXTURE_MAG_FILTER: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1792 case RL_TEXTURE_MIN_FILTER: glTexParameteri(GL_TEXTURE_CUBE_MAP, param, value); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1793 case RL_TEXTURE_FILTER_ANISOTROPIC: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1794 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1795 if (value <= RLGL.ExtSupported.maxAnisotropyLevel) glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)value); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1796 else if (RLGL.ExtSupported.maxAnisotropyLevel > 0.0f) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1797 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1798 TRACELOG(RL_LOG_WARNING, "GL: Maximum anisotropic filter level supported is %iX", id, (int)RLGL.ExtSupported.maxAnisotropyLevel); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1799 glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)value); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1800 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1801 else TRACELOG(RL_LOG_WARNING, "GL: Anisotropic filtering not supported"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1802 } break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1803 #if defined(GRAPHICS_API_OPENGL_33) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1804 case RL_TEXTURE_MIPMAP_BIAS_RATIO: glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_LOD_BIAS, value/100.0f); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1805 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1806 default: break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1807 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1808 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1809 glBindTexture(GL_TEXTURE_CUBE_MAP, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1810 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1811 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1812 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1813 // Enable shader program |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1814 void rlEnableShader(unsigned int id) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1815 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1816 #if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1817 glUseProgram(id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1818 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1819 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1820 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1821 // Disable shader program |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1822 void rlDisableShader(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1823 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1824 #if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1825 glUseProgram(0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1826 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1827 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1828 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1829 // Enable rendering to texture (fbo) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1830 void rlEnableFramebuffer(unsigned int id) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1831 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1832 #if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(RLGL_RENDER_TEXTURES_HINT) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1833 glBindFramebuffer(GL_FRAMEBUFFER, id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1834 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1835 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1836 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1837 // return the active render texture (fbo) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1838 unsigned int rlGetActiveFramebuffer(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1839 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1840 GLint fboId = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1841 #if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES3)) && defined(RLGL_RENDER_TEXTURES_HINT) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1842 glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &fboId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1843 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1844 return fboId; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1845 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1846 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1847 // Disable rendering to texture |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1848 void rlDisableFramebuffer(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1849 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1850 #if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(RLGL_RENDER_TEXTURES_HINT) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1851 glBindFramebuffer(GL_FRAMEBUFFER, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1852 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1853 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1854 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1855 // Blit active framebuffer to main framebuffer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1856 void rlBlitFramebuffer(int srcX, int srcY, int srcWidth, int srcHeight, int dstX, int dstY, int dstWidth, int dstHeight, int bufferMask) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1857 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1858 #if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES3)) && defined(RLGL_RENDER_TEXTURES_HINT) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1859 glBlitFramebuffer(srcX, srcY, srcWidth, srcHeight, dstX, dstY, dstWidth, dstHeight, bufferMask, GL_NEAREST); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1860 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1861 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1862 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1863 // Bind framebuffer object (fbo) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1864 void rlBindFramebuffer(unsigned int target, unsigned int framebuffer) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1865 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1866 #if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(RLGL_RENDER_TEXTURES_HINT) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1867 glBindFramebuffer(target, framebuffer); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1868 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1869 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1870 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1871 // Activate multiple draw color buffers |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1872 // NOTE: One color buffer is always active by default |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1873 void rlActiveDrawBuffers(int count) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1874 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1875 #if ((defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES3)) && defined(RLGL_RENDER_TEXTURES_HINT)) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1876 // NOTE: Maximum number of draw buffers supported is implementation dependant, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1877 // it can be queried with glGet*() but it must be at least 8 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1878 //GLint maxDrawBuffers = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1879 //glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1880 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1881 if (count > 0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1882 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1883 if (count > 8) TRACELOG(LOG_WARNING, "GL: Max color buffers limited to 8"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1884 else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1885 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1886 unsigned int buffers[8] = { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1887 #if defined(GRAPHICS_API_OPENGL_ES3) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1888 GL_COLOR_ATTACHMENT0_EXT, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1889 GL_COLOR_ATTACHMENT1_EXT, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1890 GL_COLOR_ATTACHMENT2_EXT, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1891 GL_COLOR_ATTACHMENT3_EXT, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1892 GL_COLOR_ATTACHMENT4_EXT, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1893 GL_COLOR_ATTACHMENT5_EXT, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1894 GL_COLOR_ATTACHMENT6_EXT, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1895 GL_COLOR_ATTACHMENT7_EXT, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1896 #else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1897 GL_COLOR_ATTACHMENT0, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1898 GL_COLOR_ATTACHMENT1, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1899 GL_COLOR_ATTACHMENT2, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1900 GL_COLOR_ATTACHMENT3, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1901 GL_COLOR_ATTACHMENT4, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1902 GL_COLOR_ATTACHMENT5, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1903 GL_COLOR_ATTACHMENT6, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1904 GL_COLOR_ATTACHMENT7, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1905 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1906 }; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1907 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1908 #if defined(GRAPHICS_API_OPENGL_ES3) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1909 glDrawBuffersEXT(count, buffers); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1910 #else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1911 glDrawBuffers(count, buffers); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1912 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1913 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1914 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1915 else TRACELOG(LOG_WARNING, "GL: One color buffer active by default"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1916 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1917 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1918 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1919 //---------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1920 // General render state configuration |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1921 //---------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1922 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1923 // Enable color blending |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1924 void rlEnableColorBlend(void) { glEnable(GL_BLEND); } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1925 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1926 // Disable color blending |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1927 void rlDisableColorBlend(void) { glDisable(GL_BLEND); } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1928 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1929 // Enable depth test |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1930 void rlEnableDepthTest(void) { glEnable(GL_DEPTH_TEST); } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1931 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1932 // Disable depth test |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1933 void rlDisableDepthTest(void) { glDisable(GL_DEPTH_TEST); } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1934 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1935 // Enable depth write |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1936 void rlEnableDepthMask(void) { glDepthMask(GL_TRUE); } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1937 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1938 // Disable depth write |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1939 void rlDisableDepthMask(void) { glDepthMask(GL_FALSE); } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1940 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1941 // Enable backface culling |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1942 void rlEnableBackfaceCulling(void) { glEnable(GL_CULL_FACE); } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1943 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1944 // Disable backface culling |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1945 void rlDisableBackfaceCulling(void) { glDisable(GL_CULL_FACE); } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1946 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1947 // Set color mask active for screen read/draw |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1948 void rlColorMask(bool r, bool g, bool b, bool a) { glColorMask(r, g, b, a); } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1949 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1950 // Set face culling mode |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1951 void rlSetCullFace(int mode) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1952 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1953 switch (mode) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1954 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1955 case RL_CULL_FACE_BACK: glCullFace(GL_BACK); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1956 case RL_CULL_FACE_FRONT: glCullFace(GL_FRONT); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1957 default: break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1958 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1959 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1960 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1961 // Enable scissor test |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1962 void rlEnableScissorTest(void) { glEnable(GL_SCISSOR_TEST); } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1963 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1964 // Disable scissor test |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1965 void rlDisableScissorTest(void) { glDisable(GL_SCISSOR_TEST); } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1966 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1967 // Scissor test |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1968 void rlScissor(int x, int y, int width, int height) { glScissor(x, y, width, height); } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1969 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1970 // Enable wire mode |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1971 void rlEnableWireMode(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1972 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1973 #if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_33) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1974 // NOTE: glPolygonMode() not available on OpenGL ES |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1975 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1976 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1977 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1978 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1979 // Enable point mode |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1980 void rlEnablePointMode(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1981 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1982 #if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_33) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1983 // NOTE: glPolygonMode() not available on OpenGL ES |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1984 glPolygonMode(GL_FRONT_AND_BACK, GL_POINT); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1985 glEnable(GL_PROGRAM_POINT_SIZE); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1986 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1987 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1988 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1989 // Disable wire mode |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1990 void rlDisableWireMode(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1991 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1992 #if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_33) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1993 // NOTE: glPolygonMode() not available on OpenGL ES |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1994 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1995 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1996 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1997 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1998 // Set the line drawing width |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1999 void rlSetLineWidth(float width) { glLineWidth(width); } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2000 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2001 // Get the line drawing width |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2002 float rlGetLineWidth(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2003 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2004 float width = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2005 glGetFloatv(GL_LINE_WIDTH, &width); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2006 return width; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2007 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2008 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2009 // Enable line aliasing |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2010 void rlEnableSmoothLines(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2011 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2012 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_11) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2013 glEnable(GL_LINE_SMOOTH); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2014 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2015 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2016 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2017 // Disable line aliasing |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2018 void rlDisableSmoothLines(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2019 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2020 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_11) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2021 glDisable(GL_LINE_SMOOTH); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2022 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2023 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2024 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2025 // Enable stereo rendering |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2026 void rlEnableStereoRender(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2027 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2028 #if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2029 RLGL.State.stereoRender = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2030 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2031 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2032 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2033 // Disable stereo rendering |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2034 void rlDisableStereoRender(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2035 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2036 #if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2037 RLGL.State.stereoRender = false; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2038 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2039 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2040 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2041 // Check if stereo render is enabled |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2042 bool rlIsStereoRenderEnabled(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2043 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2044 #if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2045 return RLGL.State.stereoRender; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2046 #else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2047 return false; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2048 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2049 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2050 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2051 // Clear color buffer with color |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2052 void rlClearColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2053 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2054 // Color values clamp to 0.0f(0) and 1.0f(255) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2055 float cr = (float)r/255; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2056 float cg = (float)g/255; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2057 float cb = (float)b/255; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2058 float ca = (float)a/255; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2059 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2060 glClearColor(cr, cg, cb, ca); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2061 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2062 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2063 // Clear used screen buffers (color and depth) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2064 void rlClearScreenBuffers(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2065 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2066 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear used buffers: Color and Depth (Depth is used for 3D) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2067 //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); // Stencil buffer not used... |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2068 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2069 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2070 // Check and log OpenGL error codes |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2071 void rlCheckErrors(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2072 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2073 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2074 int check = 1; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2075 while (check) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2076 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2077 const GLenum err = glGetError(); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2078 switch (err) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2079 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2080 case GL_NO_ERROR: check = 0; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2081 case 0x0500: TRACELOG(RL_LOG_WARNING, "GL: Error detected: GL_INVALID_ENUM"); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2082 case 0x0501: TRACELOG(RL_LOG_WARNING, "GL: Error detected: GL_INVALID_VALUE"); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2083 case 0x0502: TRACELOG(RL_LOG_WARNING, "GL: Error detected: GL_INVALID_OPERATION"); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2084 case 0x0503: TRACELOG(RL_LOG_WARNING, "GL: Error detected: GL_STACK_OVERFLOW"); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2085 case 0x0504: TRACELOG(RL_LOG_WARNING, "GL: Error detected: GL_STACK_UNDERFLOW"); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2086 case 0x0505: TRACELOG(RL_LOG_WARNING, "GL: Error detected: GL_OUT_OF_MEMORY"); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2087 case 0x0506: TRACELOG(RL_LOG_WARNING, "GL: Error detected: GL_INVALID_FRAMEBUFFER_OPERATION"); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2088 default: TRACELOG(RL_LOG_WARNING, "GL: Error detected: Unknown error code: %x", err); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2089 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2090 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2091 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2092 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2093 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2094 // Set blend mode |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2095 void rlSetBlendMode(int mode) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2096 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2097 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2098 if ((RLGL.State.currentBlendMode != mode) || ((mode == RL_BLEND_CUSTOM || mode == RL_BLEND_CUSTOM_SEPARATE) && RLGL.State.glCustomBlendModeModified)) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2099 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2100 rlDrawRenderBatch(RLGL.currentBatch); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2101 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2102 switch (mode) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2103 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2104 case RL_BLEND_ALPHA: glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendEquation(GL_FUNC_ADD); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2105 case RL_BLEND_ADDITIVE: glBlendFunc(GL_SRC_ALPHA, GL_ONE); glBlendEquation(GL_FUNC_ADD); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2106 case RL_BLEND_MULTIPLIED: glBlendFunc(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA); glBlendEquation(GL_FUNC_ADD); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2107 case RL_BLEND_ADD_COLORS: glBlendFunc(GL_ONE, GL_ONE); glBlendEquation(GL_FUNC_ADD); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2108 case RL_BLEND_SUBTRACT_COLORS: glBlendFunc(GL_ONE, GL_ONE); glBlendEquation(GL_FUNC_SUBTRACT); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2109 case RL_BLEND_ALPHA_PREMULTIPLY: glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glBlendEquation(GL_FUNC_ADD); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2110 case RL_BLEND_CUSTOM: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2111 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2112 // NOTE: Using GL blend src/dst factors and GL equation configured with rlSetBlendFactors() |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2113 glBlendFunc(RLGL.State.glBlendSrcFactor, RLGL.State.glBlendDstFactor); glBlendEquation(RLGL.State.glBlendEquation); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2114 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2115 } break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2116 case RL_BLEND_CUSTOM_SEPARATE: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2117 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2118 // NOTE: Using GL blend src/dst factors and GL equation configured with rlSetBlendFactorsSeparate() |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2119 glBlendFuncSeparate(RLGL.State.glBlendSrcFactorRGB, RLGL.State.glBlendDestFactorRGB, RLGL.State.glBlendSrcFactorAlpha, RLGL.State.glBlendDestFactorAlpha); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2120 glBlendEquationSeparate(RLGL.State.glBlendEquationRGB, RLGL.State.glBlendEquationAlpha); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2121 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2122 } break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2123 default: break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2124 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2125 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2126 RLGL.State.currentBlendMode = mode; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2127 RLGL.State.glCustomBlendModeModified = false; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2128 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2129 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2130 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2131 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2132 // Set blending mode factor and equation |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2133 void rlSetBlendFactors(int glSrcFactor, int glDstFactor, int glEquation) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2134 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2135 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2136 if ((RLGL.State.glBlendSrcFactor != glSrcFactor) || |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2137 (RLGL.State.glBlendDstFactor != glDstFactor) || |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2138 (RLGL.State.glBlendEquation != glEquation)) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2139 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2140 RLGL.State.glBlendSrcFactor = glSrcFactor; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2141 RLGL.State.glBlendDstFactor = glDstFactor; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2142 RLGL.State.glBlendEquation = glEquation; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2143 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2144 RLGL.State.glCustomBlendModeModified = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2145 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2146 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2147 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2148 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2149 // Set blending mode factor and equation separately for RGB and alpha |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2150 void rlSetBlendFactorsSeparate(int glSrcRGB, int glDstRGB, int glSrcAlpha, int glDstAlpha, int glEqRGB, int glEqAlpha) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2151 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2152 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2153 if ((RLGL.State.glBlendSrcFactorRGB != glSrcRGB) || |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2154 (RLGL.State.glBlendDestFactorRGB != glDstRGB) || |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2155 (RLGL.State.glBlendSrcFactorAlpha != glSrcAlpha) || |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2156 (RLGL.State.glBlendDestFactorAlpha != glDstAlpha) || |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2157 (RLGL.State.glBlendEquationRGB != glEqRGB) || |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2158 (RLGL.State.glBlendEquationAlpha != glEqAlpha)) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2159 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2160 RLGL.State.glBlendSrcFactorRGB = glSrcRGB; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2161 RLGL.State.glBlendDestFactorRGB = glDstRGB; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2162 RLGL.State.glBlendSrcFactorAlpha = glSrcAlpha; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2163 RLGL.State.glBlendDestFactorAlpha = glDstAlpha; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2164 RLGL.State.glBlendEquationRGB = glEqRGB; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2165 RLGL.State.glBlendEquationAlpha = glEqAlpha; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2166 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2167 RLGL.State.glCustomBlendModeModified = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2168 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2169 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2170 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2171 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2172 //---------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2173 // Module Functions Definition - OpenGL Debug |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2174 //---------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2175 #if defined(RLGL_ENABLE_OPENGL_DEBUG_CONTEXT) && defined(GRAPHICS_API_OPENGL_43) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2176 static void GLAPIENTRY rlDebugMessageCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2177 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2178 // Ignore non-significant error/warning codes (NVidia drivers) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2179 // NOTE: Here there are the details with a sample output: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2180 // - #131169 - Framebuffer detailed info: The driver allocated storage for renderbuffer 2. (severity: low) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2181 // - #131185 - Buffer detailed info: Buffer object 1 (bound to GL_ELEMENT_ARRAY_BUFFER_ARB, usage hint is GL_ENUM_88e4) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2182 // will use VIDEO memory as the source for buffer object operations. (severity: low) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2183 // - #131218 - Program/shader state performance warning: Vertex shader in program 7 is being recompiled based on GL state. (severity: medium) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2184 // - #131204 - Texture state usage warning: The texture object (0) bound to texture image unit 0 does not have |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2185 // a defined base level and cannot be used for texture mapping. (severity: low) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2186 if ((id == 131169) || (id == 131185) || (id == 131218) || (id == 131204)) return; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2187 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2188 const char *msgSource = NULL; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2189 switch (source) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2190 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2191 case GL_DEBUG_SOURCE_API: msgSource = "API"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2192 case GL_DEBUG_SOURCE_WINDOW_SYSTEM: msgSource = "WINDOW_SYSTEM"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2193 case GL_DEBUG_SOURCE_SHADER_COMPILER: msgSource = "SHADER_COMPILER"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2194 case GL_DEBUG_SOURCE_THIRD_PARTY: msgSource = "THIRD_PARTY"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2195 case GL_DEBUG_SOURCE_APPLICATION: msgSource = "APPLICATION"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2196 case GL_DEBUG_SOURCE_OTHER: msgSource = "OTHER"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2197 default: break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2198 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2199 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2200 const char *msgType = NULL; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2201 switch (type) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2202 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2203 case GL_DEBUG_TYPE_ERROR: msgType = "ERROR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2204 case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: msgType = "DEPRECATED_BEHAVIOR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2205 case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: msgType = "UNDEFINED_BEHAVIOR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2206 case GL_DEBUG_TYPE_PORTABILITY: msgType = "PORTABILITY"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2207 case GL_DEBUG_TYPE_PERFORMANCE: msgType = "PERFORMANCE"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2208 case GL_DEBUG_TYPE_MARKER: msgType = "MARKER"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2209 case GL_DEBUG_TYPE_PUSH_GROUP: msgType = "PUSH_GROUP"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2210 case GL_DEBUG_TYPE_POP_GROUP: msgType = "POP_GROUP"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2211 case GL_DEBUG_TYPE_OTHER: msgType = "OTHER"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2212 default: break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2213 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2214 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2215 const char *msgSeverity = "DEFAULT"; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2216 switch (severity) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2217 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2218 case GL_DEBUG_SEVERITY_LOW: msgSeverity = "LOW"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2219 case GL_DEBUG_SEVERITY_MEDIUM: msgSeverity = "MEDIUM"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2220 case GL_DEBUG_SEVERITY_HIGH: msgSeverity = "HIGH"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2221 case GL_DEBUG_SEVERITY_NOTIFICATION: msgSeverity = "NOTIFICATION"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2222 default: break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2223 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2224 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2225 TRACELOG(LOG_WARNING, "GL: OpenGL debug message: %s", message); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2226 TRACELOG(LOG_WARNING, " > Type: %s", msgType); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2227 TRACELOG(LOG_WARNING, " > Source = %s", msgSource); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2228 TRACELOG(LOG_WARNING, " > Severity = %s", msgSeverity); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2229 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2230 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2231 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2232 //---------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2233 // Module Functions Definition - rlgl functionality |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2234 //---------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2235 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2236 // Initialize rlgl: OpenGL extensions, default buffers/shaders/textures, OpenGL states |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2237 void rlglInit(int width, int height) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2238 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2239 // Enable OpenGL debug context if required |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2240 #if defined(RLGL_ENABLE_OPENGL_DEBUG_CONTEXT) && defined(GRAPHICS_API_OPENGL_43) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2241 if ((glDebugMessageCallback != NULL) && (glDebugMessageControl != NULL)) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2242 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2243 glDebugMessageCallback(rlDebugMessageCallback, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2244 // glDebugMessageControl(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_ERROR, GL_DEBUG_SEVERITY_HIGH, 0, 0, GL_TRUE); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2245 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2246 // Debug context options: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2247 // - GL_DEBUG_OUTPUT - Faster version but not useful for breakpoints |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2248 // - GL_DEBUG_OUTPUT_SYNCHRONUS - Callback is in sync with errors, so a breakpoint can be placed on the callback in order to get a stacktrace for the GL error |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2249 glEnable(GL_DEBUG_OUTPUT); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2250 glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2251 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2252 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2253 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2254 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2255 // Init default white texture |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2256 unsigned char pixels[4] = { 255, 255, 255, 255 }; // 1 pixel RGBA (4 bytes) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2257 RLGL.State.defaultTextureId = rlLoadTexture(pixels, 1, 1, RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, 1); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2258 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2259 if (RLGL.State.defaultTextureId != 0) TRACELOG(RL_LOG_INFO, "TEXTURE: [ID %i] Default texture loaded successfully", RLGL.State.defaultTextureId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2260 else TRACELOG(RL_LOG_WARNING, "TEXTURE: Failed to load default texture"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2261 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2262 // Init default Shader (customized for GL 3.3 and ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2263 // Loaded: RLGL.State.defaultShaderId + RLGL.State.defaultShaderLocs |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2264 rlLoadShaderDefault(); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2265 RLGL.State.currentShaderId = RLGL.State.defaultShaderId; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2266 RLGL.State.currentShaderLocs = RLGL.State.defaultShaderLocs; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2267 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2268 // Init default vertex arrays buffers |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2269 // Simulate that the default shader has the location RL_SHADER_LOC_VERTEX_NORMAL to bind the normal buffer for the default render batch |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2270 RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_NORMAL] = RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2271 RLGL.defaultBatch = rlLoadRenderBatch(RL_DEFAULT_BATCH_BUFFERS, RL_DEFAULT_BATCH_BUFFER_ELEMENTS); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2272 RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_NORMAL] = -1; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2273 RLGL.currentBatch = &RLGL.defaultBatch; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2274 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2275 // Init stack matrices (emulating OpenGL 1.1) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2276 for (int i = 0; i < RL_MAX_MATRIX_STACK_SIZE; i++) RLGL.State.stack[i] = rlMatrixIdentity(); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2277 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2278 // Init internal matrices |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2279 RLGL.State.transform = rlMatrixIdentity(); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2280 RLGL.State.projection = rlMatrixIdentity(); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2281 RLGL.State.modelview = rlMatrixIdentity(); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2282 RLGL.State.currentMatrix = &RLGL.State.modelview; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2283 #endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2284 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2285 // Initialize OpenGL default states |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2286 //---------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2287 // Init state: Depth test |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2288 glDepthFunc(GL_LEQUAL); // Type of depth testing to apply |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2289 glDisable(GL_DEPTH_TEST); // Disable depth testing for 2D (only used for 3D) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2290 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2291 // Init state: Blending mode |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2292 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Color blending function (how colors are mixed) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2293 glEnable(GL_BLEND); // Enable color blending (required to work with transparencies) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2294 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2295 // Init state: Culling |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2296 // NOTE: All shapes/models triangles are drawn CCW |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2297 glCullFace(GL_BACK); // Cull the back face (default) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2298 glFrontFace(GL_CCW); // Front face are defined counter clockwise (default) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2299 glEnable(GL_CULL_FACE); // Enable backface culling |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2300 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2301 // Init state: Cubemap seamless |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2302 #if defined(GRAPHICS_API_OPENGL_33) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2303 glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); // Seamless cubemaps (not supported on OpenGL ES 2.0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2304 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2305 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2306 #if defined(GRAPHICS_API_OPENGL_11) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2307 // Init state: Color hints (deprecated in OpenGL 3.0+) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2308 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Improve quality of color and texture coordinate interpolation |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2309 glShadeModel(GL_SMOOTH); // Smooth shading between vertex (vertex colors interpolation) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2310 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2311 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2312 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2313 // Store screen size into global variables |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2314 RLGL.State.framebufferWidth = width; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2315 RLGL.State.framebufferHeight = height; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2316 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2317 TRACELOG(RL_LOG_INFO, "RLGL: Default OpenGL state initialized successfully"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2318 //---------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2319 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2320 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2321 // Init state: Color/Depth buffers clear |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2322 glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Set clear color (black) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2323 glClearDepth(1.0f); // Set clear depth value (default) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2324 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear color and depth buffers (depth buffer required for 3D) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2325 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2326 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2327 // Vertex Buffer Object deinitialization (memory free) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2328 void rlglClose(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2329 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2330 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2331 rlUnloadRenderBatch(RLGL.defaultBatch); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2332 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2333 rlUnloadShaderDefault(); // Unload default shader |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2334 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2335 glDeleteTextures(1, &RLGL.State.defaultTextureId); // Unload default texture |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2336 TRACELOG(RL_LOG_INFO, "TEXTURE: [ID %i] Default texture unloaded successfully", RLGL.State.defaultTextureId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2337 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2338 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2339 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2340 // Load OpenGL extensions |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2341 // NOTE: External loader function must be provided |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2342 void rlLoadExtensions(void *loader) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2343 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2344 #if defined(GRAPHICS_API_OPENGL_33) // Also defined for GRAPHICS_API_OPENGL_21 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2345 // NOTE: glad is generated and contains only required OpenGL 3.3 Core extensions (and lower versions) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2346 if (gladLoadGL((GLADloadfunc)loader) == 0) TRACELOG(RL_LOG_WARNING, "GLAD: Cannot load OpenGL extensions"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2347 else TRACELOG(RL_LOG_INFO, "GLAD: OpenGL extensions loaded successfully"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2348 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2349 // Get number of supported extensions |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2350 GLint numExt = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2351 glGetIntegerv(GL_NUM_EXTENSIONS, &numExt); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2352 TRACELOG(RL_LOG_INFO, "GL: Supported extensions count: %i", numExt); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2353 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2354 #if defined(RLGL_SHOW_GL_DETAILS_INFO) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2355 // Get supported extensions list |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2356 // WARNING: glGetStringi() not available on OpenGL 2.1 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2357 TRACELOG(RL_LOG_INFO, "GL: OpenGL extensions:"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2358 for (int i = 0; i < numExt; i++) TRACELOG(RL_LOG_INFO, " %s", glGetStringi(GL_EXTENSIONS, i)); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2359 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2360 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2361 #if defined(GRAPHICS_API_OPENGL_21) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2362 // Register supported extensions flags |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2363 // Optional OpenGL 2.1 extensions |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2364 RLGL.ExtSupported.vao = GLAD_GL_ARB_vertex_array_object; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2365 RLGL.ExtSupported.instancing = (GLAD_GL_EXT_draw_instanced && GLAD_GL_ARB_instanced_arrays); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2366 RLGL.ExtSupported.texNPOT = GLAD_GL_ARB_texture_non_power_of_two; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2367 RLGL.ExtSupported.texFloat32 = GLAD_GL_ARB_texture_float; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2368 RLGL.ExtSupported.texFloat16 = GLAD_GL_ARB_texture_float; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2369 RLGL.ExtSupported.texDepth = GLAD_GL_ARB_depth_texture; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2370 RLGL.ExtSupported.maxDepthBits = 32; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2371 RLGL.ExtSupported.texAnisoFilter = GLAD_GL_EXT_texture_filter_anisotropic; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2372 RLGL.ExtSupported.texMirrorClamp = GLAD_GL_EXT_texture_mirror_clamp; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2373 #else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2374 // Register supported extensions flags |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2375 // OpenGL 3.3 extensions supported by default (core) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2376 RLGL.ExtSupported.vao = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2377 RLGL.ExtSupported.instancing = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2378 RLGL.ExtSupported.texNPOT = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2379 RLGL.ExtSupported.texFloat32 = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2380 RLGL.ExtSupported.texFloat16 = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2381 RLGL.ExtSupported.texDepth = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2382 RLGL.ExtSupported.maxDepthBits = 32; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2383 RLGL.ExtSupported.texAnisoFilter = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2384 RLGL.ExtSupported.texMirrorClamp = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2385 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2386 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2387 // Optional OpenGL 3.3 extensions |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2388 RLGL.ExtSupported.texCompASTC = GLAD_GL_KHR_texture_compression_astc_hdr && GLAD_GL_KHR_texture_compression_astc_ldr; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2389 RLGL.ExtSupported.texCompDXT = GLAD_GL_EXT_texture_compression_s3tc; // Texture compression: DXT |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2390 RLGL.ExtSupported.texCompETC2 = GLAD_GL_ARB_ES3_compatibility; // Texture compression: ETC2/EAC |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2391 #if defined(GRAPHICS_API_OPENGL_43) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2392 RLGL.ExtSupported.computeShader = GLAD_GL_ARB_compute_shader; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2393 RLGL.ExtSupported.ssbo = GLAD_GL_ARB_shader_storage_buffer_object; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2394 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2395 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2396 #endif // GRAPHICS_API_OPENGL_33 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2397 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2398 #if defined(GRAPHICS_API_OPENGL_ES3) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2399 // Register supported extensions flags |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2400 // OpenGL ES 3.0 extensions supported by default (or it should be) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2401 RLGL.ExtSupported.vao = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2402 RLGL.ExtSupported.instancing = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2403 RLGL.ExtSupported.texNPOT = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2404 RLGL.ExtSupported.texFloat32 = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2405 RLGL.ExtSupported.texFloat16 = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2406 RLGL.ExtSupported.texDepth = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2407 RLGL.ExtSupported.texDepthWebGL = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2408 RLGL.ExtSupported.maxDepthBits = 24; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2409 RLGL.ExtSupported.texAnisoFilter = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2410 RLGL.ExtSupported.texMirrorClamp = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2411 // TODO: Check for additional OpenGL ES 3.0 supported extensions: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2412 //RLGL.ExtSupported.texCompDXT = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2413 //RLGL.ExtSupported.texCompETC1 = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2414 //RLGL.ExtSupported.texCompETC2 = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2415 //RLGL.ExtSupported.texCompPVRT = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2416 //RLGL.ExtSupported.texCompASTC = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2417 //RLGL.ExtSupported.maxAnisotropyLevel = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2418 //RLGL.ExtSupported.computeShader = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2419 //RLGL.ExtSupported.ssbo = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2420 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2421 #elif defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2422 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2423 #if defined(PLATFORM_DESKTOP_GLFW) || defined(PLATFORM_DESKTOP_SDL) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2424 // TODO: Support GLAD loader for OpenGL ES 3.0 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2425 if (gladLoadGLES2((GLADloadfunc)loader) == 0) TRACELOG(RL_LOG_WARNING, "GLAD: Cannot load OpenGL ES2.0 functions"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2426 else TRACELOG(RL_LOG_INFO, "GLAD: OpenGL ES 2.0 loaded successfully"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2427 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2428 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2429 // Get supported extensions list |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2430 GLint numExt = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2431 const char **extList = RL_MALLOC(512*sizeof(const char *)); // Allocate 512 strings pointers (2 KB) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2432 const char *extensions = (const char *)glGetString(GL_EXTENSIONS); // One big const string |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2433 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2434 // NOTE: We have to duplicate string because glGetString() returns a const string |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2435 int size = strlen(extensions) + 1; // Get extensions string size in bytes |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2436 char *extensionsDup = (char *)RL_CALLOC(size, sizeof(char)); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2437 strcpy(extensionsDup, extensions); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2438 extList[numExt] = extensionsDup; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2439 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2440 for (int i = 0; i < size; i++) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2441 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2442 if (extensionsDup[i] == ' ') |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2443 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2444 extensionsDup[i] = '\0'; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2445 numExt++; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2446 extList[numExt] = &extensionsDup[i + 1]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2447 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2448 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2449 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2450 TRACELOG(RL_LOG_INFO, "GL: Supported extensions count: %i", numExt); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2451 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2452 #if defined(RLGL_SHOW_GL_DETAILS_INFO) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2453 TRACELOG(RL_LOG_INFO, "GL: OpenGL extensions:"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2454 for (int i = 0; i < numExt; i++) TRACELOG(RL_LOG_INFO, " %s", extList[i]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2455 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2456 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2457 // Check required extensions |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2458 for (int i = 0; i < numExt; i++) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2459 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2460 // Check VAO support |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2461 // NOTE: Only check on OpenGL ES, OpenGL 3.3 has VAO support as core feature |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2462 if (strcmp(extList[i], (const char *)"GL_OES_vertex_array_object") == 0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2463 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2464 // The extension is supported by our hardware and driver, try to get related functions pointers |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2465 // NOTE: emscripten does not support VAOs natively, it uses emulation and it reduces overall performance... |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2466 glGenVertexArrays = (PFNGLGENVERTEXARRAYSOESPROC)((rlglLoadProc)loader)("glGenVertexArraysOES"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2467 glBindVertexArray = (PFNGLBINDVERTEXARRAYOESPROC)((rlglLoadProc)loader)("glBindVertexArrayOES"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2468 glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSOESPROC)((rlglLoadProc)loader)("glDeleteVertexArraysOES"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2469 //glIsVertexArray = (PFNGLISVERTEXARRAYOESPROC)loader("glIsVertexArrayOES"); // NOTE: Fails in WebGL, omitted |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2470 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2471 if ((glGenVertexArrays != NULL) && (glBindVertexArray != NULL) && (glDeleteVertexArrays != NULL)) RLGL.ExtSupported.vao = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2472 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2473 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2474 // Check instanced rendering support |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2475 if (strstr(extList[i], (const char*)"instanced_arrays") != NULL) // Broad check for instanced_arrays |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2476 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2477 // Specific check |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2478 if (strcmp(extList[i], (const char *)"GL_ANGLE_instanced_arrays") == 0) // ANGLE |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2479 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2480 glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawArraysInstancedANGLE"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2481 glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawElementsInstancedANGLE"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2482 glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISOREXTPROC)((rlglLoadProc)loader)("glVertexAttribDivisorANGLE"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2483 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2484 else if (strcmp(extList[i], (const char *)"GL_EXT_instanced_arrays") == 0) // EXT |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2485 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2486 glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawArraysInstancedEXT"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2487 glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawElementsInstancedEXT"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2488 glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISOREXTPROC)((rlglLoadProc)loader)("glVertexAttribDivisorEXT"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2489 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2490 else if (strcmp(extList[i], (const char *)"GL_NV_instanced_arrays") == 0) // NVIDIA GLES |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2491 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2492 glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawArraysInstancedNV"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2493 glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawElementsInstancedNV"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2494 glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISOREXTPROC)((rlglLoadProc)loader)("glVertexAttribDivisorNV"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2495 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2496 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2497 // The feature will only be marked as supported if the elements from GL_XXX_instanced_arrays are present |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2498 if ((glDrawArraysInstanced != NULL) && (glDrawElementsInstanced != NULL) && (glVertexAttribDivisor != NULL)) RLGL.ExtSupported.instancing = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2499 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2500 else if (strstr(extList[i], (const char *)"draw_instanced") != NULL) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2501 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2502 // GL_ANGLE_draw_instanced doesn't exist |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2503 if (strcmp(extList[i], (const char *)"GL_EXT_draw_instanced") == 0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2504 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2505 glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawArraysInstancedEXT"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2506 glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawElementsInstancedEXT"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2507 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2508 else if (strcmp(extList[i], (const char*)"GL_NV_draw_instanced") == 0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2509 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2510 glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawArraysInstancedNV"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2511 glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawElementsInstancedNV"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2512 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2513 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2514 // But the functions will at least be loaded if only GL_XX_EXT_draw_instanced exist |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2515 if ((glDrawArraysInstanced != NULL) && (glDrawElementsInstanced != NULL) && (glVertexAttribDivisor != NULL)) RLGL.ExtSupported.instancing = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2516 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2517 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2518 // Check NPOT textures support |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2519 // NOTE: Only check on OpenGL ES, OpenGL 3.3 has NPOT textures full support as core feature |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2520 if (strcmp(extList[i], (const char *)"GL_OES_texture_npot") == 0) RLGL.ExtSupported.texNPOT = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2521 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2522 // Check texture float support |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2523 if (strcmp(extList[i], (const char *)"GL_OES_texture_float") == 0) RLGL.ExtSupported.texFloat32 = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2524 if (strcmp(extList[i], (const char *)"GL_OES_texture_half_float") == 0) RLGL.ExtSupported.texFloat16 = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2525 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2526 // Check depth texture support |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2527 if (strcmp(extList[i], (const char *)"GL_OES_depth_texture") == 0) RLGL.ExtSupported.texDepth = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2528 if (strcmp(extList[i], (const char *)"GL_WEBGL_depth_texture") == 0) RLGL.ExtSupported.texDepthWebGL = true; // WebGL requires unsized internal format |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2529 if (RLGL.ExtSupported.texDepthWebGL) RLGL.ExtSupported.texDepth = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2530 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2531 if (strcmp(extList[i], (const char *)"GL_OES_depth24") == 0) RLGL.ExtSupported.maxDepthBits = 24; // Not available on WebGL |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2532 if (strcmp(extList[i], (const char *)"GL_OES_depth32") == 0) RLGL.ExtSupported.maxDepthBits = 32; // Not available on WebGL |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2533 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2534 // Check texture compression support: DXT |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2535 if ((strcmp(extList[i], (const char *)"GL_EXT_texture_compression_s3tc") == 0) || |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2536 (strcmp(extList[i], (const char *)"GL_WEBGL_compressed_texture_s3tc") == 0) || |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2537 (strcmp(extList[i], (const char *)"GL_WEBKIT_WEBGL_compressed_texture_s3tc") == 0)) RLGL.ExtSupported.texCompDXT = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2538 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2539 // Check texture compression support: ETC1 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2540 if ((strcmp(extList[i], (const char *)"GL_OES_compressed_ETC1_RGB8_texture") == 0) || |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2541 (strcmp(extList[i], (const char *)"GL_WEBGL_compressed_texture_etc1") == 0)) RLGL.ExtSupported.texCompETC1 = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2542 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2543 // Check texture compression support: ETC2/EAC |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2544 if (strcmp(extList[i], (const char *)"GL_ARB_ES3_compatibility") == 0) RLGL.ExtSupported.texCompETC2 = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2545 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2546 // Check texture compression support: PVR |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2547 if (strcmp(extList[i], (const char *)"GL_IMG_texture_compression_pvrtc") == 0) RLGL.ExtSupported.texCompPVRT = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2548 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2549 // Check texture compression support: ASTC |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2550 if (strcmp(extList[i], (const char *)"GL_KHR_texture_compression_astc_hdr") == 0) RLGL.ExtSupported.texCompASTC = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2551 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2552 // Check anisotropic texture filter support |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2553 if (strcmp(extList[i], (const char *)"GL_EXT_texture_filter_anisotropic") == 0) RLGL.ExtSupported.texAnisoFilter = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2554 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2555 // Check clamp mirror wrap mode support |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2556 if (strcmp(extList[i], (const char *)"GL_EXT_texture_mirror_clamp") == 0) RLGL.ExtSupported.texMirrorClamp = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2557 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2558 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2559 // Free extensions pointers |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2560 RL_FREE(extList); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2561 RL_FREE(extensionsDup); // Duplicated string must be deallocated |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2562 #endif // GRAPHICS_API_OPENGL_ES2 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2563 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2564 // Check OpenGL information and capabilities |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2565 //------------------------------------------------------------------------------ |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2566 // Show current OpenGL and GLSL version |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2567 TRACELOG(RL_LOG_INFO, "GL: OpenGL device information:"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2568 TRACELOG(RL_LOG_INFO, " > Vendor: %s", glGetString(GL_VENDOR)); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2569 TRACELOG(RL_LOG_INFO, " > Renderer: %s", glGetString(GL_RENDERER)); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2570 TRACELOG(RL_LOG_INFO, " > Version: %s", glGetString(GL_VERSION)); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2571 TRACELOG(RL_LOG_INFO, " > GLSL: %s", glGetString(GL_SHADING_LANGUAGE_VERSION)); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2572 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2573 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2574 // NOTE: Anisotropy levels capability is an extension |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2575 #ifndef GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2576 #define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2577 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2578 glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &RLGL.ExtSupported.maxAnisotropyLevel); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2579 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2580 #if defined(RLGL_SHOW_GL_DETAILS_INFO) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2581 // Show some OpenGL GPU capabilities |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2582 TRACELOG(RL_LOG_INFO, "GL: OpenGL capabilities:"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2583 GLint capability = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2584 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &capability); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2585 TRACELOG(RL_LOG_INFO, " GL_MAX_TEXTURE_SIZE: %i", capability); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2586 glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &capability); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2587 TRACELOG(RL_LOG_INFO, " GL_MAX_CUBE_MAP_TEXTURE_SIZE: %i", capability); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2588 glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &capability); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2589 TRACELOG(RL_LOG_INFO, " GL_MAX_TEXTURE_IMAGE_UNITS: %i", capability); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2590 glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &capability); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2591 TRACELOG(RL_LOG_INFO, " GL_MAX_VERTEX_ATTRIBS: %i", capability); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2592 #if !defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2593 glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &capability); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2594 TRACELOG(RL_LOG_INFO, " GL_MAX_UNIFORM_BLOCK_SIZE: %i", capability); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2595 glGetIntegerv(GL_MAX_DRAW_BUFFERS, &capability); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2596 TRACELOG(RL_LOG_INFO, " GL_MAX_DRAW_BUFFERS: %i", capability); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2597 if (RLGL.ExtSupported.texAnisoFilter) TRACELOG(RL_LOG_INFO, " GL_MAX_TEXTURE_MAX_ANISOTROPY: %.0f", RLGL.ExtSupported.maxAnisotropyLevel); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2598 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2599 glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &capability); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2600 TRACELOG(RL_LOG_INFO, " GL_NUM_COMPRESSED_TEXTURE_FORMATS: %i", capability); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2601 GLint *compFormats = (GLint *)RL_CALLOC(capability, sizeof(GLint)); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2602 glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, compFormats); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2603 for (int i = 0; i < capability; i++) TRACELOG(RL_LOG_INFO, " %s", rlGetCompressedFormatName(compFormats[i])); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2604 RL_FREE(compFormats); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2605 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2606 #if defined(GRAPHICS_API_OPENGL_43) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2607 glGetIntegerv(GL_MAX_VERTEX_ATTRIB_BINDINGS, &capability); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2608 TRACELOG(RL_LOG_INFO, " GL_MAX_VERTEX_ATTRIB_BINDINGS: %i", capability); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2609 glGetIntegerv(GL_MAX_UNIFORM_LOCATIONS, &capability); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2610 TRACELOG(RL_LOG_INFO, " GL_MAX_UNIFORM_LOCATIONS: %i", capability); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2611 #endif // GRAPHICS_API_OPENGL_43 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2612 #else // RLGL_SHOW_GL_DETAILS_INFO |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2613 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2614 // Show some basic info about GL supported features |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2615 if (RLGL.ExtSupported.vao) TRACELOG(RL_LOG_INFO, "GL: VAO extension detected, VAO functions loaded successfully"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2616 else TRACELOG(RL_LOG_WARNING, "GL: VAO extension not found, VAO not supported"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2617 if (RLGL.ExtSupported.texNPOT) TRACELOG(RL_LOG_INFO, "GL: NPOT textures extension detected, full NPOT textures supported"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2618 else TRACELOG(RL_LOG_WARNING, "GL: NPOT textures extension not found, limited NPOT support (no-mipmaps, no-repeat)"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2619 if (RLGL.ExtSupported.texCompDXT) TRACELOG(RL_LOG_INFO, "GL: DXT compressed textures supported"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2620 if (RLGL.ExtSupported.texCompETC1) TRACELOG(RL_LOG_INFO, "GL: ETC1 compressed textures supported"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2621 if (RLGL.ExtSupported.texCompETC2) TRACELOG(RL_LOG_INFO, "GL: ETC2/EAC compressed textures supported"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2622 if (RLGL.ExtSupported.texCompPVRT) TRACELOG(RL_LOG_INFO, "GL: PVRT compressed textures supported"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2623 if (RLGL.ExtSupported.texCompASTC) TRACELOG(RL_LOG_INFO, "GL: ASTC compressed textures supported"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2624 if (RLGL.ExtSupported.computeShader) TRACELOG(RL_LOG_INFO, "GL: Compute shaders supported"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2625 if (RLGL.ExtSupported.ssbo) TRACELOG(RL_LOG_INFO, "GL: Shader storage buffer objects supported"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2626 #endif // RLGL_SHOW_GL_DETAILS_INFO |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2627 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2628 #endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2629 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2630 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2631 // Get current OpenGL version |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2632 int rlGetVersion(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2633 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2634 int glVersion = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2635 #if defined(GRAPHICS_API_OPENGL_11) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2636 glVersion = RL_OPENGL_11; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2637 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2638 #if defined(GRAPHICS_API_OPENGL_21) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2639 glVersion = RL_OPENGL_21; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2640 #elif defined(GRAPHICS_API_OPENGL_43) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2641 glVersion = RL_OPENGL_43; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2642 #elif defined(GRAPHICS_API_OPENGL_33) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2643 glVersion = RL_OPENGL_33; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2644 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2645 #if defined(GRAPHICS_API_OPENGL_ES3) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2646 glVersion = RL_OPENGL_ES_30; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2647 #elif defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2648 glVersion = RL_OPENGL_ES_20; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2649 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2650 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2651 return glVersion; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2652 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2653 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2654 // Set current framebuffer width |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2655 void rlSetFramebufferWidth(int width) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2656 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2657 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2658 RLGL.State.framebufferWidth = width; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2659 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2660 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2661 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2662 // Set current framebuffer height |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2663 void rlSetFramebufferHeight(int height) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2664 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2665 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2666 RLGL.State.framebufferHeight = height; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2667 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2668 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2669 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2670 // Get default framebuffer width |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2671 int rlGetFramebufferWidth(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2672 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2673 int width = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2674 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2675 width = RLGL.State.framebufferWidth; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2676 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2677 return width; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2678 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2679 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2680 // Get default framebuffer height |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2681 int rlGetFramebufferHeight(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2682 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2683 int height = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2684 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2685 height = RLGL.State.framebufferHeight; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2686 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2687 return height; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2688 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2689 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2690 // Get default internal texture (white texture) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2691 // NOTE: Default texture is a 1x1 pixel UNCOMPRESSED_R8G8B8A8 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2692 unsigned int rlGetTextureIdDefault(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2693 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2694 unsigned int id = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2695 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2696 id = RLGL.State.defaultTextureId; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2697 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2698 return id; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2699 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2700 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2701 // Get default shader id |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2702 unsigned int rlGetShaderIdDefault(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2703 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2704 unsigned int id = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2705 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2706 id = RLGL.State.defaultShaderId; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2707 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2708 return id; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2709 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2710 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2711 // Get default shader locs |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2712 int *rlGetShaderLocsDefault(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2713 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2714 int *locs = NULL; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2715 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2716 locs = RLGL.State.defaultShaderLocs; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2717 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2718 return locs; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2719 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2720 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2721 // Render batch management |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2722 //------------------------------------------------------------------------------------------------ |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2723 // Load render batch |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2724 rlRenderBatch rlLoadRenderBatch(int numBuffers, int bufferElements) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2725 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2726 rlRenderBatch batch = { 0 }; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2727 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2728 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2729 // Initialize CPU (RAM) vertex buffers (position, texcoord, color data and indexes) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2730 //-------------------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2731 batch.vertexBuffer = (rlVertexBuffer *)RL_MALLOC(numBuffers*sizeof(rlVertexBuffer)); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2732 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2733 for (int i = 0; i < numBuffers; i++) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2734 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2735 batch.vertexBuffer[i].elementCount = bufferElements; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2736 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2737 batch.vertexBuffer[i].vertices = (float *)RL_MALLOC(bufferElements*3*4*sizeof(float)); // 3 float by vertex, 4 vertex by quad |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2738 batch.vertexBuffer[i].texcoords = (float *)RL_MALLOC(bufferElements*2*4*sizeof(float)); // 2 float by texcoord, 4 texcoord by quad |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2739 batch.vertexBuffer[i].normals = (float *)RL_MALLOC(bufferElements*3*4*sizeof(float)); // 3 float by vertex, 4 vertex by quad |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2740 batch.vertexBuffer[i].colors = (unsigned char *)RL_MALLOC(bufferElements*4*4*sizeof(unsigned char)); // 4 float by color, 4 colors by quad |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2741 #if defined(GRAPHICS_API_OPENGL_33) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2742 batch.vertexBuffer[i].indices = (unsigned int *)RL_MALLOC(bufferElements*6*sizeof(unsigned int)); // 6 int by quad (indices) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2743 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2744 #if defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2745 batch.vertexBuffer[i].indices = (unsigned short *)RL_MALLOC(bufferElements*6*sizeof(unsigned short)); // 6 int by quad (indices) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2746 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2747 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2748 for (int j = 0; j < (3*4*bufferElements); j++) batch.vertexBuffer[i].vertices[j] = 0.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2749 for (int j = 0; j < (2*4*bufferElements); j++) batch.vertexBuffer[i].texcoords[j] = 0.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2750 for (int j = 0; j < (3*4*bufferElements); j++) batch.vertexBuffer[i].normals[j] = 0.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2751 for (int j = 0; j < (4*4*bufferElements); j++) batch.vertexBuffer[i].colors[j] = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2752 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2753 int k = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2754 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2755 // Indices can be initialized right now |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2756 for (int j = 0; j < (6*bufferElements); j += 6) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2757 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2758 batch.vertexBuffer[i].indices[j] = 4*k; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2759 batch.vertexBuffer[i].indices[j + 1] = 4*k + 1; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2760 batch.vertexBuffer[i].indices[j + 2] = 4*k + 2; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2761 batch.vertexBuffer[i].indices[j + 3] = 4*k; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2762 batch.vertexBuffer[i].indices[j + 4] = 4*k + 2; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2763 batch.vertexBuffer[i].indices[j + 5] = 4*k + 3; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2764 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2765 k++; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2766 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2767 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2768 RLGL.State.vertexCounter = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2769 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2770 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2771 TRACELOG(RL_LOG_INFO, "RLGL: Render batch vertex buffers loaded successfully in RAM (CPU)"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2772 //-------------------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2773 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2774 // Upload to GPU (VRAM) vertex data and initialize VAOs/VBOs |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2775 //-------------------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2776 for (int i = 0; i < numBuffers; i++) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2777 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2778 if (RLGL.ExtSupported.vao) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2779 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2780 // Initialize Quads VAO |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2781 glGenVertexArrays(1, &batch.vertexBuffer[i].vaoId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2782 glBindVertexArray(batch.vertexBuffer[i].vaoId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2783 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2784 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2785 // Quads - Vertex buffers binding and attributes enable |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2786 // Vertex position buffer (shader-location = 0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2787 glGenBuffers(1, &batch.vertexBuffer[i].vboId[0]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2788 glBindBuffer(GL_ARRAY_BUFFER, batch.vertexBuffer[i].vboId[0]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2789 glBufferData(GL_ARRAY_BUFFER, bufferElements*3*4*sizeof(float), batch.vertexBuffer[i].vertices, GL_DYNAMIC_DRAW); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2790 glEnableVertexAttribArray(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_POSITION]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2791 glVertexAttribPointer(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_POSITION], 3, GL_FLOAT, 0, 0, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2792 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2793 // Vertex texcoord buffer (shader-location = 1) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2794 glGenBuffers(1, &batch.vertexBuffer[i].vboId[1]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2795 glBindBuffer(GL_ARRAY_BUFFER, batch.vertexBuffer[i].vboId[1]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2796 glBufferData(GL_ARRAY_BUFFER, bufferElements*2*4*sizeof(float), batch.vertexBuffer[i].texcoords, GL_DYNAMIC_DRAW); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2797 glEnableVertexAttribArray(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_TEXCOORD01]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2798 glVertexAttribPointer(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_TEXCOORD01], 2, GL_FLOAT, 0, 0, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2799 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2800 // Vertex normal buffer (shader-location = 2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2801 glGenBuffers(1, &batch.vertexBuffer[i].vboId[2]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2802 glBindBuffer(GL_ARRAY_BUFFER, batch.vertexBuffer[i].vboId[2]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2803 glBufferData(GL_ARRAY_BUFFER, bufferElements*3*4*sizeof(float), batch.vertexBuffer[i].normals, GL_DYNAMIC_DRAW); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2804 glEnableVertexAttribArray(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_NORMAL]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2805 glVertexAttribPointer(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_NORMAL], 3, GL_FLOAT, 0, 0, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2806 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2807 // Vertex color buffer (shader-location = 3) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2808 glGenBuffers(1, &batch.vertexBuffer[i].vboId[3]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2809 glBindBuffer(GL_ARRAY_BUFFER, batch.vertexBuffer[i].vboId[3]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2810 glBufferData(GL_ARRAY_BUFFER, bufferElements*4*4*sizeof(unsigned char), batch.vertexBuffer[i].colors, GL_DYNAMIC_DRAW); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2811 glEnableVertexAttribArray(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_COLOR]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2812 glVertexAttribPointer(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_COLOR], 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2813 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2814 // Fill index buffer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2815 glGenBuffers(1, &batch.vertexBuffer[i].vboId[4]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2816 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, batch.vertexBuffer[i].vboId[4]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2817 #if defined(GRAPHICS_API_OPENGL_33) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2818 glBufferData(GL_ELEMENT_ARRAY_BUFFER, bufferElements*6*sizeof(int), batch.vertexBuffer[i].indices, GL_STATIC_DRAW); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2819 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2820 #if defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2821 glBufferData(GL_ELEMENT_ARRAY_BUFFER, bufferElements*6*sizeof(short), batch.vertexBuffer[i].indices, GL_STATIC_DRAW); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2822 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2823 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2824 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2825 TRACELOG(RL_LOG_INFO, "RLGL: Render batch vertex buffers loaded successfully in VRAM (GPU)"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2826 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2827 // Unbind the current VAO |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2828 if (RLGL.ExtSupported.vao) glBindVertexArray(0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2829 //-------------------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2830 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2831 // Init draw calls tracking system |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2832 //-------------------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2833 batch.draws = (rlDrawCall *)RL_MALLOC(RL_DEFAULT_BATCH_DRAWCALLS*sizeof(rlDrawCall)); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2834 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2835 for (int i = 0; i < RL_DEFAULT_BATCH_DRAWCALLS; i++) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2836 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2837 batch.draws[i].mode = RL_QUADS; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2838 batch.draws[i].vertexCount = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2839 batch.draws[i].vertexAlignment = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2840 //batch.draws[i].vaoId = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2841 //batch.draws[i].shaderId = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2842 batch.draws[i].textureId = RLGL.State.defaultTextureId; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2843 //batch.draws[i].RLGL.State.projection = rlMatrixIdentity(); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2844 //batch.draws[i].RLGL.State.modelview = rlMatrixIdentity(); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2845 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2846 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2847 batch.bufferCount = numBuffers; // Record buffer count |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2848 batch.drawCounter = 1; // Reset draws counter |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2849 batch.currentDepth = -1.0f; // Reset depth value |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2850 //-------------------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2851 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2852 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2853 return batch; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2854 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2855 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2856 // Unload default internal buffers vertex data from CPU and GPU |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2857 void rlUnloadRenderBatch(rlRenderBatch batch) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2858 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2859 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2860 // Unbind everything |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2861 glBindBuffer(GL_ARRAY_BUFFER, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2862 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2863 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2864 // Unload all vertex buffers data |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2865 for (int i = 0; i < batch.bufferCount; i++) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2866 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2867 // Unbind VAO attribs data |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2868 if (RLGL.ExtSupported.vao) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2869 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2870 glBindVertexArray(batch.vertexBuffer[i].vaoId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2871 glDisableVertexAttribArray(RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2872 glDisableVertexAttribArray(RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2873 glDisableVertexAttribArray(RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2874 glDisableVertexAttribArray(RL_DEFAULT_SHADER_ATTRIB_LOCATION_COLOR); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2875 glBindVertexArray(0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2876 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2877 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2878 // Delete VBOs from GPU (VRAM) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2879 glDeleteBuffers(1, &batch.vertexBuffer[i].vboId[0]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2880 glDeleteBuffers(1, &batch.vertexBuffer[i].vboId[1]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2881 glDeleteBuffers(1, &batch.vertexBuffer[i].vboId[2]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2882 glDeleteBuffers(1, &batch.vertexBuffer[i].vboId[3]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2883 glDeleteBuffers(1, &batch.vertexBuffer[i].vboId[4]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2884 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2885 // Delete VAOs from GPU (VRAM) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2886 if (RLGL.ExtSupported.vao) glDeleteVertexArrays(1, &batch.vertexBuffer[i].vaoId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2887 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2888 // Free vertex arrays memory from CPU (RAM) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2889 RL_FREE(batch.vertexBuffer[i].vertices); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2890 RL_FREE(batch.vertexBuffer[i].texcoords); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2891 RL_FREE(batch.vertexBuffer[i].normals); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2892 RL_FREE(batch.vertexBuffer[i].colors); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2893 RL_FREE(batch.vertexBuffer[i].indices); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2894 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2895 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2896 // Unload arrays |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2897 RL_FREE(batch.vertexBuffer); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2898 RL_FREE(batch.draws); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2899 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2900 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2901 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2902 // Draw render batch |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2903 // NOTE: We require a pointer to reset batch and increase current buffer (multi-buffer) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2904 void rlDrawRenderBatch(rlRenderBatch *batch) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2905 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2906 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2907 // Update batch vertex buffers |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2908 //------------------------------------------------------------------------------------------------------------ |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2909 // NOTE: If there is not vertex data, buffers doesn't need to be updated (vertexCount > 0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2910 // TODO: If no data changed on the CPU arrays --> No need to re-update GPU arrays (use a change detector flag?) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2911 if (RLGL.State.vertexCounter > 0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2912 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2913 // Activate elements VAO |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2914 if (RLGL.ExtSupported.vao) glBindVertexArray(batch->vertexBuffer[batch->currentBuffer].vaoId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2915 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2916 // Vertex positions buffer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2917 glBindBuffer(GL_ARRAY_BUFFER, batch->vertexBuffer[batch->currentBuffer].vboId[0]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2918 glBufferSubData(GL_ARRAY_BUFFER, 0, RLGL.State.vertexCounter*3*sizeof(float), batch->vertexBuffer[batch->currentBuffer].vertices); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2919 //glBufferData(GL_ARRAY_BUFFER, sizeof(float)*3*4*batch->vertexBuffer[batch->currentBuffer].elementCount, batch->vertexBuffer[batch->currentBuffer].vertices, GL_DYNAMIC_DRAW); // Update all buffer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2920 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2921 // Texture coordinates buffer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2922 glBindBuffer(GL_ARRAY_BUFFER, batch->vertexBuffer[batch->currentBuffer].vboId[1]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2923 glBufferSubData(GL_ARRAY_BUFFER, 0, RLGL.State.vertexCounter*2*sizeof(float), batch->vertexBuffer[batch->currentBuffer].texcoords); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2924 //glBufferData(GL_ARRAY_BUFFER, sizeof(float)*2*4*batch->vertexBuffer[batch->currentBuffer].elementCount, batch->vertexBuffer[batch->currentBuffer].texcoords, GL_DYNAMIC_DRAW); // Update all buffer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2925 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2926 // Normals buffer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2927 glBindBuffer(GL_ARRAY_BUFFER, batch->vertexBuffer[batch->currentBuffer].vboId[2]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2928 glBufferSubData(GL_ARRAY_BUFFER, 0, RLGL.State.vertexCounter*3*sizeof(float), batch->vertexBuffer[batch->currentBuffer].normals); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2929 //glBufferData(GL_ARRAY_BUFFER, sizeof(float)*3*4*batch->vertexBuffer[batch->currentBuffer].elementCount, batch->vertexBuffer[batch->currentBuffer].normals, GL_DYNAMIC_DRAW); // Update all buffer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2930 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2931 // Colors buffer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2932 glBindBuffer(GL_ARRAY_BUFFER, batch->vertexBuffer[batch->currentBuffer].vboId[3]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2933 glBufferSubData(GL_ARRAY_BUFFER, 0, RLGL.State.vertexCounter*4*sizeof(unsigned char), batch->vertexBuffer[batch->currentBuffer].colors); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2934 //glBufferData(GL_ARRAY_BUFFER, sizeof(float)*4*4*batch->vertexBuffer[batch->currentBuffer].elementCount, batch->vertexBuffer[batch->currentBuffer].colors, GL_DYNAMIC_DRAW); // Update all buffer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2935 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2936 // NOTE: glMapBuffer() causes sync issue |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2937 // If GPU is working with this buffer, glMapBuffer() will wait(stall) until GPU to finish its job |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2938 // To avoid waiting (idle), you can call first glBufferData() with NULL pointer before glMapBuffer() |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2939 // If you do that, the previous data in PBO will be discarded and glMapBuffer() returns a new |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2940 // allocated pointer immediately even if GPU is still working with the previous data |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2941 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2942 // Another option: map the buffer object into client's memory |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2943 // Probably this code could be moved somewhere else... |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2944 // batch->vertexBuffer[batch->currentBuffer].vertices = (float *)glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2945 // if (batch->vertexBuffer[batch->currentBuffer].vertices) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2946 // { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2947 // Update vertex data |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2948 // } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2949 // glUnmapBuffer(GL_ARRAY_BUFFER); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2950 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2951 // Unbind the current VAO |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2952 if (RLGL.ExtSupported.vao) glBindVertexArray(0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2953 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2954 //------------------------------------------------------------------------------------------------------------ |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2955 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2956 // Draw batch vertex buffers (considering VR stereo if required) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2957 //------------------------------------------------------------------------------------------------------------ |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2958 Matrix matProjection = RLGL.State.projection; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2959 Matrix matModelView = RLGL.State.modelview; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2960 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2961 int eyeCount = 1; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2962 if (RLGL.State.stereoRender) eyeCount = 2; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2963 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2964 for (int eye = 0; eye < eyeCount; eye++) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2965 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2966 if (eyeCount == 2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2967 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2968 // Setup current eye viewport (half screen width) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2969 rlViewport(eye*RLGL.State.framebufferWidth/2, 0, RLGL.State.framebufferWidth/2, RLGL.State.framebufferHeight); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2970 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2971 // Set current eye view offset to modelview matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2972 rlSetMatrixModelview(rlMatrixMultiply(matModelView, RLGL.State.viewOffsetStereo[eye])); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2973 // Set current eye projection matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2974 rlSetMatrixProjection(RLGL.State.projectionStereo[eye]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2975 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2976 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2977 // Draw buffers |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2978 if (RLGL.State.vertexCounter > 0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2979 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2980 // Set current shader and upload current MVP matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2981 glUseProgram(RLGL.State.currentShaderId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2982 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2983 // Create modelview-projection matrix and upload to shader |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2984 Matrix matMVP = rlMatrixMultiply(RLGL.State.modelview, RLGL.State.projection); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2985 glUniformMatrix4fv(RLGL.State.currentShaderLocs[RL_SHADER_LOC_MATRIX_MVP], 1, false, rlMatrixToFloat(matMVP)); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2986 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2987 if (RLGL.State.currentShaderLocs[RL_SHADER_LOC_MATRIX_PROJECTION] != -1) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2988 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2989 glUniformMatrix4fv(RLGL.State.currentShaderLocs[RL_SHADER_LOC_MATRIX_PROJECTION], 1, false, rlMatrixToFloat(RLGL.State.projection)); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2990 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2991 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2992 // WARNING: For the following setup of the view, model, and normal matrices, it is expected that |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2993 // transformations and rendering occur between rlPushMatrix() and rlPopMatrix() |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2994 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2995 if (RLGL.State.currentShaderLocs[RL_SHADER_LOC_MATRIX_VIEW] != -1) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2996 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2997 glUniformMatrix4fv(RLGL.State.currentShaderLocs[RL_SHADER_LOC_MATRIX_VIEW], 1, false, rlMatrixToFloat(RLGL.State.modelview)); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2998 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2999 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3000 if (RLGL.State.currentShaderLocs[RL_SHADER_LOC_MATRIX_MODEL] != -1) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3001 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3002 glUniformMatrix4fv(RLGL.State.currentShaderLocs[RL_SHADER_LOC_MATRIX_MODEL], 1, false, rlMatrixToFloat(RLGL.State.transform)); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3003 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3004 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3005 if (RLGL.State.currentShaderLocs[RL_SHADER_LOC_MATRIX_NORMAL] != -1) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3006 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3007 glUniformMatrix4fv(RLGL.State.currentShaderLocs[RL_SHADER_LOC_MATRIX_NORMAL], 1, false, rlMatrixToFloat(rlMatrixTranspose(rlMatrixInvert(RLGL.State.transform)))); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3008 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3009 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3010 if (RLGL.ExtSupported.vao) glBindVertexArray(batch->vertexBuffer[batch->currentBuffer].vaoId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3011 else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3012 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3013 // Bind vertex attrib: position (shader-location = 0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3014 glBindBuffer(GL_ARRAY_BUFFER, batch->vertexBuffer[batch->currentBuffer].vboId[0]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3015 glVertexAttribPointer(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_POSITION], 3, GL_FLOAT, 0, 0, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3016 glEnableVertexAttribArray(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_POSITION]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3017 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3018 // Bind vertex attrib: texcoord (shader-location = 1) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3019 glBindBuffer(GL_ARRAY_BUFFER, batch->vertexBuffer[batch->currentBuffer].vboId[1]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3020 glVertexAttribPointer(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_TEXCOORD01], 2, GL_FLOAT, 0, 0, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3021 glEnableVertexAttribArray(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_TEXCOORD01]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3022 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3023 // Bind vertex attrib: normal (shader-location = 2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3024 glBindBuffer(GL_ARRAY_BUFFER, batch->vertexBuffer[batch->currentBuffer].vboId[2]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3025 glVertexAttribPointer(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_NORMAL], 3, GL_FLOAT, 0, 0, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3026 glEnableVertexAttribArray(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_NORMAL]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3027 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3028 // Bind vertex attrib: color (shader-location = 3) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3029 glBindBuffer(GL_ARRAY_BUFFER, batch->vertexBuffer[batch->currentBuffer].vboId[3]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3030 glVertexAttribPointer(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_COLOR], 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3031 glEnableVertexAttribArray(RLGL.State.currentShaderLocs[RL_SHADER_LOC_VERTEX_COLOR]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3032 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3033 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, batch->vertexBuffer[batch->currentBuffer].vboId[4]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3034 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3035 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3036 // Setup some default shader values |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3037 glUniform4f(RLGL.State.currentShaderLocs[RL_SHADER_LOC_COLOR_DIFFUSE], 1.0f, 1.0f, 1.0f, 1.0f); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3038 glUniform1i(RLGL.State.currentShaderLocs[RL_SHADER_LOC_MAP_DIFFUSE], 0); // Active default sampler2D: texture0 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3039 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3040 // Activate additional sampler textures |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3041 // Those additional textures will be common for all draw calls of the batch |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3042 for (int i = 0; i < RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS; i++) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3043 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3044 if (RLGL.State.activeTextureId[i] > 0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3045 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3046 glActiveTexture(GL_TEXTURE0 + 1 + i); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3047 glBindTexture(GL_TEXTURE_2D, RLGL.State.activeTextureId[i]); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3048 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3049 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3050 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3051 // Activate default sampler2D texture0 (one texture is always active for default batch shader) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3052 // NOTE: Batch system accumulates calls by texture0 changes, additional textures are enabled for all the draw calls |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3053 glActiveTexture(GL_TEXTURE0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3054 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3055 for (int i = 0, vertexOffset = 0; i < batch->drawCounter; i++) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3056 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3057 // Bind current draw call texture, activated as GL_TEXTURE0 and Bound to sampler2D texture0 by default |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3058 glBindTexture(GL_TEXTURE_2D, batch->draws[i].textureId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3059 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3060 if ((batch->draws[i].mode == RL_LINES) || (batch->draws[i].mode == RL_TRIANGLES)) glDrawArrays(batch->draws[i].mode, vertexOffset, batch->draws[i].vertexCount); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3061 else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3062 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3063 #if defined(GRAPHICS_API_OPENGL_33) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3064 // We need to define the number of indices to be processed: elementCount*6 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3065 // NOTE: The final parameter tells the GPU the offset in bytes from the |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3066 // start of the index buffer to the location of the first index to process |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3067 glDrawElements(GL_TRIANGLES, batch->draws[i].vertexCount/4*6, GL_UNSIGNED_INT, (GLvoid *)(vertexOffset/4*6*sizeof(GLuint))); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3068 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3069 #if defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3070 glDrawElements(GL_TRIANGLES, batch->draws[i].vertexCount/4*6, GL_UNSIGNED_SHORT, (GLvoid *)(vertexOffset/4*6*sizeof(GLushort))); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3071 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3072 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3073 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3074 vertexOffset += (batch->draws[i].vertexCount + batch->draws[i].vertexAlignment); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3075 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3076 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3077 if (!RLGL.ExtSupported.vao) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3078 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3079 glBindBuffer(GL_ARRAY_BUFFER, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3080 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3081 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3082 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3083 glBindTexture(GL_TEXTURE_2D, 0); // Unbind textures |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3084 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3085 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3086 if (RLGL.ExtSupported.vao) glBindVertexArray(0); // Unbind VAO |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3087 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3088 glUseProgram(0); // Unbind shader program |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3089 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3090 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3091 // Restore viewport to default measures |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3092 if (eyeCount == 2) rlViewport(0, 0, RLGL.State.framebufferWidth, RLGL.State.framebufferHeight); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3093 //------------------------------------------------------------------------------------------------------------ |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3094 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3095 // Reset batch buffers |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3096 //------------------------------------------------------------------------------------------------------------ |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3097 // Reset vertex counter for next frame |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3098 RLGL.State.vertexCounter = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3099 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3100 // Reset depth for next draw |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3101 batch->currentDepth = -1.0f; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3102 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3103 // Restore projection/modelview matrices |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3104 RLGL.State.projection = matProjection; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3105 RLGL.State.modelview = matModelView; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3106 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3107 // Reset RLGL.currentBatch->draws array |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3108 for (int i = 0; i < RL_DEFAULT_BATCH_DRAWCALLS; i++) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3109 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3110 batch->draws[i].mode = RL_QUADS; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3111 batch->draws[i].vertexCount = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3112 batch->draws[i].textureId = RLGL.State.defaultTextureId; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3113 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3114 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3115 // Reset active texture units for next batch |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3116 for (int i = 0; i < RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS; i++) RLGL.State.activeTextureId[i] = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3117 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3118 // Reset draws counter to one draw for the batch |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3119 batch->drawCounter = 1; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3120 //------------------------------------------------------------------------------------------------------------ |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3121 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3122 // Change to next buffer in the list (in case of multi-buffering) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3123 batch->currentBuffer++; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3124 if (batch->currentBuffer >= batch->bufferCount) batch->currentBuffer = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3125 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3126 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3127 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3128 // Set the active render batch for rlgl |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3129 void rlSetRenderBatchActive(rlRenderBatch *batch) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3130 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3131 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3132 rlDrawRenderBatch(RLGL.currentBatch); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3133 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3134 if (batch != NULL) RLGL.currentBatch = batch; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3135 else RLGL.currentBatch = &RLGL.defaultBatch; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3136 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3137 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3138 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3139 // Update and draw internal render batch |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3140 void rlDrawRenderBatchActive(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3141 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3142 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3143 rlDrawRenderBatch(RLGL.currentBatch); // NOTE: Stereo rendering is checked inside |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3144 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3145 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3146 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3147 // Check internal buffer overflow for a given number of vertex |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3148 // and force a rlRenderBatch draw call if required |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3149 bool rlCheckRenderBatchLimit(int vCount) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3150 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3151 bool overflow = false; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3152 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3153 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3154 if ((RLGL.State.vertexCounter + vCount) >= |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3155 (RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].elementCount*4)) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3156 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3157 overflow = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3158 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3159 // Store current primitive drawing mode and texture id |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3160 int currentMode = RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3161 int currentTexture = RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3162 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3163 rlDrawRenderBatch(RLGL.currentBatch); // NOTE: Stereo rendering is checked inside |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3164 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3165 // Restore state of last batch so we can continue adding vertices |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3166 RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode = currentMode; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3167 RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId = currentTexture; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3168 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3169 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3170 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3171 return overflow; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3172 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3173 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3174 // Textures data management |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3175 //----------------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3176 // Convert image data to OpenGL texture (returns OpenGL valid Id) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3177 unsigned int rlLoadTexture(const void *data, int width, int height, int format, int mipmapCount) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3178 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3179 unsigned int id = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3180 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3181 glBindTexture(GL_TEXTURE_2D, 0); // Free any old binding |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3182 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3183 // Check texture format support by OpenGL 1.1 (compressed textures not supported) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3184 #if defined(GRAPHICS_API_OPENGL_11) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3185 if (format >= RL_PIXELFORMAT_COMPRESSED_DXT1_RGB) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3186 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3187 TRACELOG(RL_LOG_WARNING, "GL: OpenGL 1.1 does not support GPU compressed texture formats"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3188 return id; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3189 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3190 #else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3191 if ((!RLGL.ExtSupported.texCompDXT) && ((format == RL_PIXELFORMAT_COMPRESSED_DXT1_RGB) || (format == RL_PIXELFORMAT_COMPRESSED_DXT1_RGBA) || |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3192 (format == RL_PIXELFORMAT_COMPRESSED_DXT3_RGBA) || (format == RL_PIXELFORMAT_COMPRESSED_DXT5_RGBA))) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3193 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3194 TRACELOG(RL_LOG_WARNING, "GL: DXT compressed texture format not supported"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3195 return id; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3196 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3197 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3198 if ((!RLGL.ExtSupported.texCompETC1) && (format == RL_PIXELFORMAT_COMPRESSED_ETC1_RGB)) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3199 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3200 TRACELOG(RL_LOG_WARNING, "GL: ETC1 compressed texture format not supported"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3201 return id; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3202 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3203 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3204 if ((!RLGL.ExtSupported.texCompETC2) && ((format == RL_PIXELFORMAT_COMPRESSED_ETC2_RGB) || (format == RL_PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA))) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3205 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3206 TRACELOG(RL_LOG_WARNING, "GL: ETC2 compressed texture format not supported"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3207 return id; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3208 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3209 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3210 if ((!RLGL.ExtSupported.texCompPVRT) && ((format == RL_PIXELFORMAT_COMPRESSED_PVRT_RGB) || (format == RL_PIXELFORMAT_COMPRESSED_PVRT_RGBA))) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3211 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3212 TRACELOG(RL_LOG_WARNING, "GL: PVRT compressed texture format not supported"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3213 return id; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3214 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3215 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3216 if ((!RLGL.ExtSupported.texCompASTC) && ((format == RL_PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA) || (format == RL_PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA))) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3217 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3218 TRACELOG(RL_LOG_WARNING, "GL: ASTC compressed texture format not supported"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3219 return id; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3220 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3221 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3222 #endif // GRAPHICS_API_OPENGL_11 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3223 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3224 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3225 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3226 glGenTextures(1, &id); // Generate texture id |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3227 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3228 glBindTexture(GL_TEXTURE_2D, id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3229 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3230 int mipWidth = width; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3231 int mipHeight = height; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3232 int mipOffset = 0; // Mipmap data offset, only used for tracelog |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3233 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3234 // NOTE: Added pointer math separately from function to avoid UBSAN complaining |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3235 unsigned char *dataPtr = NULL; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3236 if (data != NULL) dataPtr = (unsigned char *)data; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3237 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3238 // Load the different mipmap levels |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3239 for (int i = 0; i < mipmapCount; i++) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3240 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3241 unsigned int mipSize = rlGetPixelDataSize(mipWidth, mipHeight, format); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3242 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3243 unsigned int glInternalFormat, glFormat, glType; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3244 rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3245 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3246 TRACELOGD("TEXTURE: Load mipmap level %i (%i x %i), size: %i, offset: %i", i, mipWidth, mipHeight, mipSize, mipOffset); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3247 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3248 if (glInternalFormat != 0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3249 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3250 if (format < RL_PIXELFORMAT_COMPRESSED_DXT1_RGB) glTexImage2D(GL_TEXTURE_2D, i, glInternalFormat, mipWidth, mipHeight, 0, glFormat, glType, dataPtr); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3251 #if !defined(GRAPHICS_API_OPENGL_11) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3252 else glCompressedTexImage2D(GL_TEXTURE_2D, i, glInternalFormat, mipWidth, mipHeight, 0, mipSize, dataPtr); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3253 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3254 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3255 #if defined(GRAPHICS_API_OPENGL_33) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3256 if (format == RL_PIXELFORMAT_UNCOMPRESSED_GRAYSCALE) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3257 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3258 GLint swizzleMask[] = { GL_RED, GL_RED, GL_RED, GL_ONE }; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3259 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3260 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3261 else if (format == RL_PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3262 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3263 #if defined(GRAPHICS_API_OPENGL_21) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3264 GLint swizzleMask[] = { GL_RED, GL_RED, GL_RED, GL_ALPHA }; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3265 #elif defined(GRAPHICS_API_OPENGL_33) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3266 GLint swizzleMask[] = { GL_RED, GL_RED, GL_RED, GL_GREEN }; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3267 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3268 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3269 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3270 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3271 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3272 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3273 mipWidth /= 2; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3274 mipHeight /= 2; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3275 mipOffset += mipSize; // Increment offset position to next mipmap |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3276 if (data != NULL) dataPtr += mipSize; // Increment data pointer to next mipmap |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3277 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3278 // Security check for NPOT textures |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3279 if (mipWidth < 1) mipWidth = 1; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3280 if (mipHeight < 1) mipHeight = 1; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3281 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3282 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3283 // Texture parameters configuration |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3284 // NOTE: glTexParameteri does NOT affect texture uploading, just the way it's used |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3285 #if defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3286 // NOTE: OpenGL ES 2.0 with no GL_OES_texture_npot support (i.e. WebGL) has limited NPOT support, so CLAMP_TO_EDGE must be used |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3287 if (RLGL.ExtSupported.texNPOT) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3288 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3289 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); // Set texture to repeat on x-axis |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3290 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); // Set texture to repeat on y-axis |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3291 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3292 else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3293 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3294 // NOTE: If using negative texture coordinates (LoadOBJ()), it does not work! |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3295 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); // Set texture to clamp on x-axis |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3296 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // Set texture to clamp on y-axis |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3297 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3298 #else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3299 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); // Set texture to repeat on x-axis |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3300 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); // Set texture to repeat on y-axis |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3301 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3302 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3303 // Magnification and minification filters |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3304 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // Alternative: GL_LINEAR |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3305 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); // Alternative: GL_LINEAR |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3306 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3307 #if defined(GRAPHICS_API_OPENGL_33) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3308 if (mipmapCount > 1) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3309 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3310 // Activate Trilinear filtering if mipmaps are available |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3311 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3312 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3313 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3314 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3315 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3316 // At this point we have the texture loaded in GPU and texture parameters configured |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3317 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3318 // NOTE: If mipmaps were not in data, they are not generated automatically |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3319 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3320 // Unbind current texture |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3321 glBindTexture(GL_TEXTURE_2D, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3322 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3323 if (id > 0) TRACELOG(RL_LOG_INFO, "TEXTURE: [ID %i] Texture loaded successfully (%ix%i | %s | %i mipmaps)", id, width, height, rlGetPixelFormatName(format), mipmapCount); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3324 else TRACELOG(RL_LOG_WARNING, "TEXTURE: Failed to load texture"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3325 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3326 return id; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3327 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3328 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3329 // Load depth texture/renderbuffer (to be attached to fbo) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3330 // WARNING: OpenGL ES 2.0 requires GL_OES_depth_texture and WebGL requires WEBGL_depth_texture extensions |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3331 unsigned int rlLoadTextureDepth(int width, int height, bool useRenderBuffer) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3332 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3333 unsigned int id = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3334 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3335 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3336 // In case depth textures not supported, we force renderbuffer usage |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3337 if (!RLGL.ExtSupported.texDepth) useRenderBuffer = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3338 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3339 // NOTE: We let the implementation to choose the best bit-depth |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3340 // Possible formats: GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT32 and GL_DEPTH_COMPONENT32F |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3341 unsigned int glInternalFormat = GL_DEPTH_COMPONENT; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3342 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3343 #if (defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_ES3)) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3344 // WARNING: WebGL platform requires unsized internal format definition (GL_DEPTH_COMPONENT) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3345 // while other platforms using OpenGL ES 2.0 require/support sized internal formats depending on the GPU capabilities |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3346 if (!RLGL.ExtSupported.texDepthWebGL || useRenderBuffer) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3347 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3348 if (RLGL.ExtSupported.maxDepthBits == 32) glInternalFormat = GL_DEPTH_COMPONENT32_OES; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3349 else if (RLGL.ExtSupported.maxDepthBits == 24) glInternalFormat = GL_DEPTH_COMPONENT24_OES; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3350 else glInternalFormat = GL_DEPTH_COMPONENT16; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3351 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3352 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3353 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3354 if (!useRenderBuffer && RLGL.ExtSupported.texDepth) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3355 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3356 glGenTextures(1, &id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3357 glBindTexture(GL_TEXTURE_2D, id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3358 glTexImage2D(GL_TEXTURE_2D, 0, glInternalFormat, width, height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3359 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3360 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3361 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3362 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3363 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3364 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3365 glBindTexture(GL_TEXTURE_2D, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3366 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3367 TRACELOG(RL_LOG_INFO, "TEXTURE: Depth texture loaded successfully"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3368 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3369 else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3370 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3371 // Create the renderbuffer that will serve as the depth attachment for the framebuffer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3372 // NOTE: A renderbuffer is simpler than a texture and could offer better performance on embedded devices |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3373 glGenRenderbuffers(1, &id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3374 glBindRenderbuffer(GL_RENDERBUFFER, id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3375 glRenderbufferStorage(GL_RENDERBUFFER, glInternalFormat, width, height); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3376 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3377 glBindRenderbuffer(GL_RENDERBUFFER, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3378 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3379 TRACELOG(RL_LOG_INFO, "TEXTURE: [ID %i] Depth renderbuffer loaded successfully (%i bits)", id, (RLGL.ExtSupported.maxDepthBits >= 24)? RLGL.ExtSupported.maxDepthBits : 16); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3380 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3381 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3382 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3383 return id; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3384 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3385 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3386 // Load texture cubemap |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3387 // NOTE: Cubemap data is expected to be 6 images in a single data array (one after the other), |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3388 // expected the following convention: +X, -X, +Y, -Y, +Z, -Z |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3389 unsigned int rlLoadTextureCubemap(const void *data, int size, int format, int mipmapCount) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3390 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3391 unsigned int id = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3392 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3393 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3394 int mipSize = size; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3395 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3396 // NOTE: Added pointer math separately from function to avoid UBSAN complaining |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3397 unsigned char *dataPtr = NULL; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3398 if (data != NULL) dataPtr = (unsigned char *)data; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3399 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3400 unsigned int dataSize = rlGetPixelDataSize(size, size, format); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3401 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3402 glGenTextures(1, &id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3403 glBindTexture(GL_TEXTURE_CUBE_MAP, id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3404 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3405 unsigned int glInternalFormat, glFormat, glType; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3406 rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3407 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3408 if (glInternalFormat != 0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3409 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3410 // Load cubemap faces/mipmaps |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3411 for (int i = 0; i < 6*mipmapCount; i++) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3412 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3413 int mipmapLevel = i/6; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3414 int face = i%6; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3415 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3416 if (data == NULL) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3417 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3418 if (format < RL_PIXELFORMAT_COMPRESSED_DXT1_RGB) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3419 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3420 if ((format == RL_PIXELFORMAT_UNCOMPRESSED_R32) || |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3421 (format == RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32A32) || |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3422 (format == RL_PIXELFORMAT_UNCOMPRESSED_R16) || |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3423 (format == RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16)) TRACELOG(RL_LOG_WARNING, "TEXTURES: Cubemap requested format not supported"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3424 else glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, mipmapLevel, glInternalFormat, mipSize, mipSize, 0, glFormat, glType, NULL); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3425 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3426 else TRACELOG(RL_LOG_WARNING, "TEXTURES: Empty cubemap creation does not support compressed format"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3427 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3428 else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3429 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3430 if (format < RL_PIXELFORMAT_COMPRESSED_DXT1_RGB) glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, mipmapLevel, glInternalFormat, mipSize, mipSize, 0, glFormat, glType, (unsigned char *)dataPtr + face*dataSize); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3431 else glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, mipmapLevel, glInternalFormat, mipSize, mipSize, 0, dataSize, (unsigned char *)dataPtr + face*dataSize); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3432 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3433 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3434 #if defined(GRAPHICS_API_OPENGL_33) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3435 if (format == RL_PIXELFORMAT_UNCOMPRESSED_GRAYSCALE) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3436 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3437 GLint swizzleMask[] = { GL_RED, GL_RED, GL_RED, GL_ONE }; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3438 glTexParameteriv(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3439 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3440 else if (format == RL_PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3441 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3442 #if defined(GRAPHICS_API_OPENGL_21) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3443 GLint swizzleMask[] = { GL_RED, GL_RED, GL_RED, GL_ALPHA }; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3444 #elif defined(GRAPHICS_API_OPENGL_33) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3445 GLint swizzleMask[] = { GL_RED, GL_RED, GL_RED, GL_GREEN }; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3446 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3447 glTexParameteriv(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3448 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3449 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3450 if (face == 5) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3451 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3452 mipSize /= 2; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3453 if (data != NULL) dataPtr += dataSize*6; // Increment data pointer to next mipmap |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3454 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3455 // Security check for NPOT textures |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3456 if (mipSize < 1) mipSize = 1; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3457 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3458 dataSize = rlGetPixelDataSize(mipSize, mipSize, format); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3459 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3460 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3461 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3462 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3463 // Set cubemap texture sampling parameters |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3464 if (mipmapCount > 1) glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3465 else glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3466 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3467 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3468 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3469 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3470 #if defined(GRAPHICS_API_OPENGL_33) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3471 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); // Flag not supported on OpenGL ES 2.0 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3472 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3473 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3474 glBindTexture(GL_TEXTURE_CUBE_MAP, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3475 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3476 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3477 if (id > 0) TRACELOG(RL_LOG_INFO, "TEXTURE: [ID %i] Cubemap texture loaded successfully (%ix%i)", id, size, size); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3478 else TRACELOG(RL_LOG_WARNING, "TEXTURE: Failed to load cubemap texture"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3479 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3480 return id; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3481 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3482 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3483 // Update already loaded texture in GPU with new data |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3484 // NOTE: We don't know safely if internal texture format is the expected one... |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3485 void rlUpdateTexture(unsigned int id, int offsetX, int offsetY, int width, int height, int format, const void *data) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3486 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3487 glBindTexture(GL_TEXTURE_2D, id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3488 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3489 unsigned int glInternalFormat, glFormat, glType; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3490 rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3491 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3492 if ((glInternalFormat != 0) && (format < RL_PIXELFORMAT_COMPRESSED_DXT1_RGB)) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3493 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3494 glTexSubImage2D(GL_TEXTURE_2D, 0, offsetX, offsetY, width, height, glFormat, glType, data); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3495 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3496 else TRACELOG(RL_LOG_WARNING, "TEXTURE: [ID %i] Failed to update for current texture format (%i)", id, format); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3497 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3498 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3499 // Get OpenGL internal formats and data type from raylib PixelFormat |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3500 void rlGetGlTextureFormats(int format, unsigned int *glInternalFormat, unsigned int *glFormat, unsigned int *glType) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3501 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3502 *glInternalFormat = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3503 *glFormat = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3504 *glType = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3505 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3506 switch (format) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3507 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3508 #if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_21) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3509 // NOTE: on OpenGL ES 2.0 (WebGL), internalFormat must match format and options allowed are: GL_LUMINANCE, GL_RGB, GL_RGBA |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3510 case RL_PIXELFORMAT_UNCOMPRESSED_GRAYSCALE: *glInternalFormat = GL_LUMINANCE; *glFormat = GL_LUMINANCE; *glType = GL_UNSIGNED_BYTE; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3511 case RL_PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA: *glInternalFormat = GL_LUMINANCE_ALPHA; *glFormat = GL_LUMINANCE_ALPHA; *glType = GL_UNSIGNED_BYTE; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3512 case RL_PIXELFORMAT_UNCOMPRESSED_R5G6B5: *glInternalFormat = GL_RGB; *glFormat = GL_RGB; *glType = GL_UNSIGNED_SHORT_5_6_5; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3513 case RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8: *glInternalFormat = GL_RGB; *glFormat = GL_RGB; *glType = GL_UNSIGNED_BYTE; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3514 case RL_PIXELFORMAT_UNCOMPRESSED_R5G5B5A1: *glInternalFormat = GL_RGBA; *glFormat = GL_RGBA; *glType = GL_UNSIGNED_SHORT_5_5_5_1; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3515 case RL_PIXELFORMAT_UNCOMPRESSED_R4G4B4A4: *glInternalFormat = GL_RGBA; *glFormat = GL_RGBA; *glType = GL_UNSIGNED_SHORT_4_4_4_4; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3516 case RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8: *glInternalFormat = GL_RGBA; *glFormat = GL_RGBA; *glType = GL_UNSIGNED_BYTE; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3517 #if !defined(GRAPHICS_API_OPENGL_11) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3518 #if defined(GRAPHICS_API_OPENGL_ES3) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3519 case RL_PIXELFORMAT_UNCOMPRESSED_R32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_R32F_EXT; *glFormat = GL_RED_EXT; *glType = GL_FLOAT; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3520 case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_RGB32F_EXT; *glFormat = GL_RGB; *glType = GL_FLOAT; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3521 case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32A32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_RGBA32F_EXT; *glFormat = GL_RGBA; *glType = GL_FLOAT; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3522 case RL_PIXELFORMAT_UNCOMPRESSED_R16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_R16F_EXT; *glFormat = GL_RED_EXT; *glType = GL_HALF_FLOAT; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3523 case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_RGB16F_EXT; *glFormat = GL_RGB; *glType = GL_HALF_FLOAT; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3524 case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_RGBA16F_EXT; *glFormat = GL_RGBA; *glType = GL_HALF_FLOAT; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3525 #else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3526 case RL_PIXELFORMAT_UNCOMPRESSED_R32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_LUMINANCE; *glFormat = GL_LUMINANCE; *glType = GL_FLOAT; break; // NOTE: Requires extension OES_texture_float |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3527 case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_RGB; *glFormat = GL_RGB; *glType = GL_FLOAT; break; // NOTE: Requires extension OES_texture_float |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3528 case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32A32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_RGBA; *glFormat = GL_RGBA; *glType = GL_FLOAT; break; // NOTE: Requires extension OES_texture_float |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3529 #if defined(GRAPHICS_API_OPENGL_21) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3530 case RL_PIXELFORMAT_UNCOMPRESSED_R16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_LUMINANCE; *glFormat = GL_LUMINANCE; *glType = GL_HALF_FLOAT_ARB; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3531 case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_RGB; *glFormat = GL_RGB; *glType = GL_HALF_FLOAT_ARB; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3532 case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_RGBA; *glFormat = GL_RGBA; *glType = GL_HALF_FLOAT_ARB; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3533 #else // defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3534 case RL_PIXELFORMAT_UNCOMPRESSED_R16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_LUMINANCE; *glFormat = GL_LUMINANCE; *glType = GL_HALF_FLOAT_OES; break; // NOTE: Requires extension OES_texture_half_float |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3535 case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_RGB; *glFormat = GL_RGB; *glType = GL_HALF_FLOAT_OES; break; // NOTE: Requires extension OES_texture_half_float |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3536 case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_RGBA; *glFormat = GL_RGBA; *glType = GL_HALF_FLOAT_OES; break; // NOTE: Requires extension OES_texture_half_float |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3537 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3538 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3539 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3540 #elif defined(GRAPHICS_API_OPENGL_33) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3541 case RL_PIXELFORMAT_UNCOMPRESSED_GRAYSCALE: *glInternalFormat = GL_R8; *glFormat = GL_RED; *glType = GL_UNSIGNED_BYTE; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3542 case RL_PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA: *glInternalFormat = GL_RG8; *glFormat = GL_RG; *glType = GL_UNSIGNED_BYTE; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3543 case RL_PIXELFORMAT_UNCOMPRESSED_R5G6B5: *glInternalFormat = GL_RGB565; *glFormat = GL_RGB; *glType = GL_UNSIGNED_SHORT_5_6_5; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3544 case RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8: *glInternalFormat = GL_RGB8; *glFormat = GL_RGB; *glType = GL_UNSIGNED_BYTE; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3545 case RL_PIXELFORMAT_UNCOMPRESSED_R5G5B5A1: *glInternalFormat = GL_RGB5_A1; *glFormat = GL_RGBA; *glType = GL_UNSIGNED_SHORT_5_5_5_1; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3546 case RL_PIXELFORMAT_UNCOMPRESSED_R4G4B4A4: *glInternalFormat = GL_RGBA4; *glFormat = GL_RGBA; *glType = GL_UNSIGNED_SHORT_4_4_4_4; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3547 case RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8: *glInternalFormat = GL_RGBA8; *glFormat = GL_RGBA; *glType = GL_UNSIGNED_BYTE; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3548 case RL_PIXELFORMAT_UNCOMPRESSED_R32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_R32F; *glFormat = GL_RED; *glType = GL_FLOAT; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3549 case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_RGB32F; *glFormat = GL_RGB; *glType = GL_FLOAT; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3550 case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32A32: if (RLGL.ExtSupported.texFloat32) *glInternalFormat = GL_RGBA32F; *glFormat = GL_RGBA; *glType = GL_FLOAT; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3551 case RL_PIXELFORMAT_UNCOMPRESSED_R16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_R16F; *glFormat = GL_RED; *glType = GL_HALF_FLOAT; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3552 case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_RGB16F; *glFormat = GL_RGB; *glType = GL_HALF_FLOAT; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3553 case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16: if (RLGL.ExtSupported.texFloat16) *glInternalFormat = GL_RGBA16F; *glFormat = GL_RGBA; *glType = GL_HALF_FLOAT; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3554 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3555 #if !defined(GRAPHICS_API_OPENGL_11) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3556 case RL_PIXELFORMAT_COMPRESSED_DXT1_RGB: if (RLGL.ExtSupported.texCompDXT) *glInternalFormat = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3557 case RL_PIXELFORMAT_COMPRESSED_DXT1_RGBA: if (RLGL.ExtSupported.texCompDXT) *glInternalFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3558 case RL_PIXELFORMAT_COMPRESSED_DXT3_RGBA: if (RLGL.ExtSupported.texCompDXT) *glInternalFormat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3559 case RL_PIXELFORMAT_COMPRESSED_DXT5_RGBA: if (RLGL.ExtSupported.texCompDXT) *glInternalFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3560 case RL_PIXELFORMAT_COMPRESSED_ETC1_RGB: if (RLGL.ExtSupported.texCompETC1) *glInternalFormat = GL_ETC1_RGB8_OES; break; // NOTE: Requires OpenGL ES 2.0 or OpenGL 4.3 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3561 case RL_PIXELFORMAT_COMPRESSED_ETC2_RGB: if (RLGL.ExtSupported.texCompETC2) *glInternalFormat = GL_COMPRESSED_RGB8_ETC2; break; // NOTE: Requires OpenGL ES 3.0 or OpenGL 4.3 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3562 case RL_PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA: if (RLGL.ExtSupported.texCompETC2) *glInternalFormat = GL_COMPRESSED_RGBA8_ETC2_EAC; break; // NOTE: Requires OpenGL ES 3.0 or OpenGL 4.3 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3563 case RL_PIXELFORMAT_COMPRESSED_PVRT_RGB: if (RLGL.ExtSupported.texCompPVRT) *glInternalFormat = GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG; break; // NOTE: Requires PowerVR GPU |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3564 case RL_PIXELFORMAT_COMPRESSED_PVRT_RGBA: if (RLGL.ExtSupported.texCompPVRT) *glInternalFormat = GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; break; // NOTE: Requires PowerVR GPU |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3565 case RL_PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA: if (RLGL.ExtSupported.texCompASTC) *glInternalFormat = GL_COMPRESSED_RGBA_ASTC_4x4_KHR; break; // NOTE: Requires OpenGL ES 3.1 or OpenGL 4.3 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3566 case RL_PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA: if (RLGL.ExtSupported.texCompASTC) *glInternalFormat = GL_COMPRESSED_RGBA_ASTC_8x8_KHR; break; // NOTE: Requires OpenGL ES 3.1 or OpenGL 4.3 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3567 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3568 default: TRACELOG(RL_LOG_WARNING, "TEXTURE: Current format not supported (%i)", format); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3569 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3570 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3571 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3572 // Unload texture from GPU memory |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3573 void rlUnloadTexture(unsigned int id) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3574 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3575 glDeleteTextures(1, &id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3576 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3577 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3578 // Generate mipmap data for selected texture |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3579 // NOTE: Only supports GPU mipmap generation |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3580 void rlGenTextureMipmaps(unsigned int id, int width, int height, int format, int *mipmaps) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3581 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3582 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3583 glBindTexture(GL_TEXTURE_2D, id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3584 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3585 // Check if texture is power-of-two (POT) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3586 bool texIsPOT = false; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3587 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3588 if (((width > 0) && ((width & (width - 1)) == 0)) && |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3589 ((height > 0) && ((height & (height - 1)) == 0))) texIsPOT = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3590 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3591 if ((texIsPOT) || (RLGL.ExtSupported.texNPOT)) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3592 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3593 //glHint(GL_GENERATE_MIPMAP_HINT, GL_DONT_CARE); // Hint for mipmaps generation algorithm: GL_FASTEST, GL_NICEST, GL_DONT_CARE |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3594 glGenerateMipmap(GL_TEXTURE_2D); // Generate mipmaps automatically |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3595 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3596 #define MIN(a,b) (((a)<(b))? (a):(b)) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3597 #define MAX(a,b) (((a)>(b))? (a):(b)) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3598 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3599 *mipmaps = 1 + (int)floor(log(MAX(width, height))/log(2)); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3600 TRACELOG(RL_LOG_INFO, "TEXTURE: [ID %i] Mipmaps generated automatically, total: %i", id, *mipmaps); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3601 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3602 else TRACELOG(RL_LOG_WARNING, "TEXTURE: [ID %i] Failed to generate mipmaps", id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3603 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3604 glBindTexture(GL_TEXTURE_2D, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3605 #else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3606 TRACELOG(RL_LOG_WARNING, "TEXTURE: [ID %i] GPU mipmap generation not supported", id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3607 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3608 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3609 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3610 // Read texture pixel data |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3611 void *rlReadTexturePixels(unsigned int id, int width, int height, int format) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3612 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3613 void *pixels = NULL; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3614 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3615 #if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_33) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3616 glBindTexture(GL_TEXTURE_2D, id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3617 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3618 // NOTE: Using texture id, we can retrieve some texture info (but not on OpenGL ES 2.0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3619 // Possible texture info: GL_TEXTURE_RED_SIZE, GL_TEXTURE_GREEN_SIZE, GL_TEXTURE_BLUE_SIZE, GL_TEXTURE_ALPHA_SIZE |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3620 //int width, height, format; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3621 //glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3622 //glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3623 //glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &format); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3624 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3625 // NOTE: Each row written to or read from by OpenGL pixel operations like glGetTexImage are aligned to a 4 byte boundary by default, which may add some padding |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3626 // Use glPixelStorei to modify padding with the GL_[UN]PACK_ALIGNMENT setting |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3627 // GL_PACK_ALIGNMENT affects operations that read from OpenGL memory (glReadPixels, glGetTexImage, etc.) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3628 // GL_UNPACK_ALIGNMENT affects operations that write to OpenGL memory (glTexImage, etc.) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3629 glPixelStorei(GL_PACK_ALIGNMENT, 1); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3630 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3631 unsigned int glInternalFormat, glFormat, glType; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3632 rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3633 unsigned int size = rlGetPixelDataSize(width, height, format); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3634 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3635 if ((glInternalFormat != 0) && (format < RL_PIXELFORMAT_COMPRESSED_DXT1_RGB)) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3636 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3637 pixels = RL_MALLOC(size); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3638 glGetTexImage(GL_TEXTURE_2D, 0, glFormat, glType, pixels); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3639 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3640 else TRACELOG(RL_LOG_WARNING, "TEXTURE: [ID %i] Data retrieval not suported for pixel format (%i)", id, format); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3641 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3642 glBindTexture(GL_TEXTURE_2D, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3643 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3644 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3645 #if defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3646 // glGetTexImage() is not available on OpenGL ES 2.0 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3647 // Texture width and height are required on OpenGL ES 2.0, there is no way to get it from texture id |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3648 // Two possible Options: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3649 // 1 - Bind texture to color fbo attachment and glReadPixels() |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3650 // 2 - Create an fbo, activate it, render quad with texture, glReadPixels() |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3651 // We are using Option 1, just need to care for texture format on retrieval |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3652 // NOTE: This behaviour could be conditioned by graphic driver... |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3653 unsigned int fboId = rlLoadFramebuffer(); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3654 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3655 glBindFramebuffer(GL_FRAMEBUFFER, fboId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3656 glBindTexture(GL_TEXTURE_2D, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3657 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3658 // Attach our texture to FBO |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3659 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, id, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3660 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3661 // We read data as RGBA because FBO texture is configured as RGBA, despite binding another texture format |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3662 pixels = (unsigned char *)RL_MALLOC(rlGetPixelDataSize(width, height, RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8)); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3663 glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3664 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3665 glBindFramebuffer(GL_FRAMEBUFFER, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3666 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3667 // Clean up temporal fbo |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3668 rlUnloadFramebuffer(fboId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3669 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3670 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3671 return pixels; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3672 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3673 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3674 // Read screen pixel data (color buffer) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3675 unsigned char *rlReadScreenPixels(int width, int height) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3676 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3677 unsigned char *screenData = (unsigned char *)RL_CALLOC(width*height*4, sizeof(unsigned char)); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3678 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3679 // NOTE 1: glReadPixels returns image flipped vertically -> (0,0) is the bottom left corner of the framebuffer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3680 // NOTE 2: We are getting alpha channel! Be careful, it can be transparent if not cleared properly! |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3681 glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, screenData); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3682 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3683 // Flip image vertically! |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3684 unsigned char *imgData = (unsigned char *)RL_MALLOC(width*height*4*sizeof(unsigned char)); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3685 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3686 for (int y = height - 1; y >= 0; y--) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3687 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3688 for (int x = 0; x < (width*4); x++) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3689 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3690 imgData[((height - 1) - y)*width*4 + x] = screenData[(y*width*4) + x]; // Flip line |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3691 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3692 // Set alpha component value to 255 (no trasparent image retrieval) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3693 // NOTE: Alpha value has already been applied to RGB in framebuffer, we don't need it! |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3694 if (((x + 1)%4) == 0) imgData[((height - 1) - y)*width*4 + x] = 255; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3695 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3696 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3697 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3698 RL_FREE(screenData); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3699 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3700 return imgData; // NOTE: image data should be freed |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3701 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3702 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3703 // Framebuffer management (fbo) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3704 //----------------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3705 // Load a framebuffer to be used for rendering |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3706 // NOTE: No textures attached |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3707 unsigned int rlLoadFramebuffer(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3708 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3709 unsigned int fboId = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3710 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3711 #if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(RLGL_RENDER_TEXTURES_HINT) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3712 glGenFramebuffers(1, &fboId); // Create the framebuffer object |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3713 glBindFramebuffer(GL_FRAMEBUFFER, 0); // Unbind any framebuffer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3714 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3715 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3716 return fboId; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3717 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3718 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3719 // Attach color buffer texture to an fbo (unloads previous attachment) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3720 // NOTE: Attach type: 0-Color, 1-Depth renderbuffer, 2-Depth texture |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3721 void rlFramebufferAttach(unsigned int fboId, unsigned int texId, int attachType, int texType, int mipLevel) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3722 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3723 #if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(RLGL_RENDER_TEXTURES_HINT) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3724 glBindFramebuffer(GL_FRAMEBUFFER, fboId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3725 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3726 switch (attachType) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3727 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3728 case RL_ATTACHMENT_COLOR_CHANNEL0: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3729 case RL_ATTACHMENT_COLOR_CHANNEL1: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3730 case RL_ATTACHMENT_COLOR_CHANNEL2: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3731 case RL_ATTACHMENT_COLOR_CHANNEL3: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3732 case RL_ATTACHMENT_COLOR_CHANNEL4: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3733 case RL_ATTACHMENT_COLOR_CHANNEL5: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3734 case RL_ATTACHMENT_COLOR_CHANNEL6: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3735 case RL_ATTACHMENT_COLOR_CHANNEL7: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3736 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3737 if (texType == RL_ATTACHMENT_TEXTURE2D) glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + attachType, GL_TEXTURE_2D, texId, mipLevel); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3738 else if (texType == RL_ATTACHMENT_RENDERBUFFER) glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + attachType, GL_RENDERBUFFER, texId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3739 else if (texType >= RL_ATTACHMENT_CUBEMAP_POSITIVE_X) glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + attachType, GL_TEXTURE_CUBE_MAP_POSITIVE_X + texType, texId, mipLevel); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3740 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3741 } break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3742 case RL_ATTACHMENT_DEPTH: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3743 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3744 if (texType == RL_ATTACHMENT_TEXTURE2D) glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, texId, mipLevel); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3745 else if (texType == RL_ATTACHMENT_RENDERBUFFER) glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, texId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3746 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3747 } break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3748 case RL_ATTACHMENT_STENCIL: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3749 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3750 if (texType == RL_ATTACHMENT_TEXTURE2D) glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, texId, mipLevel); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3751 else if (texType == RL_ATTACHMENT_RENDERBUFFER) glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, texId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3752 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3753 } break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3754 default: break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3755 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3756 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3757 glBindFramebuffer(GL_FRAMEBUFFER, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3758 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3759 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3760 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3761 // Verify render texture is complete |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3762 bool rlFramebufferComplete(unsigned int id) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3763 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3764 bool result = false; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3765 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3766 #if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(RLGL_RENDER_TEXTURES_HINT) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3767 glBindFramebuffer(GL_FRAMEBUFFER, id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3768 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3769 GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3770 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3771 if (status != GL_FRAMEBUFFER_COMPLETE) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3772 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3773 switch (status) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3774 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3775 case GL_FRAMEBUFFER_UNSUPPORTED: TRACELOG(RL_LOG_WARNING, "FBO: [ID %i] Framebuffer is unsupported", id); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3776 case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: TRACELOG(RL_LOG_WARNING, "FBO: [ID %i] Framebuffer has incomplete attachment", id); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3777 #if defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3778 case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS: TRACELOG(RL_LOG_WARNING, "FBO: [ID %i] Framebuffer has incomplete dimensions", id); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3779 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3780 case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: TRACELOG(RL_LOG_WARNING, "FBO: [ID %i] Framebuffer has a missing attachment", id); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3781 default: break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3782 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3783 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3784 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3785 glBindFramebuffer(GL_FRAMEBUFFER, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3786 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3787 result = (status == GL_FRAMEBUFFER_COMPLETE); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3788 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3789 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3790 return result; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3791 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3792 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3793 // Unload framebuffer from GPU memory |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3794 // NOTE: All attached textures/cubemaps/renderbuffers are also deleted |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3795 void rlUnloadFramebuffer(unsigned int id) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3796 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3797 #if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(RLGL_RENDER_TEXTURES_HINT) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3798 // Query depth attachment to automatically delete texture/renderbuffer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3799 int depthType = 0, depthId = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3800 glBindFramebuffer(GL_FRAMEBUFFER, id); // Bind framebuffer to query depth texture type |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3801 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &depthType); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3802 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3803 // TODO: Review warning retrieving object name in WebGL |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3804 // WARNING: WebGL: INVALID_ENUM: getFramebufferAttachmentParameter: invalid parameter name |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3805 // https://registry.khronos.org/webgl/specs/latest/1.0/ |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3806 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &depthId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3807 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3808 unsigned int depthIdU = (unsigned int)depthId; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3809 if (depthType == GL_RENDERBUFFER) glDeleteRenderbuffers(1, &depthIdU); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3810 else if (depthType == GL_TEXTURE) glDeleteTextures(1, &depthIdU); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3811 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3812 // NOTE: If a texture object is deleted while its image is attached to the *currently bound* framebuffer, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3813 // the texture image is automatically detached from the currently bound framebuffer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3814 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3815 glBindFramebuffer(GL_FRAMEBUFFER, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3816 glDeleteFramebuffers(1, &id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3817 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3818 TRACELOG(RL_LOG_INFO, "FBO: [ID %i] Unloaded framebuffer from VRAM (GPU)", id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3819 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3820 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3821 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3822 // Vertex data management |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3823 //----------------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3824 // Load a new attributes buffer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3825 unsigned int rlLoadVertexBuffer(const void *buffer, int size, bool dynamic) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3826 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3827 unsigned int id = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3828 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3829 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3830 glGenBuffers(1, &id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3831 glBindBuffer(GL_ARRAY_BUFFER, id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3832 glBufferData(GL_ARRAY_BUFFER, size, buffer, dynamic? GL_DYNAMIC_DRAW : GL_STATIC_DRAW); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3833 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3834 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3835 return id; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3836 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3837 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3838 // Load a new attributes element buffer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3839 unsigned int rlLoadVertexBufferElement(const void *buffer, int size, bool dynamic) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3840 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3841 unsigned int id = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3842 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3843 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3844 glGenBuffers(1, &id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3845 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3846 glBufferData(GL_ELEMENT_ARRAY_BUFFER, size, buffer, dynamic? GL_DYNAMIC_DRAW : GL_STATIC_DRAW); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3847 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3848 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3849 return id; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3850 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3851 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3852 // Enable vertex buffer (VBO) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3853 void rlEnableVertexBuffer(unsigned int id) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3854 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3855 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3856 glBindBuffer(GL_ARRAY_BUFFER, id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3857 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3858 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3859 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3860 // Disable vertex buffer (VBO) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3861 void rlDisableVertexBuffer(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3862 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3863 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3864 glBindBuffer(GL_ARRAY_BUFFER, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3865 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3866 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3867 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3868 // Enable vertex buffer element (VBO element) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3869 void rlEnableVertexBufferElement(unsigned int id) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3870 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3871 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3872 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3873 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3874 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3875 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3876 // Disable vertex buffer element (VBO element) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3877 void rlDisableVertexBufferElement(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3878 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3879 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3880 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3881 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3882 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3883 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3884 // Update vertex buffer with new data |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3885 // NOTE: dataSize and offset must be provided in bytes |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3886 void rlUpdateVertexBuffer(unsigned int id, const void *data, int dataSize, int offset) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3887 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3888 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3889 glBindBuffer(GL_ARRAY_BUFFER, id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3890 glBufferSubData(GL_ARRAY_BUFFER, offset, dataSize, data); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3891 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3892 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3893 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3894 // Update vertex buffer elements with new data |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3895 // NOTE: dataSize and offset must be provided in bytes |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3896 void rlUpdateVertexBufferElements(unsigned int id, const void *data, int dataSize, int offset) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3897 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3898 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3899 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3900 glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, offset, dataSize, data); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3901 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3902 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3903 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3904 // Enable vertex array object (VAO) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3905 bool rlEnableVertexArray(unsigned int vaoId) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3906 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3907 bool result = false; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3908 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3909 if (RLGL.ExtSupported.vao) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3910 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3911 glBindVertexArray(vaoId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3912 result = true; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3913 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3914 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3915 return result; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3916 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3917 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3918 // Disable vertex array object (VAO) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3919 void rlDisableVertexArray(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3920 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3921 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3922 if (RLGL.ExtSupported.vao) glBindVertexArray(0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3923 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3924 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3925 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3926 // Enable vertex attribute index |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3927 void rlEnableVertexAttribute(unsigned int index) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3928 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3929 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3930 glEnableVertexAttribArray(index); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3931 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3932 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3933 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3934 // Disable vertex attribute index |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3935 void rlDisableVertexAttribute(unsigned int index) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3936 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3937 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3938 glDisableVertexAttribArray(index); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3939 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3940 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3941 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3942 // Draw vertex array |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3943 void rlDrawVertexArray(int offset, int count) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3944 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3945 glDrawArrays(GL_TRIANGLES, offset, count); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3946 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3947 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3948 // Draw vertex array elements |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3949 void rlDrawVertexArrayElements(int offset, int count, const void *buffer) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3950 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3951 // NOTE: Added pointer math separately from function to avoid UBSAN complaining |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3952 unsigned short *bufferPtr = (unsigned short *)buffer; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3953 if (offset > 0) bufferPtr += offset; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3954 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3955 glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_SHORT, (const unsigned short *)bufferPtr); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3956 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3957 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3958 // Draw vertex array instanced |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3959 void rlDrawVertexArrayInstanced(int offset, int count, int instances) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3960 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3961 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3962 glDrawArraysInstanced(GL_TRIANGLES, 0, count, instances); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3963 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3964 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3965 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3966 // Draw vertex array elements instanced |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3967 void rlDrawVertexArrayElementsInstanced(int offset, int count, const void *buffer, int instances) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3968 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3969 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3970 // NOTE: Added pointer math separately from function to avoid UBSAN complaining |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3971 unsigned short *bufferPtr = (unsigned short *)buffer; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3972 if (offset > 0) bufferPtr += offset; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3973 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3974 glDrawElementsInstanced(GL_TRIANGLES, count, GL_UNSIGNED_SHORT, (const unsigned short *)bufferPtr, instances); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3975 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3976 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3977 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3978 #if defined(GRAPHICS_API_OPENGL_11) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3979 // Enable vertex state pointer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3980 void rlEnableStatePointer(int vertexAttribType, void *buffer) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3981 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3982 if (buffer != NULL) glEnableClientState(vertexAttribType); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3983 switch (vertexAttribType) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3984 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3985 case GL_VERTEX_ARRAY: glVertexPointer(3, GL_FLOAT, 0, buffer); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3986 case GL_TEXTURE_COORD_ARRAY: glTexCoordPointer(2, GL_FLOAT, 0, buffer); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3987 case GL_NORMAL_ARRAY: if (buffer != NULL) glNormalPointer(GL_FLOAT, 0, buffer); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3988 case GL_COLOR_ARRAY: if (buffer != NULL) glColorPointer(4, GL_UNSIGNED_BYTE, 0, buffer); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3989 //case GL_INDEX_ARRAY: if (buffer != NULL) glIndexPointer(GL_SHORT, 0, buffer); break; // Indexed colors |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3990 default: break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3991 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3992 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3993 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3994 // Disable vertex state pointer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3995 void rlDisableStatePointer(int vertexAttribType) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3996 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3997 glDisableClientState(vertexAttribType); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3998 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3999 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4000 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4001 // Load vertex array object (VAO) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4002 unsigned int rlLoadVertexArray(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4003 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4004 unsigned int vaoId = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4005 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4006 if (RLGL.ExtSupported.vao) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4007 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4008 glGenVertexArrays(1, &vaoId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4009 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4010 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4011 return vaoId; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4012 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4013 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4014 // Set vertex attribute |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4015 void rlSetVertexAttribute(unsigned int index, int compSize, int type, bool normalized, int stride, int offset) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4016 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4017 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4018 // NOTE: Data type could be: GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT, GL_UNSIGNED_SHORT, GL_INT, GL_UNSIGNED_INT |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4019 // Additional types (depends on OpenGL version or extensions): |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4020 // - GL_HALF_FLOAT, GL_FLOAT, GL_DOUBLE, GL_FIXED, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4021 // - GL_INT_2_10_10_10_REV, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT_10F_11F_11F_REV |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4022 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4023 size_t offsetNative = offset; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4024 glVertexAttribPointer(index, compSize, type, normalized, stride, (void *)offsetNative); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4025 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4026 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4027 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4028 // Set vertex attribute divisor |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4029 void rlSetVertexAttributeDivisor(unsigned int index, int divisor) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4030 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4031 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4032 glVertexAttribDivisor(index, divisor); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4033 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4034 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4035 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4036 // Unload vertex array object (VAO) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4037 void rlUnloadVertexArray(unsigned int vaoId) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4038 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4039 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4040 if (RLGL.ExtSupported.vao) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4041 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4042 glBindVertexArray(0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4043 glDeleteVertexArrays(1, &vaoId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4044 TRACELOG(RL_LOG_INFO, "VAO: [ID %i] Unloaded vertex array data from VRAM (GPU)", vaoId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4045 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4046 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4047 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4048 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4049 // Unload vertex buffer (VBO) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4050 void rlUnloadVertexBuffer(unsigned int vboId) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4051 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4052 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4053 glDeleteBuffers(1, &vboId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4054 //TRACELOG(RL_LOG_INFO, "VBO: Unloaded vertex data from VRAM (GPU)"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4055 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4056 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4057 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4058 // Shaders management |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4059 //----------------------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4060 // Load shader from code strings |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4061 // NOTE: If shader string is NULL, using default vertex/fragment shaders |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4062 unsigned int rlLoadShaderCode(const char *vsCode, const char *fsCode) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4063 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4064 unsigned int id = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4065 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4066 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4067 unsigned int vertexShaderId = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4068 unsigned int fragmentShaderId = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4069 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4070 // Compile vertex shader (if provided) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4071 // NOTE: If not vertex shader is provided, use default one |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4072 if (vsCode != NULL) vertexShaderId = rlCompileShader(vsCode, GL_VERTEX_SHADER); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4073 else vertexShaderId = RLGL.State.defaultVShaderId; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4074 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4075 // Compile fragment shader (if provided) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4076 // NOTE: If not vertex shader is provided, use default one |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4077 if (fsCode != NULL) fragmentShaderId = rlCompileShader(fsCode, GL_FRAGMENT_SHADER); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4078 else fragmentShaderId = RLGL.State.defaultFShaderId; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4079 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4080 // In case vertex and fragment shader are the default ones, no need to recompile, we can just assign the default shader program id |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4081 if ((vertexShaderId == RLGL.State.defaultVShaderId) && (fragmentShaderId == RLGL.State.defaultFShaderId)) id = RLGL.State.defaultShaderId; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4082 else if ((vertexShaderId > 0) && (fragmentShaderId > 0)) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4083 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4084 // One of or both shader are new, we need to compile a new shader program |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4085 id = rlLoadShaderProgram(vertexShaderId, fragmentShaderId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4086 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4087 // We can detach and delete vertex/fragment shaders (if not default ones) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4088 // NOTE: We detach shader before deletion to make sure memory is freed |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4089 if (vertexShaderId != RLGL.State.defaultVShaderId) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4090 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4091 // WARNING: Shader program linkage could fail and returned id is 0 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4092 if (id > 0) glDetachShader(id, vertexShaderId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4093 glDeleteShader(vertexShaderId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4094 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4095 if (fragmentShaderId != RLGL.State.defaultFShaderId) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4096 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4097 // WARNING: Shader program linkage could fail and returned id is 0 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4098 if (id > 0) glDetachShader(id, fragmentShaderId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4099 glDeleteShader(fragmentShaderId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4100 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4101 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4102 // In case shader program loading failed, we assign default shader |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4103 if (id == 0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4104 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4105 // In case shader loading fails, we return the default shader |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4106 TRACELOG(RL_LOG_WARNING, "SHADER: Failed to load custom shader code, using default shader"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4107 id = RLGL.State.defaultShaderId; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4108 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4109 /* |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4110 else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4111 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4112 // Get available shader uniforms |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4113 // NOTE: This information is useful for debug... |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4114 int uniformCount = -1; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4115 glGetProgramiv(id, GL_ACTIVE_UNIFORMS, &uniformCount); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4116 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4117 for (int i = 0; i < uniformCount; i++) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4118 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4119 int namelen = -1; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4120 int num = -1; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4121 char name[256] = { 0 }; // Assume no variable names longer than 256 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4122 GLenum type = GL_ZERO; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4123 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4124 // Get the name of the uniforms |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4125 glGetActiveUniform(id, i, sizeof(name) - 1, &namelen, &num, &type, name); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4126 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4127 name[namelen] = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4128 TRACELOGD("SHADER: [ID %i] Active uniform (%s) set at location: %i", id, name, glGetUniformLocation(id, name)); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4129 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4130 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4131 */ |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4132 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4133 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4134 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4135 return id; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4136 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4137 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4138 // Compile custom shader and return shader id |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4139 unsigned int rlCompileShader(const char *shaderCode, int type) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4140 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4141 unsigned int shader = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4142 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4143 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4144 shader = glCreateShader(type); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4145 glShaderSource(shader, 1, &shaderCode, NULL); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4146 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4147 GLint success = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4148 glCompileShader(shader); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4149 glGetShaderiv(shader, GL_COMPILE_STATUS, &success); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4150 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4151 if (success == GL_FALSE) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4152 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4153 switch (type) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4154 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4155 case GL_VERTEX_SHADER: TRACELOG(RL_LOG_WARNING, "SHADER: [ID %i] Failed to compile vertex shader code", shader); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4156 case GL_FRAGMENT_SHADER: TRACELOG(RL_LOG_WARNING, "SHADER: [ID %i] Failed to compile fragment shader code", shader); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4157 //case GL_GEOMETRY_SHADER: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4158 #if defined(GRAPHICS_API_OPENGL_43) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4159 case GL_COMPUTE_SHADER: TRACELOG(RL_LOG_WARNING, "SHADER: [ID %i] Failed to compile compute shader code", shader); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4160 #elif defined(GRAPHICS_API_OPENGL_33) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4161 case GL_COMPUTE_SHADER: TRACELOG(RL_LOG_WARNING, "SHADER: Compute shaders not enabled. Define GRAPHICS_API_OPENGL_43", shader); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4162 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4163 default: break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4164 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4165 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4166 int maxLength = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4167 glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &maxLength); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4168 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4169 if (maxLength > 0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4170 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4171 int length = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4172 char *log = (char *)RL_CALLOC(maxLength, sizeof(char)); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4173 glGetShaderInfoLog(shader, maxLength, &length, log); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4174 TRACELOG(RL_LOG_WARNING, "SHADER: [ID %i] Compile error: %s", shader, log); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4175 RL_FREE(log); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4176 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4177 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4178 shader = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4179 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4180 else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4181 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4182 switch (type) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4183 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4184 case GL_VERTEX_SHADER: TRACELOG(RL_LOG_INFO, "SHADER: [ID %i] Vertex shader compiled successfully", shader); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4185 case GL_FRAGMENT_SHADER: TRACELOG(RL_LOG_INFO, "SHADER: [ID %i] Fragment shader compiled successfully", shader); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4186 //case GL_GEOMETRY_SHADER: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4187 #if defined(GRAPHICS_API_OPENGL_43) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4188 case GL_COMPUTE_SHADER: TRACELOG(RL_LOG_INFO, "SHADER: [ID %i] Compute shader compiled successfully", shader); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4189 #elif defined(GRAPHICS_API_OPENGL_33) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4190 case GL_COMPUTE_SHADER: TRACELOG(RL_LOG_WARNING, "SHADER: Compute shaders not enabled. Define GRAPHICS_API_OPENGL_43", shader); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4191 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4192 default: break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4193 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4194 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4195 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4196 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4197 return shader; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4198 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4199 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4200 // Load custom shader strings and return program id |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4201 unsigned int rlLoadShaderProgram(unsigned int vShaderId, unsigned int fShaderId) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4202 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4203 unsigned int program = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4204 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4205 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4206 GLint success = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4207 program = glCreateProgram(); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4208 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4209 glAttachShader(program, vShaderId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4210 glAttachShader(program, fShaderId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4211 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4212 // NOTE: Default attribute shader locations must be Bound before linking |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4213 glBindAttribLocation(program, RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION, RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4214 glBindAttribLocation(program, RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD, RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4215 glBindAttribLocation(program, RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL, RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4216 glBindAttribLocation(program, RL_DEFAULT_SHADER_ATTRIB_LOCATION_COLOR, RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4217 glBindAttribLocation(program, RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT, RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4218 glBindAttribLocation(program, RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2, RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4219 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4220 #ifdef RL_SUPPORT_MESH_GPU_SKINNING |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4221 glBindAttribLocation(program, RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEIDS, RL_DEFAULT_SHADER_ATTRIB_NAME_BONEIDS); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4222 glBindAttribLocation(program, RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS, RL_DEFAULT_SHADER_ATTRIB_NAME_BONEWEIGHTS); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4223 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4224 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4225 // NOTE: If some attrib name is no found on the shader, it locations becomes -1 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4226 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4227 glLinkProgram(program); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4228 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4229 // NOTE: All uniform variables are intitialised to 0 when a program links |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4230 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4231 glGetProgramiv(program, GL_LINK_STATUS, &success); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4232 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4233 if (success == GL_FALSE) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4234 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4235 TRACELOG(RL_LOG_WARNING, "SHADER: [ID %i] Failed to link shader program", program); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4236 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4237 int maxLength = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4238 glGetProgramiv(program, GL_INFO_LOG_LENGTH, &maxLength); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4239 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4240 if (maxLength > 0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4241 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4242 int length = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4243 char *log = (char *)RL_CALLOC(maxLength, sizeof(char)); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4244 glGetProgramInfoLog(program, maxLength, &length, log); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4245 TRACELOG(RL_LOG_WARNING, "SHADER: [ID %i] Link error: %s", program, log); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4246 RL_FREE(log); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4247 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4248 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4249 glDeleteProgram(program); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4250 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4251 program = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4252 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4253 else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4254 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4255 // Get the size of compiled shader program (not available on OpenGL ES 2.0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4256 // NOTE: If GL_LINK_STATUS is GL_FALSE, program binary length is zero |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4257 //GLint binarySize = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4258 //glGetProgramiv(id, GL_PROGRAM_BINARY_LENGTH, &binarySize); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4259 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4260 TRACELOG(RL_LOG_INFO, "SHADER: [ID %i] Program shader loaded successfully", program); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4261 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4262 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4263 return program; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4264 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4265 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4266 // Unload shader program |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4267 void rlUnloadShaderProgram(unsigned int id) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4268 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4269 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4270 glDeleteProgram(id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4271 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4272 TRACELOG(RL_LOG_INFO, "SHADER: [ID %i] Unloaded shader program data from VRAM (GPU)", id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4273 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4274 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4275 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4276 // Get shader location uniform |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4277 int rlGetLocationUniform(unsigned int shaderId, const char *uniformName) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4278 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4279 int location = -1; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4280 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4281 location = glGetUniformLocation(shaderId, uniformName); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4282 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4283 //if (location == -1) TRACELOG(RL_LOG_WARNING, "SHADER: [ID %i] Failed to find shader uniform: %s", shaderId, uniformName); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4284 //else TRACELOG(RL_LOG_INFO, "SHADER: [ID %i] Shader uniform (%s) set at location: %i", shaderId, uniformName, location); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4285 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4286 return location; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4287 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4288 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4289 // Get shader location attribute |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4290 int rlGetLocationAttrib(unsigned int shaderId, const char *attribName) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4291 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4292 int location = -1; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4293 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4294 location = glGetAttribLocation(shaderId, attribName); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4295 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4296 //if (location == -1) TRACELOG(RL_LOG_WARNING, "SHADER: [ID %i] Failed to find shader attribute: %s", shaderId, attribName); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4297 //else TRACELOG(RL_LOG_INFO, "SHADER: [ID %i] Shader attribute (%s) set at location: %i", shaderId, attribName, location); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4298 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4299 return location; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4300 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4301 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4302 // Set shader value uniform |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4303 void rlSetUniform(int locIndex, const void *value, int uniformType, int count) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4304 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4305 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4306 switch (uniformType) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4307 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4308 case RL_SHADER_UNIFORM_FLOAT: glUniform1fv(locIndex, count, (float *)value); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4309 case RL_SHADER_UNIFORM_VEC2: glUniform2fv(locIndex, count, (float *)value); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4310 case RL_SHADER_UNIFORM_VEC3: glUniform3fv(locIndex, count, (float *)value); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4311 case RL_SHADER_UNIFORM_VEC4: glUniform4fv(locIndex, count, (float *)value); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4312 case RL_SHADER_UNIFORM_INT: glUniform1iv(locIndex, count, (int *)value); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4313 case RL_SHADER_UNIFORM_IVEC2: glUniform2iv(locIndex, count, (int *)value); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4314 case RL_SHADER_UNIFORM_IVEC3: glUniform3iv(locIndex, count, (int *)value); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4315 case RL_SHADER_UNIFORM_IVEC4: glUniform4iv(locIndex, count, (int *)value); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4316 #if !defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4317 case RL_SHADER_UNIFORM_UINT: glUniform1uiv(locIndex, count, (unsigned int *)value); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4318 case RL_SHADER_UNIFORM_UIVEC2: glUniform2uiv(locIndex, count, (unsigned int *)value); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4319 case RL_SHADER_UNIFORM_UIVEC3: glUniform3uiv(locIndex, count, (unsigned int *)value); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4320 case RL_SHADER_UNIFORM_UIVEC4: glUniform4uiv(locIndex, count, (unsigned int *)value); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4321 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4322 case RL_SHADER_UNIFORM_SAMPLER2D: glUniform1iv(locIndex, count, (int *)value); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4323 default: TRACELOG(RL_LOG_WARNING, "SHADER: Failed to set uniform value, data type not recognized"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4324 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4325 // TODO: Support glUniform1uiv(), glUniform2uiv(), glUniform3uiv(), glUniform4uiv() |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4326 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4327 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4328 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4329 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4330 // Set shader value attribute |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4331 void rlSetVertexAttributeDefault(int locIndex, const void *value, int attribType, int count) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4332 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4333 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4334 switch (attribType) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4335 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4336 case RL_SHADER_ATTRIB_FLOAT: if (count == 1) glVertexAttrib1fv(locIndex, (float *)value); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4337 case RL_SHADER_ATTRIB_VEC2: if (count == 2) glVertexAttrib2fv(locIndex, (float *)value); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4338 case RL_SHADER_ATTRIB_VEC3: if (count == 3) glVertexAttrib3fv(locIndex, (float *)value); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4339 case RL_SHADER_ATTRIB_VEC4: if (count == 4) glVertexAttrib4fv(locIndex, (float *)value); break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4340 default: TRACELOG(RL_LOG_WARNING, "SHADER: Failed to set attrib default value, data type not recognized"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4341 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4342 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4343 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4344 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4345 // Set shader value uniform matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4346 void rlSetUniformMatrix(int locIndex, Matrix mat) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4347 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4348 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4349 float matfloat[16] = { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4350 mat.m0, mat.m1, mat.m2, mat.m3, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4351 mat.m4, mat.m5, mat.m6, mat.m7, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4352 mat.m8, mat.m9, mat.m10, mat.m11, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4353 mat.m12, mat.m13, mat.m14, mat.m15 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4354 }; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4355 glUniformMatrix4fv(locIndex, 1, false, matfloat); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4356 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4357 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4358 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4359 // Set shader value uniform matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4360 void rlSetUniformMatrices(int locIndex, const Matrix *matrices, int count) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4361 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4362 #if defined(GRAPHICS_API_OPENGL_33) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4363 glUniformMatrix4fv(locIndex, count, true, (const float *)matrices); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4364 #elif defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4365 // WARNING: WebGL does not support Matrix transpose ("true" parameter) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4366 // REF: https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/uniformMatrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4367 glUniformMatrix4fv(locIndex, count, false, (const float *)matrices); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4368 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4369 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4370 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4371 // Set shader value uniform sampler |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4372 void rlSetUniformSampler(int locIndex, unsigned int textureId) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4373 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4374 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4375 // Check if texture is already active |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4376 for (int i = 0; i < RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS; i++) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4377 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4378 if (RLGL.State.activeTextureId[i] == textureId) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4379 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4380 glUniform1i(locIndex, 1 + i); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4381 return; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4382 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4383 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4384 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4385 // Register a new active texture for the internal batch system |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4386 // NOTE: Default texture is always activated as GL_TEXTURE0 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4387 for (int i = 0; i < RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS; i++) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4388 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4389 if (RLGL.State.activeTextureId[i] == 0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4390 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4391 glUniform1i(locIndex, 1 + i); // Activate new texture unit |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4392 RLGL.State.activeTextureId[i] = textureId; // Save texture id for binding on drawing |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4393 break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4394 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4395 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4396 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4397 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4398 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4399 // Set shader currently active (id and locations) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4400 void rlSetShader(unsigned int id, int *locs) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4401 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4402 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4403 if (RLGL.State.currentShaderId != id) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4404 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4405 rlDrawRenderBatch(RLGL.currentBatch); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4406 RLGL.State.currentShaderId = id; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4407 RLGL.State.currentShaderLocs = locs; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4408 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4409 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4410 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4411 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4412 // Load compute shader program |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4413 unsigned int rlLoadComputeShaderProgram(unsigned int shaderId) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4414 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4415 unsigned int program = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4416 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4417 #if defined(GRAPHICS_API_OPENGL_43) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4418 GLint success = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4419 program = glCreateProgram(); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4420 glAttachShader(program, shaderId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4421 glLinkProgram(program); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4422 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4423 // NOTE: All uniform variables are intitialised to 0 when a program links |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4424 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4425 glGetProgramiv(program, GL_LINK_STATUS, &success); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4426 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4427 if (success == GL_FALSE) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4428 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4429 TRACELOG(RL_LOG_WARNING, "SHADER: [ID %i] Failed to link compute shader program", program); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4430 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4431 int maxLength = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4432 glGetProgramiv(program, GL_INFO_LOG_LENGTH, &maxLength); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4433 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4434 if (maxLength > 0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4435 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4436 int length = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4437 char *log = (char *)RL_CALLOC(maxLength, sizeof(char)); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4438 glGetProgramInfoLog(program, maxLength, &length, log); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4439 TRACELOG(RL_LOG_WARNING, "SHADER: [ID %i] Link error: %s", program, log); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4440 RL_FREE(log); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4441 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4442 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4443 glDeleteProgram(program); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4444 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4445 program = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4446 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4447 else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4448 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4449 // Get the size of compiled shader program (not available on OpenGL ES 2.0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4450 // NOTE: If GL_LINK_STATUS is GL_FALSE, program binary length is zero |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4451 //GLint binarySize = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4452 //glGetProgramiv(id, GL_PROGRAM_BINARY_LENGTH, &binarySize); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4453 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4454 TRACELOG(RL_LOG_INFO, "SHADER: [ID %i] Compute shader program loaded successfully", program); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4455 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4456 #else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4457 TRACELOG(RL_LOG_WARNING, "SHADER: Compute shaders not enabled. Define GRAPHICS_API_OPENGL_43"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4458 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4459 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4460 return program; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4461 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4462 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4463 // Dispatch compute shader (equivalent to *draw* for graphics pilepine) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4464 void rlComputeShaderDispatch(unsigned int groupX, unsigned int groupY, unsigned int groupZ) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4465 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4466 #if defined(GRAPHICS_API_OPENGL_43) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4467 glDispatchCompute(groupX, groupY, groupZ); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4468 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4469 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4470 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4471 // Load shader storage buffer object (SSBO) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4472 unsigned int rlLoadShaderBuffer(unsigned int size, const void *data, int usageHint) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4473 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4474 unsigned int ssbo = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4475 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4476 #if defined(GRAPHICS_API_OPENGL_43) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4477 glGenBuffers(1, &ssbo); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4478 glBindBuffer(GL_SHADER_STORAGE_BUFFER, ssbo); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4479 glBufferData(GL_SHADER_STORAGE_BUFFER, size, data, usageHint? usageHint : RL_STREAM_COPY); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4480 if (data == NULL) glClearBufferData(GL_SHADER_STORAGE_BUFFER, GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE, NULL); // Clear buffer data to 0 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4481 glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4482 #else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4483 TRACELOG(RL_LOG_WARNING, "SSBO: SSBO not enabled. Define GRAPHICS_API_OPENGL_43"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4484 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4485 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4486 return ssbo; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4487 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4488 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4489 // Unload shader storage buffer object (SSBO) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4490 void rlUnloadShaderBuffer(unsigned int ssboId) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4491 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4492 #if defined(GRAPHICS_API_OPENGL_43) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4493 glDeleteBuffers(1, &ssboId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4494 #else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4495 TRACELOG(RL_LOG_WARNING, "SSBO: SSBO not enabled. Define GRAPHICS_API_OPENGL_43"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4496 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4497 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4498 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4499 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4500 // Update SSBO buffer data |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4501 void rlUpdateShaderBuffer(unsigned int id, const void *data, unsigned int dataSize, unsigned int offset) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4502 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4503 #if defined(GRAPHICS_API_OPENGL_43) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4504 glBindBuffer(GL_SHADER_STORAGE_BUFFER, id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4505 glBufferSubData(GL_SHADER_STORAGE_BUFFER, offset, dataSize, data); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4506 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4507 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4508 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4509 // Get SSBO buffer size |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4510 unsigned int rlGetShaderBufferSize(unsigned int id) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4511 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4512 #if defined(GRAPHICS_API_OPENGL_43) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4513 GLint64 size = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4514 glBindBuffer(GL_SHADER_STORAGE_BUFFER, id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4515 glGetBufferParameteri64v(GL_SHADER_STORAGE_BUFFER, GL_BUFFER_SIZE, &size); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4516 return (size > 0)? (unsigned int)size : 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4517 #else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4518 return 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4519 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4520 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4521 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4522 // Read SSBO buffer data (GPU->CPU) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4523 void rlReadShaderBuffer(unsigned int id, void *dest, unsigned int count, unsigned int offset) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4524 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4525 #if defined(GRAPHICS_API_OPENGL_43) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4526 glBindBuffer(GL_SHADER_STORAGE_BUFFER, id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4527 glGetBufferSubData(GL_SHADER_STORAGE_BUFFER, offset, count, dest); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4528 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4529 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4530 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4531 // Bind SSBO buffer |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4532 void rlBindShaderBuffer(unsigned int id, unsigned int index) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4533 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4534 #if defined(GRAPHICS_API_OPENGL_43) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4535 glBindBufferBase(GL_SHADER_STORAGE_BUFFER, index, id); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4536 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4537 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4538 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4539 // Copy SSBO buffer data |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4540 void rlCopyShaderBuffer(unsigned int destId, unsigned int srcId, unsigned int destOffset, unsigned int srcOffset, unsigned int count) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4541 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4542 #if defined(GRAPHICS_API_OPENGL_43) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4543 glBindBuffer(GL_COPY_READ_BUFFER, srcId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4544 glBindBuffer(GL_COPY_WRITE_BUFFER, destId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4545 glCopyBufferSubData(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, srcOffset, destOffset, count); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4546 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4547 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4548 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4549 // Bind image texture |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4550 void rlBindImageTexture(unsigned int id, unsigned int index, int format, bool readonly) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4551 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4552 #if defined(GRAPHICS_API_OPENGL_43) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4553 unsigned int glInternalFormat = 0, glFormat = 0, glType = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4554 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4555 rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4556 glBindImageTexture(index, id, 0, 0, 0, readonly? GL_READ_ONLY : GL_READ_WRITE, glInternalFormat); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4557 #else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4558 TRACELOG(RL_LOG_WARNING, "TEXTURE: Image texture binding not enabled. Define GRAPHICS_API_OPENGL_43"); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4559 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4560 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4561 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4562 // Matrix state management |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4563 //----------------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4564 // Get internal modelview matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4565 Matrix rlGetMatrixModelview(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4566 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4567 Matrix matrix = rlMatrixIdentity(); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4568 #if defined(GRAPHICS_API_OPENGL_11) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4569 float mat[16]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4570 glGetFloatv(GL_MODELVIEW_MATRIX, mat); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4571 matrix.m0 = mat[0]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4572 matrix.m1 = mat[1]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4573 matrix.m2 = mat[2]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4574 matrix.m3 = mat[3]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4575 matrix.m4 = mat[4]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4576 matrix.m5 = mat[5]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4577 matrix.m6 = mat[6]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4578 matrix.m7 = mat[7]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4579 matrix.m8 = mat[8]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4580 matrix.m9 = mat[9]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4581 matrix.m10 = mat[10]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4582 matrix.m11 = mat[11]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4583 matrix.m12 = mat[12]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4584 matrix.m13 = mat[13]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4585 matrix.m14 = mat[14]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4586 matrix.m15 = mat[15]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4587 #else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4588 matrix = RLGL.State.modelview; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4589 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4590 return matrix; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4591 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4592 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4593 // Get internal projection matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4594 Matrix rlGetMatrixProjection(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4595 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4596 #if defined(GRAPHICS_API_OPENGL_11) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4597 float mat[16]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4598 glGetFloatv(GL_PROJECTION_MATRIX,mat); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4599 Matrix m; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4600 m.m0 = mat[0]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4601 m.m1 = mat[1]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4602 m.m2 = mat[2]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4603 m.m3 = mat[3]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4604 m.m4 = mat[4]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4605 m.m5 = mat[5]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4606 m.m6 = mat[6]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4607 m.m7 = mat[7]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4608 m.m8 = mat[8]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4609 m.m9 = mat[9]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4610 m.m10 = mat[10]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4611 m.m11 = mat[11]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4612 m.m12 = mat[12]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4613 m.m13 = mat[13]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4614 m.m14 = mat[14]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4615 m.m15 = mat[15]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4616 return m; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4617 #else |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4618 return RLGL.State.projection; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4619 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4620 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4621 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4622 // Get internal accumulated transform matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4623 Matrix rlGetMatrixTransform(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4624 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4625 Matrix mat = rlMatrixIdentity(); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4626 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4627 // TODO: Consider possible transform matrices in the RLGL.State.stack |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4628 // Is this the right order? or should we start with the first stored matrix instead of the last one? |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4629 //Matrix matStackTransform = rlMatrixIdentity(); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4630 //for (int i = RLGL.State.stackCounter; i > 0; i--) matStackTransform = rlMatrixMultiply(RLGL.State.stack[i], matStackTransform); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4631 mat = RLGL.State.transform; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4632 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4633 return mat; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4634 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4635 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4636 // Get internal projection matrix for stereo render (selected eye) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4637 Matrix rlGetMatrixProjectionStereo(int eye) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4638 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4639 Matrix mat = rlMatrixIdentity(); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4640 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4641 mat = RLGL.State.projectionStereo[eye]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4642 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4643 return mat; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4644 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4645 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4646 // Get internal view offset matrix for stereo render (selected eye) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4647 Matrix rlGetMatrixViewOffsetStereo(int eye) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4648 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4649 Matrix mat = rlMatrixIdentity(); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4650 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4651 mat = RLGL.State.viewOffsetStereo[eye]; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4652 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4653 return mat; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4654 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4655 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4656 // Set a custom modelview matrix (replaces internal modelview matrix) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4657 void rlSetMatrixModelview(Matrix view) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4658 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4659 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4660 RLGL.State.modelview = view; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4661 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4662 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4663 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4664 // Set a custom projection matrix (replaces internal projection matrix) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4665 void rlSetMatrixProjection(Matrix projection) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4666 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4667 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4668 RLGL.State.projection = projection; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4669 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4670 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4671 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4672 // Set eyes projection matrices for stereo rendering |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4673 void rlSetMatrixProjectionStereo(Matrix right, Matrix left) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4674 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4675 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4676 RLGL.State.projectionStereo[0] = right; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4677 RLGL.State.projectionStereo[1] = left; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4678 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4679 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4680 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4681 // Set eyes view offsets matrices for stereo rendering |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4682 void rlSetMatrixViewOffsetStereo(Matrix right, Matrix left) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4683 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4684 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4685 RLGL.State.viewOffsetStereo[0] = right; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4686 RLGL.State.viewOffsetStereo[1] = left; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4687 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4688 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4689 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4690 // Load and draw a quad in NDC |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4691 void rlLoadDrawQuad(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4692 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4693 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4694 unsigned int quadVAO = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4695 unsigned int quadVBO = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4696 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4697 float vertices[] = { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4698 // Positions Texcoords |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4699 -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4700 -1.0f, -1.0f, 0.0f, 0.0f, 0.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4701 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4702 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4703 }; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4704 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4705 // Gen VAO to contain VBO |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4706 glGenVertexArrays(1, &quadVAO); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4707 glBindVertexArray(quadVAO); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4708 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4709 // Gen and fill vertex buffer (VBO) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4710 glGenBuffers(1, &quadVBO); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4711 glBindBuffer(GL_ARRAY_BUFFER, quadVBO); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4712 glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), &vertices, GL_STATIC_DRAW); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4713 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4714 // Bind vertex attributes (position, texcoords) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4715 glEnableVertexAttribArray(RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4716 glVertexAttribPointer(RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION, 3, GL_FLOAT, GL_FALSE, 5*sizeof(float), (void *)0); // Positions |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4717 glEnableVertexAttribArray(RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4718 glVertexAttribPointer(RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 5*sizeof(float), (void *)(3*sizeof(float))); // Texcoords |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4719 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4720 // Draw quad |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4721 glBindVertexArray(quadVAO); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4722 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4723 glBindVertexArray(0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4724 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4725 // Delete buffers (VBO and VAO) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4726 glDeleteBuffers(1, &quadVBO); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4727 glDeleteVertexArrays(1, &quadVAO); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4728 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4729 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4730 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4731 // Load and draw a cube in NDC |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4732 void rlLoadDrawCube(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4733 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4734 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4735 unsigned int cubeVAO = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4736 unsigned int cubeVBO = 0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4737 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4738 float vertices[] = { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4739 // Positions Normals Texcoords |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4740 -1.0f, -1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4741 1.0f, 1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 1.0f, 1.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4742 1.0f, -1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 1.0f, 0.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4743 1.0f, 1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 1.0f, 1.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4744 -1.0f, -1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4745 -1.0f, 1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4746 -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4747 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4748 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4749 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4750 -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4751 -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4752 -1.0f, 1.0f, 1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4753 -1.0f, 1.0f, -1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 1.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4754 -1.0f, -1.0f, -1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4755 -1.0f, -1.0f, -1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4756 -1.0f, -1.0f, 1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4757 -1.0f, 1.0f, 1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4758 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4759 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4760 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4761 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4762 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4763 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4764 -1.0f, -1.0f, -1.0f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4765 1.0f, -1.0f, -1.0f, 0.0f, -1.0f, 0.0f, 1.0f, 1.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4766 1.0f, -1.0f, 1.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4767 1.0f, -1.0f, 1.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4768 -1.0f, -1.0f, 1.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4769 -1.0f, -1.0f, -1.0f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4770 -1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4771 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4772 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4773 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4774 -1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4775 -1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4776 }; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4777 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4778 // Gen VAO to contain VBO |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4779 glGenVertexArrays(1, &cubeVAO); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4780 glBindVertexArray(cubeVAO); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4781 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4782 // Gen and fill vertex buffer (VBO) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4783 glGenBuffers(1, &cubeVBO); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4784 glBindBuffer(GL_ARRAY_BUFFER, cubeVBO); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4785 glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4786 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4787 // Bind vertex attributes (position, normals, texcoords) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4788 glBindVertexArray(cubeVAO); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4789 glEnableVertexAttribArray(RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4790 glVertexAttribPointer(RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION, 3, GL_FLOAT, GL_FALSE, 8*sizeof(float), (void *)0); // Positions |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4791 glEnableVertexAttribArray(RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4792 glVertexAttribPointer(RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL, 3, GL_FLOAT, GL_FALSE, 8*sizeof(float), (void *)(3*sizeof(float))); // Normals |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4793 glEnableVertexAttribArray(RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4794 glVertexAttribPointer(RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 8*sizeof(float), (void *)(6*sizeof(float))); // Texcoords |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4795 glBindBuffer(GL_ARRAY_BUFFER, 0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4796 glBindVertexArray(0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4797 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4798 // Draw cube |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4799 glBindVertexArray(cubeVAO); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4800 glDrawArrays(GL_TRIANGLES, 0, 36); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4801 glBindVertexArray(0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4802 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4803 // Delete VBO and VAO |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4804 glDeleteBuffers(1, &cubeVBO); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4805 glDeleteVertexArrays(1, &cubeVAO); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4806 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4807 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4808 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4809 // Get name string for pixel format |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4810 const char *rlGetPixelFormatName(unsigned int format) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4811 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4812 switch (format) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4813 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4814 case RL_PIXELFORMAT_UNCOMPRESSED_GRAYSCALE: return "GRAYSCALE"; break; // 8 bit per pixel (no alpha) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4815 case RL_PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA: return "GRAY_ALPHA"; break; // 8*2 bpp (2 channels) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4816 case RL_PIXELFORMAT_UNCOMPRESSED_R5G6B5: return "R5G6B5"; break; // 16 bpp |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4817 case RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8: return "R8G8B8"; break; // 24 bpp |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4818 case RL_PIXELFORMAT_UNCOMPRESSED_R5G5B5A1: return "R5G5B5A1"; break; // 16 bpp (1 bit alpha) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4819 case RL_PIXELFORMAT_UNCOMPRESSED_R4G4B4A4: return "R4G4B4A4"; break; // 16 bpp (4 bit alpha) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4820 case RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8: return "R8G8B8A8"; break; // 32 bpp |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4821 case RL_PIXELFORMAT_UNCOMPRESSED_R32: return "R32"; break; // 32 bpp (1 channel - float) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4822 case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32: return "R32G32B32"; break; // 32*3 bpp (3 channels - float) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4823 case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32A32: return "R32G32B32A32"; break; // 32*4 bpp (4 channels - float) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4824 case RL_PIXELFORMAT_UNCOMPRESSED_R16: return "R16"; break; // 16 bpp (1 channel - half float) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4825 case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16: return "R16G16B16"; break; // 16*3 bpp (3 channels - half float) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4826 case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16: return "R16G16B16A16"; break; // 16*4 bpp (4 channels - half float) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4827 case RL_PIXELFORMAT_COMPRESSED_DXT1_RGB: return "DXT1_RGB"; break; // 4 bpp (no alpha) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4828 case RL_PIXELFORMAT_COMPRESSED_DXT1_RGBA: return "DXT1_RGBA"; break; // 4 bpp (1 bit alpha) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4829 case RL_PIXELFORMAT_COMPRESSED_DXT3_RGBA: return "DXT3_RGBA"; break; // 8 bpp |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4830 case RL_PIXELFORMAT_COMPRESSED_DXT5_RGBA: return "DXT5_RGBA"; break; // 8 bpp |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4831 case RL_PIXELFORMAT_COMPRESSED_ETC1_RGB: return "ETC1_RGB"; break; // 4 bpp |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4832 case RL_PIXELFORMAT_COMPRESSED_ETC2_RGB: return "ETC2_RGB"; break; // 4 bpp |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4833 case RL_PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA: return "ETC2_RGBA"; break; // 8 bpp |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4834 case RL_PIXELFORMAT_COMPRESSED_PVRT_RGB: return "PVRT_RGB"; break; // 4 bpp |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4835 case RL_PIXELFORMAT_COMPRESSED_PVRT_RGBA: return "PVRT_RGBA"; break; // 4 bpp |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4836 case RL_PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA: return "ASTC_4x4_RGBA"; break; // 8 bpp |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4837 case RL_PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA: return "ASTC_8x8_RGBA"; break; // 2 bpp |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4838 default: return "UNKNOWN"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4839 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4840 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4841 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4842 //---------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4843 // Module specific Functions Definition |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4844 //---------------------------------------------------------------------------------- |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4845 #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4846 // Load default shader (just vertex positioning and texture coloring) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4847 // NOTE: This shader program is used for internal buffers |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4848 // NOTE: Loaded: RLGL.State.defaultShaderId, RLGL.State.defaultShaderLocs |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4849 static void rlLoadShaderDefault(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4850 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4851 RLGL.State.defaultShaderLocs = (int *)RL_CALLOC(RL_MAX_SHADER_LOCATIONS, sizeof(int)); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4852 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4853 // NOTE: All locations must be reseted to -1 (no location) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4854 for (int i = 0; i < RL_MAX_SHADER_LOCATIONS; i++) RLGL.State.defaultShaderLocs[i] = -1; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4855 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4856 // Vertex shader directly defined, no external file required |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4857 const char *defaultVShaderCode = |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4858 #if defined(GRAPHICS_API_OPENGL_21) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4859 "#version 120 \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4860 "attribute vec3 vertexPosition; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4861 "attribute vec2 vertexTexCoord; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4862 "attribute vec4 vertexColor; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4863 "varying vec2 fragTexCoord; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4864 "varying vec4 fragColor; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4865 #elif defined(GRAPHICS_API_OPENGL_33) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4866 "#version 330 \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4867 "in vec3 vertexPosition; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4868 "in vec2 vertexTexCoord; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4869 "in vec4 vertexColor; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4870 "out vec2 fragTexCoord; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4871 "out vec4 fragColor; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4872 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4873 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4874 #if defined(GRAPHICS_API_OPENGL_ES3) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4875 "#version 300 es \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4876 "precision mediump float; \n" // Precision required for OpenGL ES3 (WebGL 2) (on some browsers) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4877 "in vec3 vertexPosition; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4878 "in vec2 vertexTexCoord; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4879 "in vec4 vertexColor; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4880 "out vec2 fragTexCoord; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4881 "out vec4 fragColor; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4882 #elif defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4883 "#version 100 \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4884 "precision mediump float; \n" // Precision required for OpenGL ES2 (WebGL) (on some browsers) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4885 "attribute vec3 vertexPosition; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4886 "attribute vec2 vertexTexCoord; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4887 "attribute vec4 vertexColor; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4888 "varying vec2 fragTexCoord; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4889 "varying vec4 fragColor; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4890 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4891 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4892 "uniform mat4 mvp; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4893 "void main() \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4894 "{ \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4895 " fragTexCoord = vertexTexCoord; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4896 " fragColor = vertexColor; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4897 " gl_Position = mvp*vec4(vertexPosition, 1.0); \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4898 "} \n"; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4899 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4900 // Fragment shader directly defined, no external file required |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4901 const char *defaultFShaderCode = |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4902 #if defined(GRAPHICS_API_OPENGL_21) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4903 "#version 120 \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4904 "varying vec2 fragTexCoord; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4905 "varying vec4 fragColor; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4906 "uniform sampler2D texture0; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4907 "uniform vec4 colDiffuse; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4908 "void main() \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4909 "{ \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4910 " vec4 texelColor = texture2D(texture0, fragTexCoord); \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4911 " gl_FragColor = texelColor*colDiffuse*fragColor; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4912 "} \n"; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4913 #elif defined(GRAPHICS_API_OPENGL_33) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4914 "#version 330 \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4915 "in vec2 fragTexCoord; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4916 "in vec4 fragColor; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4917 "out vec4 finalColor; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4918 "uniform sampler2D texture0; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4919 "uniform vec4 colDiffuse; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4920 "void main() \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4921 "{ \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4922 " vec4 texelColor = texture(texture0, fragTexCoord); \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4923 " finalColor = texelColor*colDiffuse*fragColor; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4924 "} \n"; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4925 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4926 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4927 #if defined(GRAPHICS_API_OPENGL_ES3) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4928 "#version 300 es \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4929 "precision mediump float; \n" // Precision required for OpenGL ES3 (WebGL 2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4930 "in vec2 fragTexCoord; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4931 "in vec4 fragColor; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4932 "out vec4 finalColor; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4933 "uniform sampler2D texture0; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4934 "uniform vec4 colDiffuse; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4935 "void main() \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4936 "{ \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4937 " vec4 texelColor = texture(texture0, fragTexCoord); \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4938 " finalColor = texelColor*colDiffuse*fragColor; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4939 "} \n"; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4940 #elif defined(GRAPHICS_API_OPENGL_ES2) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4941 "#version 100 \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4942 "precision mediump float; \n" // Precision required for OpenGL ES2 (WebGL) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4943 "varying vec2 fragTexCoord; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4944 "varying vec4 fragColor; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4945 "uniform sampler2D texture0; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4946 "uniform vec4 colDiffuse; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4947 "void main() \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4948 "{ \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4949 " vec4 texelColor = texture2D(texture0, fragTexCoord); \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4950 " gl_FragColor = texelColor*colDiffuse*fragColor; \n" |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4951 "} \n"; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4952 #endif |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4953 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4954 // NOTE: Compiled vertex/fragment shaders are not deleted, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4955 // they are kept for re-use as default shaders in case some shader loading fails |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4956 RLGL.State.defaultVShaderId = rlCompileShader(defaultVShaderCode, GL_VERTEX_SHADER); // Compile default vertex shader |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4957 RLGL.State.defaultFShaderId = rlCompileShader(defaultFShaderCode, GL_FRAGMENT_SHADER); // Compile default fragment shader |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4958 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4959 RLGL.State.defaultShaderId = rlLoadShaderProgram(RLGL.State.defaultVShaderId, RLGL.State.defaultFShaderId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4960 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4961 if (RLGL.State.defaultShaderId > 0) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4962 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4963 TRACELOG(RL_LOG_INFO, "SHADER: [ID %i] Default shader loaded successfully", RLGL.State.defaultShaderId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4964 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4965 // Set default shader locations: attributes locations |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4966 RLGL.State.defaultShaderLocs[RL_SHADER_LOC_VERTEX_POSITION] = glGetAttribLocation(RLGL.State.defaultShaderId, RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4967 RLGL.State.defaultShaderLocs[RL_SHADER_LOC_VERTEX_TEXCOORD01] = glGetAttribLocation(RLGL.State.defaultShaderId, RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4968 RLGL.State.defaultShaderLocs[RL_SHADER_LOC_VERTEX_COLOR] = glGetAttribLocation(RLGL.State.defaultShaderId, RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4969 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4970 // Set default shader locations: uniform locations |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4971 RLGL.State.defaultShaderLocs[RL_SHADER_LOC_MATRIX_MVP] = glGetUniformLocation(RLGL.State.defaultShaderId, RL_DEFAULT_SHADER_UNIFORM_NAME_MVP); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4972 RLGL.State.defaultShaderLocs[RL_SHADER_LOC_COLOR_DIFFUSE] = glGetUniformLocation(RLGL.State.defaultShaderId, RL_DEFAULT_SHADER_UNIFORM_NAME_COLOR); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4973 RLGL.State.defaultShaderLocs[RL_SHADER_LOC_MAP_DIFFUSE] = glGetUniformLocation(RLGL.State.defaultShaderId, RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4974 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4975 else TRACELOG(RL_LOG_WARNING, "SHADER: [ID %i] Failed to load default shader", RLGL.State.defaultShaderId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4976 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4977 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4978 // Unload default shader |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4979 // NOTE: Unloads: RLGL.State.defaultShaderId, RLGL.State.defaultShaderLocs |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4980 static void rlUnloadShaderDefault(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4981 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4982 glUseProgram(0); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4983 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4984 glDetachShader(RLGL.State.defaultShaderId, RLGL.State.defaultVShaderId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4985 glDetachShader(RLGL.State.defaultShaderId, RLGL.State.defaultFShaderId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4986 glDeleteShader(RLGL.State.defaultVShaderId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4987 glDeleteShader(RLGL.State.defaultFShaderId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4988 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4989 glDeleteProgram(RLGL.State.defaultShaderId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4990 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4991 RL_FREE(RLGL.State.defaultShaderLocs); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4992 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4993 TRACELOG(RL_LOG_INFO, "SHADER: [ID %i] Default shader unloaded successfully", RLGL.State.defaultShaderId); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4994 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4995 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4996 #if defined(RLGL_SHOW_GL_DETAILS_INFO) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4997 // Get compressed format official GL identifier name |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4998 static const char *rlGetCompressedFormatName(int format) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4999 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5000 switch (format) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5001 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5002 // GL_EXT_texture_compression_s3tc |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5003 case 0x83F0: return "GL_COMPRESSED_RGB_S3TC_DXT1_EXT"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5004 case 0x83F1: return "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5005 case 0x83F2: return "GL_COMPRESSED_RGBA_S3TC_DXT3_EXT"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5006 case 0x83F3: return "GL_COMPRESSED_RGBA_S3TC_DXT5_EXT"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5007 // GL_3DFX_texture_compression_FXT1 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5008 case 0x86B0: return "GL_COMPRESSED_RGB_FXT1_3DFX"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5009 case 0x86B1: return "GL_COMPRESSED_RGBA_FXT1_3DFX"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5010 // GL_IMG_texture_compression_pvrtc |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5011 case 0x8C00: return "GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5012 case 0x8C01: return "GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5013 case 0x8C02: return "GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5014 case 0x8C03: return "GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5015 // GL_OES_compressed_ETC1_RGB8_texture |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5016 case 0x8D64: return "GL_ETC1_RGB8_OES"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5017 // GL_ARB_texture_compression_rgtc |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5018 case 0x8DBB: return "GL_COMPRESSED_RED_RGTC1"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5019 case 0x8DBC: return "GL_COMPRESSED_SIGNED_RED_RGTC1"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5020 case 0x8DBD: return "GL_COMPRESSED_RG_RGTC2"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5021 case 0x8DBE: return "GL_COMPRESSED_SIGNED_RG_RGTC2"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5022 // GL_ARB_texture_compression_bptc |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5023 case 0x8E8C: return "GL_COMPRESSED_RGBA_BPTC_UNORM_ARB"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5024 case 0x8E8D: return "GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5025 case 0x8E8E: return "GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5026 case 0x8E8F: return "GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5027 // GL_ARB_ES3_compatibility |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5028 case 0x9274: return "GL_COMPRESSED_RGB8_ETC2"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5029 case 0x9275: return "GL_COMPRESSED_SRGB8_ETC2"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5030 case 0x9276: return "GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5031 case 0x9277: return "GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5032 case 0x9278: return "GL_COMPRESSED_RGBA8_ETC2_EAC"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5033 case 0x9279: return "GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5034 case 0x9270: return "GL_COMPRESSED_R11_EAC"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5035 case 0x9271: return "GL_COMPRESSED_SIGNED_R11_EAC"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5036 case 0x9272: return "GL_COMPRESSED_RG11_EAC"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5037 case 0x9273: return "GL_COMPRESSED_SIGNED_RG11_EAC"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5038 // GL_KHR_texture_compression_astc_hdr |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5039 case 0x93B0: return "GL_COMPRESSED_RGBA_ASTC_4x4_KHR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5040 case 0x93B1: return "GL_COMPRESSED_RGBA_ASTC_5x4_KHR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5041 case 0x93B2: return "GL_COMPRESSED_RGBA_ASTC_5x5_KHR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5042 case 0x93B3: return "GL_COMPRESSED_RGBA_ASTC_6x5_KHR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5043 case 0x93B4: return "GL_COMPRESSED_RGBA_ASTC_6x6_KHR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5044 case 0x93B5: return "GL_COMPRESSED_RGBA_ASTC_8x5_KHR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5045 case 0x93B6: return "GL_COMPRESSED_RGBA_ASTC_8x6_KHR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5046 case 0x93B7: return "GL_COMPRESSED_RGBA_ASTC_8x8_KHR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5047 case 0x93B8: return "GL_COMPRESSED_RGBA_ASTC_10x5_KHR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5048 case 0x93B9: return "GL_COMPRESSED_RGBA_ASTC_10x6_KHR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5049 case 0x93BA: return "GL_COMPRESSED_RGBA_ASTC_10x8_KHR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5050 case 0x93BB: return "GL_COMPRESSED_RGBA_ASTC_10x10_KHR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5051 case 0x93BC: return "GL_COMPRESSED_RGBA_ASTC_12x10_KHR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5052 case 0x93BD: return "GL_COMPRESSED_RGBA_ASTC_12x12_KHR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5053 case 0x93D0: return "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5054 case 0x93D1: return "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5055 case 0x93D2: return "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5056 case 0x93D3: return "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5057 case 0x93D4: return "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5058 case 0x93D5: return "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5059 case 0x93D6: return "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5060 case 0x93D7: return "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5061 case 0x93D8: return "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5062 case 0x93D9: return "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5063 case 0x93DA: return "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5064 case 0x93DB: return "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5065 case 0x93DC: return "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5066 case 0x93DD: return "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5067 default: return "GL_COMPRESSED_UNKNOWN"; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5068 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5069 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5070 #endif // RLGL_SHOW_GL_DETAILS_INFO |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5071 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5072 #endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5073 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5074 // Get pixel data size in bytes (image or texture) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5075 // NOTE: Size depends on pixel format |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5076 static int rlGetPixelDataSize(int width, int height, int format) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5077 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5078 int dataSize = 0; // Size in bytes |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5079 int bpp = 0; // Bits per pixel |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5080 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5081 switch (format) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5082 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5083 case RL_PIXELFORMAT_UNCOMPRESSED_GRAYSCALE: bpp = 8; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5084 case RL_PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5085 case RL_PIXELFORMAT_UNCOMPRESSED_R5G6B5: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5086 case RL_PIXELFORMAT_UNCOMPRESSED_R5G5B5A1: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5087 case RL_PIXELFORMAT_UNCOMPRESSED_R4G4B4A4: bpp = 16; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5088 case RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8: bpp = 32; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5089 case RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8: bpp = 24; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5090 case RL_PIXELFORMAT_UNCOMPRESSED_R32: bpp = 32; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5091 case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32: bpp = 32*3; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5092 case RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32A32: bpp = 32*4; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5093 case RL_PIXELFORMAT_UNCOMPRESSED_R16: bpp = 16; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5094 case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16: bpp = 16*3; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5095 case RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16: bpp = 16*4; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5096 case RL_PIXELFORMAT_COMPRESSED_DXT1_RGB: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5097 case RL_PIXELFORMAT_COMPRESSED_DXT1_RGBA: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5098 case RL_PIXELFORMAT_COMPRESSED_ETC1_RGB: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5099 case RL_PIXELFORMAT_COMPRESSED_ETC2_RGB: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5100 case RL_PIXELFORMAT_COMPRESSED_PVRT_RGB: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5101 case RL_PIXELFORMAT_COMPRESSED_PVRT_RGBA: bpp = 4; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5102 case RL_PIXELFORMAT_COMPRESSED_DXT3_RGBA: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5103 case RL_PIXELFORMAT_COMPRESSED_DXT5_RGBA: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5104 case RL_PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA: |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5105 case RL_PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA: bpp = 8; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5106 case RL_PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA: bpp = 2; break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5107 default: break; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5108 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5109 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5110 double bytesPerPixel = (double)bpp/8.0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5111 dataSize = (int)(bytesPerPixel*width*height); // Total data size in bytes |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5112 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5113 // Most compressed formats works on 4x4 blocks, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5114 // if texture is smaller, minimum dataSize is 8 or 16 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5115 if ((width < 4) && (height < 4)) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5116 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5117 if ((format >= RL_PIXELFORMAT_COMPRESSED_DXT1_RGB) && (format < RL_PIXELFORMAT_COMPRESSED_DXT3_RGBA)) dataSize = 8; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5118 else if ((format >= RL_PIXELFORMAT_COMPRESSED_DXT3_RGBA) && (format < RL_PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA)) dataSize = 16; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5119 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5120 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5121 return dataSize; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5122 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5123 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5124 // Auxiliar math functions |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5125 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5126 // Get float array of matrix data |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5127 static rl_float16 rlMatrixToFloatV(Matrix mat) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5128 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5129 rl_float16 result = { 0 }; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5130 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5131 result.v[0] = mat.m0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5132 result.v[1] = mat.m1; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5133 result.v[2] = mat.m2; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5134 result.v[3] = mat.m3; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5135 result.v[4] = mat.m4; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5136 result.v[5] = mat.m5; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5137 result.v[6] = mat.m6; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5138 result.v[7] = mat.m7; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5139 result.v[8] = mat.m8; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5140 result.v[9] = mat.m9; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5141 result.v[10] = mat.m10; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5142 result.v[11] = mat.m11; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5143 result.v[12] = mat.m12; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5144 result.v[13] = mat.m13; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5145 result.v[14] = mat.m14; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5146 result.v[15] = mat.m15; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5147 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5148 return result; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5149 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5150 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5151 // Get identity matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5152 static Matrix rlMatrixIdentity(void) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5153 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5154 Matrix result = { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5155 1.0f, 0.0f, 0.0f, 0.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5156 0.0f, 1.0f, 0.0f, 0.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5157 0.0f, 0.0f, 1.0f, 0.0f, |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5158 0.0f, 0.0f, 0.0f, 1.0f |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5159 }; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5160 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5161 return result; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5162 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5163 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5164 // Get two matrix multiplication |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5165 // NOTE: When multiplying matrices... the order matters! |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5166 static Matrix rlMatrixMultiply(Matrix left, Matrix right) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5167 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5168 Matrix result = { 0 }; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5169 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5170 result.m0 = left.m0*right.m0 + left.m1*right.m4 + left.m2*right.m8 + left.m3*right.m12; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5171 result.m1 = left.m0*right.m1 + left.m1*right.m5 + left.m2*right.m9 + left.m3*right.m13; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5172 result.m2 = left.m0*right.m2 + left.m1*right.m6 + left.m2*right.m10 + left.m3*right.m14; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5173 result.m3 = left.m0*right.m3 + left.m1*right.m7 + left.m2*right.m11 + left.m3*right.m15; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5174 result.m4 = left.m4*right.m0 + left.m5*right.m4 + left.m6*right.m8 + left.m7*right.m12; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5175 result.m5 = left.m4*right.m1 + left.m5*right.m5 + left.m6*right.m9 + left.m7*right.m13; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5176 result.m6 = left.m4*right.m2 + left.m5*right.m6 + left.m6*right.m10 + left.m7*right.m14; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5177 result.m7 = left.m4*right.m3 + left.m5*right.m7 + left.m6*right.m11 + left.m7*right.m15; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5178 result.m8 = left.m8*right.m0 + left.m9*right.m4 + left.m10*right.m8 + left.m11*right.m12; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5179 result.m9 = left.m8*right.m1 + left.m9*right.m5 + left.m10*right.m9 + left.m11*right.m13; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5180 result.m10 = left.m8*right.m2 + left.m9*right.m6 + left.m10*right.m10 + left.m11*right.m14; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5181 result.m11 = left.m8*right.m3 + left.m9*right.m7 + left.m10*right.m11 + left.m11*right.m15; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5182 result.m12 = left.m12*right.m0 + left.m13*right.m4 + left.m14*right.m8 + left.m15*right.m12; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5183 result.m13 = left.m12*right.m1 + left.m13*right.m5 + left.m14*right.m9 + left.m15*right.m13; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5184 result.m14 = left.m12*right.m2 + left.m13*right.m6 + left.m14*right.m10 + left.m15*right.m14; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5185 result.m15 = left.m12*right.m3 + left.m13*right.m7 + left.m14*right.m11 + left.m15*right.m15; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5186 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5187 return result; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5188 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5189 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5190 // Transposes provided matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5191 static Matrix rlMatrixTranspose(Matrix mat) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5192 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5193 Matrix result = { 0 }; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5194 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5195 result.m0 = mat.m0; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5196 result.m1 = mat.m4; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5197 result.m2 = mat.m8; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5198 result.m3 = mat.m12; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5199 result.m4 = mat.m1; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5200 result.m5 = mat.m5; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5201 result.m6 = mat.m9; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5202 result.m7 = mat.m13; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5203 result.m8 = mat.m2; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5204 result.m9 = mat.m6; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5205 result.m10 = mat.m10; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5206 result.m11 = mat.m14; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5207 result.m12 = mat.m3; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5208 result.m13 = mat.m7; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5209 result.m14 = mat.m11; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5210 result.m15 = mat.m15; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5211 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5212 return result; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5213 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5214 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5215 // Invert provided matrix |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5216 static Matrix rlMatrixInvert(Matrix mat) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5217 { |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5218 Matrix result = { 0 }; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5219 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5220 // Cache the matrix values (speed optimization) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5221 float a00 = mat.m0, a01 = mat.m1, a02 = mat.m2, a03 = mat.m3; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5222 float a10 = mat.m4, a11 = mat.m5, a12 = mat.m6, a13 = mat.m7; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5223 float a20 = mat.m8, a21 = mat.m9, a22 = mat.m10, a23 = mat.m11; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5224 float a30 = mat.m12, a31 = mat.m13, a32 = mat.m14, a33 = mat.m15; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5225 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5226 float b00 = a00*a11 - a01*a10; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5227 float b01 = a00*a12 - a02*a10; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5228 float b02 = a00*a13 - a03*a10; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5229 float b03 = a01*a12 - a02*a11; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5230 float b04 = a01*a13 - a03*a11; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5231 float b05 = a02*a13 - a03*a12; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5232 float b06 = a20*a31 - a21*a30; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5233 float b07 = a20*a32 - a22*a30; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5234 float b08 = a20*a33 - a23*a30; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5235 float b09 = a21*a32 - a22*a31; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5236 float b10 = a21*a33 - a23*a31; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5237 float b11 = a22*a33 - a23*a32; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5238 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5239 // Calculate the invert determinant (inlined to avoid double-caching) |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5240 float invDet = 1.0f/(b00*b11 - b01*b10 + b02*b09 + b03*b08 - b04*b07 + b05*b06); |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5241 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5242 result.m0 = (a11*b11 - a12*b10 + a13*b09)*invDet; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5243 result.m1 = (-a01*b11 + a02*b10 - a03*b09)*invDet; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5244 result.m2 = (a31*b05 - a32*b04 + a33*b03)*invDet; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5245 result.m3 = (-a21*b05 + a22*b04 - a23*b03)*invDet; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5246 result.m4 = (-a10*b11 + a12*b08 - a13*b07)*invDet; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5247 result.m5 = (a00*b11 - a02*b08 + a03*b07)*invDet; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5248 result.m6 = (-a30*b05 + a32*b02 - a33*b01)*invDet; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5249 result.m7 = (a20*b05 - a22*b02 + a23*b01)*invDet; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5250 result.m8 = (a10*b10 - a11*b08 + a13*b06)*invDet; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5251 result.m9 = (-a00*b10 + a01*b08 - a03*b06)*invDet; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5252 result.m10 = (a30*b04 - a31*b02 + a33*b00)*invDet; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5253 result.m11 = (-a20*b04 + a21*b02 - a23*b00)*invDet; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5254 result.m12 = (-a10*b09 + a11*b07 - a12*b06)*invDet; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5255 result.m13 = (a00*b09 - a01*b07 + a02*b06)*invDet; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5256 result.m14 = (-a30*b03 + a31*b01 - a32*b00)*invDet; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5257 result.m15 = (a20*b03 - a21*b01 + a22*b00)*invDet; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5258 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5259 return result; |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5260 } |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5261 |
|
5695ef413be0
Initialized mono repo with bazels with few examples.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5262 #endif // RLGL_IMPLEMENTATION |